author | mkos |
Sun, 30 Dec 2012 00:00:00 +0100 | |
changeset 22678 | ac1ea46be942 |
parent 12009 | 4abb694f273a |
permissions | -rw-r--r-- |
12009 | 1 |
/* |
22678
ac1ea46be942
8029237: Update copyright year to match last edit in jaxws repository for 2012
mkos
parents:
12009
diff
changeset
|
2 |
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
12009 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package com.sun.xml.internal.xsom.util; |
|
27 |
||
28 |
import com.sun.xml.internal.xsom.XSAnnotation; |
|
29 |
import com.sun.xml.internal.xsom.XSAttGroupDecl; |
|
30 |
import com.sun.xml.internal.xsom.XSAttributeDecl; |
|
31 |
import com.sun.xml.internal.xsom.XSAttributeUse; |
|
32 |
import com.sun.xml.internal.xsom.XSComplexType; |
|
33 |
import com.sun.xml.internal.xsom.XSContentType; |
|
34 |
import com.sun.xml.internal.xsom.XSElementDecl; |
|
35 |
import com.sun.xml.internal.xsom.XSFacet; |
|
36 |
import com.sun.xml.internal.xsom.XSModelGroup; |
|
37 |
import com.sun.xml.internal.xsom.XSModelGroupDecl; |
|
38 |
import com.sun.xml.internal.xsom.XSNotation; |
|
39 |
import com.sun.xml.internal.xsom.XSParticle; |
|
40 |
import com.sun.xml.internal.xsom.XSSchema; |
|
41 |
import com.sun.xml.internal.xsom.XSSimpleType; |
|
42 |
import com.sun.xml.internal.xsom.XSWildcard; |
|
43 |
import com.sun.xml.internal.xsom.XSIdentityConstraint; |
|
44 |
import com.sun.xml.internal.xsom.XSXPath; |
|
45 |
import com.sun.xml.internal.xsom.visitor.XSFunction; |
|
46 |
||
47 |
/** |
|
48 |
* Extract the name of the components. |
|
49 |
* |
|
50 |
* @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li></ul> |
|
51 |
*/ |
|
52 |
public class ComponentNameFunction implements XSFunction<String> { |
|
53 |
||
54 |
// delegate to this object to get the localized name of the component type |
|
55 |
private NameGetter nameGetter = new NameGetter(null); |
|
56 |
||
57 |
/** |
|
58 |
* @see com.sun.xml.internal.xsom.visitor.XSFunction#annotation(XSAnnotation) |
|
59 |
*/ |
|
60 |
public String annotation(XSAnnotation ann) { |
|
61 |
// unnamed component |
|
62 |
return nameGetter.annotation( ann ); |
|
63 |
} |
|
64 |
||
65 |
/** |
|
66 |
* @see com.sun.xml.internal.xsom.visitor.XSFunction#attGroupDecl(XSAttGroupDecl) |
|
67 |
*/ |
|
68 |
public String attGroupDecl(XSAttGroupDecl decl) { |
|
69 |
String name = decl.getName(); |
|
70 |
if( name == null ) name = ""; |
|
71 |
return name + " " + nameGetter.attGroupDecl( decl ); |
|
72 |
} |
|
73 |
||
74 |
/** |
|
75 |
* @see com.sun.xml.internal.xsom.visitor.XSFunction#attributeDecl(XSAttributeDecl) |
|
76 |
*/ |
|
77 |
public String attributeDecl(XSAttributeDecl decl) { |
|
78 |
String name = decl.getName(); |
|
79 |
if( name == null ) name = ""; |
|
80 |
return name + " " + nameGetter.attributeDecl( decl ); |
|
81 |
} |
|
82 |
||
83 |
/** |
|
84 |
* @see com.sun.xml.internal.xsom.visitor.XSFunction#attributeUse(XSAttributeUse) |
|
85 |
*/ |
|
86 |
public String attributeUse(XSAttributeUse use) { |
|
87 |
// unnamed component |
|
88 |
return nameGetter.attributeUse( use ); |
|
89 |
} |
|
90 |
||
91 |
/** |
|
92 |
* @see com.sun.xml.internal.xsom.visitor.XSFunction#complexType(XSComplexType) |
|
93 |
*/ |
|
94 |
public String complexType(XSComplexType type) { |
|
95 |
String name = type.getName(); |
|
96 |
if( name == null ) name = "anonymous"; |
|
97 |
return name + " " + nameGetter.complexType( type ); |
|
98 |
} |
|
99 |
||
100 |
/** |
|
101 |
* @see com.sun.xml.internal.xsom.visitor.XSFunction#schema(XSSchema) |
|
102 |
*/ |
|
103 |
public String schema(XSSchema schema) { |
|
104 |
return nameGetter.schema( schema ) + " \"" + schema.getTargetNamespace()+"\""; |
|
105 |
} |
|
106 |
||
107 |
/** |
|
108 |
* @see com.sun.xml.internal.xsom.visitor.XSFunction#facet(XSFacet) |
|
109 |
*/ |
|
110 |
public String facet(XSFacet facet) { |
|
111 |
String name = facet.getName(); |
|
112 |
if( name == null ) name = ""; |
|
113 |
return name + " " + nameGetter.facet( facet ); |
|
114 |
} |
|
115 |
||
116 |
/** |
|
117 |
* @see com.sun.xml.internal.xsom.visitor.XSFunction#notation(XSNotation) |
|
118 |
*/ |
|
119 |
public String notation(XSNotation notation) { |
|
120 |
String name = notation.getName(); |
|
121 |
if( name == null ) name = ""; |
|
122 |
return name + " " + nameGetter.notation( notation ); |
|
123 |
} |
|
124 |
||
125 |
/** |
|
126 |
* @see com.sun.xml.internal.xsom.visitor.XSContentTypeFunction#simpleType(XSSimpleType) |
|
127 |
*/ |
|
128 |
public String simpleType(XSSimpleType simpleType) { |
|
129 |
String name = simpleType.getName(); |
|
130 |
if( name == null ) name = "anonymous"; |
|
131 |
return name + " " + nameGetter.simpleType( simpleType ); |
|
132 |
} |
|
133 |
||
134 |
/** |
|
135 |
* @see com.sun.xml.internal.xsom.visitor.XSContentTypeFunction#particle(XSParticle) |
|
136 |
*/ |
|
137 |
public String particle(XSParticle particle) { |
|
138 |
// unnamed component |
|
139 |
return nameGetter.particle( particle ); |
|
140 |
} |
|
141 |
||
142 |
/** |
|
143 |
* @see com.sun.xml.internal.xsom.visitor.XSContentTypeFunction#empty(XSContentType) |
|
144 |
*/ |
|
145 |
public String empty(XSContentType empty) { |
|
146 |
// unnamed component |
|
147 |
return nameGetter.empty( empty ); |
|
148 |
} |
|
149 |
||
150 |
/** |
|
151 |
* @see com.sun.xml.internal.xsom.visitor.XSTermFunction#wildcard(XSWildcard) |
|
152 |
*/ |
|
153 |
public String wildcard(XSWildcard wc) { |
|
154 |
// unnamed component |
|
155 |
return nameGetter.wildcard( wc ); |
|
156 |
} |
|
157 |
||
158 |
/** |
|
159 |
* @see com.sun.xml.internal.xsom.visitor.XSTermFunction#modelGroupDecl(XSModelGroupDecl) |
|
160 |
*/ |
|
161 |
public String modelGroupDecl(XSModelGroupDecl decl) { |
|
162 |
String name = decl.getName(); |
|
163 |
if( name == null ) name = ""; |
|
164 |
return name + " " + nameGetter.modelGroupDecl( decl ); |
|
165 |
} |
|
166 |
||
167 |
/** |
|
168 |
* @see com.sun.xml.internal.xsom.visitor.XSTermFunction#modelGroup(XSModelGroup) |
|
169 |
*/ |
|
170 |
public String modelGroup(XSModelGroup group) { |
|
171 |
// unnamed component |
|
172 |
return nameGetter.modelGroup( group ); |
|
173 |
} |
|
174 |
||
175 |
/** |
|
176 |
* @see com.sun.xml.internal.xsom.visitor.XSTermFunction#elementDecl(XSElementDecl) |
|
177 |
*/ |
|
178 |
public String elementDecl(XSElementDecl decl) { |
|
179 |
String name = decl.getName(); |
|
180 |
if( name == null ) name = ""; |
|
181 |
return name + " " + nameGetter.elementDecl( decl ); |
|
182 |
} |
|
183 |
||
184 |
public String identityConstraint(XSIdentityConstraint decl) { |
|
185 |
return decl.getName()+" "+nameGetter.identityConstraint(decl); |
|
186 |
} |
|
187 |
||
188 |
public String xpath(XSXPath xpath) { |
|
189 |
return nameGetter.xpath(xpath); |
|
190 |
} |
|
191 |
} |