summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen/cgram/TNode.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-07-03 16:06:47 +0200
committerSven Gothel <[email protected]>2014-07-03 16:06:47 +0200
commitdf9ff7f340a5ab4e07efc613f5f264eeae63d4c7 (patch)
tree239ae276b82024b140428e6c0fe5d739fdd686a4 /src/java/com/jogamp/gluegen/cgram/TNode.java
parenteb47aaba63e3b1bf55f274a0f338f1010a017ae4 (diff)
Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74)
Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74) - Change non static accesses to static members using declaring type - Change indirect accesses to static members to direct accesses (accesses through subtypes) - Add final modifier to private fields - Add final modifier to method parameters - Add final modifier to local variables - Remove unnecessary casts - Remove unnecessary '$NON-NLS$' tags - Remove trailing white spaces on all lines
Diffstat (limited to 'src/java/com/jogamp/gluegen/cgram/TNode.java')
-rw-r--r--src/java/com/jogamp/gluegen/cgram/TNode.java88
1 files changed, 44 insertions, 44 deletions
diff --git a/src/java/com/jogamp/gluegen/cgram/TNode.java b/src/java/com/jogamp/gluegen/cgram/TNode.java
index 2840d01..a564c54 100644
--- a/src/java/com/jogamp/gluegen/cgram/TNode.java
+++ b/src/java/com/jogamp/gluegen/cgram/TNode.java
@@ -46,14 +46,14 @@ public class TNode extends CommonAST {
/** Set the token vocabulary to a tokentypes class
generated by antlr.
*/
- public static void setTokenVocabulary(String s) {
+ public static void setTokenVocabulary(final String s) {
tokenVocabulary = s;
}
@Override
-public void initialize(Token token) {
- CToken tok = (CToken) token;
+public void initialize(final Token token) {
+ final CToken tok = (CToken) token;
setText(tok.getText());
setType(tok.getType());
setLineNum(tok.getLine());
@@ -61,8 +61,8 @@ public void initialize(Token token) {
setAttribute("tokenNumber", new Integer(tok.getTokenNumber()));
}
@Override
-public void initialize(AST tr) {
- TNode t = (TNode) tr;
+public void initialize(final AST tr) {
+ final TNode t = (TNode) tr;
setText(t.getText());
setType(t.getType());
setLineNum(t.getLineNum());
@@ -77,7 +77,7 @@ public void initialize(AST tr) {
/** Set the token type for this node */
@Override
- public void setType(int ttype_) {
+ public void setType(final int ttype_) {
ttype = ttype_;
}
@@ -89,7 +89,7 @@ public void initialize(AST tr) {
/** Set the marker value for this node.
This property is a general-use boolean marker.
*/
- public void setMarker(boolean marker_) {
+ public void setMarker(final boolean marker_) {
marker = marker_;
}
@@ -103,7 +103,7 @@ public void initialize(AST tr) {
/** set an attribute in the attribute table.
*/
- public void setAttribute(String attrName, Object value) {
+ public void setAttribute(final String attrName, final Object value) {
if(attributes == null)
attributes = new Hashtable<String, Object>(7);
attributes.put(attrName,value);
@@ -112,7 +112,7 @@ public void initialize(AST tr) {
/** lookup the attribute name in the attribute table.
If the value does not exist, it returns null.
*/
- public Object getAttribute(String attrName) {
+ public Object getAttribute(final String attrName) {
if(attributes == null)
return null;
else
@@ -145,7 +145,7 @@ public void initialize(AST tr) {
}
/** Set the line number for this node */
- public void setLineNum(int lineNum_) {
+ public void setLineNum(final int lineNum_) {
lineNum = lineNum_;
}
@@ -155,13 +155,13 @@ public void initialize(AST tr) {
/** Set the token text for this node */
@Override
- public void setText(String text_) {
+ public void setText(final String text_) {
text = text_;
}
/** Returns the text for this node and all children */
public String getAllChildrenText() {
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append(getText());
for (TNode node = (TNode) getFirstChild(); node != null; node = (TNode) node.getNextSibling()) {
buf.append(node.getText());
@@ -171,7 +171,7 @@ public void initialize(AST tr) {
/** return the last child of this node, or null if there is none */
public TNode getLastChild() {
- TNode down = (TNode)getFirstChild();
+ final TNode down = (TNode)getFirstChild();
if(down != null)
return down.getLastSibling();
else
@@ -181,7 +181,7 @@ public void initialize(AST tr) {
/** return the last sibling of this node, which is
this if the next sibling is null */
public TNode getLastSibling() {
- TNode next = (TNode)getNextSibling();
+ final TNode next = (TNode)getNextSibling();
if(next != null)
return next.getLastSibling();
else
@@ -191,7 +191,7 @@ public void initialize(AST tr) {
/** return the first sibling of this node, which is
this if the prev sibling is null */
public TNode getFirstSibling() {
- TNode prev = left;
+ final TNode prev = left;
if(prev != null)
return prev.getFirstSibling();
else
@@ -210,12 +210,12 @@ public void initialize(AST tr) {
if node is null, nothing happens. If the node has siblings,
then they are added in as well.
*/
- public void addSibling(AST node) {
+ public void addSibling(final AST node) {
if(node == null) return;
- TNode next = (TNode)right;
+ final TNode next = (TNode)right;
right = (TNode)node;
((TNode)node).left = this;
- TNode nodeLastSib = ((TNode)node).getLastSibling();
+ final TNode nodeLastSib = ((TNode)node).getLastSibling();
nodeLastSib.right = next;
if(next != null)
next.left = nodeLastSib;
@@ -237,9 +237,9 @@ public void initialize(AST tr) {
/** remove this node from the tree, resetting sibling and parent
pointers as necessary. This method maintains double-linking */
public void removeSelf() {
- TNode parent = up;
- TNode prev = left;
- TNode next = (TNode)right;
+ final TNode parent = up;
+ final TNode prev = left;
+ final TNode next = (TNode)right;
if(parent != null) {
parent.down = next;
@@ -263,7 +263,7 @@ public void initialize(AST tr) {
}
/** set the def node for this node */
- public void setDefNode(TNode n) {
+ public void setDefNode(final TNode n) {
defNode = n;
}
@@ -273,7 +273,7 @@ public void initialize(AST tr) {
Marker value is not copied!
*/
public TNode deepCopy() {
- TNode copy = new TNode();
+ final TNode copy = new TNode();
copy.ttype = ttype;
copy.text = text;
copy.lineNum = lineNum;
@@ -292,7 +292,7 @@ public void initialize(AST tr) {
New tree is doubleLinked, with no parent or left siblings.
defNode is not copied */
public TNode deepCopyWithRightSiblings() {
- TNode copy = new TNode();
+ final TNode copy = new TNode();
copy.ttype = ttype;
copy.text = text;
copy.lineNum = lineNum;
@@ -311,15 +311,15 @@ public void initialize(AST tr) {
/** return a short string representation of the node */
@Override
public String toString() {
- StringBuilder str = new StringBuilder( getNameForType(getType()) +
+ final StringBuilder str = new StringBuilder( getNameForType(getType()) +
"[" + getText() + ", " + "]");
if(this.getLineNum() != 0)
str.append(" line:" + (this.getLineNum() ) );
- Enumeration<String> keys = (this.getAttributesTable().keys());
+ final Enumeration<String> keys = (this.getAttributesTable().keys());
while (keys.hasMoreElements()) {
- String key = keys.nextElement();
+ final String key = keys.nextElement();
str.append(" " + key + ":" + (this.getAttribute(key)));
}
@@ -328,7 +328,7 @@ public void initialize(AST tr) {
/** print given tree to System.out */
- public static void printTree(AST t) {
+ public static void printTree(final AST t) {
if (t == null) return;
printASTNode(t,0);
System.out.print("\n");
@@ -336,7 +336,7 @@ public void initialize(AST tr) {
/** protected method that does the work of printing */
- protected static void printASTNode(AST t, int indent) {
+ protected static void printASTNode(final AST t, final int indent) {
AST child1, next;
child1 = t.getFirstChild();
@@ -347,7 +347,7 @@ public void initialize(AST tr) {
if(child1 != null)
System.out.print("(");
- String s = t.getText();
+ final String s = t.getText();
if(s != null && s.length() > 0) {
System.out.print(getNameForType(t.getType()));
System.out.print(": \"" + s + "\"");
@@ -357,12 +357,12 @@ public void initialize(AST tr) {
if(((TNode)t).getLineNum() != 0)
System.out.print(" line:" + ((TNode)t).getLineNum() );
- Enumeration<String> keys = ((TNode)t).getAttributesTable().keys();
+ final Enumeration<String> keys = ((TNode)t).getAttributesTable().keys();
while (keys.hasMoreElements()) {
- String key = keys.nextElement();
+ final String key = keys.nextElement();
System.out.print(" " + key + ":" + ((TNode)t).getAttribute(key));
}
- TNode def = ((TNode)t).getDefNode();
+ final TNode def = ((TNode)t).getDefNode();
if(def != null)
System.out.print("[" + getNameForType(def.getType()) + "]");
@@ -385,13 +385,13 @@ public void initialize(AST tr) {
/** converts an int tree token type to a name.
Does this by reflecting on nsdidl.IDLTreeTokenTypes,
and is dependent on how ANTLR 2.00 outputs that class. */
- public static String getNameForType(int t) {
+ public static String getNameForType(final int t) {
try{
- Class<?> c = Class.forName(tokenVocabulary);
- Field[] fields = c.getDeclaredFields();
+ final Class<?> c = Class.forName(tokenVocabulary);
+ final Field[] fields = c.getDeclaredFields();
if(t-2 < fields.length)
return fields[t-2].getName();
- } catch (Exception e) { System.out.println(e); }
+ } catch (final Exception e) { System.out.println(e); }
return "unfoundtype: " + t;
}
@@ -399,12 +399,12 @@ public void initialize(AST tr) {
/** set up reverse links between this node and its first
child and its first sibling, and link those as well */
public void doubleLink() {
- TNode right = (TNode)getNextSibling();
+ final TNode right = (TNode)getNextSibling();
if(right != null) {
right.left = this;
right.doubleLink();
}
- TNode down = (TNode)getFirstChild();
+ final TNode down = (TNode)getFirstChild();
if(down != null) {
down.up = this;
down.doubleLink();
@@ -413,7 +413,7 @@ public void initialize(AST tr) {
/** find first parent of the given type,
return null on failure */
- public TNode parentOfType(int type) {
+ public TNode parentOfType(final int type) {
if(up == null) {
if(left == null)
return null;
@@ -427,8 +427,8 @@ public void initialize(AST tr) {
/** find the first child of the node
of the given type, return null on failure */
- public TNode firstChildOfType(int type) {
- TNode down = (TNode)getFirstChild();
+ public TNode firstChildOfType(final int type) {
+ final TNode down = (TNode)getFirstChild();
if(down == null)
return null;
if(down.getType() == type)
@@ -438,8 +438,8 @@ public void initialize(AST tr) {
/** find the first sibling of the node
of the given type, return null on failure */
- public TNode firstSiblingOfType(int type) {
- TNode right = (TNode)getNextSibling();
+ public TNode firstSiblingOfType(final int type) {
+ final TNode right = (TNode)getNextSibling();
if(right == null)
return null;
if(right.getType() == type)