|
1 /* |
|
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
|
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.tools.internal.ws.wsdl.framework; |
|
27 |
|
28 import org.xml.sax.Locator; |
|
29 |
|
30 import java.util.HashMap; |
|
31 import java.util.Map; |
|
32 |
|
33 import com.sun.tools.internal.ws.wscompile.ErrorReceiver; |
|
34 |
|
35 /** |
|
36 * An entity, typically corresponding to an XML element. |
|
37 * |
|
38 * @author WS Development Team |
|
39 */ |
|
40 public abstract class Entity implements Elemental { |
|
41 |
|
42 private final Locator locator; |
|
43 protected ErrorReceiver errorReceiver; |
|
44 public Entity(Locator locator) { |
|
45 this.locator = locator; |
|
46 } |
|
47 |
|
48 public void setErrorReceiver(ErrorReceiver errorReceiver) { |
|
49 this.errorReceiver = errorReceiver; |
|
50 } |
|
51 |
|
52 public Locator getLocator() { |
|
53 return locator; |
|
54 } |
|
55 |
|
56 public Object getProperty(String key) { |
|
57 if (_properties == null) |
|
58 return null; |
|
59 return _properties.get(key); |
|
60 } |
|
61 |
|
62 public void setProperty(String key, Object value) { |
|
63 if (value == null) { |
|
64 removeProperty(key); |
|
65 return; |
|
66 } |
|
67 |
|
68 if (_properties == null) { |
|
69 _properties = new HashMap(); |
|
70 } |
|
71 _properties.put(key, value); |
|
72 } |
|
73 |
|
74 public void removeProperty(String key) { |
|
75 if (_properties != null) { |
|
76 _properties.remove(key); |
|
77 } |
|
78 } |
|
79 |
|
80 public void withAllSubEntitiesDo(EntityAction action) { |
|
81 // no-op by default |
|
82 } |
|
83 |
|
84 public void withAllQNamesDo(QNameAction action) { |
|
85 action.perform(getElementName()); |
|
86 } |
|
87 |
|
88 public void withAllEntityReferencesDo(EntityReferenceAction action) { |
|
89 // no-op by default |
|
90 } |
|
91 |
|
92 public abstract void validateThis(); |
|
93 |
|
94 protected void failValidation(String key) { |
|
95 throw new ValidationException(key, getElementName().getLocalPart()); |
|
96 } |
|
97 |
|
98 protected void failValidation(String key, String arg) { |
|
99 throw new ValidationException( |
|
100 key, |
|
101 new Object[] { arg, getElementName().getLocalPart()}); |
|
102 } |
|
103 |
|
104 private Map _properties; |
|
105 } |