author | joehw |
Wed, 18 Oct 2017 13:25:49 -0700 | |
changeset 47359 | e1a6c0168741 |
parent 47216 | 71c04702a3d5 |
child 48409 | 5ab69533994b |
permissions | -rw-r--r-- |
12005 | 1 |
/* |
47359
e1a6c0168741
8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
e1a6c0168741
8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents:
47216
diff
changeset
|
3 |
* @LastModified: Oct 2017 |
12005 | 4 |
*/ |
5 |
/* |
|
44797
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
6 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
7 |
* contributor license agreements. See the NOTICE file distributed with |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
8 |
* this work for additional information regarding copyright ownership. |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
9 |
* The ASF licenses this file to You under the Apache License, Version 2.0 |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
10 |
* (the "License"); you may not use this file except in compliance with |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
11 |
* the License. You may obtain a copy of the License at |
12005 | 12 |
* |
13 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
14 |
* |
|
15 |
* Unless required by applicable law or agreed to in writing, software |
|
16 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
17 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
18 |
* See the License for the specific language governing permissions and |
|
19 |
* limitations under the License. |
|
20 |
*/ |
|
21 |
||
22 |
package com.sun.org.apache.xerces.internal.impl.dv.xs; |
|
23 |
||
24 |
import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException; |
|
25 |
import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; |
|
26 |
import com.sun.org.apache.xerces.internal.xs.datatypes.ObjectList; |
|
47359
e1a6c0168741
8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents:
47216
diff
changeset
|
27 |
import java.util.AbstractList; |
12005 | 28 |
|
29 |
/** |
|
30 |
* Represent the schema list types |
|
31 |
* |
|
32 |
* @xerces.internal |
|
33 |
* |
|
34 |
* @author Neeraj Bajaj, Sun Microsystems, inc. |
|
35 |
* @author Sandy Gao, IBM |
|
36 |
* |
|
37 |
*/ |
|
38 |
public class ListDV extends TypeValidator{ |
|
39 |
||
40 |
public short getAllowedFacets(){ |
|
47359
e1a6c0168741
8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents:
47216
diff
changeset
|
41 |
return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | |
e1a6c0168741
8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents:
47216
diff
changeset
|
42 |
XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | |
e1a6c0168741
8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents:
47216
diff
changeset
|
43 |
XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE ); |
12005 | 44 |
} |
45 |
||
46 |
// this method should never be called: XSSimpleTypeDecl is responsible for |
|
47 |
// calling the item type for the convertion |
|
47359
e1a6c0168741
8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents:
47216
diff
changeset
|
48 |
public Object getActualValue(String content, ValidationContext context) |
e1a6c0168741
8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents:
47216
diff
changeset
|
49 |
throws InvalidDatatypeValueException{ |
12005 | 50 |
return content; |
51 |
} |
|
52 |
||
53 |
// length of a list type is the number of items in the list |
|
54 |
public int getDataLength(Object value) { |
|
55 |
return ((ListData)value).getLength(); |
|
56 |
} |
|
57 |
||
47359
e1a6c0168741
8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents:
47216
diff
changeset
|
58 |
final static class ListData extends AbstractList<Object> implements ObjectList { |
12005 | 59 |
final Object[] data; |
60 |
private String canonical; |
|
61 |
public ListData(Object[] data) { |
|
62 |
this.data = data; |
|
63 |
} |
|
64 |
public synchronized String toString() { |
|
65 |
if (canonical == null) { |
|
66 |
int len = data.length; |
|
67 |
StringBuffer buf = new StringBuffer(); |
|
68 |
if (len > 0) { |
|
69 |
buf.append(data[0].toString()); |
|
70 |
} |
|
71 |
for (int i = 1; i < len; i++) { |
|
72 |
buf.append(' '); |
|
73 |
buf.append(data[i].toString()); |
|
74 |
} |
|
75 |
canonical = buf.toString(); |
|
76 |
} |
|
77 |
return canonical; |
|
78 |
} |
|
79 |
public int getLength() { |
|
80 |
return data.length; |
|
81 |
} |
|
82 |
public boolean equals(Object obj) { |
|
83 |
if (!(obj instanceof ListData)) |
|
84 |
return false; |
|
85 |
Object[] odata = ((ListData)obj).data; |
|
86 |
||
87 |
int count = data.length; |
|
88 |
if (count != odata.length) |
|
89 |
return false; |
|
90 |
||
91 |
for (int i = 0 ; i < count ; i++) { |
|
92 |
if (!data[i].equals(odata[i])) |
|
93 |
return false; |
|
94 |
}//end of loop |
|
95 |
||
96 |
//everything went fine. |
|
97 |
return true; |
|
98 |
} |
|
99 |
||
100 |
public int hashCode() { |
|
101 |
int hash = 0; |
|
102 |
for (int i = 0; i < data.length; ++i) { |
|
103 |
hash ^= data[i].hashCode(); |
|
104 |
} |
|
105 |
return hash; |
|
106 |
} |
|
107 |
||
108 |
public boolean contains(Object item) { |
|
109 |
for (int i = 0;i < data.length; i++) { |
|
110 |
if (item == data[i]) { |
|
111 |
return true; |
|
112 |
} |
|
113 |
} |
|
114 |
return false; |
|
115 |
} |
|
116 |
||
117 |
public Object item(int index) { |
|
118 |
if (index < 0 || index >= data.length) { |
|
119 |
return null; |
|
120 |
} |
|
121 |
return data[index]; |
|
122 |
} |
|
123 |
||
124 |
/* |
|
125 |
* List methods |
|
126 |
*/ |
|
127 |
||
128 |
public Object get(int index) { |
|
129 |
if (index >= 0 && index < data.length) { |
|
130 |
return data[index]; |
|
131 |
} |
|
132 |
throw new IndexOutOfBoundsException("Index: " + index); |
|
133 |
} |
|
134 |
||
135 |
public int size() { |
|
136 |
return getLength(); |
|
137 |
} |
|
138 |
} |
|
139 |
} // class ListDV |