You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2006/09/24 00:01:44 UTC
svn commit: r449313 - in /xerces/java/trunk/src/org/apache/html/dom:
HTMLBuilder.java HTMLDocumentImpl.java HTMLElementImpl.java
HTMLTableCellElementImpl.java HTMLTableRowElementImpl.java
Author: mrglavas
Date: Sat Sep 23 15:01:43 2006
New Revision: 449313
URL: http://svn.apache.org/viewvc?view=rev&rev=449313
Log:
JIRA Issue #1194
http://issues.apache.org/jira/browse/XERCESJ-1194
Various code cleanup. Patch thanks to Nathan Beyer.
Modified:
xerces/java/trunk/src/org/apache/html/dom/HTMLBuilder.java
xerces/java/trunk/src/org/apache/html/dom/HTMLDocumentImpl.java
xerces/java/trunk/src/org/apache/html/dom/HTMLElementImpl.java
xerces/java/trunk/src/org/apache/html/dom/HTMLTableCellElementImpl.java
xerces/java/trunk/src/org/apache/html/dom/HTMLTableRowElementImpl.java
Modified: xerces/java/trunk/src/org/apache/html/dom/HTMLBuilder.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/html/dom/HTMLBuilder.java?view=diff&rev=449313&r1=449312&r2=449313
==============================================================================
--- xerces/java/trunk/src/org/apache/html/dom/HTMLBuilder.java (original)
+++ xerces/java/trunk/src/org/apache/html/dom/HTMLBuilder.java Sat Sep 23 15:01:43 2006
@@ -52,17 +52,10 @@
/**
* The current node in the document into which elements, text and
- * other nodes will be inserted. This starts as the document iself
+ * other nodes will be inserted. This starts as the document itself
* and reflects each element that is currently being parsed.
*/
protected ElementImpl _current;
-
- /**
- * A reference to the current locator, this is generally the parser
- * itself. The locator is used to locate errors and identify the
- * source locations of elements.
- */
- private Locator _locator;
/**
@@ -195,9 +188,7 @@
public void ignorableWhitespace( char[] text, int start, int length )
throws SAXException
- {
- Node node;
-
+ {
if ( ! _ignoreWhitespace )
_current.appendChild( new TextImpl( _document, new String( text, start, length ) ) );
}
@@ -205,9 +196,7 @@
public void processingInstruction( String target, String instruction )
throws SAXException
- {
- Node node;
-
+ {
// Processing instruction may appear before the document element (in fact, before the
// document has been created, or after the document element has been closed.
if ( _current == null && _document == null )
@@ -226,13 +215,13 @@
public HTMLDocument getHTMLDocument()
{
- return (HTMLDocument) _document;
+ return _document;
}
public void setDocumentLocator( Locator locator )
{
- _locator = locator;
+ // ignored
}
Modified: xerces/java/trunk/src/org/apache/html/dom/HTMLDocumentImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/html/dom/HTMLDocumentImpl.java?view=diff&rev=449313&r1=449312&r2=449313
==============================================================================
--- xerces/java/trunk/src/org/apache/html/dom/HTMLDocumentImpl.java (original)
+++ xerces/java/trunk/src/org/apache/html/dom/HTMLDocumentImpl.java Sat Sep 23 15:01:43 2006
@@ -418,10 +418,10 @@
public final NodeList getElementsByTagNameNS( String namespaceURI,
String localName )
{
- if ( namespaceURI != null && namespaceURI.length() > 0 )
+ if ( namespaceURI != null && namespaceURI.length() > 0 ) {
return super.getElementsByTagNameNS( namespaceURI, localName.toUpperCase(Locale.ENGLISH) );
- else
- return super.getElementsByTagName( localName.toUpperCase(Locale.ENGLISH) );
+ }
+ return super.getElementsByTagName( localName.toUpperCase(Locale.ENGLISH) );
}
@@ -447,11 +447,10 @@
public Element createElementNS( String namespaceURI, String qualifiedName )
{
- if ( namespaceURI == null || namespaceURI.length() == 0 )
+ if ( namespaceURI == null || namespaceURI.length() == 0 ) {
return createElement( qualifiedName );
- else {
- return super.createElementNS( namespaceURI, qualifiedName );
}
+ return super.createElementNS( namespaceURI, qualifiedName );
}
@@ -478,15 +477,16 @@
}
catch ( Exception except )
{
+ /*
Throwable thrw;
if ( except instanceof java.lang.reflect.InvocationTargetException )
thrw = ( (java.lang.reflect.InvocationTargetException) except ).getTargetException();
else
thrw = except;
-// System.out.println( "Exception " + thrw.getClass().getName() );
-// System.out.println( thrw.getMessage() );
-
+ System.out.println( "Exception " + thrw.getClass().getName() );
+ System.out.println( thrw.getMessage() );
+ */
throw new IllegalStateException( "HTM15 Tag '" + tagName + "' associated with an Element class that failed to construct.\n" + tagName);
}
}
Modified: xerces/java/trunk/src/org/apache/html/dom/HTMLElementImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/html/dom/HTMLElementImpl.java?view=diff&rev=449313&r1=449312&r2=449313
==============================================================================
--- xerces/java/trunk/src/org/apache/html/dom/HTMLElementImpl.java (original)
+++ xerces/java/trunk/src/org/apache/html/dom/HTMLElementImpl.java Sat Sep 23 15:01:43 2006
@@ -55,72 +55,50 @@
* @param owner The owner HTML document
* @param tagName The element's tag name
*/
- public HTMLElementImpl( HTMLDocumentImpl owner, String tagName )
- {
+ public HTMLElementImpl( HTMLDocumentImpl owner, String tagName ) {
super( owner, tagName.toUpperCase(Locale.ENGLISH) );
}
-
- public String getId()
- {
+ public String getId() {
return getAttribute( "id" );
}
-
- public void setId( String id )
- {
+ public void setId( String id ) {
setAttribute( "id", id );
- }
+ }
-
- public String getTitle()
- {
+ public String getTitle() {
return getAttribute( "title" );
}
-
- public void setTitle( String title )
- {
+ public void setTitle( String title ) {
setAttribute( "title", title );
}
-
- public String getLang()
- {
+ public String getLang() {
return getAttribute( "lang" );
- }
+ }
-
- public void setLang( String lang )
- {
+ public void setLang( String lang ) {
setAttribute( "lang", lang );
}
-
- public String getDir()
- {
+ public String getDir() {
return getAttribute( "dir" );
}
-
- public void setDir( String dir )
- {
+ public void setDir( String dir ) {
setAttribute( "dir", dir );
}
-
-
- public String getClassName()
- {
+
+ public String getClassName() {
return getAttribute( "class" );
}
-
- public void setClassName( String className )
- {
+ public void setClassName( String className ) {
setAttribute( "class", className );
}
-
/**
* Convenience method used to translate an attribute value into an integer
* value. Returns the integer value or zero if the attribute is not a
@@ -129,19 +107,15 @@
* @param value The value of the attribute
* @return The integer value, or zero if not a valid numeric string
*/
- int getInteger( String value )
- {
- try
- {
+ int getInteger( String value ) {
+ try {
return Integer.parseInt( value );
}
- catch ( NumberFormatException except )
- {
+ catch ( NumberFormatException except ) {
return 0;
}
}
-
/**
* Convenience method used to translate an attribute value into a boolean
* value. If the attribute has an associated value (even an empty string),
@@ -151,12 +125,10 @@
* @param value The value of the attribute
* @return True or false depending on whether the attribute has been set
*/
- boolean getBinary( String name )
- {
+ boolean getBinary( String name ) {
return ( getAttributeNode( name ) != null );
}
-
/**
* Convenience method used to set a boolean attribute. If the value is true,
* the attribute is set to an empty string. If the value is false, the attribute
@@ -165,62 +137,50 @@
* @param name The name of the attribute
* @param value The value of the attribute
*/
- void setAttribute( String name, boolean value )
- {
- if ( value )
+ void setAttribute( String name, boolean value ) {
+ if ( value ) {
setAttribute( name, name );
- else
+ }
+ else {
removeAttribute( name );
+ }
}
-
- public Attr getAttributeNode( String attrName )
- {
- return super.getAttributeNode( attrName.toLowerCase(Locale.ENGLISH) );
+ public Attr getAttributeNode( String attrName ) {
+ return super.getAttributeNode( attrName.toLowerCase(Locale.ENGLISH) );
}
-
public Attr getAttributeNodeNS( String namespaceURI,
- String localName )
- {
- if ( namespaceURI != null && namespaceURI.length() > 0 )
- return super.getAttributeNodeNS( namespaceURI, localName );
- else
- return super.getAttributeNode( localName.toLowerCase(Locale.ENGLISH) );
+ String localName ) {
+ if ( namespaceURI != null && namespaceURI.length() > 0 ) {
+ return super.getAttributeNodeNS( namespaceURI, localName );
+ }
+ return super.getAttributeNode( localName.toLowerCase(Locale.ENGLISH) );
}
-
- public String getAttribute( String attrName )
- {
- return super.getAttribute( attrName.toLowerCase(Locale.ENGLISH) );
+ public String getAttribute( String attrName ) {
+ return super.getAttribute( attrName.toLowerCase(Locale.ENGLISH) );
}
-
public String getAttributeNS( String namespaceURI,
- String localName )
- {
- if ( namespaceURI != null && namespaceURI.length() > 0 )
- return super.getAttributeNS( namespaceURI, localName );
- else
- return super.getAttribute( localName.toLowerCase(Locale.ENGLISH) );
+ String localName ) {
+ if ( namespaceURI != null && namespaceURI.length() > 0 ) {
+ return super.getAttributeNS( namespaceURI, localName );
+ }
+ return super.getAttribute( localName.toLowerCase(Locale.ENGLISH) );
}
-
- public final NodeList getElementsByTagName( String tagName )
- {
- return super.getElementsByTagName( tagName.toUpperCase(Locale.ENGLISH) );
+ public final NodeList getElementsByTagName( String tagName ) {
+ return super.getElementsByTagName( tagName.toUpperCase(Locale.ENGLISH) );
}
-
public final NodeList getElementsByTagNameNS( String namespaceURI,
- String localName )
- {
- if ( namespaceURI != null && namespaceURI.length() > 0 )
- return super.getElementsByTagNameNS( namespaceURI, localName.toUpperCase(Locale.ENGLISH) );
- else
- return super.getElementsByTagName( localName.toUpperCase(Locale.ENGLISH) );
- }
-
+ String localName ) {
+ if ( namespaceURI != null && namespaceURI.length() > 0 ) {
+ return super.getElementsByTagNameNS( namespaceURI, localName.toUpperCase(Locale.ENGLISH) );
+ }
+ return super.getElementsByTagName( localName.toUpperCase(Locale.ENGLISH) );
+ }
/**
* Convenience method used to capitalize a one-off attribute value before it
@@ -230,25 +190,24 @@
* @param value The value of the attribute
* @return The capitalized value
*/
- String capitalize( String value )
- {
+ String capitalize( String value ) {
+
char[] chars;
int i;
// Convert string to charactares. Convert the first one to upper case,
// the other characters to lower case, and return the converted string.
chars = value.toCharArray();
- if ( chars.length > 0 )
- {
+ if ( chars.length > 0 ) {
chars[ 0 ] = Character.toUpperCase( chars[ 0 ] );
- for ( i = 1 ; i < chars.length ; ++i )
+ for ( i = 1 ; i < chars.length ; ++i ) {
chars[ i ] = Character.toLowerCase( chars[ i ] );
+ }
return String.valueOf( chars );
}
return value;
}
-
/**
* Convenience method used to capitalize a one-off attribute value before it
* is returned. For example, the align values "LEFT" and "left" will both
@@ -257,23 +216,21 @@
* @param name The name of the attribute
* @return The capitalized value
*/
- String getCapitalized( String name )
- {
+ String getCapitalized( String name ) {
String value;
char[] chars;
int i;
value = getAttribute( name );
- if ( value != null )
- {
+ if ( value != null ) {
// Convert string to charactares. Convert the first one to upper case,
// the other characters to lower case, and return the converted string.
chars = value.toCharArray();
- if ( chars.length > 0 )
- {
+ if ( chars.length > 0 ) {
chars[ 0 ] = Character.toUpperCase( chars[ 0 ] );
- for ( i = 1 ; i < chars.length ; ++i )
+ for ( i = 1 ; i < chars.length ; ++i ) {
chars[ i ] = Character.toLowerCase( chars[ i ] );
+ }
return String.valueOf( chars );
}
}
@@ -286,20 +243,15 @@
* This method is exposed for form elements through the DOM API, but other
* elements have no access to it through the API.
*/
- public HTMLFormElement getForm()
- {
- Node parent;
-
- parent = getParentNode();
- while ( parent != null )
- {
- if ( parent instanceof HTMLFormElement )
+ public HTMLFormElement getForm() {
+ Node parent = getParentNode();
+ while ( parent != null ) {
+ if ( parent instanceof HTMLFormElement ) {
return (HTMLFormElement) parent;
+ }
parent = parent.getParentNode();
}
return null;
}
-
}
-
Modified: xerces/java/trunk/src/org/apache/html/dom/HTMLTableCellElementImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/html/dom/HTMLTableCellElementImpl.java?view=diff&rev=449313&r1=449312&r2=449313
==============================================================================
--- xerces/java/trunk/src/org/apache/html/dom/HTMLTableCellElementImpl.java (original)
+++ xerces/java/trunk/src/org/apache/html/dom/HTMLTableCellElementImpl.java Sat Sep 23 15:01:43 2006
@@ -64,7 +64,6 @@
{
Node parent;
Node child;
- int index;
parent = getParentNode();
if ( parent instanceof HTMLTableRowElement )
Modified: xerces/java/trunk/src/org/apache/html/dom/HTMLTableRowElementImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/html/dom/HTMLTableRowElementImpl.java?view=diff&rev=449313&r1=449312&r2=449313
==============================================================================
--- xerces/java/trunk/src/org/apache/html/dom/HTMLTableRowElementImpl.java (original)
+++ xerces/java/trunk/src/org/apache/html/dom/HTMLTableRowElementImpl.java Sat Sep 23 15:01:43 2006
@@ -44,10 +44,12 @@
Node parent;
parent = getParentNode();
- if ( parent instanceof HTMLTableSectionElement )
+ if ( parent instanceof HTMLTableSectionElement ) {
parent = parent.getParentNode();
- if ( parent instanceof HTMLTableElement )
- return getRowIndex( parent );;
+ }
+ if ( parent instanceof HTMLTableElement ) {
+ return getRowIndex( parent );
+ }
return -1;
}
@@ -57,10 +59,12 @@
Node parent;
parent = getParentNode();
- if ( parent instanceof HTMLTableSectionElement )
+ if ( parent instanceof HTMLTableSectionElement ) {
parent = parent.getParentNode();
- if ( parent instanceof HTMLTableElement )
+ }
+ if ( parent instanceof HTMLTableElement ) {
( (HTMLTableElementImpl) parent ).insertRowX( rowIndex, this );
+ }
}
@@ -69,10 +73,10 @@
Node parent;
parent = getParentNode();
- if ( parent instanceof HTMLTableSectionElement )
+ if ( parent instanceof HTMLTableSectionElement ) {
return getRowIndex( parent );
- else
- return -1;
+ }
+ return -1;
}
@@ -81,8 +85,9 @@
Node parent;
parent = getParentNode();
- if ( parent instanceof HTMLTableSectionElement )
+ if ( parent instanceof HTMLTableSectionElement ) {
( (HTMLTableSectionElementImpl) parent ).insertRowX( sectionRowIndex, this );
+ }
}
@@ -95,17 +100,20 @@
// TR elements under the TABLE/section. Access to the returned NodeList
// is very fast and the snapshot solves many synchronization problems.
rows = ( (HTMLElement) parent ).getElementsByTagName( "TR" );
- for ( i = 0 ; i < rows.getLength() ; ++i )
- if ( rows.item( i ) == this )
+ for ( i = 0 ; i < rows.getLength() ; ++i ) {
+ if ( rows.item( i ) == this ) {
return i;
+ }
+ }
return -1;
}
public HTMLCollection getCells()
{
- if ( _cells == null )
+ if ( _cells == null ) {
_cells = new HTMLCollectionImpl( this, HTMLCollectionImpl.CELL );
+ }
return _cells;
}
@@ -116,15 +124,13 @@
int i;
child = getFirstChild();
- while ( child != null )
- {
+ while ( child != null ) {
removeChild( child );
child = child.getNextSibling();
}
i = 0;
child = cells.item( i );
- while ( child != null )
- {
+ while ( child != null ) {
appendChild ( child );
++i;
child = cells.item( i );
@@ -139,12 +145,9 @@
newCell = new HTMLTableCellElementImpl( (HTMLDocumentImpl) getOwnerDocument(), "TD" );
child = getFirstChild();
- while ( child != null )
- {
- if ( child instanceof HTMLTableCellElement )
- {
- if ( index == 0 )
- {
+ while ( child != null ) {
+ if ( child instanceof HTMLTableCellElement ) {
+ if ( index == 0 ) {
insertBefore( newCell, child );
return newCell;
}
@@ -162,12 +165,9 @@
Node child;
child = getFirstChild();
- while ( child != null )
- {
- if ( child instanceof HTMLTableCellElement )
- {
- if ( index == 0 )
- {
+ while ( child != null ) {
+ if ( child instanceof HTMLTableCellElement ) {
+ if ( index == 0 ) {
removeChild ( child );
return;
}
@@ -208,8 +208,9 @@
// Make sure that the access key is a single character.
ch = getAttribute( "char" );
- if ( ch != null && ch.length() > 1 )
+ if ( ch != null && ch.length() > 1 ) {
ch = ch.substring( 0, 1 );
+ }
return ch;
}
@@ -217,8 +218,9 @@
public void setCh( String ch )
{
// Make sure that the access key is a single character.
- if ( ch != null && ch.length() > 1 )
+ if ( ch != null && ch.length() > 1 ) {
ch = ch.substring( 0, 1 );
+ }
setAttribute( "char", ch );
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org