();
}
void init() {
// LOG.debug("NODE FACTORY INIT");
}
public static Class> makeClass(String base, String name) {
Class> newClass = null;
String className = null;
try {
className = makeClassName(base, name);
// LOG.debug("timing...");
newClass = Class.forName(className);
// LOG.debug("...timing");
} catch (Exception e) {
throw new RuntimeException("cannot create class "+className, e);
}
return newClass;
}
/**
* @param base
* @param name
* @return
*/
private static String makeClassName(String base, String name) {
return base+S_PERIOD+CMLUtil.makeCMLName(name);
}
/** callback from element end tag.
*
* @param element the context element
* @return Nodes
*/
public Nodes finishMakingElement(Element element) {
Element parent = stack.pop();
if (current instanceof CMLElement) {
// trap exceptions, mainly due to semantics
// still trying to work this out
// try {
((CMLElement) current).finishMakingElement(parent);
// } catch (RuntimeException e) {
// LOG.warn("element throws semantic validation problem. " +
// "Should be relocated to different places "+e.getMessage());
// }
}
current = parent;
Nodes nodes = new Nodes();
nodes.append(element);
return nodes;
}
/** callback from each attribute.
*
* @param attributeName attribute name
* @param URI attribute namespace
* @param value attribute value
* @param type attribute type (ignored)
* @return Nodes
*/
public Nodes makeAttribute(String attributeName, String URI, String value, Attribute.Type type) {
Nodes nodes = new Nodes();
Attribute attribute = null;
int prefixLoc = attributeName.indexOf(":");
if (URI != null && URI.trim().length() != 0 && prefixLoc != -1) {
// namespaced non-cml attribute is allowed
attribute = new Attribute(attributeName, URI, value);
} else if (current instanceof CMLElement) {
CMLElement currentCML = (CMLElement) current;
String attributeGroupName = AttributeFactory.attributeFactory.getAttributeGroupName(attributeName, currentCML.getLocalName());
if (attributeGroupName == null) {
attribute = new Attribute(attributeName, value);
} else {
attribute = AttributeFactory.attributeFactory.getAttributeByGroupName(attributeGroupName);
((CMLAttribute)attribute).setCMLValue(value);
}
} else if (prefixLoc == -1) {
// non-prefixed non-cml element
attribute = new Attribute(attributeName, value);
} else if (prefixLoc != -1) {
// prefixed non-cml element
attribute = new Attribute(attributeName, URI, value);
}
if (attribute != null) {
nodes.append(attribute);
}
return nodes;
}
/** FIXME text - needs to trap/check values.
*
* @param text String content
* @return Nodes
*/
public Nodes makeText(String text) {
Nodes nodes = new Nodes();
nodes.append(new Text(text));
return nodes;
}
/** no-op.
*
* @param text String content
*/
public static void main(String text) {
}
/** callback from element start tag.
*
* @param name element name
* @param namespace namespace of element
* @return Element
*/
public Element startMakingElement(String name, String namespace) {
// fields;
/** new element*/
Element newElement;
int idx = name.indexOf(CMLUtil.S_COLON);
if (idx != -1) {
name = name.substring(idx+1);
}
// convert old namespaces
namespace = CMLNamespace.guessNamespace(namespace);
if (namespace.equals(null)) {
newElement = new Element(name);
} else if (namespace.trim().length() == 0) {
// this seems to be what is passed if there is no namespace
newElement = new Element(name);
} else if (!namespace.equals(CMLUtil.CML_NS)) {
newElement = new Element(name, namespace);
// end of part 1
} else {
CMLElement factoryElement = factoryElementMap.get(name);
if (factoryElement == null) {
// tacky until we get a list of CML-lite classes
Class> newClass = CMLNodeFactory.makeClass(ELEMENT_CLASS_BASE, name);
// Class> newClass = CMLNodeFactory.makeClass(ELEMENT_CLASS_BASE+S_PERIOD+LITE, name);
// if (newClass == null) {
// newClass = makeClass(ELEMENT_CLASS_BASE+S_PERIOD+MAIN, name);
// }
if (newClass == null) {
throw new RuntimeException("Cannot make class for: "+name);
}
try {
factoryElement = (CMLElement) newClass.newInstance();
} catch (Exception e) {
LOG.error("CLASS "+newClass);
LOG.error(newClass.getName());
e.printStackTrace();
throw new RuntimeException("Cannot instantiate because: "+name+"["+e+"]");
}
factoryElementMap.put(name, factoryElement);
}
newElement = factoryElement.makeElementInContext((Element)current);
}
stack.push(current);
current = newElement;
return newElement;
}
}
// end of part 3
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/CMLSchemaValidator.java 0000775 0000000 0000000 00000012736 14772244610 0026727 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.base;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import javax.xml.XMLConstants;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import javax.xml.validation.ValidatorHandler;
import nu.xom.Nodes;
import nu.xom.converters.SAXConverter;
import org.xml.sax.SAXException;
/**
* Validates against CML schema. Uses singleton pattern, since loading schema
* is time consuming, and only needs doing once.
* @author sea36
*
*/
public class CMLSchemaValidator {
private static final String SCHEMA_FILE = "schema.xsd";
private static CMLSchemaValidator instance;
private Schema schema;
/**
* Fetches instance of schema validator.
* @return validator
* @throws IOException - if schema file is not found.
* @throws RuntimeException - if schema cannot be parsed.
*/
public static CMLSchemaValidator getInstance() throws IOException {
if (instance == null) {
createInstance();
}
return instance;
}
private static synchronized void createInstance() throws IOException {
if (instance == null) {
instance = new CMLSchemaValidator();
}
}
private CMLSchemaValidator() throws IOException {
// Load schema
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
// load a WXS schema, represented by a Schema instance
InputStream is = getClass().getResourceAsStream(SCHEMA_FILE);
if (is == null) {
throw new IOException("Cannot find schema file: " + SCHEMA_FILE);
}
try {
Source schemaFile = new StreamSource(is);
schema = factory.newSchema(schemaFile);
} catch (SAXException e) {
throw new RuntimeException("invalid schema", e);
} finally {
is.close();
}
}
/**
* Validates XML from javax.xml.transform.Source against CML schema.
* Throws exception if validation fails.
* @param source
* @throws IOException - if problem reading xml.
* @throws RuntimeException - if xml does not validate against CML schema.
*/
public void validateCML(Source source) throws IOException {
Validator validator = schema.newValidator();
try {
validator.validate(source);
} catch (SAXException e) {
throw new RuntimeException("not valid CML", e);
}
}
/**
* Validates XML from java.io.InputStream against CML schema.
* Throws exception if validation fails.
* @param in
* @throws IOException
* @throws RuntimeException
*/
public void validateCML(InputStream in) throws IOException {
validateCML(new StreamSource(in));
}
/**
* Validates XML from java.io.Reader against CML schema.
* Throws exception if validation fails.
* @param in
* @throws IOException
* @throws RuntimeException
*/
public void validateCML(Reader in) throws IOException {
validateCML(new StreamSource(in));
}
/**
* Validates XML from nu.xom.Document against CML schema.
* Throws exception if validation fails.
* @param d
* @throws IOException
* @throws RuntimeException
*/
public void validateCML(nu.xom.Document d) throws IOException {
ValidatorHandler handler = schema.newValidatorHandler();
SAXConverter converter = new SAXConverter(handler);
try {
converter.convert(d);
} catch (SAXException e) {
throw new RuntimeException("not valid CML", e);
}
}
/**
* Validates XML from nu.xom.Node against CML schema.
* Throws exception if validation fails.
* @param node
* @throws IOException
* @throws RuntimeException
*/
public void validateCML(nu.xom.Node node) throws IOException {
ValidatorHandler handler = schema.newValidatorHandler();
SAXConverter converter = new SAXConverter(handler);
try {
converter.convert(new Nodes(node));
} catch (SAXException e) {
throw new RuntimeException("not valid CML", e);
}
}
/**
* Validates XML from org.w3c.dom.Node against CML schema.
* Throws exception if validation fails.
* @param node
* @throws IOException
* @throws RuntimeException
*/
public void validateCML(org.w3c.dom.Node node) throws IOException {
DOMSource source = new DOMSource(node);
validateCML(source);
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/CMLSerializer.java 0000775 0000000 0000000 00000007407 14772244610 0025771 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.base;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import nu.xom.Attribute;
import nu.xom.Document;
import nu.xom.Element;
import nu.xom.Serializer;
import nu.xom.UnavailableCharacterException;
import org.apache.log4j.Logger;
import org.xmlcml.euclid.Util;
/**
*
*
* Serializer for customising CML output
*
* This allows (a) writing to a String (b) customising elements and attributes
* Still experimental
* @author Peter Murray-Rust
* @version 5.0
*
*/
public class CMLSerializer extends Serializer implements CMLConstants {
final static Logger logger = Logger.getLogger(CMLSerializer.class);
ByteArrayOutputStream baos;
/** creates serializer to ByteArrayOutputStream.
* @see #getXML(Document)
* @see #getXML(Element)
* recover with getXML()
*/
public CMLSerializer() {
super(new ByteArrayOutputStream()); // because there is no Serializer()
baos = new ByteArrayOutputStream();
try {
this.setOutputStream(baos);
} catch (IOException e) {
Util.BUG(e);
}
}
/**
* creates normal Serializer.
*
* @param os
*/
public CMLSerializer(OutputStream os) {
super(os);
}
/**
* write a Document to string.
*
* @param doc
* the document
* @return XML for document
*/
public String getXML(Document doc) {
try {
this.write(doc);
} catch (IOException e) {
Util.BUG(e);
}
return baos.toString();
}
/**
* write XML for an element node. copies elements so it doesn't have a
* document parent
*
* @param elem
* @return the XML String
*/
public String getXML(Element elem) {
Element clone = (Element) elem.copy();
Document doc = new Document(clone);
return getXML(doc);
}
/** overrides attribute writing.
*
* Writes an attribute in the form name="value"
.
* Characters in the attribute value are escaped as necessary.
*
*
* @param attribute
* the Attribute
to write
*
* @throws IOException
* if the underlying output stream encounters an I/O error
* @throws UnavailableCharacterException
* if the attribute name contains a character that is not
* available in the current encoding
*
*/
protected void write(Attribute attribute) throws IOException {
// not sure which attributes might trigger this
super.write(attribute);
}
/** overrides element writing. allows updating of XOM before
*
* @param element
* @throws IOException
*/
protected void write(Element element) throws IOException {
if (element instanceof CMLElement) {
// ((CMLElement) element).updateXOM();
}
super.write(element);
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/CMLSimpleType.java 0000775 0000000 0000000 00000001562 14772244610 0025747 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
*/
package org.xmlcml.cml.base;
/**
* represents a simpleType which could be used for attributes
* or content
* @author pm286
*
*/
public abstract class CMLSimpleType implements CMLConstants {
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/CMLType.java 0000775 0000000 0000000 00000113747 14772244610 0024606 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.base;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.List;
import org.xmlcml.euclid.Util;
import nu.xom.Element;
import nu.xom.Node;
/**
*
*
* supports XSD and derived types generated by software and only instantiated as
* singletons
*
*
* @author Peter Murray-Rust
* @version 5.0
*
*/
public class CMLType implements CMLConstants {
/** dewisott */
public final static String NO_BASE = "Cannot find base: ";
protected String summary = "";
protected String description = "";
protected String base = null;
protected String name = null;
protected String id = null;
protected boolean isList = false;
protected String pattern = null;
protected int listLength = Integer.MIN_VALUE;
protected int iMinInclusive = Integer.MIN_VALUE;
protected int iMinExclusive = Integer.MIN_VALUE;
protected int iMaxInclusive = Integer.MAX_VALUE;
protected int iMaxExclusive = Integer.MAX_VALUE;
protected double dMinInclusive = Double.NaN;
protected double dMinExclusive = Double.NaN;
protected double dMaxInclusive = Double.NaN;
protected double dMaxExclusive = Double.NaN;
protected CMLType[] subTypes = new CMLType[0];
protected String[] sEnumerationValues = new String[0];
protected int[] iEnumerationValues = new int[0];
protected double[] dEnumerationValues = new double[0];
protected String javaType;
protected Element restriction;
protected Element union;
protected Element list;
private Element simpleType;
/**
* default.
*/
public CMLType() {
init();
}
private void init() {
summary = "";
description = "";
base = null;
name = null;
id = null;
isList = false;
pattern = null;
listLength = Integer.MIN_VALUE;
iMinInclusive = Integer.MIN_VALUE;
iMinExclusive = Integer.MIN_VALUE;
iMaxInclusive = Integer.MAX_VALUE;
iMaxExclusive = Integer.MAX_VALUE;
dMinInclusive = Double.NaN;
dMinExclusive = Double.NaN;
dMaxInclusive = Double.NaN;
dMaxExclusive = Double.NaN;
subTypes = new CMLType[0];
sEnumerationValues = new String[0];
iEnumerationValues = new int[0];
dEnumerationValues = new double[0];
javaType = null;
}
/**
* copy constructor.
*
* @param st
*/
public CMLType(CMLType st) {
}
/**
* create from XSD simpleType. may have to be called repeatedly untill all
* superTypes have been created
*
* @param simpleType
*/
public CMLType(Element simpleType) {
init();
if (!simpleType.getLocalName().equals("simpleType")) {
throw new RuntimeException(
"element is not a simpleType, found: "
+ simpleType.getLocalName());
}
this.name = simpleType.getAttributeValue("name");
this.id = simpleType.getAttributeValue("id");
this.simpleType = simpleType;
createUnion();
// unions are a problem. At present we simply take the first simpleType
// child
if (union == null || true) {
createRestriction();
createList();
createBase();
createDocumentation();
createPattern();
createLength();
createJavaType();
}
}
/**
* create min max.
*/
public void createMinMaxAndEnumerations() {
// if (union == null) {
createMinMax();
createEnumerations();
// }
}
Element createUnion() {
List unions = CMLUtil.getQueryNodes(simpleType,
".//" + XSD_UNION, XPATH_XSD);
union = null;
if (unions.size() == 1) {
union = (Element) unions.get(0);
} else if (unions.size() > 1) {
throw new RuntimeException("More than one union");
}
if (union != null) {
List nodes = CMLUtil.getQueryNodes(union, "./"
+ XSD_SIMPLE_TYPE, XPATH_XSD);
if (nodes.size() != 2) {
throw new RuntimeException(
"Union can only have two simpleTypes, found "
+ nodes.size());
}
subTypes = new CMLType[nodes.size()];
int i = 0;
for (Node node : nodes) {
subTypes[i++] = new CMLType((Element) node);
}
simpleType = subTypes[0].getSimpleType();
}
return union;
}
Element createRestriction() {
List restrictions = CMLUtil.getQueryNodes(simpleType, ".//"
+ XSD_RESTRICTION, XPATH_XSD);
restriction = null;
if (restrictions.size() == 1) {
restriction = (Element) restrictions.get(0);
} else if (restrictions.size() > 1) {
System.err.println("More than one restriction");
CMLUtil.debug(simpleType, "CMLTYPE");
}
return restriction;
}
Element createList() {
// lists are of two types:
// indefinite length
//
// and
// specific length
//
//
//
//
//
//
List lists = null;
isList = false;
if (restriction != null) {
lists = CMLUtil.getQueryNodes(restriction, "./" + XSD_SIMPLE_TYPE
+ CMLConstants.S_SLASH + XSD_LIST, XPATH_XSD);
List lengths = CMLUtil.getQueryNodes(restriction, "./"
+ XSD_LENGTH, XPATH_XSD);
if (lengths.size() == 1) {
Element length = (Element) lengths.get(0);
try {
listLength = Integer.parseInt(length
.getAttributeValue("value"));
} catch (NumberFormatException nfe) {
throw new RuntimeException("bad length: " + nfe);
}
}
} else {
lists = CMLUtil.getQueryNodes(simpleType, ".//" + XSD_LIST,
XPATH_XSD);
}
if (lists.size() == 1) {
list = (Element) lists.get(0);
isList = true;
String baseS = list.getAttributeValue("itemType");
if (baseS == null) {
CMLUtil.debug(simpleType, "SIMPLE1");
throw new RuntimeException("no base for " + name);
}
base = baseS;
} else if (lists.size() > 1) {
System.err.println("More than one list");
CMLUtil.debug(simpleType, "SIMPLE2");
}
return list;
}
String createBase() {
// base may already have been given
if (base == null) {
String baseS = simpleType.getAttributeValue("base");
base = (restriction == null) ? null : restriction
.getAttributeValue("base");
if (baseS == null && base == null) {
throw new RuntimeException("No base or restriction given");
} else if (baseS != null) {
if (base != null) {
throw new RuntimeException(
"Cannot give both base attribute and restriction");
}
base = baseS;
}
}
return base;
}
/**
* creates javaType from base. only uses XSD builtins. Id derived from other
* types has to be managed from outside this class.
*
* @return type
*/
String createJavaType() {
if (javaType == null) {
if (XSD_INTEGER.equals(base)) {
javaType = XSD_INTEGER;
} else if (XSD_NONNEGATIVEINTEGER.equals(base)) {
javaType = XSD_INTEGER;
iMinInclusive = 0;
} else if (XSD_DOUBLE.equals(base) || XSD_FLOAT.equals(base)) {
javaType = XSD_DOUBLE;
} else if (XSD_STRING.equals(base)) {
javaType = XSD_STRING;
} else if (XSD_BOOLEAN.equals(base)) {
javaType = XSD_BOOLEAN;
} else {
}
}
return javaType;
}
void createDocumentation() {
List docs = CMLUtil.getQueryNodes(simpleType, "./"
+ XSD_ANNOTATION + CMLConstants.S_SLASH + XSD_DOCUMENTATION, XPATH_XSD);
if (docs.size() == 0) {
} else if (docs.size() == 1) {
Element documentation = (Element) docs.get(0);
List summarys = CMLUtil.getQueryNodes(documentation,
".//*[@class='summary']");
summary = (summarys.size() == 0) ? null : summarys.get(0)
.getValue();
List descriptions = CMLUtil.getQueryNodes(documentation,
".//*[@class='description']");
description = (descriptions.size() == 0) ? null : descriptions.get(
0).getValue();
}
}
void createPattern() {
List patterns = CMLUtil.getQueryNodes(simpleType, "./"
+ XSD_RESTRICTION + CMLConstants.S_SLASH + XSD_PATTERN, XPATH_XSD);
if (patterns.size() > 0) {
pattern = ((Element) patterns.get(0)).getAttributeValue("value");
}
}
void createLength() {
List lengths = CMLUtil.getQueryNodes(simpleType, "./"
+ XSD_RESTRICTION + CMLConstants.S_SLASH + XSD_LENGTH, XPATH_XSD);
if (lengths.size() > 0) {
try {
listLength = Integer.parseInt(((Element) lengths.get(0))
.getAttributeValue("value"));
} catch (NumberFormatException e) {
CMLUtil.debug(simpleType, "SIMPLE3");
throw new RuntimeException("Bad length " + e);
}
}
}
void createMinMax() {
List minEx = CMLUtil.getQueryNodes(simpleType, "./"
+ XSD_RESTRICTION + CMLConstants.S_SLASH + XSD_MINEXCLUSIVE, XPATH_XSD);
if (minEx.size() > 0) {
Element elem = (Element) minEx.get(0);
String value = elem.getAttributeValue("value");
if (iMinExclusive == Integer.MIN_VALUE
&& XSD_INTEGER.equals(javaType)) {
try {
iMinExclusive = Integer.parseInt(value);
} catch (NumberFormatException e) {
throw new RuntimeException("Bad length " + e);
}
} else if (Double.isNaN(dMinExclusive)
&& XSD_DOUBLE.equals(javaType)) {
try {
dMinExclusive = (Util.parseFlexibleDouble(value));
} catch (NumberFormatException e) {
throw new RuntimeException("Bad length " + e);
} catch (ParseException e) {
throw new RuntimeException("Bad value for a double: "
+ value, e);
}
}
}
List maxEx = CMLUtil.getQueryNodes(simpleType, "./"
+ XSD_RESTRICTION + CMLConstants.S_SLASH + XSD_MAXEXCLUSIVE, XPATH_XSD);
if (maxEx.size() > 0) {
Element elem = (Element) maxEx.get(0);
String value = elem.getAttributeValue("value");
if (iMaxExclusive == Integer.MAX_VALUE
&& XSD_INTEGER.equals(javaType)) {
try {
iMaxExclusive = Integer.parseInt(value);
} catch (NumberFormatException e) {
throw new RuntimeException("Bad length " + e);
}
} else if (Double.isNaN(dMaxExclusive)
&& XSD_DOUBLE.equals(javaType)) {
try {
dMaxExclusive = (Util.parseFlexibleDouble(value));
} catch (NumberFormatException e) {
throw new RuntimeException("Bad length " + e);
} catch (ParseException e) {
throw new RuntimeException("Bad value for a double: "
+ value, e);
}
}
}
List minInc = CMLUtil.getQueryNodes(simpleType, "./"
+ XSD_RESTRICTION + CMLConstants.S_SLASH + XSD_MININCLUSIVE, XPATH_XSD);
if (minInc.size() > 0) {
Element elem = (Element) minInc.get(0);
String value = elem.getAttributeValue("value");
if (iMinInclusive == Integer.MIN_VALUE
&& XSD_INTEGER.equals(javaType)) {
try {
iMinInclusive = Integer.parseInt(value);
} catch (NumberFormatException e) {
throw new RuntimeException("Bad length " + e);
}
} else if (Double.isNaN(dMinInclusive)
&& XSD_DOUBLE.equals(javaType)) {
try {
dMinInclusive = (Util.parseFlexibleDouble(value));
} catch (NumberFormatException e) {
throw new RuntimeException("Bad length " + e);
} catch (ParseException e) {
throw new RuntimeException("Bad value for a double: "
+ value, e);
}
}
}
List maxInc = CMLUtil.getQueryNodes(simpleType, "./"
+ XSD_RESTRICTION + CMLConstants.S_SLASH + XSD_MAXINCLUSIVE, XPATH_XSD);
if (maxInc.size() > 0) {
Element elem = (Element) maxInc.get(0);
String value = elem.getAttributeValue("value");
if (iMaxInclusive == Integer.MAX_VALUE
&& XSD_INTEGER.equals(javaType)) {
try {
iMaxInclusive = Integer.parseInt(value);
} catch (NumberFormatException e) {
throw new RuntimeException("Bad length " + e);
}
} else if (Double.isNaN(dMaxInclusive)
&& XSD_DOUBLE.equals(javaType)) {
try {
dMaxInclusive = (Util.parseFlexibleDouble(value));
} catch (NumberFormatException e) {
throw new RuntimeException("Bad length " + e);
} catch (ParseException e) {
throw new RuntimeException("Bad value for a double: "
+ value, e);
}
}
}
}
void createEnumerations() {
List restrictions = CMLUtil.getQueryNodes(simpleType, "./"
+ XSD_RESTRICTION + CMLConstants.S_SLASH + XSD_ENUMERATION, XPATH_XSD);
int size = restrictions.size();
if (size > 0) {
int i = 0;
if (XSD_INTEGER.equals(javaType)) {
iEnumerationValues = new int[size];
for (Node node : restrictions) {
Element restriction = (Element) node;
try {
iEnumerationValues[i++] = Integer.parseInt(restriction
.getAttributeValue("value"));
} catch (NumberFormatException nfe) {
throw new RuntimeException(
"Cannot parse enumeration as integer: " + nfe);
}
}
} else if (XSD_DOUBLE.equals(javaType)) {
dEnumerationValues = new double[size];
for (Node node : restrictions) {
Element restriction = (Element) node;
try {
dEnumerationValues[i++] = NumberFormat
.getNumberInstance().parse(
restriction.getAttributeValue("value"))
.doubleValue();
} catch (NumberFormatException nfe) {
throw new RuntimeException(
"Cannot parse enumeration as double: " + nfe);
} catch (ParseException e) {
throw new RuntimeException(
"Bad value for a double: "
+ restriction
.getAttributeValue("value"), e);
}
}
} else if (XSD_STRING.equals(javaType)) {
sEnumerationValues = new String[size];
for (Node node : restrictions) {
Element restriction = (Element) node;
sEnumerationValues[i++] = restriction
.getAttributeValue("value");
}
}
}
}
/**
* checks value of simpleType. throws CMLRuntime if value does not check
* against SimpleType or is a list currently only uses pattern. fails if
* type is int or double
*
* @param s
* the string
* @throws RuntimeException
* wrong type or pattern fails
*/
public void checkValue(String s) throws RuntimeException {
if (subTypes.length > 0) {
for (int j = 0; j < subTypes.length; j++) {
(subTypes[j]).checkValue(s);
}
} else {
if (!base.equals(XSD_STRING)) {
throw new RuntimeException("Cannot accept String for type: "
+ base);
}
if (isList) {
throw new RuntimeException(
"cannot accept single String for String[] list");
}
checkPattern(s);
checkEnumeration(s);
}
}
/**
* checks value of simpleType. throws CMLRuntime if value does not check
* against SimpleType or is not a list currently only uses pattern. fails if
* type is int or double
*
* @param ss
* the strings
* @throws RuntimeException
* wrong type or pattern fails
*/
public void checkValue(String ss[]) throws RuntimeException {
if (subTypes.length > 0) {
for (int j = 0; j < subTypes.length; j++) {
(subTypes[j]).checkValue(ss);
}
} else {
if (!base.equals(XSD_STRING)) {
throw new RuntimeException("Cannot accept String for type: "
+ base);
}
if (!isList) {
throw new RuntimeException(
"cannot accept a list String[] for single String");
}
checkListLength(ss.length);
int i = 0;
try {
while (i < ss.length) {
checkPattern(ss[i]);
checkEnumeration(ss[i]);
i++;
}
} catch (RuntimeException e) {
throw new RuntimeException("String (" + i + ")(" + ss[i]
+ ") fails: " + e);
}
}
}
private void checkListLength(int l) throws RuntimeException {
// in many cases there is no set list length...
// assume negative list length implies this?
// if (listLength < Integer.MAX_VALUE && listLength != l) {
if (listLength > 0 && listLength != l) {
throw new RuntimeException("listLength required (" + listLength
+ ") incompatible with: " + l);
}
}
/**
* checks value of simpleType. throws CMLRuntime if value does not check
* against SimpleType or is a list currently uses min/max/In/Exclusive fails
* if type is String or double
*
* @param i
* the int
* @throws RuntimeException
* wrong type or value fails
*/
public void checkValue(int i) throws RuntimeException {
if (subTypes.length > 0) {
for (int j = 0; j < subTypes.length; j++) {
(subTypes[j]).checkValue(i);
}
} else {
if (!base.equals(XSD_INTEGER)) {
throw new RuntimeException("Cannot accept int for type: "
+ base);
}
if (isList) {
throw new RuntimeException(
"cannot accept single int for int[] list");
}
checkMinMax(i);
checkEnumeration(i);
}
}
/**
* checks value of simpleType. throws CMLRuntime if value does not check
* against SimpleType or is not a list currently uses min/max/In/Exclusive
* fails if type is String or double
*
* @param ii
* the int
* @throws RuntimeException
* wrong type or value fails
*/
public void checkValue(int ii[]) throws RuntimeException {
if (subTypes.length > 0) {
for (int j = 0; j < subTypes.length; j++) {
(subTypes[j]).checkValue(ii);
}
} else {
if (!base.equals(XSD_INTEGER)) {
throw new RuntimeException("Cannot accept int for type: "
+ base);
}
if (!isList) {
throw new RuntimeException(
"cannot accept a list int[] for single int");
}
checkListLength(ii.length);
int i = 0;
try {
while (i < ii.length) {
checkMinMax(ii[i]);
checkEnumeration(ii[i]);
i++;
}
} catch (RuntimeException e) {
throw new RuntimeException("int[] (" + i + ")(" + ii[i]
+ ") fails: " + e);
}
}
}
/**
* checks value of simpleType. throws CMLRuntime if value does not check
* against SimpleType or is a list currently uses min/max/In/Exclusive fails
* if type is String or int
*
* @param d
* the double
* @throws RuntimeException
* wrong type or value fails
*/
public void checkValue(double d) throws RuntimeException {
if (subTypes.length > 0) {
for (int j = 0; j < subTypes.length; j++) {
(subTypes[j]).checkValue(d);
}
} else {
if (!base.equals(XSD_DOUBLE)) {
throw new RuntimeException("Cannot accept double for type: "
+ base);
}
if (isList) {
throw new RuntimeException(
"cannot accept single double for double[] list");
}
checkMinMax(d);
checkEnumeration(d);
}
}
/**
* checks value of simpleType. throws CMLRuntime if value does not check
* against SimpleType or is not a list currently uses min/max/In/Exclusive
* fails if type is String or int
*
* @param dd
* the double
* @throws RuntimeException
* wrong type or value fails
*/
public void checkValue(double dd[]) throws RuntimeException {
if (subTypes.length > 0) {
for (int j = 0; j < subTypes.length; j++) {
(subTypes[j]).checkValue(dd);
}
} else {
if (!base.equals(XSD_DOUBLE)) {
throw new RuntimeException("Cannot accept String for type: "
+ base);
}
if (!isList) {
throw new RuntimeException(
"cannot accept a list double[] for single double");
}
checkListLength(dd.length);
int i = 0;
try {
while (i < dd.length) {
checkMinMax(dd[i]);
checkEnumeration(dd[i]);
i++;
}
} catch (RuntimeException e) {
throw new RuntimeException("double[] (" + i + ")(" + dd[i]
+ ") fails: " + e);
}
}
}
/**
* checks value of simpleType. throws CMLRuntime if value does not check
* against SimpleType or is a list fails if type is not boolean
*
* @param b
* the boolean
* @throws RuntimeException
* wrong type or value fails
*/
public void checkValue(boolean b) throws RuntimeException {
if (subTypes.length > 0) {
for (int j = 0; j < subTypes.length; j++) {
(subTypes[j]).checkValue(b);
}
} else {
if (!base.equals(XSD_BOOLEAN)) {
throw new RuntimeException(
"Cannot accept boolean for type: " + base);
}
if (isList) {
throw new RuntimeException(
"cannot accept single boolean for boolean[] list");
}
}
}
/**
* checks value of simpleType. throws CMLRuntime if value does not check
* against SimpleType or is not a list fails if type is not boolean
*
* @param bb
* the boolean array
* @throws RuntimeException
* wrong type or value fails
*/
public void checkValue(boolean bb[]) throws RuntimeException {
if (subTypes.length > 0) {
for (int j = 0; j < subTypes.length; j++) {
(subTypes[j]).checkValue(bb);
}
} else {
if (!base.equals(XSD_BOOLEAN)) {
throw new RuntimeException(
"Cannot accept boolean for type: " + base);
}
if (!isList) {
throw new RuntimeException(
"cannot accept a list boolean[] for single boolean");
}
checkListLength(bb.length);
}
}
/**
* get name.
*
* @return name
*/
public String getName() {
return this.name;
}
/**
* set name.
*
* @param name
*/
public void setName(String name) {
this.name = name;
}
/**
* get Base.
*
* @return base
*/
public String getBase() {
return this.base;
}
/**
* set base.
*
* @param base
*/
public void setBase(String base) {
this.base = base;
}
/**
* set id.
*
* @param id
*/
public void setId(String id) {
this.id = id;
}
/**
* returns whether ST uses a list.
*
* @return true if list.
*/
public boolean getIsList() {
return isList;
}
/**
* set is list.
*
* @param b
*/
public void setIsList(boolean b) {
this.isList = b;
}
/**
* set pattern.
*
* @param p
*/
public void setPattern(String p) {
this.pattern = p;
}
/**
* get pattern.
*
* @return pattern
*/
public String getPattern() {
return this.pattern;
}
/**
* get list length.
*
* @return length
*/
public int getListLength() {
return this.listLength;
}
/**
* set list length.
*
* @param l
*/
public void setListLength(int l) {
this.listLength = l;
}
/**
* set min inclusive.
*
* @param i
*/
public void setMinInclusive(int i) {
this.iMinInclusive = i;
}
/**
* set min exclusive.
*
* @param i
*/
public void setMinExclusive(int i) {
this.iMinExclusive = i;
}
/**
* set max inclusive.
*
* @param i
*/
public void setMaxInclusive(int i) {
this.iMaxInclusive = i;
}
/**
* set max exclusive.
*
* @param i
*/
public void setMaxExclusive(int i) {
this.iMaxExclusive = i;
}
/**
* set min exclusive.
*
* @param d
*/
public void setMinInclusive(double d) {
this.dMinInclusive = d;
}
/**
* set min exclusive.
*
* @param d
*/
public void setMinExclusive(double d) {
this.dMinExclusive = d;
}
/**
* set max inclusive.
*
* @param d
*/
public void setMaxInclusive(double d) {
this.dMaxInclusive = d;
}
/**
* set max exclusive.
*
* @param d
*/
public void setMaxExclusive(double d) {
this.dMaxExclusive = d;
}
/**
* get int min inclusive.
*
* @return min
*/
public int getIntMinInclusive() {
return this.iMinInclusive;
}
/**
* get int min exclusive.
*
* @return min
*/
public int getIntMinExclusive() {
return this.iMinExclusive;
}
/**
* get int max inclusive.
*
* @return max
*/
public int getIntMaxInclusive() {
return this.iMaxInclusive;
}
/**
* get int max exclusive.
*
* @return int
*/
public int getIntMaxExclusive() {
return this.iMaxExclusive;
}
/**
* get double min inclusive.
*
* @return min
*/
public double getDoubleMinInclusive() {
return this.dMinInclusive;
}
/**
* get double min exclusive.
*
* @return min
*/
public double getDoubleMinExclusive() {
return this.dMinExclusive;
}
/**
* get double max inclusive.
*
* @return max
*/
public double getDoubleMaxInclusive() {
return this.dMaxInclusive;
}
/**
* get double max exclusive.
*
* @return max
*/
public double getDoubleMaxExclusive() {
return this.dMaxExclusive;
}
/**
* set subtypes.
*
* @param st
*/
public void setSubTypes(CMLType[] st) {
this.subTypes = new CMLType[st.length];
for (int i = 0; i < st.length; i++) {
subTypes[i] = st[i];
}
}
// protected Elements subTypes = null;
/**
* set enumeration.
*
* @param ss
*/
public void setEnumeration(String[] ss) {
this.sEnumerationValues = ss;
}
/**
* set enumeration.
*
* @param ii
*/
public void setEnumeration(int[] ii) {
this.iEnumerationValues = ii;
}
/**
* set enumeration.
*
* @param dd
*/
public void setEnumeration(double[] dd) {
this.dEnumerationValues = dd;
}
/**
* get string enumeration.
*
* @return enumeration
*/
public String[] getStringEnumeration() {
return this.sEnumerationValues;
}
/**
* get int enumeration.
*
* @return enumeration
*/
public int[] getIntEnumeration() {
return this.iEnumerationValues;
}
/**
* get double enumeration.
*
* @return enumeration
*/
public double[] getDoubleEnumeration() {
return this.dEnumerationValues;
}
private void checkPattern(String s) throws RuntimeException {
if (s == null) {
throw new RuntimeException("Null strings not allowed");
}
if (pattern != null && !s.matches(pattern)) {
throw new RuntimeException("String (" + s
+ ") does not match pattern (" + pattern + ") for " + name);
}
}
private void checkMinMax(int i) throws RuntimeException {
if (iMinInclusive > Integer.MIN_VALUE && i < iMinInclusive) {
throw new RuntimeException("int (" + i + ") less than "
+ iMinInclusive);
}
if (iMaxInclusive < Integer.MAX_VALUE && i > iMaxInclusive) {
throw new RuntimeException("int (" + i + ") greater than "
+ iMaxInclusive);
}
if (iMinExclusive > Integer.MIN_VALUE && i <= iMinExclusive) {
throw new RuntimeException("int (" + i + ") less than equals "
+ iMinExclusive);
}
if (iMaxExclusive < Integer.MAX_VALUE && i >= iMaxExclusive) {
throw new RuntimeException("int (" + i
+ ") greater than equals " + iMaxExclusive);
}
}
private void checkMinMax(double d) throws RuntimeException {
if (!Double.isNaN(dMinInclusive) && d < dMinInclusive) {
throw new RuntimeException("double (" + d + ") less than "
+ dMinInclusive);
}
if (!Double.isNaN(dMaxInclusive) && d > dMaxInclusive) {
throw new RuntimeException("double (" + d + ") greater than "
+ dMaxInclusive);
}
if (!Double.isNaN(dMinExclusive) && d <= dMinExclusive) {
throw new RuntimeException("double (" + d
+ ") less than equals " + dMinExclusive);
}
if (!Double.isNaN(dMaxExclusive) && d >= dMaxExclusive) {
throw new RuntimeException("double (" + d
+ ") greater than equals " + dMaxExclusive);
}
}
private void checkEnumeration(int i) throws RuntimeException {
if (iEnumerationValues.length != 0) {
boolean ok = false;
for (int j = 0; j < iEnumerationValues.length; j++) {
if (i == iEnumerationValues[j]) {
ok = true;
break;
}
}
if (!ok) {
throw new RuntimeException("int (" + i
+ ") not contained in enumeration");
}
}
}
private void checkEnumeration(double d) throws RuntimeException {
if (dEnumerationValues.length != 0) {
boolean ok = false;
for (int j = 0; j < dEnumerationValues.length; j++) {
if (d == dEnumerationValues[j]) {
ok = true;
break;
}
}
if (!ok) {
throw new RuntimeException("double (" + d
+ ") not contained in enumeration");
}
}
}
private void checkEnumeration(String s) throws RuntimeException {
if (s == null) {
throw new RuntimeException(
"Null String cannot be checked against enumeration");
}
if (dEnumerationValues.length != 0) {
boolean ok = false;
for (int j = 0; j < sEnumerationValues.length; j++) {
if (s.equals(sEnumerationValues[j])) {
ok = true;
break;
}
}
if (!ok) {
throw new RuntimeException("String (" + s
+ ") not contained in enumeration");
}
}
}
/**
* compares cmlType. uses name only as we expect to have singleton CMLTypes
* null values of any component return -1
*
* @param type
* to compare
* @return 0 if all content is identical, -1 if this less than att, 1 if
* greater value
*
*/
public int compareTo(CMLType type) {
return name.compareTo(type.name);
}
/**
* get summary.
*
* @return summary
*/
public String getSummary() {
return summary;
}
/**
* set summary.
*
* @param s
*/
public void setSummary(String s) {
summary = s.trim();
if (summary.length() != 0 && !summary.endsWith(S_PERIOD)) {
summary += CMLConstants.S_PERIOD;
}
}
/**
* get description.
*
* @return description
*/
public String getDescription() {
return description;
}
/**
* get full description.
*
* @return description
*/
public String getFullDescription() {
String desc = "";
if (subTypes.length > 0) {
// desc = "**************** UNION ****************\n";
for (CMLType subType : subTypes) {
desc += "********SUBTYPE*********\n";
desc += subType.getFullDescription();
}
} else {
if (summary != null && !summary.trim().equals("")) {
desc += "\n.... " + summary;
}
if (description != null && !description.equals("")) {
desc += "\n_______________________________________\n"
+ description
+ "\n__________________________________________\n";
}
if (pattern != null) {
desc += "\n Pattern: " + pattern;
}
if (listLength != Integer.MIN_VALUE) {
desc += "\nLength: " + listLength;
}
boolean min = false;
if (iMinInclusive != Integer.MIN_VALUE) {
desc += "\nMinInclusive: " + iMinInclusive;
min = true;
}
if (iMinExclusive != Integer.MIN_VALUE) {
desc += "\nMinExclusive: " + iMinExclusive;
min = true;
}
if (!Double.isNaN(dMinInclusive)) {
desc += "\nMinInclusive: " + dMinInclusive;
min = true;
}
if (!Double.isNaN(dMinExclusive)) {
desc += "\nMinExclusive: " + dMinExclusive;
min = true;
}
if (iMaxInclusive != Integer.MAX_VALUE) {
desc += ((min) ? "" : "\n") + " MaxInclusive: " + iMaxInclusive;
}
if (iMaxExclusive != Integer.MAX_VALUE) {
desc += ((min) ? "" : "\n") + " MaxExclusive: " + iMaxExclusive;
}
if (!Double.isNaN(dMaxInclusive)) {
desc += ((min) ? "" : "\n") + " MaxInclusive: " + dMaxInclusive;
}
if (!Double.isNaN(dMaxExclusive)) {
desc += ((min) ? "" : "\n") + " MaxExclusive: " + dMaxExclusive;
}
if (sEnumerationValues.length > 0) {
desc += "\nPermitted String values:";
for (int i = 0; i < sEnumerationValues.length; i++) {
desc += "\n " + sEnumerationValues[i];
}
}
if (iEnumerationValues.length > 0) {
desc += "\nPermitted integer values:";
for (int i = 0; i < iEnumerationValues.length; i++) {
desc += "\n " + iEnumerationValues[i];
}
}
if (dEnumerationValues.length > 0) {
desc += "\nPermitted double values:";
for (int i = 0; i < dEnumerationValues.length; i++) {
desc += "\n " + dEnumerationValues[i];
}
}
}
return desc;
}
/**
* set description.
*
* @param d
*/
public void setDescription(String d) {
description = d;
}
/**
* to string.
*
* @return string
*/
public String toString() {
String s = "Name: " + name + "\n";
if (union != null) {
s += ".....UNION: " + subTypes.length;
} else {
s += this.getFullDescription();
s += "\n";
}
return s;
}
/**
* @return the dEnumerationValues
*/
public double[] getDEnumerationValues() {
return dEnumerationValues;
}
/**
* @param enumerationValues
* the dEnumerationValues to set
*/
public void setDEnumerationValues(double[] enumerationValues) {
dEnumerationValues = enumerationValues;
}
/**
* @return the dMaxExclusive
*/
public double getDMaxExclusive() {
return dMaxExclusive;
}
/**
* @param maxExclusive
* the dMaxExclusive to set
*/
public void setDMaxExclusive(double maxExclusive) {
dMaxExclusive = maxExclusive;
}
/**
* @return the dMaxInclusive
*/
public double getDMaxInclusive() {
return dMaxInclusive;
}
/**
* @param maxInclusive
* the dMaxInclusive to set
*/
public void setDMaxInclusive(double maxInclusive) {
dMaxInclusive = maxInclusive;
}
/**
* @return the dMinExclusive
*/
public double getDMinExclusive() {
return dMinExclusive;
}
/**
* @param minExclusive
* the dMinExclusive to set
*/
public void setDMinExclusive(double minExclusive) {
dMinExclusive = minExclusive;
}
/**
* @return the dMinInclusive
*/
public double getDMinInclusive() {
return dMinInclusive;
}
/**
* @param minInclusive
* the dMinInclusive to set
*/
public void setDMinInclusive(double minInclusive) {
dMinInclusive = minInclusive;
}
/**
* @return the iEnumerationValues
*/
public int[] getIEnumerationValues() {
return iEnumerationValues;
}
/**
* @param enumerationValues
* the iEnumerationValues to set
*/
public void setIEnumerationValues(int[] enumerationValues) {
iEnumerationValues = enumerationValues;
}
/**
* @return the iMaxExclusive
*/
public int getIMaxExclusive() {
return iMaxExclusive;
}
/**
* @param maxExclusive
* the iMaxExclusive to set
*/
public void setIMaxExclusive(int maxExclusive) {
iMaxExclusive = maxExclusive;
}
/**
* @return the iMaxInclusive
*/
public int getIMaxInclusive() {
return iMaxInclusive;
}
/**
* @param maxInclusive
* the iMaxInclusive to set
*/
public void setIMaxInclusive(int maxInclusive) {
iMaxInclusive = maxInclusive;
}
/**
* @return the iMinExclusive
*/
public int getIMinExclusive() {
return iMinExclusive;
}
/**
* @param minExclusive
* the iMinExclusive to set
*/
public void setIMinExclusive(int minExclusive) {
iMinExclusive = minExclusive;
}
/**
* @return the iMinInclusive
*/
public int getIMinInclusive() {
return iMinInclusive;
}
/**
* @param minInclusive
* the iMinInclusive to set
*/
public void setIMinInclusive(int minInclusive) {
iMinInclusive = minInclusive;
}
/**
* @return the javaType
*/
public String getJavaType() {
return javaType;
}
/**
* @param javaType
* the javaType to set
*/
public void setJavaType(String javaType) {
this.javaType = javaType;
}
/**
* @return the list
*/
public Element getList() {
return list;
}
/**
* @param list
* the list to set
*/
public void setList(Element list) {
this.list = list;
}
/**
* @return the restriction
*/
public Element getRestriction() {
return restriction;
}
/**
* @param restriction
* the restriction to set
*/
public void setRestriction(Element restriction) {
this.restriction = restriction;
}
/**
* @return the sEnumerationValues
*/
public String[] getSEnumerationValues() {
return sEnumerationValues;
}
/**
* @param enumerationValues
* the sEnumerationValues to set
*/
public void setSEnumerationValues(String[] enumerationValues) {
sEnumerationValues = enumerationValues;
}
/**
* @return the simpleType
*/
public Element getSimpleType() {
return simpleType;
}
/**
* @param simpleType
* the simpleType to set
*/
public void setSimpleType(Element simpleType) {
this.simpleType = simpleType;
}
/**
* @return the union
*/
public Element getUnion() {
return union;
}
/**
* @param union
* the union to set
*/
public void setUnion(Element union) {
this.union = union;
}
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @return the subTypes
*/
public CMLType[] getSubTypes() {
return subTypes;
}
/**
* @param isList
* the isList to set
*/
public void setList(boolean isList) {
this.isList = isList;
}
/**
* get data type of list.
*
* @return type
*/
public String listDataType() {
String s = " ... base " + this.base;
s += " (java: " + javaType + ") ";
if (isList) {
s += " [" + ((this.listLength >= 0) ? this.listLength : "*") + "]";
}
return s;
}
/**
* maps datatypes onto simpler values. mainly maps float, real, etc. to
* XSD_FLOAT
*
* @param value
* @return normalized value
*/
public static String getNormalizedValue(String value) {
String dataType = null;
if (value == null || value.trim().equals("")
|| value.equals(XSD_STRING)) {
dataType = XSD_STRING;
} else {
value = value.trim();
if (value.equals(XSD_INTEGER)) {
dataType = XSD_INTEGER;
} else if (value.equals(XSD_FLOAT) || value.equals(FPX_REAL)
|| value.equals(XSD_DOUBLE)) {
dataType = XSD_DOUBLE;
} else if (value.equals(XSD_DATE)) {
dataType = XSD_DATE;
} else {
throw new RuntimeException("Unknown data type: " + value);
}
}
return dataType;
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/CMLUtil.java 0000775 0000000 0000000 00000116354 14772244610 0024577 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.base;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import nu.xom.Attribute;
import nu.xom.Builder;
import nu.xom.Comment;
import nu.xom.Document;
import nu.xom.Element;
import nu.xom.Elements;
import nu.xom.Node;
import nu.xom.Nodes;
import nu.xom.ParentNode;
import nu.xom.ProcessingInstruction;
import nu.xom.Serializer;
import nu.xom.Text;
import nu.xom.XPathContext;
import nu.xom.canonical.Canonicalizer;
import org.apache.log4j.Logger;
import org.xml.sax.XMLReader;
import org.xmlcml.cml.element.CMLMolecule;
import org.xmlcml.euclid.Util;
/**
*
*
* static utilities to help manage common constructs.
*
*
* @author Peter Murray-Rust
* @version 5.0
*
*/
public abstract class CMLUtil implements CMLConstants {
private static final String DUMMY = "dummy";
private static Logger LOG = Logger.getLogger(CMLUtil.class);
public final static String DTD = ".dtd\">";
// ========================== utilities ====================== //
/**
* checks that name is QName.
*
* @param name
* of XMLName
* @throws RuntimeException
* not colonized
*/
public final static void checkPrefixedName(String name) {
if (name == null || name.indexOf(S_COLON) < 1) {
throw new RuntimeException("Unprefixed name (" + name + S_RBRAK);
}
}
/**
* get prefix from qualified name.
*
* @param s
* @return prefix (or empty string)
*/
public static String getPrefix(String s) {
int idx = s.indexOf(S_COLON);
return (idx == -1) ? S_EMPTY : s.substring(0, idx);
}
/**
* get localName from qualified name.
*
* @param s
* @return localName (or empty string)
*/
public static String getLocalName(String s) {
String ss = null;
if (s != null) {
int idx = s.indexOf(S_COLON);
ss = (idx == -1) ? s : s.substring(idx + 1);
}
return ss;
}
/**
* convenience method to extract value of exactly one node.
* uses element.query(xpath, xPathContext);
* @param element
* @param xpath
* @param xPathContext defines prefix/namespace used in query
* @return value if exactly 1 node (0 or many returns null)
*/
public static String getSingleValue(Element element, String xpath, XPathContext xPathContext) {
String s = null;
if (element == null) {
LOG.warn("Null element");
} else {
Nodes nodes = element.query(xpath, xPathContext);
s = (nodes.size() == 1) ? nodes.get(0).getValue() : null;
}
return s;
}
/**
* convenience method to extract value of exactly one node..
* uses element.query(xpath, xPathContext);
* @param element
* @param xpath
* @return value if exactly 1 node (0 or many returns null)
*/
public static String getSingleValue(Element element, String xpath) {
String s = null;
if (element == null) {
LOG.warn("Null element");
} else {
Nodes nodes = element.query(xpath);
s = (nodes.size() == 1) ? nodes.get(0).getValue() : null;
}
return s;
}
/**
* convenience method to extract value of the first of one-or-more nodes.
* uses element.query(xpath, xPathContext);
* @param element
* @param xpath
* @param xPathContext defines prefix/namespace used in query
* @return value if exactly 1 node (0 or many returns null)
*/
public static String getFirstValue(Element element, String xpath, XPathContext xPathContext) {
String s = null;
if (element == null) {
LOG.warn("Null element");
} else {
Nodes nodes = element.query(xpath, xPathContext);
s = (nodes.size() >= 1) ? nodes.get(0).getValue() : null;
}
return s;
}
/**
* convenience method to get exactly one element.
* uses element.query(xpath, xPathContext);
* @param element
* @param xpath
* @param xPathContext defines prefix/namespace used in query
* @return value if exactly 1 element (0 or many returns null)
*/
public static Element getSingleElement(Element element, String xpath, XPathContext xPathContext) {
Nodes nodes = element.query(xpath, xPathContext);
return (nodes.size() == 1) ? (Element) nodes.get(0) : null;
}
/**
* convenience routine to get query CMLelements (iterating thorugh get(i) is
* fragile if nodes are removed)
* if query result is not a CMLElement it is omitted form list, so be careful
*
* @param node
* @param xpath xpath relative to node
* @param context
* @return list of CMLelements - empty if none
*/
public static List getCMLElements(Element node, String xpath,
XPathContext context) {
List nodeList = new ArrayList();
if (node != null) {
Nodes nodes = node.query(xpath, context);
for (int i = 0; i < nodes.size(); i++) {
if (nodes.get(i) instanceof CMLElement) {
nodeList.add((CMLElement)nodes.get(i));
}
}
}
return nodeList;
}
/**
* converts an Elements to a java array. we might convert code to use
* Elements through later so this would be unneeded
*
* @param elements
* @param obj
* type of array (e.g. "new CMLAtom[0]"
* @return the java array 0f objects
*/
public final static Object[] toArray(Elements elements, Object[] obj) {
List list = new ArrayList();
for (int i = 0; i < elements.size(); i++) {
list.add(elements.get(i));
}
return list.toArray(obj);
}
/**
* debug an element. outputs XML to sysout indent = 2
*
* @param el
* the element
* @deprecated use debug(el, message) instead
*/
public static void debug(Element el) {
try {
debug(el, System.out, 2);
} catch (IOException e) {
throw new RuntimeException("BUG " + e);
}
}
/**
* debug an element. outputs XML to syserr
*
* @param el
* the element
*/
public static void debugToErr(Element el) {
try {
debug(el, System.err, 2);
} catch (IOException e) {
throw new RuntimeException("BUG " + e);
}
}
/**
* debug an element.
*
* @param el
* the element
* @param message
* the message
*/
public static void debug(Element el, String message) {
Util.println(">>>>" + message + ">>>>");
CMLUtil.debug(el);
Util.println("<<<<" + message + "<<<<");
}
/**
* debug an element.
*
* @param el
* the element
* @param os
* output stream
* @param indent
* indentation
* @throws IOException
*/
public static void debug(Element el, OutputStream os, int indent)
throws IOException {
Document document;
if (el != null) {
Node parent = el.getParent();
if (parent instanceof Document) {
document = (Document) parent;
} else {
Element copyElem = new Element(el);
document = new Document(copyElem);
}
Serializer serializer = new Serializer(os, "UTF-8");
if (indent >= 0) {
serializer.setIndent(indent);
}
serializer.write(document);
}
}
/** convenience method to avoid trapping exception
*
* @param elem
* @param file
* @param indent
*/
public static void outputQuietly(Element elem, File file, int indent) {
try {
CMLUtil.debug(elem, new FileOutputStream(file), indent);
} catch (Exception e) {
throw new RuntimeException("cannot write file: " + file, e);
}
}
/**
* convenience method to get resource from XMLFile. the resource is packaged
* with the classes for distribution. typical filename is
* org/xmlcml/molutil/elementdata.xml for file elementdata.xml in class
* hierarchy org.xmlcml.molutil
*
* @param filename
* relative to current class hierarchy.
* @return document for resource
* @throws IOException
*/
public static Document getXMLResource(String filename) throws IOException {
Document document = null;
InputStream in = null;
try {
in = Util.getInputStreamFromResource(filename);
document = (Document) new Builder().build(in);
} catch (IOException e) {
throw e;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("" + e + " in " + filename);
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return document;
}
/**
* convenience routine to get child nodes (iterating through getChild(i) is
* fragile if children are removed)
*
* @param el
* may be null
* @return list of children (immutable) - empty if none
*/
public static List getChildNodes(Element el) {
List childs = new ArrayList();
if (el != null) {
for (int i = 0; i < el.getChildCount(); i++) {
childs.add(el.getChild(i));
}
}
return childs;
}
/**
* parses XML string into element. convenience method to avoid trapping
* exceptions when string is known to be valid
*
* @param xmlString
* @return root element
* @throws RuntimeException
*/
public static Element parseXML(String xmlString) throws RuntimeException {
Element root = null;
try {
Document doc = new Builder().build(new StringReader(xmlString));
root = doc.getRootElement();
} catch (Exception e) {
throw new RuntimeException(e);
}
return root;
}
public static Document parseHtmlWithTagSoup(InputStream is) {
try {
Builder builder = getTagsoupBuilder();
return builder.build(is);
} catch (Exception e) {
throw new RuntimeException("Exception whilse parsing XML, due to: "+e.getMessage(), e);
}
}
public static Document parseHtmlWithTagSoup(File file) {
try {
return parseHtmlWithTagSoup(new FileInputStream(file));
} catch (FileNotFoundException e) {
throw new RuntimeException("Exception whilse parsing HTML, due to: "+e.getMessage(), e);
}
}
public static Builder getTagsoupBuilder() {
XMLReader tagsoup = null;
// try {
tagsoup = //XMLReaderFactory.createXMLReader("org.ccil.cowan.tagsoup.Parser");
new org.ccil.cowan.tagsoup.Parser();
// } catch (SAXException e) {
// throw new RuntimeException("Exception whilst creating XMLReader from org.ccil.cowan.tagsoup.Parser", e);
// }
return new Builder(tagsoup);
}
/**
* parses CML string into element. convenience method to avoid trapping
* exceptions when string is known to be valid
*
* @param cmlString
* @return root element
* @throws RuntimeException
*/
public static CMLElement parseCML(String cmlString) throws RuntimeException {
CMLElement root = null;
try {
Document doc = new CMLBuilder().build(new StringReader(cmlString));
root = (CMLElement) doc.getRootElement();
} catch (Exception e) {
throw new RuntimeException(e);
}
return root;
}
/**
* convenience routine to get query nodes (iterating thorugh get(i) is
* fragile if nodes are removed)
*
* @param node
* (can be null)
* @param xpath
* xpath relative to node
* @param context
* @return list of nodes (immutable) - empty if none
*/
public static List getQueryNodes(Node node, String xpath,
XPathContext context) {
List nodeList = new ArrayList();
if (node != null) {
Nodes nodes = node.query(xpath, context);
for (int i = 0; i < nodes.size(); i++) {
nodeList.add(nodes.get(i));
}
}
return nodeList;
}
/**
* convenience routine to get query nodes (iterating through get(i) is
* fragile if nodes are removed)
*
* @param node
* @param xpath
* @return list of nodes (immutable) - empty if none or null node
*/
public static List getQueryNodes(Node node, String xpath) {
List nodeList = new ArrayList();
if (node != null) {
try {
Nodes nodes = node.query(xpath);
for (int i = 0; i < nodes.size(); i++) {
nodeList.add(nodes.get(i));
}
} catch (Exception e) {
throw new RuntimeException("Bad xpath: "+xpath, e);
}
}
return nodeList;
}
/**
* convenience routine to get query Elements
* returns empty list if ANY nodes are not elements
* @param node
* @param xpath
* @return list of nodes (immutable) - empty if none or null node
*/
public static List getQueryElements(Node node, String xpath) {
List nodes = getQueryNodes(node, xpath);
return castNodesToElements(nodes);
}
/**
* convenience routine to get query Elements
* returns empty list if ANY nodes are not elements
* @param node
* @param xpath
* @return list of nodes (immutable) - empty if none or null node
*/
public static List getQueryElements(Node node, String xpath, XPathContext context) {
List nodes = getQueryNodes(node, xpath, context);
return castNodesToElements(nodes);
}
private static List castNodesToElements(List nodes) {
List elements = new ArrayList();
for (Node n : nodes) {
if (!(n instanceof Element)) {
return new ArrayList();
}
elements.add((Element) n);
}
return elements;
}
/**
* get next sibling.
*
* @author Eliotte Rusty Harold
* @param current
* may be null
* @return following sibling or null
*/
public static Node getFollowingSibling(Node current) {
Node node = null;
if (current != null) {
ParentNode parent = current.getParent();
if (parent != null) {
int index = parent.indexOf(current);
if (index + 1 < parent.getChildCount()) {
node = parent.getChild(index + 1);
}
}
}
return node;
}
/**
* get previous sibling.
*
* @param current
* @return previous sibling
*/
public static Node getPrecedingSibling(Node current) {
Node node = null;
if (current != null) {
ParentNode parent = current.getParent();
if (parent != null) {
int index = parent.indexOf(current);
if (index > 0) {
node = parent.getChild(index - 1);
}
}
}
return node;
}
/**
* gets last text descendant of element. this might be referenced from the
* following-sibling and will therefore be the immediately preceding chunk
* of text in document order if the node is a text node returns itself
*
* @param node
* @return Text node or null
*/
public static Text getLastTextDescendant(Node node) {
List l = CMLUtil.getQueryNodes(node, ".//text() | self::text()");
return (l.size() == 0) ? null : (Text) l.get(l.size() - 1);
}
/**
* gets first text descendant of element. this might be referenced from the
* preceding-sibling and will therefore be the immediately following chunk
* of text in document order if the node is a text node returns itself
*
* @param node
* @return Text node or null
*/
public static Text getFirstTextDescendant(Node node) {
List l = CMLUtil.getQueryNodes(node, ".//text() | self::text()");
return (l.size() == 0) ? null : (Text) l.get(0);
}
/**
* transfers children of 'from' to 'to'.
*
* @param from
* (will be left with no children)
* @param to
* (will gain 'from' children appended after any existing
* children
*/
public static void transferChildren(Element from, Element to) {
int nc = from.getChildCount();
int tc = to.getChildCount();
for (int i = nc - 1; i >= 0; i--) {
Node child = from.getChild(i);
child.detach();
to.insertChild(child, tc);
}
}
/**
* copies atributes of 'from' to 'to'
* @param from
* @param to
*/
public static void copyAttributes(Element from, Element to) {
int natt = from.getAttributeCount();
for (int i = 0; i < natt; i++) {
Attribute newAtt = new Attribute(from.getAttribute(i));
to.addAttribute(newAtt);
}
}
/**
* get XOM default canonical string.
*
* @param node
* @return the string
*/
public static String getCanonicalString(Node node) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Canonicalizer canon = new Canonicalizer(baos);
try {
canon.write(node);
} catch (IOException e) {
throw new RuntimeException("should never throw ", e);
}
return baos.toString();
}
/**
* remeoves all whitespace-only text nodes.
*
* @param element
* to strip whitespace from
*/
public static void removeWhitespaceNodes(Element element) {
int nChild = element.getChildCount();
List nodeList = new ArrayList();
for (int i = 0; i < nChild; i++) {
Node node = element.getChild(i);
if (node instanceof Text) {
if (node.getValue().trim().length() == 0) {
nodeList.add(node);
}
} else if (node instanceof Element) {
Element childElement = (Element) node;
removeWhitespaceNodes(childElement);
} else {
}
}
for (Node node : nodeList) {
node.detach();
}
}
/**
* sets text content of element. Does not support mixed content.
*
* @param element
* @param s
* @throws RuntimeException
* if element already has element content
*/
public static void setXMLContent(Element element, String s) {
List elements = CMLUtil.getQueryNodes(element, S_STAR);
if (elements.size() > 0) {
throw new RuntimeException(
"Cannot set text with element children");
}
Text text = CMLUtil.getFirstTextDescendant(element);
if (text == null) {
text = new Text(s);
element.appendChild(text);
} else {
text.setValue(s);
}
}
/**
* sets text content of element. Does not support mixed content.
*
* @param element
* @return text value
* @throws RuntimeException
* if element already has element content
*/
public static String getXMLContent(Element element) {
List elements = CMLUtil.getQueryNodes(element, S_STAR);
if (elements.size() > 0) {
throw new RuntimeException(
"Cannot get text with element children");
}
return element.getValue();
}
public static String toXMLString(Element element) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
CMLUtil.debug(element, baos, 0);
} catch (IOException e) {
}
return new String(baos.toByteArray());
}
/**
* read CML element. convenience method
*
* @param filename
* @return element
*/
public static CMLElement readElementFromResource(String filename) {
CMLElement element = null;
try {
InputStream in = Util.getInputStreamFromResource(filename);
element = (CMLElement) new CMLBuilder().build(in).getRootElement();
in.close();
} catch (Exception e) {
throw new RuntimeException("parse/read exception in " + filename
+ "; " + e);
}
return element;
}
/**
* bug report.
*
* @param message
*/
public static void BUG(String message) {
Util.BUG(message);
}
/**
* returns all prefixes in attributes in descendants. currently accesses all
* elements
*
* @param element
* @param attName
* attribute name (e.g. ref, dictRef)
* @return prefixes
*/
public static List getPrefixes(Element element, String attName) {
List prefixList = new ArrayList();
List refs = CMLUtil.getQueryNodes(element, ".//@" + attName,
CML_XPATH);
for (Node node : refs) {
Attribute attribute = (Attribute) node;
String value = attribute.getValue();
String prefix = CMLUtil.getPrefix(value);
if (!prefixList.contains(prefix)) {
prefixList.add(prefix);
}
}
return prefixList;
}
/**
* get namespace for list of prefixes.
*
* @param element
* in which namespaces are in scope
* @param prefixes
* @return list of namespaces
* @exception RuntimeException
* if any prefix does not map to a namespace
*/
public static List getNamespaces(Element element,
List prefixes) {
List namespaceList = new ArrayList();
for (String prefix : prefixes) {
String namespaceURI = element.getNamespaceURI(prefix);
if (namespaceURI == null) {
throw new RuntimeException("Missing namespace :" + prefix
+ ":");
}
CMLNamespace namespace = new CMLNamespace(prefix, namespaceURI);
namespaceList.add(namespace);
}
return namespaceList;
}
/**
* returns a list of list of integers. Supply it with an integer of the list
* size and it will return all possible combinations of all groupings of the
* integers up to the integer you supply
*
* thus supplying 3 would return: -- blank entry-- 1 2 3 1 2 1 3 2 3 1 2 3
*
* @param max
* @return list of all possible integer combinations going from 0 to max.
*/
public static List> generateCombinationList(int max) {
List> combinationList = new ArrayList>();
int count = (int) Math.pow(2.0, max);
for (int i = 2; i <= count; i++) {
int thisCount = i;
List intSet = new ArrayList(max);
for (int j = max; j >= 0; j--) {
int minus = (int) Math.pow(2.0, j);
int test = thisCount;
if (test - minus > 0) {
thisCount -= minus;
intSet.add(j);
}
}
combinationList.add(intSet);
}
// add entry with no values
combinationList.add(new ArrayList(0));
return combinationList;
}
/**
* make id from string. convert to lowercase and replace space by underscore
*
* @param s
* @return new id (null if s is null)
*/
public static String makeId(String s) {
String id = null;
if (s != null) {
id = s.toLowerCase();
id = id.replace(S_SPACE, S_UNDER);
}
return id;
}
/**
* create local CML class name. e.g. CMLFooBar from fooBar
*
* @param name
* @return name
*/
public static String makeCMLName(String name) {
return "CML" + capitalize(name);
}
/**
* create local Abstract class name. e.g. AbstractFooBar from fooBar
*
* @param name
* @return name
*/
public static String makeAbstractName(String name) {
return "Abstract" + capitalize(name);
}
/**
* capitalize name e.g. FooBar from fooBar
*
* @param name
* @return name
*/
public static String capitalize(String name) {
return name.substring(0, 1).toUpperCase() + name.substring(1);
}
/**
* tests 2 XML objects for equality using recursive descent.
* includes namespace testing
*
* @param refNodeXML xml serialization of first Element
* @param testElement second Element
* @param stripWhite if true remove w/s nodes
* @return message of where elements differ (null if identical)
*/
public static String equalsCanonically(String refNodeXML, Element testElement,
boolean stripWhite) {
Element refElement = null;
try {
refElement = new Builder().build(new StringReader(refNodeXML)).getRootElement();
} catch (Exception e) {
throw new RuntimeException("Parsing failed: "+refNodeXML);
}
String message = equalsCanonically(refElement, testElement, stripWhite, "/");
LOG.trace("EQCAN "+message);
return message;
}
/**
* tests 2 XML objects for equality using recursive descent.
* includes namespace testing
*
* @param refElement first node
* @param testElement second node
* @param stripWhite if true remove w/s nodes
* @return message of where elements differ (null if identical)
*/
public static String equalsCanonically(Element refElement, Element testElement,
boolean stripWhite) {
return equalsCanonically(refElement, testElement, stripWhite, "./");
}
/**
* tests 2 XML objects for equality using recursive descent.
* includes namespace testing
*
* @param refElement first node
* @param testElement second node
* @param stripWhite if true remove w/s nodes
* @return message of where elements differ (null if identical)
*/
public static String equalsCanonically(Element refElement, Element testElement,
boolean stripWhite, String xpath) {
String message = null;
// check if they are different objects
if (refElement != testElement) {
if (stripWhite) {
refElement = new Element(refElement);
removeWhitespaceNodes(refElement);
testElement = new Element(testElement);
removeWhitespaceNodes(testElement);
}
xpath = xpath+"*[local-name()='"+refElement.getLocalName()+"']/";
message = equalsCanonically(refElement, testElement, xpath);
}
return message;
}
private static String equalsCanonically(Element refElement, Element testElement, String xpath) {
String message;
message = CMLUtil.compareNamespacesCanonically(refElement, testElement, xpath);
if (message != null) {
return message;
}
String refName = refElement.getLocalName();
String testName = testElement.getLocalName();
if (message == null && !refName.equals(testName)) {
message = "element names differ at "+xpath+": "+refName+" != "+testName;
}
String refNamespace = refElement.getNamespaceURI();
String testNamespace = testElement.getNamespaceURI();
if (message == null && !refNamespace.equals(testNamespace)) {
message = "element namespaces differ at "+xpath+": "+refNamespace+" != "+testNamespace;
}
if (message == null) {
message = CMLUtil.compareAttributesCanonically(refElement, testElement, xpath);
}
if (message == null) {
message = CMLUtil.compareChildNodesCanonically(refElement, testElement, xpath);
}
return message;
}
public static String getCommonLeadingString(String s1, String s2) {
int l = Math.min(s1.length(), s2.length());
int i;
for (i = 0; i < l; i++) {
if (s1.charAt(i) != s2.charAt(i)) {
break;
}
}
return s1.substring(0, i);
}
/** compare namespaces on two elements
*
* @param refNode
* @param testNode
* @param xpath current ancestry of refNode
* @return
*/
public static String compareNamespacesCanonically(Element refNode, Element testNode, String xpath) {
String message = null;
List refNamespaceURIList = getNamespaceURIList(refNode);
List testNamespaceURIList = getNamespaceURIList(testNode);
if (refNamespaceURIList.size() != testNamespaceURIList.size()) {
message = "unequal namespace count;" +
" ref "+refNamespaceURIList.size()+";" +
" testCount "+testNamespaceURIList.size();
} else {
for (String refNamespaceURI : refNamespaceURIList) {
if (!testNamespaceURIList.contains(refNamespaceURI)) {
message = "Cannot find "+refNamespaceURI+
" in test namespaces ";
break;
}
}
}
return message;
}
/**
* @param node
* @param count
*/
private static List getNamespaceURIList(Element node) {
List namespaceURIList = new ArrayList();
for (int i = 0; i < node.getNamespaceDeclarationCount(); i++) {
String prefix = node.getNamespacePrefix(i);
String refNamespaceURI = node.getNamespaceURI(prefix);
namespaceURIList.add(refNamespaceURI);
}
return namespaceURIList;
}
/** compare attributes on two elements.
* includes normalizing attribute values
*
* @param refNode
* @param testNode
* @param xpath current ancestry of refNode
* @return
*/
public static String compareAttributesCanonically(Element refNode, Element testNode, String xpath) {
String message = null;
int refCount = refNode.getAttributeCount();
int testCount = testNode.getAttributeCount();
if (refCount != testCount) {
message = "unequal attribute count at "+xpath+" ("+refCount+" != "+testCount+")";
}
if (message == null) {
for (int i = 0; i < refCount; i++) {
Attribute attribute = refNode.getAttribute(i);
String name = attribute.getLocalName();
String namespace = attribute.getNamespaceURI();
String value = attribute.getValue();
Attribute testAttribute = (namespace == null) ?
testNode.getAttribute(name) :
testNode.getAttribute(name, namespace);
if (testAttribute == null) {
message = "no attribute in test ("+xpath+") for "+CMLUtil.printName(name, namespace);
break;
}
String refValue = CMLUtil.normalizeSpace(value);
String testValue = CMLUtil.normalizeSpace(testAttribute.getValue());
if (!refValue.equals(testValue)) {
message = "normalized attribute values for ("+xpath+"@"+CMLUtil.printName(name, namespace)+") "+refValue+" != "+testValue;
break;
}
}
}
LOG.trace("ATT MS "+message);
return message;
}
private static String printName(String name, String namespace) {
return name+((namespace == null || namespace.equals(S_EMPTY)) ? "" : "["+namespace+"]");
}
public static String normalizeSpace(String value) {
return value.replaceAll(S_WHITEREGEX, S_SPACE).trim();
}
/** compare child nodes recursively
*
* @param refNode
* @param testNode
* @param xpath current ancestry of refNode
* @return
*/
public static String compareChildNodesCanonically(Element refNode, Element testNode, String xpath) {
String message = null;
int refCount = refNode.getChildCount();
int testCount = testNode.getChildCount();
if (refCount != testCount) {
message = "unequal child node count at "+xpath+" ("+refCount+" != "+testCount+")";
}
if (message == null) {
for (int i = 0; i < refCount; i++) {
String xpathChild = xpath+"node()[position()="+(i+1)+"]";
Node refChildNode = refNode.getChild(i);
Node testChildNode = testNode.getChild(i);
Class> refClass = refChildNode.getClass();
Class> testClass = testChildNode.getClass();
if (!refClass.equals(testClass)) {
message = "child node classes differ at "+xpathChild+" "+refClass+"/"+testClass;
break;
} else if (refChildNode instanceof Element) {
message = CMLUtil.equalsCanonically((Element) refChildNode, (Element) testChildNode,
xpathChild);
} else {
message = CMLUtil.compareNonElementNodesCanonically(refChildNode, testChildNode, xpath);
if (message != null) {
break;
}
}
}
}
return message;
}
/** compare non-element nodes.
* not yet tuned for normalizing adjacent CDATA and other horrors
* @param refNode
* @param testNode
* @param xpath current ancestry of refNode
* @return
*/
public static String compareNonElementNodesCanonically(Node refNode, Node testNode, String xpath) {
String message = null;
String refValue = refNode.getValue();
String testValue = testNode.getValue();
if (refNode instanceof Comment) {
if (!refValue.equals(testValue)) {
message = "comments at ("+xpath+") differ: "+refValue+" != "+testValue;
}
} else if (refNode instanceof Text) {
if (!refValue.equals(testValue)) {
message = "text contents at ("+xpath+") differ: ["+refValue+"] != ["+testValue+"]";
}
} else if (refNode instanceof ProcessingInstruction) {
String refTarget = ((ProcessingInstruction) refNode).getTarget();
String testTarget = ((ProcessingInstruction) testNode).getTarget();
if (!refTarget.equals(testTarget)) {
message = "PI targets at ("+xpath+") differ: "+refTarget+" != "+testTarget;
}
} else {
LOG.warn("Unknown XML element in comparison: "+refNode.getClass());
}
return message;
}
/**
* some formatted XML introduces spurious WS after text strings
* @param element
*/
public static void stripTrailingWhitespaceinTexts(Element element) {
Nodes texts = element.query("//text()");
for (int i = 0; i < texts.size(); i++) {
Text text = (Text) texts.get(i);
String value = text.getValue();
value = Util.rightTrim(value);
text.setValue(value);
}
}
public static Element getSingleElement(Element element, String xpath) {
Nodes nodes = element.query(xpath);
return (nodes.size() == 1) ? (Element) nodes.get(0) : null;
}
public static void detach(nu.xom.Element element) {
ParentNode parent = (element == null) ? null : element.getParent();
if (parent != null) {
if (parent instanceof Document) {
parent.replaceChild(element, new Element(DUMMY));
} else {
element.detach();
}
}
}
public static Document ensureDocument(Element rootElement) {
Document doc = null;
if (rootElement != null) {
doc = rootElement.getDocument();
if (doc == null) {
doc = new Document(rootElement);
}
}
return doc;
}
public static Document parseQuietlyToDocument(InputStream is) {
Document document = null;
try {
document = new Builder().build(is);
} catch (Exception e) {
throw new RuntimeException("cannot parse/read stream: ", e);
}
return document;
}
public static Document parseQuietlyToCMLDocument(InputStream is) {
Document document = null;
try {
document = new CMLBuilder().build(is);
} catch (Exception e) {
throw new RuntimeException("cannot parse/read stream: ", e);
}
return document;
}
public static Document parseResourceQuietlyToDocument(String resource) {
Document document = null;
try {
document = new Builder().build(Util.getInputStreamFromResource(resource));
} catch (Exception e) {
throw new RuntimeException("cannot parse/read resource: "+resource, e);
}
return document;
}
public static Document parseQuietlyToDocument(File xmlFile) {
Document document = null;
try {
document = new Builder().build(xmlFile);
} catch (Exception e) {
throw new RuntimeException("cannot parse/read file: "+xmlFile.getAbsolutePath(), e);
}
return document;
}
public static CMLElement parseQuietlyIntoCML(String s) {
ByteArrayInputStream bais = new ByteArrayInputStream(s.getBytes());
return parseQuietlyIntoCML(bais);
}
public static CMLElement parseQuietlyIntoCML(File xmlFile) {
CMLElement rootElement = null;
try {
rootElement = (CMLElement) new CMLBuilder().build(xmlFile).getRootElement();
} catch (Exception e) {
throw new RuntimeException("cannot parse/read file: "+xmlFile.getAbsolutePath(), e);
}
return rootElement;
}
public static CMLElement parseQuietlyIntoCML(InputStream inputStream) {
CMLElement rootElement = null;
try {
rootElement = (CMLElement) new CMLBuilder().build(inputStream).getRootElement();
} catch (Exception e) {
throw new RuntimeException("cannot parse/read inputStream ", e);
}
return rootElement;
}
public static Document parseQuietlyIntoCMLDocument(File xmlFile) {
Document document = ensureDocument(parseQuietlyIntoCML(xmlFile));
return document;
}
public static List convertNodesToMoleculeList(Nodes moleculeNodes) {
List moleculeList = new ArrayList();
for (int i = 0; i < moleculeNodes.size(); i++) {
moleculeList.add((CMLMolecule) moleculeNodes.get(i));
}
return moleculeList;
}
public static List extractTopLevelMolecules(Node node) {
String xpath = "//*[not(local-name()='molecule')]" +
"/*[local-name()='molecule'] | self::*[local-name()='molecule']";
return CMLUtil.convertNodesToMoleculeList(node.query(xpath));
}
/** recursively delete all non-default and non-cml attributes
* i.e. any attribute with explicit non-cml namespace
* includes cmlx
*
* @param element
*/
public static void removeNonCMLAttributes(CMLElement element) {
List attributes = new ArrayList();
for (int i = 0; i < element.getAttributeCount(); i++) {
Attribute attribute = element.getAttribute(i);
String namespaceURI = attribute.getNamespaceURI();
if (namespaceURI != null
&& !namespaceURI.equals("")
&& !namespaceURI.equals(CMLConstants.CML_NS)) {
attributes.add(attribute);
}
}
for (Attribute attribute : attributes) {
attribute.detach();
}
List childElementList = element.getChildCMLElements();
for (CMLElement childElement : childElementList) {
removeNonCMLAttributes(childElement);
}
}
/** Removes the following content:
*
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN'
'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
*
* @param s String of the SVG document
* @return SVG document with problematic content removed
* @throws IOException
*/
public static Document stripDTDAndOtherProblematicXMLHeadings(String s) throws IOException {
if (s == null || s.length() == 0) {
throw new RuntimeException("zero length document");
}
// strip DTD
int idx = s.indexOf(DTD);
String baosS = s;
if (idx != -1) {
int ld = idx+DTD.length()+1;
if (ld < 0) {
throw new RuntimeException("BUG in stripping DTD");
}
try {
baosS = s.substring(ld);
} catch (Exception e) {
throw new RuntimeException("cannot parse string: ("+s.length()+"/"+ld+"/"+idx+") "+s.substring(0, Math.min(500, s.length())),e);
}
}
// strip HTML namespace
baosS = baosS.replace(" xmlns=\"http://www.w3.org/1999/xhtml\"", "");
// strip XML declaration
baosS = baosS.replace("", "");
baosS = removeScripts(baosS);
Document document;
try {
ByteArrayInputStream bais = new ByteArrayInputStream(baosS.getBytes()); // avoid reader
document = new Builder().build(bais);
} catch (Exception e) {
System.out.println("trying to parse:"+baosS+":");
throw new RuntimeException("BUG: DTD stripper should have created valid XML: "+e);
}
return document;
}
private static String removeScripts(String baosS) {
return removeTags("script", baosS);
}
private static String removeTags(String tag, String ss) {
int current = 0;
StringBuilder sb = new StringBuilder();
String startTag = "<"+tag;
String endTag = ""+tag+">";
while (true) {
int i = ss.indexOf(startTag, current);
if (i == -1) {
sb.append(ss.substring(current));
break;
}
sb.append(ss.substring(current, i));
i = ss.indexOf(endTag, current);
if (i == -1) {
throw new RuntimeException("missing endTag: "+endTag);
}
current = (i + endTag.length());
}
return sb.toString();
}
public static void debugPreserveWhitespace(Element element) {
try {
CMLUtil.debug(element, System.out, 0);
} catch (Exception e) {
throw new RuntimeException("BUG", e);
}
}
public static Element normalizeWhitespaceInTextNodes(Element element) {
Nodes texts = element.query(".//text()");
for (int i = 0; i < texts.size(); i++) {
Text text = (Text) texts.get(i);
text.setValue(normalizeSpace(text.getValue()));
}
return element;
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/DoubleArraySTAttribute.java 0000775 0000000 0000000 00000011437 14772244610 0027666 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.base;
import java.text.ParseException;
import org.xmlcml.euclid.Util;
import nu.xom.Attribute;
/**
* attribute representing an array of doubles.
*/
public class DoubleArraySTAttribute extends CMLAttribute {
/** dewisott */
public final static String JAVA_TYPE = "double[]";
/** dewisott */
public final static String JAVA_GET_METHOD = "getDoubleArray";
/** dewisott */
public final static String JAVA_SHORT_CLASS = "DoubleArraySTAttribute";
protected double[] dd = null;
protected int length = -1;
/**
* constructor.
*
* @param name
*/
public DoubleArraySTAttribute(String name) {
super(name);
}
/**
* construct from existing attribute.
*
* @param att
*/
public DoubleArraySTAttribute(Attribute att) {
this(att.getLocalName());
this.setCMLValue(att.getValue());
}
/**
* from DOM.
*
* @param att
* to copy, except value
* @param value
*/
public DoubleArraySTAttribute(Attribute att, String value) {
super(att, value.trim().replace(S_WHITEREGEX, S_SPACE));
}
/**
* copy constructor
*
* @param att
*/
public DoubleArraySTAttribute(DoubleArraySTAttribute att) {
super(att);
if (att.dd != null) {
this.dd = new double[att.dd.length];
for (int i = 0; i < dd.length; i++) {
this.dd[i] = att.dd[i];
}
}
this.length = att.length;
}
/**
* copy. uses copy constructor.
*
* @return copy
*/
public Attribute copy() {
return new DoubleArraySTAttribute(this);
}
/**
* sets value. throws exception if of wrong type or violates restriction
*
* @param s
* the value
*/
public void setCMLValue(String s) {
if (s != null && !s.trim().equals(S_EMPTY)) {
double[] dd = split(s.trim().replace(S_WHITEREGEX, S_SPACE),
S_WHITEREGEX);
this.setCMLValue(dd);
}
}
/**
* set and check value.
*
* @param dd
* @throws RuntimeException
*/
public void setCMLValue(double[] dd) throws RuntimeException {
checkValue(dd);
this.dd = new double[dd.length];
for (int i = 0; i < dd.length; i++) {
this.dd[i] = dd[i];
}
this.setValue(Util.concatenate(dd, S_SPACE));
}
/**
* checks value of simpleType. if value does not check
* against SimpleType uses CMLType.checkvalue() fails if type is String or
* int or is not a list
*
* @param dd
* the double array
* @throws RuntimeException
* wrong type or value fails
*/
public void checkValue(double[] dd) throws RuntimeException {
if (cmlType != null) {
cmlType.checkValue(dd);
}
}
/**
* splits string into doubles.
*
* @param s
* the string
* @param delim
* delimiter (if null defaults to S_SPACE);
* @throws RuntimeException
* If the doubles have bad values.
* @return split doubles
*/
public static double[] split(String s, String delim) {
String sss = s;
if (delim == null || delim.trim().equals(S_EMPTY)
|| delim.equals(S_WHITEREGEX)) {
delim = S_WHITEREGEX;
sss = sss.trim();
} else {
}
String[] ss = sss.split(delim);
double[] dd = new double[ss.length];
for (int i = 0; i < ss.length; i++) {
try {
dd[i] = (Util.parseFlexibleDouble(ss[i]));
} catch (NumberFormatException nfe) {
throw new RuntimeException(S_EMPTY + nfe);
} catch (ParseException e) {
throw new RuntimeException("Bad double value: " + ss[i]
+ " at " + i +" in "+ sss, e);
}
}
return dd;
}
/**
* get array.
*
* @return null if not set
*/
public Object getCMLValue() {
return dd;
}
/**
* get array.
*
* @return null if not set
*/
public double[] getDoubleArray() {
return dd;
}
/**
* get Java type.
*
* @return type
*/
public String getJavaType() {
return JAVA_TYPE;
}
/**
* get method.
*
* @return method
*/
public String getJavaGetMethod() {
return JAVA_GET_METHOD;
}
/**
* get short class name.
*
* @return classname
*/
public String getJavaShortClassName() {
return JAVA_SHORT_CLASS;
}
};
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/DoubleSTAttribute.java 0000775 0000000 0000000 00000007404 14772244610 0026666 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.base;
import java.text.ParseException;
import org.xmlcml.euclid.Util;
import nu.xom.Attribute;
/**
* attribute representing a double value.
*
*/
public class DoubleSTAttribute extends CMLAttribute {
/** dewisott */
public final static String JAVA_TYPE = "double";
/** dewisott */
public final static String JAVA_GET_METHOD = "getDouble";
/** dewisott */
public final static String JAVA_SHORT_CLASS = "DoubleSTAttribute";
protected Double d;
/**
* constructor.
*
* @param name
*/
public DoubleSTAttribute(String name) {
super(name);
}
/**
* from DOM.
*
* @param att
*/
public DoubleSTAttribute(Attribute att) {
this(att.getLocalName());
String v = att.getValue();
if (v != null && !v.trim().equals(S_EMPTY)) {
this.setCMLValue(v);
}
}
/**
* from DOM.
*
* @param att
* to copy, except value
* @param value
*/
public DoubleSTAttribute(Attribute att, String value) {
super(att, value.trim());
}
/**
* copy constructor
*
* @param att
*/
public DoubleSTAttribute(DoubleSTAttribute att) {
super(att);
if (att.d != null) {
this.d = Double.valueOf(att.d.doubleValue());
}
}
/**
* copy. uses copy constructor.
*
* @return copy
*/
public Attribute copy() {
return new DoubleSTAttribute(this);
}
/**
* get java type.
*
* @return java type
*/
public String getJavaType() {
return "double";
}
/**
* sets value. throws exception if of wrong type or violates restriction
*
* @param s
* the value
* @throws RuntimeException
*/
public void setCMLValue(String s) {
if (s != null && !s.trim().equals(S_EMPTY)) {
double d;
try {
String ss = s.trim();
if (ss.startsWith(S_PLUS)) {
ss = ss.substring(1);
}
d = (Util.parseFlexibleDouble(ss));
} catch (NumberFormatException nfe) {
throw new RuntimeException("" + nfe, nfe);
} catch (ParseException e) {
throw new RuntimeException("Bad double: " + s.trim(), e);
}
this.setCMLValue(d);
}
}
/**
* checks value of simpleType. if value does not check
* against SimpleType uses CMLType.checkvalue() fails if type is String or
* int or is a list
*
* @param d
* the double
* @throws RuntimeException
* wrong type or value fails
*/
public void checkValue(double d) throws RuntimeException {
if (cmlType != null) {
cmlType.checkValue(d);
}
}
/**
* set and check value.
*
* @param d
*/
public void setCMLValue(double d) {
checkValue(d);
this.d = Double.valueOf(d);
this.setValue("" + d);
}
/**
* get double.
*
* @return value
*/
public double getDouble() {
return d.doubleValue();
}
/**
* get java method.
*
* @return java method
*/
public String getJavaGetMethod() {
return JAVA_GET_METHOD;
}
/**
* get java short class name.
*
* @return java short className
*/
public String getJavaShortClassName() {
return JAVA_SHORT_CLASS;
}
};
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/ElementGenerator.java 0000775 0000000 0000000 00000006656 14772244610 0026571 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
*/
package org.xmlcml.cml.base;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import nu.xom.Element;
import nu.xom.Node;
import org.xmlcml.euclid.Util;
/**
* @author pm286
*
*/
public class ElementGenerator extends AbstractGenerator {
private Map elementTypeMap;
/**
* @param schemaManager
*/
public ElementGenerator(SchemaManager schemaManager) {
this.schemaManager= schemaManager;
init();
}
private void init() {
elementTypeMap = new HashMap();
nameList = new ArrayList();
}
/** read assemble.
*
* @param indir
* @throws Exception
*/
public void readAssembleAndIndexElementSchema(String indir) throws Exception {
this.readAndAssembleSchemaComponents(indir);
this.indexSchema();
}
/** index schema.
*/
public void indexSchema() {
List xsdElements = CMLUtil.getQueryNodes(schema, "./"+XSD_ELEMENT, XPATH_XSD);
// iterate through all elements
for (Node node : xsdElements) {
Element xsdElement = (Element) node;
String name = xsdElement.getAttributeValue("name");
CMLElementType elementType = null;
if (name == null) {
System.err.println("No name element on element");
} else {
elementType = new CMLElementType(xsdElement);
elementTypeMap.put(name, elementType);
nameList.add(name);
}
Map attributeGroupMap = schemaManager.getAttributeGenerator().getAttributeGroupMap();
elementType.processAttributes(attributeGroupMap);
Map typeMap = schemaManager.getTypeGenerator().getMap();
elementType.processSimpleContent(typeMap);
}
// re-iterate through elements (why??)
for (String name : nameList) {
CMLElementType elementType = elementTypeMap.get(name);
elementType.processComplexContent(elementTypeMap);
}
}
void printElements() {
for (String name : nameList) {
CMLElementType elementType = elementTypeMap.get(name);
Util.println("========================================");
Util.println(name);
Util.println("========================================");
Util.println(elementType.toString());
}
}
/**
* @return the elementTypeMap
*/
public Map getElementTypeMap() {
return elementTypeMap;
}
/**
* @param elementTypeMap the elementTypeMap to set
*/
public void setElementTypeMap(Map elementTypeMap) {
this.elementTypeMap = elementTypeMap;
}
/**
* @return the nameList
*/
public List getNameList() {
return nameList;
}
/**
* @param nameList the nameList to set
*/
public void setNameList(List nameList) {
this.nameList = nameList;
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/HasId.java 0000775 0000000 0000000 00000001563 14772244610 0024311 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.base;
/** tags CMLElement as having id.
*
* @author pm286
*
*/
public interface HasId {
/**
* @param id
*/
void setId(String id);
/**
* @return id
*/
String getId();
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/IntArraySTAttribute.java 0000775 0000000 0000000 00000011760 14772244610 0027205 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.base;
import org.xmlcml.euclid.Util;
import nu.xom.Attribute;
/**
* attribute representing an int value..
*/
public class IntArraySTAttribute extends CMLAttribute {
/** */
public final static String JAVA_TYPE = JAVA_INT+JAVA_ARRAY;
/** */
public final static String JAVA_GET_METHOD = "getIntArray";
/** */
public final static String JAVA_SHORT_CLASS = "IntArraySTAttribute";
protected int[] ii = null;
protected int length = -1;
/**
* constructor.
*
* @param name
*/
public IntArraySTAttribute(String name) {
super(name);
}
/**
* from DOM.
*
* @param att
*/
public IntArraySTAttribute(Attribute att) {
this(att.getLocalName());
this.setCMLValue(att.getValue());
}
/**
* copy constructor
*
* @param att
*/
public IntArraySTAttribute(IntArraySTAttribute att) {
super(att);
if (att.ii != null) {
this.ii = new int[att.ii.length];
for (int i = 0; i < ii.length; i++) {
this.ii[i] = att.ii[i];
}
}
this.length = att.length;
}
/** copy.
* uses copy constructor.
* @return copy
*/
public Attribute copy() {
return new IntArraySTAttribute(this);
}
/**
* from DOM.
*
* @param att
* to copy, except value
* @param value
*/
public IntArraySTAttribute(Attribute att, String value) {
super(att, value.trim().replace(S_WHITEREGEX, CMLConstants.S_SPACE));
}
/**
* set and check value.
*
* @param ii
*/
public void setCMLValue(int[] ii) {
checkValue(ii);
this.ii = new int[ii.length];
for (int i = 0; i < ii.length; i++) {
this.ii[i] = ii[i];
}
this.setValue(Util.concatenate(ii, CMLConstants.S_SPACE));
}
/**
* checks value of simpleType. if value does not check
* against SimpleType uses CMLType.checkvalue() fails if type is String or
* double or is not a list
*
* @param ii
* the int array
* @throws RuntimeException
* wrong type or value fails
*/
public void checkValue(int[] ii) {
if (cmlType != null) {
cmlType.checkValue(ii);
}
}
/**
* splits string into ints.
*
* @param s the string
* @param delim delimiter
* @return array
*/
public static int[] split(String s, String delim) {
String sss = s.trim().replace(S_WHITEREGEX, CMLConstants.S_SPACE);
if (delim == null || delim.trim().equals(S_EMPTY)
|| delim.equals(S_WHITEREGEX)) {
delim = CMLConstants.S_WHITEREGEX;
sss = sss.trim();
}
String[] ss = sss.split(delim);
int[] ii = new int[ss.length];
for (int i = 0; i < ss.length; i++) {
try {
ii[i] = Integer.parseInt(ss[i]);
} catch (NumberFormatException nfe) {
throw new RuntimeException(S_EMPTY + nfe);
}
}
return ii;
}
/**
* sets value. throws exception if of wrong type or violates restriction
*
* @param s
* the value
* @throws RuntimeException
*/
public void setCMLValue(String s) {
int[] ii = split(s.trim(), CMLConstants.S_WHITEREGEX);
this.setCMLValue(ii);
}
/**
* get array.
*
* @return null if not set
*/
public Object getCMLValue() {
return ii;
}
/**
* get array.
*
* @return null if not set
*/
public int[] getIntArray() {
return ii;
}
/**
* get java type.
*
* @return java type
*/
public String getJavaType() {
return JAVA_TYPE;
}
/**
* get java method.
*
* @return java method
*/
public String getJavaGetMethod() {
return JAVA_GET_METHOD;
}
/**
* get java short class name.
*
* @return java short className
*/
public String getJavaShortClassName() {
return JAVA_SHORT_CLASS;
}
};
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/IntSTAttribute.java 0000775 0000000 0000000 00000010056 14772244610 0026203 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.base;
import nu.xom.Attribute;
/**
* attribute representing an int value.
*/
public class IntSTAttribute extends CMLAttribute {
/** */
public final static String JAVA_TYPE = JAVA_INT;
/** */
public final static String JAVA_GET_METHOD = "getInt";
/** */
public final static String JAVA_SHORT_CLASS = "IntSTAttribute";
protected Integer i;
/**
* constructor.
*
* @param name
*/
public IntSTAttribute(String name) {
super(name);
}
/**
* from DOM.
*
* @param att
*/
public IntSTAttribute(Attribute att) {
this(att.getLocalName());
String v = att.getValue();
if (v != null && !v.trim().equals(S_EMPTY)) {
this.setCMLValue(v);
}
}
/**
* copy constructor
*
* @param att
*/
public IntSTAttribute(IntSTAttribute att) {
super(att);
if (att.i != null) {
this.i = Integer.valueOf(att.i.intValue());
}
}
/** copy.
* uses copy constructor.
* @return copy
*/
public Attribute copy() {
return new IntSTAttribute(this);
}
/**
* from DOM.
*
* @param att
* to copy, except value
* @param value
*/
public IntSTAttribute(Attribute att, String value) {
super(att, value.trim().replace(S_WHITEREGEX, CMLConstants.S_SPACE));
}
/**
* sets value. throws exception if of wrong type or violates restriction
*
* @param s
* the value
*/
public void setCMLValue(String s) {
if (s!= null && !s.trim().equals(S_EMPTY)) {
int i;
try {
i = Integer.parseInt(s.trim());
} catch (NumberFormatException nfe) {
throw new RuntimeException(S_EMPTY + nfe);
}
this.setCMLValue(i);
}
}
/**
* set and check value.
*
* @param i
*/
public void setCMLValue(int i) {
checkValue(i);
this.i = Integer.valueOf(i);
this.setValue(S_EMPTY + i);
}
/**
* checks value of simpleType. if value does not check
* against SimpleType uses CMLType.checkvalue() fails if type is String or
* double or is a list
*
* @param i
* the value
*/
public void checkValue(int i) {
if (cmlType != null) {
cmlType.checkValue(i);
}
}
/**
* returns value as Integer.
*
* @return value
*/
public Object getCMLValue() {
return i;
}
/**
* returns value as int.
*
* @return int
*/
public int getInt() {
if (i == null) {
throw new RuntimeException("integer attribute unset");
}
return i.intValue();
}
/**
* get java type.
*
* @return java type
*/
public String getJavaType() {
return JAVA_TYPE;
}
/**
* get java method.
*
* @return java method
*/
public String getJavaGetMethod() {
return JAVA_GET_METHOD;
}
/**
* get java short class name.
*
* @return java short className
*/
public String getJavaShortClassName() {
return JAVA_SHORT_CLASS;
}
};
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/SchemaManager.java 0000775 0000000 0000000 00000006651 14772244610 0026017 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
*/
package org.xmlcml.cml.base;
import nu.xom.Document;
/**
* @author pm286
*
*/
public class SchemaManager implements CMLConstants {
/** aggregated types*/
public static final String TYPES_XSD = "org/xmlcml/cml/base/types.xsd";
/** aggregated elements*/
public static final String ELEMENTS_XSD = "org/xmlcml/cml/base/elements.xsd";
/** aggregated attributes*/
public static final String ATTRIBUTEGROUPS_XSD = "org/xmlcml/cml/base/attributes.xsd";
private AttributeGenerator attributeGenerator;
private ElementGenerator elementGenerator;
private TypeGenerator typeGenerator;
private String outdir;
/** constructor.
*/
public SchemaManager() {
attributeGenerator = new AttributeGenerator(this);
elementGenerator = new ElementGenerator(this);
typeGenerator = new TypeGenerator(this);
// readAndCreateIndexes();
}
/** read and create indexes.
*/
public void readAndCreateIndexesFromSchemaFiles() {
try {
Document typeSchemaDoc = CMLUtil.getXMLResource(TYPES_XSD);
typeGenerator.setSchema(typeSchemaDoc.getRootElement());
typeGenerator.addXSDTypes();
typeGenerator.indexSchema();
Document attributeSchemaDoc = CMLUtil.getXMLResource(ATTRIBUTEGROUPS_XSD);
attributeGenerator.setSchema(attributeSchemaDoc.getRootElement());
attributeGenerator.indexSchema();
Document elementSchemaDoc = CMLUtil.getXMLResource(ELEMENTS_XSD);
elementGenerator.setSchema(elementSchemaDoc.getRootElement());
elementGenerator.indexSchema();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Cannot index schemas: "+e);
}
}
/**
* @return the attributeGenerator
*/
public AttributeGenerator getAttributeGenerator() {
return attributeGenerator;
}
/**
* @param attributeGenerator the attributeGenerator to set
*/
public void setAttributeGenerator(AttributeGenerator attributeGenerator) {
this.attributeGenerator = attributeGenerator;
}
/**
* @return the elementGenerator
*/
public ElementGenerator getElementGenerator() {
return elementGenerator;
}
/**
* @param elementGenerator the elementGenerator to set
*/
public void setElementGenerator(ElementGenerator elementGenerator) {
this.elementGenerator = elementGenerator;
}
/**
* @return the typeGenerator
*/
public TypeGenerator getTypeGenerator() {
return typeGenerator;
}
/**
* @param typeGenerator the typeGenerator to set
*/
public void setTypeGenerator(TypeGenerator typeGenerator) {
this.typeGenerator = typeGenerator;
}
/**
* @return the outdir
*/
public String getOutdir() {
return outdir;
}
/**
* @param outdir the outdir to set
*/
public void setOutdir(String outdir) {
this.outdir = outdir;
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/StringArraySTAttribute.java 0000775 0000000 0000000 00000010563 14772244610 0027721 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.base;
import org.xmlcml.euclid.Util;
import nu.xom.Attribute;
/**
* attribute representing an array of Strings.
*/
public class StringArraySTAttribute extends CMLAttribute {
/** */
public final static String JAVA_TYPE = JAVA_STRING+JAVA_ARRAY;
/** */
public final static String JAVA_GET_METHOD = "getStringArray";
/** */
public final static String JAVA_SHORT_CLASS = "StringArraySTAttribute";
protected String[] ss = null;
/**
* constructor.
*
* @param name
*/
public StringArraySTAttribute(String name) {
super(name);
}
/**
* from DOM.
*
* @param att
*/
public StringArraySTAttribute(Attribute att) {
this(att.getLocalName());
this.setCMLValue(att.getValue());
}
/**
* Sets the XOM value, and the CMLValue array.
*/
@Override
public void setValue(String s){
super.setValue(s);
this.setCMLValue(s);
}
/**
* copy constructor
*
* @param att
*/
public StringArraySTAttribute(StringArraySTAttribute att) {
super(att);
if (att.ss != null) {
this.ss = new String[att.ss.length];
for (int i = 0; i < ss.length; i++) {
this.ss[i] = att.ss[i];
}
}
}
/** copy.
* uses copy constructor.
* @return copy
*/
public Attribute copy() {
return new StringArraySTAttribute(this);
}
/**
* from DOM.
*
* @param att
* to copy, except value
* @param value
*/
public StringArraySTAttribute(Attribute att, String value) {
super(att);
this.setCMLValue(value);
}
/**
* sets value. throws exception if of wrong type or violates restriction
*
* @param s
* the value
*/
public void setCMLValue(String s) {
this.setCMLValue(arrayFromString(s));
}
protected String[] arrayFromString(String s){
String[] split = s.trim().split(S_WHITEREGEX);
return split;
}
protected String stringFromArray(String[] array){
return Util.concatenate(array, CMLConstants.S_SPACE);
}
/**
* set and check value.
*
* @param ss
*/
public void setCMLValue(String[] ss) {
checkValue(ss);
this.ss = ss;
super.setValue(stringFromArray(ss));
}
/**
* checks value of simpleType. if value does not check
* against SimpleType uses CMLType.checkvalue() fails if type is int or
* double or is not a list
*
* @param ss
* the String array
* @throws RuntimeException
* wrong type or value fails
*/
public void checkValue(String[] ss) {
if (cmlType != null) {
cmlType.checkValue(ss);
}
}
/**
* get array.
*
* @return null if not set
*/
public Object getCMLValue() {
return ss;
}
/**
* get array.
*
* @return null if not set
*/
public String[] getStringArray() {
return ss;
}
/**
* get java type.
*
* @return java type
*/
public String getJavaType() {
return JAVA_TYPE;
}
/**
* get java method.
*
* @return java method
*/
public String getJavaGetMethod() {
return JAVA_GET_METHOD;
}
/**
* get java short class name.
*
* @return java short className
*/
public String getJavaShortClassName() {
return JAVA_SHORT_CLASS;
}
};
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/StringSTAttribute.java 0000775 0000000 0000000 00000007147 14772244610 0026726 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.base;
import nu.xom.Attribute;
/**
* attribute representing a string value.
*
*/
public class StringSTAttribute extends CMLAttribute {
/** */
public final static String JAVA_TYPE = JAVA_STRING;
/** */
public final static String JAVA_GET_METHOD = "getString";
/** */
public final static String JAVA_SHORT_CLASS = "StringSTAttribute";
/**
* constructor.
*
* @param name
*/
public StringSTAttribute(String name) {
super(name);
}
/**
* from DOM.
*
* @param att
*/
public StringSTAttribute(Attribute att) {
this(att.getLocalName());
this.setCMLValue(att.getValue());
}
/**
* copy constructor
*
* @param att
*/
public StringSTAttribute(StringSTAttribute att) {
super(att);
if (att.getValue() != null) {
this.setValue(att.getValue());
}
}
/** copy.
* uses copy constructor.
* @return copy
*/
public Attribute copy() {
return new StringSTAttribute(this);
}
/**
* from DOM.
*
* @param att
* to copy, except value
* @param value
*/
public StringSTAttribute(Attribute att, String value) {
super(att, value.trim().replace(S_WHITEREGEX, CMLConstants.S_SPACE));
}
/**
* set and check value.
* trims by default
* use setCMLValue(s, trim)
* @param s
*/
public void setCMLValue(String s) {
this.setCMLValue(s, true);
}
/**
* set and check value.
*
* @param string
*/
public void setCMLValue(String string, boolean trim) {
if (string == null) {
throw new RuntimeException("Cannot set null attribute value");
}
if (trim) {
string = string.trim();
}
checkValue(string);
//this.s = string;
this.setValue(string);
}
/**
* checks value of simpleType. uses CMLType.checkvalue() fails if type is
* int or double or is a list
*
* @param s
* the value
* @throws RuntimeException
* wrong type or value fails
*/
public void checkValue(String s) {
if (cmlType != null) {
cmlType.checkValue(s);
}
}
/**
* get value.
*
* @return value
*/
public String getString() {
return this.getValue();
}
/**
* get java type.
*
* @return java type
*/
public String getJavaType() {
return JAVA_TYPE;
}
/**
* get java method.
*
* @return java method
*/
public String getJavaGetMethod() {
return JAVA_GET_METHOD;
}
/**
* get java short class name.
*
* @return java short className
*/
public String getJavaShortClassName() {
return JAVA_SHORT_CLASS;
}
};
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/TypeGenerator.java 0000775 0000000 0000000 00000012455 14772244610 0026113 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
*/
package org.xmlcml.cml.base;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import nu.xom.Element;
import nu.xom.Node;
import org.apache.log4j.Logger;
/**
* @author pm286
*
*/
public class TypeGenerator extends AbstractGenerator {
private static Logger LOG = Logger.getLogger(TypeGenerator.class);
Map map;
/**
* @param schemaManager
*
*/
public TypeGenerator(SchemaManager schemaManager) {
this.schemaManager= schemaManager;
init();
}
private void init() {
map = new HashMap();
nameList = new ArrayList();
}
/** make full CMLTypes for xsd:string, etc. */
void addXSDTypes() {
CMLType type = new CMLType();
type.setName(XSD_STRING);
type.setJavaType(XSD_STRING);
map.put(XSD_STRING, type);
type = new CMLType();
type.setName(XSD_QNAME);
type.setJavaType(XSD_STRING);
type.setPattern(PATTERN_QNAME);
map.put(XSD_QNAME, type);
type = new CMLType();
type.setName(XSD_ANYURI);
type.setJavaType(XSD_STRING);
type.setPattern(PATTERN_ANYURI);
map.put(XSD_ANYURI, type);
type = new CMLType();
type.setName(XSD_DOUBLE);
type.setJavaType(XSD_DOUBLE);
map.put(XSD_DOUBLE, type);
type = new CMLType();
type.setName(XSD_FLOAT);
type.setJavaType(XSD_DOUBLE);
map.put(XSD_FLOAT, type);
type = new CMLType();
type.setName(XSD_INTEGER);
type.setJavaType(XSD_INTEGER);
map.put(XSD_INTEGER, type);
type = new CMLType();
type.setName(XSD_NONNEGATIVEINTEGER);
type.setJavaType(XSD_INTEGER);
type.setMinInclusive((int)0);
map.put(XSD_NONNEGATIVEINTEGER, type);
type = new CMLType();
type.setName(XSD_POSITIVEINTEGER);
type.setJavaType(XSD_INTEGER);
type.setMinInclusive((int)1);
map.put(XSD_POSITIVEINTEGER, type);
type = new CMLType();
type.setName(XSD_BOOLEAN);
type.setJavaType(XSD_BOOLEAN);
map.put(XSD_BOOLEAN, type);
type = new CMLType();
type.setName(XSD_POSITIVEINTEGER);
type.setJavaType(XSD_INTEGER);
type.setMinInclusive(1);
map.put(XSD_POSITIVEINTEGER, type);
}
private boolean processJavaTypes() {
boolean change = false;
for (String name : nameList) {
CMLType type = map.get(name);
String javaType = type.getJavaType();
if (javaType == null) {
String base = type.getBase();
if (base != null) {
CMLType baseType = map.get(base);
if (baseType == null) {
throw new RuntimeException("cannot find base type: "+base);
}
String baseJavaType = baseType.getJavaType();
if (baseJavaType == null) {
// LOG.debug("base type "+base+" has null javaType");
continue;
}
type.setJavaType(baseJavaType);
change = true;
}
}
}
return change;
}
private boolean checkJavaTypes() {
boolean ok = true;
for (String name : nameList) {
CMLType type = map.get(name);
String javaType = type.getJavaType();
String base = type.getBase();
if (javaType == null && base != null) {
ok = false;
System.err.println("no javaType for "+base);
}
}
return ok;
}
/**
* @return the map
*/
public Map getMap() {
return map;
}
/**
* @param map the map to set
*/
public void setMap(Map map) {
this.map = map;
}
/** read and assemble.
*
* @param indir
* @throws Exception
*/
public void readAssembleAndIndexSchema(String indir) throws Exception {
this.readAndAssembleSchemaComponents(indir);
this.indexSchema();
}
/** index schema.
*/
public void indexSchema() {
List simpleTypes = CMLUtil.getQueryNodes(schema, "./"+XSD_SIMPLE_TYPE, XPATH_XSD);
// supertypes may not all be in place, so iterate until all are found
addXSDTypes();
for (Node node : simpleTypes) {
Element simpleTypeElement = (Element) node;
String name = simpleTypeElement.getAttributeValue("name");
if (name == null) {
System.err.println("No name attribute on simpleType");
CMLUtil.debug(simpleTypeElement, "TYPEGEN");
} else {
try {
CMLType type = new CMLType(simpleTypeElement);
map.put(name, type);
nameList.add(name);
} catch (Exception e) {
LOG.error("Cannot create "+name+"..."+e);
}
}
}
boolean change = true;
while (change) {
change = processJavaTypes();
if (!change) {
break;
}
}
if (!checkJavaTypes()) {
throw new RuntimeException("unresolved javaTypes");
}
for (String name : nameList) {
CMLType type = map.get(name);
type.createMinMaxAndEnumerations();
}
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/ 0000775 0000000 0000000 00000000000 14772244610 0023165 5 ustar 00root root 0000000 0000000 cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractAbundance.java 0000775 0000000 0000000 00000035102 14772244610 0027400 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.element;
import nu.xom.Attribute;
import org.xmlcml.cml.attribute.DictRefAttribute;
import org.xmlcml.cml.attribute.IdAttribute;
import org.xmlcml.cml.attribute.UnitsAttribute;
import org.xmlcml.cml.base.CMLAttribute;
import org.xmlcml.cml.base.CMLElement;
import org.xmlcml.cml.base.DoubleSTAttribute;
import org.xmlcml.cml.base.StringSTAttribute;
// end of part 1
/** CLASS DOCUMENTATION */
public abstract class AbstractAbundance extends CMLElement {
/** local name*/
public final static String TAG = "abundance";
/** constructor. */ public AbstractAbundance() {
super("abundance");
}
/** copy constructor.
* deep copy using XOM copy()
* @param old element to copy
*/
public AbstractAbundance(AbstractAbundance old) {
super((CMLElement) old);
}
// attribute: title
/** cache */
StringSTAttribute _att_title = null;
/** A title on an element.
* No controlled value.
* @return CMLAttribute
*/
public CMLAttribute getTitleAttribute() {
return (CMLAttribute) getAttribute("title");
}
/** A title on an element.
* No controlled value.
* @return String
*/
public String getTitle() {
StringSTAttribute att = (StringSTAttribute) this.getTitleAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A title on an element.
* No controlled value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setTitle(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_title == null) {
_att_title = (StringSTAttribute) attributeFactory.getAttribute("title", "abundance");
if (_att_title == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : title probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_title);
super.addRemove(att, value);
}
// attribute: id
/** cache */
IdAttribute _att_id = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getIdAttribute() {
return (CMLAttribute) getAttribute("id");
}
/** null
* @return String
*/
public String getId() {
IdAttribute att = (IdAttribute) this.getIdAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setId(String value) throws RuntimeException {
IdAttribute att = null;
if (_att_id == null) {
_att_id = (IdAttribute) attributeFactory.getAttribute("id", "abundance");
if (_att_id == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : id probably incompatible attributeGroupName and attributeName");
}
}
att = new IdAttribute(_att_id);
super.addRemove(att, value);
}
// attribute: convention
/** cache */
StringSTAttribute _att_convention = null;
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return CMLAttribute
*/
public CMLAttribute getConventionAttribute() {
return (CMLAttribute) getAttribute("convention");
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return String
*/
public String getConvention() {
StringSTAttribute att = (StringSTAttribute) this.getConventionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setConvention(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_convention == null) {
_att_convention = (StringSTAttribute) attributeFactory.getAttribute("convention", "abundance");
if (_att_convention == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : convention probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_convention);
super.addRemove(att, value);
}
// attribute: dictRef
/** cache */
DictRefAttribute _att_dictref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getDictRefAttribute() {
return (CMLAttribute) getAttribute("dictRef");
}
/** null
* @return String
*/
public String getDictRef() {
DictRefAttribute att = (DictRefAttribute) this.getDictRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDictRef(String value) throws RuntimeException {
DictRefAttribute att = null;
if (_att_dictref == null) {
_att_dictref = (DictRefAttribute) attributeFactory.getAttribute("dictRef", "abundance");
if (_att_dictref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : dictRef probably incompatible attributeGroupName and attributeName");
}
}
att = new DictRefAttribute(_att_dictref);
super.addRemove(att, value);
}
// attribute: min
/** cache */
StringSTAttribute _att_min = null;
/** The minimum value allowed for an element or attribute.
*
* @return CMLAttribute
*/
public CMLAttribute getMinAttribute() {
return (CMLAttribute) getAttribute("min");
}
/** The minimum value allowed for an element or attribute.
*
* @return String
*/
public String getMin() {
StringSTAttribute att = (StringSTAttribute) this.getMinAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The minimum value allowed for an element or attribute.
*
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setMin(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_min == null) {
_att_min = (StringSTAttribute) attributeFactory.getAttribute("min", "abundance");
if (_att_min == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : min probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_min);
super.addRemove(att, value);
}
// attribute: max
/** cache */
StringSTAttribute _att_max = null;
/** Maximum value allowed for an element or attribute.
*
* @return CMLAttribute
*/
public CMLAttribute getMaxAttribute() {
return (CMLAttribute) getAttribute("max");
}
/** Maximum value allowed for an element or attribute.
*
* @return String
*/
public String getMax() {
StringSTAttribute att = (StringSTAttribute) this.getMaxAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** Maximum value allowed for an element or attribute.
*
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setMax(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_max == null) {
_att_max = (StringSTAttribute) attributeFactory.getAttribute("max", "abundance");
if (_att_max == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : max probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_max);
super.addRemove(att, value);
}
// attribute: units
/** cache */
UnitsAttribute _att_units = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getUnitsAttribute() {
return (CMLAttribute) getAttribute("units");
}
/** null
* @return String
*/
public String getUnits() {
UnitsAttribute att = (UnitsAttribute) this.getUnitsAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setUnits(String value) throws RuntimeException {
UnitsAttribute att = null;
if (_att_units == null) {
_att_units = (UnitsAttribute) attributeFactory.getAttribute("units", "abundance");
if (_att_units == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : units probably incompatible attributeGroupName and attributeName");
}
}
att = new UnitsAttribute(_att_units);
super.addRemove(att, value);
}
DoubleSTAttribute _xmlContent;
/**
*
* @return double
*/
public double getXMLContent() {
String content = this.getValue();
if (_xmlContent == null) {
_xmlContent = new DoubleSTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(content);
return _xmlContent.getDouble();
}
/**
*
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setXMLContent(String value) throws RuntimeException {
if (_xmlContent == null) {
_xmlContent = new DoubleSTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(value);
String attval = _xmlContent.getValue();
this.removeChildren();
this.appendChild(attval);
}
/**
*
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setXMLContent(double value) throws RuntimeException {
if (_xmlContent == null) {
_xmlContent = new DoubleSTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(value);
String attval = (String)_xmlContent.getValue();
this.removeChildren();
this.appendChild(attval);
}
/** overrides addAttribute(Attribute)
* reroutes calls to setFoo()
* @param att attribute
*/
public void addAttribute(Attribute att) {
String name = att.getLocalName();
String value = att.getValue();
if (name == null) {
} else if (name.equals("title")) {
setTitle(value);
} else if (name.equals("id")) {
setId(value);
} else if (name.equals("convention")) {
setConvention(value);
} else if (name.equals("dictRef")) {
setDictRef(value);
} else if (name.equals("min")) {
setMin(value);
} else if (name.equals("max")) {
setMax(value);
} else if (name.equals("units")) {
setUnits(value);
} else {
super.addAttribute(att);
}
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractAction.java 0000775 0000000 0000000 00000063100 14772244610 0026734 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.element;
import nu.xom.Attribute;
import org.xmlcml.cml.attribute.DictRefAttribute;
import org.xmlcml.cml.attribute.IdAttribute;
import org.xmlcml.cml.attribute.RefAttribute;
import org.xmlcml.cml.attribute.UnitsAttribute;
import org.xmlcml.cml.base.CMLAttribute;
import org.xmlcml.cml.base.CMLElement;
import org.xmlcml.cml.base.DoubleSTAttribute;
import org.xmlcml.cml.base.StringSTAttribute;
// end of part 1
/** CLASS DOCUMENTATION */
public abstract class AbstractAction extends CMLElement {
/** local name*/
public final static String TAG = "action";
/** constructor. */ public AbstractAction() {
super("action");
}
/** copy constructor.
* deep copy using XOM copy()
* @param old element to copy
*/
public AbstractAction(AbstractAction old) {
super((CMLElement) old);
}
// attribute: title
/** cache */
StringSTAttribute _att_title = null;
/** A title on an element.
* No controlled value.
* @return CMLAttribute
*/
public CMLAttribute getTitleAttribute() {
return (CMLAttribute) getAttribute("title");
}
/** A title on an element.
* No controlled value.
* @return String
*/
public String getTitle() {
StringSTAttribute att = (StringSTAttribute) this.getTitleAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A title on an element.
* No controlled value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setTitle(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_title == null) {
_att_title = (StringSTAttribute) attributeFactory.getAttribute("title", "action");
if (_att_title == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : title probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_title);
super.addRemove(att, value);
}
// attribute: id
/** cache */
IdAttribute _att_id = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getIdAttribute() {
return (CMLAttribute) getAttribute("id");
}
/** null
* @return String
*/
public String getId() {
IdAttribute att = (IdAttribute) this.getIdAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setId(String value) throws RuntimeException {
IdAttribute att = null;
if (_att_id == null) {
_att_id = (IdAttribute) attributeFactory.getAttribute("id", "action");
if (_att_id == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : id probably incompatible attributeGroupName and attributeName");
}
}
att = new IdAttribute(_att_id);
super.addRemove(att, value);
}
// attribute: convention
/** cache */
StringSTAttribute _att_convention = null;
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return CMLAttribute
*/
public CMLAttribute getConventionAttribute() {
return (CMLAttribute) getAttribute("convention");
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return String
*/
public String getConvention() {
StringSTAttribute att = (StringSTAttribute) this.getConventionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setConvention(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_convention == null) {
_att_convention = (StringSTAttribute) attributeFactory.getAttribute("convention", "action");
if (_att_convention == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : convention probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_convention);
super.addRemove(att, value);
}
// attribute: dictRef
/** cache */
DictRefAttribute _att_dictref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getDictRefAttribute() {
return (CMLAttribute) getAttribute("dictRef");
}
/** null
* @return String
*/
public String getDictRef() {
DictRefAttribute att = (DictRefAttribute) this.getDictRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDictRef(String value) throws RuntimeException {
DictRefAttribute att = null;
if (_att_dictref == null) {
_att_dictref = (DictRefAttribute) attributeFactory.getAttribute("dictRef", "action");
if (_att_dictref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : dictRef probably incompatible attributeGroupName and attributeName");
}
}
att = new DictRefAttribute(_att_dictref);
super.addRemove(att, value);
}
// attribute: units
/** cache */
UnitsAttribute _att_units = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getUnitsAttribute() {
return (CMLAttribute) getAttribute("units");
}
/** null
* @return String
*/
public String getUnits() {
UnitsAttribute att = (UnitsAttribute) this.getUnitsAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setUnits(String value) throws RuntimeException {
UnitsAttribute att = null;
if (_att_units == null) {
_att_units = (UnitsAttribute) attributeFactory.getAttribute("units", "action");
if (_att_units == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : units probably incompatible attributeGroupName and attributeName");
}
}
att = new UnitsAttribute(_att_units);
super.addRemove(att, value);
}
// attribute: start
/** cache */
StringSTAttribute _att_start = null;
/** The start value.
* The start value in any allowable
* XSD representation
* @return CMLAttribute
*/
public CMLAttribute getStartAttribute() {
return (CMLAttribute) getAttribute("start");
}
/** The start value.
* The start value in any allowable
* XSD representation
* @return String
*/
public String getStart() {
StringSTAttribute att = (StringSTAttribute) this.getStartAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The start value.
* The start value in any allowable
* XSD representation
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setStart(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_start == null) {
_att_start = (StringSTAttribute) attributeFactory.getAttribute("start", "action");
if (_att_start == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : start probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_start);
super.addRemove(att, value);
}
// attribute: startCondition
/** cache */
StringSTAttribute _att_startcondition = null;
/** The start condition.
* This can describe the condition(s) that has to be met before an action can begin, such as in a recipe. Semantics are unexplored but could be used to control robotic operations.
* @return CMLAttribute
*/
public CMLAttribute getStartConditionAttribute() {
return (CMLAttribute) getAttribute("startCondition");
}
/** The start condition.
* This can describe the condition(s) that has to be met before an action can begin, such as in a recipe. Semantics are unexplored but could be used to control robotic operations.
* @return String
*/
public String getStartCondition() {
StringSTAttribute att = (StringSTAttribute) this.getStartConditionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The start condition.
* This can describe the condition(s) that has to be met before an action can begin, such as in a recipe. Semantics are unexplored but could be used to control robotic operations.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setStartCondition(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_startcondition == null) {
_att_startcondition = (StringSTAttribute) attributeFactory.getAttribute("startCondition", "action");
if (_att_startcondition == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : startCondition probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_startcondition);
super.addRemove(att, value);
}
// attribute: duration
/** cache */
StringSTAttribute _att_duration = null;
/** The duration of the action.
* Semantics undefined.
* @return CMLAttribute
*/
public CMLAttribute getDurationAttribute() {
return (CMLAttribute) getAttribute("duration");
}
/** The duration of the action.
* Semantics undefined.
* @return String
*/
public String getDuration() {
StringSTAttribute att = (StringSTAttribute) this.getDurationAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The duration of the action.
* Semantics undefined.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDuration(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_duration == null) {
_att_duration = (StringSTAttribute) attributeFactory.getAttribute("duration", "action");
if (_att_duration == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : duration probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_duration);
super.addRemove(att, value);
}
// attribute: end
/** cache */
StringSTAttribute _att_end = null;
/** The end value.
* The end value in any allowable XSD representation
* of data.
* @return CMLAttribute
*/
public CMLAttribute getEndAttribute() {
return (CMLAttribute) getAttribute("end");
}
/** The end value.
* The end value in any allowable XSD representation
* of data.
* @return String
*/
public String getEnd() {
StringSTAttribute att = (StringSTAttribute) this.getEndAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The end value.
* The end value in any allowable XSD representation
* of data.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setEnd(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_end == null) {
_att_end = (StringSTAttribute) attributeFactory.getAttribute("end", "action");
if (_att_end == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : end probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_end);
super.addRemove(att, value);
}
// attribute: endCondition
/** cache */
StringSTAttribute _att_endcondition = null;
/** The end condition.
*
* At present a human-readable string describing some condition when the
* ac tion should end. As XML develops it may be possible to add machine-processable
* semantics in this field.
* @return CMLAttribute
*/
public CMLAttribute getEndConditionAttribute() {
return (CMLAttribute) getAttribute("endCondition");
}
/** The end condition.
*
* At present a human-readable string describing some condition when the
* ac tion should end. As XML develops it may be possible to add machine-processable
* semantics in this field.
* @return String
*/
public String getEndCondition() {
StringSTAttribute att = (StringSTAttribute) this.getEndConditionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The end condition.
*
* At present a human-readable string describing some condition when the
* ac tion should end. As XML develops it may be possible to add machine-processable
* semantics in this field.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setEndCondition(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_endcondition == null) {
_att_endcondition = (StringSTAttribute) attributeFactory.getAttribute("endCondition", "action");
if (_att_endcondition == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : endCondition probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_endcondition);
super.addRemove(att, value);
}
// attribute: type
/** cache */
StringSTAttribute _att_type = null;
/** Type of the object.
* A qualifier which may affect the semantics of the object.
* @return CMLAttribute
*/
public CMLAttribute getTypeAttribute() {
return (CMLAttribute) getAttribute("type");
}
/** Type of the object.
* A qualifier which may affect the semantics of the object.
* @return String
*/
public String getType() {
StringSTAttribute att = (StringSTAttribute) this.getTypeAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** Type of the object.
* A qualifier which may affect the semantics of the object.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setType(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_type == null) {
_att_type = (StringSTAttribute) attributeFactory.getAttribute("type", "action");
if (_att_type == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : type probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_type);
super.addRemove(att, value);
}
// attribute: order
/** cache */
StringSTAttribute _att_order = null;
/** Describes whether child elements are sequential or parallel.
* There is no default.
* @return CMLAttribute
*/
public CMLAttribute getOrderAttribute() {
return (CMLAttribute) getAttribute("order");
}
/** Describes whether child elements are sequential or parallel.
* There is no default.
* @return String
*/
public String getOrder() {
StringSTAttribute att = (StringSTAttribute) this.getOrderAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** Describes whether child elements are sequential or parallel.
* There is no default.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setOrder(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_order == null) {
_att_order = (StringSTAttribute) attributeFactory.getAttribute("order", "action");
if (_att_order == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : order probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_order);
super.addRemove(att, value);
}
// attribute: count
/** cache */
DoubleSTAttribute _att_count = null;
/** The count of the object.
* No fixed semantics or default, normally integers.
* It is presumed that the element can be multiplied by the count value.
* @return CMLAttribute
*/
public CMLAttribute getCountAttribute() {
return (CMLAttribute) getAttribute("count");
}
/** The count of the object.
* No fixed semantics or default, normally integers.
* It is presumed that the element can be multiplied by the count value.
* @return double
*/
public double getCount() {
DoubleSTAttribute att = (DoubleSTAttribute) this.getCountAttribute();
if (att == null) {
return Double.NaN;
}
return att.getDouble();
}
/** The count of the object.
* No fixed semantics or default, normally integers.
* It is presumed that the element can be multiplied by the count value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setCount(String value) throws RuntimeException {
DoubleSTAttribute att = null;
if (_att_count == null) {
_att_count = (DoubleSTAttribute) attributeFactory.getAttribute("count", "action");
if (_att_count == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : count probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleSTAttribute(_att_count);
super.addRemove(att, value);
}
/** The count of the object.
* No fixed semantics or default, normally integers.
* It is presumed that the element can be multiplied by the count value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setCount(double value) throws RuntimeException {
if (_att_count == null) {
_att_count = (DoubleSTAttribute) attributeFactory.getAttribute("count", "action");
if (_att_count == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : count probably incompatible attributeGroupName and attributeName ");
}
}
DoubleSTAttribute att = new DoubleSTAttribute(_att_count);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: ref
/** cache */
RefAttribute _att_ref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getRefAttribute() {
return (CMLAttribute) getAttribute("ref");
}
/** null
* @return String
*/
public String getRef() {
RefAttribute att = (RefAttribute) this.getRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setRef(String value) throws RuntimeException {
RefAttribute att = null;
if (_att_ref == null) {
_att_ref = (RefAttribute) attributeFactory.getAttribute("ref", "action");
if (_att_ref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : ref probably incompatible attributeGroupName and attributeName");
}
}
att = new RefAttribute(_att_ref);
super.addRemove(att, value);
}
/** overrides addAttribute(Attribute)
* reroutes calls to setFoo()
* @param att attribute
*/
public void addAttribute(Attribute att) {
String name = att.getLocalName();
String value = att.getValue();
if (name == null) {
} else if (name.equals("title")) {
setTitle(value);
} else if (name.equals("id")) {
setId(value);
} else if (name.equals("convention")) {
setConvention(value);
} else if (name.equals("dictRef")) {
setDictRef(value);
} else if (name.equals("units")) {
setUnits(value);
} else if (name.equals("start")) {
setStart(value);
} else if (name.equals("startCondition")) {
setStartCondition(value);
} else if (name.equals("duration")) {
setDuration(value);
} else if (name.equals("end")) {
setEnd(value);
} else if (name.equals("endCondition")) {
setEndCondition(value);
} else if (name.equals("type")) {
setType(value);
} else if (name.equals("order")) {
setOrder(value);
} else if (name.equals("count")) {
setCount(value);
} else if (name.equals("ref")) {
setRef(value);
} else {
super.addAttribute(att);
}
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractActionList.java 0000775 0000000 0000000 00000060705 14772244610 0027600 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.element;
import nu.xom.Attribute;
import org.xmlcml.cml.attribute.DictRefAttribute;
import org.xmlcml.cml.attribute.IdAttribute;
import org.xmlcml.cml.attribute.UnitsAttribute;
import org.xmlcml.cml.base.CMLAttribute;
import org.xmlcml.cml.base.CMLElement;
import org.xmlcml.cml.base.DoubleSTAttribute;
import org.xmlcml.cml.base.StringSTAttribute;
// end of part 1
/** CLASS DOCUMENTATION */
public abstract class AbstractActionList extends CMLElement {
/** local name*/
public final static String TAG = "actionList";
/** constructor. */ public AbstractActionList() {
super("actionList");
}
/** copy constructor.
* deep copy using XOM copy()
* @param old element to copy
*/
public AbstractActionList(AbstractActionList old) {
super((CMLElement) old);
}
// attribute: title
/** cache */
StringSTAttribute _att_title = null;
/** A title on an element.
* No controlled value.
* @return CMLAttribute
*/
public CMLAttribute getTitleAttribute() {
return (CMLAttribute) getAttribute("title");
}
/** A title on an element.
* No controlled value.
* @return String
*/
public String getTitle() {
StringSTAttribute att = (StringSTAttribute) this.getTitleAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A title on an element.
* No controlled value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setTitle(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_title == null) {
_att_title = (StringSTAttribute) attributeFactory.getAttribute("title", "actionList");
if (_att_title == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : title probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_title);
super.addRemove(att, value);
}
// attribute: id
/** cache */
IdAttribute _att_id = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getIdAttribute() {
return (CMLAttribute) getAttribute("id");
}
/** null
* @return String
*/
public String getId() {
IdAttribute att = (IdAttribute) this.getIdAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setId(String value) throws RuntimeException {
IdAttribute att = null;
if (_att_id == null) {
_att_id = (IdAttribute) attributeFactory.getAttribute("id", "actionList");
if (_att_id == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : id probably incompatible attributeGroupName and attributeName");
}
}
att = new IdAttribute(_att_id);
super.addRemove(att, value);
}
// attribute: convention
/** cache */
StringSTAttribute _att_convention = null;
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return CMLAttribute
*/
public CMLAttribute getConventionAttribute() {
return (CMLAttribute) getAttribute("convention");
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return String
*/
public String getConvention() {
StringSTAttribute att = (StringSTAttribute) this.getConventionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setConvention(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_convention == null) {
_att_convention = (StringSTAttribute) attributeFactory.getAttribute("convention", "actionList");
if (_att_convention == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : convention probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_convention);
super.addRemove(att, value);
}
// attribute: dictRef
/** cache */
DictRefAttribute _att_dictref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getDictRefAttribute() {
return (CMLAttribute) getAttribute("dictRef");
}
/** null
* @return String
*/
public String getDictRef() {
DictRefAttribute att = (DictRefAttribute) this.getDictRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDictRef(String value) throws RuntimeException {
DictRefAttribute att = null;
if (_att_dictref == null) {
_att_dictref = (DictRefAttribute) attributeFactory.getAttribute("dictRef", "actionList");
if (_att_dictref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : dictRef probably incompatible attributeGroupName and attributeName");
}
}
att = new DictRefAttribute(_att_dictref);
super.addRemove(att, value);
}
// attribute: start
/** cache */
StringSTAttribute _att_start = null;
/** The start value.
* The start value in any allowable
* XSD representation
* @return CMLAttribute
*/
public CMLAttribute getStartAttribute() {
return (CMLAttribute) getAttribute("start");
}
/** The start value.
* The start value in any allowable
* XSD representation
* @return String
*/
public String getStart() {
StringSTAttribute att = (StringSTAttribute) this.getStartAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The start value.
* The start value in any allowable
* XSD representation
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setStart(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_start == null) {
_att_start = (StringSTAttribute) attributeFactory.getAttribute("start", "actionList");
if (_att_start == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : start probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_start);
super.addRemove(att, value);
}
// attribute: startCondition
/** cache */
StringSTAttribute _att_startcondition = null;
/** The start condition.
* This can describe the condition(s) that has to be met before an action can begin, such as in a recipe. Semantics are unexplored but could be used to control robotic operations.
* @return CMLAttribute
*/
public CMLAttribute getStartConditionAttribute() {
return (CMLAttribute) getAttribute("startCondition");
}
/** The start condition.
* This can describe the condition(s) that has to be met before an action can begin, such as in a recipe. Semantics are unexplored but could be used to control robotic operations.
* @return String
*/
public String getStartCondition() {
StringSTAttribute att = (StringSTAttribute) this.getStartConditionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The start condition.
* This can describe the condition(s) that has to be met before an action can begin, such as in a recipe. Semantics are unexplored but could be used to control robotic operations.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setStartCondition(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_startcondition == null) {
_att_startcondition = (StringSTAttribute) attributeFactory.getAttribute("startCondition", "actionList");
if (_att_startcondition == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : startCondition probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_startcondition);
super.addRemove(att, value);
}
// attribute: duration
/** cache */
StringSTAttribute _att_duration = null;
/** The duration of the action.
* Semantics undefined.
* @return CMLAttribute
*/
public CMLAttribute getDurationAttribute() {
return (CMLAttribute) getAttribute("duration");
}
/** The duration of the action.
* Semantics undefined.
* @return String
*/
public String getDuration() {
StringSTAttribute att = (StringSTAttribute) this.getDurationAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The duration of the action.
* Semantics undefined.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDuration(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_duration == null) {
_att_duration = (StringSTAttribute) attributeFactory.getAttribute("duration", "actionList");
if (_att_duration == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : duration probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_duration);
super.addRemove(att, value);
}
// attribute: end
/** cache */
StringSTAttribute _att_end = null;
/** The end value.
* The end value in any allowable XSD representation
* of data.
* @return CMLAttribute
*/
public CMLAttribute getEndAttribute() {
return (CMLAttribute) getAttribute("end");
}
/** The end value.
* The end value in any allowable XSD representation
* of data.
* @return String
*/
public String getEnd() {
StringSTAttribute att = (StringSTAttribute) this.getEndAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The end value.
* The end value in any allowable XSD representation
* of data.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setEnd(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_end == null) {
_att_end = (StringSTAttribute) attributeFactory.getAttribute("end", "actionList");
if (_att_end == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : end probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_end);
super.addRemove(att, value);
}
// attribute: endCondition
/** cache */
StringSTAttribute _att_endcondition = null;
/** The end condition.
*
* At present a human-readable string describing some condition when the
* ac tion should end. As XML develops it may be possible to add machine-processable
* semantics in this field.
* @return CMLAttribute
*/
public CMLAttribute getEndConditionAttribute() {
return (CMLAttribute) getAttribute("endCondition");
}
/** The end condition.
*
* At present a human-readable string describing some condition when the
* ac tion should end. As XML develops it may be possible to add machine-processable
* semantics in this field.
* @return String
*/
public String getEndCondition() {
StringSTAttribute att = (StringSTAttribute) this.getEndConditionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The end condition.
*
* At present a human-readable string describing some condition when the
* ac tion should end. As XML develops it may be possible to add machine-processable
* semantics in this field.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setEndCondition(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_endcondition == null) {
_att_endcondition = (StringSTAttribute) attributeFactory.getAttribute("endCondition", "actionList");
if (_att_endcondition == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : endCondition probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_endcondition);
super.addRemove(att, value);
}
// attribute: units
/** cache */
UnitsAttribute _att_units = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getUnitsAttribute() {
return (CMLAttribute) getAttribute("units");
}
/** null
* @return String
*/
public String getUnits() {
UnitsAttribute att = (UnitsAttribute) this.getUnitsAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setUnits(String value) throws RuntimeException {
UnitsAttribute att = null;
if (_att_units == null) {
_att_units = (UnitsAttribute) attributeFactory.getAttribute("units", "actionList");
if (_att_units == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : units probably incompatible attributeGroupName and attributeName");
}
}
att = new UnitsAttribute(_att_units);
super.addRemove(att, value);
}
// attribute: count
/** cache */
DoubleSTAttribute _att_count = null;
/** The count of the object.
* No fixed semantics or default, normally integers.
* It is presumed that the element can be multiplied by the count value.
* @return CMLAttribute
*/
public CMLAttribute getCountAttribute() {
return (CMLAttribute) getAttribute("count");
}
/** The count of the object.
* No fixed semantics or default, normally integers.
* It is presumed that the element can be multiplied by the count value.
* @return double
*/
public double getCount() {
DoubleSTAttribute att = (DoubleSTAttribute) this.getCountAttribute();
if (att == null) {
return Double.NaN;
}
return att.getDouble();
}
/** The count of the object.
* No fixed semantics or default, normally integers.
* It is presumed that the element can be multiplied by the count value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setCount(String value) throws RuntimeException {
DoubleSTAttribute att = null;
if (_att_count == null) {
_att_count = (DoubleSTAttribute) attributeFactory.getAttribute("count", "actionList");
if (_att_count == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : count probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleSTAttribute(_att_count);
super.addRemove(att, value);
}
/** The count of the object.
* No fixed semantics or default, normally integers.
* It is presumed that the element can be multiplied by the count value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setCount(double value) throws RuntimeException {
if (_att_count == null) {
_att_count = (DoubleSTAttribute) attributeFactory.getAttribute("count", "actionList");
if (_att_count == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : count probably incompatible attributeGroupName and attributeName ");
}
}
DoubleSTAttribute att = new DoubleSTAttribute(_att_count);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: type
/** cache */
StringSTAttribute _att_type = null;
/** Type of the object.
* A qualifier which may affect the semantics of the object.
* @return CMLAttribute
*/
public CMLAttribute getTypeAttribute() {
return (CMLAttribute) getAttribute("type");
}
/** Type of the object.
* A qualifier which may affect the semantics of the object.
* @return String
*/
public String getType() {
StringSTAttribute att = (StringSTAttribute) this.getTypeAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** Type of the object.
* A qualifier which may affect the semantics of the object.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setType(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_type == null) {
_att_type = (StringSTAttribute) attributeFactory.getAttribute("type", "actionList");
if (_att_type == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : type probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_type);
super.addRemove(att, value);
}
// attribute: order
/** cache */
StringSTAttribute _att_order = null;
/** Describes whether child elements are sequential or parallel.
* There is no default.
* @return CMLAttribute
*/
public CMLAttribute getOrderAttribute() {
return (CMLAttribute) getAttribute("order");
}
/** Describes whether child elements are sequential or parallel.
* There is no default.
* @return String
*/
public String getOrder() {
StringSTAttribute att = (StringSTAttribute) this.getOrderAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** Describes whether child elements are sequential or parallel.
* There is no default.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setOrder(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_order == null) {
_att_order = (StringSTAttribute) attributeFactory.getAttribute("order", "actionList");
if (_att_order == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : order probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_order);
super.addRemove(att, value);
}
/** overrides addAttribute(Attribute)
* reroutes calls to setFoo()
* @param att attribute
*/
public void addAttribute(Attribute att) {
String name = att.getLocalName();
String value = att.getValue();
if (name == null) {
} else if (name.equals("title")) {
setTitle(value);
} else if (name.equals("id")) {
setId(value);
} else if (name.equals("convention")) {
setConvention(value);
} else if (name.equals("dictRef")) {
setDictRef(value);
} else if (name.equals("start")) {
setStart(value);
} else if (name.equals("startCondition")) {
setStartCondition(value);
} else if (name.equals("duration")) {
setDuration(value);
} else if (name.equals("end")) {
setEnd(value);
} else if (name.equals("endCondition")) {
setEndCondition(value);
} else if (name.equals("units")) {
setUnits(value);
} else if (name.equals("count")) {
setCount(value);
} else if (name.equals("type")) {
setType(value);
} else if (name.equals("order")) {
setOrder(value);
} else {
super.addAttribute(att);
}
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractAmount.java 0000775 0000000 0000000 00000027527 14772244610 0026777 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.element;
import nu.xom.Attribute;
import org.xmlcml.cml.attribute.DictRefAttribute;
import org.xmlcml.cml.attribute.IdAttribute;
import org.xmlcml.cml.attribute.UnitsAttribute;
import org.xmlcml.cml.base.CMLAttribute;
import org.xmlcml.cml.base.CMLElement;
import org.xmlcml.cml.base.DoubleSTAttribute;
import org.xmlcml.cml.base.StringSTAttribute;
// end of part 1
/** CLASS DOCUMENTATION */
public abstract class AbstractAmount extends CMLElement {
/** local name*/
public final static String TAG = "amount";
/** constructor. */ public AbstractAmount() {
super("amount");
}
/** copy constructor.
* deep copy using XOM copy()
* @param old element to copy
*/
public AbstractAmount(AbstractAmount old) {
super((CMLElement) old);
}
// attribute: title
/** cache */
StringSTAttribute _att_title = null;
/** A title on an element.
* No controlled value.
* @return CMLAttribute
*/
public CMLAttribute getTitleAttribute() {
return (CMLAttribute) getAttribute("title");
}
/** A title on an element.
* No controlled value.
* @return String
*/
public String getTitle() {
StringSTAttribute att = (StringSTAttribute) this.getTitleAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A title on an element.
* No controlled value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setTitle(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_title == null) {
_att_title = (StringSTAttribute) attributeFactory.getAttribute("title", "amount");
if (_att_title == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : title probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_title);
super.addRemove(att, value);
}
// attribute: id
/** cache */
IdAttribute _att_id = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getIdAttribute() {
return (CMLAttribute) getAttribute("id");
}
/** null
* @return String
*/
public String getId() {
IdAttribute att = (IdAttribute) this.getIdAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setId(String value) throws RuntimeException {
IdAttribute att = null;
if (_att_id == null) {
_att_id = (IdAttribute) attributeFactory.getAttribute("id", "amount");
if (_att_id == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : id probably incompatible attributeGroupName and attributeName");
}
}
att = new IdAttribute(_att_id);
super.addRemove(att, value);
}
// attribute: convention
/** cache */
StringSTAttribute _att_convention = null;
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return CMLAttribute
*/
public CMLAttribute getConventionAttribute() {
return (CMLAttribute) getAttribute("convention");
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return String
*/
public String getConvention() {
StringSTAttribute att = (StringSTAttribute) this.getConventionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setConvention(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_convention == null) {
_att_convention = (StringSTAttribute) attributeFactory.getAttribute("convention", "amount");
if (_att_convention == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : convention probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_convention);
super.addRemove(att, value);
}
// attribute: dictRef
/** cache */
DictRefAttribute _att_dictref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getDictRefAttribute() {
return (CMLAttribute) getAttribute("dictRef");
}
/** null
* @return String
*/
public String getDictRef() {
DictRefAttribute att = (DictRefAttribute) this.getDictRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDictRef(String value) throws RuntimeException {
DictRefAttribute att = null;
if (_att_dictref == null) {
_att_dictref = (DictRefAttribute) attributeFactory.getAttribute("dictRef", "amount");
if (_att_dictref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : dictRef probably incompatible attributeGroupName and attributeName");
}
}
att = new DictRefAttribute(_att_dictref);
super.addRemove(att, value);
}
// attribute: units
/** cache */
UnitsAttribute _att_units = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getUnitsAttribute() {
return (CMLAttribute) getAttribute("units");
}
/** null
* @return String
*/
public String getUnits() {
UnitsAttribute att = (UnitsAttribute) this.getUnitsAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setUnits(String value) throws RuntimeException {
UnitsAttribute att = null;
if (_att_units == null) {
_att_units = (UnitsAttribute) attributeFactory.getAttribute("units", "amount");
if (_att_units == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : units probably incompatible attributeGroupName and attributeName");
}
}
att = new UnitsAttribute(_att_units);
super.addRemove(att, value);
}
DoubleSTAttribute _xmlContent;
/**
*
* @return double
*/
public double getXMLContent() {
String content = this.getValue();
if (_xmlContent == null) {
_xmlContent = new DoubleSTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(content);
return _xmlContent.getDouble();
}
/**
*
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setXMLContent(String value) throws RuntimeException {
if (_xmlContent == null) {
_xmlContent = new DoubleSTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(value);
String attval = _xmlContent.getValue();
this.removeChildren();
this.appendChild(attval);
}
/**
*
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setXMLContent(double value) throws RuntimeException {
if (_xmlContent == null) {
_xmlContent = new DoubleSTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(value);
String attval = (String)_xmlContent.getValue();
this.removeChildren();
this.appendChild(attval);
}
/** overrides addAttribute(Attribute)
* reroutes calls to setFoo()
* @param att attribute
*/
public void addAttribute(Attribute att) {
String name = att.getLocalName();
String value = att.getValue();
if (name == null) {
} else if (name.equals("title")) {
setTitle(value);
} else if (name.equals("id")) {
setId(value);
} else if (name.equals("convention")) {
setConvention(value);
} else if (name.equals("dictRef")) {
setDictRef(value);
} else if (name.equals("units")) {
setUnits(value);
} else {
super.addAttribute(att);
}
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractAngle.java 0000775 0000000 0000000 00000055314 14772244610 0026555 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.element;
import nu.xom.Attribute;
import org.xmlcml.cml.attribute.DictRefAttribute;
import org.xmlcml.cml.attribute.IdAttribute;
import org.xmlcml.cml.attribute.RefAttribute;
import org.xmlcml.cml.attribute.UnitsAttribute;
import org.xmlcml.cml.base.CMLAttribute;
import org.xmlcml.cml.base.CMLElement;
import org.xmlcml.cml.base.DoubleSTAttribute;
import org.xmlcml.cml.base.StringArraySTAttribute;
import org.xmlcml.cml.base.StringSTAttribute;
// end of part 1
/** CLASS DOCUMENTATION */
public abstract class AbstractAngle extends CMLElement {
/** local name*/
public final static String TAG = "angle";
/** constructor. */ public AbstractAngle() {
super("angle");
}
/** copy constructor.
* deep copy using XOM copy()
* @param old element to copy
*/
public AbstractAngle(AbstractAngle old) {
super((CMLElement) old);
}
// attribute: title
/** cache */
StringSTAttribute _att_title = null;
/** A title on an element.
* No controlled value.
* @return CMLAttribute
*/
public CMLAttribute getTitleAttribute() {
return (CMLAttribute) getAttribute("title");
}
/** A title on an element.
* No controlled value.
* @return String
*/
public String getTitle() {
StringSTAttribute att = (StringSTAttribute) this.getTitleAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A title on an element.
* No controlled value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setTitle(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_title == null) {
_att_title = (StringSTAttribute) attributeFactory.getAttribute("title", "angle");
if (_att_title == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : title probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_title);
super.addRemove(att, value);
}
// attribute: id
/** cache */
IdAttribute _att_id = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getIdAttribute() {
return (CMLAttribute) getAttribute("id");
}
/** null
* @return String
*/
public String getId() {
IdAttribute att = (IdAttribute) this.getIdAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setId(String value) throws RuntimeException {
IdAttribute att = null;
if (_att_id == null) {
_att_id = (IdAttribute) attributeFactory.getAttribute("id", "angle");
if (_att_id == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : id probably incompatible attributeGroupName and attributeName");
}
}
att = new IdAttribute(_att_id);
super.addRemove(att, value);
}
// attribute: convention
/** cache */
StringSTAttribute _att_convention = null;
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return CMLAttribute
*/
public CMLAttribute getConventionAttribute() {
return (CMLAttribute) getAttribute("convention");
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return String
*/
public String getConvention() {
StringSTAttribute att = (StringSTAttribute) this.getConventionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setConvention(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_convention == null) {
_att_convention = (StringSTAttribute) attributeFactory.getAttribute("convention", "angle");
if (_att_convention == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : convention probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_convention);
super.addRemove(att, value);
}
// attribute: dictRef
/** cache */
DictRefAttribute _att_dictref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getDictRefAttribute() {
return (CMLAttribute) getAttribute("dictRef");
}
/** null
* @return String
*/
public String getDictRef() {
DictRefAttribute att = (DictRefAttribute) this.getDictRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDictRef(String value) throws RuntimeException {
DictRefAttribute att = null;
if (_att_dictref == null) {
_att_dictref = (DictRefAttribute) attributeFactory.getAttribute("dictRef", "angle");
if (_att_dictref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : dictRef probably incompatible attributeGroupName and attributeName");
}
}
att = new DictRefAttribute(_att_dictref);
super.addRemove(att, value);
}
// attribute: atomRefs3
/** cache */
StringArraySTAttribute _att_atomrefs3 = null;
/** A list of three references to atoms.
* Typically used for defining angles,
* but could also be used to define a three-centre bond.
* @return CMLAttribute
*/
public CMLAttribute getAtomRefs3Attribute() {
return (CMLAttribute) getAttribute("atomRefs3");
}
/** A list of three references to atoms.
* Typically used for defining angles,
* but could also be used to define a three-centre bond.
* @return String[]
*/
public String[] getAtomRefs3() {
StringArraySTAttribute att = (StringArraySTAttribute) this.getAtomRefs3Attribute();
if (att == null) {
return null;
}
return att.getStringArray();
}
/** A list of three references to atoms.
* Typically used for defining angles,
* but could also be used to define a three-centre bond.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setAtomRefs3(String value) throws RuntimeException {
StringArraySTAttribute att = null;
if (_att_atomrefs3 == null) {
_att_atomrefs3 = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs3", "angle");
if (_att_atomrefs3 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs3 probably incompatible attributeGroupName and attributeName");
}
}
att = new StringArraySTAttribute(_att_atomrefs3);
super.addRemove(att, value);
}
/** A list of three references to atoms.
* Typically used for defining angles,
* but could also be used to define a three-centre bond.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setAtomRefs3(String[] value) throws RuntimeException {
if (_att_atomrefs3 == null) {
_att_atomrefs3 = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs3", "angle");
if (_att_atomrefs3 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs3 probably incompatible attributeGroupName and attributeName ");
}
}
StringArraySTAttribute att = new StringArraySTAttribute(_att_atomrefs3);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: units
/** cache */
UnitsAttribute _att_units = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getUnitsAttribute() {
return (CMLAttribute) getAttribute("units");
}
/** null
* @return String
*/
public String getUnits() {
UnitsAttribute att = (UnitsAttribute) this.getUnitsAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setUnits(String value) throws RuntimeException {
UnitsAttribute att = null;
if (_att_units == null) {
_att_units = (UnitsAttribute) attributeFactory.getAttribute("units", "angle");
if (_att_units == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : units probably incompatible attributeGroupName and attributeName");
}
}
att = new UnitsAttribute(_att_units);
super.addRemove(att, value);
}
// attribute: errorValue
/** cache */
DoubleSTAttribute _att_errorvalue = null;
/** Value of the error.
* Reports the author's estimate of the error in a scalar value. Only meaningful for dataTypes mapping to real number.
* @return CMLAttribute
*/
public CMLAttribute getErrorValueAttribute() {
return (CMLAttribute) getAttribute("errorValue");
}
/** Value of the error.
* Reports the author's estimate of the error in a scalar value. Only meaningful for dataTypes mapping to real number.
* @return double
*/
public double getErrorValue() {
DoubleSTAttribute att = (DoubleSTAttribute) this.getErrorValueAttribute();
if (att == null) {
return Double.NaN;
}
return att.getDouble();
}
/** Value of the error.
* Reports the author's estimate of the error in a scalar value. Only meaningful for dataTypes mapping to real number.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setErrorValue(String value) throws RuntimeException {
DoubleSTAttribute att = null;
if (_att_errorvalue == null) {
_att_errorvalue = (DoubleSTAttribute) attributeFactory.getAttribute("errorValue", "angle");
if (_att_errorvalue == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : errorValue probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleSTAttribute(_att_errorvalue);
super.addRemove(att, value);
}
/** Value of the error.
* Reports the author's estimate of the error in a scalar value. Only meaningful for dataTypes mapping to real number.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setErrorValue(double value) throws RuntimeException {
if (_att_errorvalue == null) {
_att_errorvalue = (DoubleSTAttribute) attributeFactory.getAttribute("errorValue", "angle");
if (_att_errorvalue == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : errorValue probably incompatible attributeGroupName and attributeName ");
}
}
DoubleSTAttribute att = new DoubleSTAttribute(_att_errorvalue);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: errorBasis
/** cache */
StringSTAttribute _att_errorbasis = null;
/** Basis of the error estimate.
*
* @return CMLAttribute
*/
public CMLAttribute getErrorBasisAttribute() {
return (CMLAttribute) getAttribute("errorBasis");
}
/** Basis of the error estimate.
*
* @return String
*/
public String getErrorBasis() {
StringSTAttribute att = (StringSTAttribute) this.getErrorBasisAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** Basis of the error estimate.
*
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setErrorBasis(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_errorbasis == null) {
_att_errorbasis = (StringSTAttribute) attributeFactory.getAttribute("errorBasis", "angle");
if (_att_errorbasis == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : errorBasis probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_errorbasis);
super.addRemove(att, value);
}
// attribute: min
/** cache */
StringSTAttribute _att_min = null;
/** The minimum value allowed for an element or attribute.
*
* @return CMLAttribute
*/
public CMLAttribute getMinAttribute() {
return (CMLAttribute) getAttribute("min");
}
/** The minimum value allowed for an element or attribute.
*
* @return String
*/
public String getMin() {
StringSTAttribute att = (StringSTAttribute) this.getMinAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The minimum value allowed for an element or attribute.
*
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setMin(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_min == null) {
_att_min = (StringSTAttribute) attributeFactory.getAttribute("min", "angle");
if (_att_min == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : min probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_min);
super.addRemove(att, value);
}
// attribute: max
/** cache */
StringSTAttribute _att_max = null;
/** Maximum value allowed for an element or attribute.
*
* @return CMLAttribute
*/
public CMLAttribute getMaxAttribute() {
return (CMLAttribute) getAttribute("max");
}
/** Maximum value allowed for an element or attribute.
*
* @return String
*/
public String getMax() {
StringSTAttribute att = (StringSTAttribute) this.getMaxAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** Maximum value allowed for an element or attribute.
*
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setMax(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_max == null) {
_att_max = (StringSTAttribute) attributeFactory.getAttribute("max", "angle");
if (_att_max == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : max probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_max);
super.addRemove(att, value);
}
// attribute: ref
/** cache */
RefAttribute _att_ref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getRefAttribute() {
return (CMLAttribute) getAttribute("ref");
}
/** null
* @return String
*/
public String getRef() {
RefAttribute att = (RefAttribute) this.getRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setRef(String value) throws RuntimeException {
RefAttribute att = null;
if (_att_ref == null) {
_att_ref = (RefAttribute) attributeFactory.getAttribute("ref", "angle");
if (_att_ref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : ref probably incompatible attributeGroupName and attributeName");
}
}
att = new RefAttribute(_att_ref);
super.addRemove(att, value);
}
DoubleSTAttribute _xmlContent;
/** A non-signed angle.
* Re-used by _angle_. Note that we also provide
* positiveAngleType (e.g. for cell angles) and torsionAngleType for _torsion_.
* @return double
*/
public double getXMLContent() {
String content = this.getValue();
if (_xmlContent == null) {
_xmlContent = new DoubleSTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(content);
return _xmlContent.getDouble();
}
/** A non-signed angle.
* Re-used by _angle_. Note that we also provide
* positiveAngleType (e.g. for cell angles) and torsionAngleType for _torsion_.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setXMLContent(String value) throws RuntimeException {
if (_xmlContent == null) {
_xmlContent = new DoubleSTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(value);
String attval = _xmlContent.getValue();
this.removeChildren();
this.appendChild(attval);
}
/** A non-signed angle.
* Re-used by _angle_. Note that we also provide
* positiveAngleType (e.g. for cell angles) and torsionAngleType for _torsion_.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setXMLContent(double value) throws RuntimeException {
if (_xmlContent == null) {
_xmlContent = new DoubleSTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(value);
String attval = (String)_xmlContent.getValue();
this.removeChildren();
this.appendChild(attval);
}
/** overrides addAttribute(Attribute)
* reroutes calls to setFoo()
* @param att attribute
*/
public void addAttribute(Attribute att) {
String name = att.getLocalName();
String value = att.getValue();
if (name == null) {
} else if (name.equals("title")) {
setTitle(value);
} else if (name.equals("id")) {
setId(value);
} else if (name.equals("convention")) {
setConvention(value);
} else if (name.equals("dictRef")) {
setDictRef(value);
} else if (name.equals("atomRefs3")) {
setAtomRefs3(value);
} else if (name.equals("units")) {
setUnits(value);
} else if (name.equals("errorValue")) {
setErrorValue(value);
} else if (name.equals("errorBasis")) {
setErrorBasis(value);
} else if (name.equals("min")) {
setMin(value);
} else if (name.equals("max")) {
setMax(value);
} else if (name.equals("ref")) {
setRef(value);
} else {
super.addAttribute(att);
}
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractArg.java 0000775 0000000 0000000 00000076464 14772244610 0026251 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.element;
import nu.xom.Attribute;
import nu.xom.Elements;
import org.xmlcml.cml.attribute.DictRefAttribute;
import org.xmlcml.cml.attribute.IdAttribute;
import org.xmlcml.cml.attribute.RefAttribute;
import org.xmlcml.cml.base.CMLAttribute;
import org.xmlcml.cml.base.CMLConstants;
import org.xmlcml.cml.base.CMLElement;
import org.xmlcml.cml.base.CMLElements;
import org.xmlcml.cml.base.StringSTAttribute;
// end of part 1
/** CLASS DOCUMENTATION */
public abstract class AbstractArg extends CMLElement {
/** local name*/
public final static String TAG = "arg";
/** constructor. */ public AbstractArg() {
super("arg");
}
/** copy constructor.
* deep copy using XOM copy()
* @param old element to copy
*/
public AbstractArg(AbstractArg old) {
super((CMLElement) old);
}
// attribute: title
/** cache */
StringSTAttribute _att_title = null;
/** A title on an element.
* No controlled value.
* @return CMLAttribute
*/
public CMLAttribute getTitleAttribute() {
return (CMLAttribute) getAttribute("title");
}
/** A title on an element.
* No controlled value.
* @return String
*/
public String getTitle() {
StringSTAttribute att = (StringSTAttribute) this.getTitleAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A title on an element.
* No controlled value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setTitle(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_title == null) {
_att_title = (StringSTAttribute) attributeFactory.getAttribute("title", "arg");
if (_att_title == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : title probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_title);
super.addRemove(att, value);
}
// attribute: id
/** cache */
IdAttribute _att_id = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getIdAttribute() {
return (CMLAttribute) getAttribute("id");
}
/** null
* @return String
*/
public String getId() {
IdAttribute att = (IdAttribute) this.getIdAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setId(String value) throws RuntimeException {
IdAttribute att = null;
if (_att_id == null) {
_att_id = (IdAttribute) attributeFactory.getAttribute("id", "arg");
if (_att_id == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : id probably incompatible attributeGroupName and attributeName");
}
}
att = new IdAttribute(_att_id);
super.addRemove(att, value);
}
// attribute: convention
/** cache */
StringSTAttribute _att_convention = null;
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return CMLAttribute
*/
public CMLAttribute getConventionAttribute() {
return (CMLAttribute) getAttribute("convention");
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return String
*/
public String getConvention() {
StringSTAttribute att = (StringSTAttribute) this.getConventionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setConvention(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_convention == null) {
_att_convention = (StringSTAttribute) attributeFactory.getAttribute("convention", "arg");
if (_att_convention == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : convention probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_convention);
super.addRemove(att, value);
}
// attribute: dictRef
/** cache */
DictRefAttribute _att_dictref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getDictRefAttribute() {
return (CMLAttribute) getAttribute("dictRef");
}
/** null
* @return String
*/
public String getDictRef() {
DictRefAttribute att = (DictRefAttribute) this.getDictRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDictRef(String value) throws RuntimeException {
DictRefAttribute att = null;
if (_att_dictref == null) {
_att_dictref = (DictRefAttribute) attributeFactory.getAttribute("dictRef", "arg");
if (_att_dictref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : dictRef probably incompatible attributeGroupName and attributeName");
}
}
att = new DictRefAttribute(_att_dictref);
super.addRemove(att, value);
}
// attribute: ref
/** cache */
RefAttribute _att_ref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getRefAttribute() {
return (CMLAttribute) getAttribute("ref");
}
/** null
* @return String
*/
public String getRef() {
RefAttribute att = (RefAttribute) this.getRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setRef(String value) throws RuntimeException {
RefAttribute att = null;
if (_att_ref == null) {
_att_ref = (RefAttribute) attributeFactory.getAttribute("ref", "arg");
if (_att_ref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : ref probably incompatible attributeGroupName and attributeName");
}
}
att = new RefAttribute(_att_ref);
super.addRemove(att, value);
}
// attribute: name
/** cache */
StringSTAttribute _att_name = null;
/** Name of the object.
* A string by which the object is known. Often a required attribute. The may or may not be a semi-controlled vocabulary.
* @return CMLAttribute
*/
public CMLAttribute getNameAttribute() {
return (CMLAttribute) getAttribute("name");
}
/** Name of the object.
* A string by which the object is known. Often a required attribute. The may or may not be a semi-controlled vocabulary.
* @return String
*/
public String getName() {
StringSTAttribute att = (StringSTAttribute) this.getNameAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** Name of the object.
* A string by which the object is known. Often a required attribute. The may or may not be a semi-controlled vocabulary.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setName(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_name == null) {
_att_name = (StringSTAttribute) attributeFactory.getAttribute("name", "arg");
if (_att_name == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : name probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_name);
super.addRemove(att, value);
}
// attribute: dataType
/** cache */
StringSTAttribute _att_datatype = null;
/** The data type of the object.
* Normally applied to scalar/array
* objects but may extend to more complex one.
* @return CMLAttribute
*/
public CMLAttribute getDataTypeAttribute() {
return (CMLAttribute) getAttribute("dataType");
}
/** The data type of the object.
* Normally applied to scalar/array
* objects but may extend to more complex one.
* @return String
*/
public String getDataType() {
StringSTAttribute att = (StringSTAttribute) this.getDataTypeAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The data type of the object.
* Normally applied to scalar/array
* objects but may extend to more complex one.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDataType(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_datatype == null) {
_att_datatype = (StringSTAttribute) attributeFactory.getAttribute("dataType", "arg");
if (_att_datatype == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : dataType probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_datatype);
super.addRemove(att, value);
}
// attribute: substitute
/** cache */
StringSTAttribute _att_substitute = null;
/** A flag on 'arg' to indicate that the value can be substituted.
* This is still experimental. The value may be an
* XPath expression, at present
* all attributes (".//@*") are processed. If an attribute contains _ijk_ where the
* name of the arg is 'ijk' this string is replaced by the value of ijk,
* e.g. if arg with name ijk has a value of 2 then 'm_ijk__z3' becomes
* 'm2_z3'. substitute="." replaces this element by its value
* @return CMLAttribute
*/
public CMLAttribute getSubstituteAttribute() {
return (CMLAttribute) getAttribute("substitute");
}
/** A flag on 'arg' to indicate that the value can be substituted.
* This is still experimental. The value may be an
* XPath expression, at present
* all attributes (".//@*") are processed. If an attribute contains _ijk_ where the
* name of the arg is 'ijk' this string is replaced by the value of ijk,
* e.g. if arg with name ijk has a value of 2 then 'm_ijk__z3' becomes
* 'm2_z3'. substitute="." replaces this element by its value
* @return String
*/
public String getSubstitute() {
StringSTAttribute att = (StringSTAttribute) this.getSubstituteAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A flag on 'arg' to indicate that the value can be substituted.
* This is still experimental. The value may be an
* XPath expression, at present
* all attributes (".//@*") are processed. If an attribute contains _ijk_ where the
* name of the arg is 'ijk' this string is replaced by the value of ijk,
* e.g. if arg with name ijk has a value of 2 then 'm_ijk__z3' becomes
* 'm2_z3'. substitute="." replaces this element by its value
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setSubstitute(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_substitute == null) {
_att_substitute = (StringSTAttribute) attributeFactory.getAttribute("substitute", "arg");
if (_att_substitute == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : substitute probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_substitute);
super.addRemove(att, value);
}
// attribute: parameterName
/** cache */
StringSTAttribute _att_parametername = null;
/** parameter name passed to an element.
* This is still experimental.
* @return CMLAttribute
*/
public CMLAttribute getParameterNameAttribute() {
return (CMLAttribute) getAttribute("parameterName");
}
/** parameter name passed to an element.
* This is still experimental.
* @return String
*/
public String getParameterName() {
StringSTAttribute att = (StringSTAttribute) this.getParameterNameAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** parameter name passed to an element.
* This is still experimental.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setParameterName(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_parametername == null) {
_att_parametername = (StringSTAttribute) attributeFactory.getAttribute("parameterName", "arg");
if (_att_parametername == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : parameterName probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_parametername);
super.addRemove(att, value);
}
// attribute: parentAttribute
/** cache */
StringSTAttribute _att_parentattribute = null;
/** raplaces attribute on parent.
* This is still experimental. Creates, overwriting
* if necessary, an attribute on parent. Example:
* {@code
*
* zubbo
*
* will create an attribute bar="zubbo" on
* }
*
* @return CMLAttribute
*/
public CMLAttribute getParentAttributeAttribute() {
return (CMLAttribute) getAttribute("parentAttribute");
}
/** raplaces attribute on parent.
* This is still experimental. Creates, overwriting
* if necessary, an attribute on parent. Example:
* {@code
*
* zubbo
*
* will create an attribute bar="zubbo" on
* }
* @return String
*/
public String getParentAttribute() {
StringSTAttribute att = (StringSTAttribute) this.getParentAttributeAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** raplaces attribute on parent.
* This is still experimental. Creates, overwriting
* if necessary, an attribute on parent. Example:
* {@code
*
* zubbo
*
* will create an attribute bar="zubbo" on
* }
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setParentAttribute(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_parentattribute == null) {
_att_parentattribute = (StringSTAttribute) attributeFactory.getAttribute("parentAttribute", "arg");
if (_att_parentattribute == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : parentAttribute probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_parentattribute);
super.addRemove(att, value);
}
// attribute: delete
/** cache */
StringSTAttribute _att_delete = null;
/** A flag indicated that the element can detach/delete itself.
* An element containg this attribute may only have a transient existence
* (e.g. a template to create other elements) and this attribute shows that
* the element can be deleted at the appropriate stage. The time at which this
* is called is application dependent. At present the presence of the attribute
* is sufficient to trigger this; later a controlled vocabulary will be developed.
* @return CMLAttribute
*/
public CMLAttribute getDeleteAttribute() {
return (CMLAttribute) getAttribute("delete");
}
/** A flag indicated that the element can detach/delete itself.
* An element containg this attribute may only have a transient existence
* (e.g. a template to create other elements) and this attribute shows that
* the element can be deleted at the appropriate stage. The time at which this
* is called is application dependent. At present the presence of the attribute
* is sufficient to trigger this; later a controlled vocabulary will be developed.
* @return String
*/
public String getDelete() {
StringSTAttribute att = (StringSTAttribute) this.getDeleteAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A flag indicated that the element can detach/delete itself.
* An element containg this attribute may only have a transient existence
* (e.g. a template to create other elements) and this attribute shows that
* the element can be deleted at the appropriate stage. The time at which this
* is called is application dependent. At present the presence of the attribute
* is sufficient to trigger this; later a controlled vocabulary will be developed.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDelete(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_delete == null) {
_att_delete = (StringSTAttribute) attributeFactory.getAttribute("delete", "arg");
if (_att_delete == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : delete probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_delete);
super.addRemove(att, value);
}
// attribute: eval
/** cache */
StringSTAttribute _att_eval = null;
/** A flag on 'arg' to indicate that the value can be calculated.
* This is still experimental. if eval="_ijk_+3" and
* the value of the ijk was 2, this would change the value of the arg to 5.
* Only + and - are currently allowed
* @return CMLAttribute
*/
public CMLAttribute getEvalAttribute() {
return (CMLAttribute) getAttribute("eval");
}
/** A flag on 'arg' to indicate that the value can be calculated.
* This is still experimental. if eval="_ijk_+3" and
* the value of the ijk was 2, this would change the value of the arg to 5.
* Only + and - are currently allowed
* @return String
*/
public String getEval() {
StringSTAttribute att = (StringSTAttribute) this.getEvalAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A flag on 'arg' to indicate that the value can be calculated.
* This is still experimental. if eval="_ijk_+3" and
* the value of the ijk was 2, this would change the value of the arg to 5.
* Only + and - are currently allowed
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setEval(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_eval == null) {
_att_eval = (StringSTAttribute) attributeFactory.getAttribute("eval", "arg");
if (_att_eval == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : eval probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_eval);
super.addRemove(att, value);
}
// element: atom
/** A flag on 'arg' to indicate that the value can be calculated.
* This is still experimental. if eval="_ijk_+3" and
* the value of the ijk was 2, this would change the value of the arg to 5.
* Only + and - are currently allowed
* @param atom child to add
*/
public void addAtom(AbstractAtom atom) {
atom.detach();
this.appendChild(atom);
}
/** A flag on 'arg' to indicate that the value can be calculated.
* This is still experimental. if eval="_ijk_+3" and
* the value of the ijk was 2, this would change the value of the arg to 5.
* Only + and - are currently allowed
* @return CMLElements<CMLAtom>
*/
public CMLElements getAtomElements() {
Elements elements = this.getChildElements("atom", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: atomType
/** A flag on 'arg' to indicate that the value can be calculated.
* This is still experimental. if eval="_ijk_+3" and
* the value of the ijk was 2, this would change the value of the arg to 5.
* Only + and - are currently allowed
* @param atomType child to add
*/
public void addAtomType(AbstractAtomType atomType) {
atomType.detach();
this.appendChild(atomType);
}
/** A flag on 'arg' to indicate that the value can be calculated.
* This is still experimental. if eval="_ijk_+3" and
* the value of the ijk was 2, this would change the value of the arg to 5.
* Only + and - are currently allowed
* @return CMLElements<CMLAtomType>
*/
public CMLElements getAtomTypeElements() {
Elements elements = this.getChildElements("atomType", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: scalar
/** A flag on 'arg' to indicate that the value can be calculated.
* This is still experimental. if eval="_ijk_+3" and
* the value of the ijk was 2, this would change the value of the arg to 5.
* Only + and - are currently allowed
* @param scalar child to add
*/
public void addScalar(AbstractScalar scalar) {
scalar.detach();
this.appendChild(scalar);
}
/** A flag on 'arg' to indicate that the value can be calculated.
* This is still experimental. if eval="_ijk_+3" and
* the value of the ijk was 2, this would change the value of the arg to 5.
* Only + and - are currently allowed
* @return CMLElements<CMLScalar>
*/
public CMLElements getScalarElements() {
Elements elements = this.getChildElements("scalar", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: array
/** A flag on 'arg' to indicate that the value can be calculated.
* This is still experimental. if eval="_ijk_+3" and
* the value of the ijk was 2, this would change the value of the arg to 5.
* Only + and - are currently allowed
* @param array child to add
*/
public void addArray(AbstractArray array) {
array.detach();
this.appendChild(array);
}
/** A flag on 'arg' to indicate that the value can be calculated.
* This is still experimental. if eval="_ijk_+3" and
* the value of the ijk was 2, this would change the value of the arg to 5.
* Only + and - are currently allowed
* @return CMLElements<CMLArray>
*/
public CMLElements getArrayElements() {
Elements elements = this.getChildElements("array", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: matrix
/** A flag on 'arg' to indicate that the value can be calculated.
* This is still experimental. if eval="_ijk_+3" and
* the value of the ijk was 2, this would change the value of the arg to 5.
* Only + and - are currently allowed
* @param matrix child to add
*/
public void addMatrix(AbstractMatrix matrix) {
matrix.detach();
this.appendChild(matrix);
}
/** A flag on 'arg' to indicate that the value can be calculated.
* This is still experimental. if eval="_ijk_+3" and
* the value of the ijk was 2, this would change the value of the arg to 5.
* Only + and - are currently allowed
* @return CMLElements<CMLMatrix>
*/
public CMLElements getMatrixElements() {
Elements elements = this.getChildElements("matrix", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: expression
/** A flag on 'arg' to indicate that the value can be calculated.
* This is still experimental. if eval="_ijk_+3" and
* the value of the ijk was 2, this would change the value of the arg to 5.
* Only + and - are currently allowed
* @param expression child to add
*/
public void addExpression(AbstractExpression expression) {
expression.detach();
this.appendChild(expression);
}
/** A flag on 'arg' to indicate that the value can be calculated.
* This is still experimental. if eval="_ijk_+3" and
* the value of the ijk was 2, this would change the value of the arg to 5.
* Only + and - are currently allowed
* @return CMLElements<CMLExpression>
*/
public CMLElements getExpressionElements() {
Elements elements = this.getChildElements("expression", CMLConstants.CML_NS);
return new CMLElements(elements);
}
/** overrides addAttribute(Attribute)
* reroutes calls to setFoo()
* @param att attribute
*/
public void addAttribute(Attribute att) {
String name = att.getLocalName();
String value = att.getValue();
if (name == null) {
} else if (name.equals("title")) {
setTitle(value);
} else if (name.equals("id")) {
setId(value);
} else if (name.equals("convention")) {
setConvention(value);
} else if (name.equals("dictRef")) {
setDictRef(value);
} else if (name.equals("ref")) {
setRef(value);
} else if (name.equals("name")) {
setName(value);
} else if (name.equals("dataType")) {
setDataType(value);
} else if (name.equals("substitute")) {
setSubstitute(value);
} else if (name.equals("parameterName")) {
setParameterName(value);
} else if (name.equals("parentAttribute")) {
setParentAttribute(value);
} else if (name.equals("delete")) {
setDelete(value);
} else if (name.equals("eval")) {
setEval(value);
} else {
super.addAttribute(att);
}
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractArray.java 0000775 0000000 0000000 00000112240 14772244610 0026575 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.element;
import nu.xom.Attribute;
import org.xmlcml.cml.attribute.DelimiterAttribute;
import org.xmlcml.cml.attribute.DictRefAttribute;
import org.xmlcml.cml.attribute.IdAttribute;
import org.xmlcml.cml.attribute.NamespaceRefAttribute;
import org.xmlcml.cml.attribute.RefAttribute;
import org.xmlcml.cml.attribute.UnitsAttribute;
import org.xmlcml.cml.base.CMLAttribute;
import org.xmlcml.cml.base.CMLElement;
import org.xmlcml.cml.base.DoubleArraySTAttribute;
import org.xmlcml.cml.base.DoubleSTAttribute;
import org.xmlcml.cml.base.IntSTAttribute;
import org.xmlcml.cml.base.StringSTAttribute;
// end of part 1
/** CLASS DOCUMENTATION */
public abstract class AbstractArray extends CMLElement {
/** local name*/
public final static String TAG = "array";
/** constructor. */ public AbstractArray() {
super("array");
}
/** copy constructor.
* deep copy using XOM copy()
* @param old element to copy
*/
public AbstractArray(AbstractArray old) {
super((CMLElement) old);
}
// attribute: title
/** cache */
StringSTAttribute _att_title = null;
/** A title on an element.
* No controlled value.
* @return CMLAttribute
*/
public CMLAttribute getTitleAttribute() {
return (CMLAttribute) getAttribute("title");
}
/** A title on an element.
* No controlled value.
* @return String
*/
public String getTitle() {
StringSTAttribute att = (StringSTAttribute) this.getTitleAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A title on an element.
* No controlled value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setTitle(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_title == null) {
_att_title = (StringSTAttribute) attributeFactory.getAttribute("title", "array");
if (_att_title == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : title probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_title);
super.addRemove(att, value);
}
// attribute: id
/** cache */
IdAttribute _att_id = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getIdAttribute() {
return (CMLAttribute) getAttribute("id");
}
/** null
* @return String
*/
public String getId() {
IdAttribute att = (IdAttribute) this.getIdAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setId(String value) throws RuntimeException {
IdAttribute att = null;
if (_att_id == null) {
_att_id = (IdAttribute) attributeFactory.getAttribute("id", "array");
if (_att_id == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : id probably incompatible attributeGroupName and attributeName");
}
}
att = new IdAttribute(_att_id);
super.addRemove(att, value);
}
// attribute: convention
/** cache */
StringSTAttribute _att_convention = null;
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return CMLAttribute
*/
public CMLAttribute getConventionAttribute() {
return (CMLAttribute) getAttribute("convention");
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return String
*/
public String getConvention() {
StringSTAttribute att = (StringSTAttribute) this.getConventionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setConvention(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_convention == null) {
_att_convention = (StringSTAttribute) attributeFactory.getAttribute("convention", "array");
if (_att_convention == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : convention probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_convention);
super.addRemove(att, value);
}
// attribute: dictRef
/** cache */
DictRefAttribute _att_dictref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getDictRefAttribute() {
return (CMLAttribute) getAttribute("dictRef");
}
/** null
* @return String
*/
public String getDictRef() {
DictRefAttribute att = (DictRefAttribute) this.getDictRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDictRef(String value) throws RuntimeException {
DictRefAttribute att = null;
if (_att_dictref == null) {
_att_dictref = (DictRefAttribute) attributeFactory.getAttribute("dictRef", "array");
if (_att_dictref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : dictRef probably incompatible attributeGroupName and attributeName");
}
}
att = new DictRefAttribute(_att_dictref);
super.addRemove(att, value);
}
// attribute: dataType
/** cache */
StringSTAttribute _att_datatype = null;
/** The data type of the object.
* Normally applied to scalar/array
* objects but may extend to more complex one.
* @return CMLAttribute
*/
public CMLAttribute getDataTypeAttribute() {
return (CMLAttribute) getAttribute("dataType");
}
/** The data type of the object.
* Normally applied to scalar/array
* objects but may extend to more complex one.
* @return String
*/
public String getDataType() {
StringSTAttribute att = (StringSTAttribute) this.getDataTypeAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The data type of the object.
* Normally applied to scalar/array
* objects but may extend to more complex one.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDataType(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_datatype == null) {
_att_datatype = (StringSTAttribute) attributeFactory.getAttribute("dataType", "array");
if (_att_datatype == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : dataType probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_datatype);
super.addRemove(att, value);
}
// attribute: errorValueArray
/** cache */
DoubleArraySTAttribute _att_errorvaluearray = null;
/** Array of error values.
* Reports the author's estimate of
* the error in an array of values. Only meaningful for
* dataTypes mapping to real number.
* @return CMLAttribute
*/
public CMLAttribute getErrorValueArrayAttribute() {
return (CMLAttribute) getAttribute("errorValueArray");
}
/** Array of error values.
* Reports the author's estimate of
* the error in an array of values. Only meaningful for
* dataTypes mapping to real number.
* @return double[]
*/
public double[] getErrorValueArray() {
DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getErrorValueArrayAttribute();
if (att == null) {
return null;
}
return att.getDoubleArray();
}
/** Array of error values.
* Reports the author's estimate of
* the error in an array of values. Only meaningful for
* dataTypes mapping to real number.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setErrorValueArray(String value) throws RuntimeException {
DoubleArraySTAttribute att = null;
if (_att_errorvaluearray == null) {
_att_errorvaluearray = (DoubleArraySTAttribute) attributeFactory.getAttribute("errorValueArray", "array");
if (_att_errorvaluearray == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : errorValueArray probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleArraySTAttribute(_att_errorvaluearray);
super.addRemove(att, value);
}
/** Array of error values.
* Reports the author's estimate of
* the error in an array of values. Only meaningful for
* dataTypes mapping to real number.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setErrorValueArray(double[] value) throws RuntimeException {
if (_att_errorvaluearray == null) {
_att_errorvaluearray = (DoubleArraySTAttribute) attributeFactory.getAttribute("errorValueArray", "array");
if (_att_errorvaluearray == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : errorValueArray probably incompatible attributeGroupName and attributeName ");
}
}
DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_errorvaluearray);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: errorBasis
/** cache */
StringSTAttribute _att_errorbasis = null;
/** Basis of the error estimate.
*
* @return CMLAttribute
*/
public CMLAttribute getErrorBasisAttribute() {
return (CMLAttribute) getAttribute("errorBasis");
}
/** Basis of the error estimate.
*
* @return String
*/
public String getErrorBasis() {
StringSTAttribute att = (StringSTAttribute) this.getErrorBasisAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** Basis of the error estimate.
*
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setErrorBasis(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_errorbasis == null) {
_att_errorbasis = (StringSTAttribute) attributeFactory.getAttribute("errorBasis", "array");
if (_att_errorbasis == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : errorBasis probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_errorbasis);
super.addRemove(att, value);
}
// attribute: minValueArray
/** cache */
DoubleArraySTAttribute _att_minvaluearray = null;
/** Minimum values for numeric _matrix_ or _array.
* A whitespace-separated lists of the same length as the array in the parent element.
* @return CMLAttribute
*/
public CMLAttribute getMinValueArrayAttribute() {
return (CMLAttribute) getAttribute("minValueArray");
}
/** Minimum values for numeric _matrix_ or _array.
* A whitespace-separated lists of the same length as the array in the parent element.
* @return double[]
*/
public double[] getMinValueArray() {
DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getMinValueArrayAttribute();
if (att == null) {
return null;
}
return att.getDoubleArray();
}
/** Minimum values for numeric _matrix_ or _array.
* A whitespace-separated lists of the same length as the array in the parent element.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setMinValueArray(String value) throws RuntimeException {
DoubleArraySTAttribute att = null;
if (_att_minvaluearray == null) {
_att_minvaluearray = (DoubleArraySTAttribute) attributeFactory.getAttribute("minValueArray", "array");
if (_att_minvaluearray == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : minValueArray probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleArraySTAttribute(_att_minvaluearray);
super.addRemove(att, value);
}
/** Minimum values for numeric _matrix_ or _array.
* A whitespace-separated lists of the same length as the array in the parent element.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setMinValueArray(double[] value) throws RuntimeException {
if (_att_minvaluearray == null) {
_att_minvaluearray = (DoubleArraySTAttribute) attributeFactory.getAttribute("minValueArray", "array");
if (_att_minvaluearray == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : minValueArray probably incompatible attributeGroupName and attributeName ");
}
}
DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_minvaluearray);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: maxValueArray
/** cache */
DoubleArraySTAttribute _att_maxvaluearray = null;
/** Maximum values for numeric _matrix_ or _array.
* A whitespace-separated list of the same length as the array in the parent element.
* @return CMLAttribute
*/
public CMLAttribute getMaxValueArrayAttribute() {
return (CMLAttribute) getAttribute("maxValueArray");
}
/** Maximum values for numeric _matrix_ or _array.
* A whitespace-separated list of the same length as the array in the parent element.
* @return double[]
*/
public double[] getMaxValueArray() {
DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getMaxValueArrayAttribute();
if (att == null) {
return null;
}
return att.getDoubleArray();
}
/** Maximum values for numeric _matrix_ or _array.
* A whitespace-separated list of the same length as the array in the parent element.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setMaxValueArray(String value) throws RuntimeException {
DoubleArraySTAttribute att = null;
if (_att_maxvaluearray == null) {
_att_maxvaluearray = (DoubleArraySTAttribute) attributeFactory.getAttribute("maxValueArray", "array");
if (_att_maxvaluearray == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : maxValueArray probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleArraySTAttribute(_att_maxvaluearray);
super.addRemove(att, value);
}
/** Maximum values for numeric _matrix_ or _array.
* A whitespace-separated list of the same length as the array in the parent element.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setMaxValueArray(double[] value) throws RuntimeException {
if (_att_maxvaluearray == null) {
_att_maxvaluearray = (DoubleArraySTAttribute) attributeFactory.getAttribute("maxValueArray", "array");
if (_att_maxvaluearray == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : maxValueArray probably incompatible attributeGroupName and attributeName ");
}
}
DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_maxvaluearray);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: start
/** cache */
StringSTAttribute _att_start = null;
/** The start value.
* The start value in any allowable
* XSD representation
* @return CMLAttribute
*/
public CMLAttribute getStartAttribute() {
return (CMLAttribute) getAttribute("start");
}
/** The start value.
* The start value in any allowable
* XSD representation
* @return String
*/
public String getStart() {
StringSTAttribute att = (StringSTAttribute) this.getStartAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The start value.
* The start value in any allowable
* XSD representation
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setStart(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_start == null) {
_att_start = (StringSTAttribute) attributeFactory.getAttribute("start", "array");
if (_att_start == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : start probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_start);
super.addRemove(att, value);
}
// attribute: end
/** cache */
StringSTAttribute _att_end = null;
/** The end value.
* The end value in any allowable XSD representation
* of data.
* @return CMLAttribute
*/
public CMLAttribute getEndAttribute() {
return (CMLAttribute) getAttribute("end");
}
/** The end value.
* The end value in any allowable XSD representation
* of data.
* @return String
*/
public String getEnd() {
StringSTAttribute att = (StringSTAttribute) this.getEndAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The end value.
* The end value in any allowable XSD representation
* of data.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setEnd(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_end == null) {
_att_end = (StringSTAttribute) attributeFactory.getAttribute("end", "array");
if (_att_end == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : end probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_end);
super.addRemove(att, value);
}
// attribute: units
/** cache */
UnitsAttribute _att_units = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getUnitsAttribute() {
return (CMLAttribute) getAttribute("units");
}
/** null
* @return String
*/
public String getUnits() {
UnitsAttribute att = (UnitsAttribute) this.getUnitsAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setUnits(String value) throws RuntimeException {
UnitsAttribute att = null;
if (_att_units == null) {
_att_units = (UnitsAttribute) attributeFactory.getAttribute("units", "array");
if (_att_units == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : units probably incompatible attributeGroupName and attributeName");
}
}
att = new UnitsAttribute(_att_units);
super.addRemove(att, value);
}
// attribute: delimiter
/** cache */
DelimiterAttribute _att_delimiter = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getDelimiterAttribute() {
return (CMLAttribute) getAttribute("delimiter");
}
/** null
* @return String
*/
public String getDelimiter() {
DelimiterAttribute att = (DelimiterAttribute) this.getDelimiterAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDelimiter(String value) throws RuntimeException {
DelimiterAttribute att = null;
if (_att_delimiter == null) {
_att_delimiter = (DelimiterAttribute) attributeFactory.getAttribute("delimiter", "array");
if (_att_delimiter == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : delimiter probably incompatible attributeGroupName and attributeName");
}
}
att = new DelimiterAttribute(_att_delimiter);
super.addRemove(att, value);
}
// attribute: size
/** cache */
IntSTAttribute _att_size = null;
/** The size of an array or matrix.
* No description
* @return CMLAttribute
*/
public CMLAttribute getSizeAttribute() {
return (CMLAttribute) getAttribute("size");
}
/** The size of an array or matrix.
* No description
* @return int
*/
public int getSize() {
IntSTAttribute att = (IntSTAttribute) this.getSizeAttribute();
if (att == null) {
throw new RuntimeException("int attribute is unset: size");
}
return att.getInt();
}
/** The size of an array or matrix.
* No description
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setSize(String value) throws RuntimeException {
IntSTAttribute att = null;
if (_att_size == null) {
_att_size = (IntSTAttribute) attributeFactory.getAttribute("size", "array");
if (_att_size == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : size probably incompatible attributeGroupName and attributeName");
}
}
att = new IntSTAttribute(_att_size);
super.addRemove(att, value);
}
/** The size of an array or matrix.
* No description
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setSize(int value) throws RuntimeException {
if (_att_size == null) {
_att_size = (IntSTAttribute) attributeFactory.getAttribute("size", "array");
if (_att_size == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : size probably incompatible attributeGroupName and attributeName ");
}
}
IntSTAttribute att = new IntSTAttribute(_att_size);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: ref
/** cache */
RefAttribute _att_ref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getRefAttribute() {
return (CMLAttribute) getAttribute("ref");
}
/** null
* @return String
*/
public String getRef() {
RefAttribute att = (RefAttribute) this.getRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setRef(String value) throws RuntimeException {
RefAttribute att = null;
if (_att_ref == null) {
_att_ref = (RefAttribute) attributeFactory.getAttribute("ref", "array");
if (_att_ref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : ref probably incompatible attributeGroupName and attributeName");
}
}
att = new RefAttribute(_att_ref);
super.addRemove(att, value);
}
// attribute: constantToSI
/** cache */
DoubleSTAttribute _att_constanttosi = null;
/** Additive constant to generate SI equivalent.
* The amount to add to a quantity in non-SI units to convert its representation to SI Units. This is applied *after* multiplierToSI. It is necessarily zero for SI units.
* @return CMLAttribute
*/
public CMLAttribute getConstantToSIAttribute() {
return (CMLAttribute) getAttribute("constantToSI");
}
/** Additive constant to generate SI equivalent.
* The amount to add to a quantity in non-SI units to convert its representation to SI Units. This is applied *after* multiplierToSI. It is necessarily zero for SI units.
* @return double
*/
public double getConstantToSI() {
DoubleSTAttribute att = (DoubleSTAttribute) this.getConstantToSIAttribute();
if (att == null) {
return Double.NaN;
}
return att.getDouble();
}
/** Additive constant to generate SI equivalent.
* The amount to add to a quantity in non-SI units to convert its representation to SI Units. This is applied *after* multiplierToSI. It is necessarily zero for SI units.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setConstantToSI(String value) throws RuntimeException {
DoubleSTAttribute att = null;
if (_att_constanttosi == null) {
_att_constanttosi = (DoubleSTAttribute) attributeFactory.getAttribute("constantToSI", "array");
if (_att_constanttosi == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : constantToSI probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleSTAttribute(_att_constanttosi);
super.addRemove(att, value);
}
/** Additive constant to generate SI equivalent.
* The amount to add to a quantity in non-SI units to convert its representation to SI Units. This is applied *after* multiplierToSI. It is necessarily zero for SI units.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setConstantToSI(double value) throws RuntimeException {
if (_att_constanttosi == null) {
_att_constanttosi = (DoubleSTAttribute) attributeFactory.getAttribute("constantToSI", "array");
if (_att_constanttosi == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : constantToSI probably incompatible attributeGroupName and attributeName ");
}
}
DoubleSTAttribute att = new DoubleSTAttribute(_att_constanttosi);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: multiplierToSI
/** cache */
DoubleSTAttribute _att_multipliertosi = null;
/** Multiplier to generate SI equivalent.
* The factor by which the non-SI unit should be multiplied to convert a quantity to its representation in SI Units. This is applied *before* _constantToSI_. Necessarily unity for SI unit.
* @return CMLAttribute
*/
public CMLAttribute getMultiplierToSIAttribute() {
return (CMLAttribute) getAttribute("multiplierToSI");
}
/** Multiplier to generate SI equivalent.
* The factor by which the non-SI unit should be multiplied to convert a quantity to its representation in SI Units. This is applied *before* _constantToSI_. Necessarily unity for SI unit.
* @return double
*/
public double getMultiplierToSI() {
DoubleSTAttribute att = (DoubleSTAttribute) this.getMultiplierToSIAttribute();
if (att == null) {
return Double.NaN;
}
return att.getDouble();
}
/** Multiplier to generate SI equivalent.
* The factor by which the non-SI unit should be multiplied to convert a quantity to its representation in SI Units. This is applied *before* _constantToSI_. Necessarily unity for SI unit.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setMultiplierToSI(String value) throws RuntimeException {
DoubleSTAttribute att = null;
if (_att_multipliertosi == null) {
_att_multipliertosi = (DoubleSTAttribute) attributeFactory.getAttribute("multiplierToSI", "array");
if (_att_multipliertosi == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : multiplierToSI probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleSTAttribute(_att_multipliertosi);
super.addRemove(att, value);
}
/** Multiplier to generate SI equivalent.
* The factor by which the non-SI unit should be multiplied to convert a quantity to its representation in SI Units. This is applied *before* _constantToSI_. Necessarily unity for SI unit.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setMultiplierToSI(double value) throws RuntimeException {
if (_att_multipliertosi == null) {
_att_multipliertosi = (DoubleSTAttribute) attributeFactory.getAttribute("multiplierToSI", "array");
if (_att_multipliertosi == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : multiplierToSI probably incompatible attributeGroupName and attributeName ");
}
}
DoubleSTAttribute att = new DoubleSTAttribute(_att_multipliertosi);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: unitType
/** cache */
NamespaceRefAttribute _att_unittype = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getUnitTypeAttribute() {
return (CMLAttribute) getAttribute("unitType");
}
/** null
* @return String
*/
public String getUnitType() {
NamespaceRefAttribute att = (NamespaceRefAttribute) this.getUnitTypeAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setUnitType(String value) throws RuntimeException {
NamespaceRefAttribute att = null;
if (_att_unittype == null) {
_att_unittype = (NamespaceRefAttribute) attributeFactory.getAttribute("unitType", "array");
if (_att_unittype == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : unitType probably incompatible attributeGroupName and attributeName");
}
}
att = new NamespaceRefAttribute(_att_unittype);
super.addRemove(att, value);
}
StringSTAttribute _xmlContent;
/**
*
* @return String
*/
public String getXMLContent() {
String content = this.getValue();
if (_xmlContent == null) {
_xmlContent = new StringSTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(content, true);
return _xmlContent.getString();
}
/**
*
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setXMLContent(String value) throws RuntimeException {
if (_xmlContent == null) {
_xmlContent = new StringSTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(value);
String attval = _xmlContent.getValue();
this.removeChildren();
this.appendChild(attval);
}
/** overrides addAttribute(Attribute)
* reroutes calls to setFoo()
* @param att attribute
*/
public void addAttribute(Attribute att) {
String name = att.getLocalName();
String value = att.getValue();
if (name == null) {
} else if (name.equals("title")) {
setTitle(value);
} else if (name.equals("id")) {
setId(value);
} else if (name.equals("convention")) {
setConvention(value);
} else if (name.equals("dictRef")) {
setDictRef(value);
} else if (name.equals("dataType")) {
setDataType(value);
} else if (name.equals("errorValueArray")) {
setErrorValueArray(value);
} else if (name.equals("errorBasis")) {
setErrorBasis(value);
} else if (name.equals("minValueArray")) {
setMinValueArray(value);
} else if (name.equals("maxValueArray")) {
setMaxValueArray(value);
} else if (name.equals("start")) {
setStart(value);
} else if (name.equals("end")) {
setEnd(value);
} else if (name.equals("units")) {
setUnits(value);
} else if (name.equals("delimiter")) {
setDelimiter(value);
} else if (name.equals("size")) {
setSize(value);
} else if (name.equals("ref")) {
setRef(value);
} else if (name.equals("constantToSI")) {
setConstantToSI(value);
} else if (name.equals("multiplierToSI")) {
setMultiplierToSI(value);
} else if (name.equals("unitType")) {
setUnitType(value);
} else {
super.addAttribute(att);
}
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractArrayList.java 0000775 0000000 0000000 00000027375 14772244610 0027447 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.element;
import nu.xom.Attribute;
import nu.xom.Elements;
import org.xmlcml.cml.attribute.DictRefAttribute;
import org.xmlcml.cml.attribute.IdAttribute;
import org.xmlcml.cml.base.CMLAttribute;
import org.xmlcml.cml.base.CMLConstants;
import org.xmlcml.cml.base.CMLElement;
import org.xmlcml.cml.base.CMLElements;
import org.xmlcml.cml.base.StringSTAttribute;
// end of part 1
/** CLASS DOCUMENTATION */
public abstract class AbstractArrayList extends CMLElement {
/** local name*/
public final static String TAG = "arrayList";
/** constructor. */ public AbstractArrayList() {
super("arrayList");
}
/** copy constructor.
* deep copy using XOM copy()
* @param old element to copy
*/
public AbstractArrayList(AbstractArrayList old) {
super((CMLElement) old);
}
// attribute: shape
/** cache */
StringSTAttribute _att_shape = null;
/** shape of object.
* Mainly square, but extensible through the _xsd:union_ mechanism.
* @return CMLAttribute
*/
public CMLAttribute getShapeAttribute() {
return (CMLAttribute) getAttribute("shape");
}
/** shape of object.
* Mainly square, but extensible through the _xsd:union_ mechanism.
* @return String
*/
public String getShape() {
StringSTAttribute att = (StringSTAttribute) this.getShapeAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** shape of object.
* Mainly square, but extensible through the _xsd:union_ mechanism.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setShape(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_shape == null) {
_att_shape = (StringSTAttribute) attributeFactory.getAttribute("shape", "arrayList");
if (_att_shape == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : shape probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_shape);
super.addRemove(att, value);
}
// attribute: title
/** cache */
StringSTAttribute _att_title = null;
/** A title on an element.
* No controlled value.
* @return CMLAttribute
*/
public CMLAttribute getTitleAttribute() {
return (CMLAttribute) getAttribute("title");
}
/** A title on an element.
* No controlled value.
* @return String
*/
public String getTitle() {
StringSTAttribute att = (StringSTAttribute) this.getTitleAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A title on an element.
* No controlled value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setTitle(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_title == null) {
_att_title = (StringSTAttribute) attributeFactory.getAttribute("title", "arrayList");
if (_att_title == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : title probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_title);
super.addRemove(att, value);
}
// attribute: id
/** cache */
IdAttribute _att_id = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getIdAttribute() {
return (CMLAttribute) getAttribute("id");
}
/** null
* @return String
*/
public String getId() {
IdAttribute att = (IdAttribute) this.getIdAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setId(String value) throws RuntimeException {
IdAttribute att = null;
if (_att_id == null) {
_att_id = (IdAttribute) attributeFactory.getAttribute("id", "arrayList");
if (_att_id == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : id probably incompatible attributeGroupName and attributeName");
}
}
att = new IdAttribute(_att_id);
super.addRemove(att, value);
}
// attribute: convention
/** cache */
StringSTAttribute _att_convention = null;
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return CMLAttribute
*/
public CMLAttribute getConventionAttribute() {
return (CMLAttribute) getAttribute("convention");
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return String
*/
public String getConvention() {
StringSTAttribute att = (StringSTAttribute) this.getConventionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setConvention(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_convention == null) {
_att_convention = (StringSTAttribute) attributeFactory.getAttribute("convention", "arrayList");
if (_att_convention == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : convention probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_convention);
super.addRemove(att, value);
}
// attribute: dictRef
/** cache */
DictRefAttribute _att_dictref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getDictRefAttribute() {
return (CMLAttribute) getAttribute("dictRef");
}
/** null
* @return String
*/
public String getDictRef() {
DictRefAttribute att = (DictRefAttribute) this.getDictRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDictRef(String value) throws RuntimeException {
DictRefAttribute att = null;
if (_att_dictref == null) {
_att_dictref = (DictRefAttribute) attributeFactory.getAttribute("dictRef", "arrayList");
if (_att_dictref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : dictRef probably incompatible attributeGroupName and attributeName");
}
}
att = new DictRefAttribute(_att_dictref);
super.addRemove(att, value);
}
// element: array
/** null
* @param array child to add
*/
public void addArray(AbstractArray array) {
array.detach();
this.appendChild(array);
}
/** null
* @return CMLElements<CMLArray>
*/
public CMLElements getArrayElements() {
Elements elements = this.getChildElements("array", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: list
/** null
* @param list child to add
*/
public void addList(AbstractList list) {
list.detach();
this.appendChild(list);
}
/** null
* @return CMLElements<CMLList>
*/
public CMLElements getListElements() {
Elements elements = this.getChildElements("list", CMLConstants.CML_NS);
return new CMLElements(elements);
}
/** overrides addAttribute(Attribute)
* reroutes calls to setFoo()
* @param att attribute
*/
public void addAttribute(Attribute att) {
String name = att.getLocalName();
String value = att.getValue();
if (name == null) {
} else if (name.equals("shape")) {
setShape(value);
} else if (name.equals("title")) {
setTitle(value);
} else if (name.equals("id")) {
setId(value);
} else if (name.equals("convention")) {
setConvention(value);
} else if (name.equals("dictRef")) {
setDictRef(value);
} else {
super.addAttribute(att);
}
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractAtom.java 0000775 0000000 0000000 00000243513 14772244610 0026427 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.element;
import nu.xom.Attribute;
import nu.xom.Elements;
import org.xmlcml.cml.attribute.DictRefAttribute;
import org.xmlcml.cml.attribute.IdAttribute;
import org.xmlcml.cml.attribute.RefAttribute;
import org.xmlcml.cml.base.CMLAttribute;
import org.xmlcml.cml.base.CMLConstants;
import org.xmlcml.cml.base.CMLElement;
import org.xmlcml.cml.base.CMLElements;
import org.xmlcml.cml.base.DoubleSTAttribute;
import org.xmlcml.cml.base.IntSTAttribute;
import org.xmlcml.cml.base.StringSTAttribute;
// end of part 1
/** CLASS DOCUMENTATION */
public abstract class AbstractAtom extends CMLElement {
/** local name*/
public final static String TAG = "atom";
/** constructor. */ public AbstractAtom() {
super("atom");
}
/** copy constructor.
* deep copy using XOM copy()
* @param old element to copy
*/
public AbstractAtom(AbstractAtom old) {
super((CMLElement) old);
}
// attribute: id
/** cache */
IdAttribute _att_id = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getIdAttribute() {
return (CMLAttribute) getAttribute("id");
}
/** null
* @return String
*/
public String getId() {
IdAttribute att = (IdAttribute) this.getIdAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setId(String value) throws RuntimeException {
IdAttribute att = null;
if (_att_id == null) {
_att_id = (IdAttribute) attributeFactory.getAttribute("id", "atom");
if (_att_id == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : id probably incompatible attributeGroupName and attributeName");
}
}
att = new IdAttribute(_att_id);
super.addRemove(att, value);
}
// attribute: convention
/** cache */
StringSTAttribute _att_convention = null;
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return CMLAttribute
*/
public CMLAttribute getConventionAttribute() {
return (CMLAttribute) getAttribute("convention");
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return String
*/
public String getConvention() {
StringSTAttribute att = (StringSTAttribute) this.getConventionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setConvention(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_convention == null) {
_att_convention = (StringSTAttribute) attributeFactory.getAttribute("convention", "atom");
if (_att_convention == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : convention probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_convention);
super.addRemove(att, value);
}
// attribute: dictRef
/** cache */
DictRefAttribute _att_dictref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getDictRefAttribute() {
return (CMLAttribute) getAttribute("dictRef");
}
/** null
* @return String
*/
public String getDictRef() {
DictRefAttribute att = (DictRefAttribute) this.getDictRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDictRef(String value) throws RuntimeException {
DictRefAttribute att = null;
if (_att_dictref == null) {
_att_dictref = (DictRefAttribute) attributeFactory.getAttribute("dictRef", "atom");
if (_att_dictref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : dictRef probably incompatible attributeGroupName and attributeName");
}
}
att = new DictRefAttribute(_att_dictref);
super.addRemove(att, value);
}
// attribute: ref
/** cache */
RefAttribute _att_ref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getRefAttribute() {
return (CMLAttribute) getAttribute("ref");
}
/** null
* @return String
*/
public String getRef() {
RefAttribute att = (RefAttribute) this.getRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setRef(String value) throws RuntimeException {
RefAttribute att = null;
if (_att_ref == null) {
_att_ref = (RefAttribute) attributeFactory.getAttribute("ref", "atom");
if (_att_ref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : ref probably incompatible attributeGroupName and attributeName");
}
}
att = new RefAttribute(_att_ref);
super.addRemove(att, value);
}
// attribute: count
/** cache */
DoubleSTAttribute _att_count = null;
/** The count of the object.
* No fixed semantics or default, normally integers.
* It is presumed that the element can be multiplied by the count value.
* @return CMLAttribute
*/
public CMLAttribute getCountAttribute() {
return (CMLAttribute) getAttribute("count");
}
/** The count of the object.
* No fixed semantics or default, normally integers.
* It is presumed that the element can be multiplied by the count value.
* @return double
*/
public double getCount() {
DoubleSTAttribute att = (DoubleSTAttribute) this.getCountAttribute();
if (att == null) {
return Double.NaN;
}
return att.getDouble();
}
/** The count of the object.
* No fixed semantics or default, normally integers.
* It is presumed that the element can be multiplied by the count value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setCount(String value) throws RuntimeException {
DoubleSTAttribute att = null;
if (_att_count == null) {
_att_count = (DoubleSTAttribute) attributeFactory.getAttribute("count", "atom");
if (_att_count == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : count probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleSTAttribute(_att_count);
super.addRemove(att, value);
}
/** The count of the object.
* No fixed semantics or default, normally integers.
* It is presumed that the element can be multiplied by the count value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setCount(double value) throws RuntimeException {
if (_att_count == null) {
_att_count = (DoubleSTAttribute) attributeFactory.getAttribute("count", "atom");
if (_att_count == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : count probably incompatible attributeGroupName and attributeName ");
}
}
DoubleSTAttribute att = new DoubleSTAttribute(_att_count);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: elementType
/** cache */
StringSTAttribute _att_elementtype = null;
/** The identity of a chemical element.
* Normally mandatory on _atom_, _isotope_, etc.
* @return CMLAttribute
*/
public CMLAttribute getElementTypeAttribute() {
return (CMLAttribute) getAttribute("elementType");
}
/** The identity of a chemical element.
* Normally mandatory on _atom_, _isotope_, etc.
* @return String
*/
public String getElementType() {
StringSTAttribute att = (StringSTAttribute) this.getElementTypeAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** The identity of a chemical element.
* Normally mandatory on _atom_, _isotope_, etc.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setElementType(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_elementtype == null) {
_att_elementtype = (StringSTAttribute) attributeFactory.getAttribute("elementType", "atom");
if (_att_elementtype == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : elementType probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_elementtype);
super.addRemove(att, value);
}
// attribute: formalCharge
/** cache */
IntSTAttribute _att_formalcharge = null;
/** The formalCharge on the object.
* NOT the calculated charge or oxidation state. No formal default, but assumed to be zero if omitted. It may become good practice to include it.
* @return CMLAttribute
*/
public CMLAttribute getFormalChargeAttribute() {
return (CMLAttribute) getAttribute("formalCharge");
}
/** The formalCharge on the object.
* NOT the calculated charge or oxidation state. No formal default, but assumed to be zero if omitted. It may become good practice to include it.
* @return int
*/
public int getFormalCharge() {
IntSTAttribute att = (IntSTAttribute) this.getFormalChargeAttribute();
if (att == null) {
throw new RuntimeException("int attribute is unset: formalCharge");
}
return att.getInt();
}
/** The formalCharge on the object.
* NOT the calculated charge or oxidation state. No formal default, but assumed to be zero if omitted. It may become good practice to include it.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setFormalCharge(String value) throws RuntimeException {
IntSTAttribute att = null;
if (_att_formalcharge == null) {
_att_formalcharge = (IntSTAttribute) attributeFactory.getAttribute("formalCharge", "atom");
if (_att_formalcharge == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : formalCharge probably incompatible attributeGroupName and attributeName");
}
}
att = new IntSTAttribute(_att_formalcharge);
super.addRemove(att, value);
}
/** The formalCharge on the object.
* NOT the calculated charge or oxidation state. No formal default, but assumed to be zero if omitted. It may become good practice to include it.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setFormalCharge(int value) throws RuntimeException {
if (_att_formalcharge == null) {
_att_formalcharge = (IntSTAttribute) attributeFactory.getAttribute("formalCharge", "atom");
if (_att_formalcharge == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : formalCharge probably incompatible attributeGroupName and attributeName ");
}
}
IntSTAttribute att = new IntSTAttribute(_att_formalcharge);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: hydrogenCount
/** cache */
IntSTAttribute _att_hydrogencount = null;
/** Number of hydrogens.
* The total number of hydrogens bonded to the atom or molecule. It is preferable to include hydrogens explicitly, and where this is done their count represents the minimum (and may thus override this attribute). It is dangerous to use this attribute for electron-deficient molecules (e.g. diborane) or hydrogen bonds. There is NO DEFAULT and the absence of this attribute must not be given any meaning.
* @return CMLAttribute
*/
public CMLAttribute getHydrogenCountAttribute() {
return (CMLAttribute) getAttribute("hydrogenCount");
}
/** Number of hydrogens.
* The total number of hydrogens bonded to the atom or molecule. It is preferable to include hydrogens explicitly, and where this is done their count represents the minimum (and may thus override this attribute). It is dangerous to use this attribute for electron-deficient molecules (e.g. diborane) or hydrogen bonds. There is NO DEFAULT and the absence of this attribute must not be given any meaning.
* @return int
*/
public int getHydrogenCount() {
IntSTAttribute att = (IntSTAttribute) this.getHydrogenCountAttribute();
if (att == null) {
throw new RuntimeException("int attribute is unset: hydrogenCount");
}
return att.getInt();
}
/** Number of hydrogens.
* The total number of hydrogens bonded to the atom or molecule. It is preferable to include hydrogens explicitly, and where this is done their count represents the minimum (and may thus override this attribute). It is dangerous to use this attribute for electron-deficient molecules (e.g. diborane) or hydrogen bonds. There is NO DEFAULT and the absence of this attribute must not be given any meaning.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setHydrogenCount(String value) throws RuntimeException {
IntSTAttribute att = null;
if (_att_hydrogencount == null) {
_att_hydrogencount = (IntSTAttribute) attributeFactory.getAttribute("hydrogenCount", "atom");
if (_att_hydrogencount == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : hydrogenCount probably incompatible attributeGroupName and attributeName");
}
}
att = new IntSTAttribute(_att_hydrogencount);
super.addRemove(att, value);
}
/** Number of hydrogens.
* The total number of hydrogens bonded to the atom or molecule. It is preferable to include hydrogens explicitly, and where this is done their count represents the minimum (and may thus override this attribute). It is dangerous to use this attribute for electron-deficient molecules (e.g. diborane) or hydrogen bonds. There is NO DEFAULT and the absence of this attribute must not be given any meaning.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setHydrogenCount(int value) throws RuntimeException {
if (_att_hydrogencount == null) {
_att_hydrogencount = (IntSTAttribute) attributeFactory.getAttribute("hydrogenCount", "atom");
if (_att_hydrogencount == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : hydrogenCount probably incompatible attributeGroupName and attributeName ");
}
}
IntSTAttribute att = new IntSTAttribute(_att_hydrogencount);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: isotope
/** cache */
DoubleSTAttribute _att_isotope = null;
/** The isotope for an element.
* A real number describing the isotope. Probably obsolet.
* @return CMLAttribute
*/
public CMLAttribute getIsotopeAttribute() {
return (CMLAttribute) getAttribute("isotope");
}
/** The isotope for an element.
* A real number describing the isotope. Probably obsolet.
* @return double
*/
public double getIsotope() {
DoubleSTAttribute att = (DoubleSTAttribute) this.getIsotopeAttribute();
if (att == null) {
return Double.NaN;
}
return att.getDouble();
}
/** The isotope for an element.
* A real number describing the isotope. Probably obsolet.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setIsotope(String value) throws RuntimeException {
DoubleSTAttribute att = null;
if (_att_isotope == null) {
_att_isotope = (DoubleSTAttribute) attributeFactory.getAttribute("isotope", "atom");
if (_att_isotope == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : isotope probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleSTAttribute(_att_isotope);
super.addRemove(att, value);
}
/** The isotope for an element.
* A real number describing the isotope. Probably obsolet.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setIsotope(double value) throws RuntimeException {
if (_att_isotope == null) {
_att_isotope = (DoubleSTAttribute) attributeFactory.getAttribute("isotope", "atom");
if (_att_isotope == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : isotope probably incompatible attributeGroupName and attributeName ");
}
}
DoubleSTAttribute att = new DoubleSTAttribute(_att_isotope);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: isotopeNumber
/** cache */
IntSTAttribute _att_isotopenumber = null;
/** The integer number for an isotope.
* The number representing the isotope. By default it does not point to a fuller description of the isotope (use isotopeRef).
* @return CMLAttribute
*/
public CMLAttribute getIsotopeNumberAttribute() {
return (CMLAttribute) getAttribute("isotopeNumber");
}
/** The integer number for an isotope.
* The number representing the isotope. By default it does not point to a fuller description of the isotope (use isotopeRef).
* @return int
*/
public int getIsotopeNumber() {
IntSTAttribute att = (IntSTAttribute) this.getIsotopeNumberAttribute();
if (att == null) {
throw new RuntimeException("int attribute is unset: isotopeNumber");
}
return att.getInt();
}
/** The integer number for an isotope.
* The number representing the isotope. By default it does not point to a fuller description of the isotope (use isotopeRef).
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setIsotopeNumber(String value) throws RuntimeException {
IntSTAttribute att = null;
if (_att_isotopenumber == null) {
_att_isotopenumber = (IntSTAttribute) attributeFactory.getAttribute("isotopeNumber", "atom");
if (_att_isotopenumber == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : isotopeNumber probably incompatible attributeGroupName and attributeName");
}
}
att = new IntSTAttribute(_att_isotopenumber);
super.addRemove(att, value);
}
/** The integer number for an isotope.
* The number representing the isotope. By default it does not point to a fuller description of the isotope (use isotopeRef).
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setIsotopeNumber(int value) throws RuntimeException {
if (_att_isotopenumber == null) {
_att_isotopenumber = (IntSTAttribute) attributeFactory.getAttribute("isotopeNumber", "atom");
if (_att_isotopenumber == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : isotopeNumber probably incompatible attributeGroupName and attributeName ");
}
}
IntSTAttribute att = new IntSTAttribute(_att_isotopenumber);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: isotopeRef
/** cache */
StringSTAttribute _att_isotoperef = null;
/** Reference to a fuller description of the isotope.
* No description
* @return CMLAttribute
*/
public CMLAttribute getIsotopeRefAttribute() {
return (CMLAttribute) getAttribute("isotopeRef");
}
/** Reference to a fuller description of the isotope.
* No description
* @return String
*/
public String getIsotopeRef() {
StringSTAttribute att = (StringSTAttribute) this.getIsotopeRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** Reference to a fuller description of the isotope.
* No description
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setIsotopeRef(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_isotoperef == null) {
_att_isotoperef = (StringSTAttribute) attributeFactory.getAttribute("isotopeRef", "atom");
if (_att_isotoperef == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : isotopeRef probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_isotoperef);
super.addRemove(att, value);
}
// attribute: isotopeListRef
/** cache */
StringSTAttribute _att_isotopelistref = null;
/** Reference to a description of the isotopic composition of an atom.
* Used when more than one atom shares the same isotopic composition (e.g. when H/D have been scrambled over some or all of the atoms in a molecule..
* @return CMLAttribute
*/
public CMLAttribute getIsotopeListRefAttribute() {
return (CMLAttribute) getAttribute("isotopeListRef");
}
/** Reference to a description of the isotopic composition of an atom.
* Used when more than one atom shares the same isotopic composition (e.g. when H/D have been scrambled over some or all of the atoms in a molecule..
* @return String
*/
public String getIsotopeListRef() {
StringSTAttribute att = (StringSTAttribute) this.getIsotopeListRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** Reference to a description of the isotopic composition of an atom.
* Used when more than one atom shares the same isotopic composition (e.g. when H/D have been scrambled over some or all of the atoms in a molecule..
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setIsotopeListRef(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_isotopelistref == null) {
_att_isotopelistref = (StringSTAttribute) attributeFactory.getAttribute("isotopeListRef", "atom");
if (_att_isotopelistref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : isotopeListRef probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_isotopelistref);
super.addRemove(att, value);
}
// attribute: occupancy
/** cache */
DoubleSTAttribute _att_occupancy = null;
/** Occupancy for an atom.
* Normally only found in crystallography. Defaults to 1.0. The occupancy is required to calculate the molecular formaula from the atoms.
* @return CMLAttribute
*/
public CMLAttribute getOccupancyAttribute() {
return (CMLAttribute) getAttribute("occupancy");
}
/** Occupancy for an atom.
* Normally only found in crystallography. Defaults to 1.0. The occupancy is required to calculate the molecular formaula from the atoms.
* @return double
*/
public double getOccupancy() {
DoubleSTAttribute att = (DoubleSTAttribute) this.getOccupancyAttribute();
if (att == null) {
return Double.NaN;
}
return att.getDouble();
}
/** Occupancy for an atom.
* Normally only found in crystallography. Defaults to 1.0. The occupancy is required to calculate the molecular formaula from the atoms.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setOccupancy(String value) throws RuntimeException {
DoubleSTAttribute att = null;
if (_att_occupancy == null) {
_att_occupancy = (DoubleSTAttribute) attributeFactory.getAttribute("occupancy", "atom");
if (_att_occupancy == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : occupancy probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleSTAttribute(_att_occupancy);
super.addRemove(att, value);
}
/** Occupancy for an atom.
* Normally only found in crystallography. Defaults to 1.0. The occupancy is required to calculate the molecular formaula from the atoms.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setOccupancy(double value) throws RuntimeException {
if (_att_occupancy == null) {
_att_occupancy = (DoubleSTAttribute) attributeFactory.getAttribute("occupancy", "atom");
if (_att_occupancy == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : occupancy probably incompatible attributeGroupName and attributeName ");
}
}
DoubleSTAttribute att = new DoubleSTAttribute(_att_occupancy);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: spinMultiplicity
/** cache */
IntSTAttribute _att_spinmultiplicity = null;
/** Spin multiplicity.
* Normally for a molecule. This attribute gives the spin multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value (though values are normally between 1 and 5.
* @return CMLAttribute
*/
public CMLAttribute getSpinMultiplicityAttribute() {
return (CMLAttribute) getAttribute("spinMultiplicity");
}
/** Spin multiplicity.
* Normally for a molecule. This attribute gives the spin multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value (though values are normally between 1 and 5.
* @return int
*/
public int getSpinMultiplicity() {
IntSTAttribute att = (IntSTAttribute) this.getSpinMultiplicityAttribute();
if (att == null) {
throw new RuntimeException("int attribute is unset: spinMultiplicity");
}
return att.getInt();
}
/** Spin multiplicity.
* Normally for a molecule. This attribute gives the spin multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value (though values are normally between 1 and 5.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setSpinMultiplicity(String value) throws RuntimeException {
IntSTAttribute att = null;
if (_att_spinmultiplicity == null) {
_att_spinmultiplicity = (IntSTAttribute) attributeFactory.getAttribute("spinMultiplicity", "atom");
if (_att_spinmultiplicity == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : spinMultiplicity probably incompatible attributeGroupName and attributeName");
}
}
att = new IntSTAttribute(_att_spinmultiplicity);
super.addRemove(att, value);
}
/** Spin multiplicity.
* Normally for a molecule. This attribute gives the spin multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value (though values are normally between 1 and 5.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setSpinMultiplicity(int value) throws RuntimeException {
if (_att_spinmultiplicity == null) {
_att_spinmultiplicity = (IntSTAttribute) attributeFactory.getAttribute("spinMultiplicity", "atom");
if (_att_spinmultiplicity == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : spinMultiplicity probably incompatible attributeGroupName and attributeName ");
}
}
IntSTAttribute att = new IntSTAttribute(_att_spinmultiplicity);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: x2
/** cache */
DoubleSTAttribute _att_x2 = null;
/** x2 coordinate for an object.
* Used for displaying the object in 2 dimensions. Unrelated to the 3-D coordinates for the object. The orientation of the axes matters as it can affect the chirality of object.
* @return CMLAttribute
*/
public CMLAttribute getX2Attribute() {
return (CMLAttribute) getAttribute("x2");
}
/** x2 coordinate for an object.
* Used for displaying the object in 2 dimensions. Unrelated to the 3-D coordinates for the object. The orientation of the axes matters as it can affect the chirality of object.
* @return double
*/
public double getX2() {
DoubleSTAttribute att = (DoubleSTAttribute) this.getX2Attribute();
if (att == null) {
return Double.NaN;
}
return att.getDouble();
}
/** x2 coordinate for an object.
* Used for displaying the object in 2 dimensions. Unrelated to the 3-D coordinates for the object. The orientation of the axes matters as it can affect the chirality of object.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setX2(String value) throws RuntimeException {
DoubleSTAttribute att = null;
if (_att_x2 == null) {
_att_x2 = (DoubleSTAttribute) attributeFactory.getAttribute("x2", "atom");
if (_att_x2 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : x2 probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleSTAttribute(_att_x2);
super.addRemove(att, value);
}
/** x2 coordinate for an object.
* Used for displaying the object in 2 dimensions. Unrelated to the 3-D coordinates for the object. The orientation of the axes matters as it can affect the chirality of object.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setX2(double value) throws RuntimeException {
if (_att_x2 == null) {
_att_x2 = (DoubleSTAttribute) attributeFactory.getAttribute("x2", "atom");
if (_att_x2 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : x2 probably incompatible attributeGroupName and attributeName ");
}
}
DoubleSTAttribute att = new DoubleSTAttribute(_att_x2);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: y2
/** cache */
DoubleSTAttribute _att_y2 = null;
/** y2 coordinate for an object.
* Used for displaying the object in 2
* dimensions. Unrelated to the 3-D coordinates for the object. The
* orientation of the axes matters as it can affect the chirality of
* object.
* @return CMLAttribute
*/
public CMLAttribute getY2Attribute() {
return (CMLAttribute) getAttribute("y2");
}
/** y2 coordinate for an object.
* Used for displaying the object in 2
* dimensions. Unrelated to the 3-D coordinates for the object. The
* orientation of the axes matters as it can affect the chirality of
* object.
* @return double
*/
public double getY2() {
DoubleSTAttribute att = (DoubleSTAttribute) this.getY2Attribute();
if (att == null) {
return Double.NaN;
}
return att.getDouble();
}
/** y2 coordinate for an object.
* Used for displaying the object in 2
* dimensions. Unrelated to the 3-D coordinates for the object. The
* orientation of the axes matters as it can affect the chirality of
* object.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setY2(String value) throws RuntimeException {
DoubleSTAttribute att = null;
if (_att_y2 == null) {
_att_y2 = (DoubleSTAttribute) attributeFactory.getAttribute("y2", "atom");
if (_att_y2 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : y2 probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleSTAttribute(_att_y2);
super.addRemove(att, value);
}
/** y2 coordinate for an object.
* Used for displaying the object in 2
* dimensions. Unrelated to the 3-D coordinates for the object. The
* orientation of the axes matters as it can affect the chirality of
* object.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setY2(double value) throws RuntimeException {
if (_att_y2 == null) {
_att_y2 = (DoubleSTAttribute) attributeFactory.getAttribute("y2", "atom");
if (_att_y2 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : y2 probably incompatible attributeGroupName and attributeName ");
}
}
DoubleSTAttribute att = new DoubleSTAttribute(_att_y2);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: x3
/** cache */
DoubleSTAttribute _att_x3 = null;
/** The x coordinate of a 3 dimensional object.
* The default units are Angstrom. (The provision
* for other units is weak at present.) Objects are always described
* with a right-handed coordinate system.
* @return CMLAttribute
*/
public CMLAttribute getX3Attribute() {
return (CMLAttribute) getAttribute("x3");
}
/** The x coordinate of a 3 dimensional object.
* The default units are Angstrom. (The provision
* for other units is weak at present.) Objects are always described
* with a right-handed coordinate system.
* @return double
*/
public double getX3() {
DoubleSTAttribute att = (DoubleSTAttribute) this.getX3Attribute();
if (att == null) {
return Double.NaN;
}
return att.getDouble();
}
/** The x coordinate of a 3 dimensional object.
* The default units are Angstrom. (The provision
* for other units is weak at present.) Objects are always described
* with a right-handed coordinate system.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setX3(String value) throws RuntimeException {
DoubleSTAttribute att = null;
if (_att_x3 == null) {
_att_x3 = (DoubleSTAttribute) attributeFactory.getAttribute("x3", "atom");
if (_att_x3 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : x3 probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleSTAttribute(_att_x3);
super.addRemove(att, value);
}
/** The x coordinate of a 3 dimensional object.
* The default units are Angstrom. (The provision
* for other units is weak at present.) Objects are always described
* with a right-handed coordinate system.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setX3(double value) throws RuntimeException {
if (_att_x3 == null) {
_att_x3 = (DoubleSTAttribute) attributeFactory.getAttribute("x3", "atom");
if (_att_x3 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : x3 probably incompatible attributeGroupName and attributeName ");
}
}
DoubleSTAttribute att = new DoubleSTAttribute(_att_x3);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: y3
/** cache */
DoubleSTAttribute _att_y3 = null;
/** The y coordinate of a 3 dimensional object.
* The default units are Angstrom. (The
* provision for other units is weak at present.) Objects are always
* described with a right-handed coordinate system.
* @return CMLAttribute
*/
public CMLAttribute getY3Attribute() {
return (CMLAttribute) getAttribute("y3");
}
/** The y coordinate of a 3 dimensional object.
* The default units are Angstrom. (The
* provision for other units is weak at present.) Objects are always
* described with a right-handed coordinate system.
* @return double
*/
public double getY3() {
DoubleSTAttribute att = (DoubleSTAttribute) this.getY3Attribute();
if (att == null) {
return Double.NaN;
}
return att.getDouble();
}
/** The y coordinate of a 3 dimensional object.
* The default units are Angstrom. (The
* provision for other units is weak at present.) Objects are always
* described with a right-handed coordinate system.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setY3(String value) throws RuntimeException {
DoubleSTAttribute att = null;
if (_att_y3 == null) {
_att_y3 = (DoubleSTAttribute) attributeFactory.getAttribute("y3", "atom");
if (_att_y3 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : y3 probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleSTAttribute(_att_y3);
super.addRemove(att, value);
}
/** The y coordinate of a 3 dimensional object.
* The default units are Angstrom. (The
* provision for other units is weak at present.) Objects are always
* described with a right-handed coordinate system.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setY3(double value) throws RuntimeException {
if (_att_y3 == null) {
_att_y3 = (DoubleSTAttribute) attributeFactory.getAttribute("y3", "atom");
if (_att_y3 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : y3 probably incompatible attributeGroupName and attributeName ");
}
}
DoubleSTAttribute att = new DoubleSTAttribute(_att_y3);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: z3
/** cache */
DoubleSTAttribute _att_z3 = null;
/** The z coordinate of a 3 dimensional object.
* The default units are Angstrom. (The
* provision for other units is weak at present.) Objects are always
* described with a right-handed coordinate system.
* @return CMLAttribute
*/
public CMLAttribute getZ3Attribute() {
return (CMLAttribute) getAttribute("z3");
}
/** The z coordinate of a 3 dimensional object.
* The default units are Angstrom. (The
* provision for other units is weak at present.) Objects are always
* described with a right-handed coordinate system.
* @return double
*/
public double getZ3() {
DoubleSTAttribute att = (DoubleSTAttribute) this.getZ3Attribute();
if (att == null) {
return Double.NaN;
}
return att.getDouble();
}
/** The z coordinate of a 3 dimensional object.
* The default units are Angstrom. (The
* provision for other units is weak at present.) Objects are always
* described with a right-handed coordinate system.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setZ3(String value) throws RuntimeException {
DoubleSTAttribute att = null;
if (_att_z3 == null) {
_att_z3 = (DoubleSTAttribute) attributeFactory.getAttribute("z3", "atom");
if (_att_z3 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : z3 probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleSTAttribute(_att_z3);
super.addRemove(att, value);
}
/** The z coordinate of a 3 dimensional object.
* The default units are Angstrom. (The
* provision for other units is weak at present.) Objects are always
* described with a right-handed coordinate system.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setZ3(double value) throws RuntimeException {
if (_att_z3 == null) {
_att_z3 = (DoubleSTAttribute) attributeFactory.getAttribute("z3", "atom");
if (_att_z3 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : z3 probably incompatible attributeGroupName and attributeName ");
}
}
DoubleSTAttribute att = new DoubleSTAttribute(_att_z3);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: xFract
/** cache */
DoubleSTAttribute _att_xfract = null;
/** Fractional x coordinate.
* normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
* @return CMLAttribute
*/
public CMLAttribute getXFractAttribute() {
return (CMLAttribute) getAttribute("xFract");
}
/** Fractional x coordinate.
* normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
* @return double
*/
public double getXFract() {
DoubleSTAttribute att = (DoubleSTAttribute) this.getXFractAttribute();
if (att == null) {
return Double.NaN;
}
return att.getDouble();
}
/** Fractional x coordinate.
* normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setXFract(String value) throws RuntimeException {
DoubleSTAttribute att = null;
if (_att_xfract == null) {
_att_xfract = (DoubleSTAttribute) attributeFactory.getAttribute("xFract", "atom");
if (_att_xfract == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : xFract probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleSTAttribute(_att_xfract);
super.addRemove(att, value);
}
/** Fractional x coordinate.
* normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setXFract(double value) throws RuntimeException {
if (_att_xfract == null) {
_att_xfract = (DoubleSTAttribute) attributeFactory.getAttribute("xFract", "atom");
if (_att_xfract == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : xFract probably incompatible attributeGroupName and attributeName ");
}
}
DoubleSTAttribute att = new DoubleSTAttribute(_att_xfract);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: yFract
/** cache */
DoubleSTAttribute _att_yfract = null;
/** Fractional y coordinate.
* normally xFract, yFract and zFract
* should all be present or absent. If present a _crystal_ element
* should also occur.
* @return CMLAttribute
*/
public CMLAttribute getYFractAttribute() {
return (CMLAttribute) getAttribute("yFract");
}
/** Fractional y coordinate.
* normally xFract, yFract and zFract
* should all be present or absent. If present a _crystal_ element
* should also occur.
* @return double
*/
public double getYFract() {
DoubleSTAttribute att = (DoubleSTAttribute) this.getYFractAttribute();
if (att == null) {
return Double.NaN;
}
return att.getDouble();
}
/** Fractional y coordinate.
* normally xFract, yFract and zFract
* should all be present or absent. If present a _crystal_ element
* should also occur.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setYFract(String value) throws RuntimeException {
DoubleSTAttribute att = null;
if (_att_yfract == null) {
_att_yfract = (DoubleSTAttribute) attributeFactory.getAttribute("yFract", "atom");
if (_att_yfract == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : yFract probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleSTAttribute(_att_yfract);
super.addRemove(att, value);
}
/** Fractional y coordinate.
* normally xFract, yFract and zFract
* should all be present or absent. If present a _crystal_ element
* should also occur.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setYFract(double value) throws RuntimeException {
if (_att_yfract == null) {
_att_yfract = (DoubleSTAttribute) attributeFactory.getAttribute("yFract", "atom");
if (_att_yfract == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : yFract probably incompatible attributeGroupName and attributeName ");
}
}
DoubleSTAttribute att = new DoubleSTAttribute(_att_yfract);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: zFract
/** cache */
DoubleSTAttribute _att_zfract = null;
/** Fractional y coordinate.
* normally xFract, yFract and zFract
* should all be present or absent. If present a _crystal_ element
* should also occur.
* @return CMLAttribute
*/
public CMLAttribute getZFractAttribute() {
return (CMLAttribute) getAttribute("zFract");
}
/** Fractional y coordinate.
* normally xFract, yFract and zFract
* should all be present or absent. If present a _crystal_ element
* should also occur.
* @return double
*/
public double getZFract() {
DoubleSTAttribute att = (DoubleSTAttribute) this.getZFractAttribute();
if (att == null) {
return Double.NaN;
}
return att.getDouble();
}
/** Fractional y coordinate.
* normally xFract, yFract and zFract
* should all be present or absent. If present a _crystal_ element
* should also occur.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setZFract(String value) throws RuntimeException {
DoubleSTAttribute att = null;
if (_att_zfract == null) {
_att_zfract = (DoubleSTAttribute) attributeFactory.getAttribute("zFract", "atom");
if (_att_zfract == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : zFract probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleSTAttribute(_att_zfract);
super.addRemove(att, value);
}
/** Fractional y coordinate.
* normally xFract, yFract and zFract
* should all be present or absent. If present a _crystal_ element
* should also occur.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setZFract(double value) throws RuntimeException {
if (_att_zfract == null) {
_att_zfract = (DoubleSTAttribute) attributeFactory.getAttribute("zFract", "atom");
if (_att_zfract == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : zFract probably incompatible attributeGroupName and attributeName ");
}
}
DoubleSTAttribute att = new DoubleSTAttribute(_att_zfract);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: title
/** cache */
StringSTAttribute _att_title = null;
/** A title on an element.
* No controlled value.
* @return CMLAttribute
*/
public CMLAttribute getTitleAttribute() {
return (CMLAttribute) getAttribute("title");
}
/** A title on an element.
* No controlled value.
* @return String
*/
public String getTitle() {
StringSTAttribute att = (StringSTAttribute) this.getTitleAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A title on an element.
* No controlled value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setTitle(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_title == null) {
_att_title = (StringSTAttribute) attributeFactory.getAttribute("title", "atom");
if (_att_title == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : title probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_title);
super.addRemove(att, value);
}
// attribute: role
/** cache */
StringSTAttribute _att_role = null;
/** Role of the object.
* How the object functions or its position in the architecture. No controlled vocabulary.
* @return CMLAttribute
*/
public CMLAttribute getRoleAttribute() {
return (CMLAttribute) getAttribute("role");
}
/** Role of the object.
* How the object functions or its position in the architecture. No controlled vocabulary.
* @return String
*/
public String getRole() {
StringSTAttribute att = (StringSTAttribute) this.getRoleAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** Role of the object.
* How the object functions or its position in the architecture. No controlled vocabulary.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setRole(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_role == null) {
_att_role = (StringSTAttribute) attributeFactory.getAttribute("role", "atom");
if (_att_role == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : role probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_role);
super.addRemove(att, value);
}
// attribute: spaceGroupMultiplicity
/** cache */
IntSTAttribute _att_spacegroupmultiplicity = null;
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the spaceGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 192. It represents the number of symmetry operations
* (without cell translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a spaceGroupMultiplicity of 2.
* The spaceGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the spaceGroup operators and so is formally redundant but this is a
* useful convenience operator. Some crystallographic experiments report this attribute
* as, for example, the IUCr CIF item 'atom_site_symmetry_multiplicity'.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @return CMLAttribute
*/
public CMLAttribute getSpaceGroupMultiplicityAttribute() {
return (CMLAttribute) getAttribute("spaceGroupMultiplicity");
}
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the spaceGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 192. It represents the number of symmetry operations
* (without cell translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a spaceGroupMultiplicity of 2.
* The spaceGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the spaceGroup operators and so is formally redundant but this is a
* useful convenience operator. Some crystallographic experiments report this attribute
* as, for example, the IUCr CIF item 'atom_site_symmetry_multiplicity'.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @return int
*/
public int getSpaceGroupMultiplicity() {
IntSTAttribute att = (IntSTAttribute) this.getSpaceGroupMultiplicityAttribute();
if (att == null) {
throw new RuntimeException("int attribute is unset: spaceGroupMultiplicity");
}
return att.getInt();
}
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the spaceGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 192. It represents the number of symmetry operations
* (without cell translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a spaceGroupMultiplicity of 2.
* The spaceGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the spaceGroup operators and so is formally redundant but this is a
* useful convenience operator. Some crystallographic experiments report this attribute
* as, for example, the IUCr CIF item 'atom_site_symmetry_multiplicity'.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setSpaceGroupMultiplicity(String value) throws RuntimeException {
IntSTAttribute att = null;
if (_att_spacegroupmultiplicity == null) {
_att_spacegroupmultiplicity = (IntSTAttribute) attributeFactory.getAttribute("spaceGroupMultiplicity", "atom");
if (_att_spacegroupmultiplicity == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : spaceGroupMultiplicity probably incompatible attributeGroupName and attributeName");
}
}
att = new IntSTAttribute(_att_spacegroupmultiplicity);
super.addRemove(att, value);
}
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the spaceGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 192. It represents the number of symmetry operations
* (without cell translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a spaceGroupMultiplicity of 2.
* The spaceGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the spaceGroup operators and so is formally redundant but this is a
* useful convenience operator. Some crystallographic experiments report this attribute
* as, for example, the IUCr CIF item 'atom_site_symmetry_multiplicity'.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setSpaceGroupMultiplicity(int value) throws RuntimeException {
if (_att_spacegroupmultiplicity == null) {
_att_spacegroupmultiplicity = (IntSTAttribute) attributeFactory.getAttribute("spaceGroupMultiplicity", "atom");
if (_att_spacegroupmultiplicity == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : spaceGroupMultiplicity probably incompatible attributeGroupName and attributeName ");
}
}
IntSTAttribute att = new IntSTAttribute(_att_spacegroupmultiplicity);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: pointGroupMultiplicity
/** cache */
IntSTAttribute _att_pointgroupmultiplicity = null;
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the pointGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 60 (for icosahedral). It represents the number of symmetry operations
* (without any translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a pointGroupMultiplicity of 2.
* The pointGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the pointGroup operators and so is formally redundant but this is a
* useful convenience operator.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @return CMLAttribute
*/
public CMLAttribute getPointGroupMultiplicityAttribute() {
return (CMLAttribute) getAttribute("pointGroupMultiplicity");
}
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the pointGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 60 (for icosahedral). It represents the number of symmetry operations
* (without any translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a pointGroupMultiplicity of 2.
* The pointGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the pointGroup operators and so is formally redundant but this is a
* useful convenience operator.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @return int
*/
public int getPointGroupMultiplicity() {
IntSTAttribute att = (IntSTAttribute) this.getPointGroupMultiplicityAttribute();
if (att == null) {
throw new RuntimeException("int attribute is unset: pointGroupMultiplicity");
}
return att.getInt();
}
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the pointGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 60 (for icosahedral). It represents the number of symmetry operations
* (without any translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a pointGroupMultiplicity of 2.
* The pointGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the pointGroup operators and so is formally redundant but this is a
* useful convenience operator.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setPointGroupMultiplicity(String value) throws RuntimeException {
IntSTAttribute att = null;
if (_att_pointgroupmultiplicity == null) {
_att_pointgroupmultiplicity = (IntSTAttribute) attributeFactory.getAttribute("pointGroupMultiplicity", "atom");
if (_att_pointgroupmultiplicity == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : pointGroupMultiplicity probably incompatible attributeGroupName and attributeName");
}
}
att = new IntSTAttribute(_att_pointgroupmultiplicity);
super.addRemove(att, value);
}
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the pointGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 60 (for icosahedral). It represents the number of symmetry operations
* (without any translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a pointGroupMultiplicity of 2.
* The pointGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the pointGroup operators and so is formally redundant but this is a
* useful convenience operator.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setPointGroupMultiplicity(int value) throws RuntimeException {
if (_att_pointgroupmultiplicity == null) {
_att_pointgroupmultiplicity = (IntSTAttribute) attributeFactory.getAttribute("pointGroupMultiplicity", "atom");
if (_att_pointgroupmultiplicity == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : pointGroupMultiplicity probably incompatible attributeGroupName and attributeName ");
}
}
IntSTAttribute att = new IntSTAttribute(_att_pointgroupmultiplicity);
super.addAttribute(att);
att.setCMLValue(value);
}
// element: name
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the pointGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 60 (for icosahedral). It represents the number of symmetry operations
* (without any translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a pointGroupMultiplicity of 2.
* The pointGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the pointGroup operators and so is formally redundant but this is a
* useful convenience operator.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @param name child to add
*/
public void addName(AbstractName name) {
name.detach();
this.appendChild(name);
}
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the pointGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 60 (for icosahedral). It represents the number of symmetry operations
* (without any translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a pointGroupMultiplicity of 2.
* The pointGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the pointGroup operators and so is formally redundant but this is a
* useful convenience operator.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @return CMLElements<CMLName>
*/
public CMLElements getNameElements() {
Elements elements = this.getChildElements("name", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: label
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the pointGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 60 (for icosahedral). It represents the number of symmetry operations
* (without any translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a pointGroupMultiplicity of 2.
* The pointGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the pointGroup operators and so is formally redundant but this is a
* useful convenience operator.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @param label child to add
*/
public void addLabel(AbstractLabel label) {
label.detach();
this.appendChild(label);
}
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the pointGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 60 (for icosahedral). It represents the number of symmetry operations
* (without any translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a pointGroupMultiplicity of 2.
* The pointGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the pointGroup operators and so is formally redundant but this is a
* useful convenience operator.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @return CMLElements<CMLLabel>
*/
public CMLElements getLabelElements() {
Elements elements = this.getChildElements("label", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: atomType
// element: array
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the pointGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 60 (for icosahedral). It represents the number of symmetry operations
* (without any translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a pointGroupMultiplicity of 2.
* The pointGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the pointGroup operators and so is formally redundant but this is a
* useful convenience operator.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @param array child to add
*/
public void addArray(AbstractArray array) {
array.detach();
this.appendChild(array);
}
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the pointGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 60 (for icosahedral). It represents the number of symmetry operations
* (without any translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a pointGroupMultiplicity of 2.
* The pointGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the pointGroup operators and so is formally redundant but this is a
* useful convenience operator.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @return CMLElements<CMLArray>
*/
public CMLElements getArrayElements() {
Elements elements = this.getChildElements("array", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: matrix
// element: scalar
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the pointGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 60 (for icosahedral). It represents the number of symmetry operations
* (without any translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a pointGroupMultiplicity of 2.
* The pointGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the pointGroup operators and so is formally redundant but this is a
* useful convenience operator.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @param scalar child to add
*/
public void addScalar(AbstractScalar scalar) {
scalar.detach();
this.appendChild(scalar);
}
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the pointGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 60 (for icosahedral). It represents the number of symmetry operations
* (without any translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a pointGroupMultiplicity of 2.
* The pointGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the pointGroup operators and so is formally redundant but this is a
* useful convenience operator.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @return CMLElements<CMLScalar>
*/
public CMLElements getScalarElements() {
Elements elements = this.getChildElements("scalar", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: atomParity
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the pointGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 60 (for icosahedral). It represents the number of symmetry operations
* (without any translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a pointGroupMultiplicity of 2.
* The pointGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the pointGroup operators and so is formally redundant but this is a
* useful convenience operator.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @param atomParity child to add
*/
public void addAtomParity(AbstractAtomParity atomParity) {
atomParity.detach();
this.appendChild(atomParity);
}
/** SpaceGroup multiplicity.
* Normally for an atom. This attribute gives the pointGroup multiplicity of the molecule and is independent of any atomic information. No default, and it may take any positive integer value
* (though values are normally between 1 and 60 (for icosahedral). It represents the number of symmetry operations
* (without any translations) that transform the atom into itself.
* Thus an atom on a centre of symmetry can have a pointGroupMultiplicity of 2.
* The pointGroupMultiplicity can be deduced from a knowledge of the
* coordinates and the pointGroup operators and so is formally redundant but this is a
* useful convenience operator.
* Distinguish carefully from occupancy which represents incomplete occupation of a
* site.
* @return CMLElements<CMLAtomParity>
*/
public CMLElements getAtomParityElements() {
Elements elements = this.getChildElements("atomParity", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: electron
/** overrides addAttribute(Attribute)
* reroutes calls to setFoo()
* @param att attribute
*/
public void addAttribute(Attribute att) {
String name = att.getLocalName();
String value = att.getValue();
if (name == null) {
} else if (name.equals("id")) {
setId(value);
} else if (name.equals("convention")) {
setConvention(value);
} else if (name.equals("dictRef")) {
setDictRef(value);
} else if (name.equals("ref")) {
setRef(value);
} else if (name.equals("count")) {
setCount(value);
} else if (name.equals("elementType")) {
setElementType(value);
} else if (name.equals("formalCharge")) {
setFormalCharge(value);
} else if (name.equals("hydrogenCount")) {
setHydrogenCount(value);
} else if (name.equals("isotope")) {
setIsotope(value);
} else if (name.equals("isotopeNumber")) {
setIsotopeNumber(value);
} else if (name.equals("isotopeRef")) {
setIsotopeRef(value);
} else if (name.equals("isotopeListRef")) {
setIsotopeListRef(value);
} else if (name.equals("occupancy")) {
setOccupancy(value);
} else if (name.equals("spinMultiplicity")) {
setSpinMultiplicity(value);
} else if (name.equals("x2")) {
setX2(value);
} else if (name.equals("y2")) {
setY2(value);
} else if (name.equals("x3")) {
setX3(value);
} else if (name.equals("y3")) {
setY3(value);
} else if (name.equals("z3")) {
setZ3(value);
} else if (name.equals("xFract")) {
setXFract(value);
} else if (name.equals("yFract")) {
setYFract(value);
} else if (name.equals("zFract")) {
setZFract(value);
} else if (name.equals("title")) {
setTitle(value);
} else if (name.equals("role")) {
setRole(value);
} else if (name.equals("spaceGroupMultiplicity")) {
setSpaceGroupMultiplicity(value);
} else if (name.equals("pointGroupMultiplicity")) {
setPointGroupMultiplicity(value);
} else {
super.addAttribute(att);
}
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractAtomArray.java 0000775 0000000 0000000 00000137223 14772244610 0027426 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.element;
import nu.xom.Attribute;
import nu.xom.Elements;
import org.xmlcml.cml.attribute.DictRefAttribute;
import org.xmlcml.cml.attribute.IdAttribute;
import org.xmlcml.cml.attribute.RefAttribute;
import org.xmlcml.cml.base.CMLAttribute;
import org.xmlcml.cml.base.CMLConstants;
import org.xmlcml.cml.base.CMLElement;
import org.xmlcml.cml.base.CMLElements;
import org.xmlcml.cml.base.DoubleArraySTAttribute;
import org.xmlcml.cml.base.IntArraySTAttribute;
import org.xmlcml.cml.base.StringArraySTAttribute;
import org.xmlcml.cml.base.StringSTAttribute;
// end of part 1
/** CLASS DOCUMENTATION */
public abstract class AbstractAtomArray extends CMLElement {
/** local name*/
public final static String TAG = "atomArray";
/** constructor. */ public AbstractAtomArray() {
super("atomArray");
}
/** copy constructor.
* deep copy using XOM copy()
* @param old element to copy
*/
public AbstractAtomArray(AbstractAtomArray old) {
super((CMLElement) old);
}
// attribute: title
/** cache */
StringSTAttribute _att_title = null;
/** A title on an element.
* No controlled value.
* @return CMLAttribute
*/
public CMLAttribute getTitleAttribute() {
return (CMLAttribute) getAttribute("title");
}
/** A title on an element.
* No controlled value.
* @return String
*/
public String getTitle() {
StringSTAttribute att = (StringSTAttribute) this.getTitleAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A title on an element.
* No controlled value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setTitle(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_title == null) {
_att_title = (StringSTAttribute) attributeFactory.getAttribute("title", "atomArray");
if (_att_title == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : title probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_title);
super.addRemove(att, value);
}
// attribute: id
/** cache */
IdAttribute _att_id = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getIdAttribute() {
return (CMLAttribute) getAttribute("id");
}
/** null
* @return String
*/
public String getId() {
IdAttribute att = (IdAttribute) this.getIdAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setId(String value) throws RuntimeException {
IdAttribute att = null;
if (_att_id == null) {
_att_id = (IdAttribute) attributeFactory.getAttribute("id", "atomArray");
if (_att_id == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : id probably incompatible attributeGroupName and attributeName");
}
}
att = new IdAttribute(_att_id);
super.addRemove(att, value);
}
// attribute: convention
/** cache */
StringSTAttribute _att_convention = null;
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return CMLAttribute
*/
public CMLAttribute getConventionAttribute() {
return (CMLAttribute) getAttribute("convention");
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return String
*/
public String getConvention() {
StringSTAttribute att = (StringSTAttribute) this.getConventionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setConvention(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_convention == null) {
_att_convention = (StringSTAttribute) attributeFactory.getAttribute("convention", "atomArray");
if (_att_convention == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : convention probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_convention);
super.addRemove(att, value);
}
// attribute: dictRef
/** cache */
DictRefAttribute _att_dictref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getDictRefAttribute() {
return (CMLAttribute) getAttribute("dictRef");
}
/** null
* @return String
*/
public String getDictRef() {
DictRefAttribute att = (DictRefAttribute) this.getDictRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDictRef(String value) throws RuntimeException {
DictRefAttribute att = null;
if (_att_dictref == null) {
_att_dictref = (DictRefAttribute) attributeFactory.getAttribute("dictRef", "atomArray");
if (_att_dictref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : dictRef probably incompatible attributeGroupName and attributeName");
}
}
att = new DictRefAttribute(_att_dictref);
super.addRemove(att, value);
}
// attribute: ref
/** cache */
RefAttribute _att_ref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getRefAttribute() {
return (CMLAttribute) getAttribute("ref");
}
/** null
* @return String
*/
public String getRef() {
RefAttribute att = (RefAttribute) this.getRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setRef(String value) throws RuntimeException {
RefAttribute att = null;
if (_att_ref == null) {
_att_ref = (RefAttribute) attributeFactory.getAttribute("ref", "atomArray");
if (_att_ref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : ref probably incompatible attributeGroupName and attributeName");
}
}
att = new RefAttribute(_att_ref);
super.addRemove(att, value);
}
// attribute: elementType
/** cache */
StringArraySTAttribute _att_elementtype = null;
/** The identity of a chemical element.
* Normally mandatory on _atom_, _isotope_, etc.
* @return CMLAttribute
*/
public CMLAttribute getElementTypeAttribute() {
return (CMLAttribute) getAttribute("elementType");
}
/** The identity of a chemical element.
* Normally mandatory on _atom_, _isotope_, etc.
* @return String[]
*/
public String[] getElementType() {
StringArraySTAttribute att = (StringArraySTAttribute) this.getElementTypeAttribute();
if (att == null) {
return null;
}
return att.getStringArray();
}
/** The identity of a chemical element.
* Normally mandatory on _atom_, _isotope_, etc.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setElementType(String value) throws RuntimeException {
StringArraySTAttribute att = null;
if (_att_elementtype == null) {
_att_elementtype = (StringArraySTAttribute) attributeFactory.getAttribute("elementType", "atomArray");
if (_att_elementtype == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : elementType probably incompatible attributeGroupName and attributeName");
}
}
att = new StringArraySTAttribute(_att_elementtype);
super.addRemove(att, value);
}
/** The identity of a chemical element.
* Normally mandatory on _atom_, _isotope_, etc.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setElementType(String[] value) throws RuntimeException {
if (_att_elementtype == null) {
_att_elementtype = (StringArraySTAttribute) attributeFactory.getAttribute("elementType", "atomArray");
if (_att_elementtype == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : elementType probably incompatible attributeGroupName and attributeName ");
}
}
StringArraySTAttribute att = new StringArraySTAttribute(_att_elementtype);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: count
/** cache */
DoubleArraySTAttribute _att_count = null;
/** Array of object counts.
* No fixed semantics or default, normally integral. It is presumed that the element can be multiplied by the count value.
* @return CMLAttribute
*/
public CMLAttribute getCountAttribute() {
return (CMLAttribute) getAttribute("count");
}
/** Array of object counts.
* No fixed semantics or default, normally integral. It is presumed that the element can be multiplied by the count value.
* @return double[]
*/
public double[] getCount() {
DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getCountAttribute();
if (att == null) {
return null;
}
return att.getDoubleArray();
}
/** Array of object counts.
* No fixed semantics or default, normally integral. It is presumed that the element can be multiplied by the count value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setCount(String value) throws RuntimeException {
DoubleArraySTAttribute att = null;
if (_att_count == null) {
_att_count = (DoubleArraySTAttribute) attributeFactory.getAttribute("count", "atomArray");
if (_att_count == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : count probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleArraySTAttribute(_att_count);
super.addRemove(att, value);
}
/** Array of object counts.
* No fixed semantics or default, normally integral. It is presumed that the element can be multiplied by the count value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setCount(double[] value) throws RuntimeException {
if (_att_count == null) {
_att_count = (DoubleArraySTAttribute) attributeFactory.getAttribute("count", "atomArray");
if (_att_count == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : count probably incompatible attributeGroupName and attributeName ");
}
}
DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_count);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: formalCharge
/** cache */
IntArraySTAttribute _att_formalcharge = null;
/** An array of formalCharges.
* Used in CML2 Array mode. NOT the calculated charge or oxidation state. No formal defaults, but assumed to be zero if omitted. It may become good practice to include it.
* @return CMLAttribute
*/
public CMLAttribute getFormalChargeAttribute() {
return (CMLAttribute) getAttribute("formalCharge");
}
/** An array of formalCharges.
* Used in CML2 Array mode. NOT the calculated charge or oxidation state. No formal defaults, but assumed to be zero if omitted. It may become good practice to include it.
* @return int[]
*/
public int[] getFormalCharge() {
IntArraySTAttribute att = (IntArraySTAttribute) this.getFormalChargeAttribute();
if (att == null) {
return null;
}
return att.getIntArray();
}
/** An array of formalCharges.
* Used in CML2 Array mode. NOT the calculated charge or oxidation state. No formal defaults, but assumed to be zero if omitted. It may become good practice to include it.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setFormalCharge(String value) throws RuntimeException {
IntArraySTAttribute att = null;
if (_att_formalcharge == null) {
_att_formalcharge = (IntArraySTAttribute) attributeFactory.getAttribute("formalCharge", "atomArray");
if (_att_formalcharge == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : formalCharge probably incompatible attributeGroupName and attributeName");
}
}
att = new IntArraySTAttribute(_att_formalcharge);
super.addRemove(att, value);
}
/** An array of formalCharges.
* Used in CML2 Array mode. NOT the calculated charge or oxidation state. No formal defaults, but assumed to be zero if omitted. It may become good practice to include it.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setFormalCharge(int[] value) throws RuntimeException {
if (_att_formalcharge == null) {
_att_formalcharge = (IntArraySTAttribute) attributeFactory.getAttribute("formalCharge", "atomArray");
if (_att_formalcharge == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : formalCharge probably incompatible attributeGroupName and attributeName ");
}
}
IntArraySTAttribute att = new IntArraySTAttribute(_att_formalcharge);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: hydrogenCount
/** cache */
IntArraySTAttribute _att_hydrogencount = null;
/** Array of hydrogenCounts.
* Normally used in CML2 array mode. The total number of hydrogens bonded to the atom or molecule. It is preferable to include hydrogens explicitly, and where this is done their count represents the minimum (and may thus override this attribute). It is dangerous to use this attribute for electron-deficient molecules (e.g. diborane) or hydrogen bonds. There is NO DEFAULT and the absence of this attribute must not be given any meaning.
* @return CMLAttribute
*/
public CMLAttribute getHydrogenCountAttribute() {
return (CMLAttribute) getAttribute("hydrogenCount");
}
/** Array of hydrogenCounts.
* Normally used in CML2 array mode. The total number of hydrogens bonded to the atom or molecule. It is preferable to include hydrogens explicitly, and where this is done their count represents the minimum (and may thus override this attribute). It is dangerous to use this attribute for electron-deficient molecules (e.g. diborane) or hydrogen bonds. There is NO DEFAULT and the absence of this attribute must not be given any meaning.
* @return int[]
*/
public int[] getHydrogenCount() {
IntArraySTAttribute att = (IntArraySTAttribute) this.getHydrogenCountAttribute();
if (att == null) {
return null;
}
return att.getIntArray();
}
/** Array of hydrogenCounts.
* Normally used in CML2 array mode. The total number of hydrogens bonded to the atom or molecule. It is preferable to include hydrogens explicitly, and where this is done their count represents the minimum (and may thus override this attribute). It is dangerous to use this attribute for electron-deficient molecules (e.g. diborane) or hydrogen bonds. There is NO DEFAULT and the absence of this attribute must not be given any meaning.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setHydrogenCount(String value) throws RuntimeException {
IntArraySTAttribute att = null;
if (_att_hydrogencount == null) {
_att_hydrogencount = (IntArraySTAttribute) attributeFactory.getAttribute("hydrogenCount", "atomArray");
if (_att_hydrogencount == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : hydrogenCount probably incompatible attributeGroupName and attributeName");
}
}
att = new IntArraySTAttribute(_att_hydrogencount);
super.addRemove(att, value);
}
/** Array of hydrogenCounts.
* Normally used in CML2 array mode. The total number of hydrogens bonded to the atom or molecule. It is preferable to include hydrogens explicitly, and where this is done their count represents the minimum (and may thus override this attribute). It is dangerous to use this attribute for electron-deficient molecules (e.g. diborane) or hydrogen bonds. There is NO DEFAULT and the absence of this attribute must not be given any meaning.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setHydrogenCount(int[] value) throws RuntimeException {
if (_att_hydrogencount == null) {
_att_hydrogencount = (IntArraySTAttribute) attributeFactory.getAttribute("hydrogenCount", "atomArray");
if (_att_hydrogencount == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : hydrogenCount probably incompatible attributeGroupName and attributeName ");
}
}
IntArraySTAttribute att = new IntArraySTAttribute(_att_hydrogencount);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: occupancy
/** cache */
DoubleArraySTAttribute _att_occupancy = null;
/** Array of occupancies.
* Normally only found in crystallography. Defaults to 1.0. The occupancy is required to calculate the molecular formula from the atoms.
* @return CMLAttribute
*/
public CMLAttribute getOccupancyAttribute() {
return (CMLAttribute) getAttribute("occupancy");
}
/** Array of occupancies.
* Normally only found in crystallography. Defaults to 1.0. The occupancy is required to calculate the molecular formula from the atoms.
* @return double[]
*/
public double[] getOccupancy() {
DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getOccupancyAttribute();
if (att == null) {
return null;
}
return att.getDoubleArray();
}
/** Array of occupancies.
* Normally only found in crystallography. Defaults to 1.0. The occupancy is required to calculate the molecular formula from the atoms.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setOccupancy(String value) throws RuntimeException {
DoubleArraySTAttribute att = null;
if (_att_occupancy == null) {
_att_occupancy = (DoubleArraySTAttribute) attributeFactory.getAttribute("occupancy", "atomArray");
if (_att_occupancy == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : occupancy probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleArraySTAttribute(_att_occupancy);
super.addRemove(att, value);
}
/** Array of occupancies.
* Normally only found in crystallography. Defaults to 1.0. The occupancy is required to calculate the molecular formula from the atoms.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setOccupancy(double[] value) throws RuntimeException {
if (_att_occupancy == null) {
_att_occupancy = (DoubleArraySTAttribute) attributeFactory.getAttribute("occupancy", "atomArray");
if (_att_occupancy == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : occupancy probably incompatible attributeGroupName and attributeName ");
}
}
DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_occupancy);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: x2
/** cache */
DoubleArraySTAttribute _att_x2 = null;
/** array of x2 coordinate.
* Normally used in CML2 array mode. Used for displaying the object in 2 dimensions. Unrelated to the 3-D coordinates for the object. The orientation of the axes matters as it can affect the chirality of object.
* @return CMLAttribute
*/
public CMLAttribute getX2Attribute() {
return (CMLAttribute) getAttribute("x2");
}
/** array of x2 coordinate.
* Normally used in CML2 array mode. Used for displaying the object in 2 dimensions. Unrelated to the 3-D coordinates for the object. The orientation of the axes matters as it can affect the chirality of object.
* @return double[]
*/
public double[] getX2() {
DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getX2Attribute();
if (att == null) {
return null;
}
return att.getDoubleArray();
}
/** array of x2 coordinate.
* Normally used in CML2 array mode. Used for displaying the object in 2 dimensions. Unrelated to the 3-D coordinates for the object. The orientation of the axes matters as it can affect the chirality of object.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setX2(String value) throws RuntimeException {
DoubleArraySTAttribute att = null;
if (_att_x2 == null) {
_att_x2 = (DoubleArraySTAttribute) attributeFactory.getAttribute("x2", "atomArray");
if (_att_x2 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : x2 probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleArraySTAttribute(_att_x2);
super.addRemove(att, value);
}
/** array of x2 coordinate.
* Normally used in CML2 array mode. Used for displaying the object in 2 dimensions. Unrelated to the 3-D coordinates for the object. The orientation of the axes matters as it can affect the chirality of object.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setX2(double[] value) throws RuntimeException {
if (_att_x2 == null) {
_att_x2 = (DoubleArraySTAttribute) attributeFactory.getAttribute("x2", "atomArray");
if (_att_x2 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : x2 probably incompatible attributeGroupName and attributeName ");
}
}
DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_x2);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: y2
/** cache */
DoubleArraySTAttribute _att_y2 = null;
/** array of y2 coordinate.
* Normally used in CML2 array mode. Used for displaying the object in 2 dimensions. Unrelated to the 3-D coordinates for the object. The orientation of the axes matters as it can affect the chirality of object.
* @return CMLAttribute
*/
public CMLAttribute getY2Attribute() {
return (CMLAttribute) getAttribute("y2");
}
/** array of y2 coordinate.
* Normally used in CML2 array mode. Used for displaying the object in 2 dimensions. Unrelated to the 3-D coordinates for the object. The orientation of the axes matters as it can affect the chirality of object.
* @return double[]
*/
public double[] getY2() {
DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getY2Attribute();
if (att == null) {
return null;
}
return att.getDoubleArray();
}
/** array of y2 coordinate.
* Normally used in CML2 array mode. Used for displaying the object in 2 dimensions. Unrelated to the 3-D coordinates for the object. The orientation of the axes matters as it can affect the chirality of object.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setY2(String value) throws RuntimeException {
DoubleArraySTAttribute att = null;
if (_att_y2 == null) {
_att_y2 = (DoubleArraySTAttribute) attributeFactory.getAttribute("y2", "atomArray");
if (_att_y2 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : y2 probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleArraySTAttribute(_att_y2);
super.addRemove(att, value);
}
/** array of y2 coordinate.
* Normally used in CML2 array mode. Used for displaying the object in 2 dimensions. Unrelated to the 3-D coordinates for the object. The orientation of the axes matters as it can affect the chirality of object.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setY2(double[] value) throws RuntimeException {
if (_att_y2 == null) {
_att_y2 = (DoubleArraySTAttribute) attributeFactory.getAttribute("y2", "atomArray");
if (_att_y2 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : y2 probably incompatible attributeGroupName and attributeName ");
}
}
DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_y2);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: x3
/** cache */
DoubleArraySTAttribute _att_x3 = null;
/** An array of x3 coordinate.
* No description
* @return CMLAttribute
*/
public CMLAttribute getX3Attribute() {
return (CMLAttribute) getAttribute("x3");
}
/** An array of x3 coordinate.
* No description
* @return double[]
*/
public double[] getX3() {
DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getX3Attribute();
if (att == null) {
return null;
}
return att.getDoubleArray();
}
/** An array of x3 coordinate.
* No description
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setX3(String value) throws RuntimeException {
DoubleArraySTAttribute att = null;
if (_att_x3 == null) {
_att_x3 = (DoubleArraySTAttribute) attributeFactory.getAttribute("x3", "atomArray");
if (_att_x3 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : x3 probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleArraySTAttribute(_att_x3);
super.addRemove(att, value);
}
/** An array of x3 coordinate.
* No description
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setX3(double[] value) throws RuntimeException {
if (_att_x3 == null) {
_att_x3 = (DoubleArraySTAttribute) attributeFactory.getAttribute("x3", "atomArray");
if (_att_x3 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : x3 probably incompatible attributeGroupName and attributeName ");
}
}
DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_x3);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: y3
/** cache */
DoubleArraySTAttribute _att_y3 = null;
/** An array of y3 coordinate.
* No description
* @return CMLAttribute
*/
public CMLAttribute getY3Attribute() {
return (CMLAttribute) getAttribute("y3");
}
/** An array of y3 coordinate.
* No description
* @return double[]
*/
public double[] getY3() {
DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getY3Attribute();
if (att == null) {
return null;
}
return att.getDoubleArray();
}
/** An array of y3 coordinate.
* No description
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setY3(String value) throws RuntimeException {
DoubleArraySTAttribute att = null;
if (_att_y3 == null) {
_att_y3 = (DoubleArraySTAttribute) attributeFactory.getAttribute("y3", "atomArray");
if (_att_y3 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : y3 probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleArraySTAttribute(_att_y3);
super.addRemove(att, value);
}
/** An array of y3 coordinate.
* No description
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setY3(double[] value) throws RuntimeException {
if (_att_y3 == null) {
_att_y3 = (DoubleArraySTAttribute) attributeFactory.getAttribute("y3", "atomArray");
if (_att_y3 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : y3 probably incompatible attributeGroupName and attributeName ");
}
}
DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_y3);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: z3
/** cache */
DoubleArraySTAttribute _att_z3 = null;
/** An array of z3 coordinate.
* No description
* @return CMLAttribute
*/
public CMLAttribute getZ3Attribute() {
return (CMLAttribute) getAttribute("z3");
}
/** An array of z3 coordinate.
* No description
* @return double[]
*/
public double[] getZ3() {
DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getZ3Attribute();
if (att == null) {
return null;
}
return att.getDoubleArray();
}
/** An array of z3 coordinate.
* No description
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setZ3(String value) throws RuntimeException {
DoubleArraySTAttribute att = null;
if (_att_z3 == null) {
_att_z3 = (DoubleArraySTAttribute) attributeFactory.getAttribute("z3", "atomArray");
if (_att_z3 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : z3 probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleArraySTAttribute(_att_z3);
super.addRemove(att, value);
}
/** An array of z3 coordinate.
* No description
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setZ3(double[] value) throws RuntimeException {
if (_att_z3 == null) {
_att_z3 = (DoubleArraySTAttribute) attributeFactory.getAttribute("z3", "atomArray");
if (_att_z3 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : z3 probably incompatible attributeGroupName and attributeName ");
}
}
DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_z3);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: xFract
/** cache */
DoubleArraySTAttribute _att_xfract = null;
/** Array of fractional x coordinate.
* normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
* @return CMLAttribute
*/
public CMLAttribute getXFractAttribute() {
return (CMLAttribute) getAttribute("xFract");
}
/** Array of fractional x coordinate.
* normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
* @return double[]
*/
public double[] getXFract() {
DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getXFractAttribute();
if (att == null) {
return null;
}
return att.getDoubleArray();
}
/** Array of fractional x coordinate.
* normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setXFract(String value) throws RuntimeException {
DoubleArraySTAttribute att = null;
if (_att_xfract == null) {
_att_xfract = (DoubleArraySTAttribute) attributeFactory.getAttribute("xFract", "atomArray");
if (_att_xfract == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : xFract probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleArraySTAttribute(_att_xfract);
super.addRemove(att, value);
}
/** Array of fractional x coordinate.
* normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setXFract(double[] value) throws RuntimeException {
if (_att_xfract == null) {
_att_xfract = (DoubleArraySTAttribute) attributeFactory.getAttribute("xFract", "atomArray");
if (_att_xfract == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : xFract probably incompatible attributeGroupName and attributeName ");
}
}
DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_xfract);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: yFract
/** cache */
DoubleArraySTAttribute _att_yfract = null;
/** Array of fractional y coordinate.
* normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
* @return CMLAttribute
*/
public CMLAttribute getYFractAttribute() {
return (CMLAttribute) getAttribute("yFract");
}
/** Array of fractional y coordinate.
* normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
* @return double[]
*/
public double[] getYFract() {
DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getYFractAttribute();
if (att == null) {
return null;
}
return att.getDoubleArray();
}
/** Array of fractional y coordinate.
* normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setYFract(String value) throws RuntimeException {
DoubleArraySTAttribute att = null;
if (_att_yfract == null) {
_att_yfract = (DoubleArraySTAttribute) attributeFactory.getAttribute("yFract", "atomArray");
if (_att_yfract == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : yFract probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleArraySTAttribute(_att_yfract);
super.addRemove(att, value);
}
/** Array of fractional y coordinate.
* normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setYFract(double[] value) throws RuntimeException {
if (_att_yfract == null) {
_att_yfract = (DoubleArraySTAttribute) attributeFactory.getAttribute("yFract", "atomArray");
if (_att_yfract == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : yFract probably incompatible attributeGroupName and attributeName ");
}
}
DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_yfract);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: zFract
/** cache */
DoubleArraySTAttribute _att_zfract = null;
/** Array of fractional z coordinate.
* normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
* @return CMLAttribute
*/
public CMLAttribute getZFractAttribute() {
return (CMLAttribute) getAttribute("zFract");
}
/** Array of fractional z coordinate.
* normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
* @return double[]
*/
public double[] getZFract() {
DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getZFractAttribute();
if (att == null) {
return null;
}
return att.getDoubleArray();
}
/** Array of fractional z coordinate.
* normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setZFract(String value) throws RuntimeException {
DoubleArraySTAttribute att = null;
if (_att_zfract == null) {
_att_zfract = (DoubleArraySTAttribute) attributeFactory.getAttribute("zFract", "atomArray");
if (_att_zfract == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : zFract probably incompatible attributeGroupName and attributeName");
}
}
att = new DoubleArraySTAttribute(_att_zfract);
super.addRemove(att, value);
}
/** Array of fractional z coordinate.
* normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setZFract(double[] value) throws RuntimeException {
if (_att_zfract == null) {
_att_zfract = (DoubleArraySTAttribute) attributeFactory.getAttribute("zFract", "atomArray");
if (_att_zfract == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : zFract probably incompatible attributeGroupName and attributeName ");
}
}
DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_zfract);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: atomID
/** cache */
StringArraySTAttribute _att_atomid = null;
/** An array of atom IDs.
* Normally an attribute of an array-based element.
* @return CMLAttribute
*/
public CMLAttribute getAtomIDAttribute() {
return (CMLAttribute) getAttribute("atomID");
}
/** An array of atom IDs.
* Normally an attribute of an array-based element.
* @return String[]
*/
public String[] getAtomID() {
StringArraySTAttribute att = (StringArraySTAttribute) this.getAtomIDAttribute();
if (att == null) {
return null;
}
return att.getStringArray();
}
/** An array of atom IDs.
* Normally an attribute of an array-based element.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setAtomID(String value) throws RuntimeException {
StringArraySTAttribute att = null;
if (_att_atomid == null) {
_att_atomid = (StringArraySTAttribute) attributeFactory.getAttribute("atomID", "atomArray");
if (_att_atomid == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : atomID probably incompatible attributeGroupName and attributeName");
}
}
att = new StringArraySTAttribute(_att_atomid);
super.addRemove(att, value);
}
/** An array of atom IDs.
* Normally an attribute of an array-based element.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setAtomID(String[] value) throws RuntimeException {
if (_att_atomid == null) {
_att_atomid = (StringArraySTAttribute) attributeFactory.getAttribute("atomID", "atomArray");
if (_att_atomid == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : atomID probably incompatible attributeGroupName and attributeName ");
}
}
StringArraySTAttribute att = new StringArraySTAttribute(_att_atomid);
super.addAttribute(att);
att.setCMLValue(value);
}
// element: atom
/** An array of atom IDs.
* Normally an attribute of an array-based element.
* @param atom child to add
*/
public void addAtom(AbstractAtom atom) {
atom.detach();
this.appendChild(atom);
}
/** An array of atom IDs.
* Normally an attribute of an array-based element.
* @return CMLElements<CMLAtom>
*/
public CMLElements getAtomElements() {
Elements elements = this.getChildElements("atom", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: array
/** An array of atom IDs.
* Normally an attribute of an array-based element.
* @param array child to add
*/
public void addArray(AbstractArray array) {
array.detach();
this.appendChild(array);
}
/** An array of atom IDs.
* Normally an attribute of an array-based element.
* @return CMLElements<CMLArray>
*/
public CMLElements getArrayElements() {
Elements elements = this.getChildElements("array", CMLConstants.CML_NS);
return new CMLElements(elements);
}
/** overrides addAttribute(Attribute)
* reroutes calls to setFoo()
* @param att attribute
*/
public void addAttribute(Attribute att) {
String name = att.getLocalName();
String value = att.getValue();
if (name == null) {
} else if (name.equals("title")) {
setTitle(value);
} else if (name.equals("id")) {
setId(value);
} else if (name.equals("convention")) {
setConvention(value);
} else if (name.equals("dictRef")) {
setDictRef(value);
} else if (name.equals("ref")) {
setRef(value);
} else if (name.equals("elementType")) {
setElementType(value);
} else if (name.equals("count")) {
setCount(value);
} else if (name.equals("formalCharge")) {
setFormalCharge(value);
} else if (name.equals("hydrogenCount")) {
setHydrogenCount(value);
} else if (name.equals("occupancy")) {
setOccupancy(value);
} else if (name.equals("x2")) {
setX2(value);
} else if (name.equals("y2")) {
setY2(value);
} else if (name.equals("x3")) {
setX3(value);
} else if (name.equals("y3")) {
setY3(value);
} else if (name.equals("z3")) {
setZ3(value);
} else if (name.equals("xFract")) {
setXFract(value);
} else if (name.equals("yFract")) {
setYFract(value);
} else if (name.equals("zFract")) {
setZFract(value);
} else if (name.equals("atomID")) {
setAtomID(value);
} else {
super.addAttribute(att);
}
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractAtomParity.java 0000775 0000000 0000000 00000032506 14772244610 0027616 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.element;
import nu.xom.Attribute;
import org.xmlcml.cml.attribute.DictRefAttribute;
import org.xmlcml.cml.attribute.IdAttribute;
import org.xmlcml.cml.base.CMLAttribute;
import org.xmlcml.cml.base.CMLElement;
import org.xmlcml.cml.base.DoubleSTAttribute;
import org.xmlcml.cml.base.StringArraySTAttribute;
import org.xmlcml.cml.base.StringSTAttribute;
// end of part 1
/** CLASS DOCUMENTATION */
public abstract class AbstractAtomParity extends CMLElement {
/** local name*/
public final static String TAG = "atomParity";
/** constructor. */ public AbstractAtomParity() {
super("atomParity");
}
/** copy constructor.
* deep copy using XOM copy()
* @param old element to copy
*/
public AbstractAtomParity(AbstractAtomParity old) {
super((CMLElement) old);
}
// attribute: title
/** cache */
StringSTAttribute _att_title = null;
/** A title on an element.
* No controlled value.
* @return CMLAttribute
*/
public CMLAttribute getTitleAttribute() {
return (CMLAttribute) getAttribute("title");
}
/** A title on an element.
* No controlled value.
* @return String
*/
public String getTitle() {
StringSTAttribute att = (StringSTAttribute) this.getTitleAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A title on an element.
* No controlled value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setTitle(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_title == null) {
_att_title = (StringSTAttribute) attributeFactory.getAttribute("title", "atomParity");
if (_att_title == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : title probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_title);
super.addRemove(att, value);
}
// attribute: id
/** cache */
IdAttribute _att_id = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getIdAttribute() {
return (CMLAttribute) getAttribute("id");
}
/** null
* @return String
*/
public String getId() {
IdAttribute att = (IdAttribute) this.getIdAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setId(String value) throws RuntimeException {
IdAttribute att = null;
if (_att_id == null) {
_att_id = (IdAttribute) attributeFactory.getAttribute("id", "atomParity");
if (_att_id == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : id probably incompatible attributeGroupName and attributeName");
}
}
att = new IdAttribute(_att_id);
super.addRemove(att, value);
}
// attribute: convention
/** cache */
StringSTAttribute _att_convention = null;
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return CMLAttribute
*/
public CMLAttribute getConventionAttribute() {
return (CMLAttribute) getAttribute("convention");
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return String
*/
public String getConvention() {
StringSTAttribute att = (StringSTAttribute) this.getConventionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setConvention(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_convention == null) {
_att_convention = (StringSTAttribute) attributeFactory.getAttribute("convention", "atomParity");
if (_att_convention == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : convention probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_convention);
super.addRemove(att, value);
}
// attribute: dictRef
/** cache */
DictRefAttribute _att_dictref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getDictRefAttribute() {
return (CMLAttribute) getAttribute("dictRef");
}
/** null
* @return String
*/
public String getDictRef() {
DictRefAttribute att = (DictRefAttribute) this.getDictRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDictRef(String value) throws RuntimeException {
DictRefAttribute att = null;
if (_att_dictref == null) {
_att_dictref = (DictRefAttribute) attributeFactory.getAttribute("dictRef", "atomParity");
if (_att_dictref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : dictRef probably incompatible attributeGroupName and attributeName");
}
}
att = new DictRefAttribute(_att_dictref);
super.addRemove(att, value);
}
// attribute: atomRefs4
/** cache */
StringArraySTAttribute _att_atomrefs4 = null;
/** A list of 4 references to atoms.
* Typically used for defining torsions and atomParities,
* but could also be used to define a four-centre bond.
* @return CMLAttribute
*/
public CMLAttribute getAtomRefs4Attribute() {
return (CMLAttribute) getAttribute("atomRefs4");
}
/** A list of 4 references to atoms.
* Typically used for defining torsions and atomParities,
* but could also be used to define a four-centre bond.
* @return String[]
*/
public String[] getAtomRefs4() {
StringArraySTAttribute att = (StringArraySTAttribute) this.getAtomRefs4Attribute();
if (att == null) {
return null;
}
return att.getStringArray();
}
/** A list of 4 references to atoms.
* Typically used for defining torsions and atomParities,
* but could also be used to define a four-centre bond.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setAtomRefs4(String value) throws RuntimeException {
StringArraySTAttribute att = null;
if (_att_atomrefs4 == null) {
_att_atomrefs4 = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs4", "atomParity");
if (_att_atomrefs4 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs4 probably incompatible attributeGroupName and attributeName");
}
}
att = new StringArraySTAttribute(_att_atomrefs4);
super.addRemove(att, value);
}
/** A list of 4 references to atoms.
* Typically used for defining torsions and atomParities,
* but could also be used to define a four-centre bond.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setAtomRefs4(String[] value) throws RuntimeException {
if (_att_atomrefs4 == null) {
_att_atomrefs4 = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs4", "atomParity");
if (_att_atomrefs4 == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs4 probably incompatible attributeGroupName and attributeName ");
}
}
StringArraySTAttribute att = new StringArraySTAttribute(_att_atomrefs4);
super.addAttribute(att);
att.setCMLValue(value);
}
DoubleSTAttribute _xmlContent;
/**
*
* @return double
*/
public double getXMLContent() {
String content = this.getValue();
if (_xmlContent == null) {
_xmlContent = new DoubleSTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(content);
return _xmlContent.getDouble();
}
/**
*
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setXMLContent(String value) throws RuntimeException {
if (_xmlContent == null) {
_xmlContent = new DoubleSTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(value);
String attval = _xmlContent.getValue();
this.removeChildren();
this.appendChild(attval);
}
/**
*
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setXMLContent(double value) throws RuntimeException {
if (_xmlContent == null) {
_xmlContent = new DoubleSTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(value);
String attval = (String)_xmlContent.getValue();
this.removeChildren();
this.appendChild(attval);
}
/** overrides addAttribute(Attribute)
* reroutes calls to setFoo()
* @param att attribute
*/
public void addAttribute(Attribute att) {
String name = att.getLocalName();
String value = att.getValue();
if (name == null) {
} else if (name.equals("title")) {
setTitle(value);
} else if (name.equals("id")) {
setId(value);
} else if (name.equals("convention")) {
setConvention(value);
} else if (name.equals("dictRef")) {
setDictRef(value);
} else if (name.equals("atomRefs4")) {
setAtomRefs4(value);
} else {
super.addAttribute(att);
}
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractAtomSet.java 0000775 0000000 0000000 00000035155 14772244610 0027104 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.element;
import nu.xom.Attribute;
import org.xmlcml.cml.attribute.DictRefAttribute;
import org.xmlcml.cml.attribute.IdAttribute;
import org.xmlcml.cml.base.CMLAttribute;
import org.xmlcml.cml.base.CMLElement;
import org.xmlcml.cml.base.IntSTAttribute;
import org.xmlcml.cml.base.StringArraySTAttribute;
import org.xmlcml.cml.base.StringSTAttribute;
// end of part 1
/** CLASS DOCUMENTATION */
public abstract class AbstractAtomSet extends CMLElement {
/** local name */
public final static String TAG = "atomSet";
/** constructor. */
public AbstractAtomSet() {
super("atomSet");
}
/**
* copy constructor. deep copy using XOM copy()
*
* @param old
* element to copy
*/
public AbstractAtomSet(AbstractAtomSet old) {
super((CMLElement) old);
}
// attribute: title
/** cache */
StringSTAttribute _att_title = null;
/**
* A title on an element. No controlled value.
*
* @return CMLAttribute
*/
public CMLAttribute getTitleAttribute() {
return (CMLAttribute) getAttribute("title");
}
/**
* A title on an element. No controlled value.
*
* @return String
*/
public String getTitle() {
StringSTAttribute att = (StringSTAttribute) this.getTitleAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/**
* A title on an element. No controlled value.
*
* @param value
* title value
* @throws RuntimeException
* attribute wrong value/type
*/
public void setTitle(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_title == null) {
_att_title = (StringSTAttribute) attributeFactory.getAttribute(
"title", "atomSet");
if (_att_title == null) {
throw new RuntimeException(
"BUG: cannot process attributeGroupName : title probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_title);
super.addRemove(att, value);
}
// attribute: id
/** cache */
IdAttribute _att_id = null;
/**
* null
*
* @return CMLAttribute
*/
public CMLAttribute getIdAttribute() {
return (CMLAttribute) getAttribute("id");
}
/**
* null
*
* @return String
*/
public String getId() {
IdAttribute att = (IdAttribute) this.getIdAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/**
* null
*
* @param value
* title value
* @throws RuntimeException
* attribute wrong value/type
*/
public void setId(String value) throws RuntimeException {
IdAttribute att = null;
if (_att_id == null) {
_att_id = (IdAttribute) attributeFactory.getAttribute("id",
"atomSet");
if (_att_id == null) {
throw new RuntimeException(
"BUG: cannot process attributeGroupName : id probably incompatible attributeGroupName and attributeName");
}
}
att = new IdAttribute(_att_id);
super.addRemove(att, value);
}
// attribute: convention
/** cache */
StringSTAttribute _att_convention = null;
/**
* A reference to a convention. There is no controlled vocabulary for
* conventions, but the author must ensure that the semantics are openly
* available and that there are mechanisms for implementation. The
* convention is inherited by all the subelements, so that a convention for
* molecule would by default extend to its bond and atom children. This can
* be overwritten if necessary by an explicit convention. It may be useful
* to create conventions with namespaces (e.g. iupac:name). Use of
* convention will normally require non-STMML semantics, and should be used
* with caution. We would expect that conventions prefixed with "ISO" would
* be useful, such as ISO8601 for dateTimes. There is no default, but the
* conventions of STMML or the related language (e.g. CML) will be assumed.
*
* @return CMLAttribute
*/
public CMLAttribute getConventionAttribute() {
return (CMLAttribute) getAttribute("convention");
}
/**
* A reference to a convention. There is no controlled vocabulary for
* conventions, but the author must ensure that the semantics are openly
* available and that there are mechanisms for implementation. The
* convention is inherited by all the subelements, so that a convention for
* molecule would by default extend to its bond and atom children. This can
* be overwritten if necessary by an explicit convention. It may be useful
* to create conventions with namespaces (e.g. iupac:name). Use of
* convention will normally require non-STMML semantics, and should be used
* with caution. We would expect that conventions prefixed with "ISO" would
* be useful, such as ISO8601 for dateTimes. There is no default, but the
* conventions of STMML or the related language (e.g. CML) will be assumed.
*
* @return String
*/
public String getConvention() {
StringSTAttribute att = (StringSTAttribute) this
.getConventionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/**
* A reference to a convention. There is no controlled vocabulary for
* conventions, but the author must ensure that the semantics are openly
* available and that there are mechanisms for implementation. The
* convention is inherited by all the subelements, so that a convention for
* molecule would by default extend to its bond and atom children. This can
* be overwritten if necessary by an explicit convention. It may be useful
* to create conventions with namespaces (e.g. iupac:name). Use of
* convention will normally require non-STMML semantics, and should be used
* with caution. We would expect that conventions prefixed with "ISO" would
* be useful, such as ISO8601 for dateTimes. There is no default, but the
* conventions of STMML or the related language (e.g. CML) will be assumed.
*
* @param value
* title value
* @throws RuntimeException
* attribute wrong value/type
*/
public void setConvention(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_convention == null) {
_att_convention = (StringSTAttribute) attributeFactory
.getAttribute("convention", "atomSet");
if (_att_convention == null) {
throw new RuntimeException(
"BUG: cannot process attributeGroupName : convention probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_convention);
super.addRemove(att, value);
}
// attribute: dictRef
/** cache */
DictRefAttribute _att_dictref = null;
/**
* null
*
* @return CMLAttribute
*/
public CMLAttribute getDictRefAttribute() {
return (CMLAttribute) getAttribute("dictRef");
}
/**
* null
*
* @return String
*/
public String getDictRef() {
DictRefAttribute att = (DictRefAttribute) this.getDictRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/**
* null
*
* @param value
* title value
* @throws RuntimeException
* attribute wrong value/type
*/
public void setDictRef(String value) throws RuntimeException {
DictRefAttribute att = null;
if (_att_dictref == null) {
_att_dictref = (DictRefAttribute) attributeFactory.getAttribute(
"dictRef", "atomSet");
if (_att_dictref == null) {
throw new RuntimeException(
"BUG: cannot process attributeGroupName : dictRef probably incompatible attributeGroupName and attributeName");
}
}
att = new DictRefAttribute(_att_dictref);
super.addRemove(att, value);
}
// attribute: size
/** cache */
IntSTAttribute _att_size = null;
/**
* The size of an array or matrix. No description
*
* @return CMLAttribute
*/
public CMLAttribute getSizeAttribute() {
return (CMLAttribute) getAttribute("size");
}
/**
* The size of an array or matrix. No description
*
* @return int
*/
public int getSize() {
IntSTAttribute att = (IntSTAttribute) this.getSizeAttribute();
if (att == null) {
throw new RuntimeException("int attribute is unset: size");
}
return att.getInt();
}
/**
* The size of an array or matrix. No description
*
* @param value
* title value
* @throws RuntimeException
* attribute wrong value/type
*/
public void setSize(String value) throws RuntimeException {
IntSTAttribute att = null;
if (_att_size == null) {
_att_size = (IntSTAttribute) attributeFactory.getAttribute("size",
"atomSet");
if (_att_size == null) {
throw new RuntimeException(
"BUG: cannot process attributeGroupName : size probably incompatible attributeGroupName and attributeName");
}
}
att = new IntSTAttribute(_att_size);
super.addRemove(att, value);
}
/**
* The size of an array or matrix. No description
*
* @param value
* title value
* @throws RuntimeException
* attribute wrong value/type
*/
public void setSize(int value) throws RuntimeException {
if (_att_size == null) {
_att_size = (IntSTAttribute) attributeFactory.getAttribute("size",
"atomSet");
if (_att_size == null) {
throw new RuntimeException(
"BUG: cannot process attributeGroupName : size probably incompatible attributeGroupName and attributeName ");
}
}
IntSTAttribute att = new IntSTAttribute(_att_size);
super.addAttribute(att);
att.setCMLValue(value);
}
StringArraySTAttribute _xmlContent;
/**
* An array of atomRefs. The atomRefs cannot be schema- or
* schematron-validated. Instances of this type will be used in array-style
* representation of bonds and atomParitys. It can also be used for arrays
* of atomIDTypes such as in complex stereochemistry, geometrical
* definitions, atom groupings, etc.
*
* @return String[]
*/
public String[] getXMLContent() {
String content = this.getValue();
if (_xmlContent == null) {
_xmlContent = new StringArraySTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(content);
return _xmlContent.getStringArray();
}
/**
* An array of atomRefs. The atomRefs cannot be schema- or
* schematron-validated. Instances of this type will be used in array-style
* representation of bonds and atomParitys. It can also be used for arrays
* of atomIDTypes such as in complex stereochemistry, geometrical
* definitions, atom groupings, etc.
*
* @param value
* title value
* @throws RuntimeException
* attribute wrong value/type
*/
public void setXMLContent(String value) throws RuntimeException {
if (_xmlContent == null) {
_xmlContent = new StringArraySTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(value);
String attval = _xmlContent.getValue();
this.removeChildren();
this.appendChild(attval);
}
/**
* An array of atomRefs. The atomRefs cannot be schema- or
* schematron-validated. Instances of this type will be used in array-style
* representation of bonds and atomParitys. It can also be used for arrays
* of atomIDTypes such as in complex stereochemistry, geometrical
* definitions, atom groupings, etc.
*
* @param value
* title value
* @throws RuntimeException
* attribute wrong value/type
*/
public void setXMLContent(String[] value) throws RuntimeException {
if (_xmlContent == null) {
_xmlContent = new StringArraySTAttribute("_xmlContent");
}
_xmlContent.setCMLValue(value);
String attval = (String) _xmlContent.getValue();
this.removeChildren();
this.appendChild(attval);
}
/**
* overrides addAttribute(Attribute) reroutes calls to setFoo()
*
* @param att
* attribute
*/
public void addAttribute(Attribute att) {
String name = att.getLocalName();
String value = att.getValue();
if (name == null) {
} else if (name.equals("title")) {
setTitle(value);
} else if (name.equals("id")) {
setId(value);
} else if (name.equals("convention")) {
setConvention(value);
} else if (name.equals("dictRef")) {
setDictRef(value);
} else if (name.equals("size")) {
setSize(value);
} else {
super.addAttribute(att);
}
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractAtomType.java 0000775 0000000 0000000 00000041473 14772244610 0027272 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.element;
import nu.xom.Attribute;
import nu.xom.Elements;
import org.xmlcml.cml.attribute.DictRefAttribute;
import org.xmlcml.cml.attribute.IdAttribute;
import org.xmlcml.cml.attribute.RefAttribute;
import org.xmlcml.cml.base.CMLAttribute;
import org.xmlcml.cml.base.CMLConstants;
import org.xmlcml.cml.base.CMLElement;
import org.xmlcml.cml.base.CMLElements;
import org.xmlcml.cml.base.StringSTAttribute;
// end of part 1
/** CLASS DOCUMENTATION */
public abstract class AbstractAtomType extends CMLElement {
/** local name*/
public final static String TAG = "atomType";
/** constructor. */ public AbstractAtomType() {
super("atomType");
}
/** copy constructor.
* deep copy using XOM copy()
* @param old element to copy
*/
public AbstractAtomType(AbstractAtomType old) {
super((CMLElement) old);
}
// attribute: name
/** cache */
StringSTAttribute _att_name = null;
/** Name of the object.
* A string by which the object is known. Often a required attribute. The may or may not be a semi-controlled vocabulary.
* @return CMLAttribute
*/
public CMLAttribute getNameAttribute() {
return (CMLAttribute) getAttribute("name");
}
/** Name of the object.
* A string by which the object is known. Often a required attribute. The may or may not be a semi-controlled vocabulary.
* @return String
*/
public String getName() {
StringSTAttribute att = (StringSTAttribute) this.getNameAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** Name of the object.
* A string by which the object is known. Often a required attribute. The may or may not be a semi-controlled vocabulary.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setName(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_name == null) {
_att_name = (StringSTAttribute) attributeFactory.getAttribute("name", "atomType");
if (_att_name == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : name probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_name);
super.addRemove(att, value);
}
// attribute: ref
/** cache */
RefAttribute _att_ref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getRefAttribute() {
return (CMLAttribute) getAttribute("ref");
}
/** null
* @return String
*/
public String getRef() {
RefAttribute att = (RefAttribute) this.getRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setRef(String value) throws RuntimeException {
RefAttribute att = null;
if (_att_ref == null) {
_att_ref = (RefAttribute) attributeFactory.getAttribute("ref", "atomType");
if (_att_ref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : ref probably incompatible attributeGroupName and attributeName");
}
}
att = new RefAttribute(_att_ref);
super.addRemove(att, value);
}
// attribute: atomRef
/** cache */
StringSTAttribute _att_atomref = null;
/** A reference to an atom.
* Used by bond, electron, etc.
* @return CMLAttribute
*/
public CMLAttribute getAtomRefAttribute() {
return (CMLAttribute) getAttribute("atomRef");
}
/** A reference to an atom.
* Used by bond, electron, etc.
* @return String
*/
public String getAtomRef() {
StringSTAttribute att = (StringSTAttribute) this.getAtomRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A reference to an atom.
* Used by bond, electron, etc.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setAtomRef(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_atomref == null) {
_att_atomref = (StringSTAttribute) attributeFactory.getAttribute("atomRef", "atomType");
if (_att_atomref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : atomRef probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_atomref);
super.addRemove(att, value);
}
// attribute: title
/** cache */
StringSTAttribute _att_title = null;
/** A title on an element.
* No controlled value.
* @return CMLAttribute
*/
public CMLAttribute getTitleAttribute() {
return (CMLAttribute) getAttribute("title");
}
/** A title on an element.
* No controlled value.
* @return String
*/
public String getTitle() {
StringSTAttribute att = (StringSTAttribute) this.getTitleAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A title on an element.
* No controlled value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setTitle(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_title == null) {
_att_title = (StringSTAttribute) attributeFactory.getAttribute("title", "atomType");
if (_att_title == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : title probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_title);
super.addRemove(att, value);
}
// attribute: id
/** cache */
IdAttribute _att_id = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getIdAttribute() {
return (CMLAttribute) getAttribute("id");
}
/** null
* @return String
*/
public String getId() {
IdAttribute att = (IdAttribute) this.getIdAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setId(String value) throws RuntimeException {
IdAttribute att = null;
if (_att_id == null) {
_att_id = (IdAttribute) attributeFactory.getAttribute("id", "atomType");
if (_att_id == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : id probably incompatible attributeGroupName and attributeName");
}
}
att = new IdAttribute(_att_id);
super.addRemove(att, value);
}
// attribute: convention
/** cache */
StringSTAttribute _att_convention = null;
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return CMLAttribute
*/
public CMLAttribute getConventionAttribute() {
return (CMLAttribute) getAttribute("convention");
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return String
*/
public String getConvention() {
StringSTAttribute att = (StringSTAttribute) this.getConventionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setConvention(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_convention == null) {
_att_convention = (StringSTAttribute) attributeFactory.getAttribute("convention", "atomType");
if (_att_convention == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : convention probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_convention);
super.addRemove(att, value);
}
// attribute: dictRef
/** cache */
DictRefAttribute _att_dictref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getDictRefAttribute() {
return (CMLAttribute) getAttribute("dictRef");
}
/** null
* @return String
*/
public String getDictRef() {
DictRefAttribute att = (DictRefAttribute) this.getDictRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDictRef(String value) throws RuntimeException {
DictRefAttribute att = null;
if (_att_dictref == null) {
_att_dictref = (DictRefAttribute) attributeFactory.getAttribute("dictRef", "atomType");
if (_att_dictref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : dictRef probably incompatible attributeGroupName and attributeName");
}
}
att = new DictRefAttribute(_att_dictref);
super.addRemove(att, value);
}
// element: molecule
/** null
* @param molecule child to add
*/
public void addMolecule(AbstractMolecule molecule) {
molecule.detach();
this.appendChild(molecule);
}
/** null
* @return CMLElements<CMLMolecule>
*/
public CMLElements getMoleculeElements() {
Elements elements = this.getChildElements("molecule", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: atom
/** null
* @param atom child to add
*/
public void addAtom(AbstractAtom atom) {
atom.detach();
this.appendChild(atom);
}
/** null
* @return CMLElements<CMLAtom>
*/
public CMLElements getAtomElements() {
Elements elements = this.getChildElements("atom", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: label
/** null
* @param label child to add
*/
public void addLabel(AbstractLabel label) {
label.detach();
this.appendChild(label);
}
/** null
* @return CMLElements<CMLLabel>
*/
public CMLElements getLabelElements() {
Elements elements = this.getChildElements("label", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: scalar
/** null
* @param scalar child to add
*/
public void addScalar(AbstractScalar scalar) {
scalar.detach();
this.appendChild(scalar);
}
/** null
* @return CMLElements<CMLScalar>
*/
public CMLElements getScalarElements() {
Elements elements = this.getChildElements("scalar", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: array
/** null
* @param array child to add
*/
public void addArray(AbstractArray array) {
array.detach();
this.appendChild(array);
}
/** null
* @return CMLElements<CMLArray>
*/
public CMLElements getArrayElements() {
Elements elements = this.getChildElements("array", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: matrix
/** null
* @param matrix child to add
*/
public void addMatrix(AbstractMatrix matrix) {
matrix.detach();
this.appendChild(matrix);
}
/** null
* @return CMLElements<CMLMatrix>
*/
public CMLElements getMatrixElements() {
Elements elements = this.getChildElements("matrix", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: property
/** null
* @param property child to add
*/
public void addProperty(AbstractProperty property) {
property.detach();
this.appendChild(property);
}
/** null
* @return CMLElements<CMLProperty>
*/
public CMLElements getPropertyElements() {
Elements elements = this.getChildElements("property", CMLConstants.CML_NS);
return new CMLElements(elements);
}
/** overrides addAttribute(Attribute)
* reroutes calls to setFoo()
* @param att attribute
*/
public void addAttribute(Attribute att) {
String name = att.getLocalName();
String value = att.getValue();
if (name == null) {
} else if (name.equals("name")) {
setName(value);
} else if (name.equals("ref")) {
setRef(value);
} else if (name.equals("atomRef")) {
setAtomRef(value);
} else if (name.equals("title")) {
setTitle(value);
} else if (name.equals("id")) {
setId(value);
} else if (name.equals("convention")) {
setConvention(value);
} else if (name.equals("dictRef")) {
setDictRef(value);
} else {
super.addAttribute(att);
}
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractAtomTypeList.java 0000775 0000000 0000000 00000030124 14772244610 0030115 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.element;
import nu.xom.Attribute;
import nu.xom.Elements;
import org.xmlcml.cml.attribute.DictRefAttribute;
import org.xmlcml.cml.attribute.IdAttribute;
import org.xmlcml.cml.attribute.RefAttribute;
import org.xmlcml.cml.base.CMLAttribute;
import org.xmlcml.cml.base.CMLConstants;
import org.xmlcml.cml.base.CMLElement;
import org.xmlcml.cml.base.CMLElements;
import org.xmlcml.cml.base.StringSTAttribute;
// end of part 1
/** CLASS DOCUMENTATION */
public abstract class AbstractAtomTypeList extends CMLElement {
/** local name*/
public final static String TAG = "atomTypeList";
/** constructor. */ public AbstractAtomTypeList() {
super("atomTypeList");
}
/** copy constructor.
* deep copy using XOM copy()
* @param old element to copy
*/
public AbstractAtomTypeList(AbstractAtomTypeList old) {
super((CMLElement) old);
}
// attribute: dictRef
/** cache */
DictRefAttribute _att_dictref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getDictRefAttribute() {
return (CMLAttribute) getAttribute("dictRef");
}
/** null
* @return String
*/
public String getDictRef() {
DictRefAttribute att = (DictRefAttribute) this.getDictRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDictRef(String value) throws RuntimeException {
DictRefAttribute att = null;
if (_att_dictref == null) {
_att_dictref = (DictRefAttribute) attributeFactory.getAttribute("dictRef", "atomTypeList");
if (_att_dictref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : dictRef probably incompatible attributeGroupName and attributeName");
}
}
att = new DictRefAttribute(_att_dictref);
super.addRemove(att, value);
}
// attribute: convention
/** cache */
StringSTAttribute _att_convention = null;
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return CMLAttribute
*/
public CMLAttribute getConventionAttribute() {
return (CMLAttribute) getAttribute("convention");
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return String
*/
public String getConvention() {
StringSTAttribute att = (StringSTAttribute) this.getConventionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setConvention(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_convention == null) {
_att_convention = (StringSTAttribute) attributeFactory.getAttribute("convention", "atomTypeList");
if (_att_convention == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : convention probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_convention);
super.addRemove(att, value);
}
// attribute: title
/** cache */
StringSTAttribute _att_title = null;
/** A title on an element.
* No controlled value.
* @return CMLAttribute
*/
public CMLAttribute getTitleAttribute() {
return (CMLAttribute) getAttribute("title");
}
/** A title on an element.
* No controlled value.
* @return String
*/
public String getTitle() {
StringSTAttribute att = (StringSTAttribute) this.getTitleAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A title on an element.
* No controlled value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setTitle(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_title == null) {
_att_title = (StringSTAttribute) attributeFactory.getAttribute("title", "atomTypeList");
if (_att_title == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : title probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_title);
super.addRemove(att, value);
}
// attribute: id
/** cache */
IdAttribute _att_id = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getIdAttribute() {
return (CMLAttribute) getAttribute("id");
}
/** null
* @return String
*/
public String getId() {
IdAttribute att = (IdAttribute) this.getIdAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setId(String value) throws RuntimeException {
IdAttribute att = null;
if (_att_id == null) {
_att_id = (IdAttribute) attributeFactory.getAttribute("id", "atomTypeList");
if (_att_id == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : id probably incompatible attributeGroupName and attributeName");
}
}
att = new IdAttribute(_att_id);
super.addRemove(att, value);
}
// attribute: ref
/** cache */
RefAttribute _att_ref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getRefAttribute() {
return (CMLAttribute) getAttribute("ref");
}
/** null
* @return String
*/
public String getRef() {
RefAttribute att = (RefAttribute) this.getRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setRef(String value) throws RuntimeException {
RefAttribute att = null;
if (_att_ref == null) {
_att_ref = (RefAttribute) attributeFactory.getAttribute("ref", "atomTypeList");
if (_att_ref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : ref probably incompatible attributeGroupName and attributeName");
}
}
att = new RefAttribute(_att_ref);
super.addRemove(att, value);
}
// element: metadataList
/** null
* @param metadataList child to add
*/
public void addMetadataList(AbstractMetadataList metadataList) {
metadataList.detach();
this.appendChild(metadataList);
}
/** null
* @return CMLElements<CMLMetadataList>
*/
public CMLElements getMetadataListElements() {
Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: name
/** null
* @param name child to add
*/
public void addName(AbstractName name) {
name.detach();
this.appendChild(name);
}
/** null
* @return CMLElements<CMLName>
*/
public CMLElements getNameElements() {
Elements elements = this.getChildElements("name", CMLConstants.CML_NS);
return new CMLElements(elements);
}
// element: atomType
/** null
* @param atomType child to add
*/
public void addAtomType(AbstractAtomType atomType) {
atomType.detach();
this.appendChild(atomType);
}
/** null
* @return CMLElements<CMLAtomType>
*/
public CMLElements getAtomTypeElements() {
Elements elements = this.getChildElements("atomType", CMLConstants.CML_NS);
return new CMLElements(elements);
}
/** overrides addAttribute(Attribute)
* reroutes calls to setFoo()
* @param att attribute
*/
public void addAttribute(Attribute att) {
String name = att.getLocalName();
String value = att.getValue();
if (name == null) {
} else if (name.equals("dictRef")) {
setDictRef(value);
} else if (name.equals("convention")) {
setConvention(value);
} else if (name.equals("title")) {
setTitle(value);
} else if (name.equals("id")) {
setId(value);
} else if (name.equals("ref")) {
setRef(value);
} else {
super.addAttribute(att);
}
}
}
cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractAtomicBasisFunction.java 0000775 0000000 0000000 00000052005 14772244610 0031425 0 ustar 00root root 0000000 0000000 /**
* Copyright 2011 Peter Murray-Rust et. al.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xmlcml.cml.element;
import nu.xom.Attribute;
import nu.xom.Elements;
import org.xmlcml.cml.attribute.DictRefAttribute;
import org.xmlcml.cml.attribute.IdAttribute;
import org.xmlcml.cml.base.CMLAttribute;
import org.xmlcml.cml.base.CMLConstants;
import org.xmlcml.cml.base.CMLElement;
import org.xmlcml.cml.base.CMLElements;
import org.xmlcml.cml.base.IntSTAttribute;
import org.xmlcml.cml.base.StringSTAttribute;
// end of part 1
/** CLASS DOCUMENTATION */
public abstract class AbstractAtomicBasisFunction extends CMLElement {
/** local name*/
public final static String TAG = "atomicBasisFunction";
/** constructor. */ public AbstractAtomicBasisFunction() {
super("atomicBasisFunction");
}
/** copy constructor.
* deep copy using XOM copy()
* @param old element to copy
*/
public AbstractAtomicBasisFunction(AbstractAtomicBasisFunction old) {
super((CMLElement) old);
}
// attribute: atomRef
/** cache */
StringSTAttribute _att_atomref = null;
/** A reference to an atom.
* Used by bond, electron, etc.
* @return CMLAttribute
*/
public CMLAttribute getAtomRefAttribute() {
return (CMLAttribute) getAttribute("atomRef");
}
/** A reference to an atom.
* Used by bond, electron, etc.
* @return String
*/
public String getAtomRef() {
StringSTAttribute att = (StringSTAttribute) this.getAtomRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A reference to an atom.
* Used by bond, electron, etc.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setAtomRef(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_atomref == null) {
_att_atomref = (StringSTAttribute) attributeFactory.getAttribute("atomRef", "atomicBasisFunction");
if (_att_atomref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : atomRef probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_atomref);
super.addRemove(att, value);
}
// attribute: title
/** cache */
StringSTAttribute _att_title = null;
/** A title on an element.
* No controlled value.
* @return CMLAttribute
*/
public CMLAttribute getTitleAttribute() {
return (CMLAttribute) getAttribute("title");
}
/** A title on an element.
* No controlled value.
* @return String
*/
public String getTitle() {
StringSTAttribute att = (StringSTAttribute) this.getTitleAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A title on an element.
* No controlled value.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setTitle(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_title == null) {
_att_title = (StringSTAttribute) attributeFactory.getAttribute("title", "atomicBasisFunction");
if (_att_title == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : title probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_title);
super.addRemove(att, value);
}
// attribute: id
/** cache */
IdAttribute _att_id = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getIdAttribute() {
return (CMLAttribute) getAttribute("id");
}
/** null
* @return String
*/
public String getId() {
IdAttribute att = (IdAttribute) this.getIdAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setId(String value) throws RuntimeException {
IdAttribute att = null;
if (_att_id == null) {
_att_id = (IdAttribute) attributeFactory.getAttribute("id", "atomicBasisFunction");
if (_att_id == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : id probably incompatible attributeGroupName and attributeName");
}
}
att = new IdAttribute(_att_id);
super.addRemove(att, value);
}
// attribute: convention
/** cache */
StringSTAttribute _att_convention = null;
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return CMLAttribute
*/
public CMLAttribute getConventionAttribute() {
return (CMLAttribute) getAttribute("convention");
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @return String
*/
public String getConvention() {
StringSTAttribute att = (StringSTAttribute) this.getConventionAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A reference to a convention.
* There is no controlled vocabulary for conventions, but the author must ensure that the semantics are openly available and that there are mechanisms for implementation. The convention is inherited by all the subelements,
* so that a convention for molecule would by default extend to its bond and atom children. This can be overwritten
* if necessary by an explicit convention.
* It may be useful to create conventions with namespaces (e.g. iupac:name).
* Use of convention will normally require non-STMML semantics, and should be used with
* caution. We would expect that conventions prefixed with "ISO" would be useful,
* such as ISO8601 for dateTimes.
* There is no default, but the conventions of STMML or the related language (e.g. CML) will be assumed.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setConvention(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_convention == null) {
_att_convention = (StringSTAttribute) attributeFactory.getAttribute("convention", "atomicBasisFunction");
if (_att_convention == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : convention probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_convention);
super.addRemove(att, value);
}
// attribute: dictRef
/** cache */
DictRefAttribute _att_dictref = null;
/** null
* @return CMLAttribute
*/
public CMLAttribute getDictRefAttribute() {
return (CMLAttribute) getAttribute("dictRef");
}
/** null
* @return String
*/
public String getDictRef() {
DictRefAttribute att = (DictRefAttribute) this.getDictRefAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** null
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setDictRef(String value) throws RuntimeException {
DictRefAttribute att = null;
if (_att_dictref == null) {
_att_dictref = (DictRefAttribute) attributeFactory.getAttribute("dictRef", "atomicBasisFunction");
if (_att_dictref == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : dictRef probably incompatible attributeGroupName and attributeName");
}
}
att = new DictRefAttribute(_att_dictref);
super.addRemove(att, value);
}
// attribute: n
/** cache */
IntSTAttribute _att_n = null;
/** The principal quantum number.
* Takes values 1, 2, 3, etc.
* @return CMLAttribute
*/
public CMLAttribute getNAttribute() {
return (CMLAttribute) getAttribute("n");
}
/** The principal quantum number.
* Takes values 1, 2, 3, etc.
* @return int
*/
public int getN() {
IntSTAttribute att = (IntSTAttribute) this.getNAttribute();
if (att == null) {
throw new RuntimeException("int attribute is unset: n");
}
return att.getInt();
}
/** The principal quantum number.
* Takes values 1, 2, 3, etc.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setN(String value) throws RuntimeException {
IntSTAttribute att = null;
if (_att_n == null) {
_att_n = (IntSTAttribute) attributeFactory.getAttribute("n", "atomicBasisFunction");
if (_att_n == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : n probably incompatible attributeGroupName and attributeName");
}
}
att = new IntSTAttribute(_att_n);
super.addRemove(att, value);
}
/** The principal quantum number.
* Takes values 1, 2, 3, etc.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setN(int value) throws RuntimeException {
if (_att_n == null) {
_att_n = (IntSTAttribute) attributeFactory.getAttribute("n", "atomicBasisFunction");
if (_att_n == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : n probably incompatible attributeGroupName and attributeName ");
}
}
IntSTAttribute att = new IntSTAttribute(_att_n);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: l
/** cache */
IntSTAttribute _att_l = null;
/** The secondary quantum number.
* takes values 0, 1, etc.
* @return CMLAttribute
*/
public CMLAttribute getLAttribute() {
return (CMLAttribute) getAttribute("l");
}
/** The secondary quantum number.
* takes values 0, 1, etc.
* @return int
*/
public int getL() {
IntSTAttribute att = (IntSTAttribute) this.getLAttribute();
if (att == null) {
throw new RuntimeException("int attribute is unset: l");
}
return att.getInt();
}
/** The secondary quantum number.
* takes values 0, 1, etc.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setL(String value) throws RuntimeException {
IntSTAttribute att = null;
if (_att_l == null) {
_att_l = (IntSTAttribute) attributeFactory.getAttribute("l", "atomicBasisFunction");
if (_att_l == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : l probably incompatible attributeGroupName and attributeName");
}
}
att = new IntSTAttribute(_att_l);
super.addRemove(att, value);
}
/** The secondary quantum number.
* takes values 0, 1, etc.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setL(int value) throws RuntimeException {
if (_att_l == null) {
_att_l = (IntSTAttribute) attributeFactory.getAttribute("l", "atomicBasisFunction");
if (_att_l == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : l probably incompatible attributeGroupName and attributeName ");
}
}
IntSTAttribute att = new IntSTAttribute(_att_l);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: m
/** cache */
IntSTAttribute _att_m = null;
/** The azimuthal quantum number.
* takes values -1, 0, 1, etc.
* @return CMLAttribute
*/
public CMLAttribute getMAttribute() {
return (CMLAttribute) getAttribute("m");
}
/** The azimuthal quantum number.
* takes values -1, 0, 1, etc.
* @return int
*/
public int getM() {
IntSTAttribute att = (IntSTAttribute) this.getMAttribute();
if (att == null) {
throw new RuntimeException("int attribute is unset: m");
}
return att.getInt();
}
/** The azimuthal quantum number.
* takes values -1, 0, 1, etc.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setM(String value) throws RuntimeException {
IntSTAttribute att = null;
if (_att_m == null) {
_att_m = (IntSTAttribute) attributeFactory.getAttribute("m", "atomicBasisFunction");
if (_att_m == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : m probably incompatible attributeGroupName and attributeName");
}
}
att = new IntSTAttribute(_att_m);
super.addRemove(att, value);
}
/** The azimuthal quantum number.
* takes values -1, 0, 1, etc.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setM(int value) throws RuntimeException {
if (_att_m == null) {
_att_m = (IntSTAttribute) attributeFactory.getAttribute("m", "atomicBasisFunction");
if (_att_m == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : m probably incompatible attributeGroupName and attributeName ");
}
}
IntSTAttribute att = new IntSTAttribute(_att_m);
super.addAttribute(att);
att.setCMLValue(value);
}
// attribute: symbol
/** cache */
StringSTAttribute _att_symbol = null;
/** A symbol.
* No semantics. However it should contain only
* ASCII characters and we may have to develop an escaping mechanism.
* Used on _atomicBasisFunction_, _unit_, etc.
* @return CMLAttribute
*/
public CMLAttribute getSymbolAttribute() {
return (CMLAttribute) getAttribute("symbol");
}
/** A symbol.
* No semantics. However it should contain only
* ASCII characters and we may have to develop an escaping mechanism.
* Used on _atomicBasisFunction_, _unit_, etc.
* @return String
*/
public String getSymbol() {
StringSTAttribute att = (StringSTAttribute) this.getSymbolAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** A symbol.
* No semantics. However it should contain only
* ASCII characters and we may have to develop an escaping mechanism.
* Used on _atomicBasisFunction_, _unit_, etc.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setSymbol(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_symbol == null) {
_att_symbol = (StringSTAttribute) attributeFactory.getAttribute("symbol", "atomicBasisFunction");
if (_att_symbol == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : symbol probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_symbol);
super.addRemove(att, value);
}
// attribute: lm
/** cache */
StringSTAttribute _att_lm = null;
/** symbolic represention of l amd m.
* takes avlues of s, p, px, dxy, dx2y2, f, etc.
* @return CMLAttribute
*/
public CMLAttribute getLmAttribute() {
return (CMLAttribute) getAttribute("lm");
}
/** symbolic represention of l amd m.
* takes avlues of s, p, px, dxy, dx2y2, f, etc.
* @return String
*/
public String getLm() {
StringSTAttribute att = (StringSTAttribute) this.getLmAttribute();
if (att == null) {
return null;
}
return att.getString();
}
/** symbolic represention of l amd m.
* takes avlues of s, p, px, dxy, dx2y2, f, etc.
* @param value title value
* @throws RuntimeException attribute wrong value/type
*/
public void setLm(String value) throws RuntimeException {
StringSTAttribute att = null;
if (_att_lm == null) {
_att_lm = (StringSTAttribute) attributeFactory.getAttribute("lm", "atomicBasisFunction");
if (_att_lm == null) {
throw new RuntimeException("BUG: cannot process attributeGroupName : lm probably incompatible attributeGroupName and attributeName");
}
}
att = new StringSTAttribute(_att_lm);
super.addRemove(att, value);
}
// element: gradient
/** symbolic represention of l amd m.
* takes avlues of s, p, px, dxy, dx2y2, f, etc.
* @param gradient child to add
*/
public void addGradient(AbstractGradient gradient) {
gradient.detach();
this.appendChild(gradient);
}
/** symbolic represention of l amd m.
* takes avlues of s, p, px, dxy, dx2y2, f, etc.
* @return CMLElements<CMLGradient>
*/
public CMLElements