< 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()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad
*** 626,637 ****
if (localName == null) {
throw new XMLStreamException("Local name cannot be null");
}
if (!fIsRepairingNamespace) {
! if (prefix == null || prefix.equals("")){
! if (!namespaceURI.equals("")) {
throw new XMLStreamException("prefix cannot be null or empty");
} else {
writeAttributeWithPrefix(null, localName, value);
return;
}
--- 626,637 ----
if (localName == null) {
throw new XMLStreamException("Local name cannot be null");
}
if (!fIsRepairingNamespace) {
! if (prefix == null || prefix.isEmpty()){
! if (!namespaceURI.isEmpty()) {
throw new XMLStreamException("prefix cannot be null or empty");
} else {
writeAttributeWithPrefix(null, localName, value);
return;
}
*** 906,916 ****
if (elem.isEmpty) {
//fWriter.write(CLOSE_EMPTY_ELEMENT);
} else {
fWriter.write(OPEN_END_TAG);
! if ((elem.prefix != null) && !(elem.prefix).equals("")) {
fWriter.write(elem.prefix);
fWriter.write(":");
}
fWriter.write(elem.localpart);
--- 906,916 ----
if (elem.isEmpty) {
//fWriter.write(CLOSE_EMPTY_ELEMENT);
} else {
fWriter.write(OPEN_END_TAG);
! if ((elem.prefix != null) && !(elem.prefix).isEmpty()) {
fWriter.write(elem.prefix);
fWriter.write(":");
}
fWriter.write(elem.localpart);
*** 943,953 ****
}
fWriter.write(OPEN_END_TAG);
if ((currentElement.prefix != null) &&
! !(currentElement.prefix).equals("")) {
fWriter.write(currentElement.prefix);
fWriter.write(":");
}
fWriter.write(currentElement.localpart);
--- 943,953 ----
}
fWriter.write(OPEN_END_TAG);
if ((currentElement.prefix != null) &&
! !(currentElement.prefix).isEmpty()) {
fWriter.write(currentElement.prefix);
fWriter.write(":");
}
fWriter.write(currentElement.localpart);
*** 1178,1200 ****
fWriter.write(DEFAULT_XMLDECL);
return;
}
// Verify the encoding before writing anything
! if (encoding != null && !encoding.equals("")) {
verifyEncoding(encoding);
}
fWriter.write("<?xml version=\"");
! if ((version == null) || version.equals("")) {
fWriter.write(DEFAULT_XML_VERSION);
} else {
fWriter.write(version);
}
! if (encoding != null && !encoding.equals("")) {
fWriter.write("\" encoding=\"");
fWriter.write(encoding);
}
if (standaloneSet) {
--- 1178,1200 ----
fWriter.write(DEFAULT_XMLDECL);
return;
}
// Verify the encoding before writing anything
! if (encoding != null && !encoding.isEmpty()) {
verifyEncoding(encoding);
}
fWriter.write("<?xml version=\"");
! if ((version == null) || version.isEmpty()) {
fWriter.write(DEFAULT_XML_VERSION);
} else {
fWriter.write(version);
}
! if (encoding != null && !encoding.isEmpty()) {
fWriter.write("\" encoding=\"");
fWriter.write(encoding);
}
if (standaloneSet) {
*** 1582,1592 ****
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("") ) {
String tmp = fInternalNamespaceContext.getPrefix(attr.uri);
if ((tmp == null) || (!tmp.equals(attr.prefix))) {
tmp = getAttrPrefix(attr.uri);
if (tmp == null) {
--- 1582,1592 ----
for (int j = 0; j < fAttributeCache.size(); j++) {
attr = fAttributeCache.get(j);
if ((attr.prefix != null) && (attr.uri != null)) {
! 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,1781 ****
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(""))) {
correctPrefix(currentElement,attr);
}
}
if (!isDeclared(currentElement)) {
if ((currentElement.prefix != null) &&
(currentElement.uri != null)) {
! if ((!currentElement.prefix.equals("")) && (!currentElement.uri.equals(""))) {
fNamespaceDecls.add(currentElement);
}
}
}
--- 1763,1781 ----
ElementState currentElement = fElementStack.peek();
removeDuplicateDecls();
for(int i=0 ; i< fAttributeCache.size();i++){
attr = fAttributeCache.get(i);
! 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.isEmpty()) && (!currentElement.uri.isEmpty())) {
fNamespaceDecls.add(currentElement);
}
}
}
*** 1796,1806 ****
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("")){
repairNamespaceDecl(attr);
}
}
QName qname = null;
--- 1796,1806 ----
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.isEmpty() && attr.uri != null && attr.uri.isEmpty()){
repairNamespaceDecl(attr);
}
}
QName qname = null;
< prev index next >