perfsonar-dev - Datum Class
Subject: perfsonar development work
List archive
- From: "Ivan K. Koga" <>
- To: Loukik Kudarimoti <>
- Cc:
- Subject: Datum Class
- Date: Mon, 14 Aug 2006 11:31:16 -0300
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:content-type; b=JMTjXQhQ/O0ZucJ259vHFSV0kV1l41emKpAQK+bDtFIqsGyf4HHrrZPfwuYfc9Rb9EobimB5+Uz0Om/35mIitWB9WtDLiWNQo+P4U2x9+570t4BuM87aCDq2S0QTnJ+r3G857nULAhIdC4jf8ZhSQ4vyO2LZbADTKnmRoFJDtZ8=
Hi Loukik,
See attached the Datum class that I modified for MA-AMP.
I donĀ“t know if I did it correctly... So, I want to know what I did wrong and how to correct it.
Regards,
Ivan Koga
/** * This describes the datum format of a amp delay measurement. * * @author Ivan Koji Koga * @version $Id: Datum.java 143 2006-08-02 16:18:29 +3 $ * @see org.ggf.ns.nmwg.base.v2_0.Element * @see org.ggf.ns.nmwg.base.v2_0.Datum * @see org.ggf.ns.nmwg.time.v2_0.Time * @see org.w3c.dom.Document * @see org.w3c.dom.Element */ package org.ggf.ns.nmwg.tools.maamp; import org.xml.sax.ContentHandler; import org.xml.sax.helpers.AttributesImpl; import org.ggf.ns.nmwg.base.v2_0.Element; import org.ggf.ns.nmwg.time.v2_0.Time; import org.xml.sax.helpers.NamespaceSupport; public class Datum extends org.ggf.ns.nmwg.base.v2_0.Datum { /** * attribute for delay value */ protected String delayvalue; /** * The constructor initializes the variables and * sets xml element information (when applicable). */ public Datum() { delayvalue=""; localName = "datum"; uri = "http://ggf.org/ns/nmwg/tools/maamp"; qName = "maamp:datum"; prefix = "maamp"; fileName = "org/ggf/ns/nmwg/tools/maamp/Datum.java"; } /** * Returns the value of the sDate attribute. * @return */ public String getDelayValue() { return delayvalue; } /** * Sets the sDate attribute * @param date */ public void setDelayValue(String ndelayvalue) { delayvalue = ndelayvalue; } /** * Sets attributes, it is important to note that we * access the underlying NMWG Datum information from the * base. */ public boolean addAttr(String attr, String value, NamespaceSupport nss) { /* if(attr.equals("value")) { setValue(value); } else if(attr.equals("valueUnits")) { setValueUnits(value); } else if(attr.equals("numBytes")) { setNumBytes(value); } else if(attr.equals("numBytesUnits")) { setNumBytesUnits(value); } else if(attr.equals("timeType")) { setTimeType(value); } else if(attr.equals("timeValue")) { setTimeValue(value); } else */ if(attr.equals("delayvalue")) { setDelayValue(value); } else if(attr.indexOf("xmlns") >= 0) { if(attr.split(":").length == 1) { if(nss.getURI("") == null) { nss.declarePrefix("", value); } if((prefix.equals("")) && !(value.equals(uri))) { uri = value; } } else { if(nss.getURI(attr.split(":")[1]) == null) { nss.declarePrefix(attr.split(":")[1], value); } if((prefix.equals(attr.split(":")[1])) && !(value.equals(uri))) { uri = value; } } } else { System.err.println("Error: " + getFileName() + " addAttr(String, String, NamespaceSupport) unrecognized attribute pair: " + attr + " - " + value); return false; } return true; } /** * The only allowable child for a datum element is the * time. */ public boolean addChild(Element newChild) { if(newChild.getLocalName().equals("time")) { setTime((Time)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 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(); } } catch(Exception e) { System.err.println("Error: " + getFileName() + " toXML(ContentHandler, NamespaceSupport) XML formulation error."); } return handler; } /** * Converts items into attributes for an xml tag. */ public AttributesImpl getAttributes(NamespaceSupport nss) { AttributesImpl atts = new AttributesImpl(); /*if(!(getValue().equals(""))) { atts.addAttribute(getUri(), "value", "value", "CDATA", getValue()); } if(!(getValueUnits().equals(""))) { atts.addAttribute(getUri(), "valueUnits", "valueUnits", "CDATA", getValueUnits()); } if(!(getNumBytes().equals(""))) { atts.addAttribute(getUri(), "numBytes", "numBytes", "CDATA", getNumBytes()); } if(!(getNumBytesUnits().equals(""))) { atts.addAttribute(getUri(), "numBytesUnits", "numBytesUnits", "CDATA", getNumBytesUnits()); } if(!(getTimeType().equals(""))) { atts.addAttribute(getUri(), "timeType", "timeType", "CDATA", getTimeType()); } if(!(getTimeValue().equals(""))) { atts.addAttribute(getUri(), "timeValue", "timeValue", "CDATA", getTimeValue()); } if(!(getSeqNum().equals(""))) { atts.addAttribute(getUri(), "seqNum", "seqNum", "CDATA", getSeqNum()); } if(!(getTTL().equals(""))) { atts.addAttribute(getUri(), "ttl", "ttl", "CDATA", getTTL()); }*/ if(!(getDelayValue().equals(""))) { atts.addAttribute(getUri(), "delayvalue", "delayvalue", "CDATA", getDelayValue()); } 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(); } return atts; } /** * Chases children references down to print out all related xml tags. */ public ContentHandler getChildren(ContentHandler handler, NamespaceSupport nss) throws Exception { if(getTime() != null) { handler = getTime().toXML(handler, nss); } return handler; } /** * 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 datum = doc.createElement(getLocalName()); datum = doc.createElementNS(getUri(), getQName()); parent.appendChild(datum); /* if(!(getValue().equals(""))) { datum.setAttribute("value", getValue()); } if(!(getValueUnits().equals(""))) { datum.setAttribute("valueUnits", getValueUnits()); } if(!(getTimeType().equals(""))) { datum.setAttribute("timeType", getTimeType()); } if(!(getTimeValue().equals(""))) { datum.setAttribute("timeValue", getTimeValue()); } if(!(getNumBytes().equals(""))) { datum.setAttribute("numBytes", getNumBytes()); } if(!(getNumBytesUnits().equals(""))) { datum.setAttribute("numBytesUnits", getNumBytesUnits()); } if(!(getSeqNum().equals(""))) { datum.setAttribute("seqNum", getSeqNum()); } if(!(getTTL().equals(""))) { datum.setAttribute("ttl", getTTL()); }*/ if(!(getDelayValue().equals(""))) { datum.setAttribute("delayvalue", getDelayValue()); } if(getTime() != null) { getTime().getDOM(datum); } } /** * Called when the object is placed in * an output statement. */ public String toString() { return getFileName() + ": ---> " + getValue() + /*" seqNum:" + getSeqNum() + " numBytes:" + getNumBytes() + " numBytesUnits:" + getNumBytesUnits() + " ttl:" + getTTL() + " valueUnits:" + getValueUnits()+ */ "delayvalue" + getDelayValue() + " timeType:" + getTimeType() + " timeValue:" + getTimeValue() + getTime(); } }
- Datum Class, Ivan K. Koga, 08/14/2006
- Re: Datum Class, Loukik Kudarimoti, 08/14/2006
- Re: [pS-dev] Datum Class, Jason Zurawski, 08/14/2006
- Re: [pS-dev] Datum Class, Ivan K. Koga, 08/16/2006
- Re: [pS-dev] Datum Class, Jason Zurawski, 08/16/2006
- Re: [pS-dev] Datum Class, Ivan K. Koga, 08/16/2006
- Re: [pS-dev] Datum Class, Jason Zurawski, 08/16/2006
- Re: [pS-dev] Datum Class, Jeff W. Boote, 08/16/2006
- Re: [pS-dev] Datum Class, Ivan K. Koga, 08/18/2006
- Re: [pS-dev] Datum Class, Jason Zurawski, 08/18/2006
- Re: [pS-dev] Datum Class, Jeff W. Boote, 08/18/2006
- Re: [pS-dev] Datum Class, Jeff W. Boote, 08/16/2006
- Re: [pS-dev] Datum Class, Jason Zurawski, 08/16/2006
- Re: [pS-dev] Datum Class, Ivan K. Koga, 08/16/2006
- Re: [pS-dev] Datum Class, Jason Zurawski, 08/16/2006
- Re: [pS-dev] Datum Class, Ivan K. Koga, 08/16/2006
Archive powered by MHonArc 2.6.16.