Skip to content

Commit a557fec

Browse files
committed
cleaning up PNode stuff
1 parent f72be6d commit a557fec

3 files changed

Lines changed: 768 additions & 1 deletion

File tree

core/.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry excluding="processing/core/PSmoothTriangle.java|processing/core/PGraphics3D.java|processing/core/PLine.java|processing/core/PTriangle.java|processing/core/PGraphics2D.java|processing/core/PPolygon.java" kind="src" path="src"/>
3+
<classpathentry kind="src" path="src"/>
44
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
55
<classpathentry kind="output" path="bin"/>
66
</classpath>
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2+
3+
/*
4+
Part of the Processing project - http://processing.org
5+
6+
Copyright (c) 2009-11 Ben Fry and Casey Reas
7+
8+
This library is free software; you can redistribute it and/or
9+
modify it under the terms of the GNU Lesser General Public
10+
License as published by the Free Software Foundation, version 2.
11+
12+
This library is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty
14+
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15+
See the GNU Lesser General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General
18+
Public License along with this library; if not, write to the
19+
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20+
Boston, MA 02111-1307 USA
21+
*/
22+
23+
package processing.core;
24+
25+
import java.io.*;
26+
27+
28+
/**
29+
* This is the base class used for the Processing XML library,
30+
* representing a single node of an XML tree.
31+
*/
32+
public interface PNode extends Serializable {
33+
34+
/**
35+
* Returns the parent element. This method returns null for the root
36+
* element.
37+
*/
38+
public PNode getParent();
39+
40+
41+
/**
42+
* Returns the full name (i.e. the name including an eventual namespace
43+
* prefix) of the element.
44+
* @return the name, or null if the element only contains #PCDATA.
45+
*/
46+
public String getName();
47+
48+
49+
/**
50+
* Returns the name of the element (without namespace prefix).
51+
* @return the name, or null if the element only contains #PCDATA.
52+
*/
53+
public String getLocalName();
54+
55+
56+
/**
57+
* Returns the number of children.
58+
* @return the count.
59+
*/
60+
public int getChildCount();
61+
62+
63+
/**
64+
* Put the names of all children into an array. Same as looping through
65+
* each child and calling getName() on each XMLElement.
66+
*/
67+
public String[] listChildren();
68+
69+
70+
/**
71+
* Returns an array containing all the child elements.
72+
*/
73+
public PNode[] getChildren();
74+
75+
76+
/**
77+
* Quick accessor for an element at a particular index.
78+
* @author processing.org
79+
*/
80+
public PNode getChild(int index);
81+
82+
83+
/**
84+
* Get a child by its name or path.
85+
* @param name element name or path/to/element
86+
* @return the first matching element
87+
*/
88+
public PNode getChild(String name);
89+
90+
91+
/**
92+
* Get any children that match this name or path. Similar to getChild(),
93+
* but will grab multiple matches rather than only the first.
94+
* @param name element name or path/to/element
95+
* @return array of child elements that match
96+
* @author processing.org
97+
*/
98+
public PNode[] getChildren(String name);
99+
100+
101+
/**
102+
* Returns the number of attributes.
103+
*/
104+
public int getAttributeCount();
105+
106+
107+
/**
108+
* Get a list of the names for all of the attributes for this node.
109+
*/
110+
public String[] listAttributes();
111+
112+
113+
/**
114+
* Returns whether an attribute exists.
115+
*/
116+
public boolean hasAttribute(String name);
117+
118+
119+
public String getString(String name);
120+
121+
122+
public String getString(String name, String defaultValue);
123+
124+
125+
public int getInt(String name);
126+
127+
128+
/**
129+
* Returns the value of an attribute.
130+
*
131+
* @param name the non-null full name of the attribute.
132+
* @param defaultValue the default value of the attribute.
133+
*
134+
* @return the value, or defaultValue if the attribute does not exist.
135+
*/
136+
public int getInt(String name, int defaultValue);
137+
138+
139+
/**
140+
* Returns the value of an attribute, or zero if not present.
141+
*/
142+
public float getFloat(String name);
143+
144+
145+
/**
146+
* Returns the value of an attribute.
147+
*
148+
* @param name the non-null full name of the attribute.
149+
* @param defaultValue the default value of the attribute.
150+
*
151+
* @return the value, or defaultValue if the attribute does not exist.
152+
*/
153+
public float getFloat(String name, float defaultValue);
154+
155+
156+
public double getDouble(String name);
157+
158+
159+
/**
160+
* Returns the value of an attribute.
161+
*
162+
* @param name the non-null full name of the attribute.
163+
* @param defaultValue the default value of the attribute.
164+
*
165+
* @return the value, or defaultValue if the attribute does not exist.
166+
*/
167+
public double getDouble(String name, double defaultValue);
168+
169+
170+
/**
171+
* Return the #PCDATA content of the element. If the element has a
172+
* combination of #PCDATA content and child elements, the #PCDATA
173+
* sections can be retrieved as unnamed child objects. In this case,
174+
* this method returns null.
175+
*
176+
* @return the content.
177+
*/
178+
public String getContent();
179+
180+
181+
public String toString();
182+
183+
184+
public String toString(boolean indent);
185+
}

0 commit comments

Comments
 (0)