1 /****************************************************************
2 * Licensed to the Apache Software Foundation (ASF) under one *
3 * or more contributor license agreements. See the NOTICE file *
4 * distributed with this work for additional information *
5 * regarding copyright ownership. The ASF licenses this file *
6 * to you under the Apache License, Version 2.0 (the *
7 * "License"); you may not use this file except in compliance *
8 * with the License. You may obtain a copy of the License at *
9 * *
10 * http://www.apache.org/licenses/LICENSE-2.0 *
11 * *
12 * Unless required by applicable law or agreed to in writing, *
13 * software distributed under the License is distributed on an *
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
15 * KIND, either express or implied. See the License for the *
16 * specific language governing permissions and limitations *
17 * under the License. *
18 ****************************************************************/
19
20 package org.apache.jsieve.comparators;
21
22 import org.apache.jsieve.exception.SievePatternException;
23
24 /**
25 * Class AsciiCasemap implements the EQUALITY operation of the i;ascii-casemap
26 * comparator as defined by RFC2244, section 3.4 - "With this function the
27 * values "hello" and "HELLO" have the same ordinal value and are considered
28 * equal".
29 */
30 public class AsciiCasemap implements Comparator {
31
32 /**
33 * Constructor for AsciiCasemap.
34 */
35 public AsciiCasemap() {
36 super();
37 }
38
39 /**
40 * @see org.apache.jsieve.comparators.Equals#equals(String, String)
41 */
42 public boolean equals(String string1, String string2) {
43 return ComparatorUtils.equals(string1.toUpperCase(), string2
44 .toUpperCase());
45 }
46
47 /**
48 * @see org.apache.jsieve.comparators.Contains#contains(String, String)
49 */
50 public boolean contains(String container, String content) {
51 return ComparatorUtils.contains(container.toUpperCase(), content
52 .toUpperCase());
53 }
54
55 /**
56 * @see org.apache.jsieve.comparators.Matches#matches(String, String)
57 */
58 public boolean matches(String string, String glob)
59 throws SievePatternException {
60 return ComparatorUtils
61 .matches(string.toUpperCase(), glob.toUpperCase());
62 }
63
64 }