Skip to content

Commit 555fa3b

Browse files
committed
revised OXM package: no provider-specific exceptions anymore, etc
1 parent 866ee11 commit 555fa3b

File tree

71 files changed

+1476
-2570
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1476
-2570
lines changed

org.springframework.core/src/main/java/org/springframework/util/Md5HashUtils.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,8 +31,7 @@ public abstract class Md5HashUtils {
3131
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
3232

3333
/**
34-
* Calculates the MD5 hash of the given bytes.
35-
*
34+
* Calculate the MD5 hash of the given bytes.
3635
* @param bytes the bytes to calculate the hash over
3736
* @return the hash
3837
*/
@@ -59,8 +58,7 @@ private static char[] getHashChars(byte[] bytes) {
5958
}
6059

6160
/**
62-
* Returns a hex string representation of the MD5 hash of the given bytes.
63-
*
61+
* Return a hex string representation of the MD5 hash of the given bytes.
6462
* @param bytes the bytes to calculate the hash over
6563
* @return a hexadecimal hash string
6664
*/
@@ -69,9 +67,8 @@ public static String getHashString(byte[] bytes) {
6967
}
7068

7169
/**
72-
* Appends a hex string representation of the MD5 hash of the given bytes to the given {@link StringBuilder}.
73-
*
74-
* @param bytes the bytes to calculate the hash over
70+
* Append a hex string representation of the MD5 hash of the given bytes to the given {@link StringBuilder}.
71+
* @param bytes the bytes to calculate the hash over
7572
* @param builder the string builder to append the hash to
7673
* @return the given string builder
7774
*/

org.springframework.core/src/main/java/org/springframework/util/xml/AbstractStaxXMLReader.java

Lines changed: 53 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
* Abstract base class for SAX <code>XMLReader</code> implementations that use StAX as a basis.
3535
*
3636
* @author Arjen Poutsma
37+
* @since 3.0
3738
* @see #setContentHandler(org.xml.sax.ContentHandler)
3839
* @see #setDTDHandler(org.xml.sax.DTDHandler)
3940
* @see #setEntityResolver(org.xml.sax.EntityResolver)
4041
* @see #setErrorHandler(org.xml.sax.ErrorHandler)
41-
* @since 3.0
4242
*/
4343
abstract class AbstractStaxXMLReader extends AbstractXMLReader {
4444

@@ -48,23 +48,25 @@ abstract class AbstractStaxXMLReader extends AbstractXMLReader {
4848

4949
private static final String IS_STANDALONE_FEATURE_NAME = "http://xml.org/sax/features/is-standalone";
5050

51+
5152
private boolean namespacesFeature = true;
5253

5354
private boolean namespacePrefixesFeature = false;
5455

5556
private Boolean isStandalone;
5657

58+
5759
@Override
5860
public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
5961
if (NAMESPACES_FEATURE_NAME.equals(name)) {
60-
return namespacesFeature;
62+
return this.namespacesFeature;
6163
}
6264
else if (NAMESPACE_PREFIXES_FEATURE_NAME.equals(name)) {
63-
return namespacePrefixesFeature;
65+
return this.namespacePrefixesFeature;
6466
}
6567
else if (IS_STANDALONE_FEATURE_NAME.equals(name)) {
66-
if (isStandalone != null) {
67-
return isStandalone;
68+
if (this.isStandalone != null) {
69+
return this.isStandalone;
6870
}
6971
else {
7072
throw new SAXNotSupportedException("startDocument() callback not completed yet");
@@ -88,35 +90,66 @@ else if (NAMESPACE_PREFIXES_FEATURE_NAME.equals(name)) {
8890
}
8991
}
9092

91-
/** Indicates whether the SAX feature <code>http://xml.org/sax/features/namespaces</code> is turned on. */
93+
protected void setStandalone(boolean standalone) {
94+
this.isStandalone = standalone;
95+
}
96+
97+
/**
98+
* Indicates whether the SAX feature <code>http://xml.org/sax/features/namespaces</code> is turned on.
99+
*/
92100
protected boolean hasNamespacesFeature() {
93-
return namespacesFeature;
101+
return this.namespacesFeature;
94102
}
95103

96-
/** Indicates whether the SAX feature <code>http://xml.org/sax/features/namespaces-prefixes</code> is turned on. */
104+
/**
105+
* Indicates whether the SAX feature <code>http://xml.org/sax/features/namespaces-prefixes</code> is turned on.
106+
*/
97107
protected boolean hasNamespacePrefixesFeature() {
98-
return namespacePrefixesFeature;
108+
return this.namespacePrefixesFeature;
99109
}
100110

101-
protected void setStandalone(boolean standalone) {
102-
isStandalone = (standalone) ? Boolean.TRUE : Boolean.FALSE;
111+
/**
112+
* Sett the SAX <code>Locator</code> based on the given StAX <code>Location</code>.
113+
* @param location the location
114+
* @see ContentHandler#setDocumentLocator(org.xml.sax.Locator)
115+
*/
116+
protected void setLocator(Location location) {
117+
if (getContentHandler() != null) {
118+
getContentHandler().setDocumentLocator(new StaxLocator(location));
119+
}
120+
}
121+
122+
/**
123+
* Convert a <code>QName</code> to a qualified name, as used by DOM and SAX.
124+
* The returned string has a format of <code>prefix:localName</code> if the
125+
* prefix is set, or just <code>localName</code> if not.
126+
* @param qName the <code>QName</code>
127+
* @return the qualified name
128+
*/
129+
protected String toQualifiedName(QName qName) {
130+
String prefix = qName.getPrefix();
131+
if (!StringUtils.hasLength(prefix)) {
132+
return qName.getLocalPart();
133+
}
134+
else {
135+
return prefix + ":" + qName.getLocalPart();
136+
}
103137
}
104138

139+
105140
/**
106-
* Parses the StAX XML reader passed at construction-time. <p/> <strong>Note</strong> that the given
107-
* <code>InputSource</code> is not read, but ignored.
108-
*
141+
* Parse the StAX XML reader passed at construction-time.
142+
* <p><b>NOTE:</b>: The given <code>InputSource</code> is not read, but ignored.
109143
* @param ignored is ignored
110-
* @throws SAXException A SAX exception, possibly wrapping a <code>XMLStreamException</code>
144+
* @throws SAXException a SAX exception, possibly wrapping a <code>XMLStreamException</code>
111145
*/
112146
public final void parse(InputSource ignored) throws SAXException {
113147
parse();
114148
}
115149

116150
/**
117-
* Parses the StAX XML reader passed at construction-time. <p/> <strong>Note</strong> that the given system identifier
118-
* is not read, but ignored.
119-
*
151+
* Parse the StAX XML reader passed at construction-time.
152+
* <p><b>NOTE:</b>: The given system identifier is not read, but ignored.
120153
* @param ignored is ignored
121154
* @throws SAXException A SAX exception, possibly wrapping a <code>XMLStreamException</code>
122155
*/
@@ -144,40 +177,13 @@ private void parse() throws SAXException {
144177
}
145178

146179
/**
147-
* Sets the SAX <code>Locator</code> based on the given StAX <code>Location</code>.
148-
*
149-
* @param location the location
150-
* @see ContentHandler#setDocumentLocator(org.xml.sax.Locator)
180+
* Template-method that parses the StAX reader passed at construction-time.
151181
*/
152-
protected void setLocator(Location location) {
153-
if (getContentHandler() != null) {
154-
getContentHandler().setDocumentLocator(new StaxLocator(location));
155-
}
156-
}
157-
158-
/** Template-method that parses the StAX reader passed at construction-time. */
159182
protected abstract void parseInternal() throws SAXException, XMLStreamException;
160183

161-
/**
162-
* Convert a <code>QName</code> to a qualified name, as used by DOM and SAX. The returned string has a format of
163-
* <code>prefix:localName</code> if the prefix is set, or just <code>localName</code> if not.
164-
*
165-
* @param qName the <code>QName</code>
166-
* @return the qualified name
167-
*/
168-
protected String toQualifiedName(QName qName) {
169-
String prefix = qName.getPrefix();
170-
if (!StringUtils.hasLength(prefix)) {
171-
return qName.getLocalPart();
172-
}
173-
else {
174-
return prefix + ":" + qName.getLocalPart();
175-
}
176-
}
177184

178185
/**
179186
* Implementation of the <code>Locator</code> interface that is based on a StAX <code>Location</code>.
180-
*
181187
* @see Locator
182188
* @see Location
183189
*/
@@ -205,4 +211,5 @@ public int getColumnNumber() {
205211
return location.getColumnNumber();
206212
}
207213
}
214+
208215
}

org.springframework.core/src/main/java/org/springframework/util/xml/JaxpVersion.java

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)