Skip to Content.
Sympa Menu

perfsonar-dev - nmwg: r356 - trunk/nmwg/java/org/ogf/schema/network/topology/l3/v20070707

Subject: perfsonar development work

List archive

nmwg: r356 - trunk/nmwg/java/org/ogf/schema/network/topology/l3/v20070707


Chronological Thread 
  • From:
  • To: ,
  • Subject: nmwg: r356 - trunk/nmwg/java/org/ogf/schema/network/topology/l3/v20070707
  • Date: Thu, 29 May 2008 07:44:17 -0400

Author: mac
Date: 2008-05-29 07:44:17 -0400 (Thu, 29 May 2008)
New Revision: 356

Modified:
trunk/nmwg/java/org/ogf/schema/network/topology/l3/v20070707/Subnet.java
Log:
Rewritten. Change subnet to handle address and netmask


Modified:
trunk/nmwg/java/org/ogf/schema/network/topology/l3/v20070707/Subnet.java
===================================================================
--- trunk/nmwg/java/org/ogf/schema/network/topology/l3/v20070707/Subnet.java
2008-05-29 08:57:26 UTC (rev 355)
+++ trunk/nmwg/java/org/ogf/schema/network/topology/l3/v20070707/Subnet.java
2008-05-29 11:44:17 UTC (rev 356)
@@ -10,15 +10,33 @@
*/
package org.ogf.schema.network.topology.l3.v20070707;

+import org.ggf.ns.nmwg.base.v2_0.Element;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.helpers.AttributesImpl;
+import org.xml.sax.helpers.NamespaceSupport;

-public class Subnet extends org.ggf.ns.nmwg.topology.l3.v3_0.Subnet {

+public class Subnet extends Element {
+/*
+
+ <nmtl3:subnet>
+ <nmtl3:address type="ipv4">212.191.224.0</nmtl3:address>
+ <nmtl3:netmask>24</nmtl3:netmask>
+ </nmtl3:subnet>
+ */
+
+ protected Address address;
+
+ protected Netmask netmask;
+
+
/**
* Constructor.
*/
public Subnet() {
super();
- subnet = "";
+ address = null;
+ netmask = null;

parent = null;
id = "";
@@ -31,21 +49,146 @@
fileName =
"org/ogf/schema/network/topology/l3/v20070707/Subnet.java";
}

+
+
+ public Address getAddress() {
+
+ return address;
+ }
+
+
+
+ public void setAddress(Address address) {
+
+ this.address = address;
+ }
+
+
+
+ public Netmask getNetmask() {
+
+ return netmask;
+ }
+
+
+
+ public void setNetmask(Netmask netmask) {
+
+ this.netmask = netmask;
+ }
+
+
/**
- * The text element is the value of this element.
+ * Add only children related to the link.
+ */
+ public boolean addChild(Element newChild) {
+ if(newChild.getLocalName().equals("address")) {
+ setAddress((Address)newChild);
+ }
+ else if(newChild.getLocalName().equals("netmask")) {
+ setNetmask((Netmask)newChild);
+ }
+ else {
+ System.err.println("Error: " + getFileName() + "
addChild(Element) unrecognized child: " + newChild);
+ return false;
+ }
+ return true;
+ }
+
+
+ /**
+ * Converts the contents of this object into an xml tag.
*/
- public boolean addText(String text) {
- String clean = text.trim();
- if(!(clean.equals(""))) {
- setSubnet(clean);
- return true;
+ public ContentHandler toXML(ContentHandler handler, NamespaceSupport
nss) throws Exception {
+ try {
+ handler.startElement(getUri(), getLocalName(), getQName(),
getAttributes(nss));
+ handler = getChildren(handler, nss);
+ handler.endElement(getUri(), getLocalName(), getQName());
+
+ if(getCompleted()) {
+ nss.popContext();
+ unSetCompleted();
+ }
}
- return false;
-// else {
-// System.err.println("Error: " + getFileName() + " authRealm
can't have a witespace value.");
-// }
-// return false;
+ catch(Exception e) {
+ System.err.println("Error: " + getFileName() + "
toXML(ContentHandler, NamespaceSupport) XML formulation error.");
+ }
+ return handler;
}

+ /**
+ * Chases children references down to pring out all related xml tags.
+ */
+ public ContentHandler getChildren(ContentHandler handler,
NamespaceSupport nss) throws Exception {
+
+ if(getAddress() != null) {
+ handler = getAddress().toXML(handler, nss);
+ }
+ if(getNetmask() != null) {
+ handler = getNetmask().toXML(handler, nss);
+ }
+
+ return handler;
+ }

+ /**
+ * Converts items into attributes for an xml tag.
+ */
+ public AttributesImpl getAttributes(NamespaceSupport nss) {
+ AttributesImpl atts = new AttributesImpl();
+
+ if(nss.getURI(getPrefix()) == null) {
+ nss.pushContext();
+ if(getPrefix().equals("")) {
+ atts.addAttribute(getUri(), "xmlns", "xmlns", "CDATA",
getUri());
+ }
+ else {
+ atts.addAttribute(getUri(), "xmlns:" + getPrefix(), "xmlns:"
+ getPrefix(), "CDATA", getUri());
+ }
+ nss.declarePrefix(getPrefix(), getUri());
+ setCompleted();
+ }
+// if(!(getId().equals(""))) {
+// atts.addAttribute(getUri(), "id", "id", "CDATA", getId());
+// }
+
+ return atts;
+ }
+
+ /**
+ * Given a DOM element (a parent), construct
+ * the children elements.
+ */
+ public void getDOM(org.w3c.dom.Element parent) {
+
+ org.w3c.dom.Document doc = parent.getOwnerDocument();
+ org.w3c.dom.Element network = doc.createElementNS(getUri(),
getQName());
+ parent.appendChild(network);
+
+ if(!(getId().equals(""))) {
+ network.setAttribute("id", getId());
+ }
+
+ if(getAddress() != null) {
+ getAddress().getDOM(network);
+ }
+ if(getNetmask() != null) {
+ getNetmask().getDOM(network);
+ }
+
+ }
+
+
+
+ @Override
+ public String toString() {
+
+ String s = super.toString() +
+ ", address: "+getAddress() +
+ ", netmask: "+getNetmask() ;
+ return s;
+ }
+
+
+
}



  • nmwg: r356 - trunk/nmwg/java/org/ogf/schema/network/topology/l3/v20070707, svnlog, 05/29/2008

Archive powered by MHonArc 2.6.16.

Top of Page