perfsonar-dev - Re: [pS-dev] Datum Class
Subject: perfsonar development work
List archive
- From: "Ivan K. Koga" <>
- To: "Jeff W. Boote" <>
- Cc: ,
- Subject: Re: [pS-dev] Datum Class
- Date: Tue, 22 Aug 2006 08:29:40 -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:references:in-reply-to:content-type:content-transfer-encoding; b=GodEvGwYKF/BNXC2ZQgdBX72v5VXdsfYXqNn/+jW4YMy0l7WESnCXgLcvjTv/Eqap6J84DGKzPRGYMeVGKMKUWq0dGbit4haxT/PRrkZHoDVYeQcZSycK7OPs0h5RawMR6hbKtp5iBjoMUONh2LWVG/u4SSBTdKfPO4CHQinzkI=
Jeff W. Boote escreveu:
Ivan, Just as an aside... Have you noticed that the AMP project seems to have run out of funding? It is on their home page:I don´t know exactly what will happen with the AMP project.In the AMP home page they are saying that will disable the machines and collection.
http://amp.nlanr.net/
Will you guys try and work something out with SDSC to keep your data feeds running?
But the AMPlet code is available and can be installed in other machines and networks. That´s what we did here in RNP.
The amplet code is disponibilized here: http://amp.nlanr.net/Software/AMP/
Ivan K. Koga wrote:
Hi all,
I am sending attached the new XML. I just change the parameter´s names to srcCommonname and dstCommonname.
I think the XML representation are Ok now.
Looks fine to me.
Jason - is "unix" time assumed if nothing is specified? I'm specifically talking about the 'select' parameters startTime/endTime. If you wanted to use a different timeType to specify them, how would you do that?
What is next?
I modified a little the Datum removing some attributes that is not used in the AMP-MA schema. But I don´t know if it is enough...
You should not be modifying the nmwg datum class directly. You should be sub-classing from it. See some of the other sub-classes for examples. javadoc will help you find them all, but here are a few of them:
org.ggf.ns.nmwg.characteristic.utilization.v2_0.Datum
org.ggf.ns.nmwg.tools.iperf.v2_0.Datum
org.ggf.ns.nmwg.tools.ping.v2_0.Datum
org.ggf.ns.nmwg.tools.traceroute.v2_0.Datum
jeff
Jeff W. Boote escreveu:
Jason Zurawski wrote:
Ivan;
The name of the source or destinations are just internal descritive parameters. They are not imposed to be common, but it is reasonably that it is the same if the host is the same. (Ex: one machine is named amp-unifacs in a amp measurement point and could be named amp-unifacs2 in another measurement point).
Jeff, Do you suggest to make change in this:
yes.
<amp:parameters id="param1">
<nmwg:parameter name="source">amp-unifacs</nmwg:parameter>
<nmwg:parameter name="destination">amp-ufsc</nmwg:parameter> </amp:parameters>
To this?:
<amp:parameters id="param1">
<nmwg:parameter name="src.commonname ">amp-unifacs</nmwg:parameter>
<nmwg:parameter name="dst.commonname">amp-ufsc</nmwg:parameter> </amp:parameters>
I think this change would describe better the parameters. I agree with Jeff.
The individual parameter names are not an issue for me either, as long as the underlying code knows what to expect. Just as a stylistic point though we usually go with camel case over doted notion.
Oh right, mea culpa. :)
srcCommonname and dstCommonname then.
jeff
------------------------------------------------------------------------
/**
* The NmwgDatum describes the collected results of a measurement.
*
*
* @author Martin Swany
* @author Jason Zurawski
* @version $Id: Datum.java 143 2006-02-13 06:29:29 +0000 (Mon, 13 Feb 2006) zurawski $ * @see org.ggf.ns.nmwg.base.v2_0.Element
* @see org.ggf.ns.nmwg.time.v2_0.Time
* @see org.w3c.dom.Document
* @see org.w3c.dom.Element
*/
package org.ggf.ns.nmwg.base.v2_0;
import java.util.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import org.ggf.ns.nmwg.time.v2_0.Time;
import org.xml.sax.helpers.NamespaceSupport;
public class Datum extends Element {
/**
* attribute to contain the value value
*/
protected String value;
/**
* attribute to contain valueUnits value
*/ protected String valueUnits;
/**
* attribute to contain timeType value
*/ protected String timeType;
/**
* attribute to contain timeValue value
*/
protected String timeValue;
/**
* possible text string for the subject
*/ protected String datum;
/**
* 'map' of child elements
*/ protected Map childMap;
/**
* Constructor.
*/ public Datum() {
value = "";
valueUnits = ""; timeType = "";
timeValue = "";
localName = "datum";
qName = "maamp:datum"; datum = ""; childMap = new HashMap();
fileName = "org/ggf/ns/nmwg/tools/maamp/Datum.java";
}
/**
* Returns the value.
*/ public String getValue() {
return value;
}
/**
* Sets the value.
*/
public void setValue(String newValue) {
value = newValue;
} /**
* Returns the units.
*/ public String getValueUnits() {
return valueUnits;
}
/**
* Sets the units.
*/ public void setValueUnits(String newValueUnits) {
valueUnits = newValueUnits;
}
/**
* Returns a time type.
*/ public String getTimeType() {
return timeType;
}
/**
* Sets a time type.
*/
public void setTimeType(String newTimeType) {
timeType = newTimeType;
}
/**
* Returns a time value.
*/ public String getTimeValue() {
return timeValue;
}
/**
* Sets a time value.
*/ public void setTimeValue(String newTimeValue) {
timeValue = newTimeValue;
}
/**
* clear the Message of all Child elements
*/ public void clearChildren() {
childMap = new HashMap();
}
/**
* Adds a child to the map.
*/ public void setChild(Element newChild) { if(newChild != null) { if(!(newChild.getId().equals(""))) { childMap.put(newChild.getId(),newChild); }
else { System.err.println("Error: " + getFileName() + " 'setChild(Element)' cannot have nil value for id.");
} }
else {
System.err.println("Error: " + getFileName() + " 'setChild(Element)' cannot have nil value for Element."); } }
/**
* Return the child map
*/ public Map getChildMap() {
return this.childMap;
}
/**
* Convert and return the child block in array form
*/
public Element[] getChildArray() {
return (Element [])childMap.values().toArray(new Element[childMap.size()]);
}
/**
* Get an iterartor to the child map
*/
public Iterator getChildIterator() {
return childMap.values().iterator();
}
/**
* Get a single child block by id from the child block
*/
public Element getChild(String id) {
if(!(id.equals(""))) {
Element e = (Element) childMap.get(id);
if(e == null) {
System.err.println("Error: " + getFileName() + " 'getChild(String)' has returned null for id: " + id); }
return e;
}
else {
System.err.println("Error: " + getFileName() + " 'getChild(String)' id cannont be nil."); return null;
}
}
/**
* Get a single metadata block by id and type from the metadata block
*/
public Element getChild(String id, String type) {
if(!(id.equals("")) && !(type.equals(""))) { Collection collection = childMap.values();
Iterator it = collection.iterator();
while (it.hasNext()) {
Element e = (Element) it.next();
if(e.getLocalName().equals(type) && e.getId().equals(id)) {
return e;
}
}
return null;
}
else {
System.err.println("Error: " + getFileName() + " 'getChild(String, String)' cannot have nil value for id or type."); return null;
}
}
/**
* Get a vector of similar 'typed' children
*/
public Vector getChildrenByType(String type) {
if(!(type.equals(""))) { Collection collection = childMap.values();
Iterator it = collection.iterator();
Vector ev = new Vector();
while (it.hasNext()) {
Element e = (Element) it.next();
if(e.getLocalName().equals(type)) {
ev.add(e);
}
}
return ev;
}
else {
System.err.println("Error: " + getFileName() + " 'getChildByType(String)' cannot have nil value for type."); return null;
} }
/**
* Returns the datum
*/
public String getDatum() {
return datum;
}
/**
* Sets the datum
*/
public void setDatum(String newDatum){
datum = newDatum;
} /**
* Called when a text element is encountered, a
* check is forced to be sure we do not enter
* whitespace.
*/ public boolean addText(String text) {
//String clean = text.trim();
if(!(text.equals(""))) {
setDatum(text);
}
else {
System.err.println("Error: " + getFileName() + " datum can't have a witespace value.");
return false;
}
return true;
} /**
* Add the various attributes to a datum element.
*/ 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("timeType")) {
setTimeType(value);
}
else if(attr.equals("timeValue")) {
setTimeValue(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;
} /**
* Add the various childrent to a datum element.
*/ public boolean addChild(Element newChild) {
if(!(newChild.getLocalName().equals(""))) { setChild((Element)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));
if(!(datum.equals(""))) {
handler.characters(datum.toCharArray(),0,datum.length());
} 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(!(getTimeType().equals(""))) {
atts.addAttribute(getUri(), "timeType", "timeType", "CDATA", getTimeType());
} if(!(getTimeValue().equals(""))) {
atts.addAttribute(getUri(), "timeValue", "timeValue", "CDATA", getTimeValue());
} 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 pring out all related xml tags.
*/
public ContentHandler getChildren(ContentHandler handler, NamespaceSupport nss) throws Exception {
Element e;
Collection ec = getChildMap().values();
for(Iterator i = ec.iterator(); i.hasNext(); ){
e = (Element)i.next();
handler = e.toXML(handler, nss);
} return handler;
} /** * Given a DOM element (a parent), construct
* the children elements.
*/ public void getDOM(org.w3c.dom.Element parent) {
Element c;
Collection cc = getChildMap().values(); 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(!(getDatum().equals(""))) {
org.w3c.dom.Text dattext = doc.createTextNode(getDatum());
datum.appendChild(dattext);
} for(Iterator i = cc.iterator(); i.hasNext(); ){
c = (Element)i.next();
c.getDOM(datum); } }
/**
* Called when the object is placed in
* an output statement.
*/ public String toString() {
String cv = ""; Element c;
Collection cc = getChildMap().values(); for(Iterator i = cc.iterator(); i.hasNext(); ){
c = (Element)i.next();
cv = cv + c.toString();
} return getFileName() + ": ---> " + getValue() + " valueUnits:" + getValueUnits() + " timeType:" + getTimeType() + " timeValue:" + getTimeValue() + " " + cv + " " + getDatum();
}
}
- Re: [pS-dev] Datum Class, (continued)
- 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, Ivan K. Koga, 08/20/2006
- Re: [pS-dev] Datum Class, Jeff W. Boote, 08/21/2006
- Re: [pS-dev] Datum Class, Ivan K. Koga, 08/22/2006
- Re: [pS-dev] Datum Class, Jason Zurawski, 08/26/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.