< prev index next >
src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java
Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
@@ -626,12 +626,12 @@
if (localName == null) {
throw new XMLStreamException("Local name cannot be null");
}
if (!fIsRepairingNamespace) {
- if (prefix == null || prefix.equals("")){
- if (!namespaceURI.equals("")) {
+ if (prefix == null || prefix.isEmpty()){
+ if (!namespaceURI.isEmpty()) {
throw new XMLStreamException("prefix cannot be null or empty");
} else {
writeAttributeWithPrefix(null, localName, value);
return;
}
@@ -906,11 +906,11 @@
if (elem.isEmpty) {
//fWriter.write(CLOSE_EMPTY_ELEMENT);
} else {
fWriter.write(OPEN_END_TAG);
- if ((elem.prefix != null) && !(elem.prefix).equals("")) {
+ if ((elem.prefix != null) && !(elem.prefix).isEmpty()) {
fWriter.write(elem.prefix);
fWriter.write(":");
}
fWriter.write(elem.localpart);
@@ -943,11 +943,11 @@
}
fWriter.write(OPEN_END_TAG);
if ((currentElement.prefix != null) &&
- !(currentElement.prefix).equals("")) {
+ !(currentElement.prefix).isEmpty()) {
fWriter.write(currentElement.prefix);
fWriter.write(":");
}
fWriter.write(currentElement.localpart);
@@ -1178,23 +1178,23 @@
fWriter.write(DEFAULT_XMLDECL);
return;
}
// Verify the encoding before writing anything
- if (encoding != null && !encoding.equals("")) {
+ if (encoding != null && !encoding.isEmpty()) {
verifyEncoding(encoding);
}
fWriter.write("<?xml version=\"");
- if ((version == null) || version.equals("")) {
+ if ((version == null) || version.isEmpty()) {
fWriter.write(DEFAULT_XML_VERSION);
} else {
fWriter.write(version);
}
- if (encoding != null && !encoding.equals("")) {
+ if (encoding != null && !encoding.isEmpty()) {
fWriter.write("\" encoding=\"");
fWriter.write(encoding);
}
if (standaloneSet) {
@@ -1582,11 +1582,11 @@
for (int j = 0; j < fAttributeCache.size(); j++) {
attr = fAttributeCache.get(j);
if ((attr.prefix != null) && (attr.uri != null)) {
- if (!attr.prefix.equals("") && !attr.uri.equals("") ) {
+ if (!attr.prefix.isEmpty() && !attr.uri.isEmpty() ) {
String tmp = fInternalNamespaceContext.getPrefix(attr.uri);
if ((tmp == null) || (!tmp.equals(attr.prefix))) {
tmp = getAttrPrefix(attr.uri);
if (tmp == null) {
@@ -1763,19 +1763,19 @@
ElementState currentElement = fElementStack.peek();
removeDuplicateDecls();
for(int i=0 ; i< fAttributeCache.size();i++){
attr = fAttributeCache.get(i);
- if((attr.prefix != null && !attr.prefix.equals("")) || (attr.uri != null && !attr.uri.equals(""))) {
+ if((attr.prefix != null && !attr.prefix.isEmpty()) || (attr.uri != null && !attr.uri.isEmpty())) {
correctPrefix(currentElement,attr);
}
}
if (!isDeclared(currentElement)) {
if ((currentElement.prefix != null) &&
(currentElement.uri != null)) {
- if ((!currentElement.prefix.equals("")) && (!currentElement.uri.equals(""))) {
+ if ((!currentElement.prefix.isEmpty()) && (!currentElement.uri.isEmpty())) {
fNamespaceDecls.add(currentElement);
}
}
}
@@ -1796,11 +1796,11 @@
for (i = 0; i < fAttributeCache.size(); i++) {
attr = fAttributeCache.get(i);
/* If 'attr' is an attribute and it is in no namespace(which means that prefix="", uri=""), attr's
namespace should not be redinded. See [http://www.w3.org/TR/REC-xml-names/#defaulting].
*/
- if (attr.prefix != null && attr.prefix.equals("") && attr.uri != null && attr.uri.equals("")){
+ if (attr.prefix != null && attr.prefix.isEmpty() && attr.uri != null && attr.uri.isEmpty()){
repairNamespaceDecl(attr);
}
}
QName qname = null;
< prev index next >