pax_global_header00006660000000000000000000000064147722446100014521gustar00rootroot0000000000000052 comment=81946dd2f0c185e60f757c484e4fc9941dfbdbd9 cmlxom-cmlxom-4.11/000077500000000000000000000000001477224461000142425ustar00rootroot00000000000000cmlxom-cmlxom-4.11/.github/000077500000000000000000000000001477224461000156025ustar00rootroot00000000000000cmlxom-cmlxom-4.11/.github/workflows/000077500000000000000000000000001477224461000176375ustar00rootroot00000000000000cmlxom-cmlxom-4.11/.github/workflows/maven.yml000066400000000000000000000016711477224461000214750ustar00rootroot00000000000000name: Java CI with Maven on: push: pull_request: jobs: build: runs-on: ubuntu-latest strategy: matrix: java: [ 8, 11, 17, 19 ] steps: - uses: actions/checkout@v4 - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v4 with: java-version: ${{ matrix.java }} distribution: 'temurin' - name: Build with Maven run: mvn clean install -Dgpg.skip -Dmaven.javadoc.skip=true coverage: runs-on: ubuntu-latest needs: build steps: - uses: actions/checkout@v4 - name: Set up Java uses: actions/setup-java@v4 with: distribution: temurin java-version: 8 - name: Build with Maven run: mvn clean install -Dgpg.skip -Dmaven.javadoc.skip=true -Dmaven.test.failure.ignore=true - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} cmlxom-cmlxom-4.11/.gitignore000077500000000000000000000001031477224461000162270ustar00rootroot00000000000000foo .project .settings/ .classpath .gitignore~ ^target/.* /target/ cmlxom-cmlxom-4.11/CITATION.cff000066400000000000000000000010441477224461000161330ustar00rootroot00000000000000cff-version: 1.2.0 message: "If you use this software, please cite it as below." title: CMLXOM version: 4.11 date-released: 2025-03-30 url: "https://github.com/BlueObelisk/cmlxom" preferred-citation: type: article authors: - family-names: Murray-Rust given-names: Peter - family-names: Rzepa given-names: Henry S. title: "CML: Evolution and design" year: 2011 month: 10 day: 14 journal: Journal of Cheminformatics volume: 3 issue: 44 doi: 10.1186/1758-2946-3-44 url: https://doi.org/10.1186/1758-2946-3-44 cmlxom-cmlxom-4.11/LICENSE.md000066400000000000000000000243771477224461000156630ustar00rootroot00000000000000Apache License ============== _Version 2.0, January 2004_ _<>_ ### Terms and Conditions for use, reproduction, and distribution #### 1. Definitions “License” shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. “Licensor” shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. “Legal Entity” shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, “control” means **(i)** the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the outstanding shares, or **(iii)** beneficial ownership of such entity. “You” (or “Your”) shall mean an individual or Legal Entity exercising permissions granted by this License. “Source” form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. “Object” form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. “Work” shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). “Derivative Works” shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. “Contribution” shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, “submitted” means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as “Not a Contribution.” “Contributor” shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. #### 2. Grant of Copyright License Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. #### 3. Grant of Patent License Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. #### 4. Redistribution You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: * **(a)** You must give any other recipients of the Work or Derivative Works a copy of this License; and * **(b)** You must cause any modified files to carry prominent notices stating that You changed the files; and * **(c)** You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and * **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. #### 5. Submission of Contributions Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. #### 6. Trademarks This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. #### 7. Disclaimer of Warranty Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. #### 8. Limitation of Liability In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. #### 9. Accepting Warranty or Additional Liability While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. _END OF TERMS AND CONDITIONS_ ### APPENDIX: How to apply the Apache License to your work To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets `[]` replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same “printed page” as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. cmlxom-cmlxom-4.11/README.md000066400000000000000000000016561477224461000155310ustar00rootroot00000000000000# CMLXOM [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.blueobelisk/cmlxom/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.blueobelisk/cmlxom) [![Build Status](https://github.com/BlueObelisk/cmlxom/actions/workflows/maven.yml/badge.svg)](https://github.com/BlueObelisk/cmlxom/actions/workflows/maven.yml) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5815142.svg)](https://doi.org/10.5281/zenodo.5815142) [![codecov](https://codecov.io/gh/BlueObelisk/cmlxom/branch/main/graph/badge.svg?token=E1NGWVWL04)](https://codecov.io/gh/BlueObelisk/cmlxom) A Java library for processing CML, implementing the XML object model (XOM) for the Chemical Markup Language (CML). ## Releases Instructions to increase the version: ```shell mvn versions:set -DnewVersion=4.12-SNAPSHOT ``` Deploy to Sonatype with the following commands, for snapshots and releases respectively: ```shell mvn clean deploy ``` cmlxom-cmlxom-4.11/nbactions.xml000077500000000000000000000020711477224461000167470ustar00rootroot00000000000000 build-with-dependencies .. reactor:make ${groupId}:${artifactId} cmlxom-cmlxom-4.11/pom.xml000066400000000000000000000331631477224461000155650ustar00rootroot00000000000000 4.0.0 org.blueobelisk cmlxom 4.11 jar CMLXOM A Java library for processing CML https://github.com/BlueObelisk/cmlxom Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt repo UTF-8 UTF-8 https://github.com/BlueObelisk/cmlxom scm:git:git://github.com/blueobelisk/cmlxom.git scm:git:ssh://git@github.com/blueobelisk/cmlxom.git adw27 Andrew Walkingshaw anyday Nick Day billyfish Simon "Billy" Tyrrell dmj30 David Jessop drzz Daniel Zaharevitz egonw Egon Willighagen ghutchis Geoff Hutchison glh29 Gemma Holliday Gowrishankar04 Gowri Shankar K iamramin Ramin Ghorashi icebearsoft Zdenek Wagner jat45 Joe Townsend jd323 Justin Davies jimdowning Jim Downing jiratj Jiri Jirat jryder Jen Ryder karne Michael Wright lehebax Sakshi Jain msh41 Mark Holt nicmila Miloslav Nic nickengland Nick England peter_corbett Peter Corbett petermr Peter Murray-Rust rzepa1 Henry Rzepa sea36 Sam Adams shk3 Stefan Kuhn sivasuriyankumarasamy sivasuriyankumarasamy steinbeck Christoph Steinbeck tohel Tobias Helmut tohw Toby White yz237 Yong Zhang 1994 cml-discuss https://lists.sourceforge.net/lists/listinfo/cml-discuss https://lists.sourceforge.net/lists/listinfo/cml-discuss http://sourceforge.net/mailarchive/forum.php?forum_name=cml-discuss hudson https://hudson.ch.cam.ac.uk/job/cmlxom Peter Murray-Rust http://blogs.ch.cam.ac.uk/pmr/ org.apache.maven.plugins maven-enforcer-plugin 3.4.1 enforce-maven enforce 3.2.5 1.8 org.apache.maven.plugins maven-compiler-plugin 3.12.1 1.8 1.8 org.apache.maven.plugins maven-javadoc-plugin 3.6.3 all,-missing 8 attach-javadocs jar aggregate aggregate site maven-source-plugin 3.3.0 attach-sources jar-no-fork org.codehaus.mojo cobertura-maven-plugin 2.7 false org.xmlcml.* 80 80 org/xmlcml/**/*.class clean pre-site clean instrument site instrument cobertura check com.mycila license-maven-plugin 4.3
src/main/resources/header.txt
org.sonatype.plugins nexus-staging-maven-plugin 1.6.13 true ossrh https://s01.oss.sonatype.org/ true org.apache.maven.plugins maven-gpg-plugin 3.1.0 sign-artifacts verify sign org.jacoco jacoco-maven-plugin 0.8.11 start-agent prepare-agent generate-report report
ossrh https://s01.oss.sonatype.org/content/repositories/snapshots ossrh https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ sonatypeSnapshots Sonatype Snapshots false true https://s01.oss.sonatype.org/content/repositories/snapshots org.blueobelisk euclid 2.10 xom xom 1.3.9 xerces xercesImpl xerces xercesImpl 2.12.2 test joda-time joda-time 2.14.0 commons-io commons-io 2.18.0 org.apache.logging.log4j log4j-1.2-api 2.24.3 org.ccil.cowan.tagsoup tagsoup 1.2.1 xml-apis xml-apis 1.4.01 junit junit 4.13.2 true release maven-assembly-plugin src org.apache.maven.plugins maven-project-info-reports-plugin index summary dependencies project-team license cim scm org.apache.maven.plugins maven-javadoc-plugin org.apache.maven.plugins maven-surefire-report-plugin org.apache.maven.plugins maven-jxr-plugin org.apache.maven.plugins maven-pmd-plugin 1.5 true org.apache.maven.plugins maven-checkstyle-plugin src/test/resources/checkstyle.xml org.codehaus.mojo cobertura-maven-plugin 2.7 org.codehaus.mojo apt-maven-plugin
cmlxom-cmlxom-4.11/src/000077500000000000000000000000001477224461000150315ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/000077500000000000000000000000001477224461000157555ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/java/000077500000000000000000000000001477224461000166765ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/java/org/000077500000000000000000000000001477224461000174655ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/000077500000000000000000000000001477224461000207615ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/000077500000000000000000000000001477224461000215345ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/attribute/000077500000000000000000000000001477224461000235375ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/attribute/CountExpressionAttributeAdapter.java000077500000000000000000000140111477224461000327370ustar00rootroot00000000000000/** * 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.attribute; import java.util.regex.Matcher; import java.util.regex.Pattern; import nu.xom.Attribute; import org.xmlcml.cml.base.StringSTAttribute; /** * user-modifiable class supporting "countExpression". * wraps a countExpression attribute and provides the same * functionality as CountExpressionAttribute used to do */ //TODO still under development public class CountExpressionAttributeAdapter extends StringSTAttribute { // /** count expression */ // public final static String NAME = "countExpression"; // String argName = "null"; // int start = 0; // int end = 0; // /** // * constructor. // * // */ // public CountExpressionAttribute() { // super(NAME); // } // // /** constructor. // * @param value // */ // public CountExpressionAttribute(String value) { // super(NAME); // this.setCMLValue(value); // } /** * constructor from element with CountExpressionAttribute * * @param att * @exception RuntimeException */ public CountExpressionAttributeAdapter(Attribute att) throws RuntimeException { super(att); } /** set value and process. * * @param value * @exception RuntimeException bad value */ public void setCMLValue(String value) throws RuntimeException { if (value == null) { throw new RuntimeException("null CountExpressionAttribute value"); } else if (value.trim().equals(S_EMPTY)) { // seems to get called with empty string initially // this is a bug } else { super.setCMLValue(value); } } /** expands countExpression into an integer. * if simple integer *(5) return that * if gaussian(n,m) computes a random value from the distrib (NYI) * if range(n,m) computes a random value in the range * if countExpression missing returns 1 * @return the count */ public int calculateCountExpression() { int count = 1; String countEx = this.getValue(); if (countEx != null) { // Element parent = (Element)this.getParent(); // if (parent != null) { // parent.removeAttribute(parent.getAttribute(CountExpressionAttribute.NAME)); // } if (countEx.startsWith("gaussian")) { countEx = countEx.substring("gaussian".length()); int[] counts = parseCount(countEx); if (counts.length != 2 || counts[0] <= 3 || counts[1] < 1 || counts[0] / counts[1] < 3) { throw new RuntimeException("Bad gaussian: "+countEx); } throw new RuntimeException("gaussian NYI"); } else if (countEx.startsWith("range")) { countEx = countEx.substring("range".length()); int[] counts = parseCount(countEx); if (counts.length != 2 || counts[0] < 0 || counts[0] >= counts[1]) { throw new RuntimeException("Bad range: "+countEx); } double mid2 = (counts[1] + counts[0])/2.; double delta2 = (counts[1] - counts[0])/2.; double dd = mid2 + delta2 * (0.5 - Math.random()); count = (int) Math.round(dd); } else if (countEx.startsWith(S_STAR)) { countEx = countEx.substring(S_STAR.length()); int[] counts = parseCount(countEx); if (counts.length != 1) { throw new RuntimeException("Bad range: "+countEx); } count = counts[0]; } else { throw new RuntimeException("Bad count expression: "+countEx); } } return count; } private int[] parseCount(String countEx) { if (!countEx.startsWith(S_LBRAK) || !countEx.endsWith(S_RBRAK)) { throw new RuntimeException("Bad range: requires (d,d): "+countEx); } countEx = countEx.substring(1, countEx.length()-1).trim(); String[] countStrings = countEx.split(S_COMMA); int[] counts = new int[countStrings.length]; for (int i = 0; i < countStrings.length; i++) { try { counts[i] = Integer.parseInt(countStrings[i]); } catch (NumberFormatException e) { throw new RuntimeException("Bad integer in countExpression :"+countStrings[i]); } } return counts; } /** * * @return a two-dimensional array containing the lower and upper values specified (in that order) * or null if there is no range */ public int [] getRange() { String countExpression = getValue(); String regex = "(?<=range\\()\\d+,\\d+(?=\\))"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(countExpression); if (matcher.find()) { String match = matcher.group(); String [] values = match.split(","); if (!(values.length == 2)) throw new RuntimeException(); int [] range = new int[2]; range [0] = Integer.parseInt(values[0]); range [1] = Integer.parseInt(values[1]); return range; } else return null; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/attribute/DelimiterAttribute.java000077500000000000000000000174301477224461000302140ustar00rootroot00000000000000/** * 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.attribute; import nu.xom.Attribute; import org.xmlcml.cml.base.StringSTAttribute; import org.xmlcml.euclid.Util; /** * user-modifiable class supporting "ref", a pointer * to a CML object. default is to clone the object and then process it. * For that reason the referenced species should be pre-declared. */ public class DelimiterAttribute extends StringSTAttribute { /** action when ensuringAttribute * * @author pm286 * */ public enum Action { /** reset to null */ RESET, /** preserve existing */ PRESERVE; private Action() { } } /** dewisott */ public final static String NAME = "delimiter"; private String splitter = null; private String concat = null; /** * constructor. * */ public DelimiterAttribute() { super(NAME); } /** constructor. * @param value */ public DelimiterAttribute(String value) { super(NAME); this.setCMLValue(value); } /** * constructor. * * @param att * @exception RuntimeException */ public DelimiterAttribute(Attribute att) throws RuntimeException { super(att); this.setCMLValue(att.getValue()); } /** set value and process. * * @param value * @exception RuntimeException bad value */ public void setCMLValue(String value) throws RuntimeException { if (value == null) { value = S_SPACE; } value = value.trim(); if (value.equals(S_EMPTY)) { value = S_SPACE; } else if (value.length() > 1) { throw new RuntimeException("Non-whitespace delimiter must only be single character"); } super.setCMLValue(value); if (value.equals(S_SPACE)) { setSplitter(S_WHITEREGEX); setConcat(S_SPACE); } else { setSplitter(getEscapedDelimiter(value)); setConcat(value); } } /** * @return the concat */ public String getConcat() { return concat; } /** * @param concat the concat to set */ public void setConcat(String concat) { this.concat = concat; } /** * @return the splitter */ public String getSplitter() { return splitter; } /** * @param splitter the splitter to set */ public void setSplitter(String splitter) { this.splitter = splitter; } /** * adds escape for regex metacharacters. e.g. '|' transforms to '\\|' * * @param delim * @return the escaped string */ private static String getEscapedDelimiter(String delim) { String delim1 = delim; if (delim.length() == 1) { // FIXME - need to add other regex characters if (delim.equals(S_PIPE) || delim.equals(S_QUERY) || delim.equals(S_STAR) || delim.equals(S_PERIOD)) { delim1 = "\\" + delim; } } return delim1; } /** * * @param content * @return split strings */ public String[] getSplitContent(String content) { String[] ss = new String[0]; content = content.trim(); if (content.length() > 0) { if (!isWhitespace()) { if (content.startsWith(concat)) { content = content.substring(1); } if (content.endsWith(concat)) { content = content.substring(0, content.length() - concat.length()); } } ss = content.split(splitter); } return ss; } /** * checks that components does not clash with delimiter. * * @param s string to check * @throws RuntimeException if d is part of s */ public void checkDelimiter(String s) throws RuntimeException { if (s.split(splitter).length > 1) { throw new RuntimeException("cannot delimit {" + s + "} with {" + concat + S_RCURLY); } } /** * set text content. if delimiter is not whitespace, prepend and append it * * @param s * @return string */ public String getDelimitedXMLContent(String s) { if (s == null) { s = S_EMPTY; } if (!s.equals(S_EMPTY)) { if (!isWhitespace()) { if (!s.startsWith(concat)) { s = concat + s; } if (!s.endsWith(concat)) { s += concat; } } } return s; } /** * append to text content. if delimiter is not whitespace, prepend and * append it * * @param s previous string * @param snew to append * @return xml content */ public String appendXMLContent(String s, String snew) { s = getDelimitedXMLContent(s); if (!isWhitespace()) { if (s.length() == 0) { s = concat + snew + concat; } else { s += (snew + concat); } } else { s += (concat + snew); } return s; } private boolean isWhitespace() { return S_WHITEREGEX.equals(splitter); } /** set text content. if delimiter is not whitespace, prepend and append it * * @param ss * @return string */ public String getDelimitedXMLContent(String[] ss) { for (String s : ss) { checkDelimiter(s); } String s = Util.concatenate(ss, concat); if (!isWhitespace()) { s = concat + s + concat; } return s; } /** set double content. if delimiter is not whitespace, prepend and append it * * @param bb array of booleans * @return string */ public String getDelimitedXMLContent(boolean[] bb) { for (boolean b: bb) { checkDelimiter(S_EMPTY+b); } String s = Util.concatenate(bb, concat); if (!isWhitespace()) { s = concat + s + concat; } return s; } /** set double content. if delimiter is not whitespace, prepend and append it * * @param dd array of doubles * @return string */ public String getDelimitedXMLContent(double[] dd) { for (double d: dd) { checkDelimiter(S_EMPTY+d); } String s = Util.concatenate(dd, concat); if (!isWhitespace()) { s = concat + s + concat; } return s; } /** set int content. if delimiter is not whitespace, prepend and append it * * @param ii int array * @return content */ public String getDelimitedXMLContent(int[] ii) { for (int i : ii) { checkDelimiter(S_EMPTY+i); } String s = Util.concatenate(ii, concat); if (!isWhitespace()) { s = concat + s + concat; } return s; } /** debug. * * @param s name of debug output */ public void debug(String s) { Util.println("-------- "+s+" -------"); Util.println(this+" .. "+this.getValue()+" .. "+this.splitter+" .. "+concat); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/attribute/DictRefAttribute.java000077500000000000000000000056641477224461000276240ustar00rootroot00000000000000/** * 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.attribute; import nu.xom.Attribute; import nu.xom.Element; import nu.xom.Node; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting DictRefAttribute. supports dictRef attribute */ public class DictRefAttribute extends NamespaceRefAttribute { /** */ public final static String NAME = "dictRef"; /** * constructor. * */ public DictRefAttribute() { super(NAME); } // /** // * constructor. // * // * @param name // * @param value // */ // public DictRefAttribute(String name, String value) { // super(NAME, value); // } /** * constructor. * * @param att */ public DictRefAttribute(Attribute att) { super(att); } /** * gets dictRef attribute from element or its parent. elements which might * carry dictRef such as scalar may be contained within a parent such as * property. In this case the dictRef may be found on the parent. This * routine returns whichever is not null * * @param el * the element * @return the attribute */ public static DictRefAttribute getDictRefFromElementOrParent(CMLElement el) { DictRefAttribute dictRefAttribute = (DictRefAttribute) el.getAttribute(NAME); if (dictRefAttribute == null) { Node parent = el.getParent(); if (parent instanceof CMLElement) { CMLElement parentElement = (CMLElement) parent; dictRefAttribute = (DictRefAttribute) parentElement.getAttribute(NAME); } } return dictRefAttribute; } /** * gets local value of dictRef value on element * eg dictRef="a:b" returns b * @param element * @return null id no dictRef ; value if no prefix */ public static String getLocalValue(Element element) { Attribute att = element.getAttribute(NAME); String value = (att == null) ? null : att.getValue(); String[] values = (value == null) ? null : value.split(CMLConstants.S_COLON); return (values == null) ? null : values[values.length-1]; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/attribute/IdAttribute.java000077500000000000000000000041571477224461000266340ustar00rootroot00000000000000/** * 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.attribute; import org.xmlcml.cml.base.StringSTAttribute; import nu.xom.Attribute; /** * user-modifiable class supporting "id". */ public class IdAttribute extends StringSTAttribute { /** id */ public final static String NAME = "id"; String argName = "null"; int start = 0; int end = 0; /** * constructor. * */ public IdAttribute() { super(NAME); } /** constructor. * @param value */ public IdAttribute(String value) { super(NAME); this.setCMLValue(value); } /** * constructor from element with IdAttribute * * @param att * @exception RuntimeException */ public IdAttribute(Attribute att) throws RuntimeException { super(att); } /** copy constructor. * @return IdAttribute copy */ public Attribute copy() { return new IdAttribute(this); } /** set value and process. * * @param value * @exception RuntimeException bad value */ public void setCMLValue(String value) throws RuntimeException { if (value == null) { throw new RuntimeException("null IdAttribute value"); } else if (value.trim().equals(S_EMPTY)) { // seems to get called with empty string initially // this is a bug } else { super.setCMLValue(value); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/attribute/NamespaceRefAttribute.java000077500000000000000000000144201477224461000306230ustar00rootroot00000000000000/** * 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.attribute; import nu.xom.Attribute; import nu.xom.Element; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.StringSTAttribute; import org.xmlcml.cml.interfacex.HasUnits; /** * abstract class supporting attributes with namespaceRef values. */ public /*abstract*/ class NamespaceRefAttribute extends StringSTAttribute { /** regex for validating prefixes */ public final static String PREFIX_REGEX = "[A-Za-z][A-Za-z0-9\\.\\-\\_]*"; /** * constructor. * * @param name */ public NamespaceRefAttribute(String name) { super(name); init(name); } public NamespaceRefAttribute(String name, String value) { this(name); this.setCMLValue(value); } public NamespaceRefAttribute(Attribute att) { this(att.getLocalName()); this.setCMLValue(att.getValue()); } void init(String name) { // SpecialAttribute.updateCMLAttributeList(name, name, this); } /** * interlude to check for QName value. * * @param value */ public void setCMLValue(String value) { super.setCMLValue(value); if (this.getValue().equals(S_EMPTY)) { // empty string is created in new attribute } else if (this.getPrefix() == null) { throw new RuntimeException("attribute value [" + this.getValue() + "] for " + this.getLocalName() + " must be QName"); } } /** * get parent element. * * @return parent */ public Element getElement() { return (Element) this.getParent(); } /** * gets namespace prefix. * * @return null if attribute has no value or no prefix */ public String getPrefix() { return getPrefix(this.getValue()); } /** gets prefix from a valid namespaceRef string. * * @param value to examine * @return prefix (null if absent) */ public static String getPrefix(String value) { String prefix = null; if (value != null) { int idx = value.indexOf(S_COLON); if (idx != -1) { prefix = value.substring(0, idx); } } return prefix; } /** * get namespaceURI for this attribute; * * @return the namespace */ public String getNamespaceURIString() { Element element = this.getElement(); String prefix = this.getPrefix(); String namespaceURI = (prefix == null) ? null : element .getNamespaceURI(prefix); return namespaceURI; } /** * gets idRef. portion of value following the colon * * @return null if attribute has no value or no prefix */ public String getIdRef() { return getLocalName(this.getValue()); } /** * sets idRef. portion of value following the colon * */ public void setIdRef(String idRef) { String value = NamespaceRefAttribute.createValue(this.getPrefix(), idRef); this.setCMLValue(value); } static int count = 0; /** create valid prefixed value. * * @param prefix * @param value * @return prefixed value */ public static String createValue(String prefix, String value) { if (prefix == null) { throw new RuntimeException("null prefix"); } if (value == null) { throw new RuntimeException("null value"); } if (prefix.trim().equals("")) { throw new RuntimeException("cannot have empty prefix"); } if (value.trim().equals("")) { throw new RuntimeException("cannot have empty value"); } if (!prefix.matches(PREFIX_REGEX)) { throw new RuntimeException("Prefix [" + prefix + "] incompatible with " + PREFIX_REGEX); } return prefix + CMLConstants.S_COLON + value; } /** return the local name after the colon. * if prefix is missing return whole string * @param name to examine * @return localName */ public static String getLocalName(String name) { String localName = null; if (name != null) { int idx = name.indexOf(S_COLON); localName = name.substring(idx+1); } return localName; } /** set units on CML Element. * * @param hasUnits to set units on * @param prefix unit dictionary prefix * @param id unit id * @param namespaceURI unit dictionary namespace */ public static void setUnits(HasUnits hasUnits, String prefix, String id, String namespaceURI) { CMLElement element = (CMLElement) hasUnits; String currentNamespace = element.getNamespaceURIForPrefix(prefix); if (currentNamespace != null) { if (!currentNamespace.equals(namespaceURI)) { throw new RuntimeException("Cannot reset units namespace for "+prefix+" from " + ""+currentNamespace+" to "+namespaceURI); } } else { element.addNamespaceDeclaration(prefix, namespaceURI); } Attribute units = element.getAttribute("units"); if (units != null) { element.removeAttribute(units); } UnitsAttribute unitAttribute = new UnitsAttribute( NamespaceRefAttribute.createValue(prefix, id)); element.addAttribute(unitAttribute); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/attribute/RefAttribute.java000077500000000000000000000106221477224461000270060ustar00rootroot00000000000000/** * 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.attribute; import java.util.List; import nu.xom.Attribute; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.StringSTAttribute; /** * user-modifiable class supporting "ref", a pointer * to a CML object. default is to clone the object and then process it. * For that reason the referenced species should be pre-declared. */ public class RefAttribute extends StringSTAttribute { /** ref */ public final static String NAME = "ref"; /** * constructor. * */ public RefAttribute() { super(NAME); } /** constructor. * @param value */ public RefAttribute(String value) { super(NAME); this.setCMLValue(value); } /** * constructor. * * @param att * @exception RuntimeException */ public RefAttribute(Attribute att) throws RuntimeException { super(att); } /** set value and process. * * @param value * @exception RuntimeException bad value */ public void setCMLValue(String value) throws RuntimeException { if (value == null) { throw new RuntimeException("null ref attribute value"); } else if (value.trim().equals(S_EMPTY)) { // seems to get called with empty string initially // this is a bug } else { super.setCMLValue(value); } } /** processes ref attribute on element. * * @param element to process */ public static void process(CMLElement element) { RefAttribute ref = (RefAttribute) element.getAttribute(RefAttribute.NAME); if (ref != null) { RefAttribute.process(element, ref); } List childElems = element.getChildCMLElements(); for (CMLElement child : childElems) { RefAttribute.process(child); } } /** process element with a ref attribute. * if the reference can be resolved copies the object and * replaces 'this' with the copy. * @param element to process * @param ref attribute * @throws RuntimeException null element or bad reference */ public static void process(CMLElement element, RefAttribute ref) throws RuntimeException { if (element == null) { throw new RuntimeException("Cannot process null ref attribute"); } CMLElement oldest = element.getOldestCMLAncestor(); if (oldest == element) { throw new RuntimeException("Cannot reference elements from oldest ancestor"); } String id = ref.getValue(); List elemList = oldest.getElementsById(id, true); if (elemList.size() == 0) { throw new RuntimeException("Cannot find element: "+id); } if (elemList.size() > 1) { throw new RuntimeException("Too many elements ("+elemList.size()+") with id: "+id); } CMLElement elemRef = elemList.get(0); CMLElement newElem = (CMLElement) elemRef.copy(); // FIXME - use RefAttribute String idgen = element.getAttributeValue("idgen"); if (idgen != null) { newElem.addAttribute(new Attribute("id", idgen)); } else { } // substitute all args // transfer any args from referring element // CMLArg.transferArgs(element, newElem); // CMLArg.substituteNameByValue(newElem); // LOG.debug("%%%%%%%%%%%%%%%%%%%%"); // LOG.debug("%%%%%%%%%%%%%%%%%%%%"); CMLElement parent = (CMLElement) element.getParent(); int idx = parent.indexOf(element); parent.insertChild(newElem, idx); // element.detach(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/attribute/UnitTypeAttribute.java000077500000000000000000000023361477224461000300560ustar00rootroot00000000000000/** * 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.attribute; import nu.xom.Attribute; public class UnitTypeAttribute extends NamespaceRefAttribute{ /** */ public final static String NAME = "unitType"; /** * constructor. * */ public UnitTypeAttribute() { super(NAME); } /** * constructor. * * @param value * QName for units */ public UnitTypeAttribute(String value) { super(NAME, value); } /** * constructor. * * @param att */ public UnitTypeAttribute(Attribute att) { super(att); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/attribute/UnitsAttribute.java000077500000000000000000000025361477224461000274010ustar00rootroot00000000000000/** * 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.attribute; import nu.xom.Attribute; /** * user-modifiable class supporting UnitsAttribute. supports units attribute */ public class UnitsAttribute extends NamespaceRefAttribute { /** */ public final static String NAME = "units"; /** * constructor. * */ public UnitsAttribute() { super(NAME); } /** * constructor. * * @param value * QName for units */ public UnitsAttribute(String value) { super(NAME, value); } /** * constructor. * * @param att */ public UnitsAttribute(Attribute att) { super(att); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/attribute/main/000077500000000000000000000000001477224461000244635ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/attribute/main/CountExpressionAttribute.java000077500000000000000000000162451477224461000323750ustar00rootroot00000000000000/** * 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.attribute.main; import nu.xom.Attribute; import nu.xom.Element; import nu.xom.Node; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.StringSTAttribute; /** * user-modifiable class supporting "countExpression". */ public class CountExpressionAttribute extends StringSTAttribute { /** count expression */ public final static String NAME = "countExpression"; String argName = "null"; int start = 0; int end = 0; /** * constructor. * */ public CountExpressionAttribute() { super(NAME); } /** constructor. * @param value */ public CountExpressionAttribute(String value) { super(NAME); this.setCMLValue(value); } /** * constructor from element with CountExpressionAttribute * * @param att * @exception RuntimeException */ public CountExpressionAttribute(Attribute att) throws RuntimeException { super(att); } /** set value and process. * * @param value * @exception RuntimeException bad value */ public void setCMLValue(String value) throws RuntimeException { if (value == null) { throw new RuntimeException("null CountExpressionAttribute value"); } else if (value.trim().equals(S_EMPTY)) { // seems to get called with empty string initially // this is a bug } else { super.setCMLValue(value); } } /** clone element with a repeat attribute. * clones the element and appends to original element * @param element to process * @throws RuntimeException null element or bad attribute */ public static void generateAndInsertClones(CMLElement element) throws RuntimeException { if (element == null) { throw new RuntimeException("Cannot process null element"); } Element parent = (Element) element.getParent(); if (parent == null) { throw new RuntimeException("Cannot process CountExpressionAttribute without parent"); } CountExpressionAttribute cea = (CountExpressionAttribute) element.getAttribute(CountExpressionAttribute.NAME); int idx = parent.indexOf(element); int count = cea.calculateCountExpression(); for (int i = 1; i < count; i++) { Element newElement = (Element) element.copy(); parent.insertChild(newElement, idx+1); } } /** clone content of element with CountExpression and append. * clones the element content and appends to original element content * @param element to process * @throws RuntimeException null element or bad attribute */ public static void cloneContentAndAppend(CMLElement element) throws RuntimeException { if (element == null) { throw new RuntimeException("Cannot process null element"); } Element parent = (Element) element.getParent(); if (parent == null) { throw new RuntimeException("Cannot process CountExpressionAttribute without parent"); } CountExpressionAttribute cea = (CountExpressionAttribute) element.getAttribute(CountExpressionAttribute.NAME); int count = cea.calculateCountExpression(); int nChild = element.getChildCount(); for (int i = 1; i < count; i++) { for (int j = 0; j < nChild; j++) { Node newChild = element.getChild(j).copy(); element.appendChild(newChild); } } } /** expands countExpression into an integer. * if simple integer *(5) return that * if gaussian(n,m) computes a random value from the distrib (NYI) * if range(n,m) computes a random value in the range * if countExpression missing returns 1 * @return the count */ public int calculateCountExpression() { int count = 1; String countEx = this.getValue(); if (countEx != null) { // Element parent = (Element)this.getParent(); // if (parent != null) { // parent.removeAttribute(parent.getAttribute(CountExpressionAttribute.NAME)); // } if (countEx.startsWith("gaussian")) { countEx = countEx.substring("gaussian".length()); int[] counts = parseCount(countEx); if (counts.length != 2 || counts[0] <= 3 || counts[1] < 1 || counts[0] / counts[1] < 3) { throw new RuntimeException("Bad gaussian: "+countEx); } throw new RuntimeException("gaussian NYI"); } else if (countEx.startsWith("range")) { countEx = countEx.substring("range".length()); int[] counts = parseCount(countEx); if (counts.length != 2 || counts[0] <= 0 || counts[0] >= counts[1]) { throw new RuntimeException("Bad range: "+countEx); } double mid2 = (counts[1] + counts[0])/2.; double delta2 = (counts[1] - counts[0])/2.; double dd = mid2 + delta2 * (0.5 - Math.random()); count = (int) Math.round(dd); } else if (countEx.startsWith(S_STAR)) { countEx = countEx.substring(S_STAR.length()); int[] counts = parseCount(countEx); if (counts.length != 1) { throw new RuntimeException("Bad range: "+countEx); } count = counts[0]; } else { throw new RuntimeException("Bad count expression: "+countEx); } } return count; } private int[] parseCount(String countEx) { if (!countEx.startsWith(S_LBRAK) || !countEx.endsWith(S_RBRAK)) { throw new RuntimeException("Bad range: requires (...): "+countEx); } countEx = countEx.substring(1, countEx.length()-1).trim(); String[] countStrings = countEx.split(S_COMMA); int[] counts = new int[countStrings.length]; for (int i = 0; i < countStrings.length; i++) { try { counts[i] = Integer.parseInt(countStrings[i]); } catch (NumberFormatException e) { throw new RuntimeException("Bad integer in countExpression :"+countStrings[i]); } } return counts; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/000077500000000000000000000000001477224461000224465ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/AbstractGenerator.java000077500000000000000000000041411477224461000267260ustar00rootroot00000000000000/** * 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.File; import java.util.List; import nu.xom.Builder; import nu.xom.Document; import nu.xom.Element; /** * @author pm286 * */ public abstract class AbstractGenerator implements CMLConstants { protected List nameList; protected SchemaManager schemaManager; protected Element schema; /** read and assemble. * * @param dir * @return root element * @throws Exception */ public Element readAndAssembleSchemaComponents(String dir) throws Exception { schema = null; if (dir == null) { throw new RuntimeException("null schema directory"); } schema = new Element("schema", XSD_NS); File file = new File(dir); if (!file.isDirectory()) { throw new RuntimeException("missing or bad schema directory: "+dir); } File[] files = file.listFiles(); for (File f : files) { if (!f.toString().endsWith(XSD_SUFF)) { continue; } Document doc = new Builder().build(f); Element elem = doc.getRootElement(); doc.replaceChild(elem, new Element("s_dummy")); schema.appendChild(elem); } // LOG.debug("CHILD "+schema.getChildCount()); return schema; } /** * @return the schema */ public Element getSchema() { return schema; } /** * @param schema the schema to set */ public void setSchema(Element schema) { this.schema = schema; } public String getValue() { return null; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/AbstractTool.java000077500000000000000000000014741477224461000257230ustar00rootroot00000000000000/** * 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; /** * a hook for the Tool machinery * * @author pmr * */ public abstract class AbstractTool implements CMLConstants { }cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/AttributeFactory.java000077500000000000000000000222471477224461000266160ustar00rootroot00000000000000/** * 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.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 AttributeFactory implements CMLConstants { final static Logger LOG = Logger.getLogger(AttributeFactory.class); // singleton /** singleton attribute factory */ public final static AttributeFactory attributeFactory = new AttributeFactory(); static { attributeFactory.init(); } private Map attributeGroupElementMap; private Map attributeGroupNameAttributeMap; private Map> elementSynonymMap; private SchemaManager schemaManager; /** constructor. */ private AttributeFactory() { } void init() { // attributeGroupNameAttributeMap = new HashMap(); elementSynonymMap = new HashMap>(); schemaManager = new SchemaManager(); schemaManager.readAndCreateIndexesFromSchemaFiles(); AttributeFactory.attributeFactory.setSchemaManager(schemaManager); makeSynonymMap(); } /** custom attributeFactory. * * @param className * @return attribute factory * @throws Exception */ public static AttributeFactory createAttributeFactory(String className) throws Exception { return (AttributeFactory) Class.forName(className).newInstance(); } /** lookup CMLAttributes by name. * * @param name to lookup * @return CMLAttribute */ public CMLAttribute getAttribute(String name) { return (CMLAttribute) attributeGroupNameAttributeMap.get(name); } private void makeSynonymMap() { attributeGroupElementMap = new HashMap(); try { // create special attributes Map attributeGroupMap = schemaManager.getAttributeGenerator().getAttributeGroupMap(); for (String attributeGroupName : attributeGroupMap.keySet()) { CMLAttribute specialAttribute = createSpecialAttribute(attributeGroupName); // replace by special attribute if (specialAttribute != null) { attributeGroupMap.put(attributeGroupName, specialAttribute); } } Element attributeTop = CMLUtil.getXMLResource(SchemaManager.ATTRIBUTEGROUPS_XSD).getRootElement(); List attributeGroups = CMLUtil.getQueryNodes(attributeTop, "./"+XSD_ATTRIBUTE_GROUP, XPATH_XSD); // this is a mess - there is some duplication attributeGroupNameAttributeMap = new HashMap(); for (Node node : attributeGroups) { Element xsdAttribute = (Element) node; String attributeGroupName = xsdAttribute.getAttributeValue("name"); attributeGroupElementMap.put(attributeGroupName, xsdAttribute); CMLAttribute att = schemaManager.getAttributeGenerator().createAttribute(attributeGroupName); attributeGroupNameAttributeMap.put(attributeGroupName, att); } Element elementTop = CMLUtil.getXMLResource(SchemaManager.ELEMENTS_XSD).getRootElement(); List elements = CMLUtil.getQueryNodes(elementTop, "./"+XSD_ELEMENT, XPATH_XSD); for (Node node : elements) { Element xsdElement = (Element) node; String elementName = xsdElement.getAttributeValue("name"); Map synonymMap = new HashMap(); elementSynonymMap.put(elementName, synonymMap); List attributeGroupsx = CMLUtil.getQueryNodes(xsdElement, ".//"+XSD_ATTRIBUTE_GROUP, XPATH_XSD); for (Node nodex : attributeGroupsx) { String ref = ((Element)nodex).getAttributeValue("ref"); Element attributeGroupx = attributeGroupElementMap.get(ref); List attNodes = CMLUtil.getQueryNodes(attributeGroupx, "./"+XSD_ATTRIBUTE, XPATH_XSD); String attributeName = ((Element)attNodes.get(0)).getAttributeValue("name"); synonymMap.put(attributeName, ref); } } } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("Cannot parse elements/attributes: "+e); } } /** create attributes if class exists. * * @param name of attribute * @return subclassed attribute */ public static CMLAttribute createSpecialAttribute(String name) { CMLAttribute attribute = null; try { String attClassName = ATTRIBUTE_CLASS_BASE+S_PERIOD+ CMLUtil.capitalize(name)+ATTRIBUTE; Class attClass = Class.forName(attClassName); if (attClass != null) { attribute = (CMLAttribute) attClass.newInstance(); } } catch (Exception e) { // carry on... } return attribute; } String getAttributeGroupName(String attributeName, String elementName) { String attributeGroupName= null; Map attNameToAttGroupNameMap = elementSynonymMap.get(elementName); if (attNameToAttGroupNameMap != null) { attributeGroupName = attNameToAttGroupNameMap.get(attributeName); } else { System.err.println("Cannot find synonym for: "+elementName); } return attributeGroupName; } /** * * @param attributeName * @param elementName * @return attribute */ public CMLAttribute getAttribute(String attributeName, String elementName) { String attributeGroupName = this.getAttributeGroupName(attributeName, elementName); if (attributeGroupName == null) { throw new RuntimeException("Cannot find attribute group for "+elementName+"@"+attributeName); } return attributeGroupNameAttributeMap.get(attributeGroupName); } /** new... * @param attributeGroupName * @return attribute */ public CMLAttribute getAttributeByGroupName(String attributeGroupName) { Map attributeGroupMap = schemaManager.getAttributeGenerator().getAttributeGroupMap(); CMLAttribute attribute = attributeGroupMap.get(attributeGroupName); if (attribute == null) { throw new RuntimeException("Cannot find attributeGroup: "+attributeGroupName); } return attribute; } /** create subclassed attribute template with dummy value. * @param attributeName * @param element * @return subclassed attribute */ public CMLAttribute createCMLAttribute(String attributeName, CMLElement element) { if (attributeName.equals(CMLXSD_XMLCONTENT)) { throw new RuntimeException("Cannot process "+CMLXSD_XMLCONTENT); } return AttributeFactory.attributeFactory.getAttribute(attributeName, element.getLocalName()); } /** create subclassed attribute template with dummay value. * * @param name * @param type * @return attribute */ public static CMLAttribute createCMLAttribute(String name, CMLType type) { CMLAttribute newAtt = createSpecialAttribute(name); String typeS = type.getJavaType(); if (newAtt != null) { } else if (XSD_BOOLEAN.equals(typeS) && !type.getIsList()) { newAtt = new BooleanSTAttribute(name); } else if (XSD_BOOLEAN.equals(typeS) && type.getIsList()) { newAtt = new BooleanArraySTAttribute(name); } else if (XSD_DOUBLE.equals(typeS) && !type.getIsList()) { newAtt = new DoubleSTAttribute(name); } else if (XSD_DOUBLE.equals(typeS) && type.getIsList()) { newAtt = new DoubleArraySTAttribute(name); } else if (XSD_INTEGER.equals(typeS) && !type.getIsList()) { newAtt = new IntSTAttribute(name); } else if (XSD_INTEGER.equals(typeS) && type.getIsList()) { newAtt = new IntArraySTAttribute(name); } else if (XSD_STRING.equals(typeS) && !type.getIsList()) { newAtt = new StringSTAttribute(name); } else if (XSD_STRING.equals(typeS) && type.getIsList()) { newAtt = new StringArraySTAttribute(name); } else { LOG.error("unknown attribute type " + type); } return newAtt; } /** get schemaManager. * * @return {@link SchemaManager} */ public SchemaManager getSchemaManager() { return schemaManager; } /** set schema manager. * * @param schemaManager */ public void setSchemaManager(SchemaManager schemaManager) { this.schemaManager = schemaManager; } public String getValue() { return null; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/AttributeGenerator.java000077500000000000000000000117531477224461000271350ustar00rootroot00000000000000/** * 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 AttributeGenerator extends AbstractGenerator { private Map attributeGroupMap; /** * @param schemaManager * */ public AttributeGenerator(SchemaManager schemaManager) { this.schemaManager = schemaManager; init(); } private void init() { attributeGroupMap = new HashMap(); nameList = new ArrayList(); } /** read and assemble. * * @param indir input directory * @throws Exception */ public void readAssembleAndIndexSchema(String indir) throws Exception { schema = this.readAndAssembleSchemaComponents(indir); this.indexSchema(); } /** index the schema. */ public void indexSchema() { List attributeGroups = CMLUtil.getQueryNodes(schema, "./"+XSD_ATTRIBUTE_GROUP, XPATH_XSD); for (Node node : attributeGroups) { Element attributeGroupElement = (Element) node; String attributeGroupName = attributeGroupElement.getAttributeValue("name"); if (attributeGroupName == null) { System.err.println("No name attribute on attribute"); } else { CMLAttribute attribute = createAttribute(attributeGroupName); attributeGroupMap.put(attributeGroupName, attribute); nameList.add(attributeGroupName); } } } /** create attribute given group name. * * @param attributeGroupName * @return attribute */ public CMLAttribute createAttribute(String attributeGroupName) { // // // ... // // CMLAttribute attribute = null; // find attributeGroup Element List attributeGroups = CMLUtil.getQueryNodes(schema, "./"+XSD_ATTRIBUTE_GROUP+"[@name='"+attributeGroupName+"']", XPATH_XSD); if (attributeGroups.size() != 1) { throw new RuntimeException("Cannot find unique attributeGroup: "+attributeGroupName); } Element attributeGroup = (Element) attributeGroups.get(0); // get child Attribute Element List attributes = CMLUtil.getQueryNodes(attributeGroup, "./"+XSD_ATTRIBUTE, XPATH_XSD); if (attributes.size() != 1) { throw new RuntimeException("Cannot find unique attribute: "+attributeGroupName); } Element attributeElement = (Element) attributes.get(0); String attributeName = attributeElement.getAttributeValue("name"); if (!attributeName.equals(attributeGroupName)) { // Util.sysout("NOTE: attributeGroup name != attribute ("+attributeGroupName+ // " != "+attributeName+")"); } String typeS = attributeElement.getAttributeValue("type"); if (typeS == null) { throw new RuntimeException("No type given for attribute "+attributeGroupName); } Map typeMap = schemaManager.getTypeGenerator().getMap(); CMLType type = typeMap.get(typeS); if (type == null) { for (String sss : typeMap.keySet()) { Util.println(sss); } throw new RuntimeException("Cannot find CMLType for "+typeS); } attribute = AttributeFactory.createCMLAttribute(attributeName, type); List summarys = CMLUtil.getQueryNodes(attributeElement, ".//*[@class='summary']"); String summary = (summarys.size() == 0) ? "No summary" : summarys.get(0).getValue(); attribute.setSummary(summary); List descriptions = CMLUtil.getQueryNodes(attributeElement, ".//*[@class='description']"); String description = (descriptions.size() == 0) ? "No description" : descriptions.get(0).getValue(); attribute.setDescription(description); return attribute; } void printAttributes() { for (String name : nameList) { Util.println(name); } } /** * @return the attributeGroupMap */ public Map getAttributeGroupMap() { return attributeGroupMap; } /** * @param attributeGroupMap the attributeGroupMap to set */ public void setAttributeGroupMap(Map attributeGroupMap) { this.attributeGroupMap = attributeGroupMap; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/BooleanArraySTAttribute.java000077500000000000000000000117671477224461000300410ustar00rootroot00000000000000/** * 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; import org.xmlcml.euclid.Util; /** * attribute representing a boolean value.. */ public class BooleanArraySTAttribute extends CMLAttribute { /** */ public final static String JAVA_TYPE = JAVA_BOOL+JAVA_ARRAY; /** */ public final static String JAVA_GET_METHOD = "getBooleanArray"; /** */ public final static String JAVA_SHORT_CLASS = "BooleanArraySTAttribute"; protected boolean[] bb = null; protected int length = -1; /** * constructor. * * @param name */ public BooleanArraySTAttribute(String name) { super(name); } /** * from DOM. * * @param att */ public BooleanArraySTAttribute(Attribute att) { this(att.getLocalName()); this.setCMLValue(att.getValue()); } /** * copy constructor * * @param att */ public BooleanArraySTAttribute(BooleanArraySTAttribute att) { super(att); if (att.bb != null) { this.bb = new boolean[att.bb.length]; for (int i = 0; i < bb.length; i++) { this.bb[i] = att.bb[i]; } } this.length = att.length; } /** * from DOM. * * @param att * to copy, except value * @param value */ public BooleanArraySTAttribute(Attribute att, String value) { super(att, value.trim().replace(S_WHITEREGEX, CMLConstants.S_SPACE)); } /** * sets and checks value. * * @param bb */ public void setCMLValue(boolean[] bb) { checkValue(bb); this.bb = new boolean[bb.length]; for (int i = 0; i < bb.length; i++) { this.bb[i] = bb[i]; } this.setValue(Util.concatenate(bb, 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 bb * the boolean array * @throws RuntimeException * wrong type or value fails */ public void checkValue(boolean[] bb) { if (cmlType != null) { cmlType.checkValue(bb); } } /** * splits string into booleans. * * @param s the string * @param delim delimiter * @return array * @throws RuntimeException * cannot parse as ints */ public static boolean[] 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); boolean[] bb = new boolean[ss.length]; for (int i = 0; i < ss.length; i++) { try { bb[i] = Boolean.parseBoolean(ss[i]); } catch (NumberFormatException nfe) { throw new RuntimeException("" + nfe); } } return bb; } /** * sets value. throws exception if of wrong type or violates restriction * * @param s * the value // * * @throws RuntimeException */ public void setCMLValue(String s) { boolean[] bb = split(s.trim(), CMLConstants.S_WHITEREGEX); this.setCMLValue(bb); } /** * get array. * * @return null if not set */ public Object getCMLValue() { return bb; } /** * get array. * * @return null if not set */ public boolean[] getIntegerArray() { return bb; } /** * 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/BooleanSTAttribute.java000077500000000000000000000100101477224461000270160ustar00rootroot00000000000000/** * 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 boolean value. */ public class BooleanSTAttribute extends CMLAttribute { /** */ public final static String JAVA_TYPE = JAVA_BOOL; /** */ public final static String JAVA_GET_METHOD = "getBoolean"; /** */ public final static String JAVA_SHORT_CLASS = "BooleanSTAttribute"; protected Boolean b; /** * constructor. * * @param name */ public BooleanSTAttribute(String name) { super(name); } /** * from DOM. * * @param att */ public BooleanSTAttribute(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 BooleanSTAttribute(BooleanSTAttribute att) { super(att); if (att.b != null) { this.b = Boolean.valueOf(att.b.booleanValue()); } } /** * from DOM. * * @param att * to copy, except value * @param value */ public BooleanSTAttribute(Attribute att, String value) { super(att, value.trim().replace(S_WHITEREGEX, S_SPACE)); } /** * sets value. throws exception if of wrong type or violates restriction * * @param s * the value * @throws RuntimeException */ public void setCMLValue(String s) { boolean i; try { i = Boolean.parseBoolean(s.trim()); } catch (NumberFormatException nfe) { throw new RuntimeException(S_EMPTY + nfe); } this.setCMLValue(i); } /** * set and check value. * * @param i */ public void setCMLValue(boolean i) { checkValue(i); this.b = Boolean.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 b * the value * @throws RuntimeException * wrong type or value fails */ public void checkValue(boolean b) { if (cmlType != null) { cmlType.checkValue(b); } } /** * returns value as Booleaneger. * * @return value */ public Object getCMLValue() { return b; } /** * returns value as boolean. * * @return value */ public boolean getBoolean() { if (b == null) { throw new RuntimeException("booleaneger attribute unset"); } return b.booleanValue(); } /** * 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/CC.java000077500000000000000000000014321477224461000236010ustar00rootroot00000000000000/** * 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; /** alias for brevity. * * @author pm286 * */ public interface CC extends CMLConstants { } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/CMLAttribute.java000077500000000000000000000212201477224461000256100ustar00rootroot00000000000000/** * 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; import nu.xom.NamespaceConflictException; import org.apache.log4j.Logger; /** * generic subclassed Attribute for CML elements. often further subclassed into * strongly typed attributes * * in CMLSchema an attributeGroup normally wraps the attribute. Normally * the names are the same, but sometimes the attribute group has a different * name from the attribute. In some cases two different attributes can have the same * name but different attribute groups. The attributeGroup name is only used for * collecting the attributes * @author Peter Murray-Rust * @version 5.0 * */ public class CMLAttribute extends Attribute implements CMLConstants { final static Logger logger = Logger.getLogger(CMLAttribute.class); public static final String CONSTANT_TO_SI = "constantToSI"; public final static String CONVENTION = "convention"; public static final String DICTREF = "dictRef"; public static final String ID = "id"; public static final String MULTIPLIER_TO_SI = "multiplierToSI"; public static final String TITLE = "title"; public static final String UNITS = "units"; protected CMLType cmlType; protected String summary; protected String description; protected String attributeGroupName; // used in code generation /** * creates attribute without value. do not use directly * * @param name */ public CMLAttribute(String name) { super(name, ""); } /** * creates attribute. * * @param name * @param value */ public CMLAttribute(String name, String value) { super(name, value); } /** * creates attribute. * * @param name * must be qualified (colonized) * @param URI * namespace * @param value * @throws NamespaceConflictException * probably no prefix in name */ protected CMLAttribute(String name, String URI, String value) throws nu.xom.NamespaceConflictException { super(name, URI, value); } /** * copy constructor * * @param att */ public CMLAttribute(CMLAttribute att) { super(att); this.cmlType = att.cmlType; // if (att.getLocalName().equals("dictRef")) { // new Exception().printStackTrace(); // } } /** * semi copy constructor * * @param att */ public CMLAttribute(Attribute att) { super(att); } /** * copy constructor from empty attribute. * used to create subclasses * @param att to copy * @param value to add (may throw CMLRuntime) */ protected CMLAttribute(Attribute att, String value) { this(att.getLocalName()); this.setCMLValue(value); } /** * makes copy of correct class. * shallow copy as most fields are not mutable * @return copy of node */ public Attribute copy() { CMLAttribute newAttribute = new CMLAttribute(this); newAttribute.setValue(this.getValue()); return newAttribute; } /** * sets attributeGroup name. normally only useful when generating code when * the attributeGroup name may be different from the attribute name. it is * required for lookup * * @param agn attributeGroup name */ public void setAttributeGroupName(String agn) { attributeGroupName = agn; } /** * gets attributeGroup name. normally only useful when generating code when * the attributeGroup name may be different from the attribute name. it is * required for lookup * * @return attributeGroup name */ public String getAttributeGroupName() { return attributeGroupName; } /** * compares attributes. As we cannot override Node.equals() which compares * identity we have to compare components. order of sorting is: attribute * class cmlType name name value * * null values of any component return -1 * * @param att * to compare * @return 0 if all content is identical, -1 if this less than att, 1 if * greater value * */ public int compareTo(Attribute att) { if (att == null) { return -1; } // same attribute? if (this == att) { return 0; } int order = 0; if (!(att instanceof CMLAttribute)) { order = -1; } CMLAttribute cmlAtt = (CMLAttribute) att; // schemas must either bosth be null or equal if (order == -1) { } else if (cmlType == null && cmlAtt.cmlType == null) { } else if (cmlType != null && cmlAtt.cmlType != null) { order = this.cmlType.compareTo(cmlAtt.cmlType); } else { order = -1; } if (order == 0) { order = this.getClass().getName().compareTo( att.getClass().getName()); } if (order == 0) { order = this.getLocalName().compareTo(cmlAtt.getLocalName()); } if (order == 0) { order = this.getValue().compareTo(cmlAtt.getValue()); } return (order == 0) ? 0 : order / Math.abs(order); } /** * get JavaType default * * @return "String" */ public String getJavaType() { return "String"; } /** * get Java set method default * * @return "setCMLValue" */ public String getJavaSetMethod() { return "setCMLValue"; } /** * get Java get method. * * @return "getCMLValue" */ public String getJavaGetMethod() { return "getCMLValue"; } /** * get Java ShortClassName. * * @return "CMLAttribute" */ public String getJavaShortClassName() { return this.getClass().getSimpleName(); } /** * get schema type. * * @return "CMLAttribute" */ public CMLType getSchemaType() { return cmlType; } /** * set schema type. * * @param schemaType could be null */ public void setSchemaType(CMLType schemaType) { this.cmlType = schemaType; } /** * returns value as a typed object. if object is a primitive, return in * wrapper (e.g. Integer) object might be an array of primitives (e.g. * int[]) types are: String, String[], Integer, int[], Double, double[] * * @return the value */ public Object getCMLValue() { return getValue(); } /** * sets value. often subclassed which will throw exception if of wrong type * * @param s * the value */ public void setCMLValue(String s) { this.setValue(s); } /** * get documentation summary. * * @return the summary */ public String getSummary() { return summary; } /** * set documentation summary. * * @param s * the summary */ public void setSummary(String s) { if (s != null) { summary = s; if (!summary.endsWith(S_PERIOD)) { summary += CMLConstants.S_PERIOD; } } } /** * get Documentation. * * @return the description */ public String getDescription() { return description; } /** * set Documentation. * * @param d * the description */ public void setDescription(String d) { description = d; } /** * @return the cmlType */ public CMLType getCmlType() { return cmlType; } /** * @param cmlType the cmlType to set */ public void setCmlType(CMLType cmlType) { this.cmlType = cmlType; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/CMLBuilder.java000077500000000000000000000136551477224461000252500ustar00rootroot00000000000000/** * 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.InputStream; import java.io.Reader; import java.io.StringReader; import nu.xom.Builder; import nu.xom.Document; import nu.xom.Element; import nu.xom.NodeFactory; import nu.xom.ParsingException; /** * *

* Class extending the XOM builder, constructs a XOM builder using either the * CML node factory as default or a passed node factory. *

* * @author Peter Murray-Rust * @version 5.0 * */ public class CMLBuilder extends Builder implements CMLConstants { /** * Constructs a XOM builder using the (subclassed) CML node factory */ public CMLBuilder() { this(CMLNodeFactory.nodeFactory); } /** * Constructs a XOM builder using the (subclassed) CML node factory * * @param validate * if true */ public CMLBuilder(boolean validate) { this(validate, CMLNodeFactory.nodeFactory); } /** * Constructs a XOM builder using the passed node factory * * @param nodeFactory * to construct builder with */ public CMLBuilder(NodeFactory nodeFactory) { super(nodeFactory); } /** * Constructs a XOM builder using the passed node factory * * @param validate * if true * @param nodeFactory * to construct builder with */ public CMLBuilder(boolean validate, NodeFactory nodeFactory) { super(validate, nodeFactory); } /** * convenience method to parse XML string. * * @param xmlString to parse * @return the root element or null */ public Element parseString(String xmlString) { Document doc = null; try { doc = this.build(new StringReader(xmlString)); } catch (IOException e) { throw new RuntimeException("BUG ", e); } catch (Exception e) { throw new RuntimeException("cannot parse: ", e); } return (doc == null) ? null : doc.getRootElement(); } /** make sure a document has CMLNamespace if possible. * if document has CML namespace, returns it. * if document does not, converts to String and reparses it. * horrid hack, but that's because some people don't use namespaces. * @param doc * @return document */ public static Document ensureCML(Document doc) { Element root = doc.getRootElement(); String nameURI = root.getNamespaceURI(); if (!CMLConstants.CML_NS.equals(nameURI)) { try { System.err.println("No CML namespace; munging one in"); ByteArrayOutputStream ss = new ByteArrayOutputStream(); CMLUtil.debug(root, ss, 0); ss.close(); String s = ss.toString(); // find first line after any declaration int idx = s.indexOf(">\n"); if (s.startsWith("\n", idx); } // add namespace String sss = s.substring(0, idx) + S_SPACE+CMLConstants.CML_XMLNS +s.substring(idx); Element newRoot = new CMLBuilder().parseString(sss); doc = newRoot.getDocument(); } catch (Exception e) { throw new RuntimeException("BUG "+e); } } return doc; } /** * messy hack to parse document which omit CML namespace * @param is * @return doc * @throws IOException * @throws ParsingException */ public Document buildEnsureCML(InputStream is) throws IOException, ParsingException { Document doc = super.build(is); return ensureCML(doc); } /** * messy hack to parse document which omits CML namespace * @param reader * @return doc * @throws IOException * @throws ParsingException */ public Document buildEnsureCML(Reader reader) throws IOException, ParsingException { Document doc = super.build(reader); return ensureCML(doc); } // this would trap the problem silently. Is it a good idea? // public Document build(Reader reader) throws ParsingException, IOException{ // Document doc = super.build(reader); // return ensureCML(doc); // } /** * Utility method that allows for convenient conversion of * XOM elements to * CML elements if necessary. * always makes a copy * * @param xml a valid CMLElement * @return the {@link CMLElement} */ public static CMLElement ensureCML(Element xml) { if (xml == null) { throw new RuntimeException("null cml"); } if (xml instanceof CMLElement) { return (CMLElement) xml.copy(); } else { Document doc = new Document((Element) xml.copy()); try { Document doc2 = new CMLBuilder().build(doc.toXML(), doc.getBaseURI()); CMLElement cmlElement = (CMLElement) doc2.getRootElement(); return cmlElement; } catch (Exception e) { CMLUtil.debug(xml, "ensureCMLProblem "+e); throw new RuntimeException("ensureCMLProblem", e); } } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/CMLConstants.java000077500000000000000000000356251477224461000256370ustar00rootroot00000000000000/** * 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.XPathContext; import org.xmlcml.euclid.EC; import org.xmlcml.euclid.EuclidConstants; /** * *

* Constants *

* * @author Peter Murray-Rust * @version 5.0 * */ public interface CMLConstants extends EuclidConstants { public enum Role { GROUP ; private Role() { ; } } /** list of identifiers. * not exhaustive - string values can be used) * @author pm286 * */ public enum Convention { /** CML */ ATOMARRAY("atomArray"), /** authorities */ /** not sure*/ MET3D("3DMET"), /** Anatomical Therapeutic Chemical Classification System for drugs */ ATC("ATC"), /** */ BEILSTEIN("Beilstein"), /** Chemical Abstracts*/ CAS("CAS"), /** Pubchem compound Id*/ CID("CID"), /** Harvard */ DRUGBANK("DrugBank"), /** EBI chemistry*/ CHEBI("ChEBI"), /** European chemicals*/ EINECS("EINECS"), /** */ GMELIN("Gmelin"), /** */ INCHI("InChI"), /** Int Union of Pure and Applied Chemistry */ IUPAC("IUPAC"), /** Japan database*/ KEGG("KEGG"), /** PubMed terminology*/ MESH("MeSH"), /** PubChem*/ PUBCHEM("PubChem"), /** Chemical labelling*/ RTECS("RTECS"), /** SMILES line notation*/ SMILES("SMILES"), /** other */ EXTERNAL("external"), ; /** */ public final String v; private Convention(String s) { v = s; } /** * equality to value * @param s * @return tru if match */ public boolean equals(String s) { return v == s; } } /** common units in chemistry */ public enum Units { /** mass*/ GRAM ("units:g"), /** density*/ GRAM_PER_CMCUBED("units:g.cm-3"), /** molarMass*/ GRAM_PER_MOLE("units:g.mol-1"), /** volume */ CMCUBED ("units:cm3"), /** volume */ ML ("units:ml"), /** volume */ L ("units:l"), /** amount */ MOL ("units:mol"), /** amount */ MMOL ("units:mmol"), ; /** dewisott */ public final String value; private Units(String s) { value = s; } /** * @return string */ public String toString() { return value; } }; /** suffix for files */ String XML_SUFF = ".xml"; /** suffix for files */ String XSD_SUFF = ".xsd"; /** xmlns attribute name */ String XMLNS = "xmlns"; /** * XSD namespace. no trailing slash */ String XSD_NS = "http://www.w3.org/2001/XMLSchema"; /** XSD prefix = 'xsd' */ String XSD_PREFIX = "xsd"; /** * namespace declaration for XSD * xmlns:xsd='http://www.w3.org/2001/XMLSchema' */ String XSD_XMLNS = XMLNS + S_COLON + XSD_PREFIX + S_EQUALS + S_APOS + XSD_NS + S_APOS; /** constant */ String XSD_ANYURI = "xsd:anyURI"; /** constant */ String XSD_BOOLEAN = "xsd:boolean"; /** constant */ String XSD_DATE = "xsd:date"; /** constant */ String XSD_DOUBLE = "xsd:double"; /** constant */ String XSD_FLOAT = "xsd:float"; /** constant */ String XSD_INTEGER = "xsd:integer"; /** constant */ String XSD_MAXEXCLUSIVE = "xsd:maxExclusive"; /** constant */ String XSD_MAXINCLUSIVE = "xsd:maxInclusive"; /** constant */ String XSD_MINEXCLUSIVE = "xsd:minExclusive"; /** constant */ String XSD_MININCLUSIVE = "xsd:minInclusive"; /** constant */ String XSD_NONNEGATIVEINTEGER = "xsd:nonNegativeInteger"; /** constant */ String XSD_POSITIVEINTEGER = "xsd:positiveInteger"; /** constant */ String XSD_POSITIVE_NUMBER = "xsd:positiveNumber"; /** constant */ String XSD_STRING = "xsd:string"; /** constant */ String XSD_QNAME = "xsd:QName"; /** element types */ /** */ String XSD_ANNOTATION = "xsd:annotation"; /** */ String XSD_ATTRIBUTE = "xsd:attribute"; /** */ String XSD_ATTRIBUTE_GROUP = "xsd:attributeGroup"; /** */ String XSD_COMPLEX_TYPE = "xsd:complexType"; /** */ String XSD_DOCUMENTATION = "xsd:documentation"; /** */ String XSD_ELEMENT = "xsd:element"; /** */ String XSD_ENUMERATION = "xsd:enumeration"; /** */ String XSD_EXTENSION = "xsd:extension"; /** */ String XSD_LENGTH = "xsd:length"; /** */ String XSD_LIST = "xsd:list"; /** */ String XSD_PATTERN = "xsd:pattern"; /** */ String XSD_RESTRICTION = "xsd:restriction"; /** */ String XSD_SIMPLE_TYPE = "xsd:simpleType"; /** */ String XSD_SIMPLE_CONTENT = "xsd:simpleContent"; /** */ String XSD_UNION = "xsd:union"; /** dewisott */ String FPX_REAL = "fpx:real"; /** */ String PATTERN_ANYURI = "http://.*"; //crude! /** */ String PATTERN_QNAME = "[A-Za-z_][A-Za-z0-9_-\\.]*:[A-Za-z_][A-Za-z0-9_-\\.]*"; /** */ XPathContext XPATH_XSD = new XPathContext("xsd", XSD_NS); /** constant */ String CMLXSD_ANNOTATION = "annotation"; /** constant */ String CMLXSD_ANY = "any"; /** constant */ String CMLXSD_APPINFO = "appinfo"; /** constant */ String CMLXSD_ATTRIBUTE = "attribute"; /** constant */ String CMLXSD_ATTRIBUTEGROUP = "attributeGroup"; /** constant */ String CMLXSD_BASE = "base"; /** constant */ String CMLXSD_CHOICE = "choice"; /** constant */ String CMLXSD_COMPLEXTYPE = "complexType"; /** constant */ String CMLXSD_DOCUMENTATION = "documentation"; /** constant */ String CMLXSD_ELEMENT = "element"; /** constant */ String CMLXSD_ENUMERATION = "enumeration"; /** constant */ String CMLXSD_EXTENSION = "extension"; /** constant */ String CMLXSD_ID = "id"; /** constant */ String CMLXSD_ITEMTYPE = "itemType"; /** constant */ String CMLXSD_LENGTH = "length"; /** constant */ String CMLXSD_LIST = "list"; /** constant */ String CMLXSD_MAXEXCLUSIVE = "maxExclusive"; /** constant */ String CMLXSD_MAXINCLUSIVE = "maxInclusive"; /** constant */ String CMLXSD_MINEXCLUSIVE = "minExclusive"; /** constant */ String CMLXSD_MININCLUSIVE = "minInclusive"; /** constant */ String CMLXSD_NAME = "name"; /** constant */ String CMLXSD_PATTERN = "pattern"; /** constant */ String CMLXSD_REF = "ref"; /** constant */ String CMLXSD_RESTRICTION = "restriction"; /** constant */ String CMLXSD_ROOT = "root"; /** constant */ String CMLXSD_SEQUENCE = "sequence"; /** constant */ String CMLXSD_SIMPLECONTENT = "simpleType"; /** constant */ String CMLXSD_SIMPLETYPE = "simpleType"; /** constant */ String CMLXSD_TEXT = "text"; /** constant */ String CMLXSD_TYPE = "type"; /** constant */ String CMLXSD_UNBOUNDED = "unbounded"; /** constant */ String CMLXSD_UNION = "union"; /** constant */ String CMLXSD_VALUE = "value"; /** constant */ String CMLXSD_ATTPREFIX = "_att_"; /** constant */ String CMLXSD_XMLCONTENT = "_xmlContent"; /** root of all CML URIs */ String CML_NS_BASE = "http://www.xml-cml.org"; /** constant */ String CML_NS = CML_NS_BASE+EC.U_S+"schema"; /** CMLX prefix (cmlx) for experimentation and development */ String CMLX_PREFIX = "cmlx"; /** cmlx namespace */ String CMLX_NS = CML_NS_BASE+EC.U_S+"schema"+S_SLASH+CMLX_PREFIX; /** * namespace declaration for CMLx with prefix */ String CMLX_XMLNS_PREFIX = XMLNS + S_COLON + CMLX_PREFIX + S_EQUALS + S_APOS + CMLX_NS + S_APOS; /** constant */ // String CML = CML_NS; /** * cml dictionary namespace reserved */ String DICT_NS = CML_NS_BASE+EC.U_S+"dict"; /** * cml URI namespace reserved */ String CML_REPOSITORY_BASE = CML_NS_BASE+EC.U_S+"repository"; /** * cml dictionary reserved */ String CML_DICT_NS = DICT_NS+EC.U_S+"cml"; /** constant */ String CML1 = CML_NS + S_SLASH + "cml1"; /** constant */ String CML2 = CML_NS + S_SLASH + "cml2"; /** constant */ String CML3 = CML_NS + S_SLASH + "cml3"; /** CML prefix (cml) reserved: for several uses */ String CML_PREFIX = "cml"; /** CML prefix + colon (cml:) */ String CML_COLON = CML_PREFIX+S_COLON; /** CML prefix when used as element namespace */ String C_E = CML_COLON; /** CML prefix when used as attribute value namespace */ String C_A = CML_COLON; /** * namespace declaration for CML without prefix */ String CML_XMLNS = XMLNS + S_EQUALS + S_APOS + CML_NS + S_APOS; /** * namespace declaration for CML with prefix */ String CML_XMLNS_PREFIX = XMLNS + S_COLON + CML_PREFIX + S_EQUALS + S_APOS + CML_NS + S_APOS; /** * obsolete CML namespaces */ String[] OLD_NAMESPACES = { CML1, CML2, CML3, "http://www.xmlcml.org/", "http://www.xmlcml.org/schema", "http://www.xml-cml.org/schema/cml2/core"}; /** constant */ String XHTML_NS = "http://www.w3.org/1999/xhtml"; /** XPathContext for CML. */ XPathContext CML_XPATH = new XPathContext("cml", CML_NS); /** namespace for SVG. * */ /** root of all SVG URIs */ String SVG_NS_BASE = "http://www.w3.org/2000/svg"; String SVG_NS = SVG_NS_BASE; /** XPathContext for SVG. */ XPathContext SVG_XPATH = new XPathContext("svg", SVG_NS); /** namespaces for XLINK * */ String XLINK_PREFIX = "xlink"; String XLINK_NS = "http://www.w3.org/1999/xlink"; /** * @deprecated */ XPathContext X_CML = CML_XPATH; /** XPath 'OR' concatenator*/ String X_OR = S_PIPE; // subdirs of components /** constant */ String TYPES = "types"; /** constant */ String ATTRIBUTES = "attributeGroups"; /** constant */ String ELEMENTS = "elements"; /** constant */ String TEXT_LIST = "CMLTextList"; /** constant */ String ATTRIBUTE_LIST = "CMLAttributeList"; /** constant */ String ELEMENT_LIST = "CMLElementList"; /** constant */ String TYPE_LIST = "CMLTypeList"; /** constant */ String ABSTRACT_NODEFACTORY = "OldNodeFactory"; /** java classnames */ String JAVA_BOOLEAN = "Boolean"; /** java classnames */ String JAVA_DOUBLE = "Double"; /** constant */ String JAVA_INTEGER = "Integer"; /** String class */ String JAVA_STRING = "String"; /** primitive */ String JAVA_BOOL = "boolean"; /** primitive */ String JAVA_INT = "int"; /** primitive */ String JAVA_DOUB = "double"; /** array */ String JAVA_ARRAY = "[]"; // for generating elements and attributes /** */ String ELEMENT_CLASS_BASE = "org.xmlcml.cml.element"; /** */ String LITE = "lite"; /** */ String MAIN = "main"; /** */ String ATTRIBUTE_CLASS_BASE = "org.xmlcml.cml.attribute"; /** */ String ATTRIBUTE = "Attribute"; // sepcial CML dataTypes /** dataType */ String CML_DATATYPETYPE = "dataTypeType"; /** namespaceRef */ String CML_NAMESPACEREFTYPE = "namespaceRefType"; /** units */ String CML_UNITSTYPE = "unitsType"; /** dictRef value identifying a filename */ String CML_FILENAME = C_A+"filename"; // ----------------------------------------------- // format /** constant */ String BANNER_S = "**************************************"; /** constant */ String WARNING_S = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; /** constant */ String AUTOGENERATED_DONOTEDIT_S = "/*======AUTOGENERATED FROM SCHEMA; DO NOT EDIT BELOW THIS LINE ======*/"; /** catalog.*/ String CATALOG_XML = "catalog.xml"; /** * units prefix reserved: for several uses */ String CML_UNITS = "units"; /** * units root namespace reserved */ String _UNIT_NS = CML_NS_BASE+EC.U_S+"units"; /** * units dictionary namespace reserved */ String UNIT_NS = _UNIT_NS+EC.U_S+"units"; /** * siUnits dictionary namespace reserved */ String SIUNIT_NS = _UNIT_NS+EC.U_S+"siUnits"; /** * unnitTypes dictionary namespace reserved */ String UNITTYPES_NS = _UNIT_NS+EC.U_S+"unitTypes"; /** * siUnits prefix reserved: for several uses */ String CML_SIUNITS = "siUnits"; // These are IDs, and must match those on the test dictionaries /** angstrom. */ String U_ANGSTROM = CML_UNITS + S_COLON + "ang"; /** degree. */ String U_DEGREE = CML_UNITS + S_COLON + "deg"; /** degree. */ String U_KCAL = CML_UNITS + S_COLON + "kcal"; /** celsius. */ String U_CELSIUS = CML_UNITS + S_COLON + "celsius"; // ================== crystal ================ /** * dictRef ids for 6 scalar children of crystal. */ String CRYSTAL_DICT_REFS[] = { CML_PREFIX + S_COLON + "a", CML_PREFIX + S_COLON + "b", CML_PREFIX + S_COLON + "c", CML_PREFIX + S_COLON + "alpha", CML_PREFIX + S_COLON + "beta", CML_PREFIX + S_COLON + "gamma" }; /** * unit refs for 6 scalar children of crystal. */ String[] CRYSTAL_DICT_UNITS = { CML_UNITS + S_COLON + "ang", CML_UNITS + S_COLON + "ang", CML_UNITS + S_COLON + "ang", CML_UNITS + S_COLON + "degree", CML_UNITS + S_COLON + "degree", CML_UNITS + S_COLON + "degree" }; // ======= test ========== /** * number of dictionaries. has to be altered every time new dictionaries are * added. */ int NDICT = 4; /** * number of units dictionaries. has to be altered every time new units * dictionaries are added. */ int NUNIT_DICT = 5; /** * number of unitType dictionaries. has to be altered every time new units * dictionaries are added. */ int NUNIT_TYPE_DICT = 1; // public final String value; }cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/CMLElement.java000077500000000000000000001136111477224461000252440ustar00rootroot00000000000000/** * 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.File; import java.io.FileInputStream; import java.io.IOException; import java.io.OutputStream; import java.io.Writer; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import nu.xom.Attribute; import nu.xom.Document; import nu.xom.Element; import nu.xom.Elements; import nu.xom.IllegalAddException; import nu.xom.Node; import nu.xom.Nodes; import nu.xom.ParentNode; import nu.xom.Serializer; import nu.xom.Text; import org.apache.log4j.Logger; import org.xmlcml.cml.attribute.RefAttribute; import org.xmlcml.cml.base.CMLLog.Severity; import org.xmlcml.euclid.Util; /** * base class for all CML elements * can be sorted on id attribute * @author Peter Murray-Rust * @version 5.0 * */ public class CMLElement extends Element implements CMLConstants, Comparable, HasId { public final static Logger LOG = Logger.getLogger(Element.class); /** hybridisation - from whatever source */ public enum Hybridization { /** constant */ SP3, /** constant */ SP2, /** constant */ SP, /** constant */ BENT, /** constant */ SQUARE_PLANAR, /** constant */ UNKNOWN; } /** * coordinateType. * */ public enum CoordinateType { /** * relate all operations to cartesian coordinates (XYZ3) */ CARTESIAN("cartesian"), /** * relate all operations to fractional coordinates (XYZFract) */ FRACTIONAL("fractional"), /** * relate all operations to 2D coordinates (XY2) */ TWOD("twod"); String name; private CoordinateType(String name) { this.name = name; } } /** * controls formal charge default why is this here?? */ public enum FormalChargeControl { /** * returns 0 if formalCharge missing * */ DEFAULT(0), /** * returns nonsense value if formalCharge missing * */ NO_DEFAULT(Integer.MIN_VALUE); int defalt; private FormalChargeControl(int def) { this.defalt = def; } } final static Logger logger = Logger.getLogger(CMLElement.class); final static String ID = "id"; private Map propertyMap; private Map> idMap; private CMLLog log = null; private AbstractTool tool; protected static CMLNodeFactory nodeFactory = CMLNodeFactory.nodeFactory; protected static AttributeFactory attributeFactory = AttributeFactory.attributeFactory; protected CMLElement() { super("element"); init(); } /** * main constructor. * * @param name * tagname */ public CMLElement(String name) { super(name, CMLConstants.CML_NS); init(); } private void init() { } /** parses a non-subclassed element into CML. * Typically used when other software such as * XOM or XSLT create elements through the normal * builder. * Removes any Document parent * Serializes the element and re-parses with CMLBuilder() * @param element the Element to parse * @return CMLElement (null if root element is not CML) */ public static CMLElement createCMLElement(Element element) { Element newElement = null; try { newElement = new CMLBuilder().parseString(CMLUtil.toXMLString(element)); } catch (Exception e) { throw new RuntimeException("BUG", e); } if (!(newElement instanceof CMLElement)) { newElement = null; } else { newElement.detach(); } return (CMLElement) newElement; } /** * normally overridden * @param id the identifier */ public void setId(String id) { this.addAttribute(new Attribute(CMLXSD_ID, id)); } /** * normally overridden * @return id */ public String getId() { return this.getAttributeValue(CMLXSD_ID); } /** * copy constructor. copies attributes, children and properties using the * copyFoo() routines (q.v.) * * @param element the element to copy */ public CMLElement(CMLElement element) { this(element.getLocalName()); copyAttributesFrom(element); copyChildrenFrom(element); copyNamespaces(element); copyProperties(element); } /** * copy node. * * @return node */ public Element copy() { return new CMLElement(this); } /** * callback when constructing from XML. No-op unless overridden in subclass * * @param parent element */ public void finishMakingElement(Element parent) { } protected void addRemove(CMLAttribute att, String value) { if (value == null || value.equals(S_EMPTY)) { this.removeAttribute(att.getLocalName()); } else if (att == null) { } else { att.setCMLValue(value); super.addAttribute(att); } } /** * copies attributes. makes subclass if necessary. * * @param element to copy from */ public void copyAttributesFrom(Element element) { for (int i = 0; i < element.getAttributeCount(); i++) { Attribute att = element.getAttribute(i); Attribute newAtt = (Attribute) att.copy(); this.addAttribute(newAtt); } } /** copies children of element make subclasses when required * * @param element to copy from */ public void copyChildrenFrom(Element element) { for (int i = 0; i < element.getChildCount(); i++) { Node childNode = element.getChild(i); Node newNode = childNode.copy(); this.appendChild(newNode); } } /** copies children of element make subclasses when required * * @param element to copy from * @param to */ public static void copyChildrenFromTo(Element element, Element to) { for (int i = 0; i < element.getChildCount(); i++) { Node childNode = element.getChild(i); Node newNode = childNode.copy(); to.appendChild(newNode); } } /** override replaceChild. * @param oldNode node to replace * @param newNode node that replaces the old node */ public void replaceChild(Node oldNode, Node newNode) { int pos = this.indexOf(oldNode); if (pos == -1) { throw new RuntimeException("Cannot replace non-child"); } newNode.detach(); this.removeChild(oldNode); this.insertChild(newNode, pos); } /** override insertChild. * if newNode has parent detach()es first * @param newNode new node to add * @param pos position where to add the node */ public void insertChild(Node newNode, int pos) { newNode.detach(); super.insertChild(newNode, pos); } /** re-route detach(). * to parent.removeChild(this); */ public void detach() { ParentNode parent = this.getParent(); if (parent != null) { if (parent instanceof Document) { parent.replaceChild(this, new Element("dummy")); } else { parent.removeChild(this); } } } /** override addNamespaceDeclaration(prefix, uri) to make it immutable. * if namespacePrefix is not set, set it, else returns no-op * without message. * @param prefix prefix for the namespace * @param uri URI of the namespace */ public void addNamespaceDeclaration(String prefix, String uri) { String namespaceURI = this.getNamespaceURI(prefix); if (namespaceURI == null) { super.addNamespaceDeclaration(prefix, uri); } } /** override removeNamespaceDeclaration(prefix) to forbid it. * @deprecated * * @param prefix prefix to remove */ public void removeNamespaceDeclaration(String prefix) { String namespaceURI = this.getNamespaceURI(prefix); if (namespaceURI == null) { throw new RuntimeException("Cannot remove namespace prefix"); } } /** override setLocalName(localName) to make it immutable. * if localname is null sets it, else no-op * @param localName local name of this element */ public void setLocalName(String localName) { String lName = this.getLocalName(); if (lName == null) { super.setLocalName(localName); } } /** set attribute. * reroutes special cases such as setId() => resetId() * @param attName name of the attribute * @param attValue value of the attribute */ public void setAttribute(String attName, String attValue) { // id is special if (ID.equals(attName)) { this.resetId(attValue); } else { this.addAttribute(new Attribute(attName, attValue)); } } // parent.addAttribute(new Attribute(parentAttribute, attValue)); /** override setNamespaceURI(String namespaceURI) to make it immutable. * if namespaceURI is not set, sets it, else no-op * @param namespaceURI URI of the namespace */ public void setNamespaceURI(String namespaceURI) { String nURI = this.getNamespaceURI(); if (nURI == null) { super.setNamespaceURI(namespaceURI); } } /** override setNamespacePrefix(String namespacePrefix) to make it immutable. * if namespacePrefix is not set, sets it, else no-op * @param namespacePrefix prefix of the namespace */ public void setNamespacePrefix(String namespacePrefix) { String nPrefix = this.getNamespacePrefix(); if (nPrefix == null) { super.setNamespacePrefix(nPrefix); } } /** replace current element by its child nodes. * does not work for root node * */ public void replaceByChildren() { Node parent = this.getParent(); if (parent == null) { } else if (!(parent instanceof Element)) { } else { Element parentElement = (Element) parent; int idx = parentElement.indexOf(this); List nodeList = new ArrayList(); for (int i = 0; i < this.getChildCount(); i++) { nodeList.add(this.getChild(i)); } for (int i = 0; i < nodeList.size(); i++) { Node node = nodeList.get(i); node.detach(); parentElement.insertChild(node, idx + i); } } this.detach(); } /** * copies namespaces. * * @param element * to copy from */ public void copyNamespaces(CMLElement element) { int n = element.getNamespaceDeclarationCount(); for (int i = 0; i < n; i++) { String namespacePrefix = element.getNamespacePrefix(i); String namespaceURI = element .getNamespaceURIForPrefix(namespacePrefix); this.addNamespaceDeclaration(namespacePrefix, namespaceURI); } } /** * copies properties. deep copy of map but NOT values * * @param element * to copy from */ public void copyProperties(CMLElement element) { if (element.propertyMap != null) { propertyMap = new HashMap(); for (String key : element.propertyMap.keySet()) { Object object = element.propertyMap.get(key); propertyMap.put(key, object); } } } /** * get XOM default canonical string. * * @return the string */ public String getCanonicalString() { return CMLUtil.getCanonicalString(this); } /** * compares elements for identity. sorting order based on canonical strings * * @param elem * to compare * @return 0 if content is identical else -1 or 1 */ public int compareTo(CMLElement elem) { String thisS = CMLUtil.getCanonicalString(this); String elemS = CMLUtil.getCanonicalString(elem); int i = thisS.compareTo(elemS); return (i == 0) ? 0 : ((i < 0) ? -1 : 1); } // ========================== utilities ====================== // /** * throws Exception. * * @param name * of attribute * @throws RuntimeException * standard message */ protected void unknownAttributeName(String name) { throw new RuntimeException("Unknown CML attribute " + name + " on " + this.getLocalName()); } protected String getCMLAttributeValue(String name) { CMLAttribute a = (CMLAttribute) this.getAttribute(name); return (a == null) ? null : (String) a.getCMLValue(); } protected CMLElement getOrCreateChild(String name) throws RuntimeException { CMLElement element = (CMLElement) this.getFirstChildElement(name, CMLConstants.CML_NS); if (element == null) { try { element = (CMLElement) Class.forName( ELEMENT_CLASS_BASE+".CML" + name.substring(0, 1) + name.substring(1)).newInstance(); } catch (Exception e) { throw new RuntimeException("" + e); } } return element; } /** ensures queries which may have cml namespace prefix have XPath context * @param query * @return nodes */ public Nodes cmlQuery(String query) { return super.query(query, CMLConstants.CML_XPATH); } /** *

* Detaches all children from this node. *

* * @return a list of all the children removed in the order they * appeared in the element */ public Nodes removeChildren() { int length = this.getChildCount(); Nodes result = new Nodes(); for (int i = 0; i < length; i++) { Node child = getChild(0); this.removeChild(child); result.append(child); } return result; } /** * remove attribute. * * @param attName */ public void removeAttribute(String attName) { Attribute att = this.getAttribute(attName); if (att != null) { this.removeAttribute(att); } } /** * copy attributes from one CMLElement to another. overwrites existing * atts * * @param from * element to copy from * @param to * element to copy to */ public static void copyAttributesFromTo(Element from, Element to) { for (int i = 0; i < from.getAttributeCount(); i++) { Attribute att = from.getAttribute(i); Attribute newAtt = (att instanceof CMLAttribute) ? new CMLAttribute( (CMLAttribute) att) : new Attribute(att); to.addAttribute(newAtt); } } /** it attribute exists detach it. * @param element * @param attName */ public static void deleteAttribute(Element element, String attName) { Attribute att = element.getAttribute(attName); if (att != null) { att.detach(); } } /** debug for element. makes copy if not document root writes to sysout * @param message */ public void debug(String message) { Util.println("<<<<<<"+message+"<<<<<<"); debug(); Util.println(">>>>>>"+message+">>>>>>"); } /** debug for element. makes copy if not document root writes to sysout */ public void debug() { try { debug(System.out, 2); } catch (IOException e) { Util.BUG(e); } } /** debug for element. makes copy if not docuemnt root writes to sysout * @param indent */ public void debug(int indent) { try { debug(System.out, indent); } catch (IOException e) { Util.BUG(e); } } /** debug. * * @param os * @param indent * @throws IOException */ public void debug(OutputStream os, int indent) throws IOException { Document document; Node parent = this.getParent(); if (parent instanceof Document) { document = (Document) parent; } else { CMLElement copyElem = new CMLElement(this); document = new Document(copyElem); } Serializer serializer = new Serializer(os); serializer.setIndent(indent); // if (indent == 0) { // serializer.setLineSeparator("\r\n"); // } serializer.write(document); } /** * set a property on the object. * * currently developed as a way of holding information during computation, * rather than adding to permanent data structure * * @param property * name, best enumerated in subclassed Tool (e.g. * AtomToo.MORGAN_COUNT). * @param value * the value to set. If null removes the property */ public void setProperty(String property, Object value) { if (property != null) { if (propertyMap == null) { propertyMap = new HashMap(); } if (value == null) { propertyMap.remove(property); } else { propertyMap.put(property, value); } } } /** * get a property on the object. * * currently developed as a way of holding information during computation, * rather than adding to permanent data structure * * @param property * name, best enumerated in subclassed Tool (e.g. * AtomToo.MORGAN_COUNT) * @return value or null if not set */ public Object getProperty(String property) { return (property == null || propertyMap == null) ? null : propertyMap .get(property); } /** * get list of property names. * * @return list of names (zero lengtn if none) */ public List getPropertyNames() { List list = new ArrayList(); if (propertyMap != null) { for (String key : propertyMap.keySet()) { list.add(key); } } return list; } /** * convenience method to get CMLElement children. avoid having to specify * namespaces. * * @return the CMLElement children */ public List getChildCMLElements() { List elementList = new ArrayList(); Elements elements = this.getChildElements(); for (int i = 0; i < elements.size(); i++) { if (elements.get(i) instanceof CMLElement) { elementList.add((CMLElement) elements.get(i)); } } return elementList; } /** * convenience method to get Element children. avoid having to specify * namespaces. * * @param name * local CML name * @return the children of that type */ public Elements getChildCMLElements(String name) { return getChildElements(name, CMLConstants.CML_NS); } /** * convenince method to get first Element child. avoid having to specify * namespaces. * * @param name * local CML name * @return the first child of that type or null */ public Element getFirstCMLChild(String name) { return getFirstChildElement(name, CMLConstants.CML_NS); } /** * convenince method to get serial Element child. avoid having to specify * namespaces. * * @param name * local CML name * @param i * serial number of child * @return the i'th child of that type or null */ public Element getChildCMLElement(String name, int i) { Elements childElements = getChildCMLElements(name); return (i < 0 || i >= childElements.size()) ? null : childElements .get(i); } /** * convenience method to get Element child count. avoid having to specify * namespaces. * * @param name * local CML name * @return the count of that type or null */ public int getCMLChildCount(String name) { Elements childElements = getChildCMLElements(name); return childElements.size(); } /** * gets attributeGroupName for attributeName. only used in code generation. * Only used by subclasses * * @param attributeName * @return null unless subclassed */ public String getAttributeGroupName(String attributeName) { return null; } /** * descendant elements by id. normally only one, but id is not required to * be unique * * @param id * @return elements */ public List getDescendantCMLElementsById(String id) { List elementList = new ArrayList(); if (id != null) { List childElements = this.getChildCMLElements(); for (CMLElement e : childElements) { if (id.equals(e.getAttribute(ID))) { elementList.add(e); } } } return elementList; } /** * get all CMLElements fitting query. * ignores non-ceml elements * @param cmlQueryString * @return list of CMLelements */ public List getElements(String cmlQueryString) { Nodes nodes = this.query(cmlQueryString, CMLConstants.CML_XPATH); List cmlElements = new ArrayList(); for (int i = 0; i < nodes.size(); i++) { if (nodes.get(i) instanceof CMLElement) { cmlElements.add((CMLElement) nodes.get(i)); } } return cmlElements; } /** * get all descendants with local name. * @deprecated use query * @param elementName to search for (null accepts all) * @param nested if true allows children of elementName (e.g. * molecule/molecule) * @return list of elements */ public List getDescendants(String elementName, boolean nested) { return getDescendants(elementName, null, nested); } /** * get all descendants with local name. * @deprecated use query * @param elementName * to search for (null accepts all) * @param attributeName * to search for (null accepts all) * @param nested * if true allows children of elementName (e.g. * molecule/molecule) * @return list of elements */ public List getDescendants(String elementName, String attributeName, boolean nested) { List elementList = new ArrayList(); boolean found = false; if (elementName == null || this.getLocalName().equals(elementName)) { if (attributeName == null || this.getAttributeValue(attributeName) != null) { elementList.add(this); found = true; } } // recurse if not found or nested if (!found || nested) { List childElements = this.getChildCMLElements(); for (CMLElement e : childElements) { List descendants = e.getDescendants(elementName, attributeName, nested); elementList.addAll(descendants); } } return elementList; } /** * get all descendants. * * @return list of elements */ public List getDescendants() { List elementList = new ArrayList(); elementList.add(this); List childElements = this.getChildCMLElements(); for (CMLElement e : childElements) { List descendants = e.getDescendants(); elementList.addAll(descendants); } return elementList; } /** * gets String content. only valid when there is a single Text child. not * checked against the schema, so use with care * * @return the XML text content or null */ public String getStringContent() { Node child = (this.getChildCount() == 0) ? null : this.getChild(0); String s = (child == null || !(child instanceof Text)) ? null : child .getValue(); return s; } /** * sets String content. very FRAGILE. not checked against the schema, so use with care. It * is almost always better to use the accessors generated from the schema * * @param value * the XML text content */ public void setStringContent(String value) { Text newText = new Text(value); if (this.getChildCount() == 0) { this.appendChild(newText); } else { Node child = this.getChild(0); if (child instanceof Text) { this.replaceChild(child, newText); } } } /** * get namespace. * * @param prefix * @return namespace */ public String getNamespaceURIForPrefix(String prefix) { String namespace = null; Element current = this; while (true) { namespace = current.getNamespaceURI(prefix); if (namespace != null) { break; } Node parent = current.getParent(); if (parent == null || parent instanceof Document) { break; } current = (Element) parent; } return namespace; } /** get prefix for declared namespace. since namespaces may be declared on * ancestors, recurse up tree till namespace found * * @param namespaceURI * @return prefix */ public String getPrefixForNamespace(String namespaceURI) { String prefix = null; int nCount = this.getNamespaceDeclarationCount(); for (int i = 0; i < nCount; i++) { String px = this.getNamespacePrefix(i); if (namespaceURI.equals(this.getNamespaceURI(px))) { prefix = px; break; } } if (prefix == null) { Node parent = this.getParent(); if (parent != null && parent instanceof CMLElement) { prefix = ((CMLElement) parent) .getPrefixForNamespace(namespaceURI); } } return prefix; } /** gets top CMLElement ancestor. * * @return top ancestor (or this if no CMLElement parent) */ public CMLElement getOldestCMLAncestor() { CMLElement current = this; while (true) { Node parent = current.getParent(); if (parent == null || !(parent instanceof CMLElement)) { break; } current = (CMLElement) parent; } return current; } /** gets element(s) which have given id. * fragile as it indexes the object once and if the * XOM is modified will be out of sync and needs refreshing * @param id (not necessarily unique * @param refresh the idMap * @return list of ids (never null, nay be 0) */ public List getElementsById(String id, boolean refresh) { if (idMap == null || refresh) { idMap = new HashMap>(); addIds(this); } List elemList = idMap.get(id); if (elemList == null) { elemList = new ArrayList(); } return elemList; } void addIds(CMLElement elem) { String id = elem.getAttributeValue(ID); if (id != null) { List idList = idMap.get(id); if (idList == null) { idList = new ArrayList(); idMap.put(id, idList); } if (!idList.contains(elem)) { idList.add(elem); } } List childList = elem.getChildCMLElements(); for (CMLElement child : childList) { addIds(child); } } /** * gets an Xpointer-like string describing the context of the element. * * @deprecated NYI * @return nothing */ public String getAncestry() { String s = ""; return s; } /** * write as HTML. many elements will override this method. * * @param w * writer * @throws IOException */ public void writeHTML(Writer w) throws IOException { w.write(""); w.write(this.getLocalName()); w.write(""); } /** convenience method to serialize the element. * * @param os * @param indent to indent lines by (non-zero may muck up whitespace) * @throws IOException */ public void serialize(OutputStream os, int indent) throws IOException { Document doc = new Document((CMLElement)this.copy()); Serializer serializer = new Serializer(os); serializer.write(doc); } /** set a CMLLog. * the molecule can then write to this when required with * element.addToLog(). * This is completely separate from log4j which I don't think can do * what I want. Maybe it's just me * @param log (null switches off logging) */ public void setLog(CMLLog log) { this.log = log; } /** add exception to log. * if log is unset, slient no action * @param t * @param message */ public void addToLog(Throwable t, String message) { if (log != null) { log.add(t, message); } } /** convenience method to add cmlx:foo attributes. * * @param attName WITHOUT prefix * @param attValue if null removes any old attributes */ public void setCMLXAttribute(String attName, String attValue) { if (attValue == null) { Attribute attribute = this.getAttribute(attName, CMLX_NS); if (attribute != null) { this.removeAttribute(attribute); } } else { addCMLXAttribute(this, attName, attValue); } } /** * creates a prefixed CMLX attribute (cmlx:foo="bar") on element in CMLX namespace * @param element * @param attName UNPREFIXED * @param attValue */ public static void addCMLXAttribute(Element element, String attName, String attValue) { Attribute attribute = makeCMLXAttribute(attName, attValue); element.addAttribute(attribute); element.addNamespaceDeclaration(CMLConstants.CMLX_PREFIX, CMLX_NS); } /** convenience method to create new cmlx:foo attribute. * * @param attName WITHOUT prefix and colon * @param value if null undefined * @return */ public static Attribute makeCMLXAttribute(String attName, String value) { return new Attribute(CMLX_PREFIX+S_COLON+attName, CMLX_NS, value); } /** convenience method to get value of cmlx:foo attribute. * * @param attName WITHOUT prefix */ public String getCMLXAttribute(String attName) { String value = null; Attribute attribute = this.getAttribute(attName, CMLX_NS); if (attribute != null) { value = attribute.getValue(); } return value; } /** *

* Appends a node to the children of this node. *

* * @param child node to append to this node * * @throws IllegalAddException if this node cannot have children * of this type * @throws NullPointerException if child is null * */ public void appendChild(Node child) { child.detach(); int childCount = this.getChildCount(); insertChild(child, childCount); } /** add severity to log. * if log is unset, slient no action * @param severity * @param message */ public void addToLog(Severity severity, String message) { if (log != null) { log.add(severity, message); } } /** allows id to be reset. * many elements forbid resetting id... * this is a fragile workaround. * do not use unless you know what you are doing * @param id */ public void resetId(String id) { this.removeAttribute(ID); this.addAttribute(new Attribute(ID, id)); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent of element to be constructed (ignored by default) * @return CMLElement */ public CMLElement makeElementInContext(Element parent) { return new CMLElement(); } /** * @return the propertyMap */ public Map getPropertyMap() { return propertyMap; } /** * @param propertyMap the propertyMap to set */ public void setPropertyMap(Map propertyMap) { this.propertyMap = propertyMap; } /** * @return the log */ public CMLLog getLog() { return log; } /** * @return the tool */ public AbstractTool getTool() { return tool; } /** * @param tool the tool to set */ public void setTool(AbstractTool tool) { this.tool = tool; } /** * dereferences element in @ref attribute and creates a new element * does NOT affect 'this' * creates a reference if inside the XML tree, else creates are copy * of XML in URL or File * */ public CMLElement dereferenceRef() { CMLElement element = null; String ref = this.getAttributeValue(RefAttribute.NAME); if (ref != null) { element = referenceWithinXML(ref); if (element == null) { element = readFromURL(ref); } if (element == null) { element = readFromRelativeFile(ref); } } return element; } /** * dereferences element in @ref attribute and creates a new element * replaces 'this' by copy of new element * * */ public void dereferenceRefsCopyReplace() { Nodes nodes = this.query("//*[@"+RefAttribute.NAME+"]", CMLConstants.CML_XPATH); List elementList = new ArrayList(); for (int i = 0; i < nodes.size(); i++) { elementList.add((CMLElement) nodes.get(i)); } for (CMLElement element : elementList) { element.dereferenceRefCopyReplace(); } } /** * dereferences element in @ref attribute * IFF 'this' is CMLElement or same class as dereferenced element * replaces 'this' by copy of new element * else discards it */ public CMLElement dereferenceRefCopyReplace() { CMLElement dereferencedElement = (CMLElement) this.dereferenceRef(); if (this.getParent() != null && !(this.getParent() instanceof Document) && dereferencedElement != null) { String id = this.getId(); CMLElement newElement = (CMLElement) dereferencedElement.copy(); if (this.getClass().equals(CMLElement.class) || this.getClass().equals(newElement.getClass())) { if (id != null) { newElement.resetId(id); } this.getParent().replaceChild(this, newElement); } } return dereferencedElement; } private CMLElement referenceWithinXML(String ref) { Nodes refs = this.query("ancestor::*//*[namespace-uri()='"+CMLConstants.CML_NS+"'and @id='"+ref+"']"); CMLElement element = refs.size() == 1 ? (CMLElement) refs.get(0) : null; return element; } private CMLElement readFromURL(String ref) { CMLElement element = null; try { URL url = new URL(ref); element = (CMLElement) new CMLBuilder().build(url.openStream()).getRootElement(); } catch (Exception e) { // wasn't a URL } return element; } private CMLElement readFromRelativeFile(String ref) { CMLElement element = null; try { File infil = new File(ref); LOG.trace("dereferencing: "+infil.getAbsolutePath()); if (!infil.exists()) { throw new RuntimeException("Cannot find file: "+infil.getAbsolutePath()); } element = (CMLElement) new CMLBuilder().build(new FileInputStream(infil)).getRootElement(); } catch (Exception e) { throw new RuntimeException("Cannot parse file", e); } return element; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/CMLElementType.java000077500000000000000000000174101477224461000261060ustar00rootroot00000000000000/** * 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.List; import java.util.Map; import nu.xom.Element; import nu.xom.Node; /** * @author pm286 * */ public class CMLElementType implements CMLConstants { private Element complexType; private Element simpleType; private Element extension; private List attributeList; private List attributeGroupNameList; private List elementTypeList; private Element xsdElement; private String name; private CMLType simpleContentType; /** constructor. * @param xsdElement */ public CMLElementType(Element xsdElement) { init(); this.xsdElement = xsdElement; this.name = xsdElement.getAttributeValue("name"); processContentTypes(); } private void processContentTypes() { List complexTypes = CMLUtil.getQueryNodes(xsdElement, "./"+XSD_COMPLEX_TYPE, XPATH_XSD); if (complexTypes.size() == 1) { complexType = (Element) complexTypes.get(0); } if (complexType == null) { throw new RuntimeException("No complexType for: "+name); } List simpleTypes = CMLUtil.getQueryNodes(complexType, "./"+XSD_SIMPLE_CONTENT, XPATH_XSD); if (simpleTypes.size() == 1) { simpleType = (Element) simpleTypes.get(0); } } void init() { attributeList = new ArrayList(); attributeGroupNameList = new ArrayList(); elementTypeList = new ArrayList(); } /** process attributes. * * @param attributeGroupMap */ public void processAttributes(Map attributeGroupMap) { Element contentType = complexType; // attributes may be in simpleContent if (simpleType != null) { List extensions = CMLUtil.getQueryNodes( simpleType, "./"+XSD_EXTENSION, XPATH_XSD); if (extensions.size() == 0) { throw new RuntimeException("Expected extension children for simpleContent for "+name); } extension = (Element) extensions.get(0); contentType = extension; } List attributes = CMLUtil.getQueryNodes( contentType, "./"+XSD_ATTRIBUTE, XPATH_XSD); if (attributes.size() != 0) { throw new RuntimeException("Use attributeGroups instead of attributes for "+name); } List attributeGroups = CMLUtil.getQueryNodes( contentType, "./"+XSD_ATTRIBUTE_GROUP, XPATH_XSD); if (attributeGroups.size() == 0) { throw new RuntimeException("NOTE: no attributeGroups for "+name); } for (Node node : attributeGroups) { Element attributeGroup = (Element) node; String attributeGroupRef = attributeGroup.getAttributeValue("ref"); CMLAttribute attribute = attributeGroupMap.get(attributeGroupRef); if (attribute == null) { throw new RuntimeException("cannot find attributeGroup: "+attributeGroupRef); } attributeList.add(attribute); attributeGroupNameList.add(attributeGroupRef); } } /** process complexContent. * @param elementTypeMap */ public void processComplexContent(Map elementTypeMap) { if (simpleType == null) { List elements = CMLUtil.getQueryNodes(complexType, ".//"+XSD_ELEMENT+"[@ref]", XPATH_XSD); if (elements.size() == 0) { // LOG.debug("NOTE: no element children for "+name); } for (Node node : elements) { Element xsdElement = (Element) node; String ref = xsdElement.getAttributeValue("ref"); if (ref == null) { throw new RuntimeException("No ref attribute for child element in "+name); } CMLElementType elementType = elementTypeMap.get(ref); if (elementType == null) { throw new RuntimeException("No element known for "+ref); } elementTypeList.add(elementType); } } } /** process simpleContent. * * @param typeMap */ public void processSimpleContent(Map typeMap) { if (extension != null) { String base = extension.getAttributeValue("base"); if (base == null) { throw new RuntimeException("No base given for extension in "+name); } simpleContentType = typeMap.get(base); if (simpleContentType == null) { throw new RuntimeException("No type found for: "+base); } } } /** * @return the attributeList */ public List getAttributeList() { return attributeList; } /** * @param attributeList the attributeList to set */ public void setAttributeList(List attributeList) { this.attributeList = attributeList; } /** * @return the attributeGroupNameList */ public List getAttributeGroupNameList() { return attributeGroupNameList; } /** * @param attributeGroupNameList the attributeGroupNameList to set */ public void setAttributeGroupNameList(List attributeGroupNameList) { this.attributeGroupNameList = attributeGroupNameList; } /** * @return the complexType */ public Element getComplexType() { return complexType; } /** * @param complexType the complexType to set */ public void setComplexType(Element complexType) { this.complexType = complexType; } /** * @return the simpleType */ public Element getSimpleType() { return simpleType; } /** * @param simpleType the simpleType to set */ public void setSimpleType(Element simpleType) { this.simpleType = simpleType; } /** * @return the elementTypeList */ public List getElementTypeList() { return elementTypeList; } /** * @param elementTypeList the elementTypeList to set */ public void setElementTypeList(List elementTypeList) { this.elementTypeList = elementTypeList; } /** * @return the name */ public String getName() { return name; } /** * @param name the name to set */ public void setName(String name) { this.name = name; } /** * @return the xsdElement */ public Element getXsdElement() { return xsdElement; } /** * @param xsdElement the xsdElement to set */ public void setXsdElement(Element xsdElement) { this.xsdElement = xsdElement; } /** * @return the simpleContentType */ public CMLType getSimpleContentType() { return simpleContentType; } /** * @param simpleContentType the simpleContentType to set */ public void setSimpleContentType(CMLType simpleContentType) { this.simpleContentType = simpleContentType; } /** * @return the extension */ public Element getExtension() { return extension; } /** * @param extension the extension to set */ public void setExtension(Element extension) { this.extension = extension; } /** to string. * @return string */ public String toString() { String s = ""; if (simpleContentType != null) { s += simpleContentType.listDataType()+"\n"; } else { for (CMLElementType elementType : elementTypeList) { s += " + "+elementType.getName()+"\n"; } } int i = 0; for (CMLAttribute attribute : attributeList) { s += " "+attribute.getLocalName(); if (++i % 6 == 0) { s += "\n"; } } s += "\n"; return s; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/CMLElements.java000077500000000000000000000106121477224461000254240ustar00rootroot00000000000000/** * 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.Iterator; import java.util.List; import nu.xom.Element; import nu.xom.Elements; /** * class to manage child elements in similar manner to XOM Elements. differs * from XOM as this is iterable * * @author pm286, and ramin */ public class CMLElements implements Iterable, CMLConstants { private ArrayList elementsArray; private Class type; /** * create from XOM elements. * * @param elements */ public CMLElements(Elements elements) { if (elements == null) { elementsArray = new ArrayList(0); } else { elementsArray = new ArrayList(elements.size()); for (int i = 0; i < elements.size(); i++) { if (i == 0) { type = elements.get(0).getClass(); } if (elements.get(i).getClass().equals(type)) { @SuppressWarnings("unchecked") E elem = (E) elements.get(i); elementsArray.add(elem); } else { throw new RuntimeException( "Elements list contains elements of different types"); } } } } /** * iterator through elements. * * @return the iterator */ public Iterator iterator() { return new CMLElementsIterator(elementsArray); } /** * returns element by serial number. * * @param i * serial * @return element or null if i out of range */ public E get(int i) { return (E) ((i < 0 || i >= elementsArray.size()) ? (E) null : elementsArray.get(i)); } /** * size of elements. * * @return the size (may be 0) */ public int size() { return elementsArray.size(); } /** * type of element. should be set at creation. If not, runs through all * elements checking type. * * @return the class */ public Class getType() { if (type.equals(java.lang.Class.class)) { int i = 0; for (Element element : elementsArray) { Class classx = element.getClass(); if (i == 0) { type = classx; } else if (!(type.equals(classx))) { throw new RuntimeException("CMLElements is not homogeneous: " + type + CMLConstants.S_SLASH + classx); } i++; } } return type; } /** * converts the elements into a List. * * @return list (could be of length 0) */ public List getList() { return new ArrayList(elementsArray); } class CMLElementsIterator implements Iterator { int index = 0; List list; /** * iterator. * * @param list */ public CMLElementsIterator(List list) { this.list = list; } /** * remove. not implemented */ public void remove() { throw new UnsupportedOperationException(); } /** * next. * * @return next element */ public T next() { return list.get(index++); } /** * has next. * * @return true if more elements */ public boolean hasNext() { return (index < list.size()); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/CMLLog.java000077500000000000000000000103061477224461000243710ustar00rootroot00000000000000/** * 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.File; import java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.List; /** generic logfile for CML activities * @author Peter Murray-Rust * @version 5.0 * */ public class CMLLog implements CMLConstants { /** levels of warnings. * @author pm286 */ public enum Severity { /** warning */ WARNING, /** error */ ERROR, /** info */ INFO, ; private Severity() { } } List messageList; /** constructor. */ public CMLLog() { messageList = new ArrayList(); } /** add string. * @param severity * @param s */ public void add(Severity severity, String s) { messageList.add(new Message(severity, s)); } /** add string. * * @param s */ public void add(String s) { messageList.add(new Message(s)); } /** add error. * * @param t * @param s */ public void add(Throwable t, String s) { messageList.add(new Message(t, s)); } /** add file. * used when writing to file * @param file * @param s */ public void add(File file, String s) { messageList.add(new Message(file, s)); } /** output log. * * @param w * @throws IOException */ public void write(Writer w) throws IOException { for (Message m : messageList) { if (m.t != null) { w.write(m.t.toString()+": "); } w.write(m.s+"\n"); } } /** output log. * * @param w * @throws IOException */ public void writeXML(Writer w) throws IOException { w.write("\n"); for (Message m : messageList) { m.writeXML(w); } w.write("\n"); } } class Message { CMLLog.Severity severity; File file; Throwable t; String s; /** constructor. * * @param s message */ public Message(String s) { this.s = s; } /** constructor. * @param sev severity level * @param s message */ public Message(CMLLog.Severity sev, String s) { this.severity = sev; this.s = s; } /** constructor. * * @param t * @param s message */ public Message(Throwable t, String s) { this.t = t; this.s = s; } /** constructor. * * @param file * @param s message */ public Message(File file, String s) { this.file = file; this.s = s; } void writeXML(Writer w) throws IOException { if (t != null) { writeThrowable(w); } else if (file != null) { writeFile(w); } else { writeString(w); } } private void writeString(Writer w) throws IOException { if (s != null) { w.write(""+s+"\n"); } } private void writeFile(Writer w) throws IOException { w.write(""); writeString(w); w.write("\n"); } private void writeThrowable(Writer w) throws IOException { w.write(""); w.write(t.getMessage()); writeString(w); w.write("\n"); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/CMLNamespace.java000077500000000000000000000051751477224461000255540ustar00rootroot00000000000000/** * 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; /** manages CML namespaces. * NOTE: NOT subclassed from nu.xom.Namespace (this is final) * * @author Peter Murray-Rust * @version 5.0 * */ public class CMLNamespace implements CMLConstants { private String prefix; private String namespaceURI; /** constructor. * * @param prefix * @param namespaceURI */ public CMLNamespace(String prefix, String namespaceURI) { this.prefix = prefix; this.namespaceURI = namespaceURI; } /** make namespace from prefix and element which holds namespaces. * iterates up ancestry namespace prefixes until finds match * @param prefix * @param element * @return namespace */ public static CMLNamespace createNamespace(String prefix, CMLElement element) { String namespaceURI = element.getNamespaceURIForPrefix(prefix); CMLNamespace namespace = null; if (namespaceURI != null) { namespace = new CMLNamespace(prefix, namespaceURI); } return namespace; } /** get namespaceURI. * * @return the URI */ public String getNamespaceURI() { return namespaceURI; } /** get prefix. * * @return the prefix */ public String getPrefix() { return prefix; } /** * guess CML namespace. if correct namespace, returns it. if obsolete * returns correct namespace. * * @param namespace * @return correct namespace or leave unchanged; */ public static String guessNamespace(String namespace) { String namesp = namespace; if (CML_NS.equals(namespace)) { namesp = namespace; } else if (namespace != null) { for (String n : CMLConstants.OLD_NAMESPACES) { if (n.equals(namespace)) { namesp = CMLConstants.CML_NS; break; } } } return namesp; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/base/CMLNodeFactory.java000077500000000000000000000160361477224461000260730ustar00rootroot00000000000000/** * 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.HashMap; import java.util.Map; import java.util.Stack; import nu.xom.Attribute; import nu.xom.Element; import nu.xom.NodeFactory; import nu.xom.Nodes; import nu.xom.Text; import org.apache.log4j.Logger; /** user-modifiable class supporting NodeFactory. * * autogenerated from schema * use as a shell which can be edited */ public class CMLNodeFactory extends NodeFactory implements CMLConstants { private static Logger LOG = Logger.getLogger(CMLNodeFactory.class); // fields; /** current of current node*/ private Element current; /** current element stack*/ private Stack stack = new Stack(); /** must give simple documentation. */ private Map factoryElementMap; // singleton /** singleton node factory. */ public static final CMLNodeFactory nodeFactory = new CMLNodeFactory(); static { nodeFactory.init(); } private CMLNodeFactory() { factoryElementMap = new HashMap(); } 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.java000077500000000000000000000127361477224461000267270ustar00rootroot00000000000000/** * 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.java000077500000000000000000000074071477224461000257710ustar00rootroot00000000000000/** * 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.java000077500000000000000000000015621477224461000257470ustar00rootroot00000000000000/** * 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.java000077500000000000000000001137471477224461000246060ustar00rootroot00000000000000/** * 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.java000077500000000000000000001163541477224461000245770ustar00rootroot00000000000000/** * 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 = ""; 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.java000077500000000000000000000114371477224461000276660ustar00rootroot00000000000000/** * 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.java000077500000000000000000000074041477224461000266660ustar00rootroot00000000000000/** * 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.java000077500000000000000000000066561477224461000265710ustar00rootroot00000000000000/** * 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.java000077500000000000000000000015631477224461000243110ustar00rootroot00000000000000/** * 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.java000077500000000000000000000117601477224461000272050ustar00rootroot00000000000000/** * 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.java000077500000000000000000000100561477224461000262030ustar00rootroot00000000000000/** * 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.java000077500000000000000000000066511477224461000260170ustar00rootroot00000000000000/** * 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.java000077500000000000000000000105631477224461000277210ustar00rootroot00000000000000/** * 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.java000077500000000000000000000071471477224461000267260ustar00rootroot00000000000000/** * 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.java000077500000000000000000000124551477224461000261130ustar00rootroot00000000000000/** * 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/000077500000000000000000000000001477224461000231655ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractAbundance.java000077500000000000000000000351021477224461000274000ustar00rootroot00000000000000/** * 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.java000077500000000000000000000631001477224461000267340ustar00rootroot00000000000000/** * 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.java000077500000000000000000000607051477224461000276000ustar00rootroot00000000000000/** * 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.java000077500000000000000000000275271477224461000267770ustar00rootroot00000000000000/** * 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.java000077500000000000000000000553141477224461000265550ustar00rootroot00000000000000/** * 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.java000077500000000000000000000764641477224461000262510ustar00rootroot00000000000000/** * 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.java000077500000000000000000001122401477224461000265750ustar00rootroot00000000000000/** * 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.java000077500000000000000000000273751477224461000274470ustar00rootroot00000000000000/** * 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.java000077500000000000000000002435131477224461000264270ustar00rootroot00000000000000/** * 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.java000077500000000000000000001372231477224461000274260ustar00rootroot00000000000000/** * 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.java000077500000000000000000000325061477224461000276160ustar00rootroot00000000000000/** * 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.java000077500000000000000000000351551477224461000271040ustar00rootroot00000000000000/** * 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.java000077500000000000000000000414731477224461000272720ustar00rootroot00000000000000/** * 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.java000077500000000000000000000301241477224461000301150ustar00rootroot00000000000000/** * 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.java000077500000000000000000000520051477224461000314250ustar00rootroot00000000000000/** * 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 getGradientElements() { Elements elements = this.getChildElements("gradient", 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("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 if (name.equals("n")) { setN(value); } else if (name.equals("l")) { setL(value); } else if (name.equals("m")) { setM(value); } else if (name.equals("symbol")) { setSymbol(value); } else if (name.equals("lm")) { setLm(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractBand.java000077500000000000000000000442261477224461000263730ustar00rootroot00000000000000/** * 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.DoubleArraySTAttribute; import org.xmlcml.cml.base.DoubleSTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractBand extends CMLElement { /** local name*/ public final static String TAG = "band"; /** constructor. */ public AbstractBand() { super("band"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractBand(AbstractBand old) { super((CMLElement) old); } // attribute: kpoint /** cache */ DoubleArraySTAttribute _att_kpoint = null; /** The k vector. * The k-vector with 3 components. * @return CMLAttribute */ public CMLAttribute getKpointAttribute() { return (CMLAttribute) getAttribute("kpoint"); } /** The k vector. * The k-vector with 3 components. * @return double[] */ public double[] getKpoint() { DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getKpointAttribute(); if (att == null) { return null; } return att.getDoubleArray(); } /** The k vector. * The k-vector with 3 components. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setKpoint(String value) throws RuntimeException { DoubleArraySTAttribute att = null; if (_att_kpoint == null) { _att_kpoint = (DoubleArraySTAttribute) attributeFactory.getAttribute("kpoint", "band"); if (_att_kpoint == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : kpoint probably incompatible attributeGroupName and attributeName"); } } att = new DoubleArraySTAttribute(_att_kpoint); super.addRemove(att, value); } /** The k vector. * The k-vector with 3 components. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setKpoint(double[] value) throws RuntimeException { if (_att_kpoint == null) { _att_kpoint = (DoubleArraySTAttribute) attributeFactory.getAttribute("kpoint", "band"); if (_att_kpoint == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : kpoint probably incompatible attributeGroupName and attributeName "); } } DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_kpoint); super.addAttribute(att); att.setCMLValue(value); } // attribute: kpointRef /** cache */ StringSTAttribute _att_kpointref = null; /** A reference to a kpoint. * Used by band, etc. * @return CMLAttribute */ public CMLAttribute getKpointRefAttribute() { return (CMLAttribute) getAttribute("kpointRef"); } /** A reference to a kpoint. * Used by band, etc. * @return String */ public String getKpointRef() { StringSTAttribute att = (StringSTAttribute) this.getKpointRefAttribute(); if (att == null) { return null; } return att.getString(); } /** A reference to a kpoint. * Used by band, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setKpointRef(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_kpointref == null) { _att_kpointref = (StringSTAttribute) attributeFactory.getAttribute("kpointRef", "band"); if (_att_kpointref == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : kpointRef probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_kpointref); super.addRemove(att, value); } // attribute: weight /** cache */ DoubleSTAttribute _att_weight = null; /** Weight of the element. * Currently the weight of the kPoint, derived from the symmetry such as the inverse of the multiplicity in real space. Thus a point at 0,0,0 in monoclinic space might be 0.25. The lowest value possible is probably 1/48.0 (in m3m). * @return CMLAttribute */ public CMLAttribute getWeightAttribute() { return (CMLAttribute) getAttribute("weight"); } /** Weight of the element. * Currently the weight of the kPoint, derived from the symmetry such as the inverse of the multiplicity in real space. Thus a point at 0,0,0 in monoclinic space might be 0.25. The lowest value possible is probably 1/48.0 (in m3m). * @return double */ public double getWeight() { DoubleSTAttribute att = (DoubleSTAttribute) this.getWeightAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Weight of the element. * Currently the weight of the kPoint, derived from the symmetry such as the inverse of the multiplicity in real space. Thus a point at 0,0,0 in monoclinic space might be 0.25. The lowest value possible is probably 1/48.0 (in m3m). * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setWeight(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_weight == null) { _att_weight = (DoubleSTAttribute) attributeFactory.getAttribute("weight", "band"); if (_att_weight == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : weight probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_weight); super.addRemove(att, value); } /** Weight of the element. * Currently the weight of the kPoint, derived from the symmetry such as the inverse of the multiplicity in real space. Thus a point at 0,0,0 in monoclinic space might be 0.25. The lowest value possible is probably 1/48.0 (in m3m). * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setWeight(double value) throws RuntimeException { if (_att_weight == null) { _att_weight = (DoubleSTAttribute) attributeFactory.getAttribute("weight", "band"); if (_att_weight == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : weight probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_weight); super.addAttribute(att); att.setCMLValue(value); } // attribute: label /** cache */ StringSTAttribute _att_label = null; /** A label. * The semantics of label are not defined in the schema but are normally commonly used standard or semi-standard text strings. This attribute has the the same semantics as the more common _label_ element. * @return CMLAttribute */ public CMLAttribute getLabelAttribute() { return (CMLAttribute) getAttribute("label"); } /** A label. * The semantics of label are not defined in the schema but are normally commonly used standard or semi-standard text strings. This attribute has the the same semantics as the more common _label_ element. * @return String */ public String getLabel() { StringSTAttribute att = (StringSTAttribute) this.getLabelAttribute(); if (att == null) { return null; } return att.getString(); } /** A label. * The semantics of label are not defined in the schema but are normally commonly used standard or semi-standard text strings. This attribute has the the same semantics as the more common _label_ element. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setLabel(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_label == null) { _att_label = (StringSTAttribute) attributeFactory.getAttribute("label", "band"); if (_att_label == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : label probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_label); 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", "band"); 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", "band"); 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", "band"); 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", "band"); 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); } /** 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("kpoint")) { setKpoint(value); } else if (name.equals("kpointRef")) { setKpointRef(value); } else if (name.equals("weight")) { setWeight(value); } else if (name.equals("label")) { setLabel(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/AbstractBandList.java000077500000000000000000000235251477224461000272260ustar00rootroot00000000000000/** * 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 AbstractBandList extends CMLElement { /** local name*/ public final static String TAG = "bandList"; /** constructor. */ public AbstractBandList() { super("bandList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractBandList(AbstractBandList 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", "bandList"); 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", "bandList"); 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", "bandList"); 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", "bandList"); 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: band /** null * @param band child to add */ public void addBand(AbstractBand band) { band.detach(); this.appendChild(band); } /** null * @return CMLElements<CMLBand> */ public CMLElements getBandElements() { Elements elements = this.getChildElements("band", 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 { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractBasisSet.java000077500000000000000000000345251477224461000272450ustar00rootroot00000000000000/** * 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 AbstractBasisSet extends CMLElement { /** local name*/ public final static String TAG = "basisSet"; /** constructor. */ public AbstractBasisSet() { super("basisSet"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractBasisSet(AbstractBasisSet 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", "basisSet"); 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", "basisSet"); 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", "basisSet"); 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", "basisSet"); 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", "basisSet"); 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: 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", "basisSet"); 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); } // element: metadataList /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: name /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param name child to add */ public void addName(AbstractName name) { name.detach(); this.appendChild(name); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLName> */ public CMLElements getNameElements() { Elements elements = this.getChildElements("name", CMLConstants.CML_NS); return new CMLElements(elements); } // element: atomicBasisFunction /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param atomicBasisFunction child to add */ public void addAtomicBasisFunction(AbstractAtomicBasisFunction atomicBasisFunction) { atomicBasisFunction.detach(); this.appendChild(atomicBasisFunction); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLAtomicBasisFunction> */ public CMLElements getAtomicBasisFunctionElements() { Elements elements = this.getChildElements("atomicBasisFunction", 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 if (name.equals("role")) { setRole(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractBond.java000077500000000000000000000562031477224461000264070ustar00rootroot00000000000000/** * 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.StringArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractBond extends CMLElement { /** local name*/ public final static String TAG = "bond"; /** constructor. */ public AbstractBond() { super("bond"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractBond(AbstractBond 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", "bond"); 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", "bond"); 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", "bond"); 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", "bond"); 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", "bond"); 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: atomRefs2 /** cache */ StringArraySTAttribute _att_atomrefs2 = null; /** References to two different atoms. * Available for any reference to atoms but normally will be the normal reference attribute on the bond element. The order of atoms is preserved and may matter for some conventions (e.g. wedge/hatch or donor bonds. * @return CMLAttribute */ public CMLAttribute getAtomRefs2Attribute() { return (CMLAttribute) getAttribute("atomRefs2"); } /** References to two different atoms. * Available for any reference to atoms but normally will be the normal reference attribute on the bond element. The order of atoms is preserved and may matter for some conventions (e.g. wedge/hatch or donor bonds. * @return String[] */ public String[] getAtomRefs2() { StringArraySTAttribute att = (StringArraySTAttribute) this.getAtomRefs2Attribute(); if (att == null) { return null; } return att.getStringArray(); } /** References to two different atoms. * Available for any reference to atoms but normally will be the normal reference attribute on the bond element. The order of atoms is preserved and may matter for some conventions (e.g. wedge/hatch or donor bonds. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefs2(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_atomrefs2 == null) { _att_atomrefs2 = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs2", "bond"); if (_att_atomrefs2 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs2 probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_atomrefs2); super.addRemove(att, value); } /** References to two different atoms. * Available for any reference to atoms but normally will be the normal reference attribute on the bond element. The order of atoms is preserved and may matter for some conventions (e.g. wedge/hatch or donor bonds. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefs2(String[] value) throws RuntimeException { if (_att_atomrefs2 == null) { _att_atomrefs2 = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs2", "bond"); if (_att_atomrefs2 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs2 probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_atomrefs2); super.addAttribute(att); att.setCMLValue(value); } // attribute: atomRefs /** cache */ StringArraySTAttribute _att_atomrefs = null; /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @return CMLAttribute */ public CMLAttribute getAtomRefsAttribute() { return (CMLAttribute) getAttribute("atomRefs"); } /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @return String[] */ public String[] getAtomRefs() { StringArraySTAttribute att = (StringArraySTAttribute) this.getAtomRefsAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefs(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_atomrefs == null) { _att_atomrefs = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs", "bond"); if (_att_atomrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_atomrefs); super.addRemove(att, value); } /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefs(String[] value) throws RuntimeException { if (_att_atomrefs == null) { _att_atomrefs = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs", "bond"); if (_att_atomrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_atomrefs); super.addAttribute(att); att.setCMLValue(value); } // attribute: bondRefs /** cache */ StringArraySTAttribute _att_bondrefs = null; /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @return CMLAttribute */ public CMLAttribute getBondRefsAttribute() { return (CMLAttribute) getAttribute("bondRefs"); } /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @return String[] */ public String[] getBondRefs() { StringArraySTAttribute att = (StringArraySTAttribute) this.getBondRefsAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setBondRefs(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_bondrefs == null) { _att_bondrefs = (StringArraySTAttribute) attributeFactory.getAttribute("bondRefs", "bond"); if (_att_bondrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : bondRefs probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_bondrefs); super.addRemove(att, value); } /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setBondRefs(String[] value) throws RuntimeException { if (_att_bondrefs == null) { _att_bondrefs = (StringArraySTAttribute) attributeFactory.getAttribute("bondRefs", "bond"); if (_att_bondrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : bondRefs probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_bondrefs); super.addAttribute(att); att.setCMLValue(value); } // attribute: order /** cache */ StringSTAttribute _att_order = null; /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @return CMLAttribute */ public CMLAttribute getOrderAttribute() { return (CMLAttribute) getAttribute("order"); } /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @return String */ public String getOrder() { StringSTAttribute att = (StringSTAttribute) this.getOrderAttribute(); if (att == null) { return null; } return att.getString(); } /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @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", "bond"); 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: cyclic /** cache */ StringSTAttribute _att_cyclic = null; /** The cyclic nature of a bond. * This is an assertion by a human or program about the * cyclic nature of a bond. It need not correspond to what is deducible from the * connection table (e.g. a bond in a ring might be labelled as 'acyclic' * or 'unknown') * @return CMLAttribute */ public CMLAttribute getCyclicAttribute() { return (CMLAttribute) getAttribute("cyclic"); } /** The cyclic nature of a bond. * This is an assertion by a human or program about the * cyclic nature of a bond. It need not correspond to what is deducible from the * connection table (e.g. a bond in a ring might be labelled as 'acyclic' * or 'unknown') * @return String */ public String getCyclic() { StringSTAttribute att = (StringSTAttribute) this.getCyclicAttribute(); if (att == null) { return null; } return att.getString(); } /** The cyclic nature of a bond. * This is an assertion by a human or program about the * cyclic nature of a bond. It need not correspond to what is deducible from the * connection table (e.g. a bond in a ring might be labelled as 'acyclic' * or 'unknown') * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setCyclic(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_cyclic == null) { _att_cyclic = (StringSTAttribute) attributeFactory.getAttribute("cyclic", "bond"); if (_att_cyclic == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : cyclic probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_cyclic); super.addRemove(att, value); } // element: bondType // element: bondStereo /** The cyclic nature of a bond. * This is an assertion by a human or program about the * cyclic nature of a bond. It need not correspond to what is deducible from the * connection table (e.g. a bond in a ring might be labelled as 'acyclic' * or 'unknown') * @param bondStereo child to add */ public void addBondStereo(AbstractBondStereo bondStereo) { bondStereo.detach(); this.appendChild(bondStereo); } /** The cyclic nature of a bond. * This is an assertion by a human or program about the * cyclic nature of a bond. It need not correspond to what is deducible from the * connection table (e.g. a bond in a ring might be labelled as 'acyclic' * or 'unknown') * @return CMLElements<CMLBondStereo> */ public CMLElements getBondStereoElements() { Elements elements = this.getChildElements("bondStereo", 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("atomRefs2")) { setAtomRefs2(value); } else if (name.equals("atomRefs")) { setAtomRefs(value); } else if (name.equals("bondRefs")) { setBondRefs(value); } else if (name.equals("order")) { setOrder(value); } else if (name.equals("cyclic")) { setCyclic(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractBondArray.java000077500000000000000000000504441477224461000274070ustar00rootroot00000000000000/** * 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.StringArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractBondArray extends CMLElement { /** local name*/ public final static String TAG = "bondArray"; /** constructor. */ public AbstractBondArray() { super("bondArray"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractBondArray(AbstractBondArray 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", "bondArray"); 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", "bondArray"); 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", "bondArray"); 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", "bondArray"); 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: bondID /** cache */ StringArraySTAttribute _att_bondid = null; /** The IDs for an array of bond. * No description * @return CMLAttribute */ public CMLAttribute getBondIDAttribute() { return (CMLAttribute) getAttribute("bondID"); } /** The IDs for an array of bond. * No description * @return String[] */ public String[] getBondID() { StringArraySTAttribute att = (StringArraySTAttribute) this.getBondIDAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** The IDs for an array of bond. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setBondID(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_bondid == null) { _att_bondid = (StringArraySTAttribute) attributeFactory.getAttribute("bondID", "bondArray"); if (_att_bondid == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : bondID probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_bondid); super.addRemove(att, value); } /** The IDs for an array of bond. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setBondID(String[] value) throws RuntimeException { if (_att_bondid == null) { _att_bondid = (StringArraySTAttribute) attributeFactory.getAttribute("bondID", "bondArray"); if (_att_bondid == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : bondID probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_bondid); super.addAttribute(att); att.setCMLValue(value); } // attribute: atomRef1 /** cache */ StringArraySTAttribute _att_atomref1 = null; /** The first atoms in each bond. * Currently only used in bondArray in CML2 array mode. * @return CMLAttribute */ public CMLAttribute getAtomRef1Attribute() { return (CMLAttribute) getAttribute("atomRef1"); } /** The first atoms in each bond. * Currently only used in bondArray in CML2 array mode. * @return String[] */ public String[] getAtomRef1() { StringArraySTAttribute att = (StringArraySTAttribute) this.getAtomRef1Attribute(); if (att == null) { return null; } return att.getStringArray(); } /** The first atoms in each bond. * Currently only used in bondArray in CML2 array mode. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRef1(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_atomref1 == null) { _att_atomref1 = (StringArraySTAttribute) attributeFactory.getAttribute("atomRef1", "bondArray"); if (_att_atomref1 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRef1 probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_atomref1); super.addRemove(att, value); } /** The first atoms in each bond. * Currently only used in bondArray in CML2 array mode. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRef1(String[] value) throws RuntimeException { if (_att_atomref1 == null) { _att_atomref1 = (StringArraySTAttribute) attributeFactory.getAttribute("atomRef1", "bondArray"); if (_att_atomref1 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRef1 probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_atomref1); super.addAttribute(att); att.setCMLValue(value); } // attribute: atomRef2 /** cache */ StringArraySTAttribute _att_atomref2 = null; /** The second atoms in each bond. * No description * @return CMLAttribute */ public CMLAttribute getAtomRef2Attribute() { return (CMLAttribute) getAttribute("atomRef2"); } /** The second atoms in each bond. * No description * @return String[] */ public String[] getAtomRef2() { StringArraySTAttribute att = (StringArraySTAttribute) this.getAtomRef2Attribute(); if (att == null) { return null; } return att.getStringArray(); } /** The second atoms in each bond. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRef2(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_atomref2 == null) { _att_atomref2 = (StringArraySTAttribute) attributeFactory.getAttribute("atomRef2", "bondArray"); if (_att_atomref2 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRef2 probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_atomref2); super.addRemove(att, value); } /** The second atoms in each bond. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRef2(String[] value) throws RuntimeException { if (_att_atomref2 == null) { _att_atomref2 = (StringArraySTAttribute) attributeFactory.getAttribute("atomRef2", "bondArray"); if (_att_atomref2 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRef2 probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_atomref2); super.addAttribute(att); att.setCMLValue(value); } // attribute: order /** cache */ StringArraySTAttribute _att_order = null; /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @return CMLAttribute */ public CMLAttribute getOrderAttribute() { return (CMLAttribute) getAttribute("order"); } /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @return String[] */ public String[] getOrder() { StringArraySTAttribute att = (StringArraySTAttribute) this.getOrderAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setOrder(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_order == null) { _att_order = (StringArraySTAttribute) attributeFactory.getAttribute("order", "bondArray"); if (_att_order == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : order probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_order); super.addRemove(att, value); } /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setOrder(String[] value) throws RuntimeException { if (_att_order == null) { _att_order = (StringArraySTAttribute) attributeFactory.getAttribute("order", "bondArray"); if (_att_order == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : order probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_order); super.addAttribute(att); att.setCMLValue(value); } // element: bond /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @param bond child to add */ public void addBond(AbstractBond bond) { bond.detach(); this.appendChild(bond); } /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @return CMLElements<CMLBond> */ public CMLElements getBondElements() { Elements elements = this.getChildElements("bond", CMLConstants.CML_NS); return new CMLElements(elements); } // element: array /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @param array child to add */ public void addArray(AbstractArray array) { array.detach(); this.appendChild(array); } /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @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("bondID")) { setBondID(value); } else if (name.equals("atomRef1")) { setAtomRef1(value); } else if (name.equals("atomRef2")) { setAtomRef2(value); } else if (name.equals("order")) { setOrder(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractBondSet.java000077500000000000000000000335531477224461000270660ustar00rootroot00000000000000/** * 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 AbstractBondSet extends CMLElement { /** local name*/ public final static String TAG = "bondSet"; /** constructor. */ public AbstractBondSet() { super("bondSet"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractBondSet(AbstractBondSet 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", "bondSet"); 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", "bondSet"); 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", "bondSet"); 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", "bondSet"); 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", "bondSet"); 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", "bondSet"); 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 references to bonds. * The references cannot (yet) * cannot be schema- or schematron-validated. Instances of this type will * be used in array-style representation of electron counts, etc. * It can also be used for arrays of bondIDTypes such as in complex stereochemistry, * geometrical definitions, bond 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 references to bonds. * The references cannot (yet) * cannot be schema- or schematron-validated. Instances of this type will * be used in array-style representation of electron counts, etc. * It can also be used for arrays of bondIDTypes such as in complex stereochemistry, * geometrical definitions, bond 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 references to bonds. * The references cannot (yet) * cannot be schema- or schematron-validated. Instances of this type will * be used in array-style representation of electron counts, etc. * It can also be used for arrays of bondIDTypes such as in complex stereochemistry, * geometrical definitions, bond 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/AbstractBondStereo.java000077500000000000000000000433441477224461000275730ustar00rootroot00000000000000/** * 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.StringArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractBondStereo extends CMLElement { /** local name*/ public final static String TAG = "bondStereo"; /** constructor. */ public AbstractBondStereo() { super("bondStereo"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractBondStereo(AbstractBondStereo old) { super((CMLElement) old); } // 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", "bondStereo"); 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", "bondStereo"); 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); } // attribute: atomRefArray /** cache */ StringArraySTAttribute _att_atomrefarray = null; /** An array of references to atoms. * Typical use would be to atoms defining a plane. * @return CMLAttribute */ public CMLAttribute getAtomRefArrayAttribute() { return (CMLAttribute) getAttribute("atomRefArray"); } /** An array of references to atoms. * Typical use would be to atoms defining a plane. * @return String[] */ public String[] getAtomRefArray() { StringArraySTAttribute att = (StringArraySTAttribute) this.getAtomRefArrayAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** An array of references to atoms. * Typical use would be to atoms defining a plane. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefArray(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_atomrefarray == null) { _att_atomrefarray = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefArray", "bondStereo"); if (_att_atomrefarray == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefArray probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_atomrefarray); super.addRemove(att, value); } /** An array of references to atoms. * Typical use would be to atoms defining a plane. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefArray(String[] value) throws RuntimeException { if (_att_atomrefarray == null) { _att_atomrefarray = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefArray", "bondStereo"); if (_att_atomrefarray == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefArray probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_atomrefarray); 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", "bondStereo"); 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", "bondStereo"); 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", "bondStereo"); 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", "bondStereo"); 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: conventionValue /** cache */ StringSTAttribute _att_conventionvalue = null; /** The value of an element with a _convention_. * When convention is used this attribute must be present and element content must be empty. * @return CMLAttribute */ public CMLAttribute getConventionValueAttribute() { return (CMLAttribute) getAttribute("conventionValue"); } /** The value of an element with a _convention_. * When convention is used this attribute must be present and element content must be empty. * @return String */ public String getConventionValue() { StringSTAttribute att = (StringSTAttribute) this.getConventionValueAttribute(); if (att == null) { return null; } return att.getString(); } /** The value of an element with a _convention_. * When convention is used this attribute must be present and element content must be empty. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setConventionValue(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_conventionvalue == null) { _att_conventionvalue = (StringSTAttribute) attributeFactory.getAttribute("conventionValue", "bondStereo"); if (_att_conventionvalue == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : conventionValue probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_conventionvalue); super.addRemove(att, value); } StringSTAttribute _xmlContent; /** Bond stereochemistry as a string. * This is purely conventional. There is no default value. * The emptyString attribute can be used to indicate a bond of * unknown or unspecified type. The interpretation of this is outside * the scope of CML-based algorithms. It may be accompanied by a convention * attribute which links to a dictionary. * @return String */ public String getXMLContent() { String content = this.getValue(); if (_xmlContent == null) { _xmlContent = new StringSTAttribute("_xmlContent"); } _xmlContent.setCMLValue(content); return _xmlContent.getString(); } /** Bond stereochemistry as a string. * This is purely conventional. There is no default value. * The emptyString attribute can be used to indicate a bond of * unknown or unspecified type. The interpretation of this is outside * the scope of CML-based algorithms. It may be accompanied by a convention * attribute which links to a dictionary. * @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("atomRefs4")) { setAtomRefs4(value); } else if (name.equals("atomRefArray")) { setAtomRefArray(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 if (name.equals("conventionValue")) { setConventionValue(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractBondType.java000077500000000000000000000366361477224461000272610ustar00rootroot00000000000000/** * 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 AbstractBondType extends CMLElement { /** local name*/ public final static String TAG = "bondType"; /** constructor. */ public AbstractBondType() { super("bondType"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractBondType(AbstractBondType 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", "bondType"); 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", "bondType"); 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: 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", "bondType"); 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", "bondType"); 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", "bondType"); 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", "bondType"); 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: bond /** null * @param bond child to add */ public void addBond(AbstractBond bond) { bond.detach(); this.appendChild(bond); } /** null * @return CMLElements<CMLBond> */ public CMLElements getBondElements() { Elements elements = this.getChildElements("bond", 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("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/AbstractBondTypeList.java000077500000000000000000000301241477224461000300770ustar00rootroot00000000000000/** * 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 AbstractBondTypeList extends CMLElement { /** local name*/ public final static String TAG = "bondTypeList"; /** constructor. */ public AbstractBondTypeList() { super("bondTypeList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractBondTypeList(AbstractBondTypeList 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", "bondTypeList"); 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", "bondTypeList"); 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", "bondTypeList"); 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", "bondTypeList"); 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", "bondTypeList"); 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: bondType /** null * @param bondType child to add */ public void addBondType(AbstractBondType bondType) { bondType.detach(); this.appendChild(bondType); } /** null * @return CMLElements<CMLBondType> */ public CMLElements getBondTypeElements() { Elements elements = this.getChildElements("bondType", 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/AbstractCellParameter.java000077500000000000000000000373411477224461000302470ustar00rootroot00000000000000/** * 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.DoubleArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractCellParameter extends CMLElement { /** local name*/ public final static String TAG = "cellParameter"; /** constructor. */ public AbstractCellParameter() { super("cellParameter"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractCellParameter(AbstractCellParameter old) { super((CMLElement) old); } // 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", "cellParameter"); 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", "cellParameter"); 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: 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", "cellParameter"); 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: 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", "cellParameter"); 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: 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", "cellParameter"); 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: type /** cache */ StringSTAttribute _att_type = null; /** The type of a cellParameter. * length or angle * @return CMLAttribute */ public CMLAttribute getTypeAttribute() { return (CMLAttribute) getAttribute("type"); } /** The type of a cellParameter. * length or angle * @return String */ public String getType() { StringSTAttribute att = (StringSTAttribute) this.getTypeAttribute(); if (att == null) { return null; } return att.getString(); } /** The type of a cellParameter. * length or angle * @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", "cellParameter"); 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: error /** cache */ DoubleArraySTAttribute _att_error = null; /** Error array for cellParameter. * 3 numbers giving error limits on paremters. * @return CMLAttribute */ public CMLAttribute getErrorAttribute() { return (CMLAttribute) getAttribute("error"); } /** Error array for cellParameter. * 3 numbers giving error limits on paremters. * @return double[] */ public double[] getError() { DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getErrorAttribute(); if (att == null) { return null; } return att.getDoubleArray(); } /** Error array for cellParameter. * 3 numbers giving error limits on paremters. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setError(String value) throws RuntimeException { DoubleArraySTAttribute att = null; if (_att_error == null) { _att_error = (DoubleArraySTAttribute) attributeFactory.getAttribute("error", "cellParameter"); if (_att_error == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : error probably incompatible attributeGroupName and attributeName"); } } att = new DoubleArraySTAttribute(_att_error); super.addRemove(att, value); } /** Error array for cellParameter. * 3 numbers giving error limits on paremters. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setError(double[] value) throws RuntimeException { if (_att_error == null) { _att_error = (DoubleArraySTAttribute) attributeFactory.getAttribute("error", "cellParameter"); if (_att_error == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : error probably incompatible attributeGroupName and attributeName "); } } DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_error); super.addAttribute(att); att.setCMLValue(value); } DoubleArraySTAttribute _xmlContent; /** A vector in 3-space. * No constraints on magnitude (i.e. could be zero. * @return double[] */ public double[] getXMLContent() { String content = this.getValue(); if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(content); return _xmlContent.getDoubleArray(); } /** A vector in 3-space. * No constraints on magnitude (i.e. could be zero. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(String value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(value); String attval = _xmlContent.getValue(); this.removeChildren(); this.appendChild(attval); } /** A vector in 3-space. * No constraints on magnitude (i.e. could be zero. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(double[] value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_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("convention")) { setConvention(value); } else if (name.equals("dictRef")) { setDictRef(value); } else if (name.equals("id")) { setId(value); } else if (name.equals("title")) { setTitle(value); } else if (name.equals("units")) { setUnits(value); } else if (name.equals("type")) { setType(value); } else if (name.equals("error")) { setError(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractCml.java000077500000000000000000000340331477224461000262350ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractCml extends CMLElement { /** local name*/ public final static String TAG = "cml"; /** constructor. */ public AbstractCml() { super("cml"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractCml(AbstractCml 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", "cml"); 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", "cml"); 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", "cml"); 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", "cml"); 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: fileId /** cache */ StringSTAttribute _att_fileid = null; /** Information identifying the name of a file or other resource. * This allows an element (such as cml) to carry limited * information about provenance such as the name of the document used to provide the * content. It is not a complete solution but can help to protect a document becoming * separated from its external metadata. It is restricted to the basic XML character set * (printable ANSI) and whitespace (which should anyway be discouraged) is normalized to * single space (attribute values cannot carry newlines). * Quotation marks and other horrors (as used in some OS) * should be avoided. * @return CMLAttribute */ public CMLAttribute getFileIdAttribute() { return (CMLAttribute) getAttribute("fileId"); } /** Information identifying the name of a file or other resource. * This allows an element (such as cml) to carry limited * information about provenance such as the name of the document used to provide the * content. It is not a complete solution but can help to protect a document becoming * separated from its external metadata. It is restricted to the basic XML character set * (printable ANSI) and whitespace (which should anyway be discouraged) is normalized to * single space (attribute values cannot carry newlines). * Quotation marks and other horrors (as used in some OS) * should be avoided. * @return String */ public String getFileId() { StringSTAttribute att = (StringSTAttribute) this.getFileIdAttribute(); if (att == null) { return null; } return att.getString(); } /** Information identifying the name of a file or other resource. * This allows an element (such as cml) to carry limited * information about provenance such as the name of the document used to provide the * content. It is not a complete solution but can help to protect a document becoming * separated from its external metadata. It is restricted to the basic XML character set * (printable ANSI) and whitespace (which should anyway be discouraged) is normalized to * single space (attribute values cannot carry newlines). * Quotation marks and other horrors (as used in some OS) * should be avoided. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setFileId(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_fileid == null) { _att_fileid = (StringSTAttribute) attributeFactory.getAttribute("fileId", "cml"); if (_att_fileid == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : fileId probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_fileid); super.addRemove(att, value); } // attribute: version /** cache */ StringSTAttribute _att_version = null; /** The version of the element. * No description * @return CMLAttribute */ public CMLAttribute getVersionAttribute() { return (CMLAttribute) getAttribute("version"); } /** The version of the element. * No description * @return String */ public String getVersion() { StringSTAttribute att = (StringSTAttribute) this.getVersionAttribute(); if (att == null) { return null; } return att.getString(); } /** The version of the element. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setVersion(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_version == null) { _att_version = (StringSTAttribute) attributeFactory.getAttribute("version", "cml"); if (_att_version == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : version probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_version); 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("fileId")) { setFileId(value); } else if (name.equals("version")) { setVersion(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractComplexObject.java000077500000000000000000000225401477224461000302600ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractComplexObject extends CMLElement { /** local name*/ public final static String TAG = "complexObject"; /** constructor. */ public AbstractComplexObject() { super("complexObject"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractComplexObject(AbstractComplexObject 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", "complexObject"); 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", "complexObject"); 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", "complexObject"); 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", "complexObject"); 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); } /** 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 { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractConditionList.java000077500000000000000000000356141477224461000303120ustar00rootroot00000000000000/** * 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 AbstractConditionList extends CMLElement { /** local name*/ public final static String TAG = "conditionList"; /** constructor. */ public AbstractConditionList() { super("conditionList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractConditionList(AbstractConditionList 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", "conditionList"); 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", "conditionList"); 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", "conditionList"); 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", "conditionList"); 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", "conditionList"); 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: 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", "conditionList"); 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); } // element: metadataList /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: name /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param name child to add */ public void addName(AbstractName name) { name.detach(); this.appendChild(name); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLName> */ public CMLElements getNameElements() { Elements elements = this.getChildElements("name", CMLConstants.CML_NS); return new CMLElements(elements); } // element: scalar /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param scalar child to add */ public void addScalar(AbstractScalar scalar) { scalar.detach(); this.appendChild(scalar); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLScalar> */ public CMLElements getScalarElements() { Elements elements = this.getChildElements("scalar", CMLConstants.CML_NS); return new CMLElements(elements); } // element: list /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param list child to add */ public void addList(AbstractList list) { list.detach(); this.appendChild(list); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @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("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 if (name.equals("role")) { setRole(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractCrystal.java000077500000000000000000000322621477224461000271450ustar00rootroot00000000000000/** * 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 AbstractCrystal extends CMLElement { /** local name*/ public final static String TAG = "crystal"; /** constructor. */ public AbstractCrystal() { super("crystal"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractCrystal(AbstractCrystal old) { super((CMLElement) old); } // attribute: z /** cache */ IntSTAttribute _att_z = null; /** The number of molecules per cell. * Molecules are defined as the _molecule_ which directly contains the _crystal_ element. * @return CMLAttribute */ public CMLAttribute getZAttribute() { return (CMLAttribute) getAttribute("z"); } /** The number of molecules per cell. * Molecules are defined as the _molecule_ which directly contains the _crystal_ element. * @return int */ public int getZ() { IntSTAttribute att = (IntSTAttribute) this.getZAttribute(); if (att == null) { throw new RuntimeException("int attribute is unset: z"); } return att.getInt(); } /** The number of molecules per cell. * Molecules are defined as the _molecule_ which directly contains the _crystal_ element. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setZ(String value) throws RuntimeException { IntSTAttribute att = null; if (_att_z == null) { _att_z = (IntSTAttribute) attributeFactory.getAttribute("z", "crystal"); if (_att_z == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : z probably incompatible attributeGroupName and attributeName"); } } att = new IntSTAttribute(_att_z); super.addRemove(att, value); } /** The number of molecules per cell. * Molecules are defined as the _molecule_ which directly contains the _crystal_ element. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setZ(int value) throws RuntimeException { if (_att_z == null) { _att_z = (IntSTAttribute) attributeFactory.getAttribute("z", "crystal"); if (_att_z == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : z probably incompatible attributeGroupName and attributeName "); } } IntSTAttribute att = new IntSTAttribute(_att_z); 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", "crystal"); 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", "crystal"); 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", "crystal"); 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", "crystal"); 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: 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: cellParameter /** null * @param cellParameter child to add */ public void addCellParameter(AbstractCellParameter cellParameter) { cellParameter.detach(); this.appendChild(cellParameter); } /** null * @return CMLElements<CMLCellParameter> */ public CMLElements getCellParameterElements() { Elements elements = this.getChildElements("cellParameter", CMLConstants.CML_NS); return new CMLElements(elements); } // element: symmetry /** null * @param symmetry child to add */ public void addSymmetry(AbstractSymmetry symmetry) { symmetry.detach(); this.appendChild(symmetry); } /** null * @return CMLElements<CMLSymmetry> */ public CMLElements getSymmetryElements() { Elements elements = this.getChildElements("symmetry", 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("z")) { setZ(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/AbstractDictionary.java000077500000000000000000000533031477224461000276300ustar00rootroot00000000000000/** * 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 AbstractDictionary extends CMLElement { /** local name*/ public final static String TAG = "dictionary"; /** constructor. */ public AbstractDictionary() { super("dictionary"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractDictionary(AbstractDictionary 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", "dictionary"); 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", "dictionary"); 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", "dictionary"); 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", "dictionary"); 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: href /** cache */ StringSTAttribute _att_href = null; /** address of a resource. * Links to another element in the same or other file. For dictionary/@dictRef requires the prefix and the physical URI * address to be contained within the same file. We can anticipate that * better mechanisms will arise - perhaps through XMLCatalogs. * At least it works at present. * @return CMLAttribute */ public CMLAttribute getHrefAttribute() { return (CMLAttribute) getAttribute("href"); } /** address of a resource. * Links to another element in the same or other file. For dictionary/@dictRef requires the prefix and the physical URI * address to be contained within the same file. We can anticipate that * better mechanisms will arise - perhaps through XMLCatalogs. * At least it works at present. * @return String */ public String getHref() { StringSTAttribute att = (StringSTAttribute) this.getHrefAttribute(); if (att == null) { return null; } return att.getString(); } /** address of a resource. * Links to another element in the same or other file. For dictionary/@dictRef requires the prefix and the physical URI * address to be contained within the same file. We can anticipate that * better mechanisms will arise - perhaps through XMLCatalogs. * At least it works at present. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setHref(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_href == null) { _att_href = (StringSTAttribute) attributeFactory.getAttribute("href", "dictionary"); if (_att_href == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : href probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_href); super.addRemove(att, value); } // attribute: namespace /** cache */ StringSTAttribute _att_namespace = null; /** The namespace for a data item. * The namespace is associated with elements such as dictionaries * and units and allows them to be referenced through free namespace prefixes. * @return CMLAttribute */ public CMLAttribute getNamespaceAttribute() { return (CMLAttribute) getAttribute("namespace"); } /** The namespace for a data item. * The namespace is associated with elements such as dictionaries * and units and allows them to be referenced through free namespace prefixes. * @return String */ public String getNamespace() { StringSTAttribute att = (StringSTAttribute) this.getNamespaceAttribute(); if (att == null) { return null; } return att.getString(); } /** The namespace for a data item. * The namespace is associated with elements such as dictionaries * and units and allows them to be referenced through free namespace prefixes. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setNamespace(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_namespace == null) { _att_namespace = (StringSTAttribute) attributeFactory.getAttribute("namespace", "dictionary"); if (_att_namespace == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : namespace probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_namespace); super.addRemove(att, value); } // attribute: dictionaryPrefix /** cache */ StringSTAttribute _att_dictionaryprefix = null; /** The namespacePrefix for a data item. * The dictionaryPrefix is associated with elements * such as dictionaries and units and allows them to be referenced namespaces. * The dictionaryPrefix is normally unbound but it may be necessary to hardcode them * occasionally. Thus if a value is fixed (e.g. "xsd:double") the prefix must * be identified and fixed. * @return CMLAttribute */ public CMLAttribute getDictionaryPrefixAttribute() { return (CMLAttribute) getAttribute("dictionaryPrefix"); } /** The namespacePrefix for a data item. * The dictionaryPrefix is associated with elements * such as dictionaries and units and allows them to be referenced namespaces. * The dictionaryPrefix is normally unbound but it may be necessary to hardcode them * occasionally. Thus if a value is fixed (e.g. "xsd:double") the prefix must * be identified and fixed. * @return String */ public String getDictionaryPrefix() { StringSTAttribute att = (StringSTAttribute) this.getDictionaryPrefixAttribute(); if (att == null) { return null; } return att.getString(); } /** The namespacePrefix for a data item. * The dictionaryPrefix is associated with elements * such as dictionaries and units and allows them to be referenced namespaces. * The dictionaryPrefix is normally unbound but it may be necessary to hardcode them * occasionally. Thus if a value is fixed (e.g. "xsd:double") the prefix must * be identified and fixed. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setDictionaryPrefix(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_dictionaryprefix == null) { _att_dictionaryprefix = (StringSTAttribute) attributeFactory.getAttribute("dictionaryPrefix", "dictionary"); if (_att_dictionaryprefix == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : dictionaryPrefix probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_dictionaryprefix); super.addRemove(att, value); } // element: unitList // /** The namespacePrefix for a data item. // * The dictionaryPrefix is associated with elements // * such as dictionaries and units and allows them to be referenced namespaces. // * The dictionaryPrefix is normally unbound but it may be necessary to hardcode them // * occasionally. Thus if a value is fixed (e.g. "xsd:double") the prefix must // * be identified and fixed. // * @param unitList child to add // */ // public void addUnitList(AbstractUnitList unitList) { // unitList.detach(); // this.appendChild(unitList); // } // /** The namespacePrefix for a data item. // * The dictionaryPrefix is associated with elements // * such as dictionaries and units and allows them to be referenced namespaces. // * The dictionaryPrefix is normally unbound but it may be necessary to hardcode them // * occasionally. Thus if a value is fixed (e.g. "xsd:double") the prefix must // * be identified and fixed. // * @return CMLElements<CMLUnitList> // */ // public CMLElements getUnitListElements() { // Elements elements = this.getChildElements("unitList", CMLConstants.CML_NS); // return new CMLElements(elements); // } // element: annotation // /** The namespacePrefix for a data item. // * The dictionaryPrefix is associated with elements // * such as dictionaries and units and allows them to be referenced namespaces. // * The dictionaryPrefix is normally unbound but it may be necessary to hardcode them // * occasionally. Thus if a value is fixed (e.g. "xsd:double") the prefix must // * be identified and fixed. // * @param annotation child to add // */ // public void addAnnotation(AbstractAnnotation annotation) { // annotation.detach(); // this.appendChild(annotation); // } // /** The namespacePrefix for a data item. // * The dictionaryPrefix is associated with elements // * such as dictionaries and units and allows them to be referenced namespaces. // * The dictionaryPrefix is normally unbound but it may be necessary to hardcode them // * occasionally. Thus if a value is fixed (e.g. "xsd:double") the prefix must // * be identified and fixed. // * @return CMLElements<CMLAnnotation> // */ // public CMLElements getAnnotationElements() { // Elements elements = this.getChildElements("annotation", CMLConstants.CML_NS); // return new CMLElements(elements); // } // element: description // /** The namespacePrefix for a data item. // * The dictionaryPrefix is associated with elements // * such as dictionaries and units and allows them to be referenced namespaces. // * The dictionaryPrefix is normally unbound but it may be necessary to hardcode them // * occasionally. Thus if a value is fixed (e.g. "xsd:double") the prefix must // * be identified and fixed. // * @param description child to add // */ // public void addDescription(AbstractDescription description) { // description.detach(); // this.appendChild(description); // } // /** The namespacePrefix for a data item. // * The dictionaryPrefix is associated with elements // * such as dictionaries and units and allows them to be referenced namespaces. // * The dictionaryPrefix is normally unbound but it may be necessary to hardcode them // * occasionally. Thus if a value is fixed (e.g. "xsd:double") the prefix must // * be identified and fixed. // * @return CMLElements<CMLDescription> // */ // public CMLElements getDescriptionElements() { // Elements elements = this.getChildElements("description", CMLConstants.CML_NS); // return new CMLElements(elements); // } // element: entry /** The namespacePrefix for a data item. * The dictionaryPrefix is associated with elements * such as dictionaries and units and allows them to be referenced namespaces. * The dictionaryPrefix is normally unbound but it may be necessary to hardcode them * occasionally. Thus if a value is fixed (e.g. "xsd:double") the prefix must * be identified and fixed. * @param entry child to add */ public void addEntry(AbstractEntry entry) { entry.detach(); this.appendChild(entry); } /** The namespacePrefix for a data item. * The dictionaryPrefix is associated with elements * such as dictionaries and units and allows them to be referenced namespaces. * The dictionaryPrefix is normally unbound but it may be necessary to hardcode them * occasionally. Thus if a value is fixed (e.g. "xsd:double") the prefix must * be identified and fixed. * @return CMLElements<CMLEntry> */ public CMLElements getEntryElements() { Elements elements = this.getChildElements("entry", 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("href")) { setHref(value); } else if (name.equals("namespace")) { setNamespace(value); } else if (name.equals("dictionaryPrefix")) { setDictionaryPrefix(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractEigen.java000077500000000000000000000374161477224461000265610ustar00rootroot00000000000000/** * 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.UnitsAttribute; 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 AbstractEigen extends CMLElement { /** local name*/ public final static String TAG = "eigen"; /** constructor. */ public AbstractEigen() { super("eigen"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractEigen(AbstractEigen old) { super((CMLElement) old); } // 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", "eigen"); 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: 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", "eigen"); 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", "eigen"); 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", "eigen"); 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", "eigen"); 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: 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", "eigen"); 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: orientation /** cache */ StringSTAttribute _att_orientation = null; /** The orientation of the eigenvector matrix. * Describes whether the vectors are columns or * rows. No default, so effectively mandatory unless you want to make implementers * guess and break applications. * @return CMLAttribute */ public CMLAttribute getOrientationAttribute() { return (CMLAttribute) getAttribute("orientation"); } /** The orientation of the eigenvector matrix. * Describes whether the vectors are columns or * rows. No default, so effectively mandatory unless you want to make implementers * guess and break applications. * @return String */ public String getOrientation() { StringSTAttribute att = (StringSTAttribute) this.getOrientationAttribute(); if (att == null) { return null; } return att.getString(); } /** The orientation of the eigenvector matrix. * Describes whether the vectors are columns or * rows. No default, so effectively mandatory unless you want to make implementers * guess and break applications. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setOrientation(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_orientation == null) { _att_orientation = (StringSTAttribute) attributeFactory.getAttribute("orientation", "eigen"); if (_att_orientation == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : orientation probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_orientation); super.addRemove(att, value); } // element: array /** The orientation of the eigenvector matrix. * Describes whether the vectors are columns or * rows. No default, so effectively mandatory unless you want to make implementers * guess and break applications. * @param array child to add */ public void addArray(AbstractArray array) { array.detach(); this.appendChild(array); } /** The orientation of the eigenvector matrix. * Describes whether the vectors are columns or * rows. No default, so effectively mandatory unless you want to make implementers * guess and break applications. * @return CMLElements<CMLArray> */ public CMLElements getArrayElements() { Elements elements = this.getChildElements("array", CMLConstants.CML_NS); return new CMLElements(elements); } // element: matrix /** The orientation of the eigenvector matrix. * Describes whether the vectors are columns or * rows. No default, so effectively mandatory unless you want to make implementers * guess and break applications. * @param matrix child to add */ public void addMatrix(AbstractMatrix matrix) { matrix.detach(); this.appendChild(matrix); } /** The orientation of the eigenvector matrix. * Describes whether the vectors are columns or * rows. No default, so effectively mandatory unless you want to make implementers * guess and break applications. * @return CMLElements<CMLMatrix> */ public CMLElements getMatrixElements() { Elements elements = this.getChildElements("matrix", 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("units")) { setUnits(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 if (name.equals("type")) { setType(value); } else if (name.equals("orientation")) { setOrientation(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractElectron.java000077500000000000000000000507231477224461000273010ustar00rootroot00000000000000/** * 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.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 AbstractElectron extends CMLElement { /** local name*/ public final static String TAG = "electron"; /** constructor. */ public AbstractElectron() { super("electron"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractElectron(AbstractElectron 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", "electron"); 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", "electron"); 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", "electron"); 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", "electron"); 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: 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", "electron"); 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: atomRefs /** cache */ StringArraySTAttribute _att_atomrefs = null; /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @return CMLAttribute */ public CMLAttribute getAtomRefsAttribute() { return (CMLAttribute) getAttribute("atomRefs"); } /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @return String[] */ public String[] getAtomRefs() { StringArraySTAttribute att = (StringArraySTAttribute) this.getAtomRefsAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefs(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_atomrefs == null) { _att_atomrefs = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs", "electron"); if (_att_atomrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_atomrefs); super.addRemove(att, value); } /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefs(String[] value) throws RuntimeException { if (_att_atomrefs == null) { _att_atomrefs = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs", "electron"); if (_att_atomrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_atomrefs); super.addAttribute(att); att.setCMLValue(value); } // attribute: bondRef /** cache */ StringSTAttribute _att_bondref = null; /** A reference to a bond. * used by electron, etc. * @return CMLAttribute */ public CMLAttribute getBondRefAttribute() { return (CMLAttribute) getAttribute("bondRef"); } /** A reference to a bond. * used by electron, etc. * @return String */ public String getBondRef() { StringSTAttribute att = (StringSTAttribute) this.getBondRefAttribute(); if (att == null) { return null; } return att.getString(); } /** A reference to a bond. * used by electron, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setBondRef(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_bondref == null) { _att_bondref = (StringSTAttribute) attributeFactory.getAttribute("bondRef", "electron"); if (_att_bondref == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : bondRef probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_bondref); super.addRemove(att, value); } // attribute: bondRefs /** cache */ StringArraySTAttribute _att_bondrefs = null; /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @return CMLAttribute */ public CMLAttribute getBondRefsAttribute() { return (CMLAttribute) getAttribute("bondRefs"); } /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @return String[] */ public String[] getBondRefs() { StringArraySTAttribute att = (StringArraySTAttribute) this.getBondRefsAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setBondRefs(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_bondrefs == null) { _att_bondrefs = (StringArraySTAttribute) attributeFactory.getAttribute("bondRefs", "electron"); if (_att_bondrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : bondRefs probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_bondrefs); super.addRemove(att, value); } /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setBondRefs(String[] value) throws RuntimeException { if (_att_bondrefs == null) { _att_bondrefs = (StringArraySTAttribute) attributeFactory.getAttribute("bondRefs", "electron"); if (_att_bondrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : bondRefs probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_bondrefs); super.addAttribute(att); att.setCMLValue(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", "electron"); 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", "electron"); 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", "electron"); 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("atomRef")) { setAtomRef(value); } else if (name.equals("atomRefs")) { setAtomRefs(value); } else if (name.equals("bondRef")) { setBondRef(value); } else if (name.equals("bondRefs")) { setBondRefs(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/AbstractEntry.java000077500000000000000000001401341477224461000266230ustar00rootroot00000000000000/** * 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.IdAttribute; import org.xmlcml.cml.attribute.UnitTypeAttribute; 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.IntSTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractEntry extends CMLElement { /** local name*/ public final static String TAG = "entry"; /** constructor. */ public AbstractEntry() { super("entry"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractEntry(AbstractEntry 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", "entry"); 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", "entry"); 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", "entry"); 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: 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", "entry"); 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: rows /** cache */ IntSTAttribute _att_rows = null; /** Number of rows. * No description * @return CMLAttribute */ public CMLAttribute getRowsAttribute() { return (CMLAttribute) getAttribute("rows"); } /** Number of rows. * No description * @return int */ public int getRows() { IntSTAttribute att = (IntSTAttribute) this.getRowsAttribute(); if (att == null) { throw new RuntimeException("int attribute is unset: rows"); } return att.getInt(); } /** Number of rows. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setRows(String value) throws RuntimeException { IntSTAttribute att = null; if (_att_rows == null) { _att_rows = (IntSTAttribute) attributeFactory.getAttribute("rows", "entry"); if (_att_rows == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : rows probably incompatible attributeGroupName and attributeName"); } } att = new IntSTAttribute(_att_rows); super.addRemove(att, value); } /** Number of rows. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setRows(int value) throws RuntimeException { if (_att_rows == null) { _att_rows = (IntSTAttribute) attributeFactory.getAttribute("rows", "entry"); if (_att_rows == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : rows probably incompatible attributeGroupName and attributeName "); } } IntSTAttribute att = new IntSTAttribute(_att_rows); super.addAttribute(att); att.setCMLValue(value); } // attribute: columns /** cache */ IntSTAttribute _att_columns = null; /** Number of columns. * No description * @return CMLAttribute */ public CMLAttribute getColumnsAttribute() { return (CMLAttribute) getAttribute("columns"); } /** Number of columns. * No description * @return int */ public int getColumns() { IntSTAttribute att = (IntSTAttribute) this.getColumnsAttribute(); if (att == null) { throw new RuntimeException("int attribute is unset: columns"); } return att.getInt(); } /** Number of columns. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setColumns(String value) throws RuntimeException { IntSTAttribute att = null; if (_att_columns == null) { _att_columns = (IntSTAttribute) attributeFactory.getAttribute("columns", "entry"); if (_att_columns == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : columns probably incompatible attributeGroupName and attributeName"); } } att = new IntSTAttribute(_att_columns); super.addRemove(att, value); } /** Number of columns. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setColumns(int value) throws RuntimeException { if (_att_columns == null) { _att_columns = (IntSTAttribute) attributeFactory.getAttribute("columns", "entry"); if (_att_columns == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : columns probably incompatible attributeGroupName and attributeName "); } } IntSTAttribute att = new IntSTAttribute(_att_columns); super.addAttribute(att); att.setCMLValue(value); } // attribute: unitType // /** cache */ // UnitTypeAttribute _att_unittype = null; // /** null // * @return CMLAttribute // */ // public CMLAttribute getUnitTypeAttribute() { // return (CMLAttribute) getAttribute("unitType"); // } // /** null // * @return String // */ // public String getUnitType() { // UnitTypeAttribute att = (UnitTypeAttribute) 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 { // UnitTypeAttribute att = null; // if (_att_unittype == null) { // _att_unittype = (UnitTypeAttribute) attributeFactory.getAttribute("unitType", "entry"); // if (_att_unittype == null) { // throw new RuntimeException("BUG: cannot process attributeGroupName : unitType probably incompatible attributeGroupName and attributeName"); // } // } // att = new UnitTypeAttribute(_att_unittype); // super.addRemove(att, value); // } // attribute: minExclusive /** cache */ DoubleSTAttribute _att_minexclusive = null; /** minimum exclusive value. * by analogy with xsd:schema. * @return CMLAttribute */ public CMLAttribute getMinExclusiveAttribute() { return (CMLAttribute) getAttribute("minExclusive"); } /** minimum exclusive value. * by analogy with xsd:schema. * @return double */ public double getMinExclusive() { DoubleSTAttribute att = (DoubleSTAttribute) this.getMinExclusiveAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** minimum exclusive value. * by analogy with xsd:schema. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMinExclusive(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_minexclusive == null) { _att_minexclusive = (DoubleSTAttribute) attributeFactory.getAttribute("minExclusive", "entry"); if (_att_minexclusive == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : minExclusive probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_minexclusive); super.addRemove(att, value); } /** minimum exclusive value. * by analogy with xsd:schema. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMinExclusive(double value) throws RuntimeException { if (_att_minexclusive == null) { _att_minexclusive = (DoubleSTAttribute) attributeFactory.getAttribute("minExclusive", "entry"); if (_att_minexclusive == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : minExclusive probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_minexclusive); super.addAttribute(att); att.setCMLValue(value); } // attribute: minInclusive /** cache */ DoubleSTAttribute _att_mininclusive = null; /** minimum inclusive value. * by analogy with xsd:schema. * @return CMLAttribute */ public CMLAttribute getMinInclusiveAttribute() { return (CMLAttribute) getAttribute("minInclusive"); } /** minimum inclusive value. * by analogy with xsd:schema. * @return double */ public double getMinInclusive() { DoubleSTAttribute att = (DoubleSTAttribute) this.getMinInclusiveAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** minimum inclusive value. * by analogy with xsd:schema. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMinInclusive(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_mininclusive == null) { _att_mininclusive = (DoubleSTAttribute) attributeFactory.getAttribute("minInclusive", "entry"); if (_att_mininclusive == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : minInclusive probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_mininclusive); super.addRemove(att, value); } /** minimum inclusive value. * by analogy with xsd:schema. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMinInclusive(double value) throws RuntimeException { if (_att_mininclusive == null) { _att_mininclusive = (DoubleSTAttribute) attributeFactory.getAttribute("minInclusive", "entry"); if (_att_mininclusive == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : minInclusive probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_mininclusive); super.addAttribute(att); att.setCMLValue(value); } // attribute: maxExclusive /** cache */ DoubleSTAttribute _att_maxexclusive = null; /** maximum exclusive value. * by analogy with xsd:schema. * @return CMLAttribute */ public CMLAttribute getMaxExclusiveAttribute() { return (CMLAttribute) getAttribute("maxExclusive"); } /** maximum exclusive value. * by analogy with xsd:schema. * @return double */ public double getMaxExclusive() { DoubleSTAttribute att = (DoubleSTAttribute) this.getMaxExclusiveAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** maximum exclusive value. * by analogy with xsd:schema. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMaxExclusive(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_maxexclusive == null) { _att_maxexclusive = (DoubleSTAttribute) attributeFactory.getAttribute("maxExclusive", "entry"); if (_att_maxexclusive == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : maxExclusive probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_maxexclusive); super.addRemove(att, value); } /** maximum exclusive value. * by analogy with xsd:schema. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMaxExclusive(double value) throws RuntimeException { if (_att_maxexclusive == null) { _att_maxexclusive = (DoubleSTAttribute) attributeFactory.getAttribute("maxExclusive", "entry"); if (_att_maxexclusive == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : maxExclusive probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_maxexclusive); super.addAttribute(att); att.setCMLValue(value); } // attribute: maxInclusive /** cache */ DoubleSTAttribute _att_maxinclusive = null; /** minimum inclusive value. * by analogy with xsd:schem. * @return CMLAttribute */ public CMLAttribute getMaxInclusiveAttribute() { return (CMLAttribute) getAttribute("maxInclusive"); } /** minimum inclusive value. * by analogy with xsd:schem. * @return double */ public double getMaxInclusive() { DoubleSTAttribute att = (DoubleSTAttribute) this.getMaxInclusiveAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** minimum inclusive value. * by analogy with xsd:schem. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMaxInclusive(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_maxinclusive == null) { _att_maxinclusive = (DoubleSTAttribute) attributeFactory.getAttribute("maxInclusive", "entry"); if (_att_maxinclusive == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : maxInclusive probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_maxinclusive); super.addRemove(att, value); } /** minimum inclusive value. * by analogy with xsd:schem. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMaxInclusive(double value) throws RuntimeException { if (_att_maxinclusive == null) { _att_maxinclusive = (DoubleSTAttribute) attributeFactory.getAttribute("maxInclusive", "entry"); if (_att_maxinclusive == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : maxInclusive probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_maxinclusive); super.addAttribute(att); att.setCMLValue(value); } // attribute: totalDigits /** cache */ IntSTAttribute _att_totaldigits = null; /** total digits in a scalar. * based on xsd:schema. * @return CMLAttribute */ public CMLAttribute getTotalDigitsAttribute() { return (CMLAttribute) getAttribute("totalDigits"); } /** total digits in a scalar. * based on xsd:schema. * @return int */ public int getTotalDigits() { IntSTAttribute att = (IntSTAttribute) this.getTotalDigitsAttribute(); if (att == null) { throw new RuntimeException("int attribute is unset: totalDigits"); } return att.getInt(); } /** total digits in a scalar. * based on xsd:schema. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setTotalDigits(String value) throws RuntimeException { IntSTAttribute att = null; if (_att_totaldigits == null) { _att_totaldigits = (IntSTAttribute) attributeFactory.getAttribute("totalDigits", "entry"); if (_att_totaldigits == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : totalDigits probably incompatible attributeGroupName and attributeName"); } } att = new IntSTAttribute(_att_totaldigits); super.addRemove(att, value); } /** total digits in a scalar. * based on xsd:schema. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setTotalDigits(int value) throws RuntimeException { if (_att_totaldigits == null) { _att_totaldigits = (IntSTAttribute) attributeFactory.getAttribute("totalDigits", "entry"); if (_att_totaldigits == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : totalDigits probably incompatible attributeGroupName and attributeName "); } } IntSTAttribute att = new IntSTAttribute(_att_totaldigits); super.addAttribute(att); att.setCMLValue(value); } // attribute: fractionDigits /** cache */ IntSTAttribute _att_fractiondigits = null; /** Number of digits after the point. * This is used in dictionaries to define precision. However it might be replaced by xsd:facet. * @return CMLAttribute */ public CMLAttribute getFractionDigitsAttribute() { return (CMLAttribute) getAttribute("fractionDigits"); } /** Number of digits after the point. * This is used in dictionaries to define precision. However it might be replaced by xsd:facet. * @return int */ public int getFractionDigits() { IntSTAttribute att = (IntSTAttribute) this.getFractionDigitsAttribute(); if (att == null) { throw new RuntimeException("int attribute is unset: fractionDigits"); } return att.getInt(); } /** Number of digits after the point. * This is used in dictionaries to define precision. However it might be replaced by xsd:facet. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setFractionDigits(String value) throws RuntimeException { IntSTAttribute att = null; if (_att_fractiondigits == null) { _att_fractiondigits = (IntSTAttribute) attributeFactory.getAttribute("fractionDigits", "entry"); if (_att_fractiondigits == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : fractionDigits probably incompatible attributeGroupName and attributeName"); } } att = new IntSTAttribute(_att_fractiondigits); super.addRemove(att, value); } /** Number of digits after the point. * This is used in dictionaries to define precision. However it might be replaced by xsd:facet. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setFractionDigits(int value) throws RuntimeException { if (_att_fractiondigits == null) { _att_fractiondigits = (IntSTAttribute) attributeFactory.getAttribute("fractionDigits", "entry"); if (_att_fractiondigits == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : fractionDigits probably incompatible attributeGroupName and attributeName "); } } IntSTAttribute att = new IntSTAttribute(_att_fractiondigits); super.addAttribute(att); att.setCMLValue(value); } // attribute: length /** cache */ IntSTAttribute _att_length = null; /** Length of an array or . * Probably will be replaced with xsd:schema tool. * * @return CMLAttribute */ public CMLAttribute getLengthAttribute() { return (CMLAttribute) getAttribute("length"); } /** Length of an array or . * Probably will be replaced with xsd:schema tool. * * @return int */ public int getLength() { IntSTAttribute att = (IntSTAttribute) this.getLengthAttribute(); if (att == null) { throw new RuntimeException("int attribute is unset: length"); } return att.getInt(); } /** Length of an array or . * Probably will be replaced with xsd:schema tool. * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setLength(String value) throws RuntimeException { IntSTAttribute att = null; if (_att_length == null) { _att_length = (IntSTAttribute) attributeFactory.getAttribute("length", "entry"); if (_att_length == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : length probably incompatible attributeGroupName and attributeName"); } } att = new IntSTAttribute(_att_length); super.addRemove(att, value); } /** Length of an array or . * Probably will be replaced with xsd:schema tool. * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setLength(int value) throws RuntimeException { if (_att_length == null) { _att_length = (IntSTAttribute) attributeFactory.getAttribute("length", "entry"); if (_att_length == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : length probably incompatible attributeGroupName and attributeName "); } } IntSTAttribute att = new IntSTAttribute(_att_length); super.addAttribute(att); att.setCMLValue(value); } // attribute: minLength /** cache */ IntSTAttribute _att_minlength = null; /** minimum length of a scalar. * by analogy with xsd:schema. * @return CMLAttribute */ public CMLAttribute getMinLengthAttribute() { return (CMLAttribute) getAttribute("minLength"); } /** minimum length of a scalar. * by analogy with xsd:schema. * @return int */ public int getMinLength() { IntSTAttribute att = (IntSTAttribute) this.getMinLengthAttribute(); if (att == null) { throw new RuntimeException("int attribute is unset: minLength"); } return att.getInt(); } /** minimum length of a scalar. * by analogy with xsd:schema. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMinLength(String value) throws RuntimeException { IntSTAttribute att = null; if (_att_minlength == null) { _att_minlength = (IntSTAttribute) attributeFactory.getAttribute("minLength", "entry"); if (_att_minlength == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : minLength probably incompatible attributeGroupName and attributeName"); } } att = new IntSTAttribute(_att_minlength); super.addRemove(att, value); } /** minimum length of a scalar. * by analogy with xsd:schema. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMinLength(int value) throws RuntimeException { if (_att_minlength == null) { _att_minlength = (IntSTAttribute) attributeFactory.getAttribute("minLength", "entry"); if (_att_minlength == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : minLength probably incompatible attributeGroupName and attributeName "); } } IntSTAttribute att = new IntSTAttribute(_att_minlength); super.addAttribute(att); att.setCMLValue(value); } // attribute: maxLength /** cache */ IntSTAttribute _att_maxlength = null; /** maximum length of a scalar. * by analogy with xsd:schem. * @return CMLAttribute */ public CMLAttribute getMaxLengthAttribute() { return (CMLAttribute) getAttribute("maxLength"); } /** maximum length of a scalar. * by analogy with xsd:schem. * @return int */ public int getMaxLength() { IntSTAttribute att = (IntSTAttribute) this.getMaxLengthAttribute(); if (att == null) { throw new RuntimeException("int attribute is unset: maxLength"); } return att.getInt(); } /** maximum length of a scalar. * by analogy with xsd:schem. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMaxLength(String value) throws RuntimeException { IntSTAttribute att = null; if (_att_maxlength == null) { _att_maxlength = (IntSTAttribute) attributeFactory.getAttribute("maxLength", "entry"); if (_att_maxlength == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : maxLength probably incompatible attributeGroupName and attributeName"); } } att = new IntSTAttribute(_att_maxlength); super.addRemove(att, value); } /** maximum length of a scalar. * by analogy with xsd:schem. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMaxLength(int value) throws RuntimeException { if (_att_maxlength == null) { _att_maxlength = (IntSTAttribute) attributeFactory.getAttribute("maxLength", "entry"); if (_att_maxlength == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : maxLength probably incompatible attributeGroupName and attributeName "); } } IntSTAttribute att = new IntSTAttribute(_att_maxlength); super.addAttribute(att); att.setCMLValue(value); } // attribute: units /** cache */ UnitsAttribute _att_units = null; /** null * @return CMLAttribute */ public CMLAttribute getUnitsAttribute() { return (CMLAttribute) getAttribute("units"); } /** Returns the value of the units attribute on the entry * @return String */ public String getUnits() { UnitsAttribute att = (UnitsAttribute) this.getUnitsAttribute(); if (att == null) { return null; } return att.getValue(); } /** 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", "entry"); 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: whiteSpace /** cache */ StringSTAttribute _att_whitespace = null; /** Whitespace. * Attached to entry. This may be obsolete. * @return CMLAttribute */ public CMLAttribute getWhiteSpaceAttribute() { return (CMLAttribute) getAttribute("whiteSpace"); } /** Whitespace. * Attached to entry. This may be obsolete. * @return String */ public String getWhiteSpace() { StringSTAttribute att = (StringSTAttribute) this.getWhiteSpaceAttribute(); if (att == null) { return null; } return att.getString(); } /** Whitespace. * Attached to entry. This may be obsolete. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setWhiteSpace(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_whitespace == null) { _att_whitespace = (StringSTAttribute) attributeFactory.getAttribute("whiteSpace", "entry"); if (_att_whitespace == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : whiteSpace probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_whitespace); super.addRemove(att, value); } // attribute: pattern /** cache */ StringSTAttribute _att_pattern = null; /** Pattern constraint. * Based on xsd:schema. * @return CMLAttribute */ public CMLAttribute getPatternAttribute() { return (CMLAttribute) getAttribute("pattern"); } /** Pattern constraint. * Based on xsd:schema. * @return String */ public String getPattern() { StringSTAttribute att = (StringSTAttribute) this.getPatternAttribute(); if (att == null) { return null; } return att.getString(); } /** Pattern constraint. * Based on xsd:schema. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPattern(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_pattern == null) { _att_pattern = (StringSTAttribute) attributeFactory.getAttribute("pattern", "entry"); if (_att_pattern == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : pattern probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_pattern); super.addRemove(att, value); } // attribute: term /** cache */ StringSTAttribute _att_term = null; /** A term in a dictionary. * The term should be a noun or nounal phrase, with a separate definition and further description. * @return CMLAttribute */ public CMLAttribute getTermAttribute() { return (CMLAttribute) getAttribute("term"); } /** A term in a dictionary. * The term should be a noun or nounal phrase, with a separate definition and further description. * @return String */ public String getTerm() { StringSTAttribute att = (StringSTAttribute) this.getTermAttribute(); if (att == null) { return null; } return att.getString(); } /** A term in a dictionary. * The term should be a noun or nounal phrase, with a separate definition and further description. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setTerm(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_term == null) { _att_term = (StringSTAttribute) attributeFactory.getAttribute("term", "entry"); if (_att_term == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : term probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_term); super.addRemove(att, value); } //// element: metadataList // // /** A term in a dictionary. // * The term should be a noun or nounal phrase, with a separate definition and further description. // * @param metadataList child to add // */ // public void addMetadataList(AbstractMetadataList metadataList) { // metadataList.detach(); // this.appendChild(metadataList); // } // /** A term in a dictionary. // * The term should be a noun or nounal phrase, with a separate definition and further description. // * @return CMLElements<CMLMetadataList> // */ // public CMLElements getMetadataListElements() { // Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); // return new CMLElements(elements); // } //// element: annotation // // /** A term in a dictionary. // * The term should be a noun or nounal phrase, with a separate definition and further description. // * @param annotation child to add // */ // public void addAnnotation(AbstractAnnotation annotation) { // annotation.detach(); // this.appendChild(annotation); // } // /** A term in a dictionary. // * The term should be a noun or nounal phrase, with a separate definition and further description. // * @return CMLElements<CMLAnnotation> // */ // public CMLElements getAnnotationElements() { // Elements elements = this.getChildElements("annotation", CMLConstants.CML_NS); // return new CMLElements(elements); // } //// element: definition // // /** A term in a dictionary. // * The term should be a noun or nounal phrase, with a separate definition and further description. // * @param definition child to add // */ // public void addDefinition(AbstractDefinition definition) { // definition.detach(); // this.appendChild(definition); // } // /** A term in a dictionary. // * The term should be a noun or nounal phrase, with a separate definition and further description. // * @return CMLElements<CMLDefinition> // */ // public CMLElements getDefinitionElements() { // Elements elements = this.getChildElements("definition", CMLConstants.CML_NS); // return new CMLElements(elements); // } //// element: description // // /** A term in a dictionary. // * The term should be a noun or nounal phrase, with a separate definition and further description. // * @param description child to add // */ // public void addDescription(AbstractDescription description) { // description.detach(); // this.appendChild(description); // } // /** A term in a dictionary. // * The term should be a noun or nounal phrase, with a separate definition and further description. // * @return CMLElements<CMLDescription> // */ // public CMLElements getDescriptionElements() { // Elements elements = this.getChildElements("description", CMLConstants.CML_NS); // return new CMLElements(elements); // } //// element: enumeration // // /** A term in a dictionary. // * The term should be a noun or nounal phrase, with a separate definition and further description. // * @param enumeration child to add // */ // public void addEnumeration(AbstractEnumeration enumeration) { // enumeration.detach(); // this.appendChild(enumeration); // } // /** A term in a dictionary. // * The term should be a noun or nounal phrase, with a separate definition and further description. // * @return CMLElements<CMLEnumeration> // */ // public CMLElements getEnumerationElements() { // Elements elements = this.getChildElements("enumeration", CMLConstants.CML_NS); // return new CMLElements(elements); // } //// element: unitType // // /** A term in a dictionary. // * The term should be a noun or nounal phrase, with a separate definition and further description. // * @param unitType child to add // */ // public void addUnitType(AbstractUnitType unitType) { // unitType.detach(); // this.appendChild(unitType); // } // /** A term in a dictionary. // * The term should be a noun or nounal phrase, with a separate definition and further description. // * @return CMLElements<CMLUnitType> // */ // public CMLElements getUnitTypeElements() { // Elements elements = this.getChildElements("unitType", CMLConstants.CML_NS); // return new CMLElements(elements); // } //// element: alternative // // /** A term in a dictionary. // * The term should be a noun or nounal phrase, with a separate definition and further description. // * @param alternative child to add // */ // public void addAlternative(AbstractAlternative alternative) { // alternative.detach(); // this.appendChild(alternative); // } // /** A term in a dictionary. // * The term should be a noun or nounal phrase, with a separate definition and further description. // * @return CMLElements<CMLAlternative> // */ // public CMLElements getAlternativeElements() { // Elements elements = this.getChildElements("alternative", CMLConstants.CML_NS); // return new CMLElements(elements); // } //// element: relatedEntry // // /** A term in a dictionary. // * The term should be a noun or nounal phrase, with a separate definition and further description. // * @param relatedEntry child to add // */ // public void addRelatedEntry(AbstractRelatedEntry relatedEntry) { // relatedEntry.detach(); // this.appendChild(relatedEntry); // } // /** A term in a dictionary. // * The term should be a noun or nounal phrase, with a separate definition and further description. // * @return CMLElements<CMLRelatedEntry> // */ // public CMLElements getRelatedEntryElements() { // Elements elements = this.getChildElements("relatedEntry", 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("dataType")) { setDataType(value); } else if (name.equals("rows")) { setRows(value); } else if (name.equals("columns")) { setColumns(value); } else if (name.equals("unitType")) { setUnitType(value); } else if (name.equals("minExclusive")) { setMinExclusive(value); } else if (name.equals("minInclusive")) { setMinInclusive(value); } else if (name.equals("maxExclusive")) { setMaxExclusive(value); } else if (name.equals("maxInclusive")) { setMaxInclusive(value); } else if (name.equals("totalDigits")) { setTotalDigits(value); } else if (name.equals("fractionDigits")) { setFractionDigits(value); } else if (name.equals("length")) { setLength(value); } else if (name.equals("minLength")) { setMinLength(value); } else if (name.equals("maxLength")) { setMaxLength(value); } else if (name.equals("units")) { setUnits(value); } else if (name.equals("whiteSpace")) { setWhiteSpace(value); } else if (name.equals("pattern")) { setPattern(value); } else if (name.equals("term")) { setTerm(value); } else { try { super.addAttribute(att); } catch (Exception e) { throw new RuntimeException("Bad attribute: " + att.getQualifiedName() + "/" + att.getValue()); } } } public void setUnitType(String value) { Attribute attribute = this.getAttribute(UnitTypeAttribute.NAME); if (attribute == null) { UnitTypeAttribute unitType = new UnitTypeAttribute(value); super.addAttribute(unitType); } else { attribute.setValue(value); } } public String getUnitType(){ UnitTypeAttribute attribute = (UnitTypeAttribute) this.getAttribute(UnitTypeAttribute.NAME); return attribute.getValue(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractExpression.java000077500000000000000000000310651477224461000276630ustar00rootroot00000000000000/** * 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 AbstractExpression extends CMLElement { /** local name*/ public final static String TAG = "expression"; /** constructor. */ public AbstractExpression() { super("expression"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractExpression(AbstractExpression 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", "expression"); 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", "expression"); 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", "expression"); 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", "expression"); 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", "expression"); 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); } // element: parameter /** The data type of the object. * Normally applied to scalar/array * objects but may extend to more complex one. * @param parameter child to add */ public void addParameter(AbstractParameter parameter) { parameter.detach(); this.appendChild(parameter); } /** The data type of the object. * Normally applied to scalar/array * objects but may extend to more complex one. * @return CMLElements<CMLParameter> */ public CMLElements getParameterElements() { Elements elements = this.getChildElements("parameter", CMLConstants.CML_NS); return new CMLElements(elements); } // element: operator /** The data type of the object. * Normally applied to scalar/array * objects but may extend to more complex one. * @param operator child to add */ public void addOperator(AbstractOperator operator) { operator.detach(); this.appendChild(operator); } /** The data type of the object. * Normally applied to scalar/array * objects but may extend to more complex one. * @return CMLElements<CMLOperator> */ public CMLElements getOperatorElements() { Elements elements = this.getChildElements("operator", 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("dataType")) { setDataType(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractFormula.java000077500000000000000000000452531477224461000271350ustar00rootroot00000000000000/** * 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.DoubleSTAttribute; import org.xmlcml.cml.base.IntSTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractFormula extends CMLElement { /** local name*/ public final static String TAG = "formula"; /** constructor. */ public AbstractFormula() { super("formula"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractFormula(AbstractFormula 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", "formula"); 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", "formula"); 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", "formula"); 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", "formula"); 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: 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", "formula"); 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", "formula"); 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: 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", "formula"); 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", "formula"); 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: concise /** cache */ StringSTAttribute _att_concise = null; /** A concise formula. * No description * @return CMLAttribute */ public CMLAttribute getConciseAttribute() { return (CMLAttribute) getAttribute("concise"); } /** A concise formula. * No description * @return String */ public String getConcise() { StringSTAttribute att = (StringSTAttribute) this.getConciseAttribute(); if (att == null) { return null; } return att.getString(); } /** A concise formula. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setConcise(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_concise == null) { _att_concise = (StringSTAttribute) attributeFactory.getAttribute("concise", "formula"); if (_att_concise == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : concise probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_concise); super.addRemove(att, value); } // attribute: inline /** cache */ StringSTAttribute _att_inline = null; /** An inline representation of the object. * No description * @return CMLAttribute */ public CMLAttribute getInlineAttribute() { return (CMLAttribute) getAttribute("inline"); } /** An inline representation of the object. * No description * @return String */ public String getInline() { StringSTAttribute att = (StringSTAttribute) this.getInlineAttribute(); if (att == null) { return null; } return att.getString(); } /** An inline representation of the object. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setInline(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_inline == null) { _att_inline = (StringSTAttribute) attributeFactory.getAttribute("inline", "formula"); if (_att_inline == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : inline probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_inline); super.addRemove(att, value); } // element: formula /** An inline representation of the object. * No description * @param formula child to add */ public void addFormula(AbstractFormula formula) { formula.detach(); this.appendChild(formula); } /** An inline representation of the object. * No description * @return CMLElements<CMLFormula> */ public CMLElements getFormulaElements() { Elements elements = this.getChildElements("formula", CMLConstants.CML_NS); return new CMLElements(elements); } // element: atomArray /** An inline representation of the object. * No description * @param atomArray child to add */ public void addAtomArray(AbstractAtomArray atomArray) { atomArray.detach(); this.appendChild(atomArray); } /** An inline representation of the object. * No description * @return CMLElements<CMLAtomArray> */ public CMLElements getAtomArrayElements() { Elements elements = this.getChildElements("atomArray", 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("count")) { setCount(value); } else if (name.equals("formalCharge")) { setFormalCharge(value); } else if (name.equals("concise")) { setConcise(value); } else if (name.equals("inline")) { setInline(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractFragment.java000077500000000000000000000400031477224461000272570ustar00rootroot00000000000000/** * 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.attribute.main.CountExpressionAttribute; 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 AbstractFragment extends CMLElement { /** local name*/ public final static String TAG = "fragment"; /** constructor. */ public AbstractFragment() { super("fragment"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractFragment(AbstractFragment 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", "fragment"); 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", "fragment"); 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", "fragment"); 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", "fragment"); 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", "fragment"); 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: 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", "fragment"); 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: countExpression /** cache */ StringSTAttribute _att_countexpression = null; /** null * @return CMLAttribute */ public CountExpressionAttribute getCountExpressionAttribute() { return (CountExpressionAttribute) getAttribute("countExpression"); } /** null * @return String */ public String getCountExpression() { CountExpressionAttribute att = (CountExpressionAttribute) this.getCountExpressionAttribute(); if (att == null) { return null; } return att.getString(); } /** null * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setCountExpression(String value) throws RuntimeException { CountExpressionAttribute att = null; if (_att_countexpression == null) { _att_countexpression = (StringSTAttribute) attributeFactory.getAttribute("countExpression", "fragment"); if (_att_countexpression == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : countExpression probably incompatible attributeGroupName and attributeName"); } } att = new CountExpressionAttribute(_att_countexpression); 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: 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: 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: fragmentList /** null * @param fragmentList child to add */ public void addFragmentList(AbstractFragmentList fragmentList) { fragmentList.detach(); this.appendChild(fragmentList); } /** null * @return CMLElements<CMLFragmentList> */ public CMLElements getFragmentListElements() { Elements elements = this.getChildElements("fragmentList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: join /** null * @param join child to add */ public void addJoin(AbstractJoin join) { join.detach(); this.appendChild(join); } /** null * @return CMLElements<CMLJoin> */ public CMLElements getJoinElements() { Elements elements = this.getChildElements("join", 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 if (name.equals("role")) { setRole(value); } else if (name.equals("countExpression")) { setCountExpression(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractFragmentList.java000077500000000000000000000356441477224461000301320ustar00rootroot00000000000000/** * 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 AbstractFragmentList extends CMLElement { /** local name*/ public final static String TAG = "fragmentList"; /** constructor. */ public AbstractFragmentList() { super("fragmentList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractFragmentList(AbstractFragmentList 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", "fragmentList"); 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", "fragmentList"); 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", "fragmentList"); 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", "fragmentList"); 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", "fragmentList"); 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: 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", "fragmentList"); 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); } // element: metadataList /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: join /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param join child to add */ public void addJoin(AbstractJoin join) { join.detach(); this.appendChild(join); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLJoin> */ public CMLElements getJoinElements() { Elements elements = this.getChildElements("join", CMLConstants.CML_NS); return new CMLElements(elements); } // element: label /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param label child to add */ public void addLabel(AbstractLabel label) { label.detach(); this.appendChild(label); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLLabel> */ public CMLElements getLabelElements() { Elements elements = this.getChildElements("label", CMLConstants.CML_NS); return new CMLElements(elements); } // element: fragment /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param fragment child to add */ public void addFragment(AbstractFragment fragment) { fragment.detach(); this.appendChild(fragment); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLFragment> */ public CMLElements getFragmentElements() { Elements elements = this.getChildElements("fragment", 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 if (name.equals("role")) { setRole(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractGradient.java000077500000000000000000000263621477224461000272650ustar00rootroot00000000000000/** * 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 AbstractGradient extends CMLElement { /** local name*/ public final static String TAG = "gradient"; /** constructor. */ public AbstractGradient() { super("gradient"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractGradient(AbstractGradient 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", "gradient"); 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", "gradient"); 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", "gradient"); 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", "gradient"); 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: 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("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/AbstractHTMLContainer.java000077500000000000000000000056151477224461000301350ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import nu.xom.Nodes; import nu.xom.XPathContext; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; public class AbstractHTMLContainer extends CMLElement { public XPathContext xhtml = new XPathContext("xhtml", CMLConstants.XHTML_NS); public AbstractHTMLContainer(AbstractHTMLContainer old) { super(old); } public AbstractHTMLContainer() { } public AbstractHTMLContainer(String tag) { super(tag); } /** * Convenience method to wrap a plain string in an XHTML P element. * * @param text * to wrap */ public void addPlainText(String text) { Element p = new Element("xhtml:p", CMLConstants.XHTML_NS); p.addNamespaceDeclaration("xhtml", CMLConstants.XHTML_NS); p.appendChild(text); this.appendChild(p); } /** * * @return An ArrayList containing all the XHTML namespaced elements which * are children of this node. */ public List getXHTMLElementList() { List childList = new ArrayList(); Nodes nodes = this.query("//xhtml:*", xhtml); for (int x = 0; x < nodes.size(); x++) { Element node = (Element) nodes.get(x); childList.add(node); } return childList; } /** * * @return A string containing all the text contained in children XHTML * elements. Content from different elements are separated by a * newline. */ public String getFlatText() { StringBuilder builder = new StringBuilder(); List list = this.getXHTMLElementList(); for (int x = 0; x < list.size(); x++) { Element elem = list.get(x); builder.append(elem.getValue()); if (x != list.size() - 1) { builder.append('\n'); } } return builder.toString(); } /** * Calls detach() on all XHTML children of this element. */ public void removeXHTMLChildren() { List list = this.getXHTMLElementList(); for (Element elem : list) { elem.detach(); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractIdentifier.java000077500000000000000000000332431477224461000276060ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractIdentifier extends CMLElement { /** local name*/ public final static String TAG = "identifier"; /** constructor. */ public AbstractIdentifier() { super("identifier"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractIdentifier(AbstractIdentifier old) { super((CMLElement) old); } // attribute: value /** cache */ StringSTAttribute _att_value = null; /** Value of a scalar object. * The value must be consistent with the dataType of the object. * @return CMLAttribute */ public CMLAttribute getCMLValueAttribute() { return (CMLAttribute) getAttribute("value"); } /** Value of a scalar object. * The value must be consistent with the dataType of the object. * @return String */ public String getCMLValue() { StringSTAttribute att = (StringSTAttribute) this.getCMLValueAttribute(); if (att == null) { return null; } return att.getString(); } /** Value of a scalar object. * The value must be consistent with the dataType of the object. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setCMLValue(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_value == null) { _att_value = (StringSTAttribute) attributeFactory.getAttribute("value", "identifier"); if (_att_value == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : value probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_value); super.addRemove(att, value); } // attribute: version /** cache */ StringSTAttribute _att_version = null; /** The version of the element. * No description * @return CMLAttribute */ public CMLAttribute getVersionAttribute() { return (CMLAttribute) getAttribute("version"); } /** The version of the element. * No description * @return String */ public String getVersion() { StringSTAttribute att = (StringSTAttribute) this.getVersionAttribute(); if (att == null) { return null; } return att.getString(); } /** The version of the element. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setVersion(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_version == null) { _att_version = (StringSTAttribute) attributeFactory.getAttribute("version", "identifier"); if (_att_version == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : version probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_version); 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", "identifier"); 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", "identifier"); 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", "identifier"); 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", "identifier"); 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: tautomeric /** cache */ StringSTAttribute _att_tautomeric = null; /** Indicates whether the structure is a tautomer. * No description * @return CMLAttribute */ public CMLAttribute getTautomericAttribute() { return (CMLAttribute) getAttribute("tautomeric"); } /** Indicates whether the structure is a tautomer. * No description * @return String */ public String getTautomeric() { StringSTAttribute att = (StringSTAttribute) this.getTautomericAttribute(); if (att == null) { return null; } return att.getString(); } /** Indicates whether the structure is a tautomer. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setTautomeric(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_tautomeric == null) { _att_tautomeric = (StringSTAttribute) attributeFactory.getAttribute("tautomeric", "identifier"); if (_att_tautomeric == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : tautomeric probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_tautomeric); 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("value")) { setCMLValue(value); } else if (name.equals("version")) { setVersion(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 if (name.equals("tautomeric")) { setTautomeric(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractIsotope.java000077500000000000000000000414051477224461000271450ustar00rootroot00000000000000/** * 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.IntSTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractIsotope extends CMLElement { /** local name*/ public final static String TAG = "isotope"; /** constructor. */ public AbstractIsotope() { super("isotope"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractIsotope(AbstractIsotope 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", "isotope"); 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", "isotope"); 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", "isotope"); 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", "isotope"); 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: number /** cache */ IntSTAttribute _att_number = null; /** A number determined by context. * Used for isotope number in isotope, and rotational symmetry number in symmetry for calculation of entropy, etc. * @return CMLAttribute */ public CMLAttribute getNumberAttribute() { return (CMLAttribute) getAttribute("number"); } /** A number determined by context. * Used for isotope number in isotope, and rotational symmetry number in symmetry for calculation of entropy, etc. * @return int */ public int getNumber() { IntSTAttribute att = (IntSTAttribute) this.getNumberAttribute(); if (att == null) { throw new RuntimeException("int attribute is unset: number"); } return att.getInt(); } /** A number determined by context. * Used for isotope number in isotope, and rotational symmetry number in symmetry for calculation of entropy, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setNumber(String value) throws RuntimeException { IntSTAttribute att = null; if (_att_number == null) { _att_number = (IntSTAttribute) attributeFactory.getAttribute("number", "isotope"); if (_att_number == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : number probably incompatible attributeGroupName and attributeName"); } } att = new IntSTAttribute(_att_number); super.addRemove(att, value); } /** A number determined by context. * Used for isotope number in isotope, and rotational symmetry number in symmetry for calculation of entropy, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setNumber(int value) throws RuntimeException { if (_att_number == null) { _att_number = (IntSTAttribute) attributeFactory.getAttribute("number", "isotope"); if (_att_number == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : number probably incompatible attributeGroupName and attributeName "); } } IntSTAttribute att = new IntSTAttribute(_att_number); super.addAttribute(att); att.setCMLValue(value); } // attribute: spin /** cache */ StringSTAttribute _att_spin = null; /** The spin of a system. * Supports fractional values. Currently the spin of a nucleus. The normal fraction representing the spin of the isotope. * @return CMLAttribute */ public CMLAttribute getSpinAttribute() { return (CMLAttribute) getAttribute("spin"); } /** The spin of a system. * Supports fractional values. Currently the spin of a nucleus. The normal fraction representing the spin of the isotope. * @return String */ public String getSpin() { StringSTAttribute att = (StringSTAttribute) this.getSpinAttribute(); if (att == null) { return null; } return att.getString(); } /** The spin of a system. * Supports fractional values. Currently the spin of a nucleus. The normal fraction representing the spin of the isotope. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setSpin(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_spin == null) { _att_spin = (StringSTAttribute) attributeFactory.getAttribute("spin", "isotope"); if (_att_spin == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : spin probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_spin); super.addRemove(att, 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", "isotope"); 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: 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", "isotope"); 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: abundance /** null * @param abundance child to add */ public void addAbundance(AbstractAbundance abundance) { abundance.detach(); this.appendChild(abundance); } /** null * @return CMLElements<CMLAbundance> */ public CMLElements getAbundanceElements() { Elements elements = this.getChildElements("abundance", 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("number")) { setNumber(value); } else if (name.equals("spin")) { setSpin(value); } else if (name.equals("elementType")) { setElementType(value); } else if (name.equals("ref")) { setRef(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractIsotopeList.java000077500000000000000000000261471477224461000300070ustar00rootroot00000000000000/** * 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 AbstractIsotopeList extends CMLElement { /** local name*/ public final static String TAG = "isotopeList"; /** constructor. */ public AbstractIsotopeList() { super("isotopeList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractIsotopeList(AbstractIsotopeList 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", "isotopeList"); 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", "isotopeList"); 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", "isotopeList"); 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", "isotopeList"); 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", "isotopeList"); 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: isotope /** null * @param isotope child to add */ public void addIsotope(AbstractIsotope isotope) { isotope.detach(); this.appendChild(isotope); } /** null * @return CMLElements<CMLIsotope> */ public CMLElements getIsotopeElements() { Elements elements = this.getChildElements("isotope", 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/AbstractJoin.java000077500000000000000000000601101477224461000264140ustar00rootroot00000000000000/** * 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.StringArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractJoin extends CMLElement { /** local name*/ public final static String TAG = "join"; /** constructor. */ public AbstractJoin() { super("join"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractJoin(AbstractJoin 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", "join"); 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", "join"); 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", "join"); 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", "join"); 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", "join"); 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: atomRefs2 /** cache */ StringArraySTAttribute _att_atomrefs2 = null; /** References to two different atoms. * Available for any reference to atoms but normally will be the normal reference attribute on the bond element. The order of atoms is preserved and may matter for some conventions (e.g. wedge/hatch or donor bonds. * @return CMLAttribute */ public CMLAttribute getAtomRefs2Attribute() { return (CMLAttribute) getAttribute("atomRefs2"); } /** References to two different atoms. * Available for any reference to atoms but normally will be the normal reference attribute on the bond element. The order of atoms is preserved and may matter for some conventions (e.g. wedge/hatch or donor bonds. * @return String[] */ public String[] getAtomRefs2() { StringArraySTAttribute att = (StringArraySTAttribute) this.getAtomRefs2Attribute(); if (att == null) { return null; } return att.getStringArray(); } /** References to two different atoms. * Available for any reference to atoms but normally will be the normal reference attribute on the bond element. The order of atoms is preserved and may matter for some conventions (e.g. wedge/hatch or donor bonds. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefs2(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_atomrefs2 == null) { _att_atomrefs2 = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs2", "join"); if (_att_atomrefs2 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs2 probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_atomrefs2); super.addRemove(att, value); } /** References to two different atoms. * Available for any reference to atoms but normally will be the normal reference attribute on the bond element. The order of atoms is preserved and may matter for some conventions (e.g. wedge/hatch or donor bonds. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefs2(String[] value) throws RuntimeException { if (_att_atomrefs2 == null) { _att_atomrefs2 = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs2", "join"); if (_att_atomrefs2 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs2 probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_atomrefs2); super.addAttribute(att); att.setCMLValue(value); } // attribute: moleculeRefs2 /** cache */ StringArraySTAttribute _att_moleculerefs2 = null; /** References to two different molecules. * Available for any reference to molecules but * normally will be the normal reference attribute on the join element. * The order of molecules is preserved and may matter. * @return CMLAttribute */ public CMLAttribute getMoleculeRefs2Attribute() { return (CMLAttribute) getAttribute("moleculeRefs2"); } /** References to two different molecules. * Available for any reference to molecules but * normally will be the normal reference attribute on the join element. * The order of molecules is preserved and may matter. * @return String[] */ public String[] getMoleculeRefs2() { StringArraySTAttribute att = (StringArraySTAttribute) this.getMoleculeRefs2Attribute(); if (att == null) { return null; } return att.getStringArray(); } /** References to two different molecules. * Available for any reference to molecules but * normally will be the normal reference attribute on the join element. * The order of molecules is preserved and may matter. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMoleculeRefs2(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_moleculerefs2 == null) { _att_moleculerefs2 = (StringArraySTAttribute) attributeFactory.getAttribute("moleculeRefs2", "join"); if (_att_moleculerefs2 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : moleculeRefs2 probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_moleculerefs2); super.addRemove(att, value); } /** References to two different molecules. * Available for any reference to molecules but * normally will be the normal reference attribute on the join element. * The order of molecules is preserved and may matter. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMoleculeRefs2(String[] value) throws RuntimeException { if (_att_moleculerefs2 == null) { _att_moleculerefs2 = (StringArraySTAttribute) attributeFactory.getAttribute("moleculeRefs2", "join"); if (_att_moleculerefs2 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : moleculeRefs2 probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_moleculerefs2); super.addAttribute(att); att.setCMLValue(value); } // attribute: order /** cache */ StringSTAttribute _att_order = null; /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @return CMLAttribute */ public CMLAttribute getOrderAttribute() { return (CMLAttribute) getAttribute("order"); } /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @return String */ public String getOrder() { StringSTAttribute att = (StringSTAttribute) this.getOrderAttribute(); if (att == null) { return null; } return att.getString(); } /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @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", "join"); 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); } // element: angle /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @param angle child to add */ public void addAngle(AbstractAngle angle) { angle.detach(); this.appendChild(angle); } /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @return CMLElements<CMLAngle> */ public CMLElements getAngleElements() { Elements elements = this.getChildElements("angle", CMLConstants.CML_NS); return new CMLElements(elements); } // element: arg /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @param arg child to add */ public void addArg(AbstractArg arg) { arg.detach(); this.appendChild(arg); } /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @return CMLElements<CMLArg> */ public CMLElements getArgElements() { Elements elements = this.getChildElements("arg", CMLConstants.CML_NS); return new CMLElements(elements); } // element: label /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @param label child to add */ public void addLabel(AbstractLabel label) { label.detach(); this.appendChild(label); } /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @return CMLElements<CMLLabel> */ public CMLElements getLabelElements() { Elements elements = this.getChildElements("label", CMLConstants.CML_NS); return new CMLElements(elements); } // element: length /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @param length child to add */ public void addLength(AbstractLength length) { length.detach(); this.appendChild(length); } /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @return CMLElements<CMLLength> */ public CMLElements getLengthElements() { Elements elements = this.getChildElements("length", CMLConstants.CML_NS); return new CMLElements(elements); } // element: metadataList /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: molecule /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @param molecule child to add */ public void addMolecule(AbstractMolecule molecule) { molecule.detach(); this.appendChild(molecule); } /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @return CMLElements<CMLMolecule> */ public CMLElements getMoleculeElements() { Elements elements = this.getChildElements("molecule", CMLConstants.CML_NS); return new CMLElements(elements); } // element: torsion /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @param torsion child to add */ public void addTorsion(AbstractTorsion torsion) { torsion.detach(); this.appendChild(torsion); } /** The order of the bond. * There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. * @return CMLElements<CMLTorsion> */ public CMLElements getTorsionElements() { Elements elements = this.getChildElements("torsion", 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 if (name.equals("atomRefs2")) { setAtomRefs2(value); } else if (name.equals("moleculeRefs2")) { setMoleculeRefs2(value); } else if (name.equals("order")) { setOrder(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractKpoint.java000077500000000000000000000371431477224461000267730ustar00rootroot00000000000000/** * 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.DoubleArraySTAttribute; import org.xmlcml.cml.base.DoubleSTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractKpoint extends CMLElement { /** local name*/ public final static String TAG = "kpoint"; /** constructor. */ public AbstractKpoint() { super("kpoint"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractKpoint(AbstractKpoint old) { super((CMLElement) old); } // attribute: weight /** cache */ DoubleSTAttribute _att_weight = null; /** Weight of the element. * Currently the weight of the kPoint, derived from the symmetry such as the inverse of the multiplicity in real space. Thus a point at 0,0,0 in monoclinic space might be 0.25. The lowest value possible is probably 1/48.0 (in m3m). * @return CMLAttribute */ public CMLAttribute getWeightAttribute() { return (CMLAttribute) getAttribute("weight"); } /** Weight of the element. * Currently the weight of the kPoint, derived from the symmetry such as the inverse of the multiplicity in real space. Thus a point at 0,0,0 in monoclinic space might be 0.25. The lowest value possible is probably 1/48.0 (in m3m). * @return double */ public double getWeight() { DoubleSTAttribute att = (DoubleSTAttribute) this.getWeightAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Weight of the element. * Currently the weight of the kPoint, derived from the symmetry such as the inverse of the multiplicity in real space. Thus a point at 0,0,0 in monoclinic space might be 0.25. The lowest value possible is probably 1/48.0 (in m3m). * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setWeight(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_weight == null) { _att_weight = (DoubleSTAttribute) attributeFactory.getAttribute("weight", "kpoint"); if (_att_weight == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : weight probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_weight); super.addRemove(att, value); } /** Weight of the element. * Currently the weight of the kPoint, derived from the symmetry such as the inverse of the multiplicity in real space. Thus a point at 0,0,0 in monoclinic space might be 0.25. The lowest value possible is probably 1/48.0 (in m3m). * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setWeight(double value) throws RuntimeException { if (_att_weight == null) { _att_weight = (DoubleSTAttribute) attributeFactory.getAttribute("weight", "kpoint"); if (_att_weight == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : weight probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_weight); super.addAttribute(att); att.setCMLValue(value); } // attribute: label /** cache */ StringSTAttribute _att_label = null; /** A label. * The semantics of label are not defined in the schema but are normally commonly used standard or semi-standard text strings. This attribute has the the same semantics as the more common _label_ element. * @return CMLAttribute */ public CMLAttribute getLabelAttribute() { return (CMLAttribute) getAttribute("label"); } /** A label. * The semantics of label are not defined in the schema but are normally commonly used standard or semi-standard text strings. This attribute has the the same semantics as the more common _label_ element. * @return String */ public String getLabel() { StringSTAttribute att = (StringSTAttribute) this.getLabelAttribute(); if (att == null) { return null; } return att.getString(); } /** A label. * The semantics of label are not defined in the schema but are normally commonly used standard or semi-standard text strings. This attribute has the the same semantics as the more common _label_ element. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setLabel(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_label == null) { _att_label = (StringSTAttribute) attributeFactory.getAttribute("label", "kpoint"); if (_att_label == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : label probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_label); 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", "kpoint"); 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", "kpoint"); 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", "kpoint"); 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", "kpoint"); 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); } DoubleArraySTAttribute _xmlContent; /** A vector in 3-space. * No constraints on magnitude (i.e. could be zero. * @return double[] */ public double[] getXMLContent() { String content = this.getValue(); if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(content); return _xmlContent.getDoubleArray(); } /** A vector in 3-space. * No constraints on magnitude (i.e. could be zero. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(String value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(value); String attval = _xmlContent.getValue(); this.removeChildren(); this.appendChild(attval); } /** A vector in 3-space. * No constraints on magnitude (i.e. could be zero. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(double[] value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_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("weight")) { setWeight(value); } else if (name.equals("label")) { setLabel(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/AbstractKpointList.java000077500000000000000000000236011477224461000276210ustar00rootroot00000000000000/** * 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 AbstractKpointList extends CMLElement { /** local name*/ public final static String TAG = "kpointList"; /** constructor. */ public AbstractKpointList() { super("kpointList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractKpointList(AbstractKpointList 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", "kpointList"); 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", "kpointList"); 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", "kpointList"); 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", "kpointList"); 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: kpoint /** null * @param kpoint child to add */ public void addKpoint(AbstractKpoint kpoint) { kpoint.detach(); this.appendChild(kpoint); } /** null * @return CMLElements<CMLKpoint> */ public CMLElements getKpointElements() { Elements elements = this.getChildElements("kpoint", 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 { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractLabel.java000077500000000000000000000201401477224461000265330ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractLabel extends CMLElement { /** local name*/ public final static String TAG = "label"; /** constructor. */ public AbstractLabel() { super("label"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractLabel(AbstractLabel 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", "label"); 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: 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", "label"); 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: value /** cache */ StringSTAttribute _att_value = null; /** Value of a scalar object. * The value must be consistent with the dataType of the object. * @return CMLAttribute */ public CMLAttribute getCMLValueAttribute() { return (CMLAttribute) getAttribute("value"); } /** Value of a scalar object. * The value must be consistent with the dataType of the object. * @return String */ public String getCMLValue() { StringSTAttribute att = (StringSTAttribute) this.getCMLValueAttribute(); if (att == null) { return null; } return att.getString(); } /** Value of a scalar object. * The value must be consistent with the dataType of the object. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setCMLValue(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_value == null) { _att_value = (StringSTAttribute) attributeFactory.getAttribute("value", "label"); if (_att_value == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : value probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_value); super.addRemove(att, value); } // attribute: objectClass /** cache */ StringSTAttribute _att_objectclass = null; /** The class of an object. * The type of this information. This is not controlled, but examples might include: * * label * summary * note * usage * qualifier * * It might be used to control display or XSL filtering. * @return CMLAttribute */ public CMLAttribute getObjectClassAttribute() { return (CMLAttribute) getAttribute("objectClass"); } /** The class of an object. * The type of this information. This is not controlled, but examples might include: * * label * summary * note * usage * qualifier * * It might be used to control display or XSL filtering. * @return String */ public String getObjectClass() { StringSTAttribute att = (StringSTAttribute) this.getObjectClassAttribute(); if (att == null) { return null; } return att.getString(); } /** The class of an object. * The type of this information. This is not controlled, but examples might include: * * label * summary * note * usage * qualifier * * It might be used to control display or XSL filtering. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setObjectClass(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_objectclass == null) { _att_objectclass = (StringSTAttribute) attributeFactory.getAttribute("objectClass", "label"); if (_att_objectclass == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : objectClass probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_objectclass); 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("id")) { setId(value); } else if (name.equals("dictRef")) { setDictRef(value); } else if (name.equals("value")) { setCMLValue(value); } else if (name.equals("objectClass")) { setObjectClass(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractLattice.java000077500000000000000000000406661477224461000271200ustar00rootroot00000000000000/** * 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 AbstractLattice extends CMLElement { /** local name*/ public final static String TAG = "lattice"; /** constructor. */ public AbstractLattice() { super("lattice"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractLattice(AbstractLattice 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", "lattice"); 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", "lattice"); 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", "lattice"); 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", "lattice"); 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: latticeType /** cache */ StringSTAttribute _att_latticetype = null; /** The primitivity of a lattice. * No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency between spacegroups, symmetry operators, etc. * @return CMLAttribute */ public CMLAttribute getLatticeTypeAttribute() { return (CMLAttribute) getAttribute("latticeType"); } /** The primitivity of a lattice. * No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency between spacegroups, symmetry operators, etc. * @return String */ public String getLatticeType() { StringSTAttribute att = (StringSTAttribute) this.getLatticeTypeAttribute(); if (att == null) { return null; } return att.getString(); } /** The primitivity of a lattice. * No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency between spacegroups, symmetry operators, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setLatticeType(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_latticetype == null) { _att_latticetype = (StringSTAttribute) attributeFactory.getAttribute("latticeType", "lattice"); if (_att_latticetype == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : latticeType probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_latticetype); super.addRemove(att, value); } // attribute: spaceType /** cache */ StringSTAttribute _att_spacetype = null; /** The spaceType of the lattice. * Usually real or reciprocal. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency for unitTypes, etc. * @return CMLAttribute */ public CMLAttribute getSpaceTypeAttribute() { return (CMLAttribute) getAttribute("spaceType"); } /** The spaceType of the lattice. * Usually real or reciprocal. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency for unitTypes, etc. * @return String */ public String getSpaceType() { StringSTAttribute att = (StringSTAttribute) this.getSpaceTypeAttribute(); if (att == null) { return null; } return att.getString(); } /** The spaceType of the lattice. * Usually real or reciprocal. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency for unitTypes, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setSpaceType(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_spacetype == null) { _att_spacetype = (StringSTAttribute) attributeFactory.getAttribute("spaceType", "lattice"); if (_att_spacetype == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : spaceType probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_spacetype); super.addRemove(att, value); } // element: scalar /** The spaceType of the lattice. * Usually real or reciprocal. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency for unitTypes, etc. * @param scalar child to add */ public void addScalar(AbstractScalar scalar) { scalar.detach(); this.appendChild(scalar); } /** The spaceType of the lattice. * Usually real or reciprocal. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency for unitTypes, etc. * @return CMLElements<CMLScalar> */ public CMLElements getScalarElements() { Elements elements = this.getChildElements("scalar", CMLConstants.CML_NS); return new CMLElements(elements); } // element: latticeVector /** The spaceType of the lattice. * Usually real or reciprocal. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency for unitTypes, etc. * @param latticeVector child to add */ public void addLatticeVector(AbstractLatticeVector latticeVector) { latticeVector.detach(); this.appendChild(latticeVector); } /** The spaceType of the lattice. * Usually real or reciprocal. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency for unitTypes, etc. * @return CMLElements<CMLLatticeVector> */ public CMLElements getLatticeVectorElements() { Elements elements = this.getChildElements("latticeVector", CMLConstants.CML_NS); return new CMLElements(elements); } // element: matrix /** The spaceType of the lattice. * Usually real or reciprocal. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency for unitTypes, etc. * @param matrix child to add */ public void addMatrix(AbstractMatrix matrix) { matrix.detach(); this.appendChild(matrix); } /** The spaceType of the lattice. * Usually real or reciprocal. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency for unitTypes, etc. * @return CMLElements<CMLMatrix> */ public CMLElements getMatrixElements() { Elements elements = this.getChildElements("matrix", CMLConstants.CML_NS); return new CMLElements(elements); } // element: symmetry /** The spaceType of the lattice. * Usually real or reciprocal. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency for unitTypes, etc. * @param symmetry child to add */ public void addSymmetry(AbstractSymmetry symmetry) { symmetry.detach(); this.appendChild(symmetry); } /** The spaceType of the lattice. * Usually real or reciprocal. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency for unitTypes, etc. * @return CMLElements<CMLSymmetry> */ public CMLElements getSymmetryElements() { Elements elements = this.getChildElements("symmetry", 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("latticeType")) { setLatticeType(value); } else if (name.equals("spaceType")) { setSpaceType(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractLatticeVector.java000077500000000000000000000376421477224461000303030ustar00rootroot00000000000000/** * 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.BooleanSTAttribute; import org.xmlcml.cml.base.CMLAttribute; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.DoubleArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractLatticeVector extends CMLElement { /** local name*/ public final static String TAG = "latticeVector"; /** constructor. */ public AbstractLatticeVector() { super("latticeVector"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractLatticeVector(AbstractLatticeVector old) { super((CMLElement) old); } // 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", "latticeVector"); 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", "latticeVector"); 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: 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", "latticeVector"); 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: 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", "latticeVector"); 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: 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", "latticeVector"); 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: periodic /** cache */ BooleanSTAttribute _att_periodic = null; /** Is the axis periodic. * Any or all of the axes may be periodic or aperiodic. An example could be a surface where 2 periodic axes (not necessarily orthogonal) are used to describe the coordinates in the surface, perhaps representing lattice vectors of a 3D crystal or 2D layer. The third vector is orthogonal and represents coordinates normal to the surface. In this case only the direction, not the magnitude of the vector is important. * @return CMLAttribute */ public CMLAttribute getPeriodicAttribute() { return (CMLAttribute) getAttribute("periodic"); } /** Is the axis periodic. * Any or all of the axes may be periodic or aperiodic. An example could be a surface where 2 periodic axes (not necessarily orthogonal) are used to describe the coordinates in the surface, perhaps representing lattice vectors of a 3D crystal or 2D layer. The third vector is orthogonal and represents coordinates normal to the surface. In this case only the direction, not the magnitude of the vector is important. * @return boolean */ public boolean getPeriodic() { BooleanSTAttribute att = (BooleanSTAttribute) this.getPeriodicAttribute(); if (att == null) { throw new RuntimeException("boolean attribute is unset: periodic"); } return att.getBoolean(); } /** Is the axis periodic. * Any or all of the axes may be periodic or aperiodic. An example could be a surface where 2 periodic axes (not necessarily orthogonal) are used to describe the coordinates in the surface, perhaps representing lattice vectors of a 3D crystal or 2D layer. The third vector is orthogonal and represents coordinates normal to the surface. In this case only the direction, not the magnitude of the vector is important. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPeriodic(String value) throws RuntimeException { BooleanSTAttribute att = null; if (_att_periodic == null) { _att_periodic = (BooleanSTAttribute) attributeFactory.getAttribute("periodic", "latticeVector"); if (_att_periodic == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : periodic probably incompatible attributeGroupName and attributeName"); } } att = new BooleanSTAttribute(_att_periodic); super.addRemove(att, value); } /** Is the axis periodic. * Any or all of the axes may be periodic or aperiodic. An example could be a surface where 2 periodic axes (not necessarily orthogonal) are used to describe the coordinates in the surface, perhaps representing lattice vectors of a 3D crystal or 2D layer. The third vector is orthogonal and represents coordinates normal to the surface. In this case only the direction, not the magnitude of the vector is important. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPeriodic(boolean value) throws RuntimeException { if (_att_periodic == null) { _att_periodic = (BooleanSTAttribute) attributeFactory.getAttribute("periodic", "latticeVector"); if (_att_periodic == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : periodic probably incompatible attributeGroupName and attributeName "); } } BooleanSTAttribute att = new BooleanSTAttribute(_att_periodic); super.addAttribute(att); att.setCMLValue(value); } DoubleArraySTAttribute _xmlContent; /** A vector in 3-space. * No constraints on magnitude (i.e. could be zero. * @return double[] */ public double[] getXMLContent() { String content = this.getValue(); if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(content); return _xmlContent.getDoubleArray(); } /** A vector in 3-space. * No constraints on magnitude (i.e. could be zero. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(String value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(value); String attval = _xmlContent.getValue(); this.removeChildren(); this.appendChild(attval); } /** A vector in 3-space. * No constraints on magnitude (i.e. could be zero. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(double[] value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_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("convention")) { setConvention(value); } else if (name.equals("dictRef")) { setDictRef(value); } else if (name.equals("id")) { setId(value); } else if (name.equals("title")) { setTitle(value); } else if (name.equals("units")) { setUnits(value); } else if (name.equals("periodic")) { setPeriodic(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractLength.java000077500000000000000000000552311477224461000267460ustar00rootroot00000000000000/** * 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 AbstractLength extends CMLElement { /** local name*/ public final static String TAG = "length"; /** constructor. */ public AbstractLength() { super("length"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractLength(AbstractLength 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", "length"); 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", "length"); 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", "length"); 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", "length"); 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: atomRefs2 /** cache */ StringArraySTAttribute _att_atomrefs2 = null; /** References to two different atoms. * Available for any reference to atoms but normally will be the normal reference attribute on the bond element. The order of atoms is preserved and may matter for some conventions (e.g. wedge/hatch or donor bonds. * @return CMLAttribute */ public CMLAttribute getAtomRefs2Attribute() { return (CMLAttribute) getAttribute("atomRefs2"); } /** References to two different atoms. * Available for any reference to atoms but normally will be the normal reference attribute on the bond element. The order of atoms is preserved and may matter for some conventions (e.g. wedge/hatch or donor bonds. * @return String[] */ public String[] getAtomRefs2() { StringArraySTAttribute att = (StringArraySTAttribute) this.getAtomRefs2Attribute(); if (att == null) { return null; } return att.getStringArray(); } /** References to two different atoms. * Available for any reference to atoms but normally will be the normal reference attribute on the bond element. The order of atoms is preserved and may matter for some conventions (e.g. wedge/hatch or donor bonds. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefs2(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_atomrefs2 == null) { _att_atomrefs2 = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs2", "length"); if (_att_atomrefs2 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs2 probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_atomrefs2); super.addRemove(att, value); } /** References to two different atoms. * Available for any reference to atoms but normally will be the normal reference attribute on the bond element. The order of atoms is preserved and may matter for some conventions (e.g. wedge/hatch or donor bonds. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefs2(String[] value) throws RuntimeException { if (_att_atomrefs2 == null) { _att_atomrefs2 = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs2", "length"); if (_att_atomrefs2 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs2 probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_atomrefs2); 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", "length"); 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", "length"); 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", "length"); 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", "length"); 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", "length"); 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", "length"); 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", "length"); 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; /** * * @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("atomRefs2")) { setAtomRefs2(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/AbstractLine3.java000077500000000000000000000435711477224461000265030ustar00rootroot00000000000000/** * 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.DoubleArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractLine3 extends CMLElement { /** local name*/ public final static String TAG = "line3"; /** constructor. */ public AbstractLine3() { super("line3"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractLine3(AbstractLine3 old) { super((CMLElement) old); } // 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", "line3"); 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", "line3"); 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: 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", "line3"); 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: 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", "line3"); 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: 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", "line3"); 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: point3 /** cache */ DoubleArraySTAttribute _att_point3 = null; /** A point in 3 dimensions. * can be used for any complex * geometrical object, such as line. * @return CMLAttribute */ public CMLAttribute getPoint3Attribute() { return (CMLAttribute) getAttribute("point3"); } /** A point in 3 dimensions. * can be used for any complex * geometrical object, such as line. * @return double[] */ public double[] getPoint3() { DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getPoint3Attribute(); if (att == null) { return null; } return att.getDoubleArray(); } /** A point in 3 dimensions. * can be used for any complex * geometrical object, such as line. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPoint3(String value) throws RuntimeException { DoubleArraySTAttribute att = null; if (_att_point3 == null) { _att_point3 = (DoubleArraySTAttribute) attributeFactory.getAttribute("point3", "line3"); if (_att_point3 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : point3 probably incompatible attributeGroupName and attributeName"); } } att = new DoubleArraySTAttribute(_att_point3); super.addRemove(att, value); } /** A point in 3 dimensions. * can be used for any complex * geometrical object, such as line. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPoint3(double[] value) throws RuntimeException { if (_att_point3 == null) { _att_point3 = (DoubleArraySTAttribute) attributeFactory.getAttribute("point3", "line3"); if (_att_point3 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : point3 probably incompatible attributeGroupName and attributeName "); } } DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_point3); super.addAttribute(att); att.setCMLValue(value); } // attribute: vector3 /** cache */ DoubleArraySTAttribute _att_vector3 = null; /** A vector in 3 dimensions. * can be used for any complex geometrical object, * such as line. * @return CMLAttribute */ public CMLAttribute getVector3Attribute() { return (CMLAttribute) getAttribute("vector3"); } /** A vector in 3 dimensions. * can be used for any complex geometrical object, * such as line. * @return double[] */ public double[] getVector3() { DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getVector3Attribute(); if (att == null) { return null; } return att.getDoubleArray(); } /** A vector in 3 dimensions. * can be used for any complex geometrical object, * such as line. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setVector3(String value) throws RuntimeException { DoubleArraySTAttribute att = null; if (_att_vector3 == null) { _att_vector3 = (DoubleArraySTAttribute) attributeFactory.getAttribute("vector3", "line3"); if (_att_vector3 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : vector3 probably incompatible attributeGroupName and attributeName"); } } att = new DoubleArraySTAttribute(_att_vector3); super.addRemove(att, value); } /** A vector in 3 dimensions. * can be used for any complex geometrical object, * such as line. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setVector3(double[] value) throws RuntimeException { if (_att_vector3 == null) { _att_vector3 = (DoubleArraySTAttribute) attributeFactory.getAttribute("vector3", "line3"); if (_att_vector3 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : vector3 probably incompatible attributeGroupName and attributeName "); } } DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_vector3); super.addAttribute(att); att.setCMLValue(value); } DoubleArraySTAttribute _xmlContent; /** An unbounded line in 3-space. * Defined by 6 real numbers, conventionally an arbitrary * point on the line and a vector3. There is no significance to the point * (i.e. it is not the "end of the line") and there are an infinite number of * ways of representing the line. DANGER. Line3 now uses the point3 and vector3 attributes * and the line3Type may be OBSOLETED. * @return double[] */ public double[] getXMLContent() { String content = this.getValue(); if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(content); return _xmlContent.getDoubleArray(); } /** An unbounded line in 3-space. * Defined by 6 real numbers, conventionally an arbitrary * point on the line and a vector3. There is no significance to the point * (i.e. it is not the "end of the line") and there are an infinite number of * ways of representing the line. DANGER. Line3 now uses the point3 and vector3 attributes * and the line3Type may be OBSOLETED. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(String value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(value); String attval = _xmlContent.getValue(); this.removeChildren(); this.appendChild(attval); } /** An unbounded line in 3-space. * Defined by 6 real numbers, conventionally an arbitrary * point on the line and a vector3. There is no significance to the point * (i.e. it is not the "end of the line") and there are an infinite number of * ways of representing the line. DANGER. Line3 now uses the point3 and vector3 attributes * and the line3Type may be OBSOLETED. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(double[] value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_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("convention")) { setConvention(value); } else if (name.equals("dictRef")) { setDictRef(value); } else if (name.equals("id")) { setId(value); } else if (name.equals("title")) { setTitle(value); } else if (name.equals("units")) { setUnits(value); } else if (name.equals("point3")) { setPoint3(value); } else if (name.equals("vector3")) { setVector3(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractLink.java000077500000000000000000001256341477224461000264270ustar00rootroot00000000000000/** * 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.base.CMLAttribute; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.StringArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractLink extends CMLElement { /** local name*/ public final static String TAG = "link"; /** constructor. */ public AbstractLink() { super("link"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractLink(AbstractLink 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", "link"); 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", "link"); 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", "link"); 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", "link"); 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: from /** cache */ StringSTAttribute _att_from = null; /** The base of one or more links. * On link elements the value is the single id of an element within the document or context specified in map@fromRef attributes. It must identify the element uniquely. The reserved value 'null' implies that no mapping has been provided for the object(s) in the 'to' attribute. This implies no semantics but may be used by software to keep count of which elements have been mapped. For multiple targets use 'fromSet'. * @return CMLAttribute */ public CMLAttribute getFromAttribute() { return (CMLAttribute) getAttribute("from"); } /** The base of one or more links. * On link elements the value is the single id of an element within the document or context specified in map@fromRef attributes. It must identify the element uniquely. The reserved value 'null' implies that no mapping has been provided for the object(s) in the 'to' attribute. This implies no semantics but may be used by software to keep count of which elements have been mapped. For multiple targets use 'fromSet'. * @return String */ public String getFrom() { StringSTAttribute att = (StringSTAttribute) this.getFromAttribute(); if (att == null) { return null; } return att.getString(); } /** The base of one or more links. * On link elements the value is the single id of an element within the document or context specified in map@fromRef attributes. It must identify the element uniquely. The reserved value 'null' implies that no mapping has been provided for the object(s) in the 'to' attribute. This implies no semantics but may be used by software to keep count of which elements have been mapped. For multiple targets use 'fromSet'. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setFrom(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_from == null) { _att_from = (StringSTAttribute) attributeFactory.getAttribute("from", "link"); if (_att_from == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : from probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_from); super.addRemove(att, value); } // attribute: to /** cache */ StringSTAttribute _att_to = null; /** The target of one or more links. * No description * @return CMLAttribute */ public CMLAttribute getToAttribute() { return (CMLAttribute) getAttribute("to"); } /** The target of one or more links. * No description * @return String */ public String getTo() { StringSTAttribute att = (StringSTAttribute) this.getToAttribute(); if (att == null) { return null; } return att.getString(); } /** The target of one or more links. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setTo(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_to == null) { _att_to = (StringSTAttribute) attributeFactory.getAttribute("to", "link"); if (_att_to == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : to probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_to); 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", "link"); 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: fromType /** cache */ StringSTAttribute _att_fromtype = null; /** The type of the base of a link. * The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. * This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. * * @return CMLAttribute */ public CMLAttribute getFromTypeAttribute() { return (CMLAttribute) getAttribute("fromType"); } /** The type of the base of a link. * The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. * This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. * * @return String */ public String getFromType() { StringSTAttribute att = (StringSTAttribute) this.getFromTypeAttribute(); if (att == null) { return null; } return att.getString(); } /** The type of the base of a link. * The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. * This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setFromType(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_fromtype == null) { _att_fromtype = (StringSTAttribute) attributeFactory.getAttribute("fromType", "link"); if (_att_fromtype == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : fromType probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_fromtype); super.addRemove(att, value); } // attribute: toType /** cache */ StringSTAttribute _att_totype = null; /** The type of the base of a link. * * The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. * This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. * * @return CMLAttribute */ public CMLAttribute getToTypeAttribute() { return (CMLAttribute) getAttribute("toType"); } /** The type of the base of a link. * * The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. * This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. * * @return String */ public String getToType() { StringSTAttribute att = (StringSTAttribute) this.getToTypeAttribute(); if (att == null) { return null; } return att.getString(); } /** The type of the base of a link. * * The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. * This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setToType(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_totype == null) { _att_totype = (StringSTAttribute) attributeFactory.getAttribute("toType", "link"); if (_att_totype == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : toType probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_totype); super.addRemove(att, value); } // attribute: fromSet /** cache */ StringArraySTAttribute _att_fromset = null; /** A set of ids representing the base of a link. * For a partial mapping where a number of 'from' elements are known to link to a number of 'to' elements it can be useful to aggregate these into a single attribute value. The primary use is to assert that n links exist between a set of n 'from' elements and n 'to' elements but that the precise links are unknown. The semantics of the reference are the same as for 'from' and all the elements must be of the same type (which can be specified with 'fromType' either on the link or the containing map). No order information is implied. In general there will be the same number of idRefs in the 'toSet' and all implicit links will share the same attributes (e.g. 'role'). In many cases the sets will be later split into discrete links thorugh further calculation or experiment (e.g. peak assignment). Sets should never be used as a lazy or concise alternative where the all the links are explicitly known. * * @return CMLAttribute */ public CMLAttribute getFromSetAttribute() { return (CMLAttribute) getAttribute("fromSet"); } /** A set of ids representing the base of a link. * For a partial mapping where a number of 'from' elements are known to link to a number of 'to' elements it can be useful to aggregate these into a single attribute value. The primary use is to assert that n links exist between a set of n 'from' elements and n 'to' elements but that the precise links are unknown. The semantics of the reference are the same as for 'from' and all the elements must be of the same type (which can be specified with 'fromType' either on the link or the containing map). No order information is implied. In general there will be the same number of idRefs in the 'toSet' and all implicit links will share the same attributes (e.g. 'role'). In many cases the sets will be later split into discrete links thorugh further calculation or experiment (e.g. peak assignment). Sets should never be used as a lazy or concise alternative where the all the links are explicitly known. * * @return String[] */ public String[] getFromSet() { StringArraySTAttribute att = (StringArraySTAttribute) this.getFromSetAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** A set of ids representing the base of a link. * For a partial mapping where a number of 'from' elements are known to link to a number of 'to' elements it can be useful to aggregate these into a single attribute value. The primary use is to assert that n links exist between a set of n 'from' elements and n 'to' elements but that the precise links are unknown. The semantics of the reference are the same as for 'from' and all the elements must be of the same type (which can be specified with 'fromType' either on the link or the containing map). No order information is implied. In general there will be the same number of idRefs in the 'toSet' and all implicit links will share the same attributes (e.g. 'role'). In many cases the sets will be later split into discrete links thorugh further calculation or experiment (e.g. peak assignment). Sets should never be used as a lazy or concise alternative where the all the links are explicitly known. * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setFromSet(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_fromset == null) { _att_fromset = (StringArraySTAttribute) attributeFactory.getAttribute("fromSet", "link"); if (_att_fromset == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : fromSet probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_fromset); super.addRemove(att, value); } /** A set of ids representing the base of a link. * For a partial mapping where a number of 'from' elements are known to link to a number of 'to' elements it can be useful to aggregate these into a single attribute value. The primary use is to assert that n links exist between a set of n 'from' elements and n 'to' elements but that the precise links are unknown. The semantics of the reference are the same as for 'from' and all the elements must be of the same type (which can be specified with 'fromType' either on the link or the containing map). No order information is implied. In general there will be the same number of idRefs in the 'toSet' and all implicit links will share the same attributes (e.g. 'role'). In many cases the sets will be later split into discrete links thorugh further calculation or experiment (e.g. peak assignment). Sets should never be used as a lazy or concise alternative where the all the links are explicitly known. * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setFromSet(String[] value) throws RuntimeException { if (_att_fromset == null) { _att_fromset = (StringArraySTAttribute) attributeFactory.getAttribute("fromSet", "link"); if (_att_fromset == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : fromSet probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_fromset); super.addAttribute(att); att.setCMLValue(value); } // attribute: toSet /** cache */ StringArraySTAttribute _att_toset = null; /** A set of ids representing the base of a link. * For a partial mapping where a number of 'to' elements are known to link to a number of 'from' elements it can be useful to aggregate these into a single attribute value. The primary use is to assert that n links exist between a set of n 'to' elements and n 'from' elements but that the precise links are unknown. The semantics of the reference are the same as for 'to' and all the elements must be of the same type (which can be specified with 'toType' either on the link or the containing map). No order information is implied. In general there will be the same number of idRefs in the 'fromSet' and all implicit links will share the same attributes (e.g. 'role'). In many cases the sets will be later split into discrete links thorugh further calculation or experiment (e.g. peak assignment). Sets should never be used as a lazy or concise alternative where the all the links are explicitly known. * * @return CMLAttribute */ public CMLAttribute getToSetAttribute() { return (CMLAttribute) getAttribute("toSet"); } /** A set of ids representing the base of a link. * For a partial mapping where a number of 'to' elements are known to link to a number of 'from' elements it can be useful to aggregate these into a single attribute value. The primary use is to assert that n links exist between a set of n 'to' elements and n 'from' elements but that the precise links are unknown. The semantics of the reference are the same as for 'to' and all the elements must be of the same type (which can be specified with 'toType' either on the link or the containing map). No order information is implied. In general there will be the same number of idRefs in the 'fromSet' and all implicit links will share the same attributes (e.g. 'role'). In many cases the sets will be later split into discrete links thorugh further calculation or experiment (e.g. peak assignment). Sets should never be used as a lazy or concise alternative where the all the links are explicitly known. * * @return String[] */ public String[] getToSet() { StringArraySTAttribute att = (StringArraySTAttribute) this.getToSetAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** A set of ids representing the base of a link. * For a partial mapping where a number of 'to' elements are known to link to a number of 'from' elements it can be useful to aggregate these into a single attribute value. The primary use is to assert that n links exist between a set of n 'to' elements and n 'from' elements but that the precise links are unknown. The semantics of the reference are the same as for 'to' and all the elements must be of the same type (which can be specified with 'toType' either on the link or the containing map). No order information is implied. In general there will be the same number of idRefs in the 'fromSet' and all implicit links will share the same attributes (e.g. 'role'). In many cases the sets will be later split into discrete links thorugh further calculation or experiment (e.g. peak assignment). Sets should never be used as a lazy or concise alternative where the all the links are explicitly known. * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setToSet(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_toset == null) { _att_toset = (StringArraySTAttribute) attributeFactory.getAttribute("toSet", "link"); if (_att_toset == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : toSet probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_toset); super.addRemove(att, value); } /** A set of ids representing the base of a link. * For a partial mapping where a number of 'to' elements are known to link to a number of 'from' elements it can be useful to aggregate these into a single attribute value. The primary use is to assert that n links exist between a set of n 'to' elements and n 'from' elements but that the precise links are unknown. The semantics of the reference are the same as for 'to' and all the elements must be of the same type (which can be specified with 'toType' either on the link or the containing map). No order information is implied. In general there will be the same number of idRefs in the 'fromSet' and all implicit links will share the same attributes (e.g. 'role'). In many cases the sets will be later split into discrete links thorugh further calculation or experiment (e.g. peak assignment). Sets should never be used as a lazy or concise alternative where the all the links are explicitly known. * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setToSet(String[] value) throws RuntimeException { if (_att_toset == null) { _att_toset = (StringArraySTAttribute) attributeFactory.getAttribute("toSet", "link"); if (_att_toset == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : toSet probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_toset); super.addAttribute(att); att.setCMLValue(value); } // attribute: fromContext /** cache */ StringSTAttribute _att_fromcontext = null; /** The context for the 'from' links in a map. * A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. * This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. * * @return CMLAttribute */ public CMLAttribute getFromContextAttribute() { return (CMLAttribute) getAttribute("fromContext"); } /** The context for the 'from' links in a map. * A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. * This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. * * @return String */ public String getFromContext() { StringSTAttribute att = (StringSTAttribute) this.getFromContextAttribute(); if (att == null) { return null; } return att.getString(); } /** The context for the 'from' links in a map. * A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. * This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setFromContext(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_fromcontext == null) { _att_fromcontext = (StringSTAttribute) attributeFactory.getAttribute("fromContext", "link"); if (_att_fromcontext == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : fromContext probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_fromcontext); super.addRemove(att, value); } // attribute: toContext /** cache */ StringSTAttribute _att_tocontext = null; /** The context for the 'from' links in a map. * A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. * This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. * * @return CMLAttribute */ public CMLAttribute getToContextAttribute() { return (CMLAttribute) getAttribute("toContext"); } /** The context for the 'from' links in a map. * A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. * This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. * * @return String */ public String getToContext() { StringSTAttribute att = (StringSTAttribute) this.getToContextAttribute(); if (att == null) { return null; } return att.getString(); } /** The context for the 'from' links in a map. * A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. * This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setToContext(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_tocontext == null) { _att_tocontext = (StringSTAttribute) attributeFactory.getAttribute("toContext", "link"); if (_att_tocontext == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : toContext probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_tocontext); 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", "link"); 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: href /** cache */ StringSTAttribute _att_href = null; /** address of a resource. * Links to another element in the same or other file. For dictionary/@dictRef requires the prefix and the physical URI * address to be contained within the same file. We can anticipate that * better mechanisms will arise - perhaps through XMLCatalogs. * At least it works at present. * @return CMLAttribute */ public CMLAttribute getHrefAttribute() { return (CMLAttribute) getAttribute("href"); } /** address of a resource. * Links to another element in the same or other file. For dictionary/@dictRef requires the prefix and the physical URI * address to be contained within the same file. We can anticipate that * better mechanisms will arise - perhaps through XMLCatalogs. * At least it works at present. * @return String */ public String getHref() { StringSTAttribute att = (StringSTAttribute) this.getHrefAttribute(); if (att == null) { return null; } return att.getString(); } /** address of a resource. * Links to another element in the same or other file. For dictionary/@dictRef requires the prefix and the physical URI * address to be contained within the same file. We can anticipate that * better mechanisms will arise - perhaps through XMLCatalogs. * At least it works at present. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setHref(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_href == null) { _att_href = (StringSTAttribute) attributeFactory.getAttribute("href", "link"); if (_att_href == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : href probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_href); super.addRemove(att, value); } // attribute: linkType /** cache */ StringSTAttribute _att_linktype = null; /** The type of the link. * No description * @return CMLAttribute */ public CMLAttribute getLinkTypeAttribute() { return (CMLAttribute) getAttribute("linkType"); } /** The type of the link. * No description * @return String */ public String getLinkType() { StringSTAttribute att = (StringSTAttribute) this.getLinkTypeAttribute(); if (att == null) { return null; } return att.getString(); } /** The type of the link. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setLinkType(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_linktype == null) { _att_linktype = (StringSTAttribute) attributeFactory.getAttribute("linkType", "link"); if (_att_linktype == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : linkType probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_linktype); 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("from")) { setFrom(value); } else if (name.equals("to")) { setTo(value); } else if (name.equals("ref")) { setRef(value); } else if (name.equals("fromType")) { setFromType(value); } else if (name.equals("toType")) { setToType(value); } else if (name.equals("fromSet")) { setFromSet(value); } else if (name.equals("toSet")) { setToSet(value); } else if (name.equals("fromContext")) { setFromContext(value); } else if (name.equals("toContext")) { setToContext(value); } else if (name.equals("role")) { setRole(value); } else if (name.equals("href")) { setHref(value); } else if (name.equals("linkType")) { setLinkType(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractList.java000077500000000000000000000252751477224461000264450ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractList extends CMLElement { /** local name*/ public final static String TAG = "list"; /** constructor. */ public AbstractList() { super("list"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractList(AbstractList 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", "list"); 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", "list"); 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", "list"); 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", "list"); 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: 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", "list"); 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); } /** 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("type")) { setType(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractMap.java000077500000000000000000000614241477224461000262430ustar00rootroot00000000000000/** * 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 AbstractMap extends CMLElement { /** local name*/ public final static String TAG = "map"; /** constructor. */ public AbstractMap() { super("map"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractMap(AbstractMap 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", "map"); 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", "map"); 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", "map"); 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", "map"); 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", "map"); 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: fromType /** cache */ StringSTAttribute _att_fromtype = null; /** The type of the base of a link. * The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. * This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. * * @return CMLAttribute */ public CMLAttribute getFromTypeAttribute() { return (CMLAttribute) getAttribute("fromType"); } /** The type of the base of a link. * The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. * This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. * * @return String */ public String getFromType() { StringSTAttribute att = (StringSTAttribute) this.getFromTypeAttribute(); if (att == null) { return null; } return att.getString(); } /** The type of the base of a link. * The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. * This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setFromType(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_fromtype == null) { _att_fromtype = (StringSTAttribute) attributeFactory.getAttribute("fromType", "map"); if (_att_fromtype == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : fromType probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_fromtype); super.addRemove(att, value); } // attribute: toType /** cache */ StringSTAttribute _att_totype = null; /** The type of the base of a link. * * The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. * This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. * * @return CMLAttribute */ public CMLAttribute getToTypeAttribute() { return (CMLAttribute) getAttribute("toType"); } /** The type of the base of a link. * * The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. * This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. * * @return String */ public String getToType() { StringSTAttribute att = (StringSTAttribute) this.getToTypeAttribute(); if (att == null) { return null; } return att.getString(); } /** The type of the base of a link. * * The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. * This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setToType(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_totype == null) { _att_totype = (StringSTAttribute) attributeFactory.getAttribute("toType", "map"); if (_att_totype == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : toType probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_totype); super.addRemove(att, value); } // attribute: fromContext /** cache */ StringSTAttribute _att_fromcontext = null; /** The context for the 'from' links in a map. * A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. * This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. * * @return CMLAttribute */ public CMLAttribute getFromContextAttribute() { return (CMLAttribute) getAttribute("fromContext"); } /** The context for the 'from' links in a map. * A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. * This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. * * @return String */ public String getFromContext() { StringSTAttribute att = (StringSTAttribute) this.getFromContextAttribute(); if (att == null) { return null; } return att.getString(); } /** The context for the 'from' links in a map. * A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. * This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setFromContext(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_fromcontext == null) { _att_fromcontext = (StringSTAttribute) attributeFactory.getAttribute("fromContext", "map"); if (_att_fromcontext == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : fromContext probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_fromcontext); super.addRemove(att, value); } // attribute: toContext /** cache */ StringSTAttribute _att_tocontext = null; /** The context for the 'from' links in a map. * A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. * This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. * * @return CMLAttribute */ public CMLAttribute getToContextAttribute() { return (CMLAttribute) getAttribute("toContext"); } /** The context for the 'from' links in a map. * A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. * This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. * * @return String */ public String getToContext() { StringSTAttribute att = (StringSTAttribute) this.getToContextAttribute(); if (att == null) { return null; } return att.getString(); } /** The context for the 'from' links in a map. * A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. * This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setToContext(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_tocontext == null) { _att_tocontext = (StringSTAttribute) attributeFactory.getAttribute("toContext", "map"); if (_att_tocontext == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : toContext probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_tocontext); 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", "map"); 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); } // element: link /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param link child to add */ public void addLink(AbstractLink link) { link.detach(); this.appendChild(link); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLLink> */ public CMLElements getLinkElements() { Elements elements = this.getChildElements("link", 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("fromType")) { setFromType(value); } else if (name.equals("toType")) { setToType(value); } else if (name.equals("fromContext")) { setFromContext(value); } else if (name.equals("toContext")) { setToContext(value); } else if (name.equals("role")) { setRole(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractMatrix.java000077500000000000000000000725531477224461000267770ustar00rootroot00000000000000/** * 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.UnitsAttribute; import org.xmlcml.cml.base.CMLAttribute; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.DoubleArraySTAttribute; import org.xmlcml.cml.base.IntSTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractMatrix extends CMLElement { /** local name*/ public final static String TAG = "matrix"; /** constructor. */ public AbstractMatrix() { super("matrix"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractMatrix(AbstractMatrix old) { super((CMLElement) old); } // 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", "matrix"); 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: 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", "matrix"); 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: rows /** cache */ IntSTAttribute _att_rows = null; /** Number of rows. * No description * @return CMLAttribute */ public CMLAttribute getRowsAttribute() { return (CMLAttribute) getAttribute("rows"); } /** Number of rows. * No description * @return int */ public int getRows() { IntSTAttribute att = (IntSTAttribute) this.getRowsAttribute(); if (att == null) { throw new RuntimeException("int attribute is unset: rows"); } return att.getInt(); } /** Number of rows. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setRows(String value) throws RuntimeException { IntSTAttribute att = null; if (_att_rows == null) { _att_rows = (IntSTAttribute) attributeFactory.getAttribute("rows", "matrix"); if (_att_rows == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : rows probably incompatible attributeGroupName and attributeName"); } } att = new IntSTAttribute(_att_rows); super.addRemove(att, value); } /** Number of rows. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setRows(int value) throws RuntimeException { if (_att_rows == null) { _att_rows = (IntSTAttribute) attributeFactory.getAttribute("rows", "matrix"); if (_att_rows == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : rows probably incompatible attributeGroupName and attributeName "); } } IntSTAttribute att = new IntSTAttribute(_att_rows); super.addAttribute(att); att.setCMLValue(value); } // attribute: columns /** cache */ IntSTAttribute _att_columns = null; /** Number of columns. * No description * @return CMLAttribute */ public CMLAttribute getColumnsAttribute() { return (CMLAttribute) getAttribute("columns"); } /** Number of columns. * No description * @return int */ public int getColumns() { IntSTAttribute att = (IntSTAttribute) this.getColumnsAttribute(); if (att == null) { throw new RuntimeException("int attribute is unset: columns"); } return att.getInt(); } /** Number of columns. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setColumns(String value) throws RuntimeException { IntSTAttribute att = null; if (_att_columns == null) { _att_columns = (IntSTAttribute) attributeFactory.getAttribute("columns", "matrix"); if (_att_columns == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : columns probably incompatible attributeGroupName and attributeName"); } } att = new IntSTAttribute(_att_columns); super.addRemove(att, value); } /** Number of columns. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setColumns(int value) throws RuntimeException { if (_att_columns == null) { _att_columns = (IntSTAttribute) attributeFactory.getAttribute("columns", "matrix"); if (_att_columns == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : columns probably incompatible attributeGroupName and attributeName "); } } IntSTAttribute att = new IntSTAttribute(_att_columns); 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", "matrix"); 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: 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", "matrix"); 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", "matrix"); 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", "matrix"); 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", "matrix"); 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: matrixType /** cache */ StringSTAttribute _att_matrixtype = null; /** Type of matrix. * Mainly square, but extensible through the _xsd:union_ mechanis. * @return CMLAttribute */ public CMLAttribute getMatrixTypeAttribute() { return (CMLAttribute) getAttribute("matrixType"); } /** Type of matrix. * Mainly square, but extensible through the _xsd:union_ mechanis. * @return String */ public String getMatrixType() { StringSTAttribute att = (StringSTAttribute) this.getMatrixTypeAttribute(); if (att == null) { return null; } return att.getString(); } /** Type of matrix. * Mainly square, but extensible through the _xsd:union_ mechanis. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMatrixType(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_matrixtype == null) { _att_matrixtype = (StringSTAttribute) attributeFactory.getAttribute("matrixType", "matrix"); if (_att_matrixtype == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : matrixType probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_matrixtype); 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", "matrix"); 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", "matrix"); 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", "matrix"); 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", "matrix"); 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", "matrix"); 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", "matrix"); 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", "matrix"); 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); } StringSTAttribute _xmlContent; /** * * @return String */ public String getXMLContent() { String content = this.getValue(); if (_xmlContent == null) { _xmlContent = new StringSTAttribute("_xmlContent"); } _xmlContent.setCMLValue(content); 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("dataType")) { setDataType(value); } else if (name.equals("delimiter")) { setDelimiter(value); } else if (name.equals("rows")) { setRows(value); } else if (name.equals("columns")) { setColumns(value); } else if (name.equals("units")) { setUnits(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 if (name.equals("matrixType")) { setMatrixType(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 { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractMechanism.java000077500000000000000000000256111477224461000274300ustar00rootroot00000000000000/** * 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 AbstractMechanism extends CMLElement { /** local name*/ public final static String TAG = "mechanism"; /** constructor. */ public AbstractMechanism() { super("mechanism"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractMechanism(AbstractMechanism 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", "mechanism"); 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", "mechanism"); 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", "mechanism"); 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", "mechanism"); 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: 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: 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: mechanismComponent /** null * @param mechanismComponent child to add */ public void addMechanismComponent(AbstractMechanismComponent mechanismComponent) { mechanismComponent.detach(); this.appendChild(mechanismComponent); } /** null * @return CMLElements<CMLMechanismComponent> */ public CMLElements getMechanismComponentElements() { Elements elements = this.getChildElements("mechanismComponent", 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 { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractMechanismComponent.java000077500000000000000000000226221477224461000313120ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractMechanismComponent extends CMLElement { /** local name*/ public final static String TAG = "mechanismComponent"; /** constructor. */ public AbstractMechanismComponent() { super("mechanismComponent"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractMechanismComponent(AbstractMechanismComponent 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", "mechanismComponent"); 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", "mechanismComponent"); 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", "mechanismComponent"); 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", "mechanismComponent"); 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); } /** 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 { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractMetadata.java000077500000000000000000000323201477224461000272370ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractMetadata extends CMLElement { /** local name*/ public final static String TAG = "metadata"; /** constructor. */ public AbstractMetadata() { super("metadata"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractMetadata(AbstractMetadata old) { super((CMLElement) old); } // attribute: content /** cache */ StringSTAttribute _att_content = null; /** content of metadata. * No description * @return CMLAttribute */ public CMLAttribute getContentAttribute() { return (CMLAttribute) getAttribute("content"); } /** content of metadata. * No description * @return String */ public String getContent() { StringSTAttribute att = (StringSTAttribute) this.getContentAttribute(); if (att == null) { return null; } return att.getString(); } /** content of metadata. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setContent(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_content == null) { _att_content = (StringSTAttribute) attributeFactory.getAttribute("content", "metadata"); if (_att_content == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : content probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_content); 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", "metadata"); 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", "metadata"); 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: 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", "metadata"); 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: name /** cache */ StringSTAttribute _att_name = null; /** The metadata type. * This is likely to be the Dublin Core * name or something similar. The use of "type" is an infelicitous * misnomer and we shall try to remove it. * @return CMLAttribute */ public CMLAttribute getNameAttribute() { return (CMLAttribute) getAttribute("name"); } /** The metadata type. * This is likely to be the Dublin Core * name or something similar. The use of "type" is an infelicitous * misnomer and we shall try to remove it. * @return String */ public String getName() { StringSTAttribute att = (StringSTAttribute) this.getNameAttribute(); if (att == null) { return null; } return att.getString(); } /** The metadata type. * This is likely to be the Dublin Core * name or something similar. The use of "type" is an infelicitous * misnomer and we shall try to remove it. * @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", "metadata"); 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: 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", "metadata"); 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); } StringSTAttribute _xmlContent; /** * * @return String */ public String getXMLContent() { String content = this.getValue(); if (_xmlContent == null) { _xmlContent = new StringSTAttribute("_xmlContent"); } _xmlContent.setCMLValue(content); 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("content")) { setContent(value); } else if (name.equals("convention")) { setConvention(value); } else if (name.equals("dictRef")) { setDictRef(value); } else if (name.equals("id")) { setId(value); } else if (name.equals("name")) { setName(value); } else if (name.equals("title")) { setTitle(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractMetadataList.java000077500000000000000000000340171477224461000301000ustar00rootroot00000000000000/** * 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 AbstractMetadataList extends CMLElement { /** local name*/ public final static String TAG = "metadataList"; /** constructor. */ public AbstractMetadataList() { super("metadataList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractMetadataList(AbstractMetadataList 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", "metadataList"); 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: 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", "metadataList"); 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: 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", "metadataList"); 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", "metadataList"); 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: 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", "metadataList"); 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: 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", "metadataList"); 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); } // element: metadataList /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: metadata /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param metadata child to add */ public void addMetadata(AbstractMetadata metadata) { metadata.detach(); this.appendChild(metadata); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLMetadata> */ public CMLElements getMetadataElements() { Elements elements = this.getChildElements("metadata", 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("id")) { setId(value); } else if (name.equals("title")) { setTitle(value); } else if (name.equals("convention")) { setConvention(value); } else if (name.equals("dictRef")) { setDictRef(value); } else if (name.equals("name")) { setName(value); } else if (name.equals("role")) { setRole(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractModule.java000077500000000000000000000302301477224461000267420ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractModule extends CMLElement { /** local name*/ public final static String TAG = "module"; /** constructor. */ public AbstractModule() { super("module"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractModule(AbstractModule old) { super((CMLElement) old); } // attribute: serial /** cache */ StringSTAttribute _att_serial = null; /** Serial number or other id. * No description * @return CMLAttribute */ public CMLAttribute getSerialAttribute() { return (CMLAttribute) getAttribute("serial"); } /** Serial number or other id. * No description * @return String */ public String getSerial() { StringSTAttribute att = (StringSTAttribute) this.getSerialAttribute(); if (att == null) { return null; } return att.getString(); } /** Serial number or other id. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setSerial(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_serial == null) { _att_serial = (StringSTAttribute) attributeFactory.getAttribute("serial", "module"); if (_att_serial == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : serial probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_serial); 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", "module"); 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", "module"); 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", "module"); 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", "module"); 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: 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", "module"); 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); } /** 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("serial")) { setSerial(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 if (name.equals("role")) { setRole(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractMolecule.java000077500000000000000000001142571477224461000272760ustar00rootroot00000000000000/** * 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.BooleanSTAttribute; 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 AbstractMolecule extends CMLElement { /** local name*/ public final static String TAG = "molecule"; /** constructor. */ public AbstractMolecule() { super("molecule"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractMolecule(AbstractMolecule 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", "molecule"); 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", "molecule"); 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", "molecule"); 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", "molecule"); 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", "molecule"); 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: idgen /** cache */ StringSTAttribute _att_idgen = null; /** Allows a referring element to generate a unique id. * idgen can hold a unique identifier which is copied into the id * attribute of the referenced element. This avoids multiple copies of the referenced * object with duplicate ids. EXPERIMENTAL * * @return CMLAttribute */ public CMLAttribute getIdgenAttribute() { return (CMLAttribute) getAttribute("idgen"); } /** Allows a referring element to generate a unique id. * idgen can hold a unique identifier which is copied into the id * attribute of the referenced element. This avoids multiple copies of the referenced * object with duplicate ids. EXPERIMENTAL * * @return String */ public String getIdgen() { StringSTAttribute att = (StringSTAttribute) this.getIdgenAttribute(); if (att == null) { return null; } return att.getString(); } /** Allows a referring element to generate a unique id. * idgen can hold a unique identifier which is copied into the id * attribute of the referenced element. This avoids multiple copies of the referenced * object with duplicate ids. EXPERIMENTAL * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setIdgen(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_idgen == null) { _att_idgen = (StringSTAttribute) attributeFactory.getAttribute("idgen", "molecule"); if (_att_idgen == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : idgen probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_idgen); super.addRemove(att, value); } // attribute: process /** cache */ StringSTAttribute _att_process = null; /** Keyword signifying how object is to be processed. * Semantics depend on the parent element * @return CMLAttribute */ public CMLAttribute getProcessAttribute() { return (CMLAttribute) getAttribute("process"); } /** Keyword signifying how object is to be processed. * Semantics depend on the parent element * @return String */ public String getProcess() { StringSTAttribute att = (StringSTAttribute) this.getProcessAttribute(); if (att == null) { return null; } return att.getString(); } /** Keyword signifying how object is to be processed. * Semantics depend on the parent element * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setProcess(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_process == null) { _att_process = (StringSTAttribute) attributeFactory.getAttribute("process", "molecule"); if (_att_process == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : process probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_process); super.addRemove(att, value); } // attribute: formula /** cache */ StringSTAttribute _att_formula = null; /** Simple chemical formula. * No description * @return CMLAttribute */ public CMLAttribute getFormulaAttribute() { return (CMLAttribute) getAttribute("formula"); } /** Simple chemical formula. * No description * @return String */ public String getFormula() { StringSTAttribute att = (StringSTAttribute) this.getFormulaAttribute(); if (att == null) { return null; } return att.getString(); } /** Simple chemical formula. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setFormula(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_formula == null) { _att_formula = (StringSTAttribute) attributeFactory.getAttribute("formula", "molecule"); if (_att_formula == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : formula probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_formula); 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", "molecule"); 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", "molecule"); 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: chirality /** cache */ StringSTAttribute _att_chirality = null; /** The chirality of a system or molecule. * This is being actively investigated by a IUPAC committee (2002) so the convention is likely to change. No formal default. * @return CMLAttribute */ public CMLAttribute getChiralityAttribute() { return (CMLAttribute) getAttribute("chirality"); } /** The chirality of a system or molecule. * This is being actively investigated by a IUPAC committee (2002) so the convention is likely to change. No formal default. * @return String */ public String getChirality() { StringSTAttribute att = (StringSTAttribute) this.getChiralityAttribute(); if (att == null) { return null; } return att.getString(); } /** The chirality of a system or molecule. * This is being actively investigated by a IUPAC committee (2002) so the convention is likely to change. No formal default. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setChirality(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_chirality == null) { _att_chirality = (StringSTAttribute) attributeFactory.getAttribute("chirality", "molecule"); if (_att_chirality == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : chirality probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_chirality); 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", "molecule"); 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", "molecule"); 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: 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", "molecule"); 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", "molecule"); 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: symmetryOriented /** cache */ BooleanSTAttribute _att_symmetryoriented = null; /** Is the molecule oriented to the symmetry. * No formal default, but a molecule is assumed to be oriented according to any _symmetry_ children. This is required for crystallographic data, but some systems for isolated molecules allow specification of arbitrary Cartesian or internal coordinates, which must be fitted or refined to a prescribed symmetry. In this case the attribute value is false. * @return CMLAttribute */ public CMLAttribute getSymmetryOrientedAttribute() { return (CMLAttribute) getAttribute("symmetryOriented"); } /** Is the molecule oriented to the symmetry. * No formal default, but a molecule is assumed to be oriented according to any _symmetry_ children. This is required for crystallographic data, but some systems for isolated molecules allow specification of arbitrary Cartesian or internal coordinates, which must be fitted or refined to a prescribed symmetry. In this case the attribute value is false. * @return boolean */ public boolean getSymmetryOriented() { BooleanSTAttribute att = (BooleanSTAttribute) this.getSymmetryOrientedAttribute(); if (att == null) { throw new RuntimeException("boolean attribute is unset: symmetryOriented"); } return att.getBoolean(); } /** Is the molecule oriented to the symmetry. * No formal default, but a molecule is assumed to be oriented according to any _symmetry_ children. This is required for crystallographic data, but some systems for isolated molecules allow specification of arbitrary Cartesian or internal coordinates, which must be fitted or refined to a prescribed symmetry. In this case the attribute value is false. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setSymmetryOriented(String value) throws RuntimeException { BooleanSTAttribute att = null; if (_att_symmetryoriented == null) { _att_symmetryoriented = (BooleanSTAttribute) attributeFactory.getAttribute("symmetryOriented", "molecule"); if (_att_symmetryoriented == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : symmetryOriented probably incompatible attributeGroupName and attributeName"); } } att = new BooleanSTAttribute(_att_symmetryoriented); super.addRemove(att, value); } /** Is the molecule oriented to the symmetry. * No formal default, but a molecule is assumed to be oriented according to any _symmetry_ children. This is required for crystallographic data, but some systems for isolated molecules allow specification of arbitrary Cartesian or internal coordinates, which must be fitted or refined to a prescribed symmetry. In this case the attribute value is false. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setSymmetryOriented(boolean value) throws RuntimeException { if (_att_symmetryoriented == null) { _att_symmetryoriented = (BooleanSTAttribute) attributeFactory.getAttribute("symmetryOriented", "molecule"); if (_att_symmetryoriented == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : symmetryOriented probably incompatible attributeGroupName and attributeName "); } } BooleanSTAttribute att = new BooleanSTAttribute(_att_symmetryoriented); super.addAttribute(att); att.setCMLValue(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", "molecule"); 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); } // element: angle // element: array /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param array child to add */ public void addArray(AbstractArray array) { array.detach(); this.appendChild(array); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLArray> */ public CMLElements getArrayElements() { Elements elements = this.getChildElements("array", CMLConstants.CML_NS); return new CMLElements(elements); } // element: atomArray /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param atomArray child to add */ public void addAtomArray(AbstractAtomArray atomArray) { atomArray.detach(); this.appendChild(atomArray); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLAtomArray> */ public CMLElements getAtomArrayElements() { Elements elements = this.getChildElements("atomArray", CMLConstants.CML_NS); return new CMLElements(elements); } // element: bondArray /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param bondArray child to add */ public void addBondArray(AbstractBondArray bondArray) { bondArray.detach(); this.appendChild(bondArray); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLBondArray> */ public CMLElements getBondArrayElements() { Elements elements = this.getChildElements("bondArray", CMLConstants.CML_NS); return new CMLElements(elements); } // element: formula /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param formula child to add */ public void addFormula(AbstractFormula formula) { formula.detach(); this.appendChild(formula); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLFormula> */ public CMLElements getFormulaElements() { Elements elements = this.getChildElements("formula", CMLConstants.CML_NS); return new CMLElements(elements); } /**Returns the value of the first formula element with a convention. * if an inline exists returns that value in preference. * Returns null if no formula of that convention exists * @param convention The Convention to look for. * @return The value of the formula inline or text if no inline exists. * @author nwe23 */ public String getFormulaWithConvention(String convention){ if(convention==null){ throw new IllegalArgumentException("Called with "+convention); } CMLElements forms=this.getFormulaElements(); for(CMLFormula form:forms){ if(convention.equals(form.getConvention())){ String value=form.getInline(); if(value!=null){ return value; } value = form.getValue(); return value; } } return null; } // element: label /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param label child to add */ public void addLabel(AbstractLabel label) { label.detach(); this.appendChild(label); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLLabel> */ public CMLElements getLabelElements() { Elements elements = this.getChildElements("label", CMLConstants.CML_NS); return new CMLElements(elements); } // element: molecule /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param molecule child to add */ public void addMolecule(AbstractMolecule molecule) { molecule.detach(); this.appendChild(molecule); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLMolecule> */ public CMLElements getMoleculeElements() { Elements elements = this.getChildElements("molecule", CMLConstants.CML_NS); return new CMLElements(elements); } // element: name /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param name child to add */ public void addName(AbstractName name) { name.detach(); this.appendChild(name); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLName> */ public CMLElements getNameElements() { Elements elements = this.getChildElements("name", CMLConstants.CML_NS); return new CMLElements(elements); } // element: propertyList /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param propertyList child to add */ public void addPropertyList(AbstractPropertyList propertyList) { propertyList.detach(); this.appendChild(propertyList); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLPropertyList> */ public CMLElements getPropertyListElements() { Elements elements = this.getChildElements("propertyList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: scalar /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param scalar child to add */ public void addScalar(AbstractScalar scalar) { scalar.detach(); this.appendChild(scalar); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLScalar> */ public CMLElements getScalarElements() { Elements elements = this.getChildElements("scalar", 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 if (name.equals("idgen")) { setIdgen(value); } else if (name.equals("process")) { setProcess(value); } else if (name.equals("formula")) { setFormula(value); } else if (name.equals("count")) { setCount(value); } else if (name.equals("chirality")) { setChirality(value); } else if (name.equals("formalCharge")) { setFormalCharge(value); } else if (name.equals("spinMultiplicity")) { setSpinMultiplicity(value); } else if (name.equals("symmetryOriented")) { setSymmetryOriented(value); } else if (name.equals("role")) { setRole(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractMoleculeList.java000077500000000000000000000311571477224461000301270ustar00rootroot00000000000000/** * 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 AbstractMoleculeList extends CMLElement { /** local name*/ public final static String TAG = "moleculeList"; /** constructor. */ public AbstractMoleculeList() { super("moleculeList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractMoleculeList(AbstractMoleculeList 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", "moleculeList"); 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", "moleculeList"); 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", "moleculeList"); 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", "moleculeList"); 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", "moleculeList"); 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: 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); } // element: moleculeList /** null * @param moleculeList child to add */ public void addMoleculeList(AbstractMoleculeList moleculeList) { moleculeList.detach(); this.appendChild(moleculeList); } /** null * @return CMLElements<CMLMoleculeList> */ public CMLElements getMoleculeListElements() { Elements elements = this.getChildElements("moleculeList", CMLConstants.CML_NS); return new CMLElements(elements); } // 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); } /** 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/AbstractName.java000077500000000000000000000213451477224461000264040ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractName extends CMLElement { /** local name*/ public final static String TAG = "name"; /** constructor. */ public AbstractName() { super("name"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractName(AbstractName 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", "name"); 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", "name"); 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", "name"); 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); } StringSTAttribute _xmlContent; /** * * @return String */ public String getXMLContent() { String content = this.getValue(); if (_xmlContent == null) { _xmlContent = new StringSTAttribute("_xmlContent"); } _xmlContent.setCMLValue(content); 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("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/AbstractObject.java000077500000000000000000000356321477224461000267360ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractObject extends CMLElement { /** local name*/ public final static String TAG = "object"; /** constructor. */ public AbstractObject() { super("object"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractObject(AbstractObject 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", "object"); 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", "object"); 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", "object"); 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", "object"); 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: 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", "object"); 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: 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", "object"); 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: 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", "object"); 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", "object"); 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); } /** 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("name")) { setName(value); } else if (name.equals("type")) { setType(value); } else if (name.equals("count")) { setCount(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractObservation.java000077500000000000000000000325531477224461000300220ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractObservation extends CMLElement { /** local name*/ public final static String TAG = "observation"; /** constructor. */ public AbstractObservation() { super("observation"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractObservation(AbstractObservation 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", "observation"); 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", "observation"); 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", "observation"); 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", "observation"); 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: 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", "observation"); 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: 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", "observation"); 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", "observation"); 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); } /** 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("type")) { setType(value); } else if (name.equals("count")) { setCount(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractOperator.java000077500000000000000000000253511477224461000273200ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractOperator extends CMLElement { /** local name*/ public final static String TAG = "operator"; /** constructor. */ public AbstractOperator() { super("operator"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractOperator(AbstractOperator 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", "operator"); 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", "operator"); 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", "operator"); 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", "operator"); 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: 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", "operator"); 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); } /** 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("type")) { setType(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractParameter.java000077500000000000000000000521471477224461000274500ustar00rootroot00000000000000/** * 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 AbstractParameter extends CMLElement { /** local name*/ public final static String TAG = "parameter"; /** constructor. */ public AbstractParameter() { super("parameter"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractParameter(AbstractParameter old) { super((CMLElement) old); } // 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", "parameter"); 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: 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", "parameter"); 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", "parameter"); 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", "parameter"); 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", "parameter"); 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: value /** cache */ StringSTAttribute _att_value = null; /** Value of a scalar object. * The value must be consistent with the dataType of the object. * @return CMLAttribute */ public CMLAttribute getCMLValueAttribute() { return (CMLAttribute) getAttribute("value"); } /** Value of a scalar object. * The value must be consistent with the dataType of the object. * @return String */ public String getCMLValue() { StringSTAttribute att = (StringSTAttribute) this.getCMLValueAttribute(); if (att == null) { return null; } return att.getString(); } /** Value of a scalar object. * The value must be consistent with the dataType of the object. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setCMLValue(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_value == null) { _att_value = (StringSTAttribute) attributeFactory.getAttribute("value", "parameter"); if (_att_value == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : value probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_value); super.addRemove(att, value); } // attribute: constraint /** cache */ StringSTAttribute _att_constraint = null; /** Constraint on a parameter. * Semantics not yet finalised. We anticipate "fixed", * "none" and symbolic relationships to other parameters. * @return CMLAttribute */ public CMLAttribute getConstraintAttribute() { return (CMLAttribute) getAttribute("constraint"); } /** Constraint on a parameter. * Semantics not yet finalised. We anticipate "fixed", * "none" and symbolic relationships to other parameters. * @return String */ public String getConstraint() { StringSTAttribute att = (StringSTAttribute) this.getConstraintAttribute(); if (att == null) { return null; } return att.getString(); } /** Constraint on a parameter. * Semantics not yet finalised. We anticipate "fixed", * "none" and symbolic relationships to other parameters. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setConstraint(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_constraint == null) { _att_constraint = (StringSTAttribute) attributeFactory.getAttribute("constraint", "parameter"); if (_att_constraint == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : constraint probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_constraint); 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", "parameter"); 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: 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", "parameter"); 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); } // element: scalar /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param scalar child to add */ public void addScalar(AbstractScalar scalar) { scalar.detach(); this.appendChild(scalar); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLScalar> */ public CMLElements getScalarElements() { Elements elements = this.getChildElements("scalar", CMLConstants.CML_NS); return new CMLElements(elements); } // element: array /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param array child to add */ public void addArray(AbstractArray array) { array.detach(); this.appendChild(array); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLArray> */ public CMLElements getArrayElements() { Elements elements = this.getChildElements("array", CMLConstants.CML_NS); return new CMLElements(elements); } // element: matrix /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param matrix child to add */ public void addMatrix(AbstractMatrix matrix) { matrix.detach(); this.appendChild(matrix); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLMatrix> */ public CMLElements getMatrixElements() { Elements elements = this.getChildElements("matrix", CMLConstants.CML_NS); return new CMLElements(elements); } // element: property /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param property child to add */ public void addProperty(AbstractProperty property) { property.detach(); this.appendChild(property); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLProperty> */ public CMLElements getPropertyElements() { Elements elements = this.getChildElements("property", CMLConstants.CML_NS); return new CMLElements(elements); } // element: expression /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param expression child to add */ public void addExpression(AbstractExpression expression) { expression.detach(); this.appendChild(expression); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLExpression> */ public CMLElements getExpressionElements() { Elements elements = this.getChildElements("expression", CMLConstants.CML_NS); return new CMLElements(elements); } // element: gradient /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param gradient child to add */ public void addGradient(AbstractGradient gradient) { gradient.detach(); this.appendChild(gradient); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLGradient> */ public CMLElements getGradientElements() { Elements elements = this.getChildElements("gradient", 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("ref")) { setRef(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 if (name.equals("value")) { setCMLValue(value); } else if (name.equals("constraint")) { setConstraint(value); } else if (name.equals("name")) { setName(value); } else if (name.equals("role")) { setRole(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractParameterList.java000077500000000000000000000360341477224461000303010ustar00rootroot00000000000000/** * 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 AbstractParameterList extends CMLElement { /** local name*/ public final static String TAG = "parameterList"; /** constructor. */ public AbstractParameterList() { super("parameterList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractParameterList(AbstractParameterList 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", "parameterList"); 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", "parameterList"); 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", "parameterList"); 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", "parameterList"); 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", "parameterList"); 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: 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", "parameterList"); 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); } // element: metadataList /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: name /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param name child to add */ public void addName(AbstractName name) { name.detach(); this.appendChild(name); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLName> */ public CMLElements getNameElements() { Elements elements = this.getChildElements("name", CMLConstants.CML_NS); return new CMLElements(elements); } // element: parameter /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param parameter child to add */ public void addParameter(AbstractParameter parameter) { parameter.detach(); this.appendChild(parameter); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLParameter> */ public CMLElements getParameterElements() { Elements elements = this.getChildElements("parameter", CMLConstants.CML_NS); return new CMLElements(elements); } // element: parameterList /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param parameterList child to add */ public void addParameterList(AbstractParameterList parameterList) { parameterList.detach(); this.appendChild(parameterList); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLParameterList> */ public CMLElements getParameterListElements() { Elements elements = this.getChildElements("parameterList", 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 if (name.equals("role")) { setRole(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractParticle.java000077500000000000000000000461321477224461000272700ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractParticle extends CMLElement { /** local name*/ public final static String TAG = "particle"; /** constructor. */ public AbstractParticle() { super("particle"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractParticle(AbstractParticle 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", "particle"); 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", "particle"); 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", "particle"); 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", "particle"); 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: 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", "particle"); 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: 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", "particle"); 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", "particle"); 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", "particle"); 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", "particle"); 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", "particle"); 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", "particle"); 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); } /** 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("type")) { setType(value); } else if (name.equals("x3")) { setX3(value); } else if (name.equals("y3")) { setY3(value); } else if (name.equals("z3")) { setZ3(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractPeak.java000077500000000000000000001704541477224461000264120ustar00rootroot00000000000000/** * 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.StringArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractPeak extends CMLElement { /** local name*/ public final static String TAG = "peak"; /** constructor. */ public AbstractPeak() { super("peak"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractPeak(AbstractPeak 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", "peak"); 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", "peak"); 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", "peak"); 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", "peak"); 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", "peak"); 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: peakHeight /** cache */ DoubleSTAttribute _att_peakheight = null; /** Height of a peak. * For 1-dimensional data * (e.g. y vs x) hould use the same units as the appropriate * axis (e.g. y). * @return CMLAttribute */ public CMLAttribute getPeakHeightAttribute() { return (CMLAttribute) getAttribute("peakHeight"); } /** Height of a peak. * For 1-dimensional data * (e.g. y vs x) hould use the same units as the appropriate * axis (e.g. y). * @return double */ public double getPeakHeight() { DoubleSTAttribute att = (DoubleSTAttribute) this.getPeakHeightAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Height of a peak. * For 1-dimensional data * (e.g. y vs x) hould use the same units as the appropriate * axis (e.g. y). * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPeakHeight(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_peakheight == null) { _att_peakheight = (DoubleSTAttribute) attributeFactory.getAttribute("peakHeight", "peak"); if (_att_peakheight == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : peakHeight probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_peakheight); super.addRemove(att, value); } /** Height of a peak. * For 1-dimensional data * (e.g. y vs x) hould use the same units as the appropriate * axis (e.g. y). * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPeakHeight(double value) throws RuntimeException { if (_att_peakheight == null) { _att_peakheight = (DoubleSTAttribute) attributeFactory.getAttribute("peakHeight", "peak"); if (_att_peakheight == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : peakHeight probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_peakheight); super.addAttribute(att); att.setCMLValue(value); } // attribute: peakMultiplicity /** cache */ StringSTAttribute _att_peakmultiplicity = null; /** Multiplicity of a peak. * Uses a semi-controlled vocabulary. * @return CMLAttribute */ public CMLAttribute getPeakMultiplicityAttribute() { return (CMLAttribute) getAttribute("peakMultiplicity"); } /** Multiplicity of a peak. * Uses a semi-controlled vocabulary. * @return String */ public String getPeakMultiplicity() { StringSTAttribute att = (StringSTAttribute) this.getPeakMultiplicityAttribute(); if (att == null) { return null; } return att.getString(); } /** Multiplicity of a peak. * Uses a semi-controlled vocabulary. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPeakMultiplicity(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_peakmultiplicity == null) { _att_peakmultiplicity = (StringSTAttribute) attributeFactory.getAttribute("peakMultiplicity", "peak"); if (_att_peakmultiplicity == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : peakMultiplicity probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_peakmultiplicity); super.addRemove(att, value); } // attribute: peakShape /** cache */ StringSTAttribute _att_peakshape = null; /** Shape of a peak. * Semi-controlled vocabulary such as broad or sharp. * @return CMLAttribute */ public CMLAttribute getPeakShapeAttribute() { return (CMLAttribute) getAttribute("peakShape"); } /** Shape of a peak. * Semi-controlled vocabulary such as broad or sharp. * @return String */ public String getPeakShape() { StringSTAttribute att = (StringSTAttribute) this.getPeakShapeAttribute(); if (att == null) { return null; } return att.getString(); } /** Shape of a peak. * Semi-controlled vocabulary such as broad or sharp. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPeakShape(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_peakshape == null) { _att_peakshape = (StringSTAttribute) attributeFactory.getAttribute("peakShape", "peak"); if (_att_peakshape == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : peakShape probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_peakshape); super.addRemove(att, value); } // attribute: integral /** cache */ StringSTAttribute _att_integral = null; /** Area under a peak. * Unfortunately units are usually arbitrary and not related to the x- and y- axis units, and in this case _peakUnits_ should be use. * @return CMLAttribute */ public CMLAttribute getIntegralAttribute() { return (CMLAttribute) getAttribute("integral"); } /** Area under a peak. * Unfortunately units are usually arbitrary and not related to the x- and y- axis units, and in this case _peakUnits_ should be use. * @return String */ public String getIntegral() { StringSTAttribute att = (StringSTAttribute) this.getIntegralAttribute(); if (att == null) { return null; } return att.getString(); } /** Area under a peak. * Unfortunately units are usually arbitrary and not related to the x- and y- axis units, and in this case _peakUnits_ should be use. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setIntegral(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_integral == null) { _att_integral = (StringSTAttribute) attributeFactory.getAttribute("integral", "peak"); if (_att_integral == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : integral probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_integral); super.addRemove(att, value); } // attribute: peakUnits /** cache */ StringSTAttribute _att_peakunits = null; /** Units for a peak or peak integral. * For 2-dimensional spectra the units represent the observation. For an integral they are usually arbitrary and not related to the x- and y- axis units. Thus NMR spectra may use hydrogen count as the units for the peak area. * @return CMLAttribute */ public CMLAttribute getPeakUnitsAttribute() { return (CMLAttribute) getAttribute("peakUnits"); } /** Units for a peak or peak integral. * For 2-dimensional spectra the units represent the observation. For an integral they are usually arbitrary and not related to the x- and y- axis units. Thus NMR spectra may use hydrogen count as the units for the peak area. * @return String */ public String getPeakUnits() { StringSTAttribute att = (StringSTAttribute) this.getPeakUnitsAttribute(); if (att == null) { return null; } return att.getString(); } /** Units for a peak or peak integral. * For 2-dimensional spectra the units represent the observation. For an integral they are usually arbitrary and not related to the x- and y- axis units. Thus NMR spectra may use hydrogen count as the units for the peak area. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPeakUnits(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_peakunits == null) { _att_peakunits = (StringSTAttribute) attributeFactory.getAttribute("peakUnits", "peak"); if (_att_peakunits == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : peakUnits probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_peakunits); super.addRemove(att, value); } // attribute: xMin /** cache */ DoubleSTAttribute _att_xmin = null; /** Minimum xValue. * Annotates x-axis data with a minimum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses xUnits or the same units as the data. There may or may not * be a _xMax_ attribute but if so xMin should be less than or equals * to it. * @return CMLAttribute */ public CMLAttribute getXMinAttribute() { return (CMLAttribute) getAttribute("xMin"); } /** Minimum xValue. * Annotates x-axis data with a minimum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses xUnits or the same units as the data. There may or may not * be a _xMax_ attribute but if so xMin should be less than or equals * to it. * @return double */ public double getXMin() { DoubleSTAttribute att = (DoubleSTAttribute) this.getXMinAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Minimum xValue. * Annotates x-axis data with a minimum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses xUnits or the same units as the data. There may or may not * be a _xMax_ attribute but if so xMin should be less than or equals * to it. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMin(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_xmin == null) { _att_xmin = (DoubleSTAttribute) attributeFactory.getAttribute("xMin", "peak"); if (_att_xmin == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xMin probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_xmin); super.addRemove(att, value); } /** Minimum xValue. * Annotates x-axis data with a minimum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses xUnits or the same units as the data. There may or may not * be a _xMax_ attribute but if so xMin should be less than or equals * to it. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMin(double value) throws RuntimeException { if (_att_xmin == null) { _att_xmin = (DoubleSTAttribute) attributeFactory.getAttribute("xMin", "peak"); if (_att_xmin == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xMin probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_xmin); super.addAttribute(att); att.setCMLValue(value); } // attribute: xMax /** cache */ DoubleSTAttribute _att_xmax = null; /** Maximum xValue. * Annotates x-axis data with a maximum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses xUnits or the same units as the data. There may or may not * be a _xMin_ attribute but if so xMax should be greater than or * equals to it. * @return CMLAttribute */ public CMLAttribute getXMaxAttribute() { return (CMLAttribute) getAttribute("xMax"); } /** Maximum xValue. * Annotates x-axis data with a maximum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses xUnits or the same units as the data. There may or may not * be a _xMin_ attribute but if so xMax should be greater than or * equals to it. * @return double */ public double getXMax() { DoubleSTAttribute att = (DoubleSTAttribute) this.getXMaxAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Maximum xValue. * Annotates x-axis data with a maximum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses xUnits or the same units as the data. There may or may not * be a _xMin_ attribute but if so xMax should be greater than or * equals to it. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMax(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_xmax == null) { _att_xmax = (DoubleSTAttribute) attributeFactory.getAttribute("xMax", "peak"); if (_att_xmax == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xMax probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_xmax); super.addRemove(att, value); } /** Maximum xValue. * Annotates x-axis data with a maximum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses xUnits or the same units as the data. There may or may not * be a _xMin_ attribute but if so xMax should be greater than or * equals to it. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMax(double value) throws RuntimeException { if (_att_xmax == null) { _att_xmax = (DoubleSTAttribute) attributeFactory.getAttribute("xMax", "peak"); if (_att_xmax == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xMax probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_xmax); super.addAttribute(att); att.setCMLValue(value); } // attribute: xValue /** cache */ DoubleSTAttribute _att_xvalue = null; /** Value along an x axis. * Annotates x-axis data with a value. It * is typically used for the location of a _peak_ or _peakGroup_. It * uses xUnits or the same units as the data. * @return CMLAttribute */ public CMLAttribute getXValueAttribute() { return (CMLAttribute) getAttribute("xValue"); } /** Value along an x axis. * Annotates x-axis data with a value. It * is typically used for the location of a _peak_ or _peakGroup_. It * uses xUnits or the same units as the data. * @return double */ public double getXValue() { DoubleSTAttribute att = (DoubleSTAttribute) this.getXValueAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Value along an x axis. * Annotates x-axis data with a value. It * is typically used for the location of a _peak_ or _peakGroup_. It * uses xUnits or the same units as the data. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXValue(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_xvalue == null) { _att_xvalue = (DoubleSTAttribute) attributeFactory.getAttribute("xValue", "peak"); if (_att_xvalue == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xValue probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_xvalue); super.addRemove(att, value); } /** Value along an x axis. * Annotates x-axis data with a value. It * is typically used for the location of a _peak_ or _peakGroup_. It * uses xUnits or the same units as the data. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXValue(double value) throws RuntimeException { if (_att_xvalue == null) { _att_xvalue = (DoubleSTAttribute) attributeFactory.getAttribute("xValue", "peak"); if (_att_xvalue == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xValue probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_xvalue); super.addAttribute(att); att.setCMLValue(value); } // attribute: xWidth /** cache */ DoubleSTAttribute _att_xwidth = null; /** An unsigned interval along an x axis. * It is typically used for the width of * a _peak_ or _peakGroup_ but could be used for any range. It uses * xUnits or the same units as the data. * @return CMLAttribute */ public CMLAttribute getXWidthAttribute() { return (CMLAttribute) getAttribute("xWidth"); } /** An unsigned interval along an x axis. * It is typically used for the width of * a _peak_ or _peakGroup_ but could be used for any range. It uses * xUnits or the same units as the data. * @return double */ public double getXWidth() { DoubleSTAttribute att = (DoubleSTAttribute) this.getXWidthAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** An unsigned interval along an x axis. * It is typically used for the width of * a _peak_ or _peakGroup_ but could be used for any range. It uses * xUnits or the same units as the data. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXWidth(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_xwidth == null) { _att_xwidth = (DoubleSTAttribute) attributeFactory.getAttribute("xWidth", "peak"); if (_att_xwidth == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xWidth probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_xwidth); super.addRemove(att, value); } /** An unsigned interval along an x axis. * It is typically used for the width of * a _peak_ or _peakGroup_ but could be used for any range. It uses * xUnits or the same units as the data. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXWidth(double value) throws RuntimeException { if (_att_xwidth == null) { _att_xwidth = (DoubleSTAttribute) attributeFactory.getAttribute("xWidth", "peak"); if (_att_xwidth == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xWidth probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_xwidth); super.addAttribute(att); att.setCMLValue(value); } // attribute: xUnits /** cache */ StringSTAttribute _att_xunits = null; /** Units for x axis. * All x-axis data must have unambiguous units. Ideally the data and _xMin_ or _xValue_ should share the same units but different xUnits can be used as long as it is clear.. * @return CMLAttribute */ public CMLAttribute getXUnitsAttribute() { return (CMLAttribute) getAttribute("xUnits"); } /** Units for x axis. * All x-axis data must have unambiguous units. Ideally the data and _xMin_ or _xValue_ should share the same units but different xUnits can be used as long as it is clear.. * @return String */ public String getXUnits() { StringSTAttribute att = (StringSTAttribute) this.getXUnitsAttribute(); if (att == null) { return null; } return att.getString(); } /** Units for x axis. * All x-axis data must have unambiguous units. Ideally the data and _xMin_ or _xValue_ should share the same units but different xUnits can be used as long as it is clear.. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXUnits(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_xunits == null) { _att_xunits = (StringSTAttribute) attributeFactory.getAttribute("xUnits", "peak"); if (_att_xunits == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xUnits probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_xunits); super.addRemove(att, value); } // attribute: yMin /** cache */ DoubleSTAttribute _att_ymin = null; /** Minimum yValue. * Annotates y-axis data with a minimum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses yUnits or the same units as the data. There may or may * not be a _yMax_ attribute but if so yMin should be less than or * equal to it. * @return CMLAttribute */ public CMLAttribute getYMinAttribute() { return (CMLAttribute) getAttribute("yMin"); } /** Minimum yValue. * Annotates y-axis data with a minimum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses yUnits or the same units as the data. There may or may * not be a _yMax_ attribute but if so yMin should be less than or * equal to it. * @return double */ public double getYMin() { DoubleSTAttribute att = (DoubleSTAttribute) this.getYMinAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Minimum yValue. * Annotates y-axis data with a minimum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses yUnits or the same units as the data. There may or may * not be a _yMax_ attribute but if so yMin should be less than or * equal to it. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYMin(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_ymin == null) { _att_ymin = (DoubleSTAttribute) attributeFactory.getAttribute("yMin", "peak"); if (_att_ymin == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yMin probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_ymin); super.addRemove(att, value); } /** Minimum yValue. * Annotates y-axis data with a minimum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses yUnits or the same units as the data. There may or may * not be a _yMax_ attribute but if so yMin should be less than or * equal to it. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYMin(double value) throws RuntimeException { if (_att_ymin == null) { _att_ymin = (DoubleSTAttribute) attributeFactory.getAttribute("yMin", "peak"); if (_att_ymin == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yMin probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_ymin); super.addAttribute(att); att.setCMLValue(value); } // attribute: yMax /** cache */ DoubleSTAttribute _att_ymax = null; /** Maximum yValue. * Annotates y-axis data with a maximum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses yUnits or the same units as the data. There may or may not * be a _yMin_ attribute but if so yMax should be greater than or * equals to it. * @return CMLAttribute */ public CMLAttribute getYMaxAttribute() { return (CMLAttribute) getAttribute("yMax"); } /** Maximum yValue. * Annotates y-axis data with a maximum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses yUnits or the same units as the data. There may or may not * be a _yMin_ attribute but if so yMax should be greater than or * equals to it. * @return double */ public double getYMax() { DoubleSTAttribute att = (DoubleSTAttribute) this.getYMaxAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Maximum yValue. * Annotates y-axis data with a maximum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses yUnits or the same units as the data. There may or may not * be a _yMin_ attribute but if so yMax should be greater than or * equals to it. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYMax(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_ymax == null) { _att_ymax = (DoubleSTAttribute) attributeFactory.getAttribute("yMax", "peak"); if (_att_ymax == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yMax probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_ymax); super.addRemove(att, value); } /** Maximum yValue. * Annotates y-axis data with a maximum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses yUnits or the same units as the data. There may or may not * be a _yMin_ attribute but if so yMax should be greater than or * equals to it. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYMax(double value) throws RuntimeException { if (_att_ymax == null) { _att_ymax = (DoubleSTAttribute) attributeFactory.getAttribute("yMax", "peak"); if (_att_ymax == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yMax probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_ymax); super.addAttribute(att); att.setCMLValue(value); } // attribute: yValue /** cache */ DoubleSTAttribute _att_yvalue = null; /** Value along a y axis. * Annotates y-axis data with a value. It * is typically used for the location of a _peak_ or _peakGroup_. It * uses yUnits or the same units as the data. * @return CMLAttribute */ public CMLAttribute getYValueAttribute() { return (CMLAttribute) getAttribute("yValue"); } /** Value along a y axis. * Annotates y-axis data with a value. It * is typically used for the location of a _peak_ or _peakGroup_. It * uses yUnits or the same units as the data. * @return double */ public double getYValue() { DoubleSTAttribute att = (DoubleSTAttribute) this.getYValueAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Value along a y axis. * Annotates y-axis data with a value. It * is typically used for the location of a _peak_ or _peakGroup_. It * uses yUnits or the same units as the data. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYValue(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_yvalue == null) { _att_yvalue = (DoubleSTAttribute) attributeFactory.getAttribute("yValue", "peak"); if (_att_yvalue == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yValue probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_yvalue); super.addRemove(att, value); } /** Value along a y axis. * Annotates y-axis data with a value. It * is typically used for the location of a _peak_ or _peakGroup_. It * uses yUnits or the same units as the data. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYValue(double value) throws RuntimeException { if (_att_yvalue == null) { _att_yvalue = (DoubleSTAttribute) attributeFactory.getAttribute("yValue", "peak"); if (_att_yvalue == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yValue probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_yvalue); super.addAttribute(att); att.setCMLValue(value); } // attribute: yWidth /** cache */ DoubleSTAttribute _att_ywidth = null; /** An unsigned interval along a y axis. * It is typically used for the width of * a _peak_ or _peakGroup_ but could be used for any range. It uses * yUnits or the same units as the data. * @return CMLAttribute */ public CMLAttribute getYWidthAttribute() { return (CMLAttribute) getAttribute("yWidth"); } /** An unsigned interval along a y axis. * It is typically used for the width of * a _peak_ or _peakGroup_ but could be used for any range. It uses * yUnits or the same units as the data. * @return double */ public double getYWidth() { DoubleSTAttribute att = (DoubleSTAttribute) this.getYWidthAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** An unsigned interval along a y axis. * It is typically used for the width of * a _peak_ or _peakGroup_ but could be used for any range. It uses * yUnits or the same units as the data. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYWidth(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_ywidth == null) { _att_ywidth = (DoubleSTAttribute) attributeFactory.getAttribute("yWidth", "peak"); if (_att_ywidth == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yWidth probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_ywidth); super.addRemove(att, value); } /** An unsigned interval along a y axis. * It is typically used for the width of * a _peak_ or _peakGroup_ but could be used for any range. It uses * yUnits or the same units as the data. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYWidth(double value) throws RuntimeException { if (_att_ywidth == null) { _att_ywidth = (DoubleSTAttribute) attributeFactory.getAttribute("yWidth", "peak"); if (_att_ywidth == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yWidth probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_ywidth); super.addAttribute(att); att.setCMLValue(value); } // attribute: yUnits /** cache */ StringSTAttribute _att_yunits = null; /** Units for y axis. * All y-axis data must have unambiguous units. Ideally the data and _yMin_ or _yValue_ should share the same units but different yUnits can be used as long as it is clear. * @return CMLAttribute */ public CMLAttribute getYUnitsAttribute() { return (CMLAttribute) getAttribute("yUnits"); } /** Units for y axis. * All y-axis data must have unambiguous units. Ideally the data and _yMin_ or _yValue_ should share the same units but different yUnits can be used as long as it is clear. * @return String */ public String getYUnits() { StringSTAttribute att = (StringSTAttribute) this.getYUnitsAttribute(); if (att == null) { return null; } return att.getString(); } /** Units for y axis. * All y-axis data must have unambiguous units. Ideally the data and _yMin_ or _yValue_ should share the same units but different yUnits can be used as long as it is clear. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYUnits(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_yunits == null) { _att_yunits = (StringSTAttribute) attributeFactory.getAttribute("yUnits", "peak"); if (_att_yunits == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yUnits probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_yunits); super.addRemove(att, value); } // attribute: atomRefs /** cache */ StringArraySTAttribute _att_atomrefs = null; /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @return CMLAttribute */ public CMLAttribute getAtomRefsAttribute() { return (CMLAttribute) getAttribute("atomRefs"); } /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @return String[] */ public String[] getAtomRefs() { StringArraySTAttribute att = (StringArraySTAttribute) this.getAtomRefsAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefs(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_atomrefs == null) { _att_atomrefs = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs", "peak"); if (_att_atomrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_atomrefs); super.addRemove(att, value); } /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefs(String[] value) throws RuntimeException { if (_att_atomrefs == null) { _att_atomrefs = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs", "peak"); if (_att_atomrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_atomrefs); super.addAttribute(att); att.setCMLValue(value); } // attribute: bondRefs /** cache */ StringArraySTAttribute _att_bondrefs = null; /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @return CMLAttribute */ public CMLAttribute getBondRefsAttribute() { return (CMLAttribute) getAttribute("bondRefs"); } /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @return String[] */ public String[] getBondRefs() { StringArraySTAttribute att = (StringArraySTAttribute) this.getBondRefsAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setBondRefs(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_bondrefs == null) { _att_bondrefs = (StringArraySTAttribute) attributeFactory.getAttribute("bondRefs", "peak"); if (_att_bondrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : bondRefs probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_bondrefs); super.addRemove(att, value); } /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setBondRefs(String[] value) throws RuntimeException { if (_att_bondrefs == null) { _att_bondrefs = (StringArraySTAttribute) attributeFactory.getAttribute("bondRefs", "peak"); if (_att_bondrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : bondRefs probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_bondrefs); super.addAttribute(att); att.setCMLValue(value); } // attribute: moleculeRefs /** cache */ StringArraySTAttribute _att_moleculerefs = null; /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @return CMLAttribute */ public CMLAttribute getMoleculeRefsAttribute() { return (CMLAttribute) getAttribute("moleculeRefs"); } /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @return String[] */ public String[] getMoleculeRefs() { StringArraySTAttribute att = (StringArraySTAttribute) this.getMoleculeRefsAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMoleculeRefs(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_moleculerefs == null) { _att_moleculerefs = (StringArraySTAttribute) attributeFactory.getAttribute("moleculeRefs", "peak"); if (_att_moleculerefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : moleculeRefs probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_moleculerefs); super.addRemove(att, value); } /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMoleculeRefs(String[] value) throws RuntimeException { if (_att_moleculerefs == null) { _att_moleculerefs = (StringArraySTAttribute) attributeFactory.getAttribute("moleculeRefs", "peak"); if (_att_moleculerefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : moleculeRefs probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_moleculerefs); super.addAttribute(att); att.setCMLValue(value); } // element: atom /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @param atom child to add */ public void addAtom(AbstractAtom atom) { atom.detach(); this.appendChild(atom); } /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @return CMLElements<CMLAtom> */ public CMLElements getAtomElements() { Elements elements = this.getChildElements("atom", CMLConstants.CML_NS); return new CMLElements(elements); } // element: bond /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @param bond child to add */ public void addBond(AbstractBond bond) { bond.detach(); this.appendChild(bond); } /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @return CMLElements<CMLBond> */ public CMLElements getBondElements() { Elements elements = this.getChildElements("bond", CMLConstants.CML_NS); return new CMLElements(elements); } // element: molecule /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @param molecule child to add */ public void addMolecule(AbstractMolecule molecule) { molecule.detach(); this.appendChild(molecule); } /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @return CMLElements<CMLMolecule> */ public CMLElements getMoleculeElements() { Elements elements = this.getChildElements("molecule", CMLConstants.CML_NS); return new CMLElements(elements); } // element: peakStructure /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @param peakStructure child to add */ public void addPeakStructure(AbstractPeakStructure peakStructure) { peakStructure.detach(); this.appendChild(peakStructure); } /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @return CMLElements<CMLPeakStructure> */ public CMLElements getPeakStructureElements() { Elements elements = this.getChildElements("peakStructure", 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 if (name.equals("peakHeight")) { setPeakHeight(value); } else if (name.equals("peakMultiplicity")) { setPeakMultiplicity(value); } else if (name.equals("peakShape")) { setPeakShape(value); } else if (name.equals("integral")) { setIntegral(value); } else if (name.equals("peakUnits")) { setPeakUnits(value); } else if (name.equals("xMin")) { setXMin(value); } else if (name.equals("xMax")) { setXMax(value); } else if (name.equals("xValue")) { setXValue(value); } else if (name.equals("xWidth")) { setXWidth(value); } else if (name.equals("xUnits")) { setXUnits(value); } else if (name.equals("yMin")) { setYMin(value); } else if (name.equals("yMax")) { setYMax(value); } else if (name.equals("yValue")) { setYValue(value); } else if (name.equals("yWidth")) { setYWidth(value); } else if (name.equals("yUnits")) { setYUnits(value); } else if (name.equals("atomRefs")) { setAtomRefs(value); } else if (name.equals("bondRefs")) { setBondRefs(value); } else if (name.equals("moleculeRefs")) { setMoleculeRefs(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractPeakGroup.java000077500000000000000000001725461477224461000274330ustar00rootroot00000000000000/** * 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.StringArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractPeakGroup extends CMLElement { /** local name*/ public final static String TAG = "peakGroup"; /** constructor. */ public AbstractPeakGroup() { super("peakGroup"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractPeakGroup(AbstractPeakGroup 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", "peakGroup"); 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", "peakGroup"); 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", "peakGroup"); 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", "peakGroup"); 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", "peakGroup"); 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: peakHeight /** cache */ DoubleSTAttribute _att_peakheight = null; /** Height of a peak. * For 1-dimensional data * (e.g. y vs x) hould use the same units as the appropriate * axis (e.g. y). * @return CMLAttribute */ public CMLAttribute getPeakHeightAttribute() { return (CMLAttribute) getAttribute("peakHeight"); } /** Height of a peak. * For 1-dimensional data * (e.g. y vs x) hould use the same units as the appropriate * axis (e.g. y). * @return double */ public double getPeakHeight() { DoubleSTAttribute att = (DoubleSTAttribute) this.getPeakHeightAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Height of a peak. * For 1-dimensional data * (e.g. y vs x) hould use the same units as the appropriate * axis (e.g. y). * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPeakHeight(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_peakheight == null) { _att_peakheight = (DoubleSTAttribute) attributeFactory.getAttribute("peakHeight", "peakGroup"); if (_att_peakheight == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : peakHeight probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_peakheight); super.addRemove(att, value); } /** Height of a peak. * For 1-dimensional data * (e.g. y vs x) hould use the same units as the appropriate * axis (e.g. y). * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPeakHeight(double value) throws RuntimeException { if (_att_peakheight == null) { _att_peakheight = (DoubleSTAttribute) attributeFactory.getAttribute("peakHeight", "peakGroup"); if (_att_peakheight == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : peakHeight probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_peakheight); super.addAttribute(att); att.setCMLValue(value); } // attribute: peakMultiplicity /** cache */ StringSTAttribute _att_peakmultiplicity = null; /** Multiplicity of a peak. * Uses a semi-controlled vocabulary. * @return CMLAttribute */ public CMLAttribute getPeakMultiplicityAttribute() { return (CMLAttribute) getAttribute("peakMultiplicity"); } /** Multiplicity of a peak. * Uses a semi-controlled vocabulary. * @return String */ public String getPeakMultiplicity() { StringSTAttribute att = (StringSTAttribute) this.getPeakMultiplicityAttribute(); if (att == null) { return null; } return att.getString(); } /** Multiplicity of a peak. * Uses a semi-controlled vocabulary. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPeakMultiplicity(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_peakmultiplicity == null) { _att_peakmultiplicity = (StringSTAttribute) attributeFactory.getAttribute("peakMultiplicity", "peakGroup"); if (_att_peakmultiplicity == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : peakMultiplicity probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_peakmultiplicity); super.addRemove(att, value); } // attribute: peakShape /** cache */ StringSTAttribute _att_peakshape = null; /** Shape of a peak. * Semi-controlled vocabulary such as broad or sharp. * @return CMLAttribute */ public CMLAttribute getPeakShapeAttribute() { return (CMLAttribute) getAttribute("peakShape"); } /** Shape of a peak. * Semi-controlled vocabulary such as broad or sharp. * @return String */ public String getPeakShape() { StringSTAttribute att = (StringSTAttribute) this.getPeakShapeAttribute(); if (att == null) { return null; } return att.getString(); } /** Shape of a peak. * Semi-controlled vocabulary such as broad or sharp. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPeakShape(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_peakshape == null) { _att_peakshape = (StringSTAttribute) attributeFactory.getAttribute("peakShape", "peakGroup"); if (_att_peakshape == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : peakShape probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_peakshape); super.addRemove(att, value); } // attribute: integral /** cache */ StringSTAttribute _att_integral = null; /** Area under a peak. * Unfortunately units are usually arbitrary and not related to the x- and y- axis units, and in this case _peakUnits_ should be use. * @return CMLAttribute */ public CMLAttribute getIntegralAttribute() { return (CMLAttribute) getAttribute("integral"); } /** Area under a peak. * Unfortunately units are usually arbitrary and not related to the x- and y- axis units, and in this case _peakUnits_ should be use. * @return String */ public String getIntegral() { StringSTAttribute att = (StringSTAttribute) this.getIntegralAttribute(); if (att == null) { return null; } return att.getString(); } /** Area under a peak. * Unfortunately units are usually arbitrary and not related to the x- and y- axis units, and in this case _peakUnits_ should be use. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setIntegral(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_integral == null) { _att_integral = (StringSTAttribute) attributeFactory.getAttribute("integral", "peakGroup"); if (_att_integral == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : integral probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_integral); super.addRemove(att, value); } // attribute: peakUnits /** cache */ StringSTAttribute _att_peakunits = null; /** Units for a peak or peak integral. * For 2-dimensional spectra the units represent the observation. For an integral they are usually arbitrary and not related to the x- and y- axis units. Thus NMR spectra may use hydrogen count as the units for the peak area. * @return CMLAttribute */ public CMLAttribute getPeakUnitsAttribute() { return (CMLAttribute) getAttribute("peakUnits"); } /** Units for a peak or peak integral. * For 2-dimensional spectra the units represent the observation. For an integral they are usually arbitrary and not related to the x- and y- axis units. Thus NMR spectra may use hydrogen count as the units for the peak area. * @return String */ public String getPeakUnits() { StringSTAttribute att = (StringSTAttribute) this.getPeakUnitsAttribute(); if (att == null) { return null; } return att.getString(); } /** Units for a peak or peak integral. * For 2-dimensional spectra the units represent the observation. For an integral they are usually arbitrary and not related to the x- and y- axis units. Thus NMR spectra may use hydrogen count as the units for the peak area. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPeakUnits(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_peakunits == null) { _att_peakunits = (StringSTAttribute) attributeFactory.getAttribute("peakUnits", "peakGroup"); if (_att_peakunits == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : peakUnits probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_peakunits); super.addRemove(att, value); } // attribute: xMin /** cache */ DoubleSTAttribute _att_xmin = null; /** Minimum xValue. * Annotates x-axis data with a minimum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses xUnits or the same units as the data. There may or may not * be a _xMax_ attribute but if so xMin should be less than or equals * to it. * @return CMLAttribute */ public CMLAttribute getXMinAttribute() { return (CMLAttribute) getAttribute("xMin"); } /** Minimum xValue. * Annotates x-axis data with a minimum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses xUnits or the same units as the data. There may or may not * be a _xMax_ attribute but if so xMin should be less than or equals * to it. * @return double */ public double getXMin() { DoubleSTAttribute att = (DoubleSTAttribute) this.getXMinAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Minimum xValue. * Annotates x-axis data with a minimum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses xUnits or the same units as the data. There may or may not * be a _xMax_ attribute but if so xMin should be less than or equals * to it. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMin(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_xmin == null) { _att_xmin = (DoubleSTAttribute) attributeFactory.getAttribute("xMin", "peakGroup"); if (_att_xmin == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xMin probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_xmin); super.addRemove(att, value); } /** Minimum xValue. * Annotates x-axis data with a minimum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses xUnits or the same units as the data. There may or may not * be a _xMax_ attribute but if so xMin should be less than or equals * to it. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMin(double value) throws RuntimeException { if (_att_xmin == null) { _att_xmin = (DoubleSTAttribute) attributeFactory.getAttribute("xMin", "peakGroup"); if (_att_xmin == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xMin probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_xmin); super.addAttribute(att); att.setCMLValue(value); } // attribute: xMax /** cache */ DoubleSTAttribute _att_xmax = null; /** Maximum xValue. * Annotates x-axis data with a maximum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses xUnits or the same units as the data. There may or may not * be a _xMin_ attribute but if so xMax should be greater than or * equals to it. * @return CMLAttribute */ public CMLAttribute getXMaxAttribute() { return (CMLAttribute) getAttribute("xMax"); } /** Maximum xValue. * Annotates x-axis data with a maximum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses xUnits or the same units as the data. There may or may not * be a _xMin_ attribute but if so xMax should be greater than or * equals to it. * @return double */ public double getXMax() { DoubleSTAttribute att = (DoubleSTAttribute) this.getXMaxAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Maximum xValue. * Annotates x-axis data with a maximum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses xUnits or the same units as the data. There may or may not * be a _xMin_ attribute but if so xMax should be greater than or * equals to it. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMax(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_xmax == null) { _att_xmax = (DoubleSTAttribute) attributeFactory.getAttribute("xMax", "peakGroup"); if (_att_xmax == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xMax probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_xmax); super.addRemove(att, value); } /** Maximum xValue. * Annotates x-axis data with a maximum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses xUnits or the same units as the data. There may or may not * be a _xMin_ attribute but if so xMax should be greater than or * equals to it. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMax(double value) throws RuntimeException { if (_att_xmax == null) { _att_xmax = (DoubleSTAttribute) attributeFactory.getAttribute("xMax", "peakGroup"); if (_att_xmax == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xMax probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_xmax); super.addAttribute(att); att.setCMLValue(value); } // attribute: xValue /** cache */ DoubleSTAttribute _att_xvalue = null; /** Value along an x axis. * Annotates x-axis data with a value. It * is typically used for the location of a _peak_ or _peakGroup_. It * uses xUnits or the same units as the data. * @return CMLAttribute */ public CMLAttribute getXValueAttribute() { return (CMLAttribute) getAttribute("xValue"); } /** Value along an x axis. * Annotates x-axis data with a value. It * is typically used for the location of a _peak_ or _peakGroup_. It * uses xUnits or the same units as the data. * @return double */ public double getXValue() { DoubleSTAttribute att = (DoubleSTAttribute) this.getXValueAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Value along an x axis. * Annotates x-axis data with a value. It * is typically used for the location of a _peak_ or _peakGroup_. It * uses xUnits or the same units as the data. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXValue(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_xvalue == null) { _att_xvalue = (DoubleSTAttribute) attributeFactory.getAttribute("xValue", "peakGroup"); if (_att_xvalue == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xValue probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_xvalue); super.addRemove(att, value); } /** Value along an x axis. * Annotates x-axis data with a value. It * is typically used for the location of a _peak_ or _peakGroup_. It * uses xUnits or the same units as the data. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXValue(double value) throws RuntimeException { if (_att_xvalue == null) { _att_xvalue = (DoubleSTAttribute) attributeFactory.getAttribute("xValue", "peakGroup"); if (_att_xvalue == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xValue probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_xvalue); super.addAttribute(att); att.setCMLValue(value); } // attribute: xWidth /** cache */ DoubleSTAttribute _att_xwidth = null; /** An unsigned interval along an x axis. * It is typically used for the width of * a _peak_ or _peakGroup_ but could be used for any range. It uses * xUnits or the same units as the data. * @return CMLAttribute */ public CMLAttribute getXWidthAttribute() { return (CMLAttribute) getAttribute("xWidth"); } /** An unsigned interval along an x axis. * It is typically used for the width of * a _peak_ or _peakGroup_ but could be used for any range. It uses * xUnits or the same units as the data. * @return double */ public double getXWidth() { DoubleSTAttribute att = (DoubleSTAttribute) this.getXWidthAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** An unsigned interval along an x axis. * It is typically used for the width of * a _peak_ or _peakGroup_ but could be used for any range. It uses * xUnits or the same units as the data. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXWidth(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_xwidth == null) { _att_xwidth = (DoubleSTAttribute) attributeFactory.getAttribute("xWidth", "peakGroup"); if (_att_xwidth == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xWidth probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_xwidth); super.addRemove(att, value); } /** An unsigned interval along an x axis. * It is typically used for the width of * a _peak_ or _peakGroup_ but could be used for any range. It uses * xUnits or the same units as the data. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXWidth(double value) throws RuntimeException { if (_att_xwidth == null) { _att_xwidth = (DoubleSTAttribute) attributeFactory.getAttribute("xWidth", "peakGroup"); if (_att_xwidth == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xWidth probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_xwidth); super.addAttribute(att); att.setCMLValue(value); } // attribute: xUnits /** cache */ StringSTAttribute _att_xunits = null; /** Units for x axis. * All x-axis data must have unambiguous units. Ideally the data and _xMin_ or _xValue_ should share the same units but different xUnits can be used as long as it is clear.. * @return CMLAttribute */ public CMLAttribute getXUnitsAttribute() { return (CMLAttribute) getAttribute("xUnits"); } /** Units for x axis. * All x-axis data must have unambiguous units. Ideally the data and _xMin_ or _xValue_ should share the same units but different xUnits can be used as long as it is clear.. * @return String */ public String getXUnits() { StringSTAttribute att = (StringSTAttribute) this.getXUnitsAttribute(); if (att == null) { return null; } return att.getString(); } /** Units for x axis. * All x-axis data must have unambiguous units. Ideally the data and _xMin_ or _xValue_ should share the same units but different xUnits can be used as long as it is clear.. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXUnits(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_xunits == null) { _att_xunits = (StringSTAttribute) attributeFactory.getAttribute("xUnits", "peakGroup"); if (_att_xunits == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : xUnits probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_xunits); super.addRemove(att, value); } // attribute: yMin /** cache */ DoubleSTAttribute _att_ymin = null; /** Minimum yValue. * Annotates y-axis data with a minimum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses yUnits or the same units as the data. There may or may * not be a _yMax_ attribute but if so yMin should be less than or * equal to it. * @return CMLAttribute */ public CMLAttribute getYMinAttribute() { return (CMLAttribute) getAttribute("yMin"); } /** Minimum yValue. * Annotates y-axis data with a minimum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses yUnits or the same units as the data. There may or may * not be a _yMax_ attribute but if so yMin should be less than or * equal to it. * @return double */ public double getYMin() { DoubleSTAttribute att = (DoubleSTAttribute) this.getYMinAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Minimum yValue. * Annotates y-axis data with a minimum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses yUnits or the same units as the data. There may or may * not be a _yMax_ attribute but if so yMin should be less than or * equal to it. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYMin(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_ymin == null) { _att_ymin = (DoubleSTAttribute) attributeFactory.getAttribute("yMin", "peakGroup"); if (_att_ymin == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yMin probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_ymin); super.addRemove(att, value); } /** Minimum yValue. * Annotates y-axis data with a minimum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses yUnits or the same units as the data. There may or may * not be a _yMax_ attribute but if so yMin should be less than or * equal to it. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYMin(double value) throws RuntimeException { if (_att_ymin == null) { _att_ymin = (DoubleSTAttribute) attributeFactory.getAttribute("yMin", "peakGroup"); if (_att_ymin == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yMin probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_ymin); super.addAttribute(att); att.setCMLValue(value); } // attribute: yMax /** cache */ DoubleSTAttribute _att_ymax = null; /** Maximum yValue. * Annotates y-axis data with a maximum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses yUnits or the same units as the data. There may or may not * be a _yMin_ attribute but if so yMax should be greater than or * equals to it. * @return CMLAttribute */ public CMLAttribute getYMaxAttribute() { return (CMLAttribute) getAttribute("yMax"); } /** Maximum yValue. * Annotates y-axis data with a maximum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses yUnits or the same units as the data. There may or may not * be a _yMin_ attribute but if so yMax should be greater than or * equals to it. * @return double */ public double getYMax() { DoubleSTAttribute att = (DoubleSTAttribute) this.getYMaxAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Maximum yValue. * Annotates y-axis data with a maximum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses yUnits or the same units as the data. There may or may not * be a _yMin_ attribute but if so yMax should be greater than or * equals to it. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYMax(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_ymax == null) { _att_ymax = (DoubleSTAttribute) attributeFactory.getAttribute("yMax", "peakGroup"); if (_att_ymax == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yMax probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_ymax); super.addRemove(att, value); } /** Maximum yValue. * Annotates y-axis data with a maximum * value. This need not be algorithmically deducible from the data * and is typically used for the extent of a _peak_ or _peakGroup_. * It uses yUnits or the same units as the data. There may or may not * be a _yMin_ attribute but if so yMax should be greater than or * equals to it. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYMax(double value) throws RuntimeException { if (_att_ymax == null) { _att_ymax = (DoubleSTAttribute) attributeFactory.getAttribute("yMax", "peakGroup"); if (_att_ymax == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yMax probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_ymax); super.addAttribute(att); att.setCMLValue(value); } // attribute: yValue /** cache */ DoubleSTAttribute _att_yvalue = null; /** Value along a y axis. * Annotates y-axis data with a value. It * is typically used for the location of a _peak_ or _peakGroup_. It * uses yUnits or the same units as the data. * @return CMLAttribute */ public CMLAttribute getYValueAttribute() { return (CMLAttribute) getAttribute("yValue"); } /** Value along a y axis. * Annotates y-axis data with a value. It * is typically used for the location of a _peak_ or _peakGroup_. It * uses yUnits or the same units as the data. * @return double */ public double getYValue() { DoubleSTAttribute att = (DoubleSTAttribute) this.getYValueAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Value along a y axis. * Annotates y-axis data with a value. It * is typically used for the location of a _peak_ or _peakGroup_. It * uses yUnits or the same units as the data. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYValue(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_yvalue == null) { _att_yvalue = (DoubleSTAttribute) attributeFactory.getAttribute("yValue", "peakGroup"); if (_att_yvalue == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yValue probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_yvalue); super.addRemove(att, value); } /** Value along a y axis. * Annotates y-axis data with a value. It * is typically used for the location of a _peak_ or _peakGroup_. It * uses yUnits or the same units as the data. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYValue(double value) throws RuntimeException { if (_att_yvalue == null) { _att_yvalue = (DoubleSTAttribute) attributeFactory.getAttribute("yValue", "peakGroup"); if (_att_yvalue == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yValue probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_yvalue); super.addAttribute(att); att.setCMLValue(value); } // attribute: yWidth /** cache */ DoubleSTAttribute _att_ywidth = null; /** An unsigned interval along a y axis. * It is typically used for the width of * a _peak_ or _peakGroup_ but could be used for any range. It uses * yUnits or the same units as the data. * @return CMLAttribute */ public CMLAttribute getYWidthAttribute() { return (CMLAttribute) getAttribute("yWidth"); } /** An unsigned interval along a y axis. * It is typically used for the width of * a _peak_ or _peakGroup_ but could be used for any range. It uses * yUnits or the same units as the data. * @return double */ public double getYWidth() { DoubleSTAttribute att = (DoubleSTAttribute) this.getYWidthAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** An unsigned interval along a y axis. * It is typically used for the width of * a _peak_ or _peakGroup_ but could be used for any range. It uses * yUnits or the same units as the data. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYWidth(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_ywidth == null) { _att_ywidth = (DoubleSTAttribute) attributeFactory.getAttribute("yWidth", "peakGroup"); if (_att_ywidth == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yWidth probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_ywidth); super.addRemove(att, value); } /** An unsigned interval along a y axis. * It is typically used for the width of * a _peak_ or _peakGroup_ but could be used for any range. It uses * yUnits or the same units as the data. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYWidth(double value) throws RuntimeException { if (_att_ywidth == null) { _att_ywidth = (DoubleSTAttribute) attributeFactory.getAttribute("yWidth", "peakGroup"); if (_att_ywidth == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yWidth probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_ywidth); super.addAttribute(att); att.setCMLValue(value); } // attribute: yUnits /** cache */ StringSTAttribute _att_yunits = null; /** Units for y axis. * All y-axis data must have unambiguous units. Ideally the data and _yMin_ or _yValue_ should share the same units but different yUnits can be used as long as it is clear. * @return CMLAttribute */ public CMLAttribute getYUnitsAttribute() { return (CMLAttribute) getAttribute("yUnits"); } /** Units for y axis. * All y-axis data must have unambiguous units. Ideally the data and _yMin_ or _yValue_ should share the same units but different yUnits can be used as long as it is clear. * @return String */ public String getYUnits() { StringSTAttribute att = (StringSTAttribute) this.getYUnitsAttribute(); if (att == null) { return null; } return att.getString(); } /** Units for y axis. * All y-axis data must have unambiguous units. Ideally the data and _yMin_ or _yValue_ should share the same units but different yUnits can be used as long as it is clear. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYUnits(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_yunits == null) { _att_yunits = (StringSTAttribute) attributeFactory.getAttribute("yUnits", "peakGroup"); if (_att_yunits == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yUnits probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_yunits); super.addRemove(att, value); } // attribute: atomRefs /** cache */ StringArraySTAttribute _att_atomrefs = null; /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @return CMLAttribute */ public CMLAttribute getAtomRefsAttribute() { return (CMLAttribute) getAttribute("atomRefs"); } /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @return String[] */ public String[] getAtomRefs() { StringArraySTAttribute att = (StringArraySTAttribute) this.getAtomRefsAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefs(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_atomrefs == null) { _att_atomrefs = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs", "peakGroup"); if (_att_atomrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_atomrefs); super.addRemove(att, value); } /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefs(String[] value) throws RuntimeException { if (_att_atomrefs == null) { _att_atomrefs = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs", "peakGroup"); if (_att_atomrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_atomrefs); super.addAttribute(att); att.setCMLValue(value); } // attribute: bondRefs /** cache */ StringArraySTAttribute _att_bondrefs = null; /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @return CMLAttribute */ public CMLAttribute getBondRefsAttribute() { return (CMLAttribute) getAttribute("bondRefs"); } /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @return String[] */ public String[] getBondRefs() { StringArraySTAttribute att = (StringArraySTAttribute) this.getBondRefsAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setBondRefs(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_bondrefs == null) { _att_bondrefs = (StringArraySTAttribute) attributeFactory.getAttribute("bondRefs", "peakGroup"); if (_att_bondrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : bondRefs probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_bondrefs); super.addRemove(att, value); } /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setBondRefs(String[] value) throws RuntimeException { if (_att_bondrefs == null) { _att_bondrefs = (StringArraySTAttribute) attributeFactory.getAttribute("bondRefs", "peakGroup"); if (_att_bondrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : bondRefs probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_bondrefs); super.addAttribute(att); att.setCMLValue(value); } // attribute: moleculeRefs /** cache */ StringArraySTAttribute _att_moleculerefs = null; /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @return CMLAttribute */ public CMLAttribute getMoleculeRefsAttribute() { return (CMLAttribute) getAttribute("moleculeRefs"); } /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @return String[] */ public String[] getMoleculeRefs() { StringArraySTAttribute att = (StringArraySTAttribute) this.getMoleculeRefsAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMoleculeRefs(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_moleculerefs == null) { _att_moleculerefs = (StringArraySTAttribute) attributeFactory.getAttribute("moleculeRefs", "peakGroup"); if (_att_moleculerefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : moleculeRefs probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_moleculerefs); super.addRemove(att, value); } /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMoleculeRefs(String[] value) throws RuntimeException { if (_att_moleculerefs == null) { _att_moleculerefs = (StringArraySTAttribute) attributeFactory.getAttribute("moleculeRefs", "peakGroup"); if (_att_moleculerefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : moleculeRefs probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_moleculerefs); super.addAttribute(att); att.setCMLValue(value); } // element: peak /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @param peak child to add */ public void addPeak(AbstractPeak peak) { peak.detach(); this.appendChild(peak); } /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @return CMLElements<CMLPeak> */ public CMLElements getPeakElements() { Elements elements = this.getChildElements("peak", CMLConstants.CML_NS); return new CMLElements(elements); } // element: peakGroup /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @param peakGroup child to add */ public void addPeakGroup(AbstractPeakGroup peakGroup) { peakGroup.detach(); this.appendChild(peakGroup); } /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @return CMLElements<CMLPeakGroup> */ public CMLElements getPeakGroupElements() { Elements elements = this.getChildElements("peakGroup", CMLConstants.CML_NS); return new CMLElements(elements); } // element: atom /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @param atom child to add */ public void addAtom(AbstractAtom atom) { atom.detach(); this.appendChild(atom); } /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @return CMLElements<CMLAtom> */ public CMLElements getAtomElements() { Elements elements = this.getChildElements("atom", CMLConstants.CML_NS); return new CMLElements(elements); } // element: bond /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @param bond child to add */ public void addBond(AbstractBond bond) { bond.detach(); this.appendChild(bond); } /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @return CMLElements<CMLBond> */ public CMLElements getBondElements() { Elements elements = this.getChildElements("bond", CMLConstants.CML_NS); return new CMLElements(elements); } // element: molecule /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @param molecule child to add */ public void addMolecule(AbstractMolecule molecule) { molecule.detach(); this.appendChild(molecule); } /** A reference to one or more molecules. * Uses the id attribute as the target identification. * The order of molecules is preserved. It is not necessarily an error to have repeated * references to the same molecule * @return CMLElements<CMLMolecule> */ public CMLElements getMoleculeElements() { Elements elements = this.getChildElements("molecule", 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 if (name.equals("peakHeight")) { setPeakHeight(value); } else if (name.equals("peakMultiplicity")) { setPeakMultiplicity(value); } else if (name.equals("peakShape")) { setPeakShape(value); } else if (name.equals("integral")) { setIntegral(value); } else if (name.equals("peakUnits")) { setPeakUnits(value); } else if (name.equals("xMin")) { setXMin(value); } else if (name.equals("xMax")) { setXMax(value); } else if (name.equals("xValue")) { setXValue(value); } else if (name.equals("xWidth")) { setXWidth(value); } else if (name.equals("xUnits")) { setXUnits(value); } else if (name.equals("yMin")) { setYMin(value); } else if (name.equals("yMax")) { setYMax(value); } else if (name.equals("yValue")) { setYValue(value); } else if (name.equals("yWidth")) { setYWidth(value); } else if (name.equals("yUnits")) { setYUnits(value); } else if (name.equals("atomRefs")) { setAtomRefs(value); } else if (name.equals("bondRefs")) { setBondRefs(value); } else if (name.equals("moleculeRefs")) { setMoleculeRefs(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractPeakList.java000077500000000000000000000270311477224461000272360ustar00rootroot00000000000000/** * 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 AbstractPeakList extends CMLElement { /** local name*/ public final static String TAG = "peakList"; /** constructor. */ public AbstractPeakList() { super("peakList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractPeakList(AbstractPeakList 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", "peakList"); 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", "peakList"); 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", "peakList"); 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", "peakList"); 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", "peakList"); 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: peak /** null * @param peak child to add */ public void addPeak(AbstractPeak peak) { peak.detach(); this.appendChild(peak); } /** null * @return CMLElements<CMLPeak> */ public CMLElements getPeakElements() { Elements elements = this.getChildElements("peak", CMLConstants.CML_NS); return new CMLElements(elements); } // element: peakGroup /** null * @param peakGroup child to add */ public void addPeakGroup(AbstractPeakGroup peakGroup) { peakGroup.detach(); this.appendChild(peakGroup); } /** null * @return CMLElements<CMLPeakGroup> */ public CMLElements getPeakGroupElements() { Elements elements = this.getChildElements("peakGroup", 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/AbstractPeakStructure.java000077500000000000000000000563571477224461000303400ustar00rootroot00000000000000/** * 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.attribute.UnitsAttribute; 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.StringArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractPeakStructure extends CMLElement { /** local name*/ public final static String TAG = "peakStructure"; /** constructor. */ public AbstractPeakStructure() { super("peakStructure"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractPeakStructure(AbstractPeakStructure 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", "peakStructure"); 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", "peakStructure"); 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", "peakStructure"); 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", "peakStructure"); 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", "peakStructure"); 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: peakMultiplicity /** cache */ StringSTAttribute _att_peakmultiplicity = null; /** Multiplicity of a peak. * Uses a semi-controlled vocabulary. * @return CMLAttribute */ public CMLAttribute getPeakMultiplicityAttribute() { return (CMLAttribute) getAttribute("peakMultiplicity"); } /** Multiplicity of a peak. * Uses a semi-controlled vocabulary. * @return String */ public String getPeakMultiplicity() { StringSTAttribute att = (StringSTAttribute) this.getPeakMultiplicityAttribute(); if (att == null) { return null; } return att.getString(); } /** Multiplicity of a peak. * Uses a semi-controlled vocabulary. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPeakMultiplicity(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_peakmultiplicity == null) { _att_peakmultiplicity = (StringSTAttribute) attributeFactory.getAttribute("peakMultiplicity", "peakStructure"); if (_att_peakmultiplicity == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : peakMultiplicity probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_peakmultiplicity); super.addRemove(att, value); } // attribute: type /** cache */ StringSTAttribute _att_type = null; /** Type of this structure. * Semi-controlled vocabulary such as coupling * or splitting. * @return CMLAttribute */ public CMLAttribute getTypeAttribute() { return (CMLAttribute) getAttribute("type"); } /** Type of this structure. * Semi-controlled vocabulary such as coupling * or splitting. * @return String */ public String getType() { StringSTAttribute att = (StringSTAttribute) this.getTypeAttribute(); if (att == null) { return null; } return att.getString(); } /** Type of this structure. * Semi-controlled vocabulary such as coupling * or splitting. * @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", "peakStructure"); 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: peakShape /** cache */ StringSTAttribute _att_peakshape = null; /** Shape of a peak. * Semi-controlled vocabulary such as broad or sharp. * @return CMLAttribute */ public CMLAttribute getPeakShapeAttribute() { return (CMLAttribute) getAttribute("peakShape"); } /** Shape of a peak. * Semi-controlled vocabulary such as broad or sharp. * @return String */ public String getPeakShape() { StringSTAttribute att = (StringSTAttribute) this.getPeakShapeAttribute(); if (att == null) { return null; } return att.getString(); } /** Shape of a peak. * Semi-controlled vocabulary such as broad or sharp. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPeakShape(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_peakshape == null) { _att_peakshape = (StringSTAttribute) attributeFactory.getAttribute("peakShape", "peakStructure"); if (_att_peakshape == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : peakShape probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_peakshape); super.addRemove(att, value); } // attribute: value /** cache */ StringSTAttribute _att_value = null; /** Value of a scalar object. * The value must be consistent with the dataType of the object. * @return CMLAttribute */ public CMLAttribute getCMLValueAttribute() { return (CMLAttribute) getAttribute("value"); } /** Value of a scalar object. * The value must be consistent with the dataType of the object. * @return String */ public String getCMLValue() { StringSTAttribute att = (StringSTAttribute) this.getCMLValueAttribute(); if (att == null) { return null; } return att.getString(); } /** Value of a scalar object. * The value must be consistent with the dataType of the object. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setCMLValue(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_value == null) { _att_value = (StringSTAttribute) attributeFactory.getAttribute("value", "peakStructure"); if (_att_value == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : value probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_value); 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", "peakStructure"); 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: atomRefs /** cache */ StringArraySTAttribute _att_atomrefs = null; /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @return CMLAttribute */ public CMLAttribute getAtomRefsAttribute() { return (CMLAttribute) getAttribute("atomRefs"); } /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @return String[] */ public String[] getAtomRefs() { StringArraySTAttribute att = (StringArraySTAttribute) this.getAtomRefsAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefs(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_atomrefs == null) { _att_atomrefs = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs", "peakStructure"); if (_att_atomrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_atomrefs); super.addRemove(att, value); } /** A reference to a list of atoms. * Used by bonds, electrons, atomSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomRefs(String[] value) throws RuntimeException { if (_att_atomrefs == null) { _att_atomrefs = (StringArraySTAttribute) attributeFactory.getAttribute("atomRefs", "peakStructure"); if (_att_atomrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomRefs probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_atomrefs); super.addAttribute(att); att.setCMLValue(value); } // attribute: bondRefs /** cache */ StringArraySTAttribute _att_bondrefs = null; /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @return CMLAttribute */ public CMLAttribute getBondRefsAttribute() { return (CMLAttribute) getAttribute("bondRefs"); } /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @return String[] */ public String[] getBondRefs() { StringArraySTAttribute att = (StringArraySTAttribute) this.getBondRefsAttribute(); if (att == null) { return null; } return att.getStringArray(); } /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setBondRefs(String value) throws RuntimeException { StringArraySTAttribute att = null; if (_att_bondrefs == null) { _att_bondrefs = (StringArraySTAttribute) attributeFactory.getAttribute("bondRefs", "peakStructure"); if (_att_bondrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : bondRefs probably incompatible attributeGroupName and attributeName"); } } att = new StringArraySTAttribute(_att_bondrefs); super.addRemove(att, value); } /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setBondRefs(String[] value) throws RuntimeException { if (_att_bondrefs == null) { _att_bondrefs = (StringArraySTAttribute) attributeFactory.getAttribute("bondRefs", "peakStructure"); if (_att_bondrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : bondRefs probably incompatible attributeGroupName and attributeName "); } } StringArraySTAttribute att = new StringArraySTAttribute(_att_bondrefs); super.addAttribute(att); att.setCMLValue(value); } // element: peakStructure /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @param peakStructure child to add */ public void addPeakStructure(AbstractPeakStructure peakStructure) { peakStructure.detach(); this.appendChild(peakStructure); } /** A reference to a list of bonds. * Used by electrons, bondSets, etc. * @return CMLElements<CMLPeakStructure> */ public CMLElements getPeakStructureElements() { Elements elements = this.getChildElements("peakStructure", 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 if (name.equals("peakMultiplicity")) { setPeakMultiplicity(value); } else if (name.equals("type")) { setType(value); } else if (name.equals("peakShape")) { setPeakShape(value); } else if (name.equals("value")) { setCMLValue(value); } else if (name.equals("units")) { setUnits(value); } else if (name.equals("atomRefs")) { setAtomRefs(value); } else if (name.equals("bondRefs")) { setBondRefs(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractPlane3.java000077500000000000000000000312421477224461000266430ustar00rootroot00000000000000/** * 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.DoubleArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractPlane3 extends CMLElement { /** local name*/ public final static String TAG = "plane3"; /** constructor. */ public AbstractPlane3() { super("plane3"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractPlane3(AbstractPlane3 old) { super((CMLElement) old); } // 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", "plane3"); 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", "plane3"); 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: 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", "plane3"); 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: 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", "plane3"); 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: 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", "plane3"); 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); } DoubleArraySTAttribute _xmlContent; /** An unbounded plane in 3-space. * Defined by 4 real numbers, conventionally a vector3 * normal to the plane and a signed scalar representing the distance to the origin. * The vector must not be of zero length (and need not be normalized. * @return double[] */ public double[] getXMLContent() { String content = this.getValue(); if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(content); return _xmlContent.getDoubleArray(); } /** An unbounded plane in 3-space. * Defined by 4 real numbers, conventionally a vector3 * normal to the plane and a signed scalar representing the distance to the origin. * The vector must not be of zero length (and need not be normalized. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(String value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(value); String attval = _xmlContent.getValue(); this.removeChildren(); this.appendChild(attval); } /** An unbounded plane in 3-space. * Defined by 4 real numbers, conventionally a vector3 * normal to the plane and a signed scalar representing the distance to the origin. * The vector must not be of zero length (and need not be normalized. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(double[] value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_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("convention")) { setConvention(value); } else if (name.equals("dictRef")) { setDictRef(value); } else if (name.equals("id")) { setId(value); } else if (name.equals("title")) { setTitle(value); } else if (name.equals("units")) { setUnits(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractPoint3.java000077500000000000000000000300651477224461000266770ustar00rootroot00000000000000/** * 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.DoubleArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractPoint3 extends CMLElement { /** local name*/ public final static String TAG = "point3"; /** constructor. */ public AbstractPoint3() { super("point3"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractPoint3(AbstractPoint3 old) { super((CMLElement) old); } // 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", "point3"); 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", "point3"); 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: 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", "point3"); 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: 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", "point3"); 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: 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", "point3"); 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); } DoubleArraySTAttribute _xmlContent; /** A point in 3-space. * The 3 components can have any signed value. * @return double[] */ public double[] getXMLContent() { String content = this.getValue(); if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(content); return _xmlContent.getDoubleArray(); } /** A point in 3-space. * The 3 components can have any signed value. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(String value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(value); String attval = _xmlContent.getValue(); this.removeChildren(); this.appendChild(attval); } /** A point in 3-space. * The 3 components can have any signed value. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(double[] value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_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("convention")) { setConvention(value); } else if (name.equals("dictRef")) { setDictRef(value); } else if (name.equals("id")) { setId(value); } else if (name.equals("title")) { setTitle(value); } else if (name.equals("units")) { setUnits(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractPotential.java000077500000000000000000000265511477224461000274670ustar00rootroot00000000000000/** * 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 AbstractPotential extends CMLElement { /** local name*/ public final static String TAG = "potential"; /** constructor. */ public AbstractPotential() { super("potential"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractPotential(AbstractPotential 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", "potential"); 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", "potential"); 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", "potential"); 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", "potential"); 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: form /** cache */ StringSTAttribute _att_form = null; /** A reference to a functional form. * Currently used for potential. * @return CMLAttribute */ public CMLAttribute getFormAttribute() { return (CMLAttribute) getAttribute("form"); } /** A reference to a functional form. * Currently used for potential. * @return String */ public String getForm() { StringSTAttribute att = (StringSTAttribute) this.getFormAttribute(); if (att == null) { return null; } return att.getString(); } /** A reference to a functional form. * Currently used for potential. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setForm(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_form == null) { _att_form = (StringSTAttribute) attributeFactory.getAttribute("form", "potential"); if (_att_form == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : form probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_form); super.addRemove(att, value); } // element: arg /** A reference to a functional form. * Currently used for potential. * @param arg child to add */ public void addArg(AbstractArg arg) { arg.detach(); this.appendChild(arg); } /** A reference to a functional form. * Currently used for potential. * @return CMLElements<CMLArg> */ public CMLElements getArgElements() { Elements elements = this.getChildElements("arg", 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("form")) { setForm(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractPotentialForm.java000077500000000000000000000324721477224461000303120ustar00rootroot00000000000000/** * 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 AbstractPotentialForm extends CMLElement { /** local name*/ public final static String TAG = "potentialForm"; /** constructor. */ public AbstractPotentialForm() { super("potentialForm"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractPotentialForm(AbstractPotentialForm 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", "potentialForm"); 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", "potentialForm"); 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", "potentialForm"); 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", "potentialForm"); 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: 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", "potentialForm"); 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); } // element: arg /** 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 arg child to add */ public void addArg(AbstractArg arg) { arg.detach(); this.appendChild(arg); } /** 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 CMLElements<CMLArg> */ public CMLElements getArgElements() { Elements elements = this.getChildElements("arg", CMLConstants.CML_NS); return new CMLElements(elements); } // element: parameter /** 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 parameter child to add */ public void addParameter(AbstractParameter parameter) { parameter.detach(); this.appendChild(parameter); } /** 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 CMLElements<CMLParameter> */ public CMLElements getParameterElements() { Elements elements = this.getChildElements("parameter", CMLConstants.CML_NS); return new CMLElements(elements); } // element: expression /** 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 expression child to add */ public void addExpression(AbstractExpression expression) { expression.detach(); this.appendChild(expression); } /** 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 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("name")) { setName(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractPotentialList.java000077500000000000000000000237031477224461000303170ustar00rootroot00000000000000/** * 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 AbstractPotentialList extends CMLElement { /** local name*/ public final static String TAG = "potentialList"; /** constructor. */ public AbstractPotentialList() { super("potentialList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractPotentialList(AbstractPotentialList 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", "potentialList"); 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", "potentialList"); 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", "potentialList"); 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", "potentialList"); 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: potential /** null * @param potential child to add */ public void addPotential(AbstractPotential potential) { potential.detach(); this.appendChild(potential); } /** null * @return CMLElements<CMLPotential> */ public CMLElements getPotentialElements() { Elements elements = this.getChildElements("potential", 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 { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractProduct.java000077500000000000000000000544621477224461000271520ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractProduct extends CMLElement { /** local name*/ public final static String TAG = "product"; /** constructor. */ public AbstractProduct() { super("product"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractProduct(AbstractProduct 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", "product"); 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", "product"); 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", "product"); 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", "product"); 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", "product"); 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: 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", "product"); 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: 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", "product"); 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", "product"); 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: state /** cache */ StringSTAttribute _att_state = null; /** The physical state of the substance. * No fixed semantics or default. * @return CMLAttribute */ public CMLAttribute getStateAttribute() { return (CMLAttribute) getAttribute("state"); } /** The physical state of the substance. * No fixed semantics or default. * @return String */ public String getState() { StringSTAttribute att = (StringSTAttribute) this.getStateAttribute(); if (att == null) { return null; } return att.getString(); } /** The physical state of the substance. * No fixed semantics or default. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setState(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_state == null) { _att_state = (StringSTAttribute) attributeFactory.getAttribute("state", "product"); if (_att_state == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : state probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_state); super.addRemove(att, value); } // element: metadataList /** The physical state of the substance. * No fixed semantics or default. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: identifier /** The physical state of the substance. * No fixed semantics or default. * @param identifier child to add */ public void addIdentifier(AbstractIdentifier identifier) { identifier.detach(); this.appendChild(identifier); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLIdentifier> */ public CMLElements getIdentifierElements() { Elements elements = this.getChildElements("identifier", CMLConstants.CML_NS); return new CMLElements(elements); } // element: label /** The physical state of the substance. * No fixed semantics or default. * @param label child to add */ public void addLabel(AbstractLabel label) { label.detach(); this.appendChild(label); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLLabel> */ public CMLElements getLabelElements() { Elements elements = this.getChildElements("label", CMLConstants.CML_NS); return new CMLElements(elements); } // element: name /** The physical state of the substance. * No fixed semantics or default. * @param name child to add */ public void addName(AbstractName name) { name.detach(); this.appendChild(name); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLName> */ public CMLElements getNameElements() { Elements elements = this.getChildElements("name", CMLConstants.CML_NS); return new CMLElements(elements); } // element: molecule /** The physical state of the substance. * No fixed semantics or default. * @param molecule child to add */ public void addMolecule(AbstractMolecule molecule) { molecule.detach(); this.appendChild(molecule); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLMolecule> */ public CMLElements getMoleculeElements() { Elements elements = this.getChildElements("molecule", CMLConstants.CML_NS); return new CMLElements(elements); } // element: electron /** The physical state of the substance. * No fixed semantics or default. * @param electron child to add */ public void addElectron(AbstractElectron electron) { electron.detach(); this.appendChild(electron); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLElectron> */ public CMLElements getElectronElements() { Elements elements = this.getChildElements("electron", CMLConstants.CML_NS); return new CMLElements(elements); } // element: substance /** The physical state of the substance. * No fixed semantics or default. * @param substance child to add */ public void addSubstance(AbstractSubstance substance) { substance.detach(); this.appendChild(substance); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLSubstance> */ public CMLElements getSubstanceElements() { Elements elements = this.getChildElements("substance", CMLConstants.CML_NS); return new CMLElements(elements); } // element: substanceList /** The physical state of the substance. * No fixed semantics or default. * @param substanceList child to add */ public void addSubstanceList(AbstractSubstanceList substanceList) { substanceList.detach(); this.appendChild(substanceList); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLSubstanceList> */ public CMLElements getSubstanceListElements() { Elements elements = this.getChildElements("substanceList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: formula /** The physical state of the substance. * No fixed semantics or default. * @param formula child to add */ public void addFormula(AbstractFormula formula) { formula.detach(); this.appendChild(formula); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLFormula> */ public CMLElements getFormulaElements() { Elements elements = this.getChildElements("formula", CMLConstants.CML_NS); return new CMLElements(elements); } // element: amount /** The physical state of the substance. * No fixed semantics or default. * @param amount child to add */ public void addAmount(AbstractAmount amount) { amount.detach(); this.appendChild(amount); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLAmount> */ public CMLElements getAmountElements() { Elements elements = this.getChildElements("amount", 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 if (name.equals("role")) { setRole(value); } else if (name.equals("count")) { setCount(value); } else if (name.equals("state")) { setState(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractProductList.java000077500000000000000000000440351477224461000300010ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractProductList extends CMLElement { /** local name*/ public final static String TAG = "productList"; /** constructor. */ public AbstractProductList() { super("productList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractProductList(AbstractProductList 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", "productList"); 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", "productList"); 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", "productList"); 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", "productList"); 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", "productList"); 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: 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", "productList"); 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: 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", "productList"); 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", "productList"); 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); } // element: metadataList /** 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 metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** 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 CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: name /** 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 name child to add */ public void addName(AbstractName name) { name.detach(); this.appendChild(name); } /** 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 CMLElements<CMLName> */ public CMLElements getNameElements() { Elements elements = this.getChildElements("name", CMLConstants.CML_NS); return new CMLElements(elements); } // element: productList /** 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 productList child to add */ public void addProductList(AbstractProductList productList) { productList.detach(); this.appendChild(productList); } /** 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 CMLElements<CMLProductList> */ public CMLElements getProductListElements() { Elements elements = this.getChildElements("productList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: product /** 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 product child to add */ public void addProduct(AbstractProduct product) { product.detach(); this.appendChild(product); } /** 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 CMLElements<CMLProduct> */ public CMLElements getProductElements() { Elements elements = this.getChildElements("product", 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 if (name.equals("role")) { setRole(value); } else if (name.equals("count")) { setCount(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractProperty.java000077500000000000000000000364411477224461000273530ustar00rootroot00000000000000/** * 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 AbstractProperty extends CMLElement { /** local name*/ public final static String TAG = "property"; /** constructor. */ public AbstractProperty() { super("property"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractProperty(AbstractProperty 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", "property"); 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", "property"); 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", "property"); 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", "property"); 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", "property"); 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: 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", "property"); 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: state /** cache */ StringSTAttribute _att_state = null; /** The physical state of the substance. * No fixed semantics or default. * @return CMLAttribute */ public CMLAttribute getStateAttribute() { return (CMLAttribute) getAttribute("state"); } /** The physical state of the substance. * No fixed semantics or default. * @return String */ public String getState() { StringSTAttribute att = (StringSTAttribute) this.getStateAttribute(); if (att == null) { return null; } return att.getString(); } /** The physical state of the substance. * No fixed semantics or default. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setState(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_state == null) { _att_state = (StringSTAttribute) attributeFactory.getAttribute("state", "property"); if (_att_state == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : state probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_state); super.addRemove(att, value); } // element: name /** The physical state of the substance. * No fixed semantics or default. * @param name child to add */ public void addName(AbstractName name) { name.detach(); this.appendChild(name); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLName> */ public CMLElements getNameElements() { Elements elements = this.getChildElements("name", CMLConstants.CML_NS); return new CMLElements(elements); } // element: scalar /** The physical state of the substance. * No fixed semantics or default. * @param scalar child to add */ public void addScalar(AbstractScalar scalar) { scalar.detach(); this.appendChild(scalar); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLScalar> */ public CMLElements getScalarElements() { Elements elements = this.getChildElements("scalar", CMLConstants.CML_NS); return new CMLElements(elements); } // element: array /** The physical state of the substance. * No fixed semantics or default. * @param array child to add */ public void addArray(AbstractArray array) { array.detach(); this.appendChild(array); } /** The physical state of the substance. * No fixed semantics or default. * @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("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 if (name.equals("role")) { setRole(value); } else if (name.equals("state")) { setState(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractPropertyList.java000077500000000000000000000344011477224461000302010ustar00rootroot00000000000000/** * 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 AbstractPropertyList extends CMLElement { /** local name*/ public final static String TAG = "propertyList"; /** constructor. */ public AbstractPropertyList() { super("propertyList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractPropertyList(AbstractPropertyList 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", "propertyList"); 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", "propertyList"); 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", "propertyList"); 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", "propertyList"); 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", "propertyList"); 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: 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", "propertyList"); 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); } // element: name /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param name child to add */ public void addName(AbstractName name) { name.detach(); this.appendChild(name); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLName> */ public CMLElements getNameElements() { Elements elements = this.getChildElements("name", CMLConstants.CML_NS); return new CMLElements(elements); } // element: property /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param property child to add */ public void addProperty(AbstractProperty property) { property.detach(); this.appendChild(property); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLProperty> */ public CMLElements getPropertyElements() { Elements elements = this.getChildElements("property", CMLConstants.CML_NS); return new CMLElements(elements); } // element: propertyList /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param propertyList child to add */ public void addPropertyList(AbstractPropertyList propertyList) { propertyList.detach(); this.appendChild(propertyList); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLPropertyList> */ public CMLElements getPropertyListElements() { Elements elements = this.getChildElements("propertyList", 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 if (name.equals("role")) { setRole(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractReactant.java000077500000000000000000000545011477224461000272650ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractReactant extends CMLElement { /** local name*/ public final static String TAG = "reactant"; /** constructor. */ public AbstractReactant() { super("reactant"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractReactant(AbstractReactant 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", "reactant"); 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", "reactant"); 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", "reactant"); 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", "reactant"); 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", "reactant"); 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: 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", "reactant"); 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: 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", "reactant"); 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", "reactant"); 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: state /** cache */ StringSTAttribute _att_state = null; /** The physical state of the substance. * No fixed semantics or default. * @return CMLAttribute */ public CMLAttribute getStateAttribute() { return (CMLAttribute) getAttribute("state"); } /** The physical state of the substance. * No fixed semantics or default. * @return String */ public String getState() { StringSTAttribute att = (StringSTAttribute) this.getStateAttribute(); if (att == null) { return null; } return att.getString(); } /** The physical state of the substance. * No fixed semantics or default. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setState(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_state == null) { _att_state = (StringSTAttribute) attributeFactory.getAttribute("state", "reactant"); if (_att_state == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : state probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_state); super.addRemove(att, value); } // element: metadataList /** The physical state of the substance. * No fixed semantics or default. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: identifier /** The physical state of the substance. * No fixed semantics or default. * @param identifier child to add */ public void addIdentifier(AbstractIdentifier identifier) { identifier.detach(); this.appendChild(identifier); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLIdentifier> */ public CMLElements getIdentifierElements() { Elements elements = this.getChildElements("identifier", CMLConstants.CML_NS); return new CMLElements(elements); } // element: label /** The physical state of the substance. * No fixed semantics or default. * @param label child to add */ public void addLabel(AbstractLabel label) { label.detach(); this.appendChild(label); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLLabel> */ public CMLElements getLabelElements() { Elements elements = this.getChildElements("label", CMLConstants.CML_NS); return new CMLElements(elements); } // element: name /** The physical state of the substance. * No fixed semantics or default. * @param name child to add */ public void addName(AbstractName name) { name.detach(); this.appendChild(name); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLName> */ public CMLElements getNameElements() { Elements elements = this.getChildElements("name", CMLConstants.CML_NS); return new CMLElements(elements); } // element: molecule /** The physical state of the substance. * No fixed semantics or default. * @param molecule child to add */ public void addMolecule(AbstractMolecule molecule) { molecule.detach(); this.appendChild(molecule); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLMolecule> */ public CMLElements getMoleculeElements() { Elements elements = this.getChildElements("molecule", CMLConstants.CML_NS); return new CMLElements(elements); } // element: electron /** The physical state of the substance. * No fixed semantics or default. * @param electron child to add */ public void addElectron(AbstractElectron electron) { electron.detach(); this.appendChild(electron); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLElectron> */ public CMLElements getElectronElements() { Elements elements = this.getChildElements("electron", CMLConstants.CML_NS); return new CMLElements(elements); } // element: substance /** The physical state of the substance. * No fixed semantics or default. * @param substance child to add */ public void addSubstance(AbstractSubstance substance) { substance.detach(); this.appendChild(substance); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLSubstance> */ public CMLElements getSubstanceElements() { Elements elements = this.getChildElements("substance", CMLConstants.CML_NS); return new CMLElements(elements); } // element: substanceList /** The physical state of the substance. * No fixed semantics or default. * @param substanceList child to add */ public void addSubstanceList(AbstractSubstanceList substanceList) { substanceList.detach(); this.appendChild(substanceList); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLSubstanceList> */ public CMLElements getSubstanceListElements() { Elements elements = this.getChildElements("substanceList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: formula /** The physical state of the substance. * No fixed semantics or default. * @param formula child to add */ public void addFormula(AbstractFormula formula) { formula.detach(); this.appendChild(formula); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLFormula> */ public CMLElements getFormulaElements() { Elements elements = this.getChildElements("formula", CMLConstants.CML_NS); return new CMLElements(elements); } // element: amount /** The physical state of the substance. * No fixed semantics or default. * @param amount child to add */ public void addAmount(AbstractAmount amount) { amount.detach(); this.appendChild(amount); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLAmount> */ public CMLElements getAmountElements() { Elements elements = this.getChildElements("amount", 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 if (name.equals("role")) { setRole(value); } else if (name.equals("count")) { setCount(value); } else if (name.equals("state")) { setState(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractReactantList.java000077500000000000000000000441031477224461000301160ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractReactantList extends CMLElement { /** local name*/ public final static String TAG = "reactantList"; /** constructor. */ public AbstractReactantList() { super("reactantList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractReactantList(AbstractReactantList 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", "reactantList"); 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", "reactantList"); 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", "reactantList"); 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", "reactantList"); 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", "reactantList"); 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: 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", "reactantList"); 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: 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", "reactantList"); 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", "reactantList"); 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); } // element: metadataList /** 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 metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** 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 CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: name /** 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 name child to add */ public void addName(AbstractName name) { name.detach(); this.appendChild(name); } /** 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 CMLElements<CMLName> */ public CMLElements getNameElements() { Elements elements = this.getChildElements("name", CMLConstants.CML_NS); return new CMLElements(elements); } // element: reactantList /** 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 reactantList child to add */ public void addReactantList(AbstractReactantList reactantList) { reactantList.detach(); this.appendChild(reactantList); } /** 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 CMLElements<CMLReactantList> */ public CMLElements getReactantListElements() { Elements elements = this.getChildElements("reactantList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: reactant /** 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 reactant child to add */ public void addReactant(AbstractReactant reactant) { reactant.detach(); this.appendChild(reactant); } /** 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 CMLElements<CMLReactant> */ public CMLElements getReactantElements() { Elements elements = this.getChildElements("reactant", 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 if (name.equals("role")) { setRole(value); } else if (name.equals("count")) { setCount(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractReaction.java000077500000000000000000001307271477224461000272750ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractReaction extends CMLElement { /** local name*/ public final static String TAG = "reaction"; /** constructor. */ public AbstractReaction() { super("reaction"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractReaction(AbstractReaction 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", "reaction"); 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", "reaction"); 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", "reaction"); 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", "reaction"); 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: format /** cache */ StringSTAttribute _att_format = null; /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return CMLAttribute */ public CMLAttribute getFormatAttribute() { return (CMLAttribute) getAttribute("format"); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return String */ public String getFormat() { StringSTAttribute att = (StringSTAttribute) this.getFormatAttribute(); if (att == null) { return null; } return att.getString(); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setFormat(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_format == null) { _att_format = (StringSTAttribute) attributeFactory.getAttribute("format", "reaction"); if (_att_format == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : format probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_format); 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", "reaction"); 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: role /** cache */ StringSTAttribute _att_role = null; /** Role of the reaction. * No description * @return CMLAttribute */ public CMLAttribute getRoleAttribute() { return (CMLAttribute) getAttribute("role"); } /** Role of the reaction. * No description * @return String */ public String getRole() { StringSTAttribute att = (StringSTAttribute) this.getRoleAttribute(); if (att == null) { return null; } return att.getString(); } /** Role of the reaction. * No description * @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", "reaction"); 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: type /** cache */ StringSTAttribute _att_type = null; /** Type of the reaction. * No description * @return CMLAttribute */ public CMLAttribute getTypeAttribute() { return (CMLAttribute) getAttribute("type"); } /** Type of the reaction. * No description * @return String */ public String getType() { StringSTAttribute att = (StringSTAttribute) this.getTypeAttribute(); if (att == null) { return null; } return att.getString(); } /** Type of the reaction. * No description * @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", "reaction"); 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: state /** cache */ StringSTAttribute _att_state = null; /** The physical state of the substance. * No fixed semantics or default. * @return CMLAttribute */ public CMLAttribute getStateAttribute() { return (CMLAttribute) getAttribute("state"); } /** The physical state of the substance. * No fixed semantics or default. * @return String */ public String getState() { StringSTAttribute att = (StringSTAttribute) this.getStateAttribute(); if (att == null) { return null; } return att.getString(); } /** The physical state of the substance. * No fixed semantics or default. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setState(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_state == null) { _att_state = (StringSTAttribute) attributeFactory.getAttribute("state", "reaction"); if (_att_state == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : state probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_state); super.addRemove(att, value); } // attribute: atomMap /** cache */ StringSTAttribute _att_atommap = null; /** A reference to a map providing mappings between atoms. * The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking atoms. The topology of the linking is defined by the application - it could be overlay of molecular fragments, reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of atoms are of equal size and have 1:1 mapping between each id. This is another way of saying that the atoms mapped by a given ID are "the same atom". * @return CMLAttribute */ public CMLAttribute getAtomMapAttribute() { return (CMLAttribute) getAttribute("atomMap"); } /** A reference to a map providing mappings between atoms. * The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking atoms. The topology of the linking is defined by the application - it could be overlay of molecular fragments, reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of atoms are of equal size and have 1:1 mapping between each id. This is another way of saying that the atoms mapped by a given ID are "the same atom". * @return String */ public String getAtomMap() { StringSTAttribute att = (StringSTAttribute) this.getAtomMapAttribute(); if (att == null) { return null; } return att.getString(); } /** A reference to a map providing mappings between atoms. * The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking atoms. The topology of the linking is defined by the application - it could be overlay of molecular fragments, reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of atoms are of equal size and have 1:1 mapping between each id. This is another way of saying that the atoms mapped by a given ID are "the same atom". * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomMap(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_atommap == null) { _att_atommap = (StringSTAttribute) attributeFactory.getAttribute("atomMap", "reaction"); if (_att_atommap == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomMap probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_atommap); super.addRemove(att, value); } // attribute: electronMap /** cache */ StringSTAttribute _att_electronmap = null; /** A reference to a map providing mappings between electrons. * The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking electrons. The topology of the linking is defined by the application - it could be reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of electrons are of equal size and have 1:1 mapping between each id. This is another way of saying that the electrons mapped by a given ID are "the same electron". * @return CMLAttribute */ public CMLAttribute getElectronMapAttribute() { return (CMLAttribute) getAttribute("electronMap"); } /** A reference to a map providing mappings between electrons. * The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking electrons. The topology of the linking is defined by the application - it could be reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of electrons are of equal size and have 1:1 mapping between each id. This is another way of saying that the electrons mapped by a given ID are "the same electron". * @return String */ public String getElectronMap() { StringSTAttribute att = (StringSTAttribute) this.getElectronMapAttribute(); if (att == null) { return null; } return att.getString(); } /** A reference to a map providing mappings between electrons. * The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking electrons. The topology of the linking is defined by the application - it could be reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of electrons are of equal size and have 1:1 mapping between each id. This is another way of saying that the electrons mapped by a given ID are "the same electron". * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setElectronMap(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_electronmap == null) { _att_electronmap = (StringSTAttribute) attributeFactory.getAttribute("electronMap", "reaction"); if (_att_electronmap == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : electronMap probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_electronmap); super.addRemove(att, value); } // attribute: bondMap /** cache */ StringSTAttribute _att_bondmap = null; /** A reference to a map providing mappings between bonds. * The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking bonds. The topology of the linking is defined by the application - it could be overlay of molecular fragments, reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of bonds are of equal size and have 1:1 mapping between each id. This is another way of saying that the bonds mapped by a given ID are "the same bond". * @return CMLAttribute */ public CMLAttribute getBondMapAttribute() { return (CMLAttribute) getAttribute("bondMap"); } /** A reference to a map providing mappings between bonds. * The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking bonds. The topology of the linking is defined by the application - it could be overlay of molecular fragments, reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of bonds are of equal size and have 1:1 mapping between each id. This is another way of saying that the bonds mapped by a given ID are "the same bond". * @return String */ public String getBondMap() { StringSTAttribute att = (StringSTAttribute) this.getBondMapAttribute(); if (att == null) { return null; } return att.getString(); } /** A reference to a map providing mappings between bonds. * The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking bonds. The topology of the linking is defined by the application - it could be overlay of molecular fragments, reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of bonds are of equal size and have 1:1 mapping between each id. This is another way of saying that the bonds mapped by a given ID are "the same bond". * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setBondMap(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_bondmap == null) { _att_bondmap = (StringSTAttribute) attributeFactory.getAttribute("bondMap", "reaction"); if (_att_bondmap == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : bondMap probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_bondmap); super.addRemove(att, value); } // attribute: yield /** cache */ DoubleSTAttribute _att_yield = null; /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLAttribute */ public CMLAttribute getYieldAttribute() { return (CMLAttribute) getAttribute("yield"); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return double */ public double getYield() { DoubleSTAttribute att = (DoubleSTAttribute) this.getYieldAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYield(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_yield == null) { _att_yield = (DoubleSTAttribute) attributeFactory.getAttribute("yield", "reaction"); if (_att_yield == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yield probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_yield); super.addRemove(att, value); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYield(double value) throws RuntimeException { if (_att_yield == null) { _att_yield = (DoubleSTAttribute) attributeFactory.getAttribute("yield", "reaction"); if (_att_yield == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yield probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_yield); super.addAttribute(att); att.setCMLValue(value); } // element: metadataList /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: label /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param label child to add */ public void addLabel(AbstractLabel label) { label.detach(); this.appendChild(label); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLElements<CMLLabel> */ public CMLElements getLabelElements() { Elements elements = this.getChildElements("label", CMLConstants.CML_NS); return new CMLElements(elements); } // element: name /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param name child to add */ public void addName(AbstractName name) { name.detach(); this.appendChild(name); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLElements<CMLName> */ public CMLElements getNameElements() { Elements elements = this.getChildElements("name", CMLConstants.CML_NS); return new CMLElements(elements); } // element: identifier /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param identifier child to add */ public void addIdentifier(AbstractIdentifier identifier) { identifier.detach(); this.appendChild(identifier); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLElements<CMLIdentifier> */ public CMLElements getIdentifierElements() { Elements elements = this.getChildElements("identifier", CMLConstants.CML_NS); return new CMLElements(elements); } // element: reactiveCentre /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param reactiveCentre child to add */ public void addReactiveCentre(AbstractReactiveCentre reactiveCentre) { reactiveCentre.detach(); this.appendChild(reactiveCentre); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLElements<CMLReactiveCentre> */ public CMLElements getReactiveCentreElements() { Elements elements = this.getChildElements("reactiveCentre", CMLConstants.CML_NS); return new CMLElements(elements); } // element: mechanism /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param mechanism child to add */ public void addMechanism(AbstractMechanism mechanism) { mechanism.detach(); this.appendChild(mechanism); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLElements<CMLMechanism> */ public CMLElements getMechanismElements() { Elements elements = this.getChildElements("mechanism", CMLConstants.CML_NS); return new CMLElements(elements); } // element: reactantList /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param reactantList child to add */ public void addReactantList(AbstractReactantList reactantList) { reactantList.detach(); this.appendChild(reactantList); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLElements<CMLReactantList> */ public CMLElements getReactantListElements() { Elements elements = this.getChildElements("reactantList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: spectatorList /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param spectatorList child to add */ public void addSpectatorList(AbstractSpectatorList spectatorList) { spectatorList.detach(); this.appendChild(spectatorList); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLElements<CMLSpectatorList> */ public CMLElements getSpectatorListElements() { Elements elements = this.getChildElements("spectatorList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: substanceList /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param substanceList child to add */ public void addSubstanceList(AbstractSubstanceList substanceList) { substanceList.detach(); this.appendChild(substanceList); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLElements<CMLSubstanceList> */ public CMLElements getSubstanceListElements() { Elements elements = this.getChildElements("substanceList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: conditionList /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param conditionList child to add */ public void addConditionList(AbstractConditionList conditionList) { conditionList.detach(); this.appendChild(conditionList); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLElements<CMLConditionList> */ public CMLElements getConditionListElements() { Elements elements = this.getChildElements("conditionList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: transitionState /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param transitionState child to add */ public void addTransitionState(AbstractTransitionState transitionState) { transitionState.detach(); this.appendChild(transitionState); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLElements<CMLTransitionState> */ public CMLElements getTransitionStateElements() { Elements elements = this.getChildElements("transitionState", CMLConstants.CML_NS); return new CMLElements(elements); } // element: productList /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param productList child to add */ public void addProductList(AbstractProductList productList) { productList.detach(); this.appendChild(productList); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLElements<CMLProductList> */ public CMLElements getProductListElements() { Elements elements = this.getChildElements("productList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: propertyList /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param propertyList child to add */ public void addPropertyList(AbstractPropertyList propertyList) { propertyList.detach(); this.appendChild(propertyList); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLElements<CMLPropertyList> */ public CMLElements getPropertyListElements() { Elements elements = this.getChildElements("propertyList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: map /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param map child to add */ public void addMap(AbstractMap map) { map.detach(); this.appendChild(map); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLElements<CMLMap> */ public CMLElements getMapElements() { Elements elements = this.getChildElements("map", CMLConstants.CML_NS); return new CMLElements(elements); } // element: object /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param object child to add */ public void addObject(AbstractObject object) { object.detach(); this.appendChild(object); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLElements<CMLObject> */ public CMLElements getObjectElements() { Elements elements = this.getChildElements("object", 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("format")) { setFormat(value); } else if (name.equals("ref")) { setRef(value); } else if (name.equals("role")) { setRole(value); } else if (name.equals("type")) { setType(value); } else if (name.equals("state")) { setState(value); } else if (name.equals("atomMap")) { setAtomMap(value); } else if (name.equals("electronMap")) { setElectronMap(value); } else if (name.equals("bondMap")) { setBondMap(value); } else if (name.equals("yield")) { setYield(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractReactionList.java000077500000000000000000000335021477224461000301220ustar00rootroot00000000000000/** * 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 AbstractReactionList extends CMLElement { /** local name*/ public final static String TAG = "reactionList"; /** constructor. */ public AbstractReactionList() { super("reactionList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractReactionList(AbstractReactionList 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", "reactionList"); 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", "reactionList"); 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", "reactionList"); 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", "reactionList"); 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: 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", "reactionList"); 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", "reactionList"); 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: reactionScheme /** null * @param reactionScheme child to add */ public void addReactionScheme(AbstractReactionScheme reactionScheme) { reactionScheme.detach(); this.appendChild(reactionScheme); } /** null * @return CMLElements<CMLReactionScheme> */ public CMLElements getReactionSchemeElements() { Elements elements = this.getChildElements("reactionScheme", CMLConstants.CML_NS); return new CMLElements(elements); } // element: reaction /** null * @param reaction child to add */ public void addReaction(AbstractReaction reaction) { reaction.detach(); this.appendChild(reaction); } /** null * @return CMLElements<CMLReaction> */ public CMLElements getReactionElements() { Elements elements = this.getChildElements("reaction", 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("name")) { setName(value); } else if (name.equals("ref")) { setRef(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractReactionScheme.java000077500000000000000000000646411477224461000304230ustar00rootroot00000000000000/** * 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 AbstractReactionScheme extends CMLElement { /** local name*/ public final static String TAG = "reactionScheme"; /** constructor. */ public AbstractReactionScheme() { super("reactionScheme"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractReactionScheme(AbstractReactionScheme 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", "reactionScheme"); 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", "reactionScheme"); 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", "reactionScheme"); 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", "reactionScheme"); 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", "reactionScheme"); 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: role /** cache */ StringSTAttribute _att_role = null; /** Role of the reaction. * No description * @return CMLAttribute */ public CMLAttribute getRoleAttribute() { return (CMLAttribute) getAttribute("role"); } /** Role of the reaction. * No description * @return String */ public String getRole() { StringSTAttribute att = (StringSTAttribute) this.getRoleAttribute(); if (att == null) { return null; } return att.getString(); } /** Role of the reaction. * No description * @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", "reactionScheme"); 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: type /** cache */ StringSTAttribute _att_type = null; /** Type of the reaction. * No description * @return CMLAttribute */ public CMLAttribute getTypeAttribute() { return (CMLAttribute) getAttribute("type"); } /** Type of the reaction. * No description * @return String */ public String getType() { StringSTAttribute att = (StringSTAttribute) this.getTypeAttribute(); if (att == null) { return null; } return att.getString(); } /** Type of the reaction. * No description * @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", "reactionScheme"); 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: state /** cache */ StringSTAttribute _att_state = null; /** The physical state of the substance. * No fixed semantics or default. * @return CMLAttribute */ public CMLAttribute getStateAttribute() { return (CMLAttribute) getAttribute("state"); } /** The physical state of the substance. * No fixed semantics or default. * @return String */ public String getState() { StringSTAttribute att = (StringSTAttribute) this.getStateAttribute(); if (att == null) { return null; } return att.getString(); } /** The physical state of the substance. * No fixed semantics or default. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setState(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_state == null) { _att_state = (StringSTAttribute) attributeFactory.getAttribute("state", "reactionScheme"); if (_att_state == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : state probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_state); super.addRemove(att, value); } // attribute: format /** cache */ StringSTAttribute _att_format = null; /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return CMLAttribute */ public CMLAttribute getFormatAttribute() { return (CMLAttribute) getAttribute("format"); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return String */ public String getFormat() { StringSTAttribute att = (StringSTAttribute) this.getFormatAttribute(); if (att == null) { return null; } return att.getString(); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setFormat(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_format == null) { _att_format = (StringSTAttribute) attributeFactory.getAttribute("format", "reactionScheme"); if (_att_format == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : format probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_format); super.addRemove(att, value); } // element: metadataList /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: label /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @param label child to add */ public void addLabel(AbstractLabel label) { label.detach(); this.appendChild(label); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return CMLElements<CMLLabel> */ public CMLElements getLabelElements() { Elements elements = this.getChildElements("label", CMLConstants.CML_NS); return new CMLElements(elements); } // element: name /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @param name child to add */ public void addName(AbstractName name) { name.detach(); this.appendChild(name); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return CMLElements<CMLName> */ public CMLElements getNameElements() { Elements elements = this.getChildElements("name", CMLConstants.CML_NS); return new CMLElements(elements); } // element: identifier /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @param identifier child to add */ public void addIdentifier(AbstractIdentifier identifier) { identifier.detach(); this.appendChild(identifier); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return CMLElements<CMLIdentifier> */ public CMLElements getIdentifierElements() { Elements elements = this.getChildElements("identifier", CMLConstants.CML_NS); return new CMLElements(elements); } // element: reaction /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @param reaction child to add */ public void addReaction(AbstractReaction reaction) { reaction.detach(); this.appendChild(reaction); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return CMLElements<CMLReaction> */ public CMLElements getReactionElements() { Elements elements = this.getChildElements("reaction", CMLConstants.CML_NS); return new CMLElements(elements); } // element: reactionStepList /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @param reactionStepList child to add */ public void addReactionStepList(AbstractReactionStepList reactionStepList) { reactionStepList.detach(); this.appendChild(reactionStepList); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return CMLElements<CMLReactionStepList> */ public CMLElements getReactionStepListElements() { Elements elements = this.getChildElements("reactionStepList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: reactionScheme /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @param reactionScheme child to add */ public void addReactionScheme(AbstractReactionScheme reactionScheme) { reactionScheme.detach(); this.appendChild(reactionScheme); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return CMLElements<CMLReactionScheme> */ public CMLElements getReactionSchemeElements() { Elements elements = this.getChildElements("reactionScheme", 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 if (name.equals("role")) { setRole(value); } else if (name.equals("type")) { setType(value); } else if (name.equals("state")) { setState(value); } else if (name.equals("format")) { setFormat(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractReactionStep.java000077500000000000000000000471131477224461000301250ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractReactionStep extends CMLElement { /** local name*/ public final static String TAG = "reactionStep"; /** constructor. */ public AbstractReactionStep() { super("reactionStep"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractReactionStep(AbstractReactionStep 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", "reactionStep"); 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", "reactionStep"); 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", "reactionStep"); 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", "reactionStep"); 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", "reactionStep"); 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: yield /** cache */ DoubleSTAttribute _att_yield = null; /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return CMLAttribute */ public CMLAttribute getYieldAttribute() { return (CMLAttribute) getAttribute("yield"); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @return double */ public double getYield() { DoubleSTAttribute att = (DoubleSTAttribute) this.getYieldAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYield(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_yield == null) { _att_yield = (DoubleSTAttribute) attributeFactory.getAttribute("yield", "reactionStep"); if (_att_yield == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yield probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_yield); super.addRemove(att, value); } /** Yield of a reaction or reactionStep. * Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setYield(double value) throws RuntimeException { if (_att_yield == null) { _att_yield = (DoubleSTAttribute) attributeFactory.getAttribute("yield", "reactionStep"); if (_att_yield == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : yield probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_yield); super.addAttribute(att); att.setCMLValue(value); } // attribute: ratio /** cache */ DoubleSTAttribute _att_ratio = null; /** A ratio in the range 0 to 1. * Currently used for ratios between brached reactions but re-usable for other concepts. * @return CMLAttribute */ public CMLAttribute getRatioAttribute() { return (CMLAttribute) getAttribute("ratio"); } /** A ratio in the range 0 to 1. * Currently used for ratios between brached reactions but re-usable for other concepts. * @return double */ public double getRatio() { DoubleSTAttribute att = (DoubleSTAttribute) this.getRatioAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** A ratio in the range 0 to 1. * Currently used for ratios between brached reactions but re-usable for other concepts. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setRatio(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_ratio == null) { _att_ratio = (DoubleSTAttribute) attributeFactory.getAttribute("ratio", "reactionStep"); if (_att_ratio == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : ratio probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_ratio); super.addRemove(att, value); } /** A ratio in the range 0 to 1. * Currently used for ratios between brached reactions but re-usable for other concepts. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setRatio(double value) throws RuntimeException { if (_att_ratio == null) { _att_ratio = (DoubleSTAttribute) attributeFactory.getAttribute("ratio", "reactionStep"); if (_att_ratio == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : ratio probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_ratio); super.addAttribute(att); att.setCMLValue(value); } // element: metadataList /** A ratio in the range 0 to 1. * Currently used for ratios between brached reactions but re-usable for other concepts. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** A ratio in the range 0 to 1. * Currently used for ratios between brached reactions but re-usable for other concepts. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: name /** A ratio in the range 0 to 1. * Currently used for ratios between brached reactions but re-usable for other concepts. * @param name child to add */ public void addName(AbstractName name) { name.detach(); this.appendChild(name); } /** A ratio in the range 0 to 1. * Currently used for ratios between brached reactions but re-usable for other concepts. * @return CMLElements<CMLName> */ public CMLElements getNameElements() { Elements elements = this.getChildElements("name", CMLConstants.CML_NS); return new CMLElements(elements); } // element: label /** A ratio in the range 0 to 1. * Currently used for ratios between brached reactions but re-usable for other concepts. * @param label child to add */ public void addLabel(AbstractLabel label) { label.detach(); this.appendChild(label); } /** A ratio in the range 0 to 1. * Currently used for ratios between brached reactions but re-usable for other concepts. * @return CMLElements<CMLLabel> */ public CMLElements getLabelElements() { Elements elements = this.getChildElements("label", CMLConstants.CML_NS); return new CMLElements(elements); } // element: reactionScheme /** A ratio in the range 0 to 1. * Currently used for ratios between brached reactions but re-usable for other concepts. * @param reactionScheme child to add */ public void addReactionScheme(AbstractReactionScheme reactionScheme) { reactionScheme.detach(); this.appendChild(reactionScheme); } /** A ratio in the range 0 to 1. * Currently used for ratios between brached reactions but re-usable for other concepts. * @return CMLElements<CMLReactionScheme> */ public CMLElements getReactionSchemeElements() { Elements elements = this.getChildElements("reactionScheme", CMLConstants.CML_NS); return new CMLElements(elements); } // element: reaction /** A ratio in the range 0 to 1. * Currently used for ratios between brached reactions but re-usable for other concepts. * @param reaction child to add */ public void addReaction(AbstractReaction reaction) { reaction.detach(); this.appendChild(reaction); } /** A ratio in the range 0 to 1. * Currently used for ratios between brached reactions but re-usable for other concepts. * @return CMLElements<CMLReaction> */ public CMLElements getReactionElements() { Elements elements = this.getChildElements("reaction", 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 if (name.equals("yield")) { setYield(value); } else if (name.equals("ratio")) { setRatio(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractReactionStepList.java000077500000000000000000000474411477224461000307650ustar00rootroot00000000000000/** * 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 AbstractReactionStepList extends CMLElement { /** local name*/ public final static String TAG = "reactionStepList"; /** constructor. */ public AbstractReactionStepList() { super("reactionStepList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractReactionStepList(AbstractReactionStepList 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", "reactionStepList"); 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", "reactionStepList"); 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", "reactionStepList"); 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", "reactionStepList"); 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", "reactionStepList"); 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: 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", "reactionStepList"); 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: format /** cache */ StringSTAttribute _att_format = null; /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return CMLAttribute */ public CMLAttribute getFormatAttribute() { return (CMLAttribute) getAttribute("format"); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return String */ public String getFormat() { StringSTAttribute att = (StringSTAttribute) this.getFormatAttribute(); if (att == null) { return null; } return att.getString(); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setFormat(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_format == null) { _att_format = (StringSTAttribute) attributeFactory.getAttribute("format", "reactionStepList"); if (_att_format == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : format probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_format); super.addRemove(att, value); } // element: metadataList /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: name /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @param name child to add */ public void addName(AbstractName name) { name.detach(); this.appendChild(name); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return CMLElements<CMLName> */ public CMLElements getNameElements() { Elements elements = this.getChildElements("name", CMLConstants.CML_NS); return new CMLElements(elements); } // element: label /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @param label child to add */ public void addLabel(AbstractLabel label) { label.detach(); this.appendChild(label); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return CMLElements<CMLLabel> */ public CMLElements getLabelElements() { Elements elements = this.getChildElements("label", CMLConstants.CML_NS); return new CMLElements(elements); } // element: reactionStep /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @param reactionStep child to add */ public void addReactionStep(AbstractReactionStep reactionStep) { reactionStep.detach(); this.appendChild(reactionStep); } /** Format of the reaction component. * Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. * @return CMLElements<CMLReactionStep> */ public CMLElements getReactionStepElements() { Elements elements = this.getChildElements("reactionStep", 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 if (name.equals("type")) { setType(value); } else if (name.equals("format")) { setFormat(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractReactiveCentre.java000077500000000000000000000267121477224461000304320ustar00rootroot00000000000000/** * 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 AbstractReactiveCentre extends CMLElement { /** local name*/ public final static String TAG = "reactiveCentre"; /** constructor. */ public AbstractReactiveCentre() { super("reactiveCentre"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractReactiveCentre(AbstractReactiveCentre 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", "reactiveCentre"); 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", "reactiveCentre"); 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", "reactiveCentre"); 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", "reactiveCentre"); 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: atomTypeList /** null * @param atomTypeList child to add */ public void addAtomTypeList(AbstractAtomTypeList atomTypeList) { atomTypeList.detach(); this.appendChild(atomTypeList); } /** null * @return CMLElements<CMLAtomTypeList> */ public CMLElements getAtomTypeListElements() { Elements elements = this.getChildElements("atomTypeList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: bondTypeList /** null * @param bondTypeList child to add */ public void addBondTypeList(AbstractBondTypeList bondTypeList) { bondTypeList.detach(); this.appendChild(bondTypeList); } /** null * @return CMLElements<CMLBondTypeList> */ public CMLElements getBondTypeListElements() { Elements elements = this.getChildElements("bondTypeList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: atomSet /** null * @param atomSet child to add */ public void addAtomSet(AbstractAtomSet atomSet) { atomSet.detach(); this.appendChild(atomSet); } /** null * @return CMLElements<CMLAtomSet> */ public CMLElements getAtomSetElements() { Elements elements = this.getChildElements("atomSet", CMLConstants.CML_NS); return new CMLElements(elements); } // element: bondSet /** null * @param bondSet child to add */ public void addBondSet(AbstractBondSet bondSet) { bondSet.detach(); this.appendChild(bondSet); } /** null * @return CMLElements<CMLBondSet> */ public CMLElements getBondSetElements() { Elements elements = this.getChildElements("bondSet", 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 { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractRegion.java000077500000000000000000000440621477224461000267500ustar00rootroot00000000000000/** * 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.DoubleArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractRegion extends CMLElement { /** local name*/ public final static String TAG = "region"; /** constructor. */ public AbstractRegion() { super("region"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractRegion(AbstractRegion old) { super((CMLElement) old); } // attribute: sphere3 /** cache */ DoubleArraySTAttribute _att_sphere3 = null; /** A sphere. * Currently describes a region. Any point falling within the sphere or on its surface is within the region. * @return CMLAttribute */ public CMLAttribute getSphere3Attribute() { return (CMLAttribute) getAttribute("sphere3"); } /** A sphere. * Currently describes a region. Any point falling within the sphere or on its surface is within the region. * @return double[] */ public double[] getSphere3() { DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getSphere3Attribute(); if (att == null) { return null; } return att.getDoubleArray(); } /** A sphere. * Currently describes a region. Any point falling within the sphere or on its surface is within the region. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setSphere3(String value) throws RuntimeException { DoubleArraySTAttribute att = null; if (_att_sphere3 == null) { _att_sphere3 = (DoubleArraySTAttribute) attributeFactory.getAttribute("sphere3", "region"); if (_att_sphere3 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : sphere3 probably incompatible attributeGroupName and attributeName"); } } att = new DoubleArraySTAttribute(_att_sphere3); super.addRemove(att, value); } /** A sphere. * Currently describes a region. Any point falling within the sphere or on its surface is within the region. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setSphere3(double[] value) throws RuntimeException { if (_att_sphere3 == null) { _att_sphere3 = (DoubleArraySTAttribute) attributeFactory.getAttribute("sphere3", "region"); if (_att_sphere3 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : sphere3 probably incompatible attributeGroupName and attributeName "); } } DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_sphere3); super.addAttribute(att); att.setCMLValue(value); } // attribute: box3 /** cache */ DoubleArraySTAttribute _att_box3 = null; /** A parallelipiped box. * By default the box uses isometric Cartesians axes but can also be linked to lattice Vector. Any point falling within the box or on a boundary is within the regio. * @return CMLAttribute */ public CMLAttribute getBox3Attribute() { return (CMLAttribute) getAttribute("box3"); } /** A parallelipiped box. * By default the box uses isometric Cartesians axes but can also be linked to lattice Vector. Any point falling within the box or on a boundary is within the regio. * @return double[] */ public double[] getBox3() { DoubleArraySTAttribute att = (DoubleArraySTAttribute) this.getBox3Attribute(); if (att == null) { return null; } return att.getDoubleArray(); } /** A parallelipiped box. * By default the box uses isometric Cartesians axes but can also be linked to lattice Vector. Any point falling within the box or on a boundary is within the regio. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setBox3(String value) throws RuntimeException { DoubleArraySTAttribute att = null; if (_att_box3 == null) { _att_box3 = (DoubleArraySTAttribute) attributeFactory.getAttribute("box3", "region"); if (_att_box3 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : box3 probably incompatible attributeGroupName and attributeName"); } } att = new DoubleArraySTAttribute(_att_box3); super.addRemove(att, value); } /** A parallelipiped box. * By default the box uses isometric Cartesians axes but can also be linked to lattice Vector. Any point falling within the box or on a boundary is within the regio. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setBox3(double[] value) throws RuntimeException { if (_att_box3 == null) { _att_box3 = (DoubleArraySTAttribute) attributeFactory.getAttribute("box3", "region"); if (_att_box3 == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : box3 probably incompatible attributeGroupName and attributeName "); } } DoubleArraySTAttribute att = new DoubleArraySTAttribute(_att_box3); super.addAttribute(att); att.setCMLValue(value); } // attribute: atomSetRef /** cache */ StringSTAttribute _att_atomsetref = null; /** An atomSet describing the region. * Any point falling within atomOffset of any atom in the set lies within the region. This means the region could consist of disjoint fragments. * @return CMLAttribute */ public CMLAttribute getAtomSetRefAttribute() { return (CMLAttribute) getAttribute("atomSetRef"); } /** An atomSet describing the region. * Any point falling within atomOffset of any atom in the set lies within the region. This means the region could consist of disjoint fragments. * @return String */ public String getAtomSetRef() { StringSTAttribute att = (StringSTAttribute) this.getAtomSetRefAttribute(); if (att == null) { return null; } return att.getString(); } /** An atomSet describing the region. * Any point falling within atomOffset of any atom in the set lies within the region. This means the region could consist of disjoint fragments. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setAtomSetRef(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_atomsetref == null) { _att_atomsetref = (StringSTAttribute) attributeFactory.getAttribute("atomSetRef", "region"); if (_att_atomsetref == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : atomSetRef probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_atomsetref); super.addRemove(att, value); } // attribute: regionRefs /** cache */ StringSTAttribute _att_regionrefs = null; /** A list of regions creating a union. * The union of a series of regions produces a larger region (possibly disjoint). Any point belonging to any of the referenced regions is a member of this region. * @return CMLAttribute */ public CMLAttribute getRegionRefsAttribute() { return (CMLAttribute) getAttribute("regionRefs"); } /** A list of regions creating a union. * The union of a series of regions produces a larger region (possibly disjoint). Any point belonging to any of the referenced regions is a member of this region. * @return String */ public String getRegionRefs() { StringSTAttribute att = (StringSTAttribute) this.getRegionRefsAttribute(); if (att == null) { return null; } return att.getString(); } /** A list of regions creating a union. * The union of a series of regions produces a larger region (possibly disjoint). Any point belonging to any of the referenced regions is a member of this region. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setRegionRefs(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_regionrefs == null) { _att_regionrefs = (StringSTAttribute) attributeFactory.getAttribute("regionRefs", "region"); if (_att_regionrefs == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : regionRefs probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_regionrefs); 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", "region"); 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", "region"); 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", "region"); 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", "region"); 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); } /** 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("sphere3")) { setSphere3(value); } else if (name.equals("box3")) { setBox3(value); } else if (name.equals("atomSetRef")) { setAtomSetRef(value); } else if (name.equals("regionRefs")) { setRegionRefs(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/AbstractRelatedEntry.java000077500000000000000000000125731477224461000301310ustar00rootroot00000000000000/** * 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.base.CMLAttribute; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractRelatedEntry extends CMLElement { /** local name*/ public final static String TAG = "relatedEntry"; /** constructor. */ public AbstractRelatedEntry() { super("relatedEntry"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractRelatedEntry(AbstractRelatedEntry old) { super((CMLElement) old); } // attribute: type /** cache */ StringSTAttribute _att_type = null; /** Type of relatedEntry. * Type represents a the type of relationship in a relatedEntry element. * @return CMLAttribute */ public CMLAttribute getTypeAttribute() { return (CMLAttribute) getAttribute("type"); } /** Type of relatedEntry. * Type represents a the type of relationship in a relatedEntry element. * @return String */ public String getType() { StringSTAttribute att = (StringSTAttribute) this.getTypeAttribute(); if (att == null) { return null; } return att.getString(); } /** Type of relatedEntry. * Type represents a the type of relationship in a relatedEntry element. * @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", "relatedEntry"); 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: href /** cache */ StringSTAttribute _att_href = null; /** address of a resource. * Links to another element in the same or other file. For dictionary/@dictRef requires the prefix and the physical URI * address to be contained within the same file. We can anticipate that * better mechanisms will arise - perhaps through XMLCatalogs. * At least it works at present. * @return CMLAttribute */ public CMLAttribute getHrefAttribute() { return (CMLAttribute) getAttribute("href"); } /** address of a resource. * Links to another element in the same or other file. For dictionary/@dictRef requires the prefix and the physical URI * address to be contained within the same file. We can anticipate that * better mechanisms will arise - perhaps through XMLCatalogs. * At least it works at present. * @return String */ public String getHref() { StringSTAttribute att = (StringSTAttribute) this.getHrefAttribute(); if (att == null) { return null; } return att.getString(); } /** address of a resource. * Links to another element in the same or other file. For dictionary/@dictRef requires the prefix and the physical URI * address to be contained within the same file. We can anticipate that * better mechanisms will arise - perhaps through XMLCatalogs. * At least it works at present. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setHref(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_href == null) { _att_href = (StringSTAttribute) attributeFactory.getAttribute("href", "relatedEntry"); if (_att_href == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : href probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_href); 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("type")) { setType(value); } else if (name.equals("href")) { setHref(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractSample.java000077500000000000000000000351171477224461000267470ustar00rootroot00000000000000/** * 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 AbstractSample extends CMLElement { /** local name*/ public final static String TAG = "sample"; /** constructor. */ public AbstractSample() { super("sample"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractSample(AbstractSample 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", "sample"); 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", "sample"); 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", "sample"); 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", "sample"); 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", "sample"); 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: state /** cache */ StringSTAttribute _att_state = null; /** The physical state of the substance. * No fixed semantics or default. * @return CMLAttribute */ public CMLAttribute getStateAttribute() { return (CMLAttribute) getAttribute("state"); } /** The physical state of the substance. * No fixed semantics or default. * @return String */ public String getState() { StringSTAttribute att = (StringSTAttribute) this.getStateAttribute(); if (att == null) { return null; } return att.getString(); } /** The physical state of the substance. * No fixed semantics or default. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setState(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_state == null) { _att_state = (StringSTAttribute) attributeFactory.getAttribute("state", "sample"); if (_att_state == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : state probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_state); super.addRemove(att, value); } // element: metadataList /** The physical state of the substance. * No fixed semantics or default. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: molecule /** The physical state of the substance. * No fixed semantics or default. * @param molecule child to add */ public void addMolecule(AbstractMolecule molecule) { molecule.detach(); this.appendChild(molecule); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLMolecule> */ public CMLElements getMoleculeElements() { Elements elements = this.getChildElements("molecule", CMLConstants.CML_NS); return new CMLElements(elements); } // element: substance /** The physical state of the substance. * No fixed semantics or default. * @param substance child to add */ public void addSubstance(AbstractSubstance substance) { substance.detach(); this.appendChild(substance); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLSubstance> */ public CMLElements getSubstanceElements() { Elements elements = this.getChildElements("substance", CMLConstants.CML_NS); return new CMLElements(elements); } // element: substanceList /** The physical state of the substance. * No fixed semantics or default. * @param substanceList child to add */ public void addSubstanceList(AbstractSubstanceList substanceList) { substanceList.detach(); this.appendChild(substanceList); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLSubstanceList> */ public CMLElements getSubstanceListElements() { Elements elements = this.getChildElements("substanceList", 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 if (name.equals("state")) { setState(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractScalar.java000077500000000000000000000702131477224461000267270ustar00rootroot00000000000000/** * 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.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.DoubleSTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractScalar extends CMLElement { /** local name*/ public final static String TAG = "scalar"; /** constructor. */ public AbstractScalar() { super("scalar"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractScalar(AbstractScalar 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", "scalar"); 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", "scalar"); 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", "scalar"); 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", "scalar"); 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", "scalar"); 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: 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", "scalar"); 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", "scalar"); 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", "scalar"); 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", "scalar"); 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", "scalar"); 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", "scalar"); 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: 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", "scalar"); 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: 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", "scalar"); 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", "scalar"); 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", "scalar"); 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", "scalar"); 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 */ CMLAttribute _att_unittype = null; /** null * @return CMLAttribute */ public NamespaceRefAttribute getUnitTypeAttribute() { return (NamespaceRefAttribute) 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", "scalar"); 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, false); return _xmlContent.getString(); // System.out.println(":"+content+":"); // return this.getValue(); } /** * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(String value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new StringSTAttribute("_xmlContent"); } // bug _xmlContent.setCMLValue(value, false); String attval = _xmlContent.getValue(); this.removeChildren(); this.appendChild(attval); // this.appendChild(value); // System.out.println(":"+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("dataType")) { setDataType(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 if (name.equals("units")) { setUnits(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/AbstractSpectator.java000077500000000000000000000333121477224461000274650ustar00rootroot00000000000000/** * 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 AbstractSpectator extends CMLElement { /** local name*/ public final static String TAG = "spectator"; /** constructor. */ public AbstractSpectator() { super("spectator"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractSpectator(AbstractSpectator 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", "spectator"); 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", "spectator"); 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", "spectator"); 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", "spectator"); 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: 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", "spectator"); 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); } // element: metadataList /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: label /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param label child to add */ public void addLabel(AbstractLabel label) { label.detach(); this.appendChild(label); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLLabel> */ public CMLElements getLabelElements() { Elements elements = this.getChildElements("label", CMLConstants.CML_NS); return new CMLElements(elements); } // element: molecule /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param molecule child to add */ public void addMolecule(AbstractMolecule molecule) { molecule.detach(); this.appendChild(molecule); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLMolecule> */ public CMLElements getMoleculeElements() { Elements elements = this.getChildElements("molecule", CMLConstants.CML_NS); return new CMLElements(elements); } // element: object /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @param object child to add */ public void addObject(AbstractObject object) { object.detach(); this.appendChild(object); } /** Role of the object. * How the object functions or its position in the architecture. No controlled vocabulary. * @return CMLElements<CMLObject> */ public CMLElements getObjectElements() { Elements elements = this.getChildElements("object", 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("role")) { setRole(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractSpectatorList.java000077500000000000000000000237031477224461000303240ustar00rootroot00000000000000/** * 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 AbstractSpectatorList extends CMLElement { /** local name*/ public final static String TAG = "spectatorList"; /** constructor. */ public AbstractSpectatorList() { super("spectatorList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractSpectatorList(AbstractSpectatorList 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", "spectatorList"); 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", "spectatorList"); 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", "spectatorList"); 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", "spectatorList"); 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: spectator /** null * @param spectator child to add */ public void addSpectator(AbstractSpectator spectator) { spectator.detach(); this.appendChild(spectator); } /** null * @return CMLElements<CMLSpectator> */ public CMLElements getSpectatorElements() { Elements elements = this.getChildElements("spectator", 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 { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractSpectrum.java000077500000000000000000000604151477224461000273270ustar00rootroot00000000000000/** * 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 AbstractSpectrum extends CMLElement { /** local name*/ public final static String TAG = "spectrum"; /** constructor. */ public AbstractSpectrum() { super("spectrum"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractSpectrum(AbstractSpectrum 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", "spectrum"); 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", "spectrum"); 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", "spectrum"); 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", "spectrum"); 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", "spectrum"); 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: moleculeRef /** cache */ StringSTAttribute _att_moleculeref = null; /** A reference to a molecule. * Used by spectrum, etc. * @return CMLAttribute */ public CMLAttribute getMoleculeRefAttribute() { return (CMLAttribute) getAttribute("moleculeRef"); } /** A reference to a molecule. * Used by spectrum, etc. * @return String */ public String getMoleculeRef() { StringSTAttribute att = (StringSTAttribute) this.getMoleculeRefAttribute(); if (att == null) { return null; } return att.getString(); } /** A reference to a molecule. * Used by spectrum, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMoleculeRef(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_moleculeref == null) { _att_moleculeref = (StringSTAttribute) attributeFactory.getAttribute("moleculeRef", "spectrum"); if (_att_moleculeref == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : moleculeRef probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_moleculeref); super.addRemove(att, value); } // attribute: type /** cache */ StringSTAttribute _att_type = null; /** The type of the spectrum. * No description * @return CMLAttribute */ public CMLAttribute getTypeAttribute() { return (CMLAttribute) getAttribute("type"); } /** The type of the spectrum. * No description * @return String */ public String getType() { StringSTAttribute att = (StringSTAttribute) this.getTypeAttribute(); if (att == null) { return null; } return att.getString(); } /** The type of the spectrum. * No description * @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", "spectrum"); 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: format /** cache */ StringSTAttribute _att_format = null; /** Format of a spectrum. * The data structure of the spectrum. (Not the format of the data). This describes how the data structure is to be interpreted. * @return CMLAttribute */ public CMLAttribute getFormatAttribute() { return (CMLAttribute) getAttribute("format"); } /** Format of a spectrum. * The data structure of the spectrum. (Not the format of the data). This describes how the data structure is to be interpreted. * @return String */ public String getFormat() { StringSTAttribute att = (StringSTAttribute) this.getFormatAttribute(); if (att == null) { return null; } return att.getString(); } /** Format of a spectrum. * The data structure of the spectrum. (Not the format of the data). This describes how the data structure is to be interpreted. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setFormat(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_format == null) { _att_format = (StringSTAttribute) attributeFactory.getAttribute("format", "spectrum"); if (_att_format == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : format probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_format); super.addRemove(att, value); } // attribute: measurement /** cache */ StringSTAttribute _att_measurement = null; /** Type of spectral measurement. * The nature of the measured data. This is not an exhaustive list and should only be used if it affects the storage or immediate processing. * @return CMLAttribute */ public CMLAttribute getMeasurementAttribute() { return (CMLAttribute) getAttribute("measurement"); } /** Type of spectral measurement. * The nature of the measured data. This is not an exhaustive list and should only be used if it affects the storage or immediate processing. * @return String */ public String getMeasurement() { StringSTAttribute att = (StringSTAttribute) this.getMeasurementAttribute(); if (att == null) { return null; } return att.getString(); } /** Type of spectral measurement. * The nature of the measured data. This is not an exhaustive list and should only be used if it affects the storage or immediate processing. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMeasurement(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_measurement == null) { _att_measurement = (StringSTAttribute) attributeFactory.getAttribute("measurement", "spectrum"); if (_att_measurement == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : measurement probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_measurement); super.addRemove(att, value); } // attribute: ft /** cache */ StringSTAttribute _att_ft = null; /** Domain of an FT spectrum. * Indicates whether a spectrum is raw FID or has been transforme. * @return CMLAttribute */ public CMLAttribute getFtAttribute() { return (CMLAttribute) getAttribute("ft"); } /** Domain of an FT spectrum. * Indicates whether a spectrum is raw FID or has been transforme. * @return String */ public String getFt() { StringSTAttribute att = (StringSTAttribute) this.getFtAttribute(); if (att == null) { return null; } return att.getString(); } /** Domain of an FT spectrum. * Indicates whether a spectrum is raw FID or has been transforme. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setFt(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_ft == null) { _att_ft = (StringSTAttribute) attributeFactory.getAttribute("ft", "spectrum"); if (_att_ft == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : ft probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_ft); super.addRemove(att, value); } // attribute: state /** cache */ StringSTAttribute _att_state = null; /** The physical state of the substance. * No fixed semantics or default. * @return CMLAttribute */ public CMLAttribute getStateAttribute() { return (CMLAttribute) getAttribute("state"); } /** The physical state of the substance. * No fixed semantics or default. * @return String */ public String getState() { StringSTAttribute att = (StringSTAttribute) this.getStateAttribute(); if (att == null) { return null; } return att.getString(); } /** The physical state of the substance. * No fixed semantics or default. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setState(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_state == null) { _att_state = (StringSTAttribute) attributeFactory.getAttribute("state", "spectrum"); if (_att_state == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : state probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_state); super.addRemove(att, value); } // element: metadataList /** The physical state of the substance. * No fixed semantics or default. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: sample /** The physical state of the substance. * No fixed semantics or default. * @param sample child to add */ public void addSample(AbstractSample sample) { sample.detach(); this.appendChild(sample); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLSample> */ public CMLElements getSampleElements() { Elements elements = this.getChildElements("sample", CMLConstants.CML_NS); return new CMLElements(elements); } // element: parameterList /** The physical state of the substance. * No fixed semantics or default. * @param parameterList child to add */ public void addParameterList(AbstractParameterList parameterList) { parameterList.detach(); this.appendChild(parameterList); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLParameterList> */ public CMLElements getParameterListElements() { Elements elements = this.getChildElements("parameterList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: substanceList /** The physical state of the substance. * No fixed semantics or default. * @param substanceList child to add */ public void addSubstanceList(AbstractSubstanceList substanceList) { substanceList.detach(); this.appendChild(substanceList); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLSubstanceList> */ public CMLElements getSubstanceListElements() { Elements elements = this.getChildElements("substanceList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: conditionList /** The physical state of the substance. * No fixed semantics or default. * @param conditionList child to add */ public void addConditionList(AbstractConditionList conditionList) { conditionList.detach(); this.appendChild(conditionList); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLConditionList> */ public CMLElements getConditionListElements() { Elements elements = this.getChildElements("conditionList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: spectrumData /** The physical state of the substance. * No fixed semantics or default. * @param spectrumData child to add */ public void addSpectrumData(AbstractSpectrumData spectrumData) { spectrumData.detach(); this.appendChild(spectrumData); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLSpectrumData> */ public CMLElements getSpectrumDataElements() { Elements elements = this.getChildElements("spectrumData", CMLConstants.CML_NS); return new CMLElements(elements); } // element: peakList /** The physical state of the substance. * No fixed semantics or default. * @param peakList child to add */ public void addPeakList(AbstractPeakList peakList) { peakList.detach(); this.appendChild(peakList); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLPeakList> */ public CMLElements getPeakListElements() { Elements elements = this.getChildElements("peakList", 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 if (name.equals("moleculeRef")) { setMoleculeRef(value); } else if (name.equals("type")) { setType(value); } else if (name.equals("format")) { setFormat(value); } else if (name.equals("measurement")) { setMeasurement(value); } else if (name.equals("ft")) { setFt(value); } else if (name.equals("state")) { setState(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractSpectrumData.java000077500000000000000000000270411477224461000301170ustar00rootroot00000000000000/** * 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 AbstractSpectrumData extends CMLElement { /** local name*/ public final static String TAG = "spectrumData"; /** constructor. */ public AbstractSpectrumData() { super("spectrumData"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractSpectrumData(AbstractSpectrumData 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", "spectrumData"); 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", "spectrumData"); 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", "spectrumData"); 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", "spectrumData"); 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", "spectrumData"); 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: xaxis /** null * @param xaxis child to add */ public void addXaxis(AbstractXaxis xaxis) { xaxis.detach(); this.appendChild(xaxis); } /** null * @return CMLElements<CMLXaxis> */ public CMLElements getXaxisElements() { Elements elements = this.getChildElements("xaxis", CMLConstants.CML_NS); return new CMLElements(elements); } // element: yaxis /** null * @param yaxis child to add */ public void addYaxis(AbstractYaxis yaxis) { yaxis.detach(); this.appendChild(yaxis); } /** null * @return CMLElements<CMLYaxis> */ public CMLElements getYaxisElements() { Elements elements = this.getChildElements("yaxis", 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/AbstractSpectrumList.java000077500000000000000000000347431477224461000301700ustar00rootroot00000000000000/** * 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 AbstractSpectrumList extends CMLElement { /** local name*/ public final static String TAG = "spectrumList"; /** constructor. */ public AbstractSpectrumList() { super("spectrumList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractSpectrumList(AbstractSpectrumList 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", "spectrumList"); 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", "spectrumList"); 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", "spectrumList"); 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", "spectrumList"); 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", "spectrumList"); 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: moleculeRef /** cache */ StringSTAttribute _att_moleculeref = null; /** A reference to a molecule. * Used by spectrum, etc. * @return CMLAttribute */ public CMLAttribute getMoleculeRefAttribute() { return (CMLAttribute) getAttribute("moleculeRef"); } /** A reference to a molecule. * Used by spectrum, etc. * @return String */ public String getMoleculeRef() { StringSTAttribute att = (StringSTAttribute) this.getMoleculeRefAttribute(); if (att == null) { return null; } return att.getString(); } /** A reference to a molecule. * Used by spectrum, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMoleculeRef(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_moleculeref == null) { _att_moleculeref = (StringSTAttribute) attributeFactory.getAttribute("moleculeRef", "spectrumList"); if (_att_moleculeref == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : moleculeRef probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_moleculeref); super.addRemove(att, value); } // element: metadataList /** A reference to a molecule. * Used by spectrum, etc. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** A reference to a molecule. * Used by spectrum, etc. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: list /** A reference to a molecule. * Used by spectrum, etc. * @param list child to add */ public void addList(AbstractList list) { list.detach(); this.appendChild(list); } /** A reference to a molecule. * Used by spectrum, etc. * @return CMLElements<CMLList> */ public CMLElements getListElements() { Elements elements = this.getChildElements("list", CMLConstants.CML_NS); return new CMLElements(elements); } // element: spectrumList /** A reference to a molecule. * Used by spectrum, etc. * @param spectrumList child to add */ public void addSpectrumList(AbstractSpectrumList spectrumList) { spectrumList.detach(); this.appendChild(spectrumList); } /** A reference to a molecule. * Used by spectrum, etc. * @return CMLElements<CMLSpectrumList> */ public CMLElements getSpectrumListElements() { Elements elements = this.getChildElements("spectrumList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: spectrum /** A reference to a molecule. * Used by spectrum, etc. * @param spectrum child to add */ public void addSpectrum(AbstractSpectrum spectrum) { spectrum.detach(); this.appendChild(spectrum); } /** A reference to a molecule. * Used by spectrum, etc. * @return CMLElements<CMLSpectrum> */ public CMLElements getSpectrumElements() { Elements elements = this.getChildElements("spectrum", 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 if (name.equals("moleculeRef")) { setMoleculeRef(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractSphere3.java000077500000000000000000000305431477224461000270350ustar00rootroot00000000000000/** * 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.DoubleArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractSphere3 extends CMLElement { /** local name*/ public final static String TAG = "sphere3"; /** constructor. */ public AbstractSphere3() { super("sphere3"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractSphere3(AbstractSphere3 old) { super((CMLElement) old); } // 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", "sphere3"); 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", "sphere3"); 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: 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", "sphere3"); 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: 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", "sphere3"); 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: 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", "sphere3"); 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); } DoubleArraySTAttribute _xmlContent; /** A sphere in 3-space. * Defined by 4 real numbers, conventionally a point3 at * the centre of the sphere and a nonNegative scalar for the radius. * @return double[] */ public double[] getXMLContent() { String content = this.getValue(); if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(content); return _xmlContent.getDoubleArray(); } /** A sphere in 3-space. * Defined by 4 real numbers, conventionally a point3 at * the centre of the sphere and a nonNegative scalar for the radius. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(String value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(value); String attval = _xmlContent.getValue(); this.removeChildren(); this.appendChild(attval); } /** A sphere in 3-space. * Defined by 4 real numbers, conventionally a point3 at * the centre of the sphere and a nonNegative scalar for the radius. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(double[] value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_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("convention")) { setConvention(value); } else if (name.equals("dictRef")) { setDictRef(value); } else if (name.equals("id")) { setId(value); } else if (name.equals("title")) { setTitle(value); } else if (name.equals("units")) { setUnits(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractSubstance.java000077500000000000000000000512111477224461000274460ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractSubstance extends CMLElement { /** local name*/ public final static String TAG = "substance"; /** constructor. */ public AbstractSubstance() { super("substance"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractSubstance(AbstractSubstance 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", "substance"); 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", "substance"); 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", "substance"); 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", "substance"); 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: 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", "substance"); 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: 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", "substance"); 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: 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", "substance"); 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", "substance"); 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", "substance"); 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: state /** cache */ StringSTAttribute _att_state = null; /** The physical state of the substance. * No fixed semantics or default. * @return CMLAttribute */ public CMLAttribute getStateAttribute() { return (CMLAttribute) getAttribute("state"); } /** The physical state of the substance. * No fixed semantics or default. * @return String */ public String getState() { StringSTAttribute att = (StringSTAttribute) this.getStateAttribute(); if (att == null) { return null; } return att.getString(); } /** The physical state of the substance. * No fixed semantics or default. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setState(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_state == null) { _att_state = (StringSTAttribute) attributeFactory.getAttribute("state", "substance"); if (_att_state == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : state probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_state); super.addRemove(att, value); } // element: metadataList /** The physical state of the substance. * No fixed semantics or default. * @param metadataList child to add */ public void addMetadataList(AbstractMetadataList metadataList) { metadataList.detach(); this.appendChild(metadataList); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLMetadataList> */ public CMLElements getMetadataListElements() { Elements elements = this.getChildElements("metadataList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: amount /** The physical state of the substance. * No fixed semantics or default. * @param amount child to add */ public void addAmount(AbstractAmount amount) { amount.detach(); this.appendChild(amount); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLAmount> */ public CMLElements getAmountElements() { Elements elements = this.getChildElements("amount", CMLConstants.CML_NS); return new CMLElements(elements); } // element: molecule /** The physical state of the substance. * No fixed semantics or default. * @param molecule child to add */ public void addMolecule(AbstractMolecule molecule) { molecule.detach(); this.appendChild(molecule); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLMolecule> */ public CMLElements getMoleculeElements() { Elements elements = this.getChildElements("molecule", CMLConstants.CML_NS); return new CMLElements(elements); } // element: name /** The physical state of the substance. * No fixed semantics or default. * @param name child to add */ public void addName(AbstractName name) { name.detach(); this.appendChild(name); } /** The physical state of the substance. * No fixed semantics or default. * @return CMLElements<CMLName> */ public CMLElements getNameElements() { Elements elements = this.getChildElements("name", CMLConstants.CML_NS); return new CMLElements(elements); } // element: property /** The physical state of the substance. * No fixed semantics or default. * @param property child to add */ public void addProperty(AbstractProperty property) { property.detach(); this.appendChild(property); } /** The physical state of the substance. * No fixed semantics or default. * @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("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("type")) { setType(value); } else if (name.equals("role")) { setRole(value); } else if (name.equals("ref")) { setRef(value); } else if (name.equals("count")) { setCount(value); } else if (name.equals("state")) { setState(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractSubstanceList.java000077500000000000000000000371571477224461000303170ustar00rootroot00000000000000/** * 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 AbstractSubstanceList extends CMLElement { /** local name*/ public final static String TAG = "substanceList"; /** constructor. */ public AbstractSubstanceList() { super("substanceList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractSubstanceList(AbstractSubstanceList 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", "substanceList"); 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", "substanceList"); 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", "substanceList"); 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", "substanceList"); 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: type /** cache */ StringSTAttribute _att_type = null; /** Type of the substanceList. * Extension is allowed through the "other" value. * @return CMLAttribute */ public CMLAttribute getTypeAttribute() { return (CMLAttribute) getAttribute("type"); } /** Type of the substanceList. * Extension is allowed through the "other" value. * @return String */ public String getType() { StringSTAttribute att = (StringSTAttribute) this.getTypeAttribute(); if (att == null) { return null; } return att.getString(); } /** Type of the substanceList. * Extension is allowed through the "other" value. * @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", "substanceList"); 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: 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", "substanceList"); 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: 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", "substanceList"); 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: amount /** null * @param amount child to add */ public void addAmount(AbstractAmount amount) { amount.detach(); this.appendChild(amount); } /** null * @return CMLElements<CMLAmount> */ public CMLElements getAmountElements() { Elements elements = this.getChildElements("amount", CMLConstants.CML_NS); return new CMLElements(elements); } // element: substance /** null * @param substance child to add */ public void addSubstance(AbstractSubstance substance) { substance.detach(); this.appendChild(substance); } /** null * @return CMLElements<CMLSubstance> */ public CMLElements getSubstanceElements() { Elements elements = this.getChildElements("substance", CMLConstants.CML_NS); return new CMLElements(elements); } // element: propertyList /** null * @param propertyList child to add */ public void addPropertyList(AbstractPropertyList propertyList) { propertyList.detach(); this.appendChild(propertyList); } /** null * @return CMLElements<CMLPropertyList> */ public CMLElements getPropertyListElements() { Elements elements = this.getChildElements("propertyList", 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("type")) { setType(value); } else if (name.equals("role")) { setRole(value); } else if (name.equals("ref")) { setRef(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractSymmetry.java000077500000000000000000000454021477224461000273550ustar00rootroot00000000000000/** * 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 AbstractSymmetry extends CMLElement { /** local name*/ public final static String TAG = "symmetry"; /** constructor. */ public AbstractSymmetry() { super("symmetry"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractSymmetry(AbstractSymmetry 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", "symmetry"); 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", "symmetry"); 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", "symmetry"); 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", "symmetry"); 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: pointGroup /** cache */ StringSTAttribute _att_pointgroup = null; /** A point group. * No fixed semantics, though Schoenflies is recommended over Hermann-Mauguin. We may provide a controlled-extensible list in the future. * @return CMLAttribute */ public CMLAttribute getPointGroupAttribute() { return (CMLAttribute) getAttribute("pointGroup"); } /** A point group. * No fixed semantics, though Schoenflies is recommended over Hermann-Mauguin. We may provide a controlled-extensible list in the future. * @return String */ public String getPointGroup() { StringSTAttribute att = (StringSTAttribute) this.getPointGroupAttribute(); if (att == null) { return null; } return att.getString(); } /** A point group. * No fixed semantics, though Schoenflies is recommended over Hermann-Mauguin. We may provide a controlled-extensible list in the future. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPointGroup(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_pointgroup == null) { _att_pointgroup = (StringSTAttribute) attributeFactory.getAttribute("pointGroup", "symmetry"); if (_att_pointgroup == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : pointGroup probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_pointgroup); super.addRemove(att, value); } // attribute: spaceGroup /** cache */ StringSTAttribute _att_spacegroup = null; /** A space group. * No fixed semantics, though Hermann-Mauguin or Hall is recommended over Schoenflies. We may provide a controlled-extensible list in the future. * @return CMLAttribute */ public CMLAttribute getSpaceGroupAttribute() { return (CMLAttribute) getAttribute("spaceGroup"); } /** A space group. * No fixed semantics, though Hermann-Mauguin or Hall is recommended over Schoenflies. We may provide a controlled-extensible list in the future. * @return String */ public String getSpaceGroup() { StringSTAttribute att = (StringSTAttribute) this.getSpaceGroupAttribute(); if (att == null) { return null; } return att.getString(); } /** A space group. * No fixed semantics, though Hermann-Mauguin or Hall is recommended over Schoenflies. We may provide a controlled-extensible list in the future. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setSpaceGroup(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_spacegroup == null) { _att_spacegroup = (StringSTAttribute) attributeFactory.getAttribute("spaceGroup", "symmetry"); if (_att_spacegroup == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : spaceGroup probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_spacegroup); super.addRemove(att, value); } // attribute: irreducibleRepresentation /** cache */ StringSTAttribute _att_irreduciblerepresentation = null; /** A symmetry species. * No fixed semantics, though we may provide a controlled-extensible list in the future. * @return CMLAttribute */ public CMLAttribute getIrreducibleRepresentationAttribute() { return (CMLAttribute) getAttribute("irreducibleRepresentation"); } /** A symmetry species. * No fixed semantics, though we may provide a controlled-extensible list in the future. * @return String */ public String getIrreducibleRepresentation() { StringSTAttribute att = (StringSTAttribute) this.getIrreducibleRepresentationAttribute(); if (att == null) { return null; } return att.getString(); } /** A symmetry species. * No fixed semantics, though we may provide a controlled-extensible list in the future. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setIrreducibleRepresentation(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_irreduciblerepresentation == null) { _att_irreduciblerepresentation = (StringSTAttribute) attributeFactory.getAttribute("irreducibleRepresentation", "symmetry"); if (_att_irreduciblerepresentation == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : irreducibleRepresentation probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_irreduciblerepresentation); super.addRemove(att, value); } // attribute: number /** cache */ IntSTAttribute _att_number = null; /** A number determined by context. * Used for isotope number in isotope, and rotational symmetry number in symmetry for calculation of entropy, etc. * @return CMLAttribute */ public CMLAttribute getNumberAttribute() { return (CMLAttribute) getAttribute("number"); } /** A number determined by context. * Used for isotope number in isotope, and rotational symmetry number in symmetry for calculation of entropy, etc. * @return int */ public int getNumber() { IntSTAttribute att = (IntSTAttribute) this.getNumberAttribute(); if (att == null) { throw new RuntimeException("int attribute is unset: number"); } return att.getInt(); } /** A number determined by context. * Used for isotope number in isotope, and rotational symmetry number in symmetry for calculation of entropy, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setNumber(String value) throws RuntimeException { IntSTAttribute att = null; if (_att_number == null) { _att_number = (IntSTAttribute) attributeFactory.getAttribute("number", "symmetry"); if (_att_number == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : number probably incompatible attributeGroupName and attributeName"); } } att = new IntSTAttribute(_att_number); super.addRemove(att, value); } /** A number determined by context. * Used for isotope number in isotope, and rotational symmetry number in symmetry for calculation of entropy, etc. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setNumber(int value) throws RuntimeException { if (_att_number == null) { _att_number = (IntSTAttribute) attributeFactory.getAttribute("number", "symmetry"); if (_att_number == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : number probably incompatible attributeGroupName and attributeName "); } } IntSTAttribute att = new IntSTAttribute(_att_number); super.addAttribute(att); att.setCMLValue(value); } // element: matrix /** A number determined by context. * Used for isotope number in isotope, and rotational symmetry number in symmetry for calculation of entropy, etc. * @param matrix child to add */ public void addMatrix(AbstractMatrix matrix) { matrix.detach(); this.appendChild(matrix); } /** A number determined by context. * Used for isotope number in isotope, and rotational symmetry number in symmetry for calculation of entropy, etc. * @return CMLElements<CMLMatrix> */ public CMLElements getMatrixElements() { Elements elements = this.getChildElements("matrix", CMLConstants.CML_NS); return new CMLElements(elements); } // element: transform3 /** A number determined by context. * Used for isotope number in isotope, and rotational symmetry number in symmetry for calculation of entropy, etc. * @param transform3 child to add */ public void addTransform3(AbstractTransform3 transform3) { transform3.detach(); this.appendChild(transform3); } /** A number determined by context. * Used for isotope number in isotope, and rotational symmetry number in symmetry for calculation of entropy, etc. * @return CMLElements<CMLTransform3> */ public CMLElements getTransform3Elements() { Elements elements = this.getChildElements("transform3", 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("pointGroup")) { setPointGroup(value); } else if (name.equals("spaceGroup")) { setSpaceGroup(value); } else if (name.equals("irreducibleRepresentation")) { setIrreducibleRepresentation(value); } else if (name.equals("number")) { setNumber(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractSystem.java000077500000000000000000000367011477224461000270120ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractSystem extends CMLElement { /** local name*/ public final static String TAG = "system"; /** constructor. */ public AbstractSystem() { super("system"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractSystem(AbstractSystem old) { super((CMLElement) old); } // attribute: dimensionality /** cache */ IntSTAttribute _att_dimensionality = null; /** Dimensionality of a coordinate system. * Note that this means that coordinates of higher dimensionality * are ignored or an error is flagged. Thus z3 and dimensionality='2' are incompatible. * At present higher dimensionalities than 3 (cf. Wondratschek) are not supported. * The labelling of the axes id not controlled. ?? should we have an explicit * attribute for labelling convention?. * @return CMLAttribute */ public CMLAttribute getDimensionalityAttribute() { return (CMLAttribute) getAttribute("dimensionality"); } /** Dimensionality of a coordinate system. * Note that this means that coordinates of higher dimensionality * are ignored or an error is flagged. Thus z3 and dimensionality='2' are incompatible. * At present higher dimensionalities than 3 (cf. Wondratschek) are not supported. * The labelling of the axes id not controlled. ?? should we have an explicit * attribute for labelling convention?. * @return int */ public int getDimensionality() { IntSTAttribute att = (IntSTAttribute) this.getDimensionalityAttribute(); if (att == null) { throw new RuntimeException("int attribute is unset: dimensionality"); } return att.getInt(); } /** Dimensionality of a coordinate system. * Note that this means that coordinates of higher dimensionality * are ignored or an error is flagged. Thus z3 and dimensionality='2' are incompatible. * At present higher dimensionalities than 3 (cf. Wondratschek) are not supported. * The labelling of the axes id not controlled. ?? should we have an explicit * attribute for labelling convention?. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setDimensionality(String value) throws RuntimeException { IntSTAttribute att = null; if (_att_dimensionality == null) { _att_dimensionality = (IntSTAttribute) attributeFactory.getAttribute("dimensionality", "system"); if (_att_dimensionality == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : dimensionality probably incompatible attributeGroupName and attributeName"); } } att = new IntSTAttribute(_att_dimensionality); super.addRemove(att, value); } /** Dimensionality of a coordinate system. * Note that this means that coordinates of higher dimensionality * are ignored or an error is flagged. Thus z3 and dimensionality='2' are incompatible. * At present higher dimensionalities than 3 (cf. Wondratschek) are not supported. * The labelling of the axes id not controlled. ?? should we have an explicit * attribute for labelling convention?. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setDimensionality(int value) throws RuntimeException { if (_att_dimensionality == null) { _att_dimensionality = (IntSTAttribute) attributeFactory.getAttribute("dimensionality", "system"); if (_att_dimensionality == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : dimensionality probably incompatible attributeGroupName and attributeName "); } } IntSTAttribute att = new IntSTAttribute(_att_dimensionality); super.addAttribute(att); att.setCMLValue(value); } // attribute: periodicity /** cache */ IntSTAttribute _att_periodicity = null; /** Periodicity of the system. * No description * @return CMLAttribute */ public CMLAttribute getPeriodicityAttribute() { return (CMLAttribute) getAttribute("periodicity"); } /** Periodicity of the system. * No description * @return int */ public int getPeriodicity() { IntSTAttribute att = (IntSTAttribute) this.getPeriodicityAttribute(); if (att == null) { throw new RuntimeException("int attribute is unset: periodicity"); } return att.getInt(); } /** Periodicity of the system. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPeriodicity(String value) throws RuntimeException { IntSTAttribute att = null; if (_att_periodicity == null) { _att_periodicity = (IntSTAttribute) attributeFactory.getAttribute("periodicity", "system"); if (_att_periodicity == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : periodicity probably incompatible attributeGroupName and attributeName"); } } att = new IntSTAttribute(_att_periodicity); super.addRemove(att, value); } /** Periodicity of the system. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setPeriodicity(int value) throws RuntimeException { if (_att_periodicity == null) { _att_periodicity = (IntSTAttribute) attributeFactory.getAttribute("periodicity", "system"); if (_att_periodicity == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : periodicity probably incompatible attributeGroupName and attributeName "); } } IntSTAttribute att = new IntSTAttribute(_att_periodicity); 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", "system"); 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", "system"); 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", "system"); 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", "system"); 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); } /** 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("dimensionality")) { setDimensionality(value); } else if (name.equals("periodicity")) { setPeriodicity(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/AbstractTable.java000077500000000000000000000441701477224461000265540ustar00rootroot00000000000000/** * 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.UnitsAttribute; 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 AbstractTable extends CMLElement { /** local name*/ public final static String TAG = "table"; /** constructor. */ public AbstractTable() { super("table"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractTable(AbstractTable old) { super((CMLElement) old); } // attribute: rows /** cache */ IntSTAttribute _att_rows = null; /** Number of rows. * No description * @return CMLAttribute */ public CMLAttribute getRowsAttribute() { return (CMLAttribute) getAttribute("rows"); } /** Number of rows. * No description * @return int */ public int getRows() { IntSTAttribute att = (IntSTAttribute) this.getRowsAttribute(); if (att == null) { throw new RuntimeException("int attribute is unset: rows"); } return att.getInt(); } /** Number of rows. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setRows(String value) throws RuntimeException { IntSTAttribute att = null; if (_att_rows == null) { _att_rows = (IntSTAttribute) attributeFactory.getAttribute("rows", "table"); if (_att_rows == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : rows probably incompatible attributeGroupName and attributeName"); } } att = new IntSTAttribute(_att_rows); super.addRemove(att, value); } /** Number of rows. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setRows(int value) throws RuntimeException { if (_att_rows == null) { _att_rows = (IntSTAttribute) attributeFactory.getAttribute("rows", "table"); if (_att_rows == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : rows probably incompatible attributeGroupName and attributeName "); } } IntSTAttribute att = new IntSTAttribute(_att_rows); super.addAttribute(att); att.setCMLValue(value); } // attribute: columns /** cache */ IntSTAttribute _att_columns = null; /** Number of columns. * No description * @return CMLAttribute */ public CMLAttribute getColumnsAttribute() { return (CMLAttribute) getAttribute("columns"); } /** Number of columns. * No description * @return int */ public int getColumns() { IntSTAttribute att = (IntSTAttribute) this.getColumnsAttribute(); if (att == null) { throw new RuntimeException("int attribute is unset: columns"); } return att.getInt(); } /** Number of columns. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setColumns(String value) throws RuntimeException { IntSTAttribute att = null; if (_att_columns == null) { _att_columns = (IntSTAttribute) attributeFactory.getAttribute("columns", "table"); if (_att_columns == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : columns probably incompatible attributeGroupName and attributeName"); } } att = new IntSTAttribute(_att_columns); super.addRemove(att, value); } /** Number of columns. * No description * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setColumns(int value) throws RuntimeException { if (_att_columns == null) { _att_columns = (IntSTAttribute) attributeFactory.getAttribute("columns", "table"); if (_att_columns == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : columns probably incompatible attributeGroupName and attributeName "); } } IntSTAttribute att = new IntSTAttribute(_att_columns); 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", "table"); 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: tableType /** cache */ StringSTAttribute _att_tabletype = null; /** type of table. * controls content * @return CMLAttribute */ public CMLAttribute getTableTypeAttribute() { return (CMLAttribute) getAttribute("tableType"); } /** type of table. * controls content * @return String */ public String getTableType() { StringSTAttribute att = (StringSTAttribute) this.getTableTypeAttribute(); if (att == null) { return null; } return att.getString(); } /** type of table. * controls content * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setTableType(String value) throws RuntimeException { StringSTAttribute att = null; if (_att_tabletype == null) { _att_tabletype = (StringSTAttribute) attributeFactory.getAttribute("tableType", "table"); if (_att_tabletype == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : tableType probably incompatible attributeGroupName and attributeName"); } } att = new StringSTAttribute(_att_tabletype); 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", "table"); 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", "table"); 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", "table"); 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", "table"); 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: arrayList /** null * @param arrayList child to add */ public void addArrayList(AbstractArrayList arrayList) { arrayList.detach(); this.appendChild(arrayList); } /** null * @return CMLElements<CMLArrayList> */ public CMLElements getArrayListElements() { Elements elements = this.getChildElements("arrayList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: tableHeader /** null * @param tableHeader child to add */ public void addTableHeader(AbstractTableHeader tableHeader) { tableHeader.detach(); this.appendChild(tableHeader); } /** null * @return CMLElements<CMLTableHeader> */ public CMLElements getTableHeaderElements() { Elements elements = this.getChildElements("tableHeader", CMLConstants.CML_NS); return new CMLElements(elements); } // element: tableRowList /** null * @param tableRowList child to add */ public void addTableRowList(AbstractTableRowList tableRowList) { tableRowList.detach(); this.appendChild(tableRowList); } /** null * @return CMLElements<CMLTableRowList> */ public CMLElements getTableRowListElements() { Elements elements = this.getChildElements("tableRowList", CMLConstants.CML_NS); return new CMLElements(elements); } // element: tableContent /** null * @param tableContent child to add */ public void addTableContent(AbstractTableContent tableContent) { tableContent.detach(); this.appendChild(tableContent); } /** null * @return CMLElements<CMLTableContent> */ public CMLElements getTableContentElements() { Elements elements = this.getChildElements("tableContent", 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("rows")) { setRows(value); } else if (name.equals("columns")) { setColumns(value); } else if (name.equals("units")) { setUnits(value); } else if (name.equals("tableType")) { setTableType(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/AbstractTableCell.java000077500000000000000000000224701477224461000273530ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractTableCell extends CMLElement { /** local name*/ public final static String TAG = "tableCell"; /** constructor. */ public AbstractTableCell() { super("tableCell"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractTableCell(AbstractTableCell 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", "tableCell"); 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", "tableCell"); 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", "tableCell"); 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", "tableCell"); 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); } /** 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 { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractTableContent.java000077500000000000000000000267521477224461000301150ustar00rootroot00000000000000/** * 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.base.CMLAttribute; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractTableContent extends CMLElement { /** local name*/ public final static String TAG = "tableContent"; /** constructor. */ public AbstractTableContent() { super("tableContent"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractTableContent(AbstractTableContent 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", "tableContent"); 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", "tableContent"); 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: 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", "tableContent"); 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: 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", "tableContent"); 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", "tableContent"); 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); } StringSTAttribute _xmlContent; /** * * @return String */ public String getXMLContent() { String content = this.getValue(); if (_xmlContent == null) { _xmlContent = new StringSTAttribute("_xmlContent"); } _xmlContent.setCMLValue(content); 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("delimiter")) { setDelimiter(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/AbstractTableHeader.java000077500000000000000000000237671477224461000276760ustar00rootroot00000000000000/** * 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 AbstractTableHeader extends CMLElement { /** local name*/ public final static String TAG = "tableHeader"; /** constructor. */ public AbstractTableHeader() { super("tableHeader"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractTableHeader(AbstractTableHeader 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", "tableHeader"); 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", "tableHeader"); 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", "tableHeader"); 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", "tableHeader"); 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: tableHeaderCell /** null * @param tableHeaderCell child to add */ public void addTableHeaderCell(AbstractTableHeaderCell tableHeaderCell) { tableHeaderCell.detach(); this.appendChild(tableHeaderCell); } /** null * @return CMLElements<CMLTableHeaderCell> */ public CMLElements getTableHeaderCellElements() { Elements elements = this.getChildElements("tableHeaderCell", 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 { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractTableHeaderCell.java000077500000000000000000000467731477224461000305000ustar00rootroot00000000000000/** * 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.NamespaceRefAttribute; 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 AbstractTableHeaderCell extends CMLElement { /** local name*/ public final static String TAG = "tableHeaderCell"; /** constructor. */ public AbstractTableHeaderCell() { super("tableHeaderCell"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractTableHeaderCell(AbstractTableHeaderCell 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", "tableHeaderCell"); 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", "tableHeaderCell"); 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", "tableHeaderCell"); 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", "tableHeaderCell"); 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", "tableHeaderCell"); 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: 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", "tableHeaderCell"); 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: 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", "tableHeaderCell"); 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", "tableHeaderCell"); 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", "tableHeaderCell"); 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", "tableHeaderCell"); 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", "tableHeaderCell"); 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); } /** 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("units")) { setUnits(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/AbstractTableRow.java000077500000000000000000000236211477224461000272420ustar00rootroot00000000000000/** * 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 AbstractTableRow extends CMLElement { /** local name*/ public final static String TAG = "tableRow"; /** constructor. */ public AbstractTableRow() { super("tableRow"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractTableRow(AbstractTableRow 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", "tableRow"); 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", "tableRow"); 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", "tableRow"); 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", "tableRow"); 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: tableCell /** null * @param tableCell child to add */ public void addTableCell(AbstractTableCell tableCell) { tableCell.detach(); this.appendChild(tableCell); } /** null * @return CMLElements<CMLTableCell> */ public CMLElements getTableCellElements() { Elements elements = this.getChildElements("tableCell", 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 { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractTableRowList.java000077500000000000000000000236551477224461000301050ustar00rootroot00000000000000/** * 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 AbstractTableRowList extends CMLElement { /** local name*/ public final static String TAG = "tableRowList"; /** constructor. */ public AbstractTableRowList() { super("tableRowList"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractTableRowList(AbstractTableRowList 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", "tableRowList"); 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", "tableRowList"); 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", "tableRowList"); 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", "tableRowList"); 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: tableRow /** null * @param tableRow child to add */ public void addTableRow(AbstractTableRow tableRow) { tableRow.detach(); this.appendChild(tableRow); } /** null * @return CMLElements<CMLTableRow> */ public CMLElements getTableRowElements() { Elements elements = this.getChildElements("tableRow", 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 { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractTorsion.java000077500000000000000000000546001477224461000271610ustar00rootroot00000000000000/** * 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 AbstractTorsion extends CMLElement { /** local name*/ public final static String TAG = "torsion"; /** constructor. */ public AbstractTorsion() { super("torsion"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractTorsion(AbstractTorsion 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", "torsion"); 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", "torsion"); 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", "torsion"); 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", "torsion"); 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", "torsion"); 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", "torsion"); 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); } // 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", "torsion"); 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", "torsion"); 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", "torsion"); 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", "torsion"); 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", "torsion"); 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", "torsion"); 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", "torsion"); 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; /** The type of a torsion angle. * @return double */ public double getXMLContent() { String content = this.getValue(); if (_xmlContent == null) { _xmlContent = new DoubleSTAttribute("_xmlContent"); } _xmlContent.setCMLValue(content); return _xmlContent.getDouble(); } /** The type of a torsion angle. * @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); } /** The type of a torsion angle. * @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 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/AbstractTransform3.java000077500000000000000000000257331477224461000275670ustar00rootroot00000000000000/** * 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.DoubleArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractTransform3 extends CMLElement { /** local name*/ public final static String TAG = "transform3"; /** constructor. */ public AbstractTransform3() { super("transform3"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractTransform3(AbstractTransform3 old) { super((CMLElement) old); } // 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", "transform3"); 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", "transform3"); 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: 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", "transform3"); 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: 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", "transform3"); 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); } DoubleArraySTAttribute _xmlContent; /** A 4x4 transformation matrix * This is the base for extending the transform3 element. * * @return double[] */ public double[] getXMLContent() { String content = this.getValue(); if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(content); return _xmlContent.getDoubleArray(); } /** A 4x4 transformation matrix * This is the base for extending the transform3 element. * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(String value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(value); String attval = _xmlContent.getValue(); this.removeChildren(); this.appendChild(attval); } /** A 4x4 transformation matrix * This is the base for extending the transform3 element. * * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(double[] value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_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("convention")) { setConvention(value); } else if (name.equals("dictRef")) { setDictRef(value); } else if (name.equals("id")) { setId(value); } else if (name.equals("title")) { setTitle(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractTransitionState.java000077500000000000000000000247461477224461000306670ustar00rootroot00000000000000/** * 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 AbstractTransitionState extends CMLElement { /** local name*/ public final static String TAG = "transitionState"; /** constructor. */ public AbstractTransitionState() { super("transitionState"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractTransitionState(AbstractTransitionState 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", "transitionState"); 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", "transitionState"); 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", "transitionState"); 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", "transitionState"); 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: propertyList /** null * @param propertyList child to add */ public void addPropertyList(AbstractPropertyList propertyList) { propertyList.detach(); this.appendChild(propertyList); } /** null * @return CMLElements<CMLPropertyList> */ public CMLElements getPropertyListElements() { Elements elements = this.getChildElements("propertyList", 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 { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractVector3.java000077500000000000000000000301221477224461000270420ustar00rootroot00000000000000/** * 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.DoubleArraySTAttribute; import org.xmlcml.cml.base.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractVector3 extends CMLElement { /** local name*/ public final static String TAG = "vector3"; /** constructor. */ public AbstractVector3() { super("vector3"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractVector3(AbstractVector3 old) { super((CMLElement) old); } // 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", "vector3"); 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", "vector3"); 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: 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", "vector3"); 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: 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", "vector3"); 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: 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", "vector3"); 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); } DoubleArraySTAttribute _xmlContent; /** A vector in 3-space. * No constraints on magnitude (i.e. could be zero. * @return double[] */ public double[] getXMLContent() { String content = this.getValue(); if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(content); return _xmlContent.getDoubleArray(); } /** A vector in 3-space. * No constraints on magnitude (i.e. could be zero. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(String value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_xmlContent"); } _xmlContent.setCMLValue(value); String attval = _xmlContent.getValue(); this.removeChildren(); this.appendChild(attval); } /** A vector in 3-space. * No constraints on magnitude (i.e. could be zero. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setXMLContent(double[] value) throws RuntimeException { if (_xmlContent == null) { _xmlContent = new DoubleArraySTAttribute("_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("convention")) { setConvention(value); } else if (name.equals("dictRef")) { setDictRef(value); } else if (name.equals("id")) { setId(value); } else if (name.equals("title")) { setTitle(value); } else if (name.equals("units")) { setUnits(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractXaxis.java000077500000000000000000000412221477224461000266140ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractXaxis extends CMLElement { /** local name*/ public final static String TAG = "xaxis"; /** constructor. */ public AbstractXaxis() { super("xaxis"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractXaxis(AbstractXaxis 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", "xaxis"); 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", "xaxis"); 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", "xaxis"); 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", "xaxis"); 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", "xaxis"); 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: multiplierToData /** cache */ DoubleSTAttribute _att_multipliertodata = null; /** The scale by which to multiply raw data or a unit. * The scale is applied *before* adding any constant. * The attribute may be found on a data item (scalar, array, matrix, etc.) or * a user-defined unit. * @return CMLAttribute */ public CMLAttribute getMultiplierToDataAttribute() { return (CMLAttribute) getAttribute("multiplierToData"); } /** The scale by which to multiply raw data or a unit. * The scale is applied *before* adding any constant. * The attribute may be found on a data item (scalar, array, matrix, etc.) or * a user-defined unit. * @return double */ public double getMultiplierToData() { DoubleSTAttribute att = (DoubleSTAttribute) this.getMultiplierToDataAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** The scale by which to multiply raw data or a unit. * The scale is applied *before* adding any constant. * The attribute may be found on a data item (scalar, array, matrix, etc.) or * a user-defined unit. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMultiplierToData(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_multipliertodata == null) { _att_multipliertodata = (DoubleSTAttribute) attributeFactory.getAttribute("multiplierToData", "xaxis"); if (_att_multipliertodata == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : multiplierToData probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_multipliertodata); super.addRemove(att, value); } /** The scale by which to multiply raw data or a unit. * The scale is applied *before* adding any constant. * The attribute may be found on a data item (scalar, array, matrix, etc.) or * a user-defined unit. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMultiplierToData(double value) throws RuntimeException { if (_att_multipliertodata == null) { _att_multipliertodata = (DoubleSTAttribute) attributeFactory.getAttribute("multiplierToData", "xaxis"); if (_att_multipliertodata == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : multiplierToData probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_multipliertodata); super.addAttribute(att); att.setCMLValue(value); } // attribute: constantToData /** cache */ DoubleSTAttribute _att_constanttodata = null; /** The constant to add to the raw data. * add *after* applying any multiplier. * @return CMLAttribute */ public CMLAttribute getConstantToDataAttribute() { return (CMLAttribute) getAttribute("constantToData"); } /** The constant to add to the raw data. * add *after* applying any multiplier. * @return double */ public double getConstantToData() { DoubleSTAttribute att = (DoubleSTAttribute) this.getConstantToDataAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** The constant to add to the raw data. * add *after* applying any multiplier. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setConstantToData(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_constanttodata == null) { _att_constanttodata = (DoubleSTAttribute) attributeFactory.getAttribute("constantToData", "xaxis"); if (_att_constanttodata == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : constantToData probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_constanttodata); super.addRemove(att, value); } /** The constant to add to the raw data. * add *after* applying any multiplier. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setConstantToData(double value) throws RuntimeException { if (_att_constanttodata == null) { _att_constanttodata = (DoubleSTAttribute) attributeFactory.getAttribute("constantToData", "xaxis"); if (_att_constanttodata == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : constantToData probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_constanttodata); super.addAttribute(att); att.setCMLValue(value); } // element: array /** The constant to add to the raw data. * add *after* applying any multiplier. * @param array child to add */ public void addArray(AbstractArray array) { array.detach(); this.appendChild(array); } /** The constant to add to the raw data. * add *after* applying any multiplier. * @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("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 if (name.equals("multiplierToData")) { setMultiplierToData(value); } else if (name.equals("constantToData")) { setConstantToData(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractYaxis.java000077500000000000000000000412221477224461000266150ustar00rootroot00000000000000/** * 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.StringSTAttribute; // end of part 1 /** CLASS DOCUMENTATION */ public abstract class AbstractYaxis extends CMLElement { /** local name*/ public final static String TAG = "yaxis"; /** constructor. */ public AbstractYaxis() { super("yaxis"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractYaxis(AbstractYaxis 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", "yaxis"); 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", "yaxis"); 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", "yaxis"); 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", "yaxis"); 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", "yaxis"); 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: multiplierToData /** cache */ DoubleSTAttribute _att_multipliertodata = null; /** The scale by which to multiply raw data or a unit. * The scale is applied *before* adding any constant. * The attribute may be found on a data item (scalar, array, matrix, etc.) or * a user-defined unit. * @return CMLAttribute */ public CMLAttribute getMultiplierToDataAttribute() { return (CMLAttribute) getAttribute("multiplierToData"); } /** The scale by which to multiply raw data or a unit. * The scale is applied *before* adding any constant. * The attribute may be found on a data item (scalar, array, matrix, etc.) or * a user-defined unit. * @return double */ public double getMultiplierToData() { DoubleSTAttribute att = (DoubleSTAttribute) this.getMultiplierToDataAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** The scale by which to multiply raw data or a unit. * The scale is applied *before* adding any constant. * The attribute may be found on a data item (scalar, array, matrix, etc.) or * a user-defined unit. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMultiplierToData(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_multipliertodata == null) { _att_multipliertodata = (DoubleSTAttribute) attributeFactory.getAttribute("multiplierToData", "yaxis"); if (_att_multipliertodata == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : multiplierToData probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_multipliertodata); super.addRemove(att, value); } /** The scale by which to multiply raw data or a unit. * The scale is applied *before* adding any constant. * The attribute may be found on a data item (scalar, array, matrix, etc.) or * a user-defined unit. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setMultiplierToData(double value) throws RuntimeException { if (_att_multipliertodata == null) { _att_multipliertodata = (DoubleSTAttribute) attributeFactory.getAttribute("multiplierToData", "yaxis"); if (_att_multipliertodata == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : multiplierToData probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_multipliertodata); super.addAttribute(att); att.setCMLValue(value); } // attribute: constantToData /** cache */ DoubleSTAttribute _att_constanttodata = null; /** The constant to add to the raw data. * add *after* applying any multiplier. * @return CMLAttribute */ public CMLAttribute getConstantToDataAttribute() { return (CMLAttribute) getAttribute("constantToData"); } /** The constant to add to the raw data. * add *after* applying any multiplier. * @return double */ public double getConstantToData() { DoubleSTAttribute att = (DoubleSTAttribute) this.getConstantToDataAttribute(); if (att == null) { return Double.NaN; } return att.getDouble(); } /** The constant to add to the raw data. * add *after* applying any multiplier. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setConstantToData(String value) throws RuntimeException { DoubleSTAttribute att = null; if (_att_constanttodata == null) { _att_constanttodata = (DoubleSTAttribute) attributeFactory.getAttribute("constantToData", "yaxis"); if (_att_constanttodata == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : constantToData probably incompatible attributeGroupName and attributeName"); } } att = new DoubleSTAttribute(_att_constanttodata); super.addRemove(att, value); } /** The constant to add to the raw data. * add *after* applying any multiplier. * @param value title value * @throws RuntimeException attribute wrong value/type */ public void setConstantToData(double value) throws RuntimeException { if (_att_constanttodata == null) { _att_constanttodata = (DoubleSTAttribute) attributeFactory.getAttribute("constantToData", "yaxis"); if (_att_constanttodata == null) { throw new RuntimeException("BUG: cannot process attributeGroupName : constantToData probably incompatible attributeGroupName and attributeName "); } } DoubleSTAttribute att = new DoubleSTAttribute(_att_constanttodata); super.addAttribute(att); att.setCMLValue(value); } // element: array /** The constant to add to the raw data. * add *after* applying any multiplier. * @param array child to add */ public void addArray(AbstractArray array) { array.detach(); this.appendChild(array); } /** The constant to add to the raw data. * add *after* applying any multiplier. * @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("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 if (name.equals("multiplierToData")) { setMultiplierToData(value); } else if (name.equals("constantToData")) { setConstantToData(value); } else { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/AbstractZMatrix.java000077500000000000000000000254111477224461000271200ustar00rootroot00000000000000/** * 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 AbstractZMatrix extends CMLElement { /** local name*/ public final static String TAG = "zMatrix"; /** constructor. */ public AbstractZMatrix() { super("zMatrix"); } /** copy constructor. * deep copy using XOM copy() * @param old element to copy */ public AbstractZMatrix(AbstractZMatrix 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", "zMatrix"); 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", "zMatrix"); 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", "zMatrix"); 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", "zMatrix"); 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: length /** null * @param length child to add */ public void addLength(AbstractLength length) { length.detach(); this.appendChild(length); } /** null * @return CMLElements<CMLLength> */ public CMLElements getLengthElements() { Elements elements = this.getChildElements("length", CMLConstants.CML_NS); return new CMLElements(elements); } // element: angle /** null * @param angle child to add */ public void addAngle(AbstractAngle angle) { angle.detach(); this.appendChild(angle); } /** null * @return CMLElements<CMLAngle> */ public CMLElements getAngleElements() { Elements elements = this.getChildElements("angle", CMLConstants.CML_NS); return new CMLElements(elements); } // element: torsion /** null * @param torsion child to add */ public void addTorsion(AbstractTorsion torsion) { torsion.detach(); this.appendChild(torsion); } /** null * @return CMLElements<CMLTorsion> */ public CMLElements getTorsionElements() { Elements elements = this.getChildElements("torsion", 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 { super.addAttribute(att); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLAbundance.java000077500000000000000000000036131477224461000262520ustar00rootroot00000000000000/** * 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 org.xmlcml.cml.base.CMLElement; import nu.xom.Element; /** * The abundance of an isotope. * * * The abundance of an isotope in an isotopeList. Values are expressed in * percentages. user-modifiable class autogenerated from schema use as a shell * which can be edited * */ public class CMLAbundance extends AbstractAbundance { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLAbundance() { } /** * constructor. * * @param old */ public CMLAbundance(CMLAbundance old) { super((AbstractAbundance) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLAbundance(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLAbundance */ public CMLElement makeElementInContext(Element parent) { return new CMLAbundance(); } /* ======AUTOGENERATED FROM SCHEMA; DO NOT EDIT BELOW THIS LINE ====== */ } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLAction.java000077500000000000000000000031551477224461000256100ustar00rootroot00000000000000/** * 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 org.xmlcml.cml.base.CMLElement; import nu.xom.Element; /** * user-modifiable class supporting action. * autogenerated from schema use as a * shell which can be edited * */ public class CMLAction extends AbstractAction { /** * constructor. */ public CMLAction() { } /** * constructor. * * @param old */ public CMLAction(CMLAction old) { super((AbstractAction) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLAction(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLAction */ public CMLElement makeElementInContext(Element parent) { return new CMLAction(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLActionList.java000077500000000000000000000032231477224461000264400ustar00rootroot00000000000000/** * 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 org.xmlcml.cml.base.CMLElement; import nu.xom.Element; /** * user-modifiable class supporting actionList. * autogenerated from schema use * as a shell which can be edited * */ public class CMLActionList extends AbstractActionList { /** * constructor. */ public CMLActionList() { } /** * constructor. * * @param old */ public CMLActionList(CMLActionList old) { super((AbstractActionList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLActionList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLActionList */ public CMLElement makeElementInContext(Element parent) { return new CMLActionList(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLAmount.java000077500000000000000000000033251477224461000256350ustar00rootroot00000000000000/** * 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 org.xmlcml.cml.base.CMLElement; import nu.xom.Element; /** * user-modifiable class supporting amount. * autogenerated from schema use as a * shell which can be edited * */ public class CMLAmount extends AbstractAmount { /** mass, volume */ public enum Type { /** mass */ MASS, /** volume */ VOLUME; } /** * constructor. */ public CMLAmount() { } /** * constructor. * * @param old */ public CMLAmount(CMLAmount old) { super((AbstractAmount) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLAmount(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLAmount */ public CMLElement makeElementInContext(Element parent) { return new CMLAmount(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLAngle.java000077500000000000000000000243221477224461000254200ustar00rootroot00000000000000/** * 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 java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.euclid.Angle; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Util; import nu.xom.Element; import nu.xom.Nodes; /** * user-modifiable class supporting angle. */ public class CMLAngle extends AbstractAngle { private static Logger LOG = Logger.getLogger(CMLAngle.class); static { LOG.setLevel(Level.DEBUG); } /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLAngle() { } /** * constructor. * * @param old */ public CMLAngle(CMLAngle old) { super((AbstractAngle) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLAngle(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLAngle */ public CMLElement makeElementInContext(Element parent) { return new CMLAngle(); } /** * gets atomIds as list. * * @return the atomIds (null if no atomRefs3) */ public List getAtomIds() { List idList = null; String[] atomRefs3 = getAtomRefs3(); if (atomRefs3 != null) { idList = new ArrayList(); for (String s : atomRefs3) { idList.add(s); } } return idList; } /** * gets atoms as array of atoms. * * @param molecule * @return the atoms (null if no atomRefs3) */ public List getAtoms(CMLMolecule molecule) { List atomList = new ArrayList(); for (String atomRef : getAtomRefs3()) { CMLAtom atom = molecule.getAtomById(atomRef); if (atom == null) { throw new RuntimeException("cannot find atom: "+atomRef); } if (atomList.contains(atom)) { throw new RuntimeException("duplicate atom in angle: "+atomRef); } atomList.add(atom); } return atomList; } /** * gets value calculated from coordinates. requires atomRefs3 ro be set and * valid. then gets the angle between atomRefs3 0-1-2 * * @param molecule * owning molecule (all atoms must be in this) * @return the angle in degrees (NaN if cannot calculate) */ public double getCalculatedAngle(CMLMolecule molecule) { List atomList = this.getAtoms(molecule); return this.getCalculatedAngle(atomList); } /** * Finds ancestral molecule and then uses getCalculatedAngle(CMLMolecule) * * @return the angle in degrees (null if cannot calculate) */ public Double getCalculatedAngle() { CMLMolecule molecule = CMLMolecule.getAncestorMolecule(this); return (molecule == null) ? null : getCalculatedAngle(molecule); } /** * Finds ancestral molecule and then uses getCalculatedAngle(CMLMolecule) * * @return the angle in degrees (null if cannot calculate) */ public Double getCalculatedAngle(String units) { Double ang = getCalculatedAngle(); // degrees if (Angle.Units.RADIANS.toString().equals(units)) { ang /= Angle.DEGREES_IN_RADIAN; } return ang; } /** * gets value calculated from coordinates. requires atomRefs3 to be set and * valid. then gets the angle between atomRefs3 0-1-2 * * @param atomList * @return the angle in degrees (NaN if cannot calculate) */ public double getCalculatedAngle(List atomList) { double calculatedAngle = Double.NaN; if (atomList != null) { if (atomList.size() != 3) { throw new RuntimeException("angle requires 3 atoms"); } Point3[] coord = new Point3[3]; int i = 0; for (CMLAtom atom : atomList) { coord[i] = atom.getXYZ3(); if (coord[i++] == null) { break; } } try { Angle angle = Point3.getAngle(coord[0], coord[1], coord[2]); if (angle != null) { calculatedAngle = angle.getDegrees(); } } catch (Exception e) { throw new RuntimeException("Bug: " + e); } } return calculatedAngle; } /** create key from atomRefs3 attribute and atomHash * * @return the hash null if no atomRefs3 */ public String atomHash() { String[] a = this.getAtomRefs3(); return (a == null) ? null : atomHash(a[0], a[1], a[2]); } /** * create key from three atoms. a1-a2-a3 and a3-a2-a1 are equivalent * * @param atomId1 * @param atomId2 * @param atomId3 * @return the hash */ public static String atomHash(final String atomId1, final String atomId2, final String atomId3) { String result = null; if (!(atomId1 == null || atomId2 == null || atomId3 == null)) { String a1 = atomId1; String a3 = atomId3; if (atomId1.compareTo(atomId3) > 0) { a3 = atomId1; a1 = atomId3; } else if (atomId1.compareTo(atomId3) < 0) { a1 = atomId1; a3 = atomId3; } result = a1 + CMLBond.HASH_SYMB + atomId2 + CMLBond.HASH_SYMB + a3; } return result; } /** translates elements to list. * @param angleElements * @return the list of angles * @deprecated try to use List<CMLAngle> */ public static List getList(CMLElements angleElements) { List angleList = new ArrayList(); for (CMLAngle angle : angleElements) { angleList.add(angle); } return angleList; } /** * gets a Map of angles indexed by atoms. the map has the keys of atomHashs * for the angles * * @param angleList * list of the angles * @return the indexed table (keyed on atomHash) */ public static Map getIndexedAngles(List angleList) { Map angleTable = new HashMap(); for (CMLAngle angle : angleList) { String[] id = angle.getAtomRefs3(); String key = atomHash(id[0], id[1], id[2]); angleTable.put(key, angle); } return angleTable; } /** set atomRefs3 attribute. * * @param atom0 * @param atom1 * @param atom2 */ public void setAtomRefs3( CMLAtom atom0, CMLAtom atom1, CMLAtom atom2) { this.setAtomRefs3( new String[]{ atom0.getId(), atom1.getId(), atom2.getId() }); } /** writes angles to an XHTML table. * columns are atom1.label atom2.label atom3.label angle in deg * @param w writer to output * @param angleList * @param molecule * @throws IOException */ public static void outputHTML( Writer w, List angleList, CMLMolecule molecule) throws IOException { if (angleList.size() > 0) { w.write("\n"); w.write(""); w.write(""); w.write(""); w.write(""); w.write(""); w.write("\n"); for (CMLAngle angle : angleList) { List atoms = angle.getAtoms(molecule); w.write(""); for (int i = 0; i < 3; i++) { w.write(""); } String s = ""+angle.getXMLContent(); w.write(""); w.write("\n"); } w.write("
"); w.write("atom1 (id)"); w.write(""); w.write("atom2 (id)"); w.write(""); w.write("atom3 (id)"); w.write(""); w.write("angle"); w.write("
"); CMLAtom atom = atoms.get(i); Nodes labelNodes = atom.query( CMLScalar.NS+"[@dictRef='iucr:_atom_site_label']", CMLConstants.CML_XPATH); String label = ((CMLScalar) labelNodes.get(0)).getXMLContent()+" ("+atom.getId()+S_RBRAK; w.write( (label == null) ? atom.getId() : label); w.write(""+s.substring(0, Math.min(6, s.length()))+"
\n"); } } /** get string. * * @return the string */ public String getString() { String s = S_EMPTY; String[] a = getAtomRefs3(); if (a != null) { s += Util.concatenate(a, S_MINUS); } s += S_SPACE; s += this.getXMLContent(); return s; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLArg.java000077500000000000000000000535501477224461000251100ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import nu.xom.Attribute; import nu.xom.Element; import nu.xom.Elements; import nu.xom.Node; import nu.xom.Nodes; import nu.xom.Text; import org.xmlcml.cml.attribute.IdAttribute; import org.xmlcml.cml.attribute.RefAttribute; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLUtil; /** * user-modifiable class supporting arg. * There is a lot still being worked out. * Too many statics. * @author pm286 */ public class CMLArg extends AbstractArg { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** start of expandable argument. */ public final static String START_CHARS = CMLConstants.S_LCURLY+S_DOLLAR; /** end of expandable argument. */ public final static String END_CHARS = CMLConstants.S_RCURLY; /** * constructor. */ public CMLArg() { } /** create integer argument. * adds scalar child. * @param name of arg * @param i */ public CMLArg(String name, int i) { setInteger(i); this.setName(name); } /** create integer argument. * adds scalar child. * @param name of arg * @param s */ public CMLArg(String name, String s) { setString(s); this.setName(name); } /** * constructor. * * @param old */ public CMLArg(CMLArg old) { super((AbstractArg) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLArg(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLArg */ public CMLElement makeElementInContext(Element parent) { return new CMLArg(); } /** inserts arg child. * * @param parent to hold arg * @param arg to add * @param position to add att * @throws RuntimeException null args or bad position or duplicate argName */ public static void addArg(CMLElement parent, CMLArg arg, int position) throws RuntimeException { // checks Elements args = parent.getChildCMLElements(CMLArg.TAG); if (parent == null || arg == null || position < 0) { throw new RuntimeException("null args or negative position"); } if (position > args.size()) { throw new RuntimeException("position > argCount"); } String argName = arg.getName(); for (int i = 0; i < args.size(); i++) { String name = ((CMLArg)args.get(i)).getName(); if (name == null || name.trim().equals(S_EMPTY)) { throw new RuntimeException("missing name in arg: "); } if (name.equals(argName)) { throw new RuntimeException("duplicate arg: "+argName); } } // OK, insert arg parent.insertChild(arg, position); } /** remove all arg childern from element. * * @param element to remove args from */ public static void removeArgs(CMLElement element) { if (element != null) { List args = CMLUtil.getQueryNodes(element, CMLArg.NS, CMLConstants.CML_XPATH); for (Node arg : args) { arg.detach(); } } } /** substitute arg name by symbol. * currently uses _ij_ to represent value of ij. * routine recursively descends tree and substitutes all attribute values * @param element to edit */ public static void substituteNameByValue(CMLElement element) { CMLArg.substituteNameByValue(element, new ArrayList()); } /** transfers args from one element to another. * if an arg of name ijk exists on element and toElem * it is copied from fromElem to toElem * @param fromElem * @param toElem * @exception RuntimeException bad args */ public static void transferArgs(CMLElement fromElem, CMLElement toElem) throws RuntimeException { List fromList = CMLArg.getArgs(fromElem); List toList = CMLArg.getArgs(toElem); for (CMLArg fromArg : fromList) { String fromName = fromArg.getName(); if (fromName == null) { throw new RuntimeException("missing name in arg"); } for (CMLArg toArg : toList) { String toName = toArg.getName(); if (toName == null) { throw new RuntimeException("missing name in arg"); } if (fromName.equals(toName)) { CMLArg copyFromArg = (CMLArg) fromArg.copy(); int idx = toElem.indexOf(toArg); if (idx < 0) { throw new RuntimeException("BUG idx < 0"); } toElem.insertChild(copyFromArg, idx); toArg.detach(); break; } } } } /** gets args from element. * * @param element * @return list of args (empty if none) */ private static List getArgs(CMLElement element) { List argList = new ArrayList(); Elements args = element.getChildCMLElements(CMLArg.TAG); for (int i = 0; i < args.size(); i++) { argList.add((CMLArg) args.get(i)); } return argList; } /** substitute arg name by symbol. * currently uses _ij_ to represent value of ij. * routine recursively descends tree and substitutes all attribute values * @param element to edit * @param oldArgList list of args */ public static void substituteNameByValue(CMLElement element, List oldArgList) { Elements args = element.getChildCMLElements(CMLArg.TAG); // create list of active args List newArgList = new ArrayList(); // add child args to list for (int i = 0; i < args.size(); i++) { newArgList.add((CMLArg) args.get(i)); } // add old ones that are not overridden for (CMLArg oldArg : oldArgList) { boolean overridden = false; for (int i = 0; i < args.size(); i++) { CMLArg arg = (CMLArg) args.get(i); if (oldArg.getName().equals(arg.getName())) { overridden = true; break; } } if (!overridden) { newArgList.add(oldArg); } } // self substitute in args (only eval at present) for (CMLArg newArg : newArgList) { newArg.eval(newArgList); } // now process the attributes of element for (CMLArg newArg : newArgList) { if (newArg.getSubstituteAttribute() != null) { newArg.substituteAttributes(element); if (newArg.getDeleteAttribute() != null) { newArg.detach(); } } } // proceed to children Elements elements = element.getChildElements(); for (int j = 0; j < elements.size(); j++) { Element childElement = elements.get(j); if (childElement instanceof CMLElement) { CMLElement childCMLElement = (CMLElement) childElement; // skip other args of if (childCMLElement.getLocalName().equals(CMLArg.TAG)) { } else { CMLArg.substituteNameByValue(childCMLElement, newArgList); } } } } private void substituteAttributes(Element element) { // make a copy of attribute lists as we are resetting them int attCount = element.getAttributeCount(); List attList = new ArrayList(); for (int j = 0; j < attCount; j++) { Attribute att = element.getAttribute(j); attList.add(att); } for (Attribute att : attList) { this.substituteNameByValue(att); } } void substituteNameByValue(Attribute att) { // do not substitute refs if (att instanceof RefAttribute) { } else { String value = att.getValue(); String value1 = value; String newValue = this.getValue().trim(); if (!newValue.equals(S_EMPTY)) { value1 = value1.replaceAll(S_UNDER+this.getName()+S_UNDER, newValue); if (!value.equals(value1)) { Element parent = (Element) att.getParent(); // remove attribute so as not to triffer reset error parent.removeAttribute(parent.getAttribute(att.getLocalName())); att.setValue(value1); parent.addAttribute(att); } else { } } } } /** get dataType. * if null sets value to dataType of child scalar; * if scalar is null set to xsd:string * @return the dataType */ public String getDataType() { String dataType = super.getDataType(); if (dataType == null) { CMLScalar scalar = this.getScalar(); if (scalar != null) { dataType = scalar.getDataType(); } } if (dataType == null) { dataType = XSD_STRING; this.setDataType(XSD_STRING); } return dataType; } /** substitutes and evaluates all eval attributes. * * @param argList */ public void eval(List argList) { Attribute eval = this.getEvalAttribute(); if (eval != null) { for (CMLArg arg : argList) { arg.substituteNameByValue(eval); } String value = eval.getValue().trim(); if (this.getDataType().equals(XSD_STRING)) { } else { value = value.replace(S_PLUS, CMLConstants.S_SPACE+S_PLUS+S_SPACE); value = value.replace(S_MINUS, CMLConstants.S_SPACE+S_MINUS+S_SPACE); String[] tokens = value.trim().split("\\s+"); if (tokens.length % 2 != 1) { throw new RuntimeException("bad eval for numeric data: "+value); } if (this.getDataType().equals(XSD_DOUBLE)) { try { double dd = Double.valueOf(tokens[0]).doubleValue(); String op = CMLConstants.S_EMPTY; for (int i = 1; i < tokens.length; i+=2) { op = tokens[i]; double d = Double.valueOf(tokens[i+1]).doubleValue(); if (op.equals(S_PLUS)) { dd += d; } else if (op.equals(S_MINUS)) { dd -= d; } else { throw new RuntimeException("Bad operator: ("+op+") in eval: "+value); } } this.setDouble(dd); } catch (NumberFormatException e) { throw new RuntimeException("Bad numeric double eval: "+value); } } else if (this.getDataType().equals(XSD_INTEGER)) { try { int jj = Integer.parseInt(tokens[0]); String op = CMLConstants.S_EMPTY; for (int i = 1; i < tokens.length; i+=2) { op = tokens[i]; int j = Integer.parseInt(tokens[i+1]); if (op.equals(S_PLUS)) { jj += j; } else if (op.equals(S_MINUS)) { jj -= j; } else { throw new RuntimeException("Bad operator: ("+op+") in eval: "+value); } } this.setInteger(jj); } catch (NumberFormatException e) { throw new RuntimeException("Bad numeric integer eval: "+value); } } } } Attribute evalx = this.getEvalAttribute(); if (evalx != null) { evalx.detach(); } } /** gets the integer value. * requires a child scalar of dataType xsd:integer * @return integer value * @throws RuntimeException if no integer scalar */ public int getInteger() throws RuntimeException { CMLScalar scalar = getScalar(); if (scalar == null) { throw new RuntimeException("no child scalar"); } return scalar.getInt(); } /** sets integer value. * creates scalar if necessary * @param i * @throws RuntimeException */ public void setInteger(int i) throws RuntimeException { CMLScalar scalar = (CMLScalar) this.getChildCMLElement(CMLScalar.TAG, 0); if (scalar == null) { scalar = new CMLScalar(i); this.appendChild(scalar); } else { scalar.setValue(i); } } /** gets the string value. * requires a child scalar of dataType xsd:string * @return string value * @throws RuntimeException if no string scalar */ public String getString() throws RuntimeException { String string = null; CMLScalar scalar = getScalar(); if (scalar != null) { string = scalar.getXMLContent(); } else { string = this.getValue(); } return string; } /** sets string value. * creates scalar if necessary * @param s * @throws RuntimeException */ public void setString(String s) throws RuntimeException { CMLScalar scalar = (CMLScalar) this.getChildCMLElement(CMLScalar.TAG, 0); if (scalar == null) { scalar = new CMLScalar(s); this.appendChild(scalar); } else { scalar.setXMLContent(s); } } /** gets the double value. * requires a child scalar of dataType xsd:double * @return double value * @throws RuntimeException if no double scalar */ public double getDouble() throws RuntimeException { CMLScalar scalar = getScalar(); if (scalar == null) { throw new RuntimeException("no child scalar"); } return scalar.getDouble(); } /** sets double value. * creates scalar if necessary * @param d * @throws RuntimeException */ public void setDouble(double d) throws RuntimeException { CMLScalar scalar = (CMLScalar) this.getChildCMLElement(CMLScalar.TAG, 0); if (scalar == null) { scalar = new CMLScalar(d); } else { scalar.setValue(d); } this.appendChild(scalar); } /** get the first child scalar if any. * * @return the scalar */ public CMLScalar getScalar() { Elements scalars = this.getChildCMLElements(CMLScalar.TAG); return (scalars == null || scalars.size() == 0) ? null : (CMLScalar) scalars.get(0); } /** process all instances of arg in element. *TODO currently doesn't do anything * @param element */ public static void processArgs(CMLElement element) { Nodes parameterNameArgs = element.query(CMLArg.NS+"[@parameterName]", CMLConstants.CML_XPATH); for (int i = 0; i < parameterNameArgs.size(); i++) { @SuppressWarnings("unused") CMLArg arg = (CMLArg) parameterNameArgs.get(i); } } /** substitute parameter value through element. * * @param element to edit * @param name of arg (must occur as arg in element) * @param value of arg */ public static void substituteParameterName( CMLElement element, String name, String value) { String id = element.getAttributeValue(IdAttribute.NAME); CMLArg parameterArg = null; Nodes nameArgs = element.query(CMLArg.NS+"[@parameterName='"+name+"']", CMLConstants.CML_XPATH); if (nameArgs.size() == 0) { element.debug("ARG NOT FOUND"); throw new RuntimeException("arg not found: "+name+S_SLASH+id); } else if (nameArgs.size() > 1) { throw new RuntimeException("duplicate args: "+name+S_SLASH+id); } else { parameterArg = (CMLArg) nameArgs.get(0); } // replace {$xyz} String orig = START_CHARS+name+END_CHARS; Nodes nodes = element.query(".//@* | .//text()"); for (int i = 0; i < nodes.size(); i++) { Node node = nodes.get(i); String val = node.getValue(); if (val.indexOf(orig) != -1) { val = val.replace(orig, value); if (node instanceof Attribute) { ((Attribute)node).setValue(val); } else if (node instanceof Text) { ((Text)node).setValue(val); } else { throw new RuntimeException("BUG "+node.getClass()); } } } // remove arg parameterArg.detach(); } /** process all arg/@parentAttribute in element. * * @param element to edit */ public static void substituteParentAttributes(CMLElement element) { Nodes parentAttributeArgs = element.query(".//"+CMLArg.NS+"[@parentAttribute]", CMLConstants.CML_XPATH); for (int i = 0; i < parentAttributeArgs.size(); i++) { CMLArg parentAttributeArg = (CMLArg) parentAttributeArgs.get(i); String parentAttribute = parentAttributeArg.getParentAttribute(); String attValue = parentAttributeArg.getString(); Element parent = (Element) parentAttributeArg.getParent(); ((CMLElement)parent).setAttribute(parentAttribute, attValue); // parent.addAttribute(new Attribute(parentAttribute, attValue)); parentAttributeArg.detach(); } } /** process all arg/@substitute in element. * * @param element to edit */ public static void substituteTextContent(CMLElement element) { Nodes textContentArgs = element.query(".//"+CMLArg.NS+"[@substitute[.='.']]", CMLConstants.CML_XPATH); for (int i = 0; i < textContentArgs.size(); i++) { CMLArg textContentArg = (CMLArg) textContentArgs.get(i); String value = textContentArg.getValue(); if (value.startsWith(START_CHARS) && value.endsWith(END_CHARS)) { // unsubstituted arg } else { Element parent = (Element) textContentArg.getParent(); parent.appendChild(new Text(value)); } textContentArg.detach(); } } /** apply arg to element. * if this/@parentAttribute[.='foo'], add foo attribute with * value of arg * @param element */ public void processArg(CMLElement element) { if (this.getParentAttribute() != null) { String parentAttribute = this.getParentAttribute(); String value = this.getString(); Element parent = (Element) this.getParent(); parent.addAttribute(new Attribute(parentAttribute, value)); this.detach(); } } /** add arguments to descendant elements. * descendants mut have @ref. * * @param current context for search * @param localName of element to search for */ public static void addIdxArgsWithSerialNumber(CMLElement current, String localName) { Nodes nodes = current.query(".//"+C_E+localName+"[@ref]", CMLConstants.CML_XPATH); Set idSet = new HashSet(); for (int i = 0; i < nodes.size(); i++) { CMLElement element = (CMLElement) nodes.get(i); String serial = CMLConstants.S_EMPTY+(i+1); String id = element.getAttributeValue(IdAttribute.NAME); if (id == null) { id = CMLConstants.S_EMPTY+serial; } else { id += CMLConstants.S_UNDER+serial; if (idSet.contains(id)) { throw new RuntimeException("Non-unique element id: "+id); } } element.addAttribute(new Attribute(IdAttribute.NAME, id)); idSet.add(id); CMLArg arg = new CMLArg("idx", serial); element.appendChild(arg); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLArray.java000077500000000000000000001001761477224461000254520ustar00rootroot00000000000000/** * 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 java.text.ParseException; import java.util.ArrayList; import java.util.List; import nu.xom.Attribute; import nu.xom.Element; import org.apache.log4j.Logger; import org.joda.time.DateTime; import org.xmlcml.cml.attribute.DelimiterAttribute; import org.xmlcml.cml.attribute.DelimiterAttribute.Action; import org.xmlcml.cml.attribute.NamespaceRefAttribute; import org.xmlcml.cml.base.CMLAttribute; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLType; import org.xmlcml.cml.interfacex.HasArraySize; import org.xmlcml.cml.interfacex.HasDataType; import org.xmlcml.cml.interfacex.HasDelimiter; import org.xmlcml.cml.interfacex.HasDictRef; import org.xmlcml.cml.interfacex.HasUnits; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.IntArray; import org.xmlcml.euclid.JodaDate; import org.xmlcml.euclid.RealArray; import org.xmlcml.euclid.Util; /** * user-modifiable class supporting array. * autogenerated from schema use as a * shell which can be edited * */ public class CMLArray extends AbstractArray implements HasUnits, HasArraySize, HasDataType, HasDictRef, HasDelimiter { static Logger logger = Logger.getLogger(CMLArray.class); /** namespaced element name. */ public final static String NS = C_E + TAG; private DelimiterAttribute delimiterAttribute = null; /** * constructor. */ public CMLArray() { init(); } private void init() { // ensureDelimiterAttribute(Action.RESET); } /** * constructor. * * @param old */ public CMLArray(CMLArray old) { super((AbstractArray) old); init(); } /** * copy node . * * @return Node */ @Override public Element copy() { return new CMLArray(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLArray */ @Override public CMLElement makeElementInContext(Element parent) { return new CMLArray(); } /** * check array is OK. * * @param parent * element */ @Override public void finishMakingElement(Element parent) { delimiterAttribute = null; delimiterAttribute = (DelimiterAttribute) this.getDelimiterAttribute(); int ll = -1; int size = -1; if (this.getSizeAttribute() != null) { String aa = super.getAttributeValue("size"); size = Integer.parseInt(aa); } String dataType = this.getDataType(); if (dataType.equals(XSD_STRING)) { String[] ss = this.getStrings(); ll = ss.length; } else if (XSD_DOUBLE.equals(CMLType.getNormalizedValue(dataType))) { try { double[] ss = this.getDoubles(); ll = ss.length; } catch (RuntimeException e) { throw new RuntimeException("Fault in XML: " + this.getXMLContent(), e); } } else if (dataType.equals(XSD_INTEGER)) { try { int[] ss = this.getInts(); ll = ss.length; } catch (RuntimeException e) { throw new RuntimeException("cannot parse as ints: " + this.getXMLContent()); } } else if (dataType.equals(CML_DATATYPETYPE)) { String[] ss = this.getStrings(); ll = ss.length; } else if (dataType.equals(CML_NAMESPACEREFTYPE)) { String[] ss = this.getStrings(); ll = ss.length; } else if (dataType.equals(CML_UNITSTYPE)) { String[] ss = this.getStrings(); ll = ss.length; } else { throw new RuntimeException("array does not support dataType: " + dataType); } if (size != -1 && ll != size) { throw new RuntimeException("Size attribute: " + size + " incompatible with content: " + ll); } if (size != -1) { this.resetSize(ll); } else { this.removeAttribute("size"); } } public void ensureDelimiterAttribute(Action action) { if (action.equals(Action.RESET)) { delimiterAttribute = null; } delimiterAttribute = (DelimiterAttribute) this.getDelimiterAttribute(); if (delimiterAttribute == null) { delimiterAttribute = new DelimiterAttribute(S_SPACE); super.setDelimiter(S_SPACE); } } /** * get delimiter attribute if the delimiter is whitespace this should return * null * * @return attribute */ @Override public CMLAttribute getDelimiterAttribute() { delimiterAttribute = (DelimiterAttribute) super.getDelimiterAttribute(); return delimiterAttribute; } // =========================== additional constructors // ======================== /** * formed from components. size is extracted from array dimensions sets * dataType to xsd:string cannot use default delimiter (S_SPACE) if strings * contain whitespace, so choose another delimiter * * @param array * @throws RuntimeException * strings must not contain whitespace */ public CMLArray(String[] array) throws RuntimeException { this.setArray(array); } /** * formed from components. size is extracted from array dimensions sets * dataType to xsd:string cannot use delimiter if strings contain it, so * choose another delimiter * * @param array * @param delimiter * @throws RuntimeException * strings must not contain delimiter */ public CMLArray(String[] array, String delimiter) throws RuntimeException { setDelimiter(delimiter); this.setArray(array); } /** * formed from components. size is extracted from array dimensions sets * dataType to xsd:double * * @param array */ public CMLArray(RealArray array) { this.setArray(array.getArray()); } /** * formed from components. size is extracted from array dimensions sets * dataType to xsd:double * * @param array */ public CMLArray(double[] array) { this.setArray(array); } /** * formed from components. size is extracted from array dimensions sets * dataType to xsd:double * * @param array */ public CMLArray(boolean[] array) { this.setArray(array); } /** * formed from components. size is extracted from array dimensions sets * dataType to xsd:double cannot use delimiter if strings contain it, so * choose another delimiter * * @param array * @param delimiter * @throws RuntimeException * strings must not contain delimiter */ public CMLArray(double[] array, String delimiter) throws RuntimeException { setDelimiter(delimiter); this.setArray(array); } /** * formed from components. size is extracted from array dimensions sets * dataType to xsd:integer * * @param array */ public CMLArray(DateTime[] array) { this.setArray(array); } /** * formed from components. size is extracted from array dimensions sets * dataType to xsd:integer * * @param array */ public CMLArray(int[] array) { this.setArray(array); } /** * formed from components. size is extracted from array dimensions sets * dataType to xsd:integer cannot use delimiter if strings contain it, so * choose another delimiter * * @param array * @param delimiter * @throws RuntimeException * doubles must not contain delimiter */ public CMLArray(int[] array, String delimiter) { setDelimiter(delimiter); this.setArray(array); } /** * creates array of given dataType * * @param dataType */ public CMLArray(String dataType) { this(); this.resetDataType(dataType); } public static CMLArray createArray(List scalarList) { CMLArray array = null; if (scalarList != null && scalarList.size() > 0) { CMLScalar scalar = scalarList.get(0); if (scalar == null) { throw new RuntimeException("Null scalar in list: " + scalarList.size()); } array = createArrayWithAttributes(scalar); } for (CMLScalar scalar : scalarList) { array.append(scalar); } array.removeWhitespaceDelimiterAttribute(); return array; } public static CMLArray createArrayWithAttributes(HasDataType hasDataType) { CMLArray array; String dataType = hasDataType.getDataType(); if (dataType == null) { throw new RuntimeException("Null data type"); } array = new CMLArray(dataType); String dictRef = hasDataType.getDictRef(); if (dictRef != null) { array.setDictRef(dictRef); } String units = ((HasUnits) hasDataType).getUnits(); if (units != null) { array.setUnits(units); } array.removeWhitespaceDelimiterAttribute(); return array; } /** * creates array of type comptatible with scalar can be used to add * subsequently scalar contents to array does NOT add scalar contents * typical use List<CMLScalar> scalars; CMLArray array = * CMLArray.createEmptyArray(scalars.get(0)); for (CMLScalar scalar : * scalars) { array.append(scalar); } * * @param scalar * @return */ public CMLArray createEmptyArray(CMLScalar scalar) { CMLArray array = null; if (scalar != null && scalar.getDataType() != null) { array = new CMLArray(scalar.getDataType()); } array.removeWhitespaceDelimiterAttribute(); return array; } /** * creates a new array formed from a subset of the current array * @param start inclusive start * @param end inclusive end * @return new array of correct dataType and dictRef; null if fails * @throws IllegalArgumentException if indices are out of bounds */ public CMLArray createSubArray(int start, int end) throws IllegalArgumentException { int size = this.getSize(); if (start < 0 || end >= size || end < start) { throw new IllegalArgumentException("bad array slice indexes "+start+"/"+end+" in "+size); } String dataType = this.getDataType(); CMLArray subArray = null; if (dataType == null || dataType.equals(CMLConstants.XSD_STRING)) { String[] sout = new String[end-start+1]; String[] ss = this.getStrings(); for (int i = start; i <= end; i++) { sout[i-start] = ss[i]; } String delimiter = this.getDelimiter(); subArray = (delimiter == null) ? new CMLArray(sout) : new CMLArray(sout, delimiter); } else if (dataType.equals(CMLConstants.XSD_DOUBLE)) { RealArray realArray = new RealArray(this.getDoubles()); subArray = new CMLArray(realArray.getSubArray(start, end)); } else if (dataType.equals(CMLConstants.XSD_INTEGER)) { IntArray intArray = new IntArray(this.getInts()); subArray = new CMLArray(intArray.getSubArray(start, end).getArray()); } String dictRef = this.getDictRef(); if (dictRef != null) { subArray.setDictRef(dictRef); } return subArray; } // ====================== housekeeping methods ===================== /** * get size of array. * * @return size */ public int getArraySize() { return this.getSize(); } /** * returns array of primitive types based on dataType. * * @return double[], int[], String[] or null */ public Object getPrimitiveArray() { Object primitiveArray = null; if (XSD_DOUBLE.equals(this.getDataType())) { primitiveArray = this.getDoubles(); } else if (XSD_BOOLEAN.equals(this.getDataType())) { primitiveArray = this.getBooleans(); } else if (XSD_DATE.equals(this.getDataType())) { primitiveArray = this.getDates(); } else if (XSD_INTEGER.equals(this.getDataType())) { primitiveArray = this.getInts(); } else if (XSD_STRING.equals(this.getDataType())) { primitiveArray = this.getStrings(); } else { primitiveArray = this.getStrings(); } return primitiveArray; } /** * get strings. * * @return strings */ public String[] getStrings() { String[] ss = null; if (this.getDataType().equals(XSD_STRING)) { ss = getSplitContent(); } return ss; } /** * splits content into tokens. if delimiter is whitespace, trims content and * splits at whitespace (however long) else assume starts and ends with * delimiter * * @return the tokens * @throws RuntimeException * if size attribute is inconsistent */ private String[] getSplitContent() throws RuntimeException { String[] ss = new String[0]; String content = this.getXMLContent(); if (content != null) { content = content.trim(); ensureDelimiterAttribute(Action.PRESERVE); ss = delimiterAttribute.getSplitContent(content); int size = -1; if (this.getSizeAttribute() == null) { //size = ss.length; //setSize(size); } else { size = super.getSize(); if (ss.length != size) { // FIXME this is not yet working // throw new CMLRuntime("Bad array length: "+size+" // incompatible // with elements: "+ss.length); } } } this.removeWhitespaceDelimiterAttribute(); return ss; } /** * get doubles. * * @return doubles * @throws RuntimeException */ public boolean[] getBooleans() throws RuntimeException { boolean[] dd = null; String dataType = this.getDataType(); if (dataType != null && XSD_BOOLEAN.equals(CMLType.getNormalizedValue(dataType))) { String[] ss = getSplitContent(); dd = new boolean[ss.length]; for (int i = 0; i < dd.length; i++) { dd[i] = Boolean.valueOf(ss[i]); } } return dd; } /** * get doubles. * * @return doubles * @throws RuntimeException */ public double[] getDoubles() throws RuntimeException { double[] dd = null; String dataType = this.getDataType(); if (dataType != null && XSD_DOUBLE.equals(CMLType.getNormalizedValue(dataType))) { String[] ss = getSplitContent(); dd = new double[ss.length]; for (int i = 0; i < dd.length; i++) { try { dd[i] = Util.parseFlexibleDouble(ss[i]); } catch (NumberFormatException nfe) { throw new RuntimeException("Bad double :" + ss[i] + " at position: " + i, nfe); } catch (ParseException e) { throw new RuntimeException("Bad double : " + ss[i] + "at position " + i, e); } } } return dd; } /** convenience method returns a list of doubles for either xsd:integer or xsd:double * * @return */ public double[] getNumbersAsDoubles() { double[] doubles = getDoubles(); if (doubles == null) { int[] integers = getInts(); if (integers != null) { RealArray realArray = RealArray.createRealArray(integers); doubles = (realArray == null) ? null : realArray.getArray(); } } return doubles; } /** * get dates * * @return dates * @throws RuntimeException */ public DateTime[] getDates() throws RuntimeException { DateTime[] dd = null; String dataType = this.getDataType(); if (dataType != null && XSD_DATE.equals(CMLType.getNormalizedValue(dataType))) { String[] ss = getSplitContent(); dd = new DateTime[ss.length]; for (int i = 0; i < dd.length; i++) { dd[i] = JodaDate.parseDate(ss[i]); } } return dd; } /** * get ints. * * @return ints * @throws RuntimeException */ public int[] getInts() throws RuntimeException { int[] ii = null; String dataType = this.getDataType(); if (XSD_INTEGER.equals(dataType)) { String[] ss = getSplitContent(); ii = new int[ss.length]; for (int i = 0; i < ii.length; i++) { try { ii[i] = Integer.valueOf(ss[i]).intValue(); } catch (NumberFormatException nfe) { throw new RuntimeException("Bad int (" + ss[i] + ") at position: " + i); } } } return ii; } public CMLScalar getElementAt(int i) { CMLScalar scalar = null; if (i >= 0 && i < getSize()) { String dataType = this.getDataType(); if (dataType == null) { dataType = XSD_STRING; } if (dataType.equals(XSD_STRING)) { String s = getStrings()[i]; scalar = new CMLScalar(s); } else if (dataType.equals(XSD_BOOLEAN)) { Boolean b = getBooleans()[i]; scalar = new CMLScalar(b); } else if (dataType.equals(XSD_DATE)) { DateTime d = getDates()[i]; scalar = new CMLScalar(d); } else if (dataType.equals(XSD_DOUBLE)) { Double d = getDoubles()[i]; scalar = new CMLScalar(d); } else if (dataType.equals(XSD_INTEGER)) { Integer ii = getInts()[i]; scalar = new CMLScalar(ii); } CMLArray.copyAttributesFromTo(this, scalar); } return scalar; } public static void copyAttributesFromTo(Element from, Element to) { copyAttributeTo(from, to, CMLAttribute.CONSTANT_TO_SI); copyAttributeTo(from, to, CMLAttribute.CONVENTION); copyAttributeTo(from, to, CMLAttribute.DICTREF); copyAttributeTo(from, to, CMLAttribute.ID); copyAttributeTo(from, to, CMLAttribute.MULTIPLIER_TO_SI); copyAttributeTo(from, to, CMLAttribute.TITLE); copyAttributeTo(from, to, CMLAttribute.UNITS); } private static void copyAttributeTo(Element from, Element to, String attName) { String attVal = from.getAttributeValue(attName); if (attVal != null) { to.addAttribute(new Attribute(attName, attVal)); } } /** * returns the String value of the array. convenience method to avoid * repeated accesses i.e. converts int and double to string * * @return strings */ public List getStringValues() { List values = new ArrayList(); String dataType = this.getDataType(); if (dataType == null || dataType.equals(XSD_STRING)) { String[] strings = this.getStrings(); for (String s : strings) { values.add(s); } } else if (XSD_INTEGER.equals(dataType)) { int[] ints = this.getInts(); for (int i : ints) { values.add(S_EMPTY + i); } } else if (XSD_DOUBLE.equals(dataType)) { double[] doubles = this.getDoubles(); for (double d : doubles) { values.add(S_EMPTY + d); } } return values; } // ====================== subsidiary accessors ===================== /** * sets components. * * @param array * @throws RuntimeException */ public void setArray(String[] array) throws RuntimeException { resetDataType(XSD_STRING); ensureDelimiterAttribute(Action.PRESERVE); for (String s : array) { delimiterAttribute.checkDelimiter(s); } setXMLContent(delimiterAttribute.getDelimitedXMLContent(array)); resetSize(array.length); this.removeWhitespaceDelimiterAttribute(); } private void resetDataType(String type) { Attribute a = (this.getAttribute("dataType")); if (a != null) { this.removeAttribute(a); } super.setDataType(type); } private void resetSize(int size) { Attribute a = (this.getAttribute("size")); if (a != null) { this.removeAttribute(a); } super.setSize(size); } /** * sets components. NOT IMPLEMENTED * * @param array */ public void setArray(DateTime[] array) { resetDataType(XSD_DATE); ensureDelimiterAttribute(Action.PRESERVE); // setXMLContent(delimiterAttribute.getDelimitedXMLContent(array)); resetSize(array.length); throw new RuntimeException("dates in array not fully implemented"); // this.removeWhitespaceDelimiterAttribute(); } /** * sets components. * * @param array */ public void setArray(boolean[] array) { resetDataType(XSD_BOOLEAN); ensureDelimiterAttribute(Action.PRESERVE); setXMLContent(delimiterAttribute.getDelimitedXMLContent(array)); resetSize(array.length); this.removeWhitespaceDelimiterAttribute(); } /** * sets components. * * @param array */ public void setArray(double[] array) { resetDataType(XSD_DOUBLE); ensureDelimiterAttribute(Action.PRESERVE); setXMLContent(delimiterAttribute.getDelimitedXMLContent(array)); resetSize(array.length); this.removeWhitespaceDelimiterAttribute(); } /** * sets components. * * @param array */ public void setArray(int[] array) { resetDataType(XSD_INTEGER); ensureDelimiterAttribute(Action.PRESERVE); setXMLContent(delimiterAttribute.getDelimitedXMLContent(array)); resetSize(array.length); this.removeWhitespaceDelimiterAttribute(); } /** * gets size of array. * * @return int size of array */ public int getSize() { int size = -1; if (this.getSizeAttribute() != null) { size = super.getSize(); } else { String[] array = this.getSplitContent(); size = array.length; } return size; } /** * reset null to whitespace, etc. * * @return String */ public String getDelimiter() { String delimiter = super.getDelimiter(); if (delimiter == null) { ensureDelimiterAttribute(Action.RESET); delimiter = delimiterAttribute.getValue(); } this.removeWhitespaceDelimiterAttribute(); return delimiter; } /** * set delimiter. * * @param value */ public void setDelimiter(String value) { String[] old = this.getSplitContent(); ensureDelimiterAttribute(Action.RESET); super.setDelimiter(value); delimiterAttribute = (DelimiterAttribute) this.getDelimiterAttribute(); if (old.length>0) { for (String s : old) { delimiterAttribute.checkDelimiter(s); } setXMLContent(delimiterAttribute.getDelimitedXMLContent(old)); } removeWhitespaceDelimiterAttribute(); } /** * get dataType. if attribute not set, reset to String. * * @return dataType (default XSD_STRING) */ public String getDataType() { String dataType = super.getDataType(); if (dataType == null) { dataType = XSD_STRING; super.setDataType(dataType); } return CMLType.getNormalizedValue(dataType); } /** * set dataType. * * sets dataType. Cannot reset after array is populated * * @param dType * (default XSD_STRING) * @throws RuntimeException * attempt to reset datatype */ public void setDataType(String dType) { if (this.getDataTypeAttribute() != null) { throw new RuntimeException("Cannot reset dataType"); } super.setDataType(dType); } /** * set size. * * @deprecated not user-accesible - throws CMLRuntime sets delimiter. Cannot * reset after array is populated if delimiter is whitespace, * removes the attribute * @param s * the size * @throws RuntimeException * attempt to reset datatype */ public void setSize(int s) { if (this.getSizeAttribute() != null) { throw new RuntimeException("user cannot reset size"); } super.setSize(s); } // ====================== functionality ===================== /** * can two arrays be used for arithmetic. checks that both arrays are * numeric and of same dataType and of same size * * @param array * the array to test; can have different owner * @throws RuntimeException * if not of same numeric data type and size */ public void checkNumericConformability(CMLArray array) { String thisDataType = this.getDataType(); String arrayDataType = array.getDataType(); if (thisDataType.equals(XSD_STRING) || !thisDataType.equals(arrayDataType) || this.getSize() != array.getSize()) { throw new RuntimeException( "Unsuitable dataTypes for numeric operations / " + this.getDataType() + CMLConstants.S_SLASH + this.getSize() + CMLConstants.S_SLASH + array.getDataType() + CMLConstants.S_SLASH + array.getSize()); } } /** * subtract an array from this.. * * result = this - array, owner document = this does not alter this only * works if both arrays are numeric and of same dataType * * @param array * the array to subtract; can have different owner * @throws RuntimeException * inappropriate dataTypes, unequal arrays * @return new array */ public CMLArray subtract(CMLArray array) { checkNumericConformability(array); CMLArray resultArray = null; try { if (this.getDataType().equals(XSD_DOUBLE)) { RealArray result = new RealArray(array.getDoubles()) .subtract(new RealArray(this.getDoubles())); resultArray = new CMLArray(result.getArray()); } else if (this.getDataType().equals(XSD_INTEGER)) { IntArray result = new IntArray(array.getInts()) .subtract(new IntArray(this.getInts())); resultArray = new CMLArray(result.getArray()); } } catch (EuclidRuntimeException je) { throw new RuntimeException(S_EMPTY + je); } return resultArray; } /** * add an array to this.. * * result is this + array, owner document = this does not alter this * * only works if both arrays are numeric and of same dataType * * @param array * the array to add; can have different owner * @throws RuntimeException * inappropriate dataTypes, unequal arrays * * @return the new array */ public CMLArray plus(CMLArray array) { checkNumericConformability(array); CMLArray resultArray = null; try { if (this.getDataType().equals(XSD_DOUBLE)) { RealArray result = new RealArray(this.getDoubles()) .plus(new RealArray(array.getDoubles())); resultArray = new CMLArray(result.getArray()); } else if (this.getDataType().equals(XSD_INTEGER)) { IntArray result = new IntArray(this.getInts()) .plus(new IntArray(array.getInts())); resultArray = new CMLArray(result.getArray()); } } catch (EuclidRuntimeException je) { throw new RuntimeException(S_EMPTY + je); } return resultArray; } /** * add a string. * * datatype must be unset or have been set to XSD_STRING * * @param s * String to add * * @throws RuntimeException * dataType not XSD_STRING */ public void append(String s) throws RuntimeException { String dataType = this.getDataType(); if (!XSD_STRING.equals(dataType)) { throw new RuntimeException("Cannot add string (" + s + ") to array of: " + dataType); } appendXML(s, 1); } /** * add a double. datatype must have been set to XSD_DOUBLE * * @param b * boolean to add * @throws RuntimeException * dataType not XSD_BOOLEAN */ public void append(boolean b) throws RuntimeException { String dataType = this.getDataType(); if (!XSD_BOOLEAN.equals(dataType)) { throw new RuntimeException("Cannot add boolean to array of: " + dataType); } appendXML(S_EMPTY + b, 1); } /** * add a double. datatype must have been set to XSD_DOUBLE * * @param d * double to add * @throws RuntimeException * dataType not XSD_DOUBLE */ public void append(double d) throws RuntimeException { String dataType = this.getDataType(); if (!XSD_DOUBLE.equals(dataType)) { throw new RuntimeException("Cannot add double to array of: " + dataType); } appendXML(Double.toString(d), 1); } /** * add an integer. datatype must have been set to XSD_INTEGER * * @param i * integer to add * @throws RuntimeException * dataType not XSD_INTEGER */ public void append(int i) throws RuntimeException { String dataType = this.getDataType(); if (!XSD_INTEGER.equals(dataType)) { throw new RuntimeException("Cannot add int to array of: " + dataType); } appendXML(S_EMPTY + i, 1); } public void append(CMLArray array) { if (!this.getDataType().equals(array.getDataType())) { throw new RuntimeException( "Cannot append array of different type: " + this.getDataType() + " != " + array.getDataType()); } if (!this.getDelimiter().equals(array.getDelimiter())) { throw new RuntimeException( "Cannot append array with different delimiter: " + this.getDelimiter() + " != " + array.getDelimiter()); } if (this.getUnits() != null && !this.getUnits().equals(array.getUnits())) { throw new RuntimeException( "Cannot append array with different units: " + this.getDelimiter() + " != " + array.getUnits()); } String arrayString = array.getXMLContent(); String delimiter = this.getDelimiter().trim(); if (delimiter.length() > 0) { arrayString = arrayString.substring(1, arrayString.length() - 1); } appendXML(arrayString, array.getSize()); } private void appendXML(String s, int toAdd) { int size = (this.getSizeAttribute() == null) ? 0 : this.getSize(); ensureDelimiterAttribute(Action.PRESERVE); if (toAdd <= 1) { delimiterAttribute.checkDelimiter(s); } String xmlContent = this.getXMLContent(); String delimitedContent = delimiterAttribute.appendXMLContent( xmlContent, s); this.setXMLContent(delimitedContent); resetSize(size + toAdd); this.removeWhitespaceDelimiterAttribute(); } public void append(CMLScalar scalar) { if (scalar != null) { String dataType = this.getDataType(); if (!dataType.equals(scalar.getDataType())) { throw new RuntimeException( "Cannot append scalar of different type: " + dataType + " != " + scalar.getDataType()); } if (this.getUnits() != null && !this.getUnits().equals(scalar.getUnits())) { throw new RuntimeException( "Cannot append scalar with different units: " + this.getDelimiter() + " != " + scalar.getUnits()); } append(scalar.getXMLContent(), dataType); this.removeWhitespaceDelimiterAttribute(); } } private void append(String content, String dataType) { if (XSD_STRING.equals(dataType)) { this.append(content); } else if (XSD_BOOLEAN.equals(dataType)) { this.append(Boolean.valueOf(content).booleanValue()); } else if (XSD_DATE.equals(dataType)) { this.append(JodaDate.parseDate(content).toString()); } else if (XSD_DOUBLE.equals(dataType)) { this.append(Double.valueOf(content).doubleValue()); } else if (XSD_INTEGER.equals(dataType)) { this.append(Integer.valueOf(content).intValue()); } } public void append(HasDictRef hasDictRef) { if (hasDictRef instanceof CMLScalar) { this.append((CMLScalar) hasDictRef); } else if (hasDictRef instanceof CMLArray) { this.append((CMLArray) hasDictRef); } else { throw new RuntimeException("Cannot add HasDictRef: " + ((CMLElement) hasDictRef).getLocalName()); } this.removeWhitespaceDelimiterAttribute(); // this.debug("APPPEND"); } /** * sets units attribute. requires namespace for unit to be in scope. * * @param prefix * for namespace * @param id * for unit * @param namespaceURI * sets units namespace if not present already */ public void setUnits(String prefix, String id, String namespaceURI) { NamespaceRefAttribute.setUnits((HasUnits) this, prefix, id, namespaceURI); } /** * add an integer. datatype must have been set to XSD_DATE * * @param d * date to add */ public void append(DateTime d) throws RuntimeException { String dataType = this.getDataType(); if (!XSD_DATE.equals(dataType)) { throw new RuntimeException("Cannot add date to array of: " + dataType); } appendXML(d.toString(), 1); } /** * removes attributes of the form delimiter="" or delimiter=" " */ public void removeWhitespaceDelimiterAttribute() { CMLArray.removeWhitespaceDelimiterAttribute(this); } public static void removeWhitespaceDelimiterAttribute( HasDelimiter hasDelimiter) { Attribute delimiter = hasDelimiter.getDelimiterAttribute(); if (delimiter != null && delimiter.getValue().trim().length() == 0) { delimiter.detach(); } } /** makes a list of CMLArrays * * @param elements * @return List<CMLArray> */ public static List extractArrays(List elements) { List arrayList = new ArrayList(); for (Element element : elements) { if (element instanceof CMLArray) { arrayList.add((CMLArray) element); } } return arrayList; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLArrayList.java000077500000000000000000000216011477224461000263010ustar00rootroot00000000000000/** * 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. */ // /*======AUTOGENERATED FROM SCHEMA; DO NOT EDIT BELOW THIS LINE ======*/ package org.xmlcml.cml.element; import java.util.ArrayList; import java.util.List; import nu.xom.Element; import nu.xom.Node; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.base.CMLUtil; import org.xmlcml.cml.interfacex.HasArraySize; /** A list of arrays or lists. * * * \n A major use of arrayList is to contain data within rectangular tables. However there is no \nabsolute requirement and the table can have any shape. The shape attribute hould be used \nto assert rectangularity. \n\n * * user-modifiable class autogenerated from schema if no class exists * use as a shell which can be edited * the autogeneration software will not overwrite an existing class file */ public class CMLArrayList extends org.xmlcml.cml.element.AbstractArrayList { /** must give simple documentation. * */ public CMLArrayList() { } /** must give simple documentation. * * @param old CMLArrayList to copy */ public CMLArrayList(CMLArrayList old) { super((org.xmlcml.cml.element.AbstractArrayList) old); } /** copy node . * * @return Node */ public Element copy() { return new CMLArrayList(this); } /** create new instance in context of parent, overridable by subclasses. * * @param parent parent of element to be constructed (ignored by default) * @return CMLArrayList */ public CMLElement makeElementInContext(Element parent) { return new CMLArrayList(); } /** create tableHeader from chidren. * @throws RuntimeException if chidren are inconsistent * @return tableHeader (may be empty) */ public CMLTableHeader createTableHeader() { CMLTableHeader tableHeader = new CMLTableHeader(); // CMLUtil.throwNYI(); List arraysAndLists = this.getArrays(); for (HasArraySize node : arraysAndLists) { CMLTableHeaderCell tableHeaderCell = this.createTableHeaderCell(node); tableHeader.addTableHeaderCell(tableHeaderCell); } return tableHeader; } /** create tableHeaderCell by copying attributes from array or list. * new cell has no string content. * @param node array or list * @return cell (never null) */ public CMLTableHeaderCell createTableHeaderCell(HasArraySize node) { CMLTableHeaderCell tableHeaderCell = null; if (node instanceof CMLArray) { tableHeaderCell = createTableHeaderCell((CMLArray) node); } else if (node instanceof CMLList) { tableHeaderCell = createTableHeaderCell((CMLList) node); } return tableHeaderCell; } /** create tableHeaderCell by copying attributes from array. * new cell has no string content. * @param array * @return cell (never null) */ public CMLTableHeaderCell createTableHeaderCell(CMLArray array) { CMLTableHeaderCell tableHeaderCell = new CMLTableHeaderCell(); if (array.getTitleAttribute() != null) { tableHeaderCell.setTitle(array.getTitle()); } if (array.getIdAttribute() != null) { tableHeaderCell.setId(array.getId()); } if (array.getDictRefAttribute() != null) { tableHeaderCell.setDictRef(array.getDictRef()); } if (array.getConventionAttribute() != null) { tableHeaderCell.setConvention(array.getConvention()); } if (array.getConstantToSIAttribute() != null) { tableHeaderCell.setConstantToSI(array.getConstantToSI()); } if (array.getMultiplierToSIAttribute() != null) { tableHeaderCell.setMultiplierToSI(array.getMultiplierToSI()); } if (array.getDataTypeAttribute() != null) { tableHeaderCell.setDataType(array.getDataType()); } if (array.getUnitTypeAttribute() != null) { tableHeaderCell.setUnitType(array.getUnitType()); } if (array.getUnitsAttribute() != null) { tableHeaderCell.setUnits(array.getUnits()); } return tableHeaderCell; } /** create tableHeaderCell by copying attributes from list. * new cell has no string content. * @param list * @return cell (never null) */ public CMLTableHeaderCell createTableHeaderCell(CMLList list) { CMLTableHeaderCell tableHeaderCell = new CMLTableHeaderCell(); if (list.getTitleAttribute() != null) { tableHeaderCell.setTitle(list.getTitle()); } if (list.getIdAttribute() != null) { tableHeaderCell.setId(list.getId()); } if (list.getDictRefAttribute() != null) { tableHeaderCell.setDictRef(list.getDictRef()); } if (list.getConventionAttribute() != null) { tableHeaderCell.setConvention(list.getConvention()); } List childNodes = CMLUtil.getQueryNodes(this, CMLConstants.S_STAR); if (childNodes.size() > 0) { tableHeaderCell.setDataType(((Element)childNodes.get(0)).getQualifiedName()); } return tableHeaderCell; } /** get ordered list of array and list children. * * @return list (may be empty) */ public List getArrays() { List list = new ArrayList(); List nodes = CMLUtil.getQueryNodes(this, CMLArray.NS+X_OR+CMLList.NS, CMLConstants.CML_XPATH); for (Node node : nodes) { list.add((HasArraySize) node); } return list; } /** get count of array and list children. * * @return count */ public int getArraysCount() { return this.getArrays().size(); } /** create tableContent. * * @return tableContent */ public CMLTableContent createTableContent() { String delimiter = this.getCommonDelimiter(); CMLTableContent tableContent = new CMLTableContent(); if (delimiter != null) { tableContent.setDelimiter(delimiter); } List listsAndArrays = this.getArrays(); int nCol = listsAndArrays.size(); if (nCol > 0) { int rowCount = ((HasArraySize)listsAndArrays.get(0)).getArraySize(); List> stringLists = new ArrayList>(); for (HasArraySize node : listsAndArrays) { stringLists.add(((HasArraySize)node).getStringValues()); } for (int iRow = 0; iRow < rowCount; iRow++) { for (int jCol = 0; jCol < nCol; jCol++) { String s = stringLists.get(jCol).get(iRow); tableContent.append(s, delimiter); } } tableContent.finishAppendingStrings(delimiter); } return tableContent; } /** iterate through children to see if all delimiters are identical. * @throws RuntimeException if inconsistent * @return common delimiter */ public String getCommonDelimiter() { String delimiter = null; CMLElements arrays = this.getArrayElements(); for (CMLArray array : arrays) { String delimiter0 = array.getDelimiter(); if (delimiter == null) { if (delimiter0 != null) { delimiter = delimiter0; } } else { if (!delimiter0.equals(delimiter)) { throw new RuntimeException("Cannot find common delimiter: >" +delimiter0+"::"+delimiter +"<"); } } } return delimiter; } /** get row size (from first array). * * @return size */ public int getRowCount() { int rows = 0; if (this.getArraysCount() > 0) { HasArraySize array = (HasArraySize) this.getArrays().get(0); rows = array.getArraySize(); } return rows; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLAtom.java000077500000000000000000001050601477224461000252710ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import java.util.Set; import nu.xom.Element; import nu.xom.Node; import nu.xom.ParentNode; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Real2; import org.xmlcml.euclid.Transform2; import org.xmlcml.euclid.Transform3; import org.xmlcml.euclid.Util; import org.xmlcml.euclid.Vector2; import org.xmlcml.euclid.Vector3; import org.xmlcml.molutil.ChemicalElement; import org.xmlcml.molutil.ChemicalElement.AS; import org.xmlcml.molutil.ChemicalElement.Type; /** * Class representing the CML atom element * * @author Peter Murray-Rust, Ramin Ghorashi (2005) * */ public class CMLAtom extends AbstractAtom { final static Logger LOG = Logger.getLogger(CMLAtom.class); /** namespaced element name.*/ public final static String NS = C_E+TAG; static { LOG.setLevel(Level.WARN); }; List ligandAtoms = null; List ligandBonds = null; /** * Construct a new CMLAtom element without id. */ public CMLAtom() { super(); init(); } void init() { ligandAtoms = new ArrayList(); ligandBonds = new ArrayList(); } /** * Construct a new CMLAtom element with immutable id. * @param id */ public CMLAtom(String id) { super(); this.setId(id); } /** * copy constructor. * * @param old * to copy */ public CMLAtom(CMLAtom old) { super(old); init(); } /** * Create new CMLAtom with specified id and ChemicalElement.AS * @param id * @param as atom symbol */ public CMLAtom(String id, AS as) { this(id, ChemicalElement.getChemicalElement(as)); } /** * Create new CMLAtom with specified id and ChemicalElement. * @param id * @param chem */ public CMLAtom(String id, ChemicalElement chem) { this(id); this.setElementType(chem.getSymbol()); } /** * copy node . * * @return Node */ public Element copy() { return new CMLAtom(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLAtom * @throws RuntimeException */ public CMLElement makeElementInContext(Element parent) throws RuntimeException { String error = null; CMLAtom atom = null; // these rules need revising periodically if (parent == null) { atom = new CMLAtom(); } else if (parent instanceof CMLAtomArray) { // atomArray parent must be child of Molecule or Formula Element grandParent = (Element) parent.getParent(); if (grandParent == null) { error = "Atom needs non-null grandparent"; } else if (grandParent instanceof CMLMolecule) { atom = new CMLAtom(); } else if (grandParent instanceof CMLFormula) { error = "Atom grandparent must be not be formula"; } else { error = "Atom grandparent must be molecule"; } } else { atom = new CMLAtom(); // error = "Atom needs atomArray parent"; } if (error != null) { throw new RuntimeException(error); } return atom; } /** * make sure atomId is present * * @param parent * element */ public void finishMakingElement(Element parent) { try { check(); } catch (RuntimeException e) { LOG.warn(e.getMessage()); } } /** * checks the CML compliance of this element * */ public void check() { String id = this.getId(); if (id == null) { throw new RuntimeException("Atom id must not be null"); } CMLMolecule molecule = getMolecule(); if (molecule != null) { CMLAtom oldAtom = getMolecule().getAtomById(id); if (oldAtom != null) { if (oldAtom != this) { oldAtom.debug("OLD ATOM"); throw new RuntimeException("atom check: duplicate atom id: " + id); } } } else { // is this an error? // throw new CMLRuntime("Atom has no molecule"); } } /** set id. * this will index the atom if it has a parent. * id cannot be reset. * @param id */ public void setId(String id) { String id0 = this.getId(); if (id0 != null) { if(!id0.equals(id)) { throw new RuntimeException("Cannot reindex id"); } } else { // LOG.debug("ATOM SET ID "+id); super.setId(id); ParentNode parent = this.getParent(); if (parent != null && parent instanceof CMLAtomArray) { CMLAtomArray atomArray = (CMLAtomArray) parent; if (atomArray != null) { atomArray.indexAtom(this); } } } } /** gets current ligands. * updated every time atoms or bonds are added or removed * @return list */ public List getLigandAtoms() { if (ligandAtoms == null) { ligandAtoms = new ArrayList(); } return ligandAtoms; } /** gets current bonds to ligands. * list is aligned with ligandAtoms * updated every time atoms or bonds are added or removed * @return list */ public List getLigandBonds() { if (ligandBonds == null) { ligandBonds = new ArrayList(); } return ligandBonds; } void addLigandBond(CMLBond bond, CMLAtom otherAtom) { getLigandAtoms(); if (ligandAtoms.contains(otherAtom)) { throw new RuntimeException("Duplicate ligand: "+otherAtom.getId()); } getLigandBonds(); if (ligandBonds.contains(bond)) { throw new RuntimeException("Duplicate bond: "+bond.getAtomRefs2()); } ligandAtoms.add(otherAtom); ligandBonds.add(bond); } /** deletes ligand info but not bond. * therefore not for public use. * @param bond * @param otherAtom */ void clearLigandInfo(CMLBond bond, CMLAtom otherAtom) { if (ligandAtoms != null) { if (!ligandAtoms.contains(otherAtom)) { throw new RuntimeException("Unknown ligand: "+otherAtom.getString()); } ligandAtoms.remove(otherAtom); } else { ; // is this an error? } if (ligandBonds != null) { if (!ligandBonds.contains(bond)) { throw new RuntimeException("Unknown bond: "+bond.getString()); } ligandBonds.remove(bond); } else { ; // is this an error? } } /** delete ligand info but not bond. * not for public use. */ void clearLigandInfo() { int nlig = ligandAtoms.size(); for (int i = nlig - 1; i >= 0; i--) { this.clearLigandInfo(ligandBonds.get(i), ligandAtoms.get(i)); } } /** * Get owner molecule. * * @return owner molecule */ public CMLMolecule getMolecule() { Node atomArray = this.getParent(); if (atomArray != null) { Node grandParent = atomArray.getParent(); if (grandParent != null && grandParent instanceof CMLMolecule) { return (CMLMolecule) grandParent; } } return null; } CMLAtomArray getAtomArray() { ParentNode parent = this.getParent(); return (parent == null || !(parent instanceof CMLAtomArray)) ? null : (CMLAtomArray) parent; } /** remove atom. * routed to atomArray.removeAtom() */ public void detach() { CMLAtomArray atomArray = getAtomArray(); if (this.getParent() != null && atomArray != null) { atomArray.removeAtom(this); } } /** gets all explict hydrogen ligand atoms. * ignore hydrogen count * @return list of atoms */ public List getLigandHydrogenAtoms() { List hydrogenAtoms = new ArrayList(); List ligandAtoms = this.getLigandAtoms(); for (CMLAtom ligand : ligandAtoms) { if (AS.H.equals(ligand.getElementType())) { hydrogenAtoms.add(ligand); } } return hydrogenAtoms; } /** if atom has one or more hydrogen atoms deletes one. * mainly for managing count for aromatics. * @return atom deleted or null */ public CMLAtom deleteAnyLigandHydrogenAtom() { CMLAtom ligand = null; List hydrogens = getLigandHydrogenAtoms(); if (hydrogens.size() > 0) { CMLMolecule molecule = this.getMolecule(); ligand = hydrogens.get(0); CMLBond bond = molecule.getBond(this, ligand); molecule.deleteBond(bond); molecule.deleteAtom(ligand); } return ligand; } /** * Returns the number of valence electrons this atom has based on its * chemical element * * @return number of valence electrons */ public int getValenceElectrons() { ChemicalElement chemicalElement = this.getChemicalElement(); if (chemicalElement != null) { return chemicalElement.getValenceElectrons(); } return 0; } /** * gets Real2 for x2 y2. * * @return the point; null if x2, etc. are unset */ public Real2 getXY2() { if (hasCoordinates(CoordinateType.TWOD)) { return new Real2(this.getX2(), this.getY2()); } return null; } /** * sets Real2 for x2 y2. * * @param point */ public void setXY2(Real2 point) { this.setX2(point.getX()); this.setY2(point.getY()); } /** * gets Point3 for x3, y3, z3. * * @see #getPoint3(CoordinateType) * @return the point; null if x3, etc. are unset */ public Point3 getXYZ3() { if (hasCoordinates(CoordinateType.CARTESIAN)) { return new Point3(this.getX3(), this.getY3(), this.getZ3()); } return null; } /** * gets Point3 for cartesians or fractionals. * * @see #getXYZ3() * @see #getXYZFract() * @param type * selects cartesians or fractionals * @return the point; null if x3 or xFract, etc. are unset */ public Point3 getPoint3(CoordinateType type) { Point3 point = null; if (type.equals(CoordinateType.CARTESIAN)) { point = getXYZ3(); } else if (type.equals(CoordinateType.FRACTIONAL)) { point = getXYZFract(); } return point; } /** * sets Point3 for x3 y3 z3. * * @param point */ public void setXYZ3(Point3 point) { this.setX3(point.getArray()[0]); this.setY3(point.getArray()[1]); this.setZ3(point.getArray()[2]); } /** * sets Point3 for cartesians or fractionals. * * @param point * to set * @param type * selects cartesians or fractionals * @return the point; null if x3 or xFract, etc. are unset */ public Point3 setPoint3(Point3 point, CoordinateType type) { if (type.equals(CoordinateType.CARTESIAN)) { setXYZ3(point); } else if (type.equals(CoordinateType.FRACTIONAL)) { setXYZFract(point); } return point; } /** * unsets Point3 for cartesians or fractionals or 2D. remove appropraite * attributes * * @param type * selects cartesians or fractionals */ public void unsetPoint(CoordinateType type) { if (type.equals(CoordinateType.CARTESIAN)) { unsetXYZ3(); } else if (type.equals(CoordinateType.FRACTIONAL)) { unsetXYZFract(); } else if (type.equals(CoordinateType.TWOD)) { unsetXY2(); } } /** * unsets x3 y3 z3. */ public void unsetXYZ3() { this.removeAttribute("x3"); this.removeAttribute("y3"); this.removeAttribute("z3"); } /** * unsets xFract yFract zFract. */ public void unsetXYZFract() { this.removeAttribute("xFract"); this.removeAttribute("yFract"); this.removeAttribute("zFract"); } /** * unsets x2 y2 */ public void unsetXY2() { this.removeAttribute("x2"); this.removeAttribute("y2"); } /** * transform 3D coordinates. does NOT alter fractional or 2D coordinates * * @param transform * the transformation */ public void transformCartesians(Transform3 transform) { Point3 point = this.getXYZ3(); if (point != null) { point = point.transform(transform); this.setXYZ3(point); } } /** * gets Point3 for xFract, yFract, zFract. * * @return the point; null if xFract, etc. are unset */ public Point3 getXYZFract() { if (hasCoordinates(CoordinateType.FRACTIONAL)) { return new Point3(this.getXFract(), this.getYFract(), this .getZFract()); } return null; } /** * sets Point3 for x3 y3 z3. * * @param point */ public void setXYZFract(Point3 point) { this.setXFract(point.getArray()[0]); this.setYFract(point.getArray()[1]); this.setZFract(point.getArray()[2]); } /** * transform 3D fractional coordinates. modifies this does not modify x3, * y3, z3 (may need to re-generate cartesians) * * @param transform * the transformation */ public void transformFractionals(Transform3 transform) { Point3 point = this.getXYZFract(); point = point.transform(transform); this.setXYZFract(point); } /** * The formalCharge on the atom. this attribute is often omitted; if so * getFormalCharge() will throw CMLRuntime. this routine allows the caller * to decide whether an omission default to 0. * * @param control * @return int */ public int getFormalCharge(FormalChargeControl control) { int fc = 0; try { fc = getFormalCharge(); } catch (RuntimeException e) { if (FormalChargeControl.NO_DEFAULT.equals(control)) { throw e; } } return fc; } /** * Gets the fractional coordinate for this atom * * @return the fractional coordinate or null if it has not been set */ public Point3 getFractCoord() { if (this.getXFractAttribute() != null && this.getYFractAttribute() != null && this.getZFractAttribute() != null) { return new Point3(this.getXFract(), this.getYFract(), this .getZFract()); } else { return null; } } /** * gets chemical element corresponding to elementType. * * @return the chemical element (or null) */ public ChemicalElement getChemicalElement() { return ChemicalElement.getChemicalElement(this.getElementType()); } /** convenience method to determine whether atom is of given elementType; * * @param elementType * @return true if element of same type as getElementType() */ public boolean hasElement(String elementType) { return elementType != null && elementType.equals(this.getElementType()); } /** * gets atomicNumber corresponding to elementType. * * @return atomic number (0 if not found) */ public int getAtomicNumber() { ChemicalElement chemicalElement = getChemicalElement(); return (chemicalElement == null) ? 0 : chemicalElement .getAtomicNumber(); } /** * get convenience serial number for common elements. only used by Molutils * and valency tools do not use outside JUMBO. This should be reengineered * to manage valency at some stage * * @param elemType * @return number */ public static int getCommonElementSerialNumber(String elemType) { final String[] elems = { AS.H.value, AS.C.value, AS.N.value, AS.O.value, AS.F.value, AS.Si.value, AS.P.value, AS.S.value, AS.Cl.value, AS.Br.value, AS.I.value }; for (int i = 0; i < elems.length; i++) { if (elems[i].equals(elemType)) { return i; } } return -1; } /** * gets cross product for 3 atoms in 3D. * * gets cross products of this->at1 X this->at2 * * @param atom1 * first atom * @param atom2 * second atom * * @return the cross product (null if parameters are null; zero if atoms are * coincident or colinear) */ // should this really be a public function? public Vector3 get3DCrossProduct(CMLAtom atom1, CMLAtom atom2) { Vector3 cross = null; Vector3 v1 = this.getVector3(atom1); Vector3 v2 = this.getVector3(atom2); cross = v1.cross(v2); return cross; } /** * gets cross product for 3 atoms in 2D. * * gets cross products of this->at1 X this->at2 the result is a 3D vector * perpendicular to xy2 plane * * @param atom1 * first atom * @param atom2 * second atom * * @return the cross product (null if parameters are null; zero if atoms are * coincident or colinear) */ // should this really be a public function? public Vector3 get2DCrossProduct(CMLAtom atom1, CMLAtom atom2) { Vector3 cross = null; if (atom1 != null && atom2 != null) { Point3 p0 = get2DPoint3(); Point3 p1 = atom1.get2DPoint3(); Point3 p2 = atom2.get2DPoint3(); if (p1 != null && p2 != null) { Vector3 v1 = p1.subtract(p0); Vector3 v2 = p2.subtract(p0); cross = v1.cross(v2); } } return cross; } /** * gets 2D coordinates as a 3D point. * * adds a z coordinate of 0.0. Result is not stored * * @return the point (null if no 2D coordinates) */ public Point3 get2DPoint3() { Point3 point = null; if (hasCoordinates(CoordinateType.TWOD)) { point = new Point3(this.getX2(), this.getY2(), 0.0); } return point; } /** * gets vector from this atom to another. * * gets vector this->at1 (i.e. at1 minus this) * * @param atom1 * other atom * * @return the vector (null if atoms are null or have no coordinates) */ public Vector3 getVector3(CMLAtom atom1) { Vector3 v = null; if (atom1 != null) { Point3 p0 = this.getXYZ3(); Point3 p1 = atom1.getXYZ3(); if (p1 != null && p0 != null) { v = p1.subtract(p0); } } return v; } /** * gets vector from this atom to another. * * gets vector this->at1 (i.e. at1 minus this) * * @param atom1 * other atom * * @return the vector (null if atoms are null or have no coordinates) */ public Real2 getVector2(CMLAtom atom1) { Real2 v = null; if (atom1 != null) { Real2 p0 = this.getXY2(); Real2 p1 = atom1.getXY2(); if (p1 != null && p0 != null) { v = p1.subtract(p0); } } return v; } /** * increase x2 and y2 coordinates. * * if x2 or y2 is unset, no action (to avoid a default of zero) * * @param dx * amount to add * @param dy * amount to add */ public void increaseXY2(double dx, double dy) { if (hasCoordinates(CoordinateType.TWOD)) { this.setX2(this.getX2() + dx); this.setY2(this.getY2() + dy); } } /** * transforms 2D coordinates of atom. * * if x2 or y2 is unset take no action * * @param t2 * transformation */ public void transform(Transform2 t2) { if (hasCoordinates(CoordinateType.TWOD)) { Real2 xy = new Real2(this.getX2(), this.getY2()); xy.transformBy(t2); this.setX2(xy.getX()); this.setY2(xy.getY()); } } /** * increase x3, y3 and z3 coordinates. * * if x3, y3 or z3 is unset, no action * * @param dx * amount to add * @param dy * amount to add * @param dz * amount to add */ public void increaseXYZ3(double dx, double dy, double dz) { if (hasCoordinates(CoordinateType.CARTESIAN)) { this.setX3(this.getX3() + dx); this.setY3(this.getY3() + dy); this.setZ3(this.getZ3() + dz); } } /** * increase x3, y3 and z3 coordinates. * * if x3, y3 or z3 is unset, no action * * @param dx * amount to add * @param dy * amount to add * @param dz * amount to add */ public void increaseXYZFract(double dx, double dy, double dz) { if (hasCoordinates(CoordinateType.CARTESIAN)) { this.setXFract(this.getXFract() + dx); this.setYFract(this.getYFract() + dy); this.setZFract(this.getZFract() + dz); } } /** * get distance between atoms. * * @param atom2 the other atom * * @return distance (throws Exception if atom(s) lack coordinates) */ public double getDistanceTo(CMLAtom atom2) { Vector3 vector = getVector3(atom2); if (vector != null) { return getVector3(atom2).getLength(); } else { throw new RuntimeException("cannot calculate distance"); } } /** * get 2D distance between atoms. * @param atom2 the other atom * @return distance (Double.NaN if atom(s) lack coordinates) */ public double getDistance2(CMLAtom atom2) { Real2 xy0 = this.getXY2(); Real2 xy1 = atom2.getXY2(); double distance2 = Double.NaN; if (xy0 != null && xy1 != null) { distance2 = xy0.getDistance(xy1); } return distance2; } /** * get squared distance between atoms. * * @param atom2 the other atom * * @return squared distance (NaN if atom(s) lack coordinates) */ public double getSquaredDistanceTo(CMLAtom atom2) { double dist2 = Double.NaN; Point3 p = this.getPoint3(CoordinateType.CARTESIAN); Point3 p2 = atom2.getPoint3(CoordinateType.CARTESIAN); if (p != null || p2 != null) { dist2 = p.getSquaredDistanceFromPoint(p2); } return dist2; } /**are two atoms within sum of radii. * * @param atom2 * @param radiusType * @return true if atoms are within sum */ public boolean isWithinRadiusSum ( CMLAtom atom2, ChemicalElement.RadiusType radiusType) { boolean within = false; ChemicalElement elem = this.getChemicalElement(); ChemicalElement elem2 = atom2.getChemicalElement(); if (elem != null && elem2 != null) { double radsum = elem.getRadius(radiusType) + elem2.getRadius(radiusType); double radsum2 = radsum * radsum; within = (radsum2 > this.getSquaredDistanceTo(atom2)); } return within; } /** * Rounds the coords that are within epsilon of 0 to 0. works coordinates * (XY2, XYZ3, XYZFract) according to coordinateType * * @param epsilon * (must not be 0) * @param coordinateType */ public void roundCoords(double epsilon, CoordinateType coordinateType) { epsilon = (epsilon == 0.0) ? 1.0E-50 : epsilon; final double factor = 1.0 / epsilon; // 2D int i; if (CoordinateType.TWOD.equals(coordinateType) && this.hasCoordinates(CoordinateType.TWOD)) { i = (int) (this.getX2() * factor); this.setX2(((double) i) * epsilon); i = (int) (this.getY2() * factor); this.setY2(((double) i) * epsilon); } // 3D if (CoordinateType.CARTESIAN.equals(coordinateType) && this.hasCoordinates(CoordinateType.CARTESIAN)) { i = (int) (this.getX3() * factor); this.setX3(((double) i) * epsilon); i = (int) (this.getY3() * factor); this.setY3(((double) i) * epsilon); i = (int) (this.getZ3() * factor); this.setZ3(((double) i) * epsilon); } // Fractionals if (CoordinateType.FRACTIONAL.equals(coordinateType) && this.hasCoordinates(CoordinateType.FRACTIONAL)) { i = (int) (this.getXFract() * factor); this.setXFract(((double) i) * epsilon); i = (int) (this.getYFract() * factor); this.setYFract(((double) i) * epsilon); i = (int) (this.getZFract() * factor); this.setZFract(((double) i) * epsilon); } } /** * Determines whether or not this atom has coordinates of a given type * * @param type * of coordinate * @return true if all coordinates or a given type are set, false otherwise */ public boolean hasCoordinates(CoordinateType type) { boolean has = false; if (CoordinateType.TWOD.equals(type)) { has = (this.getX2Attribute() != null && this.getY2Attribute() != null); } else if (CoordinateType.CARTESIAN.equals(type)) { has = (this.getX3Attribute() != null && this.getY3Attribute() != null && this.getZ3Attribute() != null); } else if (CoordinateType.FRACTIONAL.equals(type)) { has = (this.getXFractAttribute() != null && this.getYFractAttribute() != null && this .getZFractAttribute() != null); } return has; } /** * simple atom comparison based on atomic mass (not recursive). * * @param otherAtom * @return int the comparison */ public int compareByAtomicNumber(CMLAtom otherAtom) { int thisAtnum = getAtomicNumber(); int otherAtnum = otherAtom.getAtomicNumber(); int comp = 0; if (thisAtnum < otherAtnum) { comp = -1; } else if (thisAtnum > otherAtnum) { comp = 1; } return comp; } /** * gets count of hydrogens. Explicit hydrogen count overrides value of HydrogenCount * attribute if it is greater. * @return hydrogenCount(); */ public int getHydrogenCount() { int hcAttributeValue = 0; if (super.getHydrogenCountAttribute() != null) { hcAttributeValue = super.getHydrogenCount(); } int hcExplicit = getLigandHydrogenAtoms().size(); return Math.max(hcAttributeValue, hcExplicit); } /** gets formal charge. * * if attribute is missing, returns 0 * If you don't like this behaviour, test for null getFormalChargeAttribute() * and create your own behaviour * @return count on attribute or 0 */ public int getFormalCharge() { int fc = 0; if (super.getFormalChargeAttribute() != null) { fc = super.getFormalCharge(); } return fc; } /** get list of atoms filtered by elements. * * @param atomList list of atoms * @param elementSet elements in filter * @return atoms with elements in filter */ public static List filter(List atomList, Set elementSet) { List newAtomList = new ArrayList(); for (CMLAtom atom : atomList) { ChemicalElement element = atom.getChemicalElement(); if (element != null && elementSet.contains(element)) { newAtomList.add(atom); } } return newAtomList; } /** rename atom and all bonds it occurs in. * * @param newId */ public void renameId(String newId) { String oldId = this.getId(); List bondList = this.getLigandBonds(); for (CMLBond ligandBond : bondList) { ligandBond.renameAtomRef(oldId, newId); } // must delay this to the end to keep indexes OK this.resetId(newId); } /** replace element in atomRefs array. * used for swapping first and last atoms in either atomRefs2, atomRefs3 or atomRefs4 * @param atomRefs array with atom ids * @param atom * @param rGroup * @param last * @return true if swapped */ public static boolean replaceAtomRefs(String[] atomRefs, CMLAtom atom, CMLAtom rGroup, int last) { boolean change = false; if (atomRefs[0].equals(rGroup.getId())) { atomRefs[0] = atom.getId(); change = true; } else if (atomRefs[last].equals(rGroup.getId())) { atomRefs[last] = atom.getId(); change = true; } return change; } /** to string. * @return atom id and element type at present */ public String getString() { StringBuilder sb = new StringBuilder(); sb.append("id='"+this.getId()+"'"); sb.append(" elementType='"+this.getElementType()+"'"); return sb.toString(); } /** * is atom of given type. * * @param typeList * @return true if of type */ public boolean atomIsCompatible(List typeList) { boolean isCompatible = false; ChemicalElement chemicalElement = ChemicalElement .getChemicalElement(this.getElementType()); for (Type type : typeList) { if (type != null && chemicalElement.isChemicalElementType(type)) { isCompatible = true; } } return isCompatible; } /** * gets list of ligands in 2D diagram in clockwise order. * * starting atom is arbitrary (makes smallest clockwise angle with xAxis). * The 4 atoms can be compared to atomRefs4 given by author or other methods * to see if they are of the same or alternative parity. * * use compareAtomRefs4(CMLAtom[] a, CMLAtom[] b) for comparison * * @param atom4 * the original list of 4 atoms * @return ligands sorted into clockwise order * @throws RuntimeException */ public CMLAtom[] getClockwiseLigands(CMLAtom[] atom4) throws RuntimeException { Vector2 vx = new Vector2(1.0, 0.0); Real2 thisxy = getXY2(); double[] angle = new double[4]; Vector2 v = null; for (int i = 0; i < 4; i++) { try { v = new Vector2(atom4[i].getXY2().subtract(thisxy)); // Angle class appears to be broken, hence the degrees angle[i] = vx.getAngleMadeWith(v).getDegrees(); } catch (NullPointerException npe) { throw new RuntimeException( "Cannot compute clockwise ligands"); } if (angle[i] < 0) { angle[i] += 360.; } if (angle[i] > 360.) { angle[i] -= 360.; } } // get atom4Refs sorted in cyclic order CMLAtom[] cyclicAtom4 = new CMLAtom[4]; for (int i = 0; i < 4; i++) { double minAngle = Double.MAX_VALUE; int low = -1; for (int j = 0; j < 4; j++) { if (angle[j] >= 0 && angle[j] < minAngle) { low = j; minAngle = angle[j]; } } if (low != -1) { cyclicAtom4[i] = atom4[low]; angle[low] = -100.; } else { throw new RuntimeException( "Couldn't get AtomRefs4 sorted in cyclic order"); } } // all 4 angles must be less than PI // the ligands in clockwise order for (int i = 0; i < 4; i++) { CMLAtom cyclicAtomNext = cyclicAtom4[(i < 3) ? i + 1 : 0]; Real2 cyclicXy = cyclicAtom4[i].getXY2(); Real2 cyclicXyNext = cyclicAtomNext.getXY2(); v = new Vector2(cyclicXy.subtract(thisxy)); Vector2 vNext = new Vector2(cyclicXyNext.subtract(thisxy)); double ang = v.getAngleMadeWith(vNext).getDegrees(); if (ang < 0) { ang += 360.; } if (ang > 360.) { ang -= 360.; } if (ang > 180.) { throw new RuntimeException("All 4 ligands on same side " + getId()); } } return cyclicAtom4; } /** is this atom clode to another. * * @param atom * @return true if close */ public boolean hasCloseContact(CMLAtom atom) { double valenceDist = this.getChemicalElement().getCovalentRadius()+atom.getChemicalElement().getVDWRadius(); double dist = this.getDistanceTo(atom); if ((valenceDist/2) > dist) { return true; } else { return false; } } public static void debugAtom(String msg, CMLAtom atom) { if (atom == null) { Util.println(msg+"..."); } else { Util.println(msg+"..."+atom.getId()); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLAtomArray.java000077500000000000000000000700511477224461000262710ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import nu.xom.Element; import nu.xom.ParentNode; import org.apache.log4j.Logger; 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.StringArraySTAttribute; import org.xmlcml.cml.element.CMLFormula.Sort; import org.xmlcml.euclid.Util; /** * user-modifiable class supporting atomArray. * autogenerated from schema use * as a shell which can be edited * */ public class CMLAtomArray extends AbstractAtomArray { private static Logger LOG = Logger.getLogger(CMLAtomArray.class); final static Logger logger = Logger.getLogger(CMLAtomArray.class); /** namespaced element name.*/ public final static String NS = C_E+TAG; /** map of atom ids to atoms.*/ Map atomMap; /** * constructor. */ public CMLAtomArray() { super(); init(); } void init() { atomMap = new HashMap(); // new Exception().printStackTrace(); } /** copy constructor. * NOTE: this will NOT index the atoms. This is dealt with in * the Molecule copy costructor * * @param old */ public CMLAtomArray(CMLAtomArray old) { super(old); init(); } /** * copy node . * * @return Node */ public Element copy() { return new CMLAtomArray(this); } /** * create new instance in context of parent, overridable by subclasses. * * parent must be non-null molecule with no atomArray Child * * @param parent * parent of element to be constructed (ignored by default) * @return CMLAtom */ public CMLElement makeElementInContext(Element parent) { if (parent == null) { throw new RuntimeException("atomArray must have parent"); } else if (parent.getLocalName().equals(CMLMolecule.TAG)) { if (parent.getChildElements("atomArray", CMLConstants.CML_NS).size() > 0) { throw new RuntimeException( "molecule/atomArray must have no atomArray siblings"); } } else if (parent.getLocalName().equals(CMLFormula.TAG)) { CMLFormula formula = (CMLFormula) parent; CMLElements atomArrays = formula.getAtomArrayElements(); if (atomArrays.size() > 0) { if (formula.isProcessedConcise() && atomArrays.size() == 1) { formula.removeChild(atomArrays.get(0)); } else { throw new RuntimeException( "formula/atomArray must have no atomArray siblings"); } } } else { throw new RuntimeException("atomArray cannot have parent: " + parent.getLocalName()); } return new CMLAtomArray(); } /** finish making element. * * @param parent element */ public void finishMakingElement(Element parent) { super.finishMakingElement(parent); // this is here because the parser doesn't route through the // addAtom indexAtoms(); } /** An array of atom IDs. * * Normally an attribute of an array-based element. * --type info-- * * 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. * * JUMBO expands this into atoms. If any atoms are already present * throws an error. * * @param atomIDs * @throws RuntimeException duplicate atom, bad id, etc */ public void setAtomID(String[] atomIDs) throws RuntimeException { if (atomIDs == null) { throw new RuntimeException("null atomIDs"); } if (this.getAtoms().size() > 0) { throw new RuntimeException("Cannot use atomID with existing children"); } for (String s : atomIDs) { CMLAtom atom = new CMLAtom(s); this.addAtom(atom); } } /** adds a atom. * reroutes to addAtom(atom) * @param atom to add * @return added atom or null * @throws RuntimeException if already child or duplicate hash */ public CMLAtom appendChild(CMLAtom atom) { CMLAtom atom0 = this.addAtom(atom); return atom0; } /** get number of child atoms. * * @return count */ public int size() { return this.getAtomElements().size(); } /** sorts atomArray. * currently only works for array type syntax. * * @param sort */ public void sort(Sort sort) { String[] elems = this.getElementType(); double[] counts = this.getCount(); int nelem = elems.length; String[] sortS = new String[elems.length]; for (int i = 0; i < nelem; i++) { sortS[i] = elems[i] + CMLConstants.S_SPACE + counts[i]; } Arrays.sort(sortS); if (sort.equals(Sort.ALPHABETIC_ELEMENTS)) { ; // already done } else if (sort.equals(Sort.CHFIRST)) { String[] temp = new String[nelem]; int c = 0; for (int i = 0; i < nelem; i++) { if (sortS[i].startsWith("C ")) { temp[c++] = sortS[i]; } } for (int i = 0; i < nelem; i++) { if (sortS[i].startsWith("H ")) { temp[c++] = sortS[i]; } } for (int i = 0; i < nelem; i++) { if (sortS[i].startsWith("C ") || sortS[i].startsWith("H ")) { ; // } else { temp[c++] = sortS[i]; } } System.arraycopy(temp, 0, sortS, 0, nelem); } for (int i = 0; i < nelem; i++) { String[] ss = sortS[i].split(S_SPACE); elems[i] = ss[0]; counts[i] = Double.valueOf(ss[1]).doubleValue(); } this.setElementTypeAndCount(elems, counts); } /** * generates concise representation. correponds to concise attribute in * schema. only works if atomArray has elementType and count in array format * * @param formalCharge (maybe omit this) * @throws RuntimeException if atomArray of wrong sort * @return concise string */ public String generateConcise(int formalCharge) { String concise = null; String[] elems = this.getElementType(); double[] counts = this.getCount(); if (elems == null && counts == null) { elems = new String[0]; counts = new double[0]; } else if (elems == null || counts == null) { throw new RuntimeException( "atomArray has elements/counts "+elems+S_SLASH+counts); } else if (counts.length != elems.length) { throw new RuntimeException( "atomArray has inconsistent counts/elems "+counts.length+S_SLASH+elems.length); } int nelem = elems.length; StringBuffer sb = new StringBuffer(); for (int i = 0; i < nelem; i++) { sb.append(S_SPACE); sb.append(elems[i]); sb.append(S_SPACE); sb.append(Util.trim(Util.format(counts[i], 4))); } if (formalCharge != 0) { sb.append(S_SPACE); sb.append(formalCharge); } concise = (sb.length() == 0) ? CMLConstants.S_EMPTY : sb.substring(1); return concise; } /** * adds a atom. * * @param atom to add * @return added atom or null * @throws RuntimeException if already child or duplicate hash */ public CMLAtom addAtom(CMLAtom atom) { int count = this.getChildCount(); return this.insertAtom(atom, count); } /** * adds a atom. * * @param atom to add * @param pos position (see insertChild) * @return added atom or null * @throws RuntimeException if already child or duplicate hash */ public CMLAtom insertAtom(CMLAtom atom, int pos) { String id = atom.getId(); if (id == null) { throw new RuntimeException("Atom must have id"); } ParentNode parent = atom.getParent(); if (parent != null && parent.equals(this)) { throw new RuntimeException("atom already added"); } if (atomMap != null && atomMap.containsKey(id)) { throw new RuntimeException("atom already in array: "+id); } indexAtom(atom); this.insertChild(atom, pos); return atom; } void indexAtom(CMLAtom atom) { if (atomMap == null) { atomMap = new HashMap(); } atomMap.put(atom.getId(), atom); } /** removes a atom. * reroutes to removeAtom(atom) * @param atom to remove * @return removed atom or null * @throws RuntimeException */ public CMLAtom removeChild(CMLAtom atom) { return this.removeAtom(atom); } /** * removes a atom. * * @param atom * @return deleted atom or null */ public CMLAtom removeAtom(CMLAtom atom) { CMLAtom deletedAtom = null; if (this.equals(atom.getParent())) { super.removeChild(atom); if (atomMap != null) { atomMap.remove(atom.getId()); } deleteLigandBonds(atom); deletedAtom = atom; } return deletedAtom; } /** delete all bonds to this atom. * * @param atom * @return list of deleted bonds */ List deleteLigandBonds(CMLAtom atom) { CMLBondArray bondArray = this.getBondArray(); List ligandBonds = atom.getLigandBonds(); // make copy or we get conncurrentModification List ligandBonds1 = new ArrayList(); for (CMLBond bond : ligandBonds) { ligandBonds1.add(bond); } for (CMLBond bond : ligandBonds1) { bondArray.removeBond(bond); } return ligandBonds; } void deleteLigandBonds() { List atomList = this.getAtoms(); for (CMLAtom atom : atomList) { deleteLigandBonds(atom); } } void clearLigandInfo() { List atomList = this.getAtoms(); for (CMLAtom atom : atomList) { atom.clearLigandInfo(); } } void debugLigands() { List atomList = this.getAtoms(); for (CMLAtom atom : atomList) { Util.println("ATOM: "+atom.getString()); for (CMLAtom ligand : atom.getLigandAtoms()) { Util.println(" LIG: "+ligand.getString()); } } } /** get sibling bondArray. * * @return bondArray or null */ CMLBondArray getBondArray() { CMLBondArray bondArray = null; CMLMolecule molecule = this.getMolecule(); if (molecule != null) { CMLElements bondArrays = molecule.getBondArrayElements(); bondArray = (bondArrays.size() == 0) ? null : bondArrays.get(0); } return bondArray; } /** gets parent molecule. * * @return parent molecule or null */ public CMLMolecule getMolecule() { CMLMolecule molecule = null; ParentNode node = this.getParent(); if (node != null && node instanceof CMLMolecule) { molecule = (CMLMolecule) node; } return molecule; } /** reroute to molecule.removeAtomArray(). * also implicitly removes bondArray */ public void detach() { ParentNode parent = this.getParent(); if (parent != null) { if (parent instanceof CMLMolecule) { CMLMolecule molecule = (CMLMolecule) parent; molecule.removeAtomArray(); } else { super.detach(); } } } void indexAtoms() { List atoms = this.getAtoms(); this.getAtomMap(); atomMap.clear(); for (CMLAtom atom : atoms) { // atom.debug("ATOM IN MOLECULE"); String id = atom.getId(); // LOG.debug("ATOMID: "+id); if (atomMap.containsKey(id)) { // this.debug("DUPLICATE INDEX ATOMS"); throw new RuntimeException("Index atom: duplicate atom: "+id); } atomMap.put(id, atom); } } /** get map of atom hash to atoms. * * @return map */ public Map getAtomMap() { return atomMap; } /** get list of atoms in order. * * @return atoms */ public List getAtoms() { List atomList = new ArrayList(); CMLElements atoms = this.getAtomElements(); for (CMLAtom atom : atoms) { atomList.add(atom); } return atomList; } /** get atom by id. * * @param id * @return atom or null */ public CMLAtom getAtomById(String id) { return (atomMap == null) ? null : atomMap.get(id); } private List getAtoms(int length, String typeName) { ParentNode parent = this.getParent(); if (parent == null) { throw new RuntimeException("null parent for atomArray"); } if (parent instanceof CMLFormula) { throw new RuntimeException("don't use this for formula"); } // if parent is formula, artificially create atoms List atomList = this.getAtoms(); // check atoms match arrays if (atomList.size() != length) { throw new RuntimeException("inconsistent atom count ("+ atomList.size()+") and "+typeName+" ("+length+S_RBRAK); } return atomList; } /** formula-specific. * * @param elem * @param count * @throws RuntimeException */ public void setElementTypeAndCount(String[] elem, double[] count) throws RuntimeException { if (elem.length > 0 && count.length > 0) { StringArraySTAttribute att = new StringArraySTAttribute("elementType"); att.setCMLValue(elem); this.addAttribute(att); DoubleArraySTAttribute datt = new DoubleArraySTAttribute("count"); datt.setCMLValue(count); this.addAttribute(datt); } } /** The identity of a chemical element. * * Normally mandatory on _atom_, _isotope_, etc. * --type info-- * * An array of elementTypes. * Instances of this type will be used in array-style representation of atoms. * @param value elementType value * @throws RuntimeException attribute wrong value/type */ public void setElementType(String[] value) throws RuntimeException { if (value == null) { throw new RuntimeException("null elementType"); } List atomList = this.getAtoms(value.length, "elementType"); LOG.debug("ATOM "+this.getAtoms().size()); int i = 0; for (CMLAtom atom : atomList) { atom.setElementType(value[i++]); } } /** Array of object counts. * * No fixed semantics or default, normally integral. It is presumed that the element can be multiplied by the count value. * --type info-- * * Array of counts. * Normally, but not always, integers. can be used with a number of elements * @param value count value * @throws RuntimeException attribute wrong value/type */ public void setCount(double[] value) throws RuntimeException { if (value == null) { throw new RuntimeException("null count"); } List atomList = this.getAtoms(value.length, "count"); int i = 0; for (CMLAtom atom : atomList) { atom.setCount(value[i++]); } } /** 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. * --type info-- * * Array of formalCharges. * Used for electron-bookeeping. This has no relation to its calculated (fractional) charge or oxidation state. * @param value formalCharge value * @throws RuntimeException attribute wrong value/type */ public void setFormalCharge(String[] value) throws RuntimeException { if (value == null) { throw new RuntimeException("null formalCharge"); } List atomList = this.getAtoms(value.length, "formalCharge"); int i = 0; for (CMLAtom atom : atomList) { atom.setFormalCharge(Integer.parseInt(value[i++])); } } /** 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. * --type info-- * * Array of hydrogenCounts. * The total number of hydrogen atoms bonded to an atom or contained in a molecule, whether explicitly included as atoms or not. It is an error to have hydrogen count less than the explicit hydrogen count. There is no default value and no assumptions about hydrogen Count can be made if it is not given. If hydrogenCount is given on every atom, then the values can be summed to give the total hydrogenCount for the (sub)molecule. Because of this hydrogenCount should not be used where hydrogen atoms bridge 2 or more atoms. * @param value hydrogenCount value * @throws RuntimeException attribute wrong value/type */ public void setHydrogenCount(String[] value) throws RuntimeException { if (value == null) { throw new RuntimeException("null hydrogenCount"); } List atomList = this.getAtoms(value.length, "hydrogenCount"); int i = 0; for (CMLAtom atom : atomList) { atom.setHydrogenCount(Integer.parseInt(value[i++])); } } /** Array of occupancies. * * Normally only found in crystallography. Defaults to 1.0. The occupancy is required to calculate the molecular formula from the atoms. * --type info-- * * Array of atomic occupancies. * Primarily for crystallography. Values outside 0-1 are not allowed. * @param value occupancy value * @throws RuntimeException attribute wrong value/type */ public void setOccupancy(String[] value) throws RuntimeException { if (value == null) { throw new RuntimeException("null occupancy"); } List atomList = this.getAtoms(value.length, "occupancy"); int i = 0; for (CMLAtom atom : atomList) { atom.setOccupancy(Double.valueOf(value[i++]).doubleValue()); } } /** 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. * --type info-- * * An array of coordinateComponents for a single coordinate. * An array of coordinateComponents for a single coordinate * where these all refer to an X-coordinate (NOT x,y,z).Instances of this type will be * used in array-style representation of 2-D or 3-D coordinates. Currently no machine * validation. Currently not used in STMML, but re-used by CML (see example). * @param value x2 value * @throws RuntimeException attribute wrong value/type */ public void setX2(double[] value) throws RuntimeException { if (value == null) { throw new RuntimeException("null x2: "+this.getId()); } List atomList = this.getAtoms(value.length, "x2"); int i = 0; for (CMLAtom atom : atomList) { atom.setX2(value[i++]); } } /** 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. * --type info-- * * An array of coordinateComponents for a single coordinate. * An array of coordinateComponents for a single coordinate * where these all refer to an X-coordinate (NOT x,y,z).Instances of this type will be * used in array-style representation of 2-D or 3-D coordinates. Currently no machine * validation. Currently not used in STMML, but re-used by CML (see example). * @param value y2 value * @throws RuntimeException attribute wrong value/type */ public void setY2(double[] value) throws RuntimeException { if (value == null) { throw new RuntimeException("null y2"); } List atomList = this.getAtoms(value.length, "y2"); int i = 0; for (CMLAtom atom : atomList) { atom.setY2(value[i++]); } } /** Normally used in CML2 array mode. * * * --type info-- * * An array of coordinateComponents for a single coordinate. * An array of coordinateComponents for a single coordinate * where these all refer to an X-coordinate (NOT x,y,z).Instances of this type will be * used in array-style representation of 2-D or 3-D coordinates. Currently no machine * validation. Currently not used in STMML, but re-used by CML (see example). * must have already processed setAtomID * @param value must match atom count * @throws RuntimeException null x3, inconsistent atom count, etc. */ public void setX3(double[] value) throws RuntimeException { if (value == null) { throw new RuntimeException("null x3"); } List atomList = this.getAtoms(value.length, "x3"); int i = 0; for (CMLAtom atom : atomList) { atom.setX3(value[i++]); } } /** Normally used in CML2 array mode. * * * --type info-- * * An array of coordinateComponents for a single coordinate. * An array of coordinateComponents for a single coordinate * where these all refer to an X-coordinate (NOT x,y,z).Instances of this type will be * used in array-style representation of 2-D or 3-D coordinates. Currently no machine * validation. Currently not used in STMML, but re-used by CML (see example). * @param value y3 value * @throws RuntimeException attribute wrong value/type */ public void setY3(double[] value) throws RuntimeException { if (value == null) { throw new RuntimeException("null y3"); } List atomList = this.getAtoms(value.length, "y3"); int i = 0; for (CMLAtom atom : atomList) { atom.setY3(value[i++]); } } /** Normally used in CML2 array mode. * * * --type info-- * * An array of coordinateComponents for a single coordinate. * An array of coordinateComponents for a single coordinate * where these all refer to an X-coordinate (NOT x,y,z).Instances of this type will be * used in array-style representation of 2-D or 3-D coordinates. Currently no machine * validation. Currently not used in STMML, but re-used by CML (see example). * @param value z3 value * @throws RuntimeException attribute wrong value/type */ public void setZ3(double[] value) throws RuntimeException { if (value == null) { throw new RuntimeException("null z3"); } List atomList = this.getAtoms(value.length, "z3"); int i = 0; for (CMLAtom atom : atomList) { atom.setZ3(value[i++]); } } /** Array of fractional x coordinate. * * normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. * --type info-- * * An array of coordinateComponents for a single coordinate. * An array of coordinateComponents for a single coordinate * where these all refer to an X-coordinate (NOT x,y,z).Instances of this type will be * used in array-style representation of 2-D or 3-D coordinates. Currently no machine * validation. Currently not used in STMML, but re-used by CML (see example). * @param value xFract value * @throws RuntimeException attribute wrong value/type */ public void setXFract(double[] value) throws RuntimeException { if (value == null) { throw new RuntimeException("null xFract"); } List atomList = this.getAtoms(value.length, "xFract"); int i = 0; for (CMLAtom atom : atomList) { atom.setXFract(value[i++]); } } /** Array of fractional y coordinate. * * normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. * --type info-- * * An array of coordinateComponents for a single coordinate. * An array of coordinateComponents for a single coordinate * where these all refer to an X-coordinate (NOT x,y,z).Instances of this type will be * used in array-style representation of 2-D or 3-D coordinates. Currently no machine * validation. Currently not used in STMML, but re-used by CML (see example). * @param value yFract value * @throws RuntimeException attribute wrong value/type */ public void setYFract(double[] value) throws RuntimeException { if (value == null) { throw new RuntimeException("null yFract"); } List atomList = this.getAtoms(value.length, "yFract"); int i = 0; for (CMLAtom atom : atomList) { atom.setYFract(value[i++]); } } /** Array of fractional z coordinate. * * normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. * --type info-- * * An array of coordinateComponents for a single coordinate. * An array of coordinateComponents for a single coordinate * where these all refer to an X-coordinate (NOT x,y,z).Instances of this type will be * used in array-style representation of 2-D or 3-D coordinates. Currently no machine * validation. Currently not used in STMML, but re-used by CML (see example). * @param value zFract value * @throws RuntimeException attribute wrong value/type */ public void setZFract(double[] value) throws RuntimeException { if (value == null) { throw new RuntimeException("null zFract"); } List atomList = this.getAtoms(value.length, "zFract"); int i = 0; for (CMLAtom atom : atomList) { atom.setZFract(value[i++]); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLAtomParity.java000077500000000000000000000135651477224461000264720ustar00rootroot00000000000000/** * 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 java.util.List; import nu.xom.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting atomParity. * autogenerated from schema use * as a shell which can be edited * */ public class CMLAtomParity extends AbstractAtomParity { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** */ public final static int TWODIM = 1; /** */ public final static int THREEDIM = 2; /** minimum improper torsion angle to be regarded as chiral */ public final static double MINRAD = 0.15; /** minimum acceptable absolute value for parity, else assumed 0 */ public final static double EPSILON = 0.0001; /** * maximum acceptable absolute value for planarity, else assumed 0 * (Experimental) */ public final static double PLANARITYLIMIT = 0.4; /** */ public double minChiralDeterminant; /** * constructor. */ public CMLAtomParity() { super(); } /** * constructor. * * @param old */ public CMLAtomParity(CMLAtomParity old) { super((AbstractAtomParity) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLAtomParity(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLAtom */ public CMLElement makeElementInContext(Element parent) { return new CMLAtomParity(); } /** * sets atoms and their references. convenience method, calls * setAtomRefs4(String[]) * * @param atoms4 * @throws RuntimeException * wrong number of atoms */ public void setAtomRefs4(CMLAtom[] atoms4) throws RuntimeException { if (atoms4 == null || atoms4.length != 4) { throw new RuntimeException("Must give 4 atoms"); } this.setAtomRefs4(new String[] { atoms4[0].getId(), atoms4[1].getId(), atoms4[2].getId(), atoms4[3].getId(), }); } /** * Rearranges the atomRefs4 into the new order given and swaps the parity if * required. * * @param newAtomsRefs4 * the original atomRefs4, but in a new order * * @throws RuntimeException * the 4 atoms do not correspond or there are duplicates */ public void rearrangeAtomRefs4(String[] newAtomsRefs4) throws RuntimeException { String[] oldAtomsRefs4 = this.getAtomRefs4(); if (newAtomsRefs4.length != 4) { throw new RuntimeException("atomRefs4 must have 4 atoms"); } int parity = 0; for (int i = 0; i < 4; i++) { boolean found = false; for (int j = i; j < 4; j++) { if (newAtomsRefs4[i].equals(oldAtomsRefs4[j])) { if (i != j) { String temp = oldAtomsRefs4[i]; oldAtomsRefs4[i] = oldAtomsRefs4[j]; oldAtomsRefs4[j] = temp; parity = 1 - parity; } found = true; break; } } if (!found) { throw new RuntimeException( "newAtomRefs4 is not a rearrangement of the original set!"); } } this.setXMLContent(this.getXMLContent() * (1 - 2 * parity)); } /** * get value as signed integer. * * @return +1, 0 or -1 */ public int getIntegerValue() { int i = 0; double value = this.getXMLContent(); if (Math.abs(value) > MINRAD) { i = (value < 0) ? -1 : 1; } return i; } /** * gets atomRefs4 as array of atoms. * * uses the value in 'atomParity' element * * @param molecule * @return the atoms (null if no atomRefs4) */ public CMLAtom[] getAtomRefs4(CMLMolecule molecule) { String[] atomIds = this.getAtomRefs4(); CMLAtom[] atoms = null; if (atomIds != null && atomIds.length == 4) { atoms = new CMLAtom[4]; for (int i = 0; i < 4; i++) { atoms[i] = molecule.getAtomById(atomIds[i]); } } return atoms; } /** * utility method to create atomRefs4 attribute * * @param atoms * @return string array or null */ public static String[] createAtomRefs4(List atoms) { if (atoms == null || atoms.size() != 4) { throw new RuntimeException("Bad atom list argument."); } String[] atomRefs4 = new String[4]; int i = 0; for (CMLAtom atom : atoms) { atomRefs4[i++] = atom.getId(); } return atomRefs4; } /** * is the value zero. * * @return is (close to) zero */ public boolean isZero() { double value = this.getXMLContent(); return (Math.abs(value) < MINRAD); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLAtomSet.java000077500000000000000000001232101477224461000257420ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import nu.xom.Element; import org.apache.log4j.Logger; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.element.CMLMap.Direction; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Point3Vector; import org.xmlcml.euclid.Real2; import org.xmlcml.euclid.Real3Range; import org.xmlcml.euclid.RealMatrix; import org.xmlcml.euclid.Transform2; import org.xmlcml.euclid.Util; import org.xmlcml.euclid.Vector3; import org.xmlcml.molutil.ChemicalElement.AS; /** * user-modifiable class supporting atomSet. * autogenerated from schema use as * a shell which can be edited * */ public class CMLAtomSet extends AbstractAtomSet { final static Logger logger = Logger.getLogger(CMLAtomSet.class); /** namespaced element name.*/ public final static String NS = C_E+TAG; // arbitrary large distance to unmap atoms of different types /** */ public final static int MAX_DIST = 999999; protected CMLMolecule molecule; protected LinkedHashSet set = new LinkedHashSet(); protected Map idTable; protected boolean checkDuplicates = false; /** * constructor. */ public CMLAtomSet() { super(); checkDuplicates = true; } private void init() { set = new LinkedHashSet(); idTable = new HashMap(); this.setXMLContent(S_EMPTY); this.setSize(0); } /** copy constructor. copies references to atoms * * @param old to copy */ public CMLAtomSet(CMLAtomSet old) { super(old); init(); for (CMLAtom atom : old.set) { this.addAtom(atom); } } // private void copyTable(Map fromMap, // Map toMap) { // if (fromMap != null) { // for (String s : fromMap.keySet()) { // toMap.put(s, fromMap.get(s)); // } // } // } /** * copy node . * * @return Node */ public Element copy() { return new CMLAtomSet(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLAtom */ public CMLElement makeElementInContext(Element parent) { return new CMLAtomSet(); } /** atomSet from a molecule with atomIds. * * @param mol * the molecule * @param atomId * the ids */ public CMLAtomSet(CMLMolecule mol, String[] atomId) { this(); for (int i = 0; i < atomId.length; i++) { CMLAtom atom = mol.getAtomById(atomId[i]); if (atom != null) { this.addAtom(atom); } } } /** adds atoms from different molecules. * fragile. May or may not be a good idea. * owner molecule is null * @param molecules * @return new atomSet */ public static CMLAtomSet createFromMolecules(List molecules) { CMLAtomSet atomSet = new CMLAtomSet(); for (CMLMolecule mol : molecules) { atomSet.addAtoms(mol.getAtoms()); atomSet.molecule = null; } return atomSet; } /** adds atoms. * fragile. May or may not be a good idea. * @param atoms * @return new atomSet */ public static CMLAtomSet createFromAtoms(List atoms) { CMLAtomSet atomSet = new CMLAtomSet(); atomSet.addAtoms(atoms); return atomSet; } /** * create from a molecule. * * @param mol * the molecule */ public CMLAtomSet(CMLMolecule mol) { this.checkDuplicates = false; List atomList = mol.getAtoms(); addAtoms(atomList); } /** * @param molecules */ public CMLAtomSet(List molecules) { this(); for (CMLMolecule molecule : molecules) { this.addAtoms(molecule.getAtoms()); } } /** * creates atomSet from array of atoms. * @param atoms to add */ public CMLAtomSet(CMLAtom[] atoms) { this(); addAtoms(atoms); } /** * creates atomSet from set of atoms. * * @param atomSet * to add */ public CMLAtomSet(Set atomSet) { this(); if (atomSet != null) { for (CMLAtom atom : atomSet) { addAtom(atom); } } } /** * add array of atoms. // * * * @deprecated use generics * @param atoms */ public void addAtoms(CMLAtom[] atoms) { if (atoms != null) { for (int i = 0; i < atoms.length; i++) { this.addAtom(atoms[i]); } } } /** * add atoms. * always use this when adding a list of atoms to avoid QUADRATIC SLOW performance * @param atoms */ public void addAtoms(List atoms) { boolean forceUpdate = false; String[] ids = new String[atoms.size()]; int i = 0; for (CMLAtom atom : atoms) { this.addAtom(atom, forceUpdate); ids[i++] = atom.getId(); } updateContent(); } /** update the string content and size attribute. * only required for lazy addition of atoms. * most people won't use this. * */ public void updateContent() { String[] ids = this.getAtomIDs(); this.setXMLContent(ids); this.setSize(ids.length); } /** * adds atom to set. * SLOW. alters text content in XOM. Only use if adding single atoms * for lists of atoms, use addAtoms() * @param atom * to add */ public void addAtom(CMLAtom atom) { boolean forceUpdate = true; addAtom(atom, forceUpdate); } /** * adds atom to set with lazy option * avoids updating every addition. However it must be finished with * atomSet.update(); Use forceUpdate=false with care. * for lists of atoms, use addAtoms() * @param atom to add * @param forceUpdate if true forces update of text content (QUADRATIC and SLOW) */ public void addAtom(CMLAtom atom, boolean forceUpdate) { if (atom != null && !set.contains(atom)) { set.add(atom); if (idTable == null) { idTable = new HashMap(); } idTable.put(atom.getId(), atom); if (forceUpdate) { addAtomId(atom.getId()); } } if (molecule == null) { molecule = atom.getMolecule(); } else if (checkDuplicates) { if (!molecule.equals(atom.getMolecule())) { if (atom.getMolecule() != null) { System.out.println(molecule.hashCode()+ "/" + atom.getMolecule().hashCode()); throw new RuntimeException("cannot add atoms from different moelcules"); } } } } /** add atom id. * SLOW: updates set content. Only use when adding a few single atoms * else use addAtoms(); * @param id * @param updateXOM if false do not update XML content (valuable when adding many atoms) */ private void addAtomId(String id) { String[] content = {}; int size = 0; if (this.getSizeAttribute() != null) { content = this.getXMLContent(); size = this.getSize(); } this.setXMLContent(Util.addElementToStringArray(content, id)); this.setSize(size + 1); } /** * adds atomSet to set. * * @param atomSet * to add */ public void addAtomSet(CMLAtomSet atomSet) { addAtoms(atomSet.getAtoms()); } /** * gets i'th atom in set. * @param i serial * @return the atom */ public CMLAtom getAtom(int i) { List atomList = this.getAtoms(); return (atomList == null || i < 0 || i >= atomList.size()) ? null : atomList.get(i); } /** * gets all atoms in set. * * (not cached - need synchronising with addAtom) * * @return the atoms */ public List getAtoms() { List atoms = new ArrayList(); for (Iterator e = set.iterator(); e.hasNext();) { atoms.add(e.next()); } return atoms; } /** * gets size of set. * * @return the size */ public int size() { // getAtoms(); return set.size(); } /** * gets all ids of atoms. * * @return the atomIds */ public String[] getAtomIDs() { String[] atomIDs = new String[set.size()]; int count = 0; for (Iterator ii = set.iterator(); ii.hasNext();) { atomIDs[count++] = ii.next().getId(); } return atomIDs; } /** * gets atoms by ids. * * @param ids * @return the atoms */ public CMLAtomSet getAtomSetById(List ids) { CMLAtomSet atomSet = new CMLAtomSet(); for (String id : ids) { CMLAtom atom = (CMLAtom) this.getAtomById(id); atomSet.addAtom(atom); } return atomSet; } /** * gets atoms by ids. * convenience * @param ids * @return the atoms */ public CMLAtomSet getAtomSetById(String[] ids) { CMLAtomSet atomSet = new CMLAtomSet(); for (String id : ids) { CMLAtom atom = (CMLAtom) this.getAtomById(id); if (atom == null) { throw new RuntimeException("unknown atom: "+id); } atomSet.addAtom(atom); } return atomSet; } /** * gets atomSubset by elementType. * * @param elementType * for selecting subset * @return the atomSet containing ony atoms with given elementType */ public CMLAtomSet getAtomSetByElementType(String elementType) { CMLAtomSet atomSet = new CMLAtomSet(); List atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); if (elementType.equals(atom.getElementType())) { atomSet.addAtom((CMLAtom) atom); } } return atomSet; } /** * gets atom by id. * * @param id * @return the atom */ public CMLAtom getAtomById(String id) { return (CMLAtom) ((idTable == null) ? null : idTable.get(id)); } /** * does atomSet contain atom. * * @param atom * * @return true if contains atom */ public boolean contains(CMLAtom atom) { return set.contains(atom); } /** * removes atom from set. does NOT remove atom from molecule * * @param atom * to remove * @throws RuntimeException * atom not in set */ public void removeAtom(CMLAtom atom) throws RuntimeException { if (atom != null) { if (set.contains(atom)) { // throw new RuntimeException("atom not in set:" + atom.getId() + CMLConstants.S_COLON // + Util.concatenate(this.getXMLContent(), CMLConstants.S_SLASH)); // remove from set set.remove(atom); // and from id table String id = atom.getId(); idTable.remove(id); // and from XOM XMLContent String[] content = this.getXMLContent(); content = Util.removeElementFromStringArray(content, id); this.setXMLContent(content); // and adjust size int c = this.getSize(); this.setSize(c - 1); // atom.detach(); this kills the atoms relationship to its molecule! } } } /** * removes atom from set. * * @param id * of atom to remove * @throws RuntimeException * atom not in set */ public void removeAtomById(String id) throws RuntimeException { removeAtom(this.getAtomById(id)); } /** * removes atomSet from set. * * @param atomSet * to remove * @throws RuntimeException * one or more atoms not in set */ public void removeAtomSet(CMLAtomSet atomSet) throws RuntimeException { if (atomSet != null) { for (CMLAtom atom : atomSet.getAtoms()) { if (this.contains(atom)) this.removeAtom(atom); } } } /** gets vector of 3D coordinates. * all atoms must have coordinates * * @param type * @return the vector (null if missing 3D coordinates) */ public Point3Vector getCoordinates3(CoordinateType type) { List atoms = this.getAtoms(); Point3Vector p3Vector = new Point3Vector(); boolean ok = true; for (CMLAtom atom : atoms) { if (!atom.hasCoordinates(type)) { ok = false; break; } p3Vector.add(atom.getPoint3(type)); } return (!ok) ? null : p3Vector; } /** * translate molecule in 3D. * * @param delta3 * add to all 3D coordinates */ public void translate3D(Vector3 delta3) { List atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); if (atom.getX3Attribute() != null && atom.getY3Attribute() != null && atom.getZ3Attribute() != null) { atom.setX3(atom.getX3() + delta3.getArray()[0]); atom.setY3(atom.getY3() + delta3.getArray()[1]); atom.setZ3(atom.getZ3() + delta3.getArray()[2]); } } } /** get 3D centroid. * * @param type * CARTESIAN or FRACTIONAL * @return centroid of 3D coords or null */ public Point3 getCentroid3(CoordinateType type) { Point3 centroid3 = null; Point3Vector p3Vector = this.getCoordinates3(type); if (p3Vector != null) { centroid3 = p3Vector.getCentroid(); } return centroid3; } /** get 3D range. * * @param type CARTESIAN or FRACTIONAL * @return range of 3D coords or null if no coords */ public Real3Range calculateRange3(CoordinateType type) { Real3Range range3 = null; Point3Vector p3Vector = this.getCoordinates3(type); if (p3Vector != null) { range3 = p3Vector.getRange3(); } return range3; } /** * get corresponding molecule. * * uses parent molecule * * @return the molecule (null if none) */ public CMLMolecule getMolecule() { if (molecule == null) { List atoms = this.getAtoms(); if (atoms.size() > 0) { molecule = CMLMolecule.getMoleculeAncestor(atoms.get(0)); } else { throw new RuntimeException("NO atoms in set..."); } } return molecule; } /** * apply crystallographic symmetry. * * * @param orthMat * @param transMat * @param x * @param y * @param z */ /*-- public boolean applySymmetry (final RealSquareMatrix orthMat, final RealMatrix transMat, final int x, final int y, final int z) { List atoms = this.getAtoms(); if (atoms != null) { RealArray oldCoord = new RealArray (4); RealArray newCoord = null; RealArray cartCoord = new RealArray (3); double [] newData; for (int i = atoms.size() - 1; i >= 0; -- i) { CMLAtom atom = atoms.get(i); oldCoord.setElementAt (0, atom.getXFract ()); oldCoord.setElementAt (1, atom.getYFract ()); oldCoord.setElementAt (2, atom.getZFract ()); oldCoord.setElementAt (3, 1.0); try { newCoord = transMat.multiply (oldCoord); } catch (EuclidRuntimeException ume) { logger.info("AtomSetToolImpl :: applySymmetry: UnequalMatricesException"); logger.info("matrix " + transMat.getRows () + "x" + transMat.getCols ()); logger.info ("coord " + oldCoord.size ()); return false; } newCoord.setElementAt (0, newCoord.elementAt (0) + x); newCoord.setElementAt (1, newCoord.elementAt (1) + y); newCoord.setElementAt (2, newCoord.elementAt (2) + z); try { cartCoord = orthMat.multiply (newCoord); } catch (EuclidRuntimeException ume) { logger.info ("AtomSetToolImpl :: applySymmetry -> Couldn't apply orthMat" + orthMat + " to " + newCoord); return false; } newData = newCoord.getArray (); atom.setXFract (newData [0]); atom.setYFract (newData [1]); atom.setZFract (newData [2]); newData = cartCoord.getArray (); atom.setX3 (newData [0]); atom.setY3 (newData [1]); atom.setZ3 (newData [2]); } } else { throw new CMLRuntime ("null atoms"); } return true; } --*/ /** * transforms all 2D atom coordinates by t. SEEMS IDENTICAL TO transform() * * @param t2 * the transformation * */ /*-- public void transformBy(Transform2 t2) { List atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); Real2 xy2 = atom.getXY2(); // atom may have no coordinates, skip it if (xy2 != null) { xy2.transformBy(t2); atom.setXY2(xy2); } } } --*/ /** * excludes atoms by excludeElementTypes. * * creates new AtomSet. * * @param elementTypes * to exclude * @return atomSet */ public CMLAtomSet excludeElementTypes(String[] elementTypes) { CMLAtomSet newAtomSet = new CMLAtomSet(); List atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); String elementType = atom.getElementType(); boolean exclude = false; for (int j = 0; j < elementTypes.length; j++) { if (elementType == null || elementType.equals(S_EMPTY) || elementType.equals(elementTypes[j])) { exclude = true; break; } } if (!exclude) { newAtomSet.addAtom(atoms.get(i)); } } return newAtomSet; } /** * compare two atom sets for priority. * * assumes sets are in order (i.e. compares each set with each other without * normalization or sorting testing is done with atomTool.compareTo(atom) * (i.e. no recursion) compare atom[i] with otherAtom[i] until a mismatch is * found return atom[i].compareTo(otherAtom[i]); if atomSets are of * different length, but match to the lengtn of the shortest, then if * atomSet.length < otherAtomSet return -1 else 1 if otherAtomSet is null, * return 1 (even if this contains zero atoms) * * @param otherAtomSet * to compare. If null returns 1 * * @return are sets different (by ordered atom equality) */ public int compareTo(CMLAtomSet otherAtomSet) { int result = 0; // boolean equals = false; if (otherAtomSet == null) { result = 1; } else { List atoms = this.getAtoms(); List otherAtoms = otherAtomSet.getAtoms(); int length = Math.min(atoms.size(), otherAtoms.size()); for (int i = 0; i < length; i++) { int compare = atoms.get(i).compareTo(otherAtoms.get(i)); if (compare != 0) { result = compare; break; } } if (atoms.size() > length) { result = 1; } else if (otherAtoms.size() > length) { result = -1; } } return result; } /** * compare two atom sets for content. * * compare unordered atoms * @param otherAtomSet * to compare. * * @return true if identical and non null */ public boolean hasContentEqualTo(CMLAtomSet otherAtomSet) { boolean result = false; if (otherAtomSet != null && this.size() == otherAtomSet.size()) { CMLAtomSet atomSet = this.complement(otherAtomSet); result = atomSet.size() == 0; } return result; } /** * includes atoms by excludeElementTypes. * * creates new AtomSet. * * @param elementTypes * to include * @return atomSet */ public CMLAtomSet includeElementTypes(String[] elementTypes) { CMLAtomSet newAtomSet = new CMLAtomSet(); List atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); String elementType = atom.getElementType(); boolean include = false; for (int j = 0; j < elementTypes.length; j++) { if (elementType.equals(elementTypes[j])) { include = true; break; } } if (include) { newAtomSet.addAtom(atom); } } return newAtomSet; } /** * get formula. * * @param control * @return calculated formula * @throws RuntimeException */ public CMLFormula getCalculatedFormula(CMLMolecule.HydrogenControl control) throws RuntimeException { CMLFormula formula = new CMLFormula(); if (control.equals(CMLMolecule.HydrogenControl.USE_HYDROGEN_COUNT) || control.equals(CMLMolecule.HydrogenControl.USE_EXPLICIT_HYDROGENS) || control.equals(CMLMolecule.HydrogenControl.NO_EXPLICIT_HYDROGENS)) { } else { throw new RuntimeException("No hydrogen count control on Formula"); } double hCount = 0; for (CMLAtom atom : getAtoms()) { String elementType = atom.getElementType(); double occupancy = (atom.getOccupancyAttribute() == null) ? 1.0 : atom.getOccupancy(); int multiplicity = (atom.getSpaceGroupMultiplicityAttribute() == null) ? 1 : atom.getSpaceGroupMultiplicity(); if (AS.H.equals(elementType)) { if (CMLMolecule.HydrogenControl.USE_EXPLICIT_HYDROGENS .equals(control)) { hCount += occupancy / (double) multiplicity; } } else { if (CMLMolecule.HydrogenControl.USE_HYDROGEN_COUNT .equals(control)) { hCount += atom.getHydrogenCount() * occupancy; } formula.add(elementType, occupancy / (double) multiplicity); } } if (hCount > 0.000001) { formula.add(AS.H.value, hCount); } int charge = getCalculatedFormalCharge(); formula.setFormalCharge(charge); formula.normalize(); return formula; } /** * Calculate formalCharge from atomCharges. * * @return calculated formal charge * @throws RuntimeException */ public int getCalculatedFormalCharge() throws RuntimeException { List atoms = this.getAtoms(); int charge = 0; for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); try { charge += atom.getFormalCharge(); } catch (RuntimeException e) { } } return charge; } /** * Returns intersection of this atomSet with another. * * Creates new atomSet containing the atoms that are in both this atomSet, * and the one supplied. *

* eg. as1 = {a1, a2, a3}; as2 = {a2, a4}
* (as1) intersection (as2) = (as2) intersection (as1) = {a2} * * @param atomSet2 * atomSet to insersect with * @return intersection * @throws RuntimeException */ public CMLAtomSet intersection(CMLAtomSet atomSet2) throws RuntimeException { CMLAtomSet newAtomSet = new CMLAtomSet(); List atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { if (atomSet2.contains(atoms.get(i))) { newAtomSet.addAtom(atoms.get(i)); } } return newAtomSet; } /** * Returns complement of this atomSet with another. * * Creates new atomSet containing the atoms that are in this atomSet, and * not the one supplied. *

* eg. as1 = {a1, a2, a3}; as2 = {a2, a4}
* (as1) complement (as2) = {a1, a3}
* (as2) complement (as1) = {a4} * * @param atomSet2 * atomSet to complement; if null assumed empty * @return atomSet */ public CMLAtomSet complement(CMLAtomSet atomSet2) { if (atomSet2 == null) { return this; } CMLAtomSet newAtomSet = new CMLAtomSet(); List atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { if (!atomSet2.contains(atoms.get(i))) { newAtomSet.addAtom(atoms.get(i)); } } return newAtomSet; } /** * Returns union of this atomSet with another. * * Creates new atomSet containing the atoms that are in this atomSet, and/or * the one supplied. (Inclusive or) *

* eg. as1 = {a1, a2, a3}; as2 = {a2, a4}
* (as1) union (as2) = (as2) union (as1) = {a1, a2, a3, a4} * * @param atomSet2 * atomSet to unite with * @throws RuntimeException * @return atom set */ public CMLAtomSet union(CMLAtomSet atomSet2) throws RuntimeException { CMLAtomSet newAtomSet = new CMLAtomSet(); List atoms = this.getAtoms(); newAtomSet.addAtoms(atoms); newAtomSet.addAtoms(atomSet2.getAtoms()); return newAtomSet; } /** * Returns symmetric difference of this atomSet with another. * * Creates new atomSet containing the atoms that are in either atomSet, or * the one supplied, but not both. (Exclusive or) *

* eg. as1 = {a1, a2, a3}; as2 = {a2, a4}
* (as1) symmetric difference (as2) = {a1, a3, a4} * * @param atomSet2 * atomSet to xor with * @throws RuntimeException * @return atomSet * */ public CMLAtomSet symmetricDifference(CMLAtomSet atomSet2) { CMLAtomSet newAtomSet = new CMLAtomSet(); List atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { if (!atomSet2.contains(atoms.get(i))) { newAtomSet.addAtom(atoms.get(i)); } } List atoms2 = atomSet2.getAtoms(); for (int i = 0; i < atoms2.size(); i++) { CMLAtom atom = atoms2.get(i); if (!this.contains(atom)) { newAtomSet.addAtom(atom); } } return newAtomSet; } /** * Returns intersection of this atomSet's atomIds with another's. * * Creates new atomSet containing the atoms that are in both this atomSet, * and the one supplied. *

* eg. as1 = {a1, a2, a3}; as2 = {a2, a4}
* (as1) intersection (as2) = (as2) intersection (as1) = {a2} * * @param atomSet2 * atomSet to insersect with * @return String array of atom Ids * @throws RuntimeException */ public String[] intersectionByAtomId(CMLAtomSet atomSet2) { CMLAtomSet result = intersection(atomSet2); return result.getAtomIDs(); } /** * Returns compliment of this atomSet's atomIds with another's. * * Creates new atomSet containing the atoms that are in this atomSet, and * not the one supplied. *

* eg. as1 = {a1, a2, a3}; as2 = {a2, a4}
* (as1) compliment (as2) = {a1, a3}
* (as2) compliment (as1) = {a4} * * @param atomSet2 * atomSet to compliment * @return String array of atom Ids * @throws RuntimeException */ public String[] complementByAtomId(CMLAtomSet atomSet2) { CMLAtomSet result = complement(atomSet2); return result.getAtomIDs(); } /** * Returns union of this atomSet's atomIds with another's. * * Creates new atomSet containing the atoms that are in this atomSet, and/or * the one supplied. (Inclusive or) *

* eg. as1 = {a1, a2, a3}; as2 = {a2, a4}
* (as1) union (as2) = (as2) union (as1) = {a1, a2, a3, a4} * * @param atomSet2 * atomSet to unite with * @return ids * @throws RuntimeException */ public String[] unionByAtomId(CMLAtomSet atomSet2) { CMLAtomSet result = union(atomSet2); return result.getAtomIDs(); } /** * Returns symmetric difference of this atomSet's atomIds with another's. * * Creates new atomSet containing the atoms that are in either atomSet, or * the one supplied, but not both. (Exclusive or) *

* eg. as1 = {a1, a2, a3}; as2 = {a2, a4}
* (as1) symmetric difference (as2) = {a1, a3, a4} * * @param atomSet2 * atomSet to xor with * @return ids * @throws RuntimeException */ public String[] symmetricDifferenceByAtomId(CMLAtomSet atomSet2) { CMLAtomSet result = symmetricDifference(atomSet2); return result.getAtomIDs(); } /** * transform 2D coordinates. * * @param transform * the transformation * */ public void transform(Transform2 transform) { List atoms = this.getAtoms(); for (CMLAtom atom : atoms) { atom.transform(transform); } } /** * gets vector of 2D coordinates. * * all atoms must have coordinates COPIES coordinates so operations on * vector do not affect atomset * * @return the vector (null if missing 2D coordinates) */ public List getVector2D() { List atoms = this.getAtoms(); List p2Vector = new ArrayList(); boolean ok = true; for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); if (atom.getX2Attribute() == null || atom.getY2Attribute() == null) { ok = false; break; } Real2 p2 = new Real2(atom.getX2(), atom.getY2()); p2Vector.add(p2); } if (!ok) { p2Vector = null; } return p2Vector; } /** * sets vector of 2D coordinates. * * must be same length as atom set * * @param p2Vector * the vector * @throws RuntimeException * vector of wrong length */ public void setVector2D(List p2Vector) { List atoms = this.getAtoms(); if (p2Vector.size() != atoms.size()) { throw new RuntimeException("Vector (" + p2Vector.size() + ") not same length as atoms (" + atoms.size() + CMLConstants.S_RBRAK); } for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); Real2 coord = p2Vector.get(i); atom.setX2(coord.getX()); atom.setY2(coord.getY()); } } /** * translate molecule in 2D. * * @param delta2 * add to all 2D coordinates */ public void translate2D(Real2 delta2) { List atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); if (atom.getX2Attribute() != null && atom.getY2Attribute() != null) { atom.setX2(atom.getX2() + delta2.getX()); atom.setY2(atom.getY2() + delta2.getY()); } } } /** multiply all 2D coordinates by given factor. * will usually alter centroid of molecule * * @param scale all 2D coordinates */ public void scale2D(double scale) { List atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); Real2 xy = atom.getXY2(); if (xy != null) { xy = new Real2(xy.multiplyBy(scale)); atom.setXY2(xy); } } } /** * get 2D centroid. * * @return centroid of 2D coords or null */ public Real2 getCentroid2D() { Real2 centroid2D = null; List p2Vector = getVector2D(); if (p2Vector != null) { centroid2D = Real2.getCentroid(p2Vector); } return centroid2D; } /** * translate centroid of atomSet2 to centroid of this. * * will ALTER coords of atomSet2 (should save and restore if required) * * @param atomSet2 * atomSet to overlap * @return shift */ public Real2 overlap2DCentroids(CMLAtomSet atomSet2) { Real2 centroid = this.getCentroid2D(); Real2 centroid2 = atomSet2.getCentroid2D(); Real2 shift = centroid.subtract(centroid2); atomSet2.translate2D(shift); centroid2 = atomSet2.getCentroid2D(); return shift; } /** * get distance matrix. * * @param atomSet2 * @return distance matrix */ public RealMatrix getDistanceMatrix(CMLAtomSet atomSet2) { List coords = this.getVector2D(); List coords2 = atomSet2.getVector2D(); RealMatrix matrix = null; if (coords != null && coords2 != null) { matrix = Real2.getDistanceMatrix(coords, coords2); } return matrix; } /** * Sets chemical element of all atoms in set. * * @param elementType */ public void setChemicalElements(String elementType) { List atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); atom.setElementType(elementType); } } /** * Applies label to all atoms in set. * * @param labelValue * @throws RuntimeException */ public void labelAtoms(String labelValue) { List atoms = this.getAtoms(); if (atoms.size() > 0) { for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); CMLLabel label = new CMLLabel(); label.setCMLValue(labelValue); atom.addLabel(label); } } } /** * creates map from this to atomSet2. sets must be of same length else null * result has owner documnent from this from links == this, to links = * atomSet2 * * @param atomSet2 * other atom set; if null returns null * @return map of both or null */ public CMLMap getMap(CMLAtomSet atomSet2) { CMLMap map = null; List fromAtoms = this.getAtoms(); List toAtoms = atomSet2.getAtoms(); if (atomSet2 != null) { toAtoms = atomSet2.getAtoms(); } if (toAtoms != null && toAtoms.size() == fromAtoms.size()) { map = new CMLMap(); for (int i = 0; i < fromAtoms.size(); i++) { CMLLink link = new CMLLink(); link.setTitle("from getMap"); link.setFrom(fromAtoms.get(i).getId()); link.setTo(toAtoms.get(i).getId()); map.addLink(link); } } return map; } /** * split into atoms sets which contain only single elemenTypes. * * @return atomSetTools mapped by element atomicSymbol (empty map if none) */ public Map splitByElements() { Map map = new HashMap(); List atoms = getAtoms(); for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); String el = atom.getElementType(); CMLAtomSet atomSet = map.get(el); if (atomSet == null) { atomSet = new CMLAtomSet(); map.put(el, atomSet); } atomSet.addAtom(atom); } return map; } /** * get matched atom. does not work with sets * * if atom id="a1" and link to="a1" from="b1" and toFrom = Direction.FROM * then will return atom id="b1" in atomSet1 * * @param atom0 * atom to search with. Its id must occur in a single toFrom * attribute * @param map * with links * @param toFrom * specifies attribute for target atom * @return mapped atom or null */ public CMLAtom getMappedAtom(CMLMap map, CMLAtom atom0, Direction toFrom) { CMLAtom targetAtom = null; String targetId = (atom0 == null || map == null) ? null : map.getRef( atom0.getId(), toFrom); if (targetId != null) { targetAtom = this.getAtomById(targetId); } return targetAtom; } /** * get matched atomSet. * * iterates through atomSet0 finding matches in atomSet1. * * if atomSet1 = {a0, a1, a2, a3} and atomSet1 = {b2, b3, b4} and link * to="a1" from="b1" link to="a2" from="b2" link to="a3" from="b3" link * to="a4" from="b4" and toFrom = Direction.FROM then will return {a2, a3} * * @param map * to search with. Its ids must occur in toFrom attributes * @param atomSet1 * containing result atoms * @param toFrom * specifies attribute for target atom * @return mapped atomSet or null */ // FIXME not checked public CMLAtomSet getMappedAtomSet(CMLMap map, CMLAtomSet atomSet1, Direction toFrom) { CMLAtomSet targetAtomSet = new CMLAtomSet(); List atoms1 = this.getAtoms(); for (CMLAtom atom0 : atoms1) { CMLAtom targetAtom = null; String targetId = (atom0 == null) ? null : map.getRef( atom0.getId(), toFrom); if (targetId != null) { targetAtom = atomSet1.getAtomById(targetId); targetAtomSet.addAtom(targetAtom); } } return targetAtomSet; } /** * remove any atoms which occur in Direction.FROM or Direction.TO links.. * probably works with sets * * @param map * from links may point * @param toAtomSet * to which to links may point * @throws RuntimeException * atom not in set */ public void removeAtoms(CMLMap map, CMLAtomSet toAtomSet) { this.removeAtoms(map, Direction.FROM); toAtomSet.removeAtoms(map, Direction.TO); } /** * remove any atoms which occur in links.. * * @param map * to which from/to links may point * @param control * Direction.TO or Direction.FROM controls which end of link to * use * @throws RuntimeException */ public void removeAtoms(CMLMap map, Direction control) { for (String ref : map.getRefs(control)) { this.removeAtomById(ref); } } public void setMolecule(CMLMolecule molecule) { this.molecule = molecule; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLAtomType.java000077500000000000000000000033131477224461000261310ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting atomType. * autogenerated from schema use as * a shell which can be edited * */ public class CMLAtomType extends AbstractAtomType { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLAtomType() { } /** * constructor. * * @param old */ public CMLAtomType(CMLAtomType old) { super((AbstractAtomType) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLAtomType(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLAtomType */ public CMLElement makeElementInContext(Element parent) { return new CMLAtomType(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLAtomTypeList.java000077500000000000000000000032471477224461000267730ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting atomTypeList. * autogenerated from schema * use as a shell which can be edited * */ public class CMLAtomTypeList extends AbstractAtomTypeList { /** * constructor. */ public CMLAtomTypeList() { } /** * constructor. * * @param old */ public CMLAtomTypeList(CMLAtomTypeList old) { super((AbstractAtomTypeList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLAtomTypeList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLAtomTypeList */ public CMLElement makeElementInContext(Element parent) { return new CMLAtomTypeList(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLAtomicBasisFunction.java000077500000000000000000000106551477224461000303020ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.element.CMLBasisSet.Basis; import org.xmlcml.molutil.ChemicalElement; /** * user-modifiable class supporting atomicBasisFunction. * autogenerated from * schema use as a shell which can be edited * */ public class CMLAtomicBasisFunction extends AbstractAtomicBasisFunction { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLAtomicBasisFunction() { } /** * constructor. * * @param old */ public CMLAtomicBasisFunction(CMLAtomicBasisFunction old) { super((AbstractAtomicBasisFunction) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLAtomicBasisFunction(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLAtomicBasisFunction */ public CMLElement makeElementInContext(Element parent) { return new CMLAtomicBasisFunction(); } /** * create from components. * * @param l * quantum * @param m * quantum * @param n * quantum * @param lm * @param symbol * @param atomRef */ public CMLAtomicBasisFunction(int l, int m, int n, String lm, String symbol, String atomRef) { this(); this.setL(l); this.setM(m); this.setN(n); this.setLm(lm); this.setSymbol(symbol); this.setAtomRef(atomRef); } /** * get ordered list of ABFs for atom. uses basis and element to generate * list in order * * @param atom * @param basis * @return atomicBasisFuctions */ public static List getABFList(CMLAtom atom, Basis basis) { List abfList = new ArrayList(); if (atom != null && atom.getId() != null) { ChemicalElement element = ChemicalElement.getChemicalElement(atom .getElementType()); if (element != null) { if (basis.equals(Basis.MINIMAL)) { int n = element.getPeriod(); int m = 0; int l = 0; String id = atom.getId(); abfList.add(new CMLAtomicBasisFunction(l, m, n, "s", "s", id)); if (n > 1) { abfList.add(new CMLAtomicBasisFunction(l, m, n, "px", "px", id)); m = -1; abfList.add(new CMLAtomicBasisFunction(l, m, n, "py", "py", id)); m = 1; abfList.add(new CMLAtomicBasisFunction(l, m, n, "pz", "pz", id)); } } else { // } } } return abfList; } /** * simple string representation. concatenates n, lm, symbol and atom, * example 2s(s'), 3dx2-y2(DX2Y2) * * @return string */ public String getString() { String s = CMLConstants.S_EMPTY + getN() + getLm() + CMLConstants.S_LBRAK + getSymbol() + ")(" + getId() + CMLConstants.S_RBRAK; return s; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLAxis.java000077500000000000000000000003651477224461000252770ustar00rootroot00000000000000package org.xmlcml.cml.element; public interface CMLAxis { enum AxisType { X, Y, Z } void setMultiplierToData(double m); void setConstantToData(double c); AxisType getAxisType(); void addArray(AbstractArray array); } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLBand.java000077500000000000000000000031271477224461000252360ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting band. * autogenerated from schema use as a * shell which can be edited * */ public class CMLBand extends AbstractBand { /** * constructor. */ public CMLBand() { } /** * constructor. * * @param old */ public CMLBand(CMLBand old) { super((AbstractBand) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLBand(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLBand */ public CMLElement makeElementInContext(Element parent) { return new CMLBand(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLBandList.java000077500000000000000000000031771477224461000260770ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting bandList. * autogenerated from schema use as * a shell which can be edited * */ public class CMLBandList extends AbstractBandList { /** * constructor. */ public CMLBandList() { } /** * constructor. * * @param old */ public CMLBandList(CMLBandList old) { super((AbstractBandList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLBandList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLBandList */ public CMLElement makeElementInContext(Element parent) { return new CMLBandList(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLBasisSet.java000077500000000000000000000234621477224461000261130ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.molutil.ChemicalElement; /** * user-modifiable class supporting basisSet. * autogenerated from schema use as * a shell which can be edited * */ public class CMLBasisSet extends AbstractBasisSet { /** * common basis sets. currently only minimal * * @author pmr * */ public enum Basis { /** valence only */ MINIMAL("minimal", "H s else s+3p"); /** value used for comparison with document */ public String value; /** description */ public String desc; private Basis(String value, String desc) { this.value = value; this.desc = desc; } } /** molecule to which this set applies */ CMLMolecule molecule = null; /** basis to which this set applies */ Basis basis = null; /** atomic orbital coefficients. */ CMLEigen coefficients = null; /** * constructor. */ public CMLBasisSet() { } /** * constructor. * * @param old */ public CMLBasisSet(CMLBasisSet old) { super((AbstractBasisSet) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLBasisSet(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLBasisSet */ public CMLElement makeElementInContext(Element parent) { return new CMLBasisSet(); } /** * constructor. * * @param basis * to use * @param molecule * to use */ public CMLBasisSet(Basis basis, CMLMolecule molecule) { this.basis = basis; this.molecule = molecule; } /** * get all ABFs that contain a given l value. * * @param l * the principal quantum number * @return all ABFs that have this value of l */ public List getABFsByL(int l) { List abfList = new ArrayList(); CMLElements abChildList = this .getAtomicBasisFunctionElements(); for (CMLAtomicBasisFunction abf : abChildList) { if (abf.getLAttribute() != null && abf.getL() == l) { abfList.add(abf); } } return abfList; } /** * get all ABFs that contain a given m value. * * @param m * quantum number * @return all ABFs that have this value of m */ public List getABFsByM(int m) { List abfList = new ArrayList(); CMLElements abChildList = this .getAtomicBasisFunctionElements(); for (CMLAtomicBasisFunction abf : abChildList) { if (abf.getMAttribute() != null && abf.getM() == m) { abfList.add(abf); } } return abfList; } /** * get all ABFs that contain a given n value. * * @param n * quantum number * @return all ABFs that have this value of n */ public List getABFsByN(int n) { List abfList = new ArrayList(); CMLElements abChildList = this .getAtomicBasisFunctionElements(); for (CMLAtomicBasisFunction abf : abChildList) { if (abf.getNAttribute() != null && abf.getN() == n) { abfList.add(abf); } } return abfList; } /** * get all ABFs that contain a given lm value. * * @param lm * quantum number * @return all ABFs that have this value of lm (empty if lm is null) */ public List getABFsByLM(String lm) { List abfList = new ArrayList(); CMLElements abChildList = this .getAtomicBasisFunctionElements(); for (CMLAtomicBasisFunction abf : abChildList) { if (lm.equals(abf.getLm())) { abfList.add(abf); } } return abfList; } /** * get all ABFs that contain a given symbol. * * @param symbol * @return all ABFs that have this symbol (empty if symbol is null) */ public List getABFsBySymbol(String symbol) { List abfList = new ArrayList(); if (symbol != null) { CMLElements abChildList = this .getAtomicBasisFunctionElements(); for (CMLAtomicBasisFunction abf : abChildList) { if (symbol.equals(abf.getSymbol())) { abfList.add(abf); } } } return abfList; } /** * sets molecule. required if atomic orbitals are required for each atom * * @param mol * molecule corresponding to */ public void setMolecule(CMLMolecule mol) { this.molecule = mol; } /** * sets basis. required if calculating electrons * * @param basis */ public void setBasis(Basis basis) { this.basis = basis; } /** * set atomic orbital coefficients. * * @param coefficients * @throws RuntimeException * wrong size */ public void setMolecularOrbitalCoefficients(CMLEigen coefficients) { if (this.getAtomicBasisFunctionElements().size() != coefficients .getSize()) { throw new RuntimeException("Number of orbitals (" + this.getAtomicBasisFunctionElements().size() + ") inconsistent with size of matrix (" + coefficients.getSize() + S_RBRAK); } this.coefficients = coefficients; } /** * create basis set. requires molecule to have been set * * @return basisSet of null if molecule not set */ CMLBasisSet createBasisSet() { CMLBasisSet basisSet = null; if (molecule != null && basis != null) { basisSet = new CMLBasisSet(); List atoms = molecule.getAtoms(); if (basis.equals(Basis.MINIMAL)) { for (CMLAtom atom : atoms) { List abfList = CMLAtomicBasisFunction .getABFList(atom, basis); for (CMLAtomicBasisFunction abf : abfList) { basisSet.addAtomicBasisFunction(abf); } } } else { throw new RuntimeException("Unsupported basis set " + basis.value); } } return basisSet; } /** * generates the number of electrons. requires molecule to have been set * uses the basis set to count the electrons. Thus a minimal basis set for * the first 2 rows will count just the valence electrond (H=1, Li=1, ... * F=7) and adjust for overall charge. * * @throws RuntimeException * unsupported basis * @return electron count or 0 if molecule or basis not set */ public int getElectronCount() { int count = 0; if (molecule != null && basis != null) { List atoms = molecule.getAtoms(); for (CMLAtom atom : atoms) { if (basis.equals(Basis.MINIMAL)) { ChemicalElement element = atom.getChemicalElement(); int nValence = element.getValenceElectrons(); count += nValence; } else { throw new RuntimeException("Basis set not supported: " + basis); } } if (molecule.getFormalChargeAttribute() != null) { count -= molecule.getFormalCharge(); } } return count; } /** * simple string representation. concatenates basis and then lists ABFs * * @return string */ public String getString() { StringBuffer sb = new StringBuffer("basis: " + basis + "\n"); CMLElements abfList = this .getAtomicBasisFunctionElements(); for (int i = 0; i < abfList.size(); i++) { sb.append(abfList.get(i).getString()); if (i < abfList.size() - 1) { sb.append("\n"); } } return sb.toString(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLBond.java000077500000000000000000000624171477224461000252630ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Attribute; import nu.xom.Element; import nu.xom.Node; import nu.xom.ParentNode; import org.apache.log4j.Logger; import org.xmlcml.cml.attribute.IdAttribute; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Real2; import org.xmlcml.molutil.ChemicalElement; /** * user-modifiable class supporting this. * autogenerated from schema use as a * shell which can be edited * */ public class CMLBond extends AbstractBond { /** namespaced element name.*/ public final static String NS = C_E+TAG; /// bond orders // 1 should be normalized into S public final static String DEPRECATED_SINGLE = "1"; // 2 should be normalized into D public final static String DEPRECATED_DOUBLE = "2"; // 3 should be normalized into T public final static String DEPRECATED_TRIPLE = "3"; /** messages.*/ public enum Message { /** no grandparent */ NULL_GRANDPARENT("null grandparent for bond"), ; /** value.*/ public String value; private Message(String s) { value = s; } } final static Logger logger = Logger.getLogger(CMLBond.class); /** unspecified bond */ public final static String UNKNOWN_ORDER = "UNK"; /** single bond */ private /*public*/ final static String SINGLE = "1"; public final static String SINGLE_NORM = SINGLE; /** double bond */ private /*public*/ final static String DOUBLE = "2"; public final static String DOUBLE_NORM = DOUBLE; /** triple bond */ private /*public*/ final static String TRIPLE = "3"; public final static String TRIPLE_NORM = TRIPLE; /** single bond */ public final static String SINGLE_S = "S"; /** double bond */ public final static String DOUBLE_D = "D"; /** triple bond */ public final static String TRIPLE_T = "T"; /** aromatic bond */ public final static String AROMATIC = "A"; // same as SMILES /** zero bond (disjoint == CMLConstants.S_PERIOD in SMILES) */ public final static String ZERO = CMLConstants.S_PERIOD; /** wedge bond */ public final static String WEDGE = "W"; /** hatch bond */ public final static String HATCH = "H"; /** bold bond */ public final static String QUERY_BOLD = "BOLD?"; /** parallel hash bond */ public final static String QUERY_HASH = "HASH?"; /** cis bond */ public final static String CIS = "C"; /** trans bond */ public final static String TRANS = "T"; /** linear bond */ public final static String LINEAR = "L"; /** nostereo bond */ public final static String NOSTEREO = CMLConstants.S_MINUS; /** acyclic bond */ public final static String ACYCLIC = "ACYCLIC"; /** cyclic bond */ public final static String CYCLIC = "CYCLIC"; /** unknown cyclicity bond */ public final static String CYCLIC_UNKNOWN = "UNK"; /** attribute denoting cyclic nature. * */ public final static String USER_CYCLIC = "userCyclic"; /** bond type */ public final static String[] bondType = { SINGLE, DOUBLE, TRIPLE, AROMATIC, ZERO, WEDGE, HATCH, NOSTEREO, }; public static final double[] bondOrders = { 1.0, 2.0, 3.0, 1.5, 0.0, 1.0, 1.0, 1.0, }; public final static String HASH_SYMB = CMLConstants.S_UNDER+S_UNDER; public final static String BOND_LINK = CMLConstants.S_MINUS; List atomList; /** * no-arg constructor. This should not normally be used in applications as * it does not enforce atom and molecule references. Use CMLBond(CMLAtom, * CMLAtom) or molecule.createAndAddBond(...); * */ public CMLBond() { super(); } /** preferred constructor. * @param id * @param atom1 * @param atom2 * @throws RuntimeException * if atoms are null, identical or don't have molecule owner or * have different molecule owners.or don't have ids. */ public CMLBond(String id, CMLAtom atom1, CMLAtom atom2) throws RuntimeException { this(atom1, atom2); this.setId(id); } /** Constructor. * @param id * @param atom1 * @param atom2 * @param order * @throws RuntimeException * if atoms are null, identical or don't have molecule owner or * have different molecule owners.or don't have ids. */ public CMLBond(String id, CMLAtom atom1, CMLAtom atom2, String order) throws RuntimeException { this(id, atom1, atom2); setOrder(order); } /** * normal constructor. * * @param atom1 * @param atom2 * @throws RuntimeException * if atoms are null, identical or don't have molecule owner or * have different molecule owners.or don't have ids. */ public CMLBond(CMLAtom atom1, CMLAtom atom2) throws RuntimeException { super(); if (atom1 == null || atom2 == null) { throw new RuntimeException("Atoms in bond muct not be null"); } if (atom1 == atom2) { throw new RuntimeException("Atoms in bond must be distinct: "+atom1.getId()+", "+atom2.getId()); } if (atom1.getMolecule() == null || atom2.getMolecule() == null) { throw new RuntimeException( "Atoms in bond must have owner molecules"); } if (!atom1.getMolecule().equals(atom2.getMolecule())) { throw new RuntimeException( "Atoms in bond must have identical owner molecule"); } String atomId1 = atom1.getId(); String atomId2 = atom2.getId(); if (atomId1 == null || atomId2 == null) { throw new RuntimeException("Atoms in bond must have ids"); } this.setAtomRefs2(new String[] { atomId1, atomId2 }); } /** * constructor. * * @param atom1 * @param atom2 * @param order * @throws RuntimeException * if atoms are null, identical or don't have molecule owner or * have different molecule owners.or don't have ids. */ public CMLBond(CMLAtom atom1, CMLAtom atom2, String order) throws RuntimeException { this(atom1, atom2); setOrder(order); } /** * copy constructor. * * @param old * to copy */ public CMLBond(CMLBond old) { super((AbstractBond) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLBond(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLBond */ public CMLBond makeElementInContext(Element parent) { CMLBond bond = null; if (parent == null) { bond = new CMLBond(); } else if (parent instanceof CMLBondArray) { Element grandParent = (Element) parent.getParent(); if (!(grandParent instanceof CMLMolecule)) { throw new RuntimeException("Bond needs molecule grandparent"); } else { bond = new CMLBond(); } } else { throw new RuntimeException("Bond needs bondArray parent"); } return bond; } /** * callback when constructing from XML. manages atomRefs2 * * @param parent * element */ public void finishMakingElement(Element parent) { getMolecule(); // check attributes are present if (this.getAtomRefs2() != null) { } else if (this.getAtomRefs() != null) { } else { throw new RuntimeException("bond must have AtomRefs2 or atomRefs"); } // we need checks that atoms are actually in molecule.. } /** set id. * this will index the bond if it has a parent. * id cannot be reset. * @param id */ public void setId(String id) { /* if (this.getId() != null) { throw new RuntimeException("Cannot reindex id"); } */ super.setId(id); ParentNode parent = this.getParent(); if (parent != null && parent instanceof CMLBondArray) { CMLBondArray bondArray = (CMLBondArray) parent; bondArray.getBondIdMap().put(id, this); } } /*-----------end required for each subclass ------------------*/ /** * gets normalised order. * * since CML allows both "1" and "S" for single, gets a consistent * representation * * @return SINGLE, DOUBLE, etc. as appropriate; null returns null */ public String getOrder() { String order = super.getOrder(); if (order == null) { order = null; } else if (isSingle(order)) { order = CMLBond.SINGLE_S; } else if (isDouble(order)) { order = CMLBond.DOUBLE_D; } else if (isTriple(order)) { order = CMLBond.TRIPLE_T; } else if (order.equals(CMLBond.AROMATIC)) { } else { order = UNKNOWN_ORDER; } return order; } CMLBondArray getBondArray() { ParentNode parent = this.getParent(); return (parent == null || !(parent instanceof CMLBondArray)) ? null : (CMLBondArray) parent; } /** remove bond. * routed to bondArray.removeBond() */ public void detach() { CMLBondArray bondArray = getBondArray(); if (bondArray != null) { bondArray.removeBond(this); } } /** * gets the owner molecule. * * @return the molecule (null if none) */ public CMLMolecule getMolecule() { CMLMolecule molecule = null; Node bondArray = this.getParent(); if (bondArray != null) { Node grandParent = bondArray.getParent(); if (grandParent != null) { if (grandParent instanceof CMLMolecule) { molecule = (CMLMolecule) grandParent; } else { throw new RuntimeException("grandParent of bond is not a molecule: "+grandParent.getClass()); } } else { throw new RuntimeException(Message.NULL_GRANDPARENT.value); } } return molecule; } /** Gets id of n'th atom in bond. * @param i serial of atom * @return id or null */ public String getAtomId(int i) { CMLAtom atom = this.getAtom(i); return (atom == null) ? null : atom.getId(); } /** * Gets n'th atom in bond. * @param i serial of atom * @return atom or null */ public CMLAtom getAtom(int i) { List atomList = this.getAtoms(); return (atomList == null || i < 0 || i >= atomList.size()) ? null : atomList.get(i); } /** Gets a typed List of all the atoms involved in the bond * * @return a list of 2 atoms * @throws RuntimeException * if molecule is null, no atomRefs2 attribute or atom is not in * bond */ public List getAtoms() throws RuntimeException { if (atomList == null) { atomList = new ArrayList(); String[] atomRefs2 = this.getAtomRefs2(); if (atomRefs2 == null) { throw new RuntimeException("bond has no atomRefs2"); } CMLMolecule molecule = this.getMolecule(); if (molecule == null) { throw new RuntimeException("bond has no parent molecule"); } addAtom(atomList, molecule, atomRefs2[0]); addAtom(atomList, molecule, atomRefs2[1]); } return atomList; } /** get calculated bond length. * independent of any CMLLength element that might describe this bond. * @return length (or Double.NaN if impossible) * @deprecated use getBondLength(CoordinateType) */ public double getBondLength() { double d = Double.NaN; List atoms = this.getAtoms(); if (atoms.size() == 2) { d = atoms.get(0).getDistanceTo(atoms.get(1)); } return d; } /** get calculated bond length. * independent of any CMLLength element that might describe this bond. * @return length (or Double.NaN if impossible) */ public double getBondLength(CoordinateType type) { double d = Double.NaN; List atoms = this.getAtoms(); if (atoms.size() == 2) { if (CoordinateType.TWOD.equals(type)) { Real2 xy0 = atoms.get(0).getXY2(); Real2 xy1 = atoms.get(1).getXY2(); d = xy0.getDistance(xy1); } else if (CoordinateType.CARTESIAN.equals(type)) { d = atoms.get(0).getDistanceTo(atoms.get(1)); } else { throw new RuntimeException("Bad type: "+type); } } return d; } private void addAtom(List atomList, CMLMolecule molecule, String id) { CMLAtom atom = molecule.getAtomById(id); if (atom == null) { // CMLMolecule molecule = this.getMolecule(); String molId = (molecule == null) ? null : molecule.getId(); throw new RuntimeException("Non-existent atom in bond : atom/mol " + id+S_SLASH+molId); } atomList.add(atom); } /** gets id of other atom in bond. * * @param id known id * @return the other id (null if id = null) */ public String getOtherAtomId(String id) { String id1 = null; if (id != null) { String[] atomRefs2 = this.getAtomRefs2(); if (atomRefs2 != null) { if (id.equals(atomRefs2[0])) { id1 = atomRefs2[1]; } else if (id.equals(atomRefs2[1])) { id1 = atomRefs2[0]; } else { } } } return id1; } /** gets other atom in bond. * * @param atom * @return the other atom (null if atom = null) */ public CMLAtom getOtherAtom(CMLAtom atom) { CMLAtom otherAtom = null; if (atom != null) { atomList = getAtoms(); if (atomList != null) { int idx = atomList.indexOf(atom); if (idx == -1) { throw new RuntimeException("atom not in bond: "+atom.getId()); } otherAtom = atomList.get(1 - idx); } } return otherAtom; } /** * append string to id. perhaps to identify molecule * * @param s * @param updateRefs */ public void appendToId(String s, boolean updateRefs) { String id = this.getId(); if ((id != null) && (id.length() > 0)) { this.resetId(id + s); if (updateRefs) { String[] refs = this.getAtomRefs2(); if (refs != null) { for (int j = refs.length - 1; j >= 0; --j) { refs[j] += s; } } this.setAtomRefs2(refs); } } } /** adds bond info as ligands to atoms. * * @param bond */ void updateLigands() { List atoms = this.getAtoms(); atoms.get(0).addLigandBond(this, atoms.get(1)); atoms.get(1).addLigandBond(this, atoms.get(0)); } /** sets atomRefs in bond. convenience method * be careful * @param atomId1 * @param atomId2 * @throws RuntimeException */ void setAtomRefs2(String atomId1, String atomId2) throws RuntimeException { this.setAtomRefs2(new String[] { atomId1, atomId2 }); } /** * get hash from two atoms. * * @param atomId1 * @param atomId2 * @return the hash */ public static String atomHash(String atomId1, String atomId2) { if (atomId1 == null || atomId2 == null) { return null; } if (atomId1 == atomId2) { return null; } if (atomId1.compareTo(atomId2) < 0) { String temp = atomId2; atomId2 = atomId1; atomId1 = temp; } return atomId1 + HASH_SYMB + atomId2; } /** * get atom hash. * * @param atomRefs2 * @return atom hash */ public static String atomHash(String[] atomRefs2) { return (atomRefs2 == null) ? null : atomHash(atomRefs2[0], atomRefs2[1]); } /** * uses atomRefs2 to create hash. * * @return null if no atomRefs2 */ public String atomHash() { return atomHash(this.getAtomRefs2()); } /** * get unique hash for pair of atoms. normal use is to identify bond * * @param atom1 * @param atom2 * @return hash string or null */ public static String atomHash(CMLAtom atom1, CMLAtom atom2) { String hash = null; if (atom1 != null && atom2 != null) { hash = atomHash(atom1.getId(), atom2.getId()); } return hash; } /** * get atom hash. * * @param bond * @return hash * @throws RuntimeException * no atomRefs2 attribute */ public static String atomHash(CMLBond bond) throws RuntimeException { String hash = null; if (bond != null) { String[] atomRefs2 = bond.getAtomRefs2(); if (atomRefs2 == null) { throw new RuntimeException("no atomRefs2 attribute"); } hash = atomHash(atomRefs2[0], atomRefs2[1]); } return hash; } /** * set cyclicity. * * @param c * cyclicity (UNKNOWN, ACYCLIC or CYCLIC) */ public void setCyclic(String c) { this.addAttribute(new Attribute(USER_CYCLIC, c)); } /** * get cyclicity. * * @return cyclicity (UNKNOWN, ACYCLIC or CYCLIC) */ public String getCyclic() { return this.getAttributeValue(USER_CYCLIC); } /** * get stereo. * * @return stereo */ public CMLBondStereo getBondStereo() { return (CMLBondStereo) this.getFirstCMLChild(CMLBondStereo.TAG); } /** * set CMLBondStereo child. * * remove any previous CMLBondStereo and then append this one * * @param stereo * to add */ public void setBondStereo(CMLBondStereo stereo) { clearBondStereo(); try { this.addBondStereo(stereo); } catch (Exception e) { throw new RuntimeException("BUG " + e); } } /** * removes all bondStereo children. * */ public void clearBondStereo() { while (this.getBondStereoElements().size() > 0) { this.removeChild(this.getBondStereo()); } } /** * are atoms bonded. is interatom distance less than radius1 + radius2 + * tolerance? * * @param atom1 * @param atom2 * @return true if within sum of radii + tolerance */ public static boolean areWithinBondingDistance(final CMLAtom atom1, final CMLAtom atom2) { List atomList = new ArrayList(2); atomList.add(atom1); atomList.add(atom2); double covd = 0.0; for (CMLAtom atom : atomList) { ChemicalElement el = atom.getChemicalElement(); if (el == null) { throw new RuntimeException("cannot find chemicalElement for atom ("+ atom.getId()+"):"+atom.getElementType()); } double radius = el.getTypeAdjustedCovalentRadius(); covd += radius; } final double dx = atom1.getX3() - atom2.getX3(); final double dy = atom1.getY3() - atom2.getY3(); final double dz = atom1.getZ3() - atom2.getZ3(); final double d2 = dx * dx + dy * dy + dz * dz; double covd2 = covd * covd; //LOG.debug(atom1.getId()+"/"+atom2.getId()+" : d2 "+ // d2+", covd2 "+covd2); return (d2 < covd2); } /** helper function to determinate whether bond contains atom of given elementType. * * @param elementType * @return true if one or more atoms is of this type */ public boolean containsElement(String elementType) { getAtoms(); return atomList.size() == 2 && (atomList.get(0).hasElement(elementType) || atomList.get(1).hasElement(elementType)); } /** * increments bond order by given amount. use with care. Only really useful * when generating bond orders * * @param delta * (should really only be 1 or -1) */ public void incrementOrder(int delta) { String order = this.getOrder(); if (delta == 1) { if (order == null || isSingle(order)) { order = CMLBond.DOUBLE_D; } else if (isDouble(order)) { order = CMLBond.TRIPLE_T; } else if (isTriple(order)) { order = "4"; } else { throw new RuntimeException("Cannot increment bond order " + order); } } else if (delta == 2) { if (order == null) { order = CMLBond.DOUBLE_D; } else if (isSingle(order)) { order = CMLBond.TRIPLE_T; } else if (isDouble(order)) { order = "4"; } else { throw new RuntimeException("Cannot increment bond order " + order); } } else if (delta == -1) { if (order == null) { throw new RuntimeException("Cannot decrement bond order " + order); } else if (isDouble(order)) { order = CMLBond.SINGLE_S; } else if (isTriple(order)) { order = CMLBond.DOUBLE_D; } else { throw new RuntimeException("Cannot decrement bond order " + order); } } else if (delta == 0) { // no-op } else { throw new RuntimeException("Cannot change bond order by " + delta); } this.setOrder(order); } public static boolean isSingle(String order) { return order != null &&(order.equals(CMLBond.SINGLE) || order.equals(CMLBond.SINGLE_S)); } public static boolean isDouble(String order) { return order != null &&(order.equals(CMLBond.DOUBLE) || order.equals(CMLBond.DOUBLE_D)); } public static boolean isTriple(String order) { return order != null &&(order.equals(CMLBond.TRIPLE) || order.equals(CMLBond.TRIPLE_T)); } /** create id for potential bond. * for is atom1.getId()-atom2.getId() * @param atom1 * @param atom2 * @return the id */ public static String createId(CMLAtom atom1, CMLAtom atom2) { String[] atomR2 = new String[2]; atomR2[0] = atom1.getId(); atomR2[1] = atom2.getId(); return createId(atomR2); } private static String createId(String[] atomR2) { return atomR2[0]+BOND_LINK+atomR2[1]; } /** create id for bond. * for is atom1.getId()-atom2.getId() * @return the id */ public String createId() { return createId(this.getAtomRefs2()); } /** string for bond. * * @return the string */ public String getString() { // CMLMolecule molecule = this.getMolecule(); String s = CMLConstants.S_EMPTY; String[] atomRefs2 = this.getAtomRefs2(); if (atomRefs2 != null) { s = atomHash(); // s += atomRefs2[0]+S_UNDER+atomRefs2[1]; } return s; } /** renames atomRef in bond * * no checks are made for uniqueness, etc. not recommended for general use * * @param oldId * the old atomRef id * @param newId * the new atomRef id * @throws RuntimeException * oldId not found in atomRefs2 */ void renameAtomRef(String oldId, String newId) { String[] atomRefs2 = this.getAtomRefs2(); // int idx = atomRefs2.indexOf(S_SPACE); // String atomRef0 = atomRefs2.substring(0, idx); // String atomRef1 = atomRefs2.substring(idx+1); String newAtomRef0 = CMLConstants.S_EMPTY; String newAtomRef1 = CMLConstants.S_EMPTY; if (oldId.equals(atomRefs2[0])) { newAtomRef0 = newId; newAtomRef1 = atomRefs2[1]; } else if (oldId.equals(atomRefs2[1])) { newAtomRef0 = atomRefs2[0]; newAtomRef1 = newId; } else { throw new RuntimeException("Cannot find find atomRef: " + oldId + " in atomRefs2: " + atomRefs2); } // getMolecule().moleculeBonds.reKeyBond(this, newAtomRef0, // newAtomRef1); this.setAtomRefs2(new String[] { newAtomRef0, newAtomRef1 }); } /** new id and set it. * * @return the id */ public String generateAndSetId() { String bondId = this.getId(); if (bondId != null) { this.removeAttribute(IdAttribute.NAME); } List atomListx = this.getAtoms(); String at0id = atomListx.get(0).getId(); String at1id = atomListx.get(1).getId(); bondId = at0id + CMLConstants.S_UNDER + at1id; this.setId(bondId); return bondId; } public void swapAtomsInBond(CMLAtom atom0, CMLAtom atom1) { this.setAtomRefs2(new String[] { atom1.getId(), atom0.getId() }); } public void swapAtomsInBond() { this.setAtomRefs2(new String[] { this.getAtomRefs2()[1], this.getAtomRefs2()[0] }); } /** * @return the length given by 2D coordinates * @throws RuntimeException if not computable (no coord, missing atoms...) */ public double calculateBondLength3D() { return calculateBondLength(CoordinateType.CARTESIAN); } /** * @return the length given by 3D coordinates * @throws RuntimeException if not computable (no coord, missing atoms...) */ public double calculateBondLength2D() { return calculateBondLength(CoordinateType.TWOD); } /** * get bond length. * * uses 3D atom coordinates, else 2D atom coordinates, to generate length * * @param type * @return the length * @throws RuntimeException if not computable (no coord, missing atoms...) */ public double calculateBondLength(CoordinateType type) { CMLAtom atom0 = null; CMLAtom atom1 = null; List atomList = getAtoms(); atom0 = atomList.get(0); atom1 = atomList.get(1); if (atom0 == null || atom1 == null) { throw new RuntimeException("missing atoms"); } double length = -1.0; if (type.equals(CoordinateType.CARTESIAN)) { length = calculateLength3D(atom0, atom1); } else if (type.equals(CoordinateType.TWOD)) { length = calculateLength2D(atom0, atom1); } return length; } private double calculateLength2D(CMLAtom atom0, CMLAtom atom1) { double length; Real2 p0 = atom0.getXY2(); Real2 p1 = atom1.getXY2(); if (p0 == null || p1 == null) { throw new RuntimeException( "atoms do not have 2D coordinates"); } length = p0.getDistance(p1); return length; } private double calculateLength3D(CMLAtom atom0, CMLAtom atom1) { double length; Point3 p0 = atom0.getXYZ3(); Point3 p1 = atom1.getXYZ3(); if (p0 == null || p1 == null) { throw new RuntimeException( "atoms do not have 3D coordinates"); } length = p0.getDistanceFromPoint(p1); return length; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLBondArray.java000077500000000000000000000256671477224461000262700ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import nu.xom.Element; import nu.xom.ParentNode; import org.apache.log4j.Logger; import org.xmlcml.cml.base.CMLElements; /** * class supporting bondArray. * * autogenerated from schema use * bondArray manages the bonds in the parent molecule. * it always indexes them by atom hash (from atomRefs2) and * will also index by id if present. * */ public class CMLBondArray extends AbstractBondArray { private static Logger LOG = Logger.getLogger(CMLBondArray.class); /** namespaced element name.*/ public final static String NS = C_E+TAG; /** messages.*/ public enum Message { /** no parent for bondArray*/ NULL_BONDARRAY_PARENT("null bondArray parent"), ; /** value.*/ public String value; private Message(String s) { value = s; } } /** map of bond ids to bonds.*/ Map bondIdMap; /** map of atomRefs2 to bonds.*/ Map bondMap; // static int count = 0; /** * constructor. */ public CMLBondArray() { super(); init(); } private void init() { bondMap = new HashMap(); bondIdMap = new HashMap(); } /** * copy constructor. * NOTE: this will NOT index the bonds. This is dealt with in * the Molecule copy costructor * @param old */ public CMLBondArray(CMLBondArray old) { super((AbstractBondArray) old); init(); } /** * copy node . * * @return Node */ public Element copy() { return new CMLBondArray(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLBond */ public CMLBondArray makeElementInContext(Element parent) { CMLBondArray bondArray = new CMLBondArray(); return bondArray; } /** finish making element. * * @param parent * element */ public void finishMakingElement(Element parent) { super.finishMakingElement(parent); // this is here because the parser doesn't route through the // addBond indexBonds(); } /** adds a bond. * reroutes to addBond(bond) * @param bond to add * @return added bond or null * @throws RuntimeException if already child or duplicate hash */ public CMLBond appendChild(CMLBond bond) { CMLBond bond0 = this.addBond(bond); return bond0; } /** get number of child bonds. * * @return count */ public int size() { return this.getBondElements().size(); } /** adds a bond. * * cannot add bond unless bondArray already is child of molecule. * otherwise it doesn't know how to reference atoms * @param bond to add * @return added bond or null * @throws RuntimeException if already child or duplicate hash or not part of molecule */ public CMLBond addBond(CMLBond bond) { int count = this.getChildCount(); return this.insertBond(bond, count); } /** * adds a bond. * will fail if bondArray is not child of molecule * @param bond to add * @param pos position (see insertChild) * @return added bond or null * @throws RuntimeException if already child or duplicate hash */ public CMLBond insertBond(CMLBond bond, int pos) { ParentNode parent = bond.getParent(); CMLBond addedBond = null; if (parent != null) { if (parent.equals(this)) { throw new RuntimeException("bond already added "+bond.getString()); } } else { if (this.getMolecule() == null) { throw new RuntimeException("bondArray parent must be molecule"); } } this.insertChild(bond, pos); addedBond = indexBondAndLigands(bond); indexBondId(bond); return addedBond; } private CMLBond indexBondAndLigands(CMLBond bond) { CMLBond addedBond = null; String hash = CMLBond.atomHash(bond); if (hash != null) { if (bondMap.containsKey(hash)) { String molId = (bond.getMolecule() == null) ? null : bond.getMolecule().getId(); throw new RuntimeException("bond already in array "+bond.getId()+S_SLASH+hash+S_SLASH+molId); } bondMap.put(hash, bond); addedBond = bond; bond.updateLigands(); } return addedBond; } private void indexBondId(CMLBond bond) { String id = bond.getId(); if (id != null && !"".equals(id.trim())) { if (bondIdMap.containsKey(id)) { throw new RuntimeException("bond already in id map "+bond.getId()+S_SLASH+bond.getMolecule().getId()); } bondIdMap.put(id, bond); } } /** index all the bonds by atom hash. * and by bond id */ public void indexBonds() { CMLMolecule molecule = this.getMolecule(); if (molecule == null) { throw new RuntimeException("Cannot index bonds without molecule"); } CMLAtomArray atomArray = molecule.getAtomArray(); if (atomArray == null) { throw new RuntimeException("Cannot index bonds without atoms"); } atomArray.clearLigandInfo(); List bonds = this.getBonds(); bondMap.clear(); bondIdMap.clear(); for (CMLBond bond : bonds) { try { indexBondAndLigands(bond); indexBondId(bond); } catch (RuntimeException e) { LOG.trace("BUG: SKIPPED BOND (maybe coincident)"+e); } } } /** get parent molecule. * * @return null if no parent or parent is not molecule */ public CMLMolecule getMolecule() { CMLMolecule molecule = null; ParentNode parent = this.getParent(); if (parent != null && parent instanceof CMLMolecule) { molecule = (CMLMolecule) parent; } return molecule; } @SuppressWarnings("unused") private CMLAtomArray getAtomArray() { CMLMolecule molecule = this.getMolecule(); return (molecule == null) ? null : molecule.getAtomArray(); } /** adds bond info as ligands to atoms. * * @param bond */ void updateLigands() { List bondList = this.getBonds(); for (CMLBond bond : bondList) { bond.updateLigands(); } } /** removes a bond. * reroutes to removeBond(bond) * @param bond to remove * @return removed bond or null * @throws RuntimeException */ public CMLBond removeChild(CMLBond bond) { return this.removeBond(bond); } /** * removes a bond. * * @param bond * @return deleted bond or null */ public CMLBond removeBond(CMLBond bond) { CMLBond deletedBond = null; if (bond != null && this.equals(bond.getParent())) { List atoms = bond.getAtoms(); if (atoms != null) { int err = 0; if (atoms.size() == 2) { try { atoms.get(0).clearLigandInfo(bond, atoms.get(1)); } catch (RuntimeException e) { err++; } try { atoms.get(1).clearLigandInfo(bond, atoms.get(0)); } catch (RuntimeException e) { err++; } if (err > 0) { System.err.println("trouble removing ligands of "+bond.getString()); } } else { ;// when we have failed to add bond } } else { ; // is this an error? } super.removeChild(bond); this.getBondMap().remove(CMLBond.atomHash(bond)); this.getBondIdMap().remove(bond.getId()); } return deletedBond; } /** get map of bond hash to bonds. * * @return map */ public Map getBondMap() { if (bondMap == null) { bondMap = new HashMap(); } return bondMap; } /** get map of bond id to bonds. * * @return map */ public Map getBondIdMap() { if (bondIdMap == null) { bondIdMap = new HashMap(); } return bondIdMap; } /** get list of bonds in order. * * @return bonds */ public List getBonds() { List bondList = new ArrayList(); CMLElements bonds = this.getBondElements(); for (CMLBond bond : bonds) { bondList.add(bond); } return bondList; } /** get bond by hash. * * @param hash * @return bond or null */ public CMLBond getBondByHash(String hash) { return bondMap.get(hash); } /** get bond by atomRefs2. * * @param atomRefs2 * @return bond or null */ public CMLBond getBondByAtomRefs2(String[] atomRefs2) { return bondMap.get(CMLBond.atomHash(atomRefs2)); } /** get bond by id. * * @param id * @return bond or null */ public CMLBond getBondById(String id) { return (bondIdMap == null) ? null : bondIdMap.get(id); } /** reroute to molecule.removeBondArray(). * */ public void detach() { ParentNode parent = this.getParent(); if (parent != null && parent instanceof CMLMolecule) { CMLMolecule molecule = (CMLMolecule) parent; molecule.removeBondArray(); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLBondSet.java000077500000000000000000000427721477224461000257410ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import nu.xom.Element; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.euclid.Util; /** * user-modifiable class supporting bondSet. * autogenerated from schema use as * a shell which can be edited * */ public class CMLBondSet extends AbstractBondSet { /** namespaced element name.*/ public final static String NS = C_E+TAG; protected Set set = new LinkedHashSet(); protected HashMap idTable; protected Map atomRefs2Table; protected CMLMolecule molecule = null; /** * default constructor. * */ public CMLBondSet() { super(); init(); } /** * copy constructor. * * @param old */ public CMLBondSet(CMLBondSet old) { super(old); init(); // copy bond references for (CMLBond bond : old.set) { this.addBond(bond); } } /** * copy node . * * @return Node */ public Element copy() { return new CMLBondSet(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLBond */ public CMLElement makeElementInContext(Element parent) { return new CMLBondSet(); } /** * creates bondSet from list of bond IDs. * * useful when the ids have been produced elsewhere * * @param ids * the ids to use * @throws RuntimeException * cannot find bond with id */ // public CMLBondSet(/*CMLMolecule mol, */String[] ids) // { // CMLBondSet bondSet = this.getBondsById(ids); // this.addBondSet(bondSet); // } /** * create from a molecule. gets all bonds in the molecule * * @param mol * the molecule */ public CMLBondSet(CMLMolecule mol) { this(); try { for (CMLBond bond : mol.getBonds()) { this.addBond(bond); } } catch (Exception e) { ; } } /** * creates bondSet from list of bonds. * * @param bonds must all be in same molecule * */ public CMLBondSet(List bonds) { this(); addBonds(bonds); } /** adds bonds. * fragile. May or may not be a good idea. * @param bonds * @return new bondSet */ public static CMLBondSet createFromBonds(List bonds) { CMLBondSet bondSet = new CMLBondSet(); bondSet.addBonds(bonds); return bondSet; } /** * creates bondSet from list of bonds. * * @param bonds * must all be in same molecule * @throws RuntimeException * one or more bonds has no id * */ public CMLBondSet(CMLBond[] bonds) throws RuntimeException { this(); addBonds(bonds); } void init() { set = new LinkedHashSet(); idTable = new HashMap(); setSize(0); setXMLContent(S_EMPTY); } /** bondSet from a molecule with bondIds. * * @param mol the molecule * @param bondId the ids */ public CMLBondSet(CMLMolecule mol, String[] bondId) { this(); for (int i = 0; i < bondId.length; i++) { CMLBond bond = mol.getBondById(bondId[i]); if (bond != null) { this.addBond(bond); } } } /** * add bobds to bond set. * * @param bonds * to add */ public void addBonds(CMLBond[] bonds) { if (bonds != null) { for (CMLBond b : bonds) { this.addBond(b); } } } /** * create from List of bonds. * * @param bonds * to add * @throws RuntimeException * one or more bonds has no id */ public void addBonds(List bonds) throws RuntimeException { for (CMLBond b : bonds) { this.addBond(b); } } /** * adds bond to set. * * @param bond * to add (if null throws Exception) * @throws RuntimeException * Bond must have id or duplicate bond */ public void addBond(CMLBond bond) throws RuntimeException { /* * set.add(bond); idTable.put(bond.getId(), bond); */ if (bond == null) { throw new RuntimeException("Cannot add null bond"); } else if (set.contains(bond)) { throw new RuntimeException("duplicate bond in bondSet: " + bond.getId()); } else { set.add(bond); if (idTable == null) { idTable = new HashMap(); } if (atomRefs2Table == null) { atomRefs2Table = new HashMap(); } String id = bond.getId(); if (id == null) { throw new RuntimeException("Bond in bondSet must have id"); } if (this.getBondById(id) != null) { throw new RuntimeException("duplicate bond in bondSet: " + id); } else { } idTable.put(bond.getId(), bond); addBondId(bond.getId()); atomRefs2Table.put(CMLBond.atomHash(bond), bond); } } void addBondId(String id) { String[] content = {}; int size = 0; if (this.getSizeAttribute() != null) { content = this.getXMLContent(); size = this.getSize(); } this.setXMLContent(Util.addElementToStringArray(content, id)); this.setSize(size + 1); } /** * adds bondSet to set. * * @param bondSet * to add * @throws RuntimeException * duplicate bond (should use boolean operations) */ public void addBondSet(CMLBondSet bondSet) throws RuntimeException { addBonds(bondSet.getBonds()); } /** * gets i'th bond in set. * @param i serial * @return the bond */ public CMLBond getBond(int i) { List bondList = this.getBonds(); return (bondList == null || i < 0 || i >= bondList.size()) ? null : bondList.get(i); } /** gets all bonds in set. * * @return the bonds */ public List getBonds() { List bonds = new ArrayList(); for (CMLBond bond : set) { bonds.add(bond); } return bonds; } /** gets all atoms in set as atomSet. * * @return the atomSet */ public CMLAtomSet getAtomSet() { getMolecule(); List bonds = getBonds(); CMLAtomSet atomSet = new CMLAtomSet(); for (CMLBond bond : bonds) { List atoms = null; atoms = bond.getAtoms(); atomSet.addAtoms(atoms); } return atomSet; } /** * does bondSet contain bond. * * @param bond * * @return true if contains bond */ public boolean contains(CMLBond bond) { return set.contains(bond); } /** * gets size of set. * * @return the size */ public int size() { getBonds(); return set.size(); } /** * gets all ids of bonds. * * @return the bondIds */ public List getBondIDs() { List bonds = getBonds(); List bondIDs = new ArrayList(); if (bonds != null) { for (CMLBond bond : bonds) { bondIDs.add(bond.getId()); } } return bondIDs; } /** * gets bonds by ids. * * @param ids * the ids * @return the bonds * @throws RuntimeException * cannot find bond for id or incomplete bond info */ public CMLBondSet getBondsById(String[] ids) throws RuntimeException { CMLBondSet bondSet = new CMLBondSet(); for (String id : ids) { CMLBond bond = this.getBondById(id); if (bond != null) { bondSet.addBond(bond); } else { throw new RuntimeException("Cannot find bond: " + id); } } return bondSet; } /** * gets bond by id. * * @param id * @return the bond */ public CMLBond getBondById(String id) { return idTable.get(id); } /** * compare two bond sets for content. * * compare unordered bonds * @param otherBondSet to compare. * * @return true if identical and non null */ public boolean hasContentEqualTo(CMLBondSet otherBondSet) { boolean result = false; if (otherBondSet != null && this.size() == otherBondSet.size()) { CMLBondSet bondSet = this.complement(otherBondSet); result = bondSet.size() == 0; } return result; } /** * Returns complement of this bondSet with another. * * Creates new bondSet containing the bonds that are in this bondSet, and * not the one supplied. *

* eg. as1 = {a1, a2, a3}; as2 = {a2, a4}
* (as1) complement (as2) = {a1, a3}
* (as2) complement (as1) = {a4} * * @param bondSet2 bondSet to complement; if null assumed empty * @return bondSet */ public CMLBondSet complement(CMLBondSet bondSet2) { if (bondSet2 == null) { return this; } CMLBondSet newBondSet = new CMLBondSet(); List bonds = this.getBonds(); for (int i = 0; i < bonds.size(); i++) { if (!bondSet2.contains(bonds.get(i))) { newBondSet.addBond(bonds.get(i)); } } return newBondSet; } /** * Returns union of this bondSet with another. * * Creates new bondSet containing the bonds that are in this bondSet, and/or * the one supplied. (Inclusive or) *

* eg. as1 = {a1, a2, a3}; as2 = {a2, a4}
* (as1) union (as2) = (as2) union (as1) = {a1, a2, a3, a4} * * @param bondSet2 * bondSet to unite with * @throws RuntimeException * @return bond set */ public CMLBondSet union(CMLBondSet bondSet2) throws RuntimeException { CMLBondSet newBondSet = new CMLBondSet(); List bonds = this.getBonds(); newBondSet.addBonds(bonds); List bonds2 = bondSet2.getBonds(); for (CMLBond bond2 : bonds2) { if (!newBondSet.contains(bond2)) { newBondSet.addBond(bond2); } } return newBondSet; } /** * Returns intersection of this bondSet with another. * * Creates new bondSet containing the bonds that are in this bondSet, and * the one supplied. (and) *

* eg. as1 = {a1, a2, a3}; as2 = {a2, a4}
* (as1) union (as2) = (as2) intersection (as1) = {a2} * * @param bondSet2 bondSet to intersect with * @throws RuntimeException * @return bond set */ public CMLBondSet intersection(CMLBondSet bondSet2) throws RuntimeException { CMLBondSet newBondSet = new CMLBondSet(); List bonds2 = bondSet2.getBonds(); for (CMLBond bond2 : bonds2) { if (this.contains(bond2)) { newBondSet.addBond(bond2); } } return newBondSet; } /** * Returns symmetric difference of this bondSet with another. * * Creates new bondSet containing the bonds that are in either bondSet, or * the one supplied, but not both. (Exclusive or) *

* eg. as1 = {a1, a2, a3}; as2 = {a2, a4}
* (as1) symmetric difference (as2) = {a1, a3, a4} * * @param bondSet2 * bondSet to xor with * @return bondSet * */ public CMLBondSet symmetricDifference(CMLBondSet bondSet2) { CMLBondSet newBondSet = new CMLBondSet(); List bonds = this.getBonds(); for (int i = 0; i < bonds.size(); i++) { if (!bondSet2.contains(bonds.get(i))) { newBondSet.addBond(bonds.get(i)); } } List bonds2 = bondSet2.getBonds(); for (int i = 0; i < bonds2.size(); i++) { CMLBond bond = bonds2.get(i); if (!this.contains(bond)) { newBondSet.addBond(bond); } } return newBondSet; } /** get corresponding molecule. * @return the molecule (null if none) */ public CMLMolecule getMolecule() { if (molecule == null) { List bonds = this.getBonds(); if (bonds.size() > 0) { molecule = CMLMolecule.getMoleculeAncestor(bonds.get(0)); } else { throw new RuntimeException("NO bonds in set..."); } } return molecule; } /** * removes bond from set. does NOT remove bond from molecule * * @param bond * to remove * @throws RuntimeException * bond not in set */ public void removeBond(CMLBond bond) throws RuntimeException { if (bond != null) { if (!set.contains(bond)) { throw new RuntimeException("Bond not in set:" + bond.getId() + CMLConstants.S_COLON + Util.concatenate(this.getXMLContent(), CMLConstants.S_SLASH)); } // remove from set set.remove(bond); // and from id table String id = bond.getId(); idTable.remove(id); // and from XOM XMLContent String[] content = this.getXMLContent(); content = Util.removeElementFromStringArray(content, id); this.setXMLContent(content); // and adjust size int c = this.getSize(); this.setSize(c - 1); // bond.detach(); this kills the bonds relationship to its molecule! } } /** * removes bond from set. * * @param id * of bond to remove * @throws RuntimeException * bond not in set */ public void removeBondById(String id) throws RuntimeException { removeBond(this.getBondById(id)); } /** * removes bondSet from set. * * @param bondSet * to remove * @throws RuntimeException * one or more bonds not in set */ public void removeBondSet(CMLBondSet bondSet) throws RuntimeException { if (bondSet != null) { for (CMLBond bond : bondSet.getBonds()) { if (this.contains(bond)) this.removeBond(bond); } } } /** * gets average 2D bond length. * * if excludeElements is not null, exclude any bonds including those * excludeElementTypes ELSE if includeElements is not null, include any * bonds including only those excludeElementTypes ELSE use all bonds * * @param excludeElements * list of element symbols to exclude * @param includeElements * list of element symbols to include * @return average bond length (NaN if no bonds selected) */ public double getAverage2DBondLength(String[] excludeElements, String[] includeElements) { double sum = 0.0; int count = 0; List bonds = getBonds(); for (CMLBond bond : bonds) { String elem0 = bond.getAtom(0).getElementType(); String elem1 = bond.getAtom(1).getElementType(); boolean skip = false; if (excludeElements != null) { skip = Util.containsString(excludeElements, elem0) || Util.containsString(excludeElements, elem1); } else if (includeElements != null) { skip = !Util.containsString(includeElements, elem0) || !Util.containsString(excludeElements, elem1); } if (!skip) { double length = bond.calculateBondLength(CoordinateType.TWOD); sum += length; count++; } } return (count == 0) ? Double.NaN : sum / (double) count; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLBondStereo.java000077500000000000000000000065441477224461000264440ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting bondStereo. * autogenerated from schema use * as a shell which can be edited * */ public class CMLBondStereo extends AbstractBondStereo { /** namespaced element name.*/ public final static String NS = C_E+TAG; public final static String HATCH = "H"; public final static String WEDGE = "W"; public final static String NONE = "none"; public final static String XML_NONE = ""; public final static String REVERSE = "flip"; public final static String WEDGEHATCH = "wedgehatch"; /** * constructor. */ public CMLBondStereo() { super(); } /** * constructor. * * @param old */ public CMLBondStereo(CMLBondStereo old) { super((AbstractBondStereo) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLBondStereo(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLBond */ public CMLElement makeElementInContext(Element parent) { return new CMLBondStereo(); } /** matches parity for two exemplars of same bondStereo * example: * {@code C} * and * {@code C} * are identical - any other combination is not * @param bs * @return 1 if identical -1 if opposite 0 if neither */ public int matchParity(CMLBondStereo bs) { int res = 0; String thisx = this.getXMLContent().trim(); String bsx = bs.getXMLContent().trim(); String[] this4 = this.getAtomRefs4(); String[] bs4 = bs.getAtomRefs4(); if (this4 == null || bs4 == null || this4.length != 4 || bs4.length != 4) { throw new RuntimeException("bondStereo has no atomRefs4"); } if ( ( this4[0].equals(bs4[0]) && this4[1].equals(bs4[1]) && this4[2].equals(bs4[2]) && this4[3].equals(bs4[3]) ) || ( this4[0].equals(bs4[3]) && this4[1].equals(bs4[2]) && this4[2].equals(bs4[1]) && this4[3].equals(bs4[0]) ) ) { res = (thisx.equals(bsx)) ? 1 : -1; } return res; } public void SetCMLWedgeHatchConvention() { this.setConvention (CMLBondStereo.WEDGEHATCH); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLBondType.java000077500000000000000000000031751477224461000261210ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting bondType. * autogenerated from schema use as * a shell which can be edited * */ public class CMLBondType extends AbstractBondType { /** * constructor. */ public CMLBondType() { } /** * constructor. * * @param old */ public CMLBondType(CMLBondType old) { super((AbstractBondType) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLBondType(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLBondType */ public CMLElement makeElementInContext(Element parent) { return new CMLBondType(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLBondTypeList.java000077500000000000000000000032451477224461000267530ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting bondTypeList. * autogenerated from schema * use as a shell which can be edited * */ public class CMLBondTypeList extends AbstractBondTypeList { /** * constructor. */ public CMLBondTypeList() { } /** * constructor. * * @param old */ public CMLBondTypeList(CMLBondTypeList old) { super((AbstractBondTypeList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLBondTypeList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLBondTypeList */ public CMLElement makeElementInContext(Element parent) { return new CMLBondTypeList(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLCellParameter.java000077500000000000000000000223251477224461000271130ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; /** * A set of 3 cell parameters. * * * Either 3 lengths or 3 angles. * * user-modifiable class autogenerated from schema if no class exists use as a * shell which can be edited the autogeneration software will not overwrite an * existing class file * */ public class CMLCellParameter extends AbstractCellParameter { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** type of cellParameter */ public enum Type { /** three lengths */ LENGTH("length"), /** three angles */ ANGLE("angle"); /** value for comparison */ public final String s; Type(String s) { this.s = s; } } /** * dictRef attributes for obsolete cell parameters. do not use these if * possible. cellParameter has replaced this */ public final static String[] dictRef = { CMLCrystal.A, CMLCrystal.B, CMLCrystal.C, CMLCrystal.ALPHA, CMLCrystal.BETA, CMLCrystal.GAMMA, }; /** * constructor */ public CMLCellParameter() { } /** * copy constructor * * @param old * CMLCellParameter to copy */ public CMLCellParameter(CMLCellParameter old) { super((AbstractCellParameter) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLCellParameter(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLCellParameter */ public CMLElement makeElementInContext(Element parent) { return new CMLCellParameter(); } /** * constructor from 3 CMLScalar of correct type. * * @param scalar * @param type */ public CMLCellParameter(CMLScalar[] scalar, Type type) { this(); if (scalar == null || scalar.length != 3) { throw new RuntimeException("bad args to constructor" + scalar); } double[] values = new double[3]; String units = null; double[] error = new double[3]; boolean hasError = false; for (int i = 0; i < 3; i++) { values[i] = scalar[i].getDouble(); if (units == null) { units = scalar[i].getUnits(); } error[i] = Double.NaN; if (scalar[i].getErrorValueAttribute() != null) { error[i] = scalar[i].getErrorValue(); hasError = true; } } if (units != null) { this.setUnits(units); } if (hasError) { this.setError(error); } if (type == null) { throw new RuntimeException("Null type"); } else if (type.equals(Type.LENGTH) || type.equals(Type.ANGLE)) { this.setType(type.s); this.setXMLContent(values); } } /** * constructor from 3 CMLScalar of correct type. * * @param scalar * @param type */ public CMLCellParameter(List scalar, Type type) { this((CMLScalar[]) scalar.toArray(new CMLScalar[0]), type); } /** * extracts cellParameter of given type. * * @param cellParameters * array of length 2 with lengths and angles (any order). MUST * have both this list is what is normally returned by accessing * the XOM * @param type * of parameter * @return the cellParameter (or null if not found or corrupt * cellParameters) */ public static CMLCellParameter getCellParameter( List cellParameters, Type type) { CMLCellParameter cellParameter = null; if (cellParameters != null && cellParameters.size() == 2) { CMLCellParameter length = null; CMLCellParameter angle = null; for (CMLCellParameter cellP : cellParameters) { if (Type.LENGTH.s.equals(cellP.getType())) { length = cellP; } else if (Type.ANGLE.s.equals(cellP.getType())) { angle = cellP; } else if (cellP.getType() == null) { throw new RuntimeException( "cellParameter requires type attribute"); } else { throw new RuntimeException("unknown type on cellParameter: " + cellP.getType()); } } if (length != null && angle != null) { cellParameter = (Type.LENGTH.equals(type)) ? length : angle; } } return cellParameter; } /** * extracts cellParameter of given type. * * @param cellParameters * array of length 2 with lengths and angles (any order). MUST * have both this list is what is normally returned by accessing * the XOM * @param type * of parameter * @return the cellParameter (or null if not found or corrupt * cellParameters) */ public static CMLCellParameter getCellParameter( CMLElements cellParameters, Type type) { List cellParams = new ArrayList(); for (CMLCellParameter cellParam : cellParameters) { cellParams.add(cellParam); } return getCellParameter(cellParams, type); } /** * gets CMLScalar representation from valid cellParameters. * * @param cellParameterElements * must be exactly one each of length and angle * @return the 6 cell parameters in order a,b,c,alpha,beta,gamma */ public static List createCMLScalars( List cellParameterElements) { List cellParams = new ArrayList(); CMLCellParameter length = CMLCellParameter.getCellParameter( cellParameterElements, CMLCellParameter.Type.LENGTH); CMLCellParameter angle = CMLCellParameter.getCellParameter( cellParameterElements, CMLCellParameter.Type.ANGLE); if (length != null && angle != null) { double[] error = length.getError(); for (int i = 0; i < 3; i++) { cellParams.add(CMLCrystal.createScalar(dictRef[i], length .getXMLContent()[i], length.getUnits(), (error == null) ? Double.NaN : error[i])); } error = angle.getError(); for (int i = 3; i < 6; i++) { cellParams.add(CMLCrystal.createScalar(dictRef[i], angle .getXMLContent()[i - 3], angle.getUnits(), (error == null) ? Double.NaN : error[i - 3])); } } return cellParams; } /** * gets CMLScalar representation from valid cellParameters. * * @param cellParameterElements * must be exactly one each of length and angle * @return the 6 cell parameters in order a,b,c,alpha,beta,gamma */ public static List createCMLScalars( CMLElements cellParameterElements) { if (cellParameterElements.size() != 2) { throw new RuntimeException("must have exactly 2 CellParameterElements"); } String type0 = cellParameterElements.get(0).getType(); String type1 = cellParameterElements.get(1).getType(); List cellParams = new ArrayList(); if (Type.LENGTH.toString().equalsIgnoreCase(type0) && Type.ANGLE.toString().equalsIgnoreCase(type1)) { cellParams.add(cellParameterElements.get(0)); cellParams.add(cellParameterElements.get(1)); } else if (Type.ANGLE.toString().equalsIgnoreCase(type0) && Type.LENGTH.toString().equalsIgnoreCase(type1)) { cellParams.add(cellParameterElements.get(1)); cellParams.add(cellParameterElements.get(0)); } else { throw new RuntimeException("Bad CellParameters"); } return createCMLScalars(cellParams); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLCml.java000077500000000000000000000032571477224461000251110ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting cml. * autogenerated from schema use as a * shell which can be edited * */ public class CMLCml extends AbstractCml { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLCml() { } /** * constructor. * * @param old */ public CMLCml(CMLCml old) { super((AbstractCml) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLCml(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLCml */ public CMLElement makeElementInContext(Element parent) { CMLCml cml = new CMLCml(); return cml; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLComplexObject.java000077500000000000000000000041651477224461000271330ustar00rootroot00000000000000/** * 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. */ // /*======AUTOGENERATED FROM SCHEMA; DO NOT EDIT BELOW THIS LINE ======*/ package org.xmlcml.cml.element; import nu.xom.Element; import org.xmlcml.cml.base.CMLElement; /** * An element to hold any combination of heterogeneous element children. * * * complexObject can be used as it stands but will often be extended by\n schema * definitions in dictionary entries. * * user-modifiable class autogenerated from schema if no class exists use as a * shell which can be edited the autogeneration software will not overwrite an * existing class file * */ public class CMLComplexObject extends AbstractComplexObject { /** * must give simple documentation. * * */ public CMLComplexObject() { } /** * must give simple documentation. * * @param old * CMLComplexObject to copy * */ public CMLComplexObject(CMLComplexObject old) { super((AbstractComplexObject) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLComplexObject(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLComplexObject */ public CMLElement makeElementInContext(Element parent) { return new CMLComplexObject(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLConditionList.java000077500000000000000000000032571477224461000271600ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting conditionList. * autogenerated from schema * use as a shell which can be edited * */ public class CMLConditionList extends AbstractConditionList { /** * constructor. */ public CMLConditionList() { } /** * constructor. * * @param old */ public CMLConditionList(CMLConditionList old) { super((AbstractConditionList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLConditionList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLConditionList */ public CMLElement makeElementInContext(Element parent) { return new CMLConditionList(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLCrystal.java000077500000000000000000000705561477224461000260250ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import nu.xom.Elements; import nu.xom.Nodes; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.element.CMLCellParameter.Type; import org.xmlcml.euclid.RealArray; import org.xmlcml.euclid.RealSquareMatrix; import org.xmlcml.euclid.Transform3; /** * user-modifiable class supporting crystal. * * @author pmr * */ public class CMLCrystal extends AbstractCrystal { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * crystal systems. */ public enum Bravais { /** triclinic */ TRICLINIC("triclinic"), /** monoclinic */ MONOCLINIC("monoclinic"), /** orthorhombic */ ORTHORHOMBIC("orthorhombic"), /** tetragonal */ TETRAGONAL("tetragonal"), /** trigonal */ TRIGONAL("trigonal"), /** hexagonal */ HEXAGONAL("hexagonal"), /** cubic */ CUBIC("cubic"), /** unknown */ UNKNOWN("unknown"); String desc; private Bravais(String description) { this.desc = description; } } /** * lattice centering. * */ public enum Centering { /** primitive */ P("P", "primitive", new String[] {}), /** body-centered */ I("I", "body-centered", new String[] { "1/2+x, 1/2+y, 1/2+z" }), /** rhomohedral */ R("R", "rhomohedral", new String[] { "1/3+x, 2/3+y, 2/3+z", "2/3+x, 1/3+y, 1/3+z" }), /** face-centered */ F("F", "face-centered", new String[] { "x, 1/2+y, 1/2+z", "1/2+x, y, 1/2+z", "1/2+x, 1/2+y, z" }), /** A-centered */ A("A", "A-centered", new String[] { "x, 1/2+y, 1/2+z" }), /** B-centered */ B("B", "B-centered", new String[] { "1/2+x, y, 1/2+z" }), /** C-centered */ C("C", "C-centered", new String[] { "1/2+x, 1/2+y, z" }), /** unknown */ UNKNOWN(S_QUERY, "unknown", new String[] {}); String symbol; String desc; List translations; private Centering(String symbol, String description, String[] operators) { this.symbol = symbol; this.desc = description; this.translations = new ArrayList(); for (String operator : operators) { try { translations.add(new CMLTransform3(operator)); } catch (Exception e) { throw new RuntimeException("bug " + e); } } } } /** symbols constants */ /** a */ public final static String A = C_A + "a"; /** b */ public final static String B = C_A + "b"; /** c */ public final static String C = C_A + "c"; /** a */ public final static String ALPHA = C_A + "alpha"; /** b */ public final static String BETA = C_A + "beta"; /** c */ public final static String GAMMA = C_A + "gamma"; /** convert Z to #operators */ public final static String Z2OP = C_A + "z2op"; private static final String[] CELL_DICTREF = { "iucr:cell_length_a", "iucr:cell_length_b", "iucr:cell_length_c", "iucr:cell_angle_alpha", "iucr:cell_angle_beta", "iucr:cell_angle_gamma", }; private static final String[] CELL_DICTREF1 = { "iucr:_cell_length_a", "iucr:_cell_length_b", "iucr:_cell_length_c", "iucr:_cell_angle_alpha", "iucr:_cell_angle_beta", "iucr:_cell_angle_gamma", }; private static final String[] CELL_CML = { "cml:a", "cml:b", "cml:c", "cml:alpha", "cml:beta", "cml:gamma", }; /** * constructor. */ public CMLCrystal() { } /** * constructor. * * @param old */ public CMLCrystal(CMLCrystal old) { super((AbstractCrystal) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLCrystal(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLCrystal */ public CMLElement makeElementInContext(Element parent) { return new CMLCrystal(); } /** * constructor from lattice. * * @param lattice * (contains 3 lattice vectors) */ public CMLCrystal(CMLLattice lattice) { this(lattice.getCellParameters()); } /** * constructor from lengths and angles. units are angstrom and degrees must * be ordered a,b,c,alpha, beta, gamma * * @param params * 3 length and 3 angles * @exception RuntimeException * params of wrong length */ public CMLCrystal(double[] params) throws RuntimeException { this(createScalars(params, null)); } /** * constructor from lengths and angles. units are angstrom and degrees must * be ordered a,b,c,alpha, beta, gamma * * @param scalars * 3 length and 3 angles * @exception RuntimeException * parans or wrong length */ public CMLCrystal(CMLScalar[] scalars) { this(); if (scalars == null || scalars.length != 6) { throw new RuntimeException("scalar must be of length 6"); } for (CMLScalar scalar : scalars) { this.appendChild(scalar); } } /** get the crystallographic orthogonalization matrix as a transform * * @see #getOrthogonalizationMatrix() * @return the orthogonalization matrix as a transform */ public Transform3 getOrthogonalizationTransform() { Transform3 t = null; try { t = new Transform3(this.getOrthogonalizationMatrix()); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("BUG "+e); } return t; } /** get the crystallographic orthogonalization matrix. * * see Rollett "Computing Methods in Crystallography" Pergamon 1965 p.23 the * matrix has zeros above the diagonal: a*sin(beta)*sin(gamma*) 0.0 0.0 * -a*sin(beta)*cos(gamma*) b*sin(alpha) 0.0 a*cos(beta) b*cos(alpha) c * * @return the orthogonalization matrix * @throws RuntimeException */ public RealSquareMatrix getOrthogonalizationMatrix() { double[] param = getCellParameterValues(); RealSquareMatrix orthMat = new RealSquareMatrix(3); // Rollett "Computing Methods in Crystallography" Pergamon 1965 p.23 double dtor = Math.PI / 180.0; double sina = Math.sin(dtor * param[3]); double cosa = Math.cos(dtor * param[3]); double sinb = Math.sin(dtor * param[4]); double cosb = Math.cos(dtor * param[4]); double cosg = Math.cos(dtor * param[5]); double cosgstar = (cosa * cosb - cosg) / (sina * sinb); double singstar = Math.sqrt(1.0 - cosgstar * cosgstar); double[][] flmat = orthMat.getMatrix(); flmat[0][0] = param[0] * sinb * singstar; flmat[0][1] = 0.0; flmat[0][2] = 0.0; flmat[1][0] = -1.0 * param[0] * sinb * cosgstar; flmat[1][1] = param[1] * sina; flmat[1][2] = 0.0; flmat[2][0] = param[0] * cosb; flmat[2][1] = param[1] * cosa; flmat[2][2] = param[2]; return orthMat; } /** * set cell lengths and angles. * * NO DEFAULT VALUES. * * @param a * the a cell length (ANGSTROM) * @param b * the b cell length (ANGSTROM) * @param c * the c cell length (ANGSTROM) * @param alpha * the alpha cell angle (DEGREES) * @param beta * the beta cell angle (DEGREES) * @param gamma * the gamma cell angle (DEGREES) * * @throws RuntimeException * corrupted number of cell parameters */ public void setCellParameters(double a, double b, double c, double alpha, double beta, double gamma) { double temp[] = new double[6]; temp[0] = a; temp[1] = b; temp[2] = c; temp[3] = alpha; temp[4] = beta; temp[5] = gamma; setCellParameters(temp, null); } /** * set cell lengths and angles. omits error * * @param params * (length 6: 3 lengths ANGSTROM and three angles DEGREES - IN * ORDER) * * @throws RuntimeException * corrupted number of cell parameters */ public void setCellParameters(double params[]) { setCellParameters(params, null); } /** * set cell lengths and angles. * * NO DEFAULT VALUES. * * @param params * (length 6: 3 lengths ANGSTROM and three angles DEGREES - IN * ORDER) * @param error * if not null errors in lengths and angles in same units * * @throws RuntimeException * corrupted number of cell parameters */ public void setCellParameters(double params[], double error[]) { if (params == null || params.length != 6) { throw new RuntimeException("Must have 6 cell parameters"); } Elements cellParamVector = this.getChildCMLElements("scalar"); if (cellParamVector.size() == 0) { for (int i = 0; i < 6; i++) { CMLScalar cellParam = CMLCrystal.createScalar( CRYSTAL_DICT_REFS[i], params[i], CRYSTAL_DICT_UNITS[i], Double.NaN); this.addScalar(cellParam); } } else if (cellParamVector.size() == 6) { for (int i = 0; i < 6; i++) { CMLScalar cellParam = (CMLScalar) cellParamVector.get(i); cellParam.setValue(params[i]); if (error != null) { cellParam.setErrorValue(error[i]); } cellParam.setDictRef(CRYSTAL_DICT_REFS[i]); } } else { throw new RuntimeException( "Corrupted cell parameters: must be exactly 6 (found: " + cellParamVector.size() + S_RBRAK); } } /** * get cell lengths and angles as list of CMLScalars. if cellParameters are * used, take values from them but do not update XOM * * @deprecated - use CMLCellParameters instead // but this works now * @throws RuntimeException * corrupted number of cell parameters * @return CMLScalar[] the parameters in order (null if not set) */ public List getCellScalars() throws RuntimeException { List cellScalars = new ArrayList(); // Nodes cellScalarNodes = this.query("cml:scalar[starts-with(@dictRef, 'iucr:_cell')]", CMLConstants.CML_XPATH); Nodes cellScalarNodes = this.query("cml:scalar[@dictRef]", CMLConstants.CML_XPATH); int cellScalarCount = cellScalarNodes.size(); if (cellScalarCount != 6) { throw new RuntimeException("Bad number of cell scalars: "+cellScalarCount); } CMLElements cellParameterElements = this.getCellParameterElements(); if (cellParameterElements != null && cellParameterElements.size() == 2) { cellScalars = CMLCellParameter.createCMLScalars(cellParameterElements); } else if (cellScalarNodes != null && cellScalarNodes.size() == 6) { cellScalars = sortCellScalars(cellScalarNodes); } else if (cellScalarNodes != null && cellParameterElements == null) { } else { this.debug("CELLPAR"); throw new RuntimeException("Bad number of cell parameter children: " + cellScalarNodes.size()); } return cellScalars; } private List sortCellScalars(Nodes cellScalarNodes) { List cellScalarList = new ArrayList(6); for (int i = 0; i < 6; i++) { cellScalarList.add((CMLScalar)null); } for (int i = 0; i < 6; i++) { CMLScalar scalar = (CMLScalar)cellScalarNodes.get(i); String dictRef = scalar.getDictRef().toLowerCase(); int j = getCellParameterIndex(dictRef); if (j == -1) { throw new RuntimeException("Cannot interpret cell parameter: "+dictRef); } else if (cellScalarList.get(j) != null) { throw new RuntimeException("duplicate value for "+dictRef); } cellScalarList.set(j, scalar); } return cellScalarList; } private int getCellParameterIndex(String dictRef) { for (int i = 0; i < 6; i++) { if ( dictRef.equals(CELL_DICTREF[i]) || dictRef.equals(CELL_DICTREF1[i]) || dictRef.equals(CELL_CML[i])) { return i; } } return -1; } /** * get cell lengths and angles as CMLCellParameters. if XOM has * cellParameter children copy them else create from CMLScalar else return * empty list * * @throws RuntimeException * corrupted number of cell parameters * @return the parameters in order (null if not set) */ public List createCellParameterElements() throws RuntimeException { CMLElements cellScalarElements = this.getScalarElements(); CMLElements cellParameterElements = this .getCellParameterElements(); List cellParameterList = new ArrayList(); if (cellParameterElements != null && cellParameterElements.size() == 2) { CMLCellParameter length = CMLCellParameter.getCellParameter( cellParameterElements, CMLCellParameter.Type.LENGTH); CMLCellParameter angle = CMLCellParameter.getCellParameter( cellParameterElements, CMLCellParameter.Type.ANGLE); if (length != null && angle != null) { cellParameterList.add(length); cellParameterList.add(angle); } } else if (cellScalarElements != null && cellScalarElements.size() == 6) { List lengthParams = new ArrayList(); for (int i = 0; i < 3; i++) { lengthParams.add(new CMLScalar((CMLScalar) cellScalarElements .get(i))); } List angleParams = new ArrayList(); for (int i = 3; i < 6; i++) { angleParams.add(new CMLScalar((CMLScalar) cellScalarElements .get(i))); } cellParameterList.add(new CMLCellParameter(lengthParams, Type.LENGTH)); cellParameterList .add(new CMLCellParameter(angleParams, Type.ANGLE)); } else if (cellScalarElements.size() > 0) { throw new RuntimeException("Bad number of cell parameter children: " + cellScalarElements.size()); // this is really horrible - must change } else { throw new RuntimeException("no cell params"); } return cellParameterList; } /** * get cell lengths and angles as array of doubles. * * Values ARE IN ANGSTROM and DEGREES. * * @throws RuntimeException * corrupted number of cell parameters * @return double[] the parameters in order (null if not set) */ public double[] getCellParameterValues() { List paramElements = getCellScalars(); double[] temp = new double[6]; if (paramElements == null) { return null; } for (int i = 0; i < 6; i++) { temp[i] = (Double.valueOf(paramElements.get(i).getXMLContent())).doubleValue(); } LOG.trace("cell values "+new RealArray(temp)); return temp; } /** * adds symmetry operator * * @param so * The SymmetryOp to add */ /*-- public void addSymmetryOperator(SymmetryOp so) { if (symOps == null) { symOps = new ArrayList (); } symOps.add (so); } --*/ /** * returns an array of the SymmetryOps describing the symmetry operators or * null if there are no symmetry operators */ /*-- public List getSymmetryOperators() { //LOG.debug ("nu sym ops " + symOps.size ()); if ((symOps != null) && (symOps.size () != 0)) { List ops = new ArrayList(); return (symOps(ops)); } else { return null; } } --*/ /** * get lattice containing latticeVectors. requires cell parameters to be * set. * * @return the lattice. */ public CMLLattice getLattice() { RealSquareMatrix matrix = this.getOrthogonalizationMatrix(); double[][] flmat = matrix.getMatrix(); CMLLattice lattice = new CMLLattice(); double[] v = new double[3]; v[0] = flmat[0][0]; v[1] = flmat[1][0]; v[2] = flmat[2][0]; CMLLatticeVector aVector = new CMLLatticeVector(v); lattice.addLatticeVector(aVector); v[0] = flmat[0][1]; v[1] = flmat[1][1]; v[2] = flmat[2][1]; CMLLatticeVector bVector = new CMLLatticeVector(v); lattice.addLatticeVector(bVector); v[0] = flmat[0][2]; v[1] = flmat[1][2]; v[2] = flmat[2][2]; CMLLatticeVector cVector = new CMLLatticeVector(v); lattice.addLatticeVector(cVector); return lattice; } /** * get cell volume. use current cell parameters. V= * abc(1-cos^2alpha-cos^2beta-cos^2gamma + 2cos alpha cos beta cos * gamma)^(1/2) * * @return volume */ public double getCellVolume() { double[] param = this.getCellParameterValues(); double dtor = Math.PI / 180.0; double cosa = Math.cos(dtor * param[3]); double cosb = Math.cos(dtor * param[4]); double cosg = Math.cos(dtor * param[5]); double vol = param[0] * param[1] * param[2] * Math.sqrt(1 - cosa * cosa - cosb * cosb - cosg * cosg + 2 * cosa * cosb * cosg); return vol; } /** * get cell volume. use scalar triple product of current lattice vectors V = * aVect * bVect . cVect * * @return volume */ public double getCellVolume1() { CMLLattice lattice = this.getLattice(); CMLVector3 a = lattice.getLatticeVectorElements().get(0) .getCMLVector3(); CMLVector3 b = lattice.getLatticeVectorElements().get(1) .getCMLVector3(); CMLVector3 c = lattice.getLatticeVectorElements().get(2) .getCMLVector3(); return a.getScalarTripleProduct(b, c); } /** * get cell volume. use determinant of orthogonalization matrix V = * det(orthMat) * * @return volume */ public double getCellVolume2() { RealSquareMatrix orthMat = this.getOrthogonalizationMatrix(); return orthMat.determinant(); } /** * gets volume of reciprocal cell. scaling factor is 1.0 (i.e. * wavelength-independent) * * @return volume */ public double getReciprocalCellVolume() { return 1. / this.getCellVolume(); } /** * get reciprocal cell scaling factor is 1.0 (i.e. wavelength-independent) * * @return the cell. */ public CMLCrystal getReciprocalCell() { CMLLattice reciprocalLattice = this.getReciprocalLattice(); CMLCrystal crystal = new CMLCrystal(reciprocalLattice); return crystal; } /** * get reciprocal lattice scaling factor is 1.0 (i.e. * wavelength-independent) * * @return the lattice */ public CMLLattice getReciprocalLattice() { CMLLattice lattice = this.getLattice(); CMLVector3 a = lattice.getLatticeVectorElements().get(0) .getCMLVector3(); CMLVector3 b = lattice.getLatticeVectorElements().get(1) .getCMLVector3(); CMLVector3 c = lattice.getLatticeVectorElements().get(2) .getCMLVector3(); double recipvol = 1. / a.getScalarTripleProduct(b, c); CMLVector3 astar = b.getCrossProduct(c).multiplyBy(recipvol); CMLLatticeVector astarVect = new CMLLatticeVector(astar); CMLVector3 bstar = c.getCrossProduct(a).multiplyBy(recipvol); CMLLatticeVector bstarVect = new CMLLatticeVector(bstar); CMLVector3 cstar = a.getCrossProduct(b).multiplyBy(recipvol); CMLLatticeVector cstarVect = new CMLLatticeVector(cstar); return new CMLLattice(astarVect, bstarVect, cstarVect); } private static CMLScalar[] createScalars(double[] params, double[] error) throws RuntimeException { if (params == null || params.length != 6) { throw new RuntimeException("params must be of length 6"); } CMLScalar[] scalar = new CMLScalar[6]; for (int i = 0; i < 6; i++) { double err = (error == null) ? Double.NaN : error[i]; scalar[i] = createScalar(CRYSTAL_DICT_REFS[i], params[i], CRYSTAL_DICT_UNITS[i], err); } return scalar; } /** * create a cell parameter scalar from its values. omits error * * @param dictRef * @param param * @param unitRef * @return the scalar */ public static CMLScalar createScalar(String dictRef, double param, String unitRef) { return createScalar(dictRef, param, unitRef, Double.NaN); } /** * create a cell parameter scalar from its values. * * @param dictRef * @param param * @param unitRef * @param error * neglect if Double.NaN * @return the scalar */ public static CMLScalar createScalar(String dictRef, double param, String unitRef, double error) { CMLScalar scalar = new CMLScalar(param); scalar.setDictRef(dictRef); if (unitRef != null) { scalar.setUnits(unitRef); } if (!Double.isNaN(error)) { scalar.setErrorValue(error); } return scalar; } /** * gets primitive cell. finds Centering; if not UNKNOWN or P applies it * * @return new lattice */ public CMLLattice getPrimitiveLattice() { CMLElements symmetry = this.getSymmetryElements(); Centering centering = (symmetry.size() == 0) ? Centering.P : symmetry .get(0).getCentering(); return this.getPrimitiveLattice(centering); } /** * gets primitive cell. * * @param centering * @return new lattice */ public CMLLattice getPrimitiveLattice(CMLCrystal.Centering centering) { CMLLattice lattice = this.getLattice(); CMLLatticeVector[] latticeVectors = new CMLLatticeVector[3]; if (centering.equals(Centering.P) || centering.equals(Centering.UNKNOWN)) { // copy current latticeVectors int i = 0; for (CMLLatticeVector lv : lattice.getLatticeVectorElements()) { latticeVectors[i++] = new CMLLatticeVector(lv); } } else if (centering.equals(Centering.A)) { latticeVectors[0] = new CMLLatticeVector(lattice.getCMLVector3(0)); CMLVector3 bPlusC = lattice.getCMLVector3(1).plus( lattice.getCMLVector3(2)); latticeVectors[1] = new CMLLatticeVector(bPlusC.multiplyBy(0.5)); CMLVector3 bMinusC = lattice.getCMLVector3(1).subtract( lattice.getCMLVector3(2)); latticeVectors[2] = new CMLLatticeVector(bMinusC.multiplyBy(0.5)); } else if (centering.equals(Centering.B)) { CMLVector3 aPlusC = lattice.getCMLVector3(0).plus( lattice.getCMLVector3(2)); latticeVectors[0] = new CMLLatticeVector(aPlusC.multiplyBy(0.5)); CMLVector3 aMinusC = lattice.getCMLVector3(0).subtract( lattice.getCMLVector3(2)); latticeVectors[1] = new CMLLatticeVector(lattice.getCMLVector3(1)); latticeVectors[2] = new CMLLatticeVector(aMinusC.multiplyBy(0.5)); } else if (centering.equals(Centering.C)) { CMLVector3 aPlusB = lattice.getCMLVector3(0).plus( lattice.getCMLVector3(1)); latticeVectors[0] = new CMLLatticeVector(aPlusB.multiplyBy(0.5)); CMLVector3 aMinusB = lattice.getCMLVector3(0).subtract( lattice.getCMLVector3(1)); latticeVectors[1] = new CMLLatticeVector(aMinusB.multiplyBy(0.5)); latticeVectors[2] = new CMLLatticeVector(lattice.getCMLVector3(2)); } else if (centering.equals(Centering.I)) { latticeVectors[0] = new CMLLatticeVector(lattice.getCMLVector3(0)); CMLVector3 aPlusBplusC = lattice.getCMLVector3(0).plus( lattice.getCMLVector3(1)).plus(lattice.getCMLVector3(2)); latticeVectors[1] = new CMLLatticeVector(aPlusBplusC .multiplyBy(0.5)); CMLVector3 aPlusBminusC = lattice.getCMLVector3(0).plus( lattice.getCMLVector3(1)) .subtract(lattice.getCMLVector3(2)); latticeVectors[2] = new CMLLatticeVector(aPlusBminusC .multiplyBy(0.5)); } else if (centering.equals(Centering.F)) { CMLVector3 bPlusC = lattice.getCMLVector3(1).plus( lattice.getCMLVector3(2)); latticeVectors[0] = new CMLLatticeVector(bPlusC.multiplyBy(0.5)); CMLVector3 cPlusA = lattice.getCMLVector3(2).plus( lattice.getCMLVector3(0)); latticeVectors[1] = new CMLLatticeVector(cPlusA.multiplyBy(0.5)); CMLVector3 aPlusB = lattice.getCMLVector3(0).plus( lattice.getCMLVector3(1)); latticeVectors[2] = new CMLLatticeVector(aPlusB.multiplyBy(0.5)); } else if (centering.equals(Centering.R)) { throw new RuntimeException("R not implemented"); } CMLLattice primitiveLattice = new CMLLattice(latticeVectors); return primitiveLattice; } /** convenience method to get a single crystal descendant of an element. * * @param element to search under * @return the 'crystal' * @throws RuntimeException if 0 or >1 nodes */ public static CMLCrystal getContainedCrystal(CMLElement element) throws RuntimeException { Nodes crystalNodes = element.query(".//"+CMLCrystal.NS, CMLConstants.CML_XPATH); if (crystalNodes.size() == 0) { throw new RuntimeException("NO FOUND"); } else if (crystalNodes.size() > 1) { throw new RuntimeException("TOO MANY FOUND "+crystalNodes.size()); } return (CMLCrystal) crystalNodes.get(0); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLDefinition.java000077500000000000000000000032311477224461000264560ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * * @author nwe23 * */ public class CMLDefinition extends AbstractHTMLContainer { public final static String TAG = "definition"; public final static String NS = C_E + TAG; /** * copy constructor. deep copy using XOM copy() * * @param old * element to copy */ public CMLDefinition(CMLDefinition old) { super((AbstractHTMLContainer) old); } public CMLDefinition(){ super(TAG); } /** * copy node . * * @return Node */ public Element copy() { return new CMLDefinition(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLDefinition */ public CMLElement makeElementInContext(Element parent) { return new CMLDefinition(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLDescription.java000077500000000000000000000032301477224461000266500ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * * @author nwe23 * */ public class CMLDescription extends AbstractHTMLContainer { public final static String TAG = "description"; public final static String NS = C_E + TAG; /** * copy constructor. deep copy using XOM copy() * * @param old * element to copy */ public CMLDescription(CMLDescription old) { super((AbstractHTMLContainer) old); } public CMLDescription(){ super(TAG); } /** * copy node . * * @return Node */ public Element copy() { return new CMLDescription(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLDescription */ public CMLElement makeElementInContext(Element parent) { return new CMLDescription(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLDictionary.java000077500000000000000000000156221477224461000265020ustar00rootroot00000000000000/** * 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 java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.HashMap; import java.util.Map; import nu.xom.Element; import org.apache.log4j.Logger; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.base.CMLUtil; /** * user-modifiable class supporting dictionary. * */ public class CMLDictionary extends AbstractDictionary { private final static Logger LOG = Logger.getLogger(CMLDictionary.class); /** namespaced element name.*/ public final static String NS = C_E+TAG; protected Map entryMap = null; /** * constructor. */ public CMLDictionary() { } /** * constructor. * * @param old */ public CMLDictionary(CMLDictionary old) { super((AbstractDictionary) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLDictionary(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLDictionary */ public CMLElement makeElementInContext(Element parent) { return new CMLDictionary(); } /** * index entries by id. * */ public int indexEntries() { if (entryMap == null) { entryMap = new HashMap(); CMLElements entryNodes = this.getEntryElements(); for (CMLEntry entry : entryNodes) { String id = entry.getId(); if (id != null) { entryMap.put(id, entry); } } LOG.trace("Created dictionary with entries: "+entryNodes.size()); } return entryMap.size(); } /** * creates dictionary from file; * effectively static but requires to be called from a dictionary object * @param file * file to create from * @return the dictionary or null * @throws IOException * @throws RuntimeException * if file is not a well-formed dictionary */ public CMLDictionary createDictionary(File file) throws IOException { return createDictionary(file.toURI().toURL()); } public static CMLDictionary createDictionary0(File file) throws IOException { return createDictionary(file.toURI().toURL()); } public static CMLDictionary createDictionary(URL url) throws IOException { InputStream in = null; CMLDictionary dictionary = null; // this will fail if dictionary is badly formed try { in = url.openStream(); dictionary = createDictionary(in); } catch (Exception e) { throw new RuntimeException("Cannot create dictionary", e); } finally { try { in.close(); } catch(IOException e) { e.printStackTrace(); } } return dictionary; } public static CMLDictionary createDictionary(InputStream is) throws IOException { CMLDictionary cmlDictionary = null; try { Element element = new CMLBuilder().build(is).getRootElement(); cmlDictionary = (CMLDictionary) CMLUtil.getSingleElement(element, ".//self::cml:dictionary", CML_XPATH); cmlDictionary.indexEntries(); } catch (Exception e) { throw new RuntimeException("Cannot create dictionary", e); } return cmlDictionary; } /** * get Entry by id. * * @deprecated use getCMLEntry() * @param id * the entryId (null if absent) * @return entry */ public CMLEntry getGenericEntry(String id) { return getCMLEntry(id); // throw new CMLRuntime("deprecated, use getCMLEntry()"); } /** get Entry by id. * do not ignore case * @param id the entryId (null if absent) * @return entry */ public CMLEntry getCMLEntry(String id) { int nentries = this.indexEntries(); return entryMap.get(id); } /** * add new Entry. * * @param entry * to add * @throws RuntimeException * entry already present. */ public void addEntry(CMLEntry entry) { String id = entry.getId(); if (id == null) { throw new RuntimeException("Entry has no id"); } if (getCMLEntry(id) != null) { throw new RuntimeException("Entry for " + id + " already present"); } entryMap.put(id, entry); this.appendChild(entry); } /** * add new Entry in order of id * * @param entry to add * @throws RuntimeException * entry already present. */ public void addEntryInOrder(CMLEntry entry) { String id = entry.getId(); if (id == null) { throw new RuntimeException("Entry has no id"); } if (getCMLEntry(id) == null) { entryMap.put(id, entry); CMLElements entries = this.getEntryElements(); int idx = entries.size(); for (CMLEntry entry0 : entries) { if (id.compareTo(entry0.getId()) < 0) { idx = this.indexOf(entry0); break; } } this.insertChild(entry, idx); } } /** * remove Entry. calls removeEntryById() * * @param entry * to remove, no action if not present * */ public void removeEntry(CMLEntry entry) { String id = entry.getId(); removeEntryById(id); } /** * remove Entry by id. the preferred method * * @param id * of entry to remove, no action if null or not present * */ public void removeEntryById(String id) { if (id != null) { CMLEntry entry1 = (CMLEntry) this.getCMLEntry(id); if (entry1 != null) { entryMap.remove(id); entry1.detach(); } } } // /** // * create dictionaryMap. // * // * @param file // * @param useSubdirectories // * @return dictionaryMap // */ // public GenericDictionaryMap createDictionaryMap(File file, // boolean useSubdirectories) { // return null; // } // /** sort entries. // * also sorts enumerations in each entry // */ // public void sortEntries() { // TreeSet treeSet = new TreeSet(); // for (CMLEntry entry : this.getEntryElements()) { // treeSet.add(entry); // entry.detach(); // } // Iterator iterator = treeSet.iterator(); // while (iterator.hasNext()) { // CMLEntry entry = (CMLEntry) iterator.next(); // this.appendChild(entry); // entry.sortEnumerations(); // } // } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLEigen.java000077500000000000000000000176271477224461000254330ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.euclid.RealArray; import org.xmlcml.euclid.RealMatrix; import org.xmlcml.euclid.Util; /** * user-modifiable class supporting eigen. * autogenerated from schema use as a * shell which can be edited * */ public class CMLEigen extends AbstractEigen { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** orientation of matrix. */ public enum Orientation { /** values down */ VALUES_ROWS("rowVectors", "eigenvalues correspond to rows"), /** values across */ VALUES_COLS("columnVectors", "eigenvalues correspond to columns"); /** this should corespond to schema enumeration */ public String value; /** a description */ public String desc; private Orientation(String value, String desc) { this.desc = desc; this.value = value; } } /** * constructor. */ public CMLEigen() { } /** * constructor. * * @param old */ public CMLEigen(CMLEigen old) { super((AbstractEigen) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLEigen(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLEigen */ public CMLElement makeElementInContext(Element parent) { CMLEigen eigen = new CMLEigen(); return eigen; } /** * check child array and matrix and update. * * @param parent * element */ public void finishMakingElement(Element parent) { CMLArray eigenvalues = this.getEigenvalues(); CMLMatrix eigenvectors = this.getEigenvectors(); if (eigenvalues != null && eigenvectors != null) { if (eigenvectors.getRowsAttribute() == null || eigenvectors.getColumnsAttribute() == null) { throw new RuntimeException( "must give rows and columns attributes on eigenvectors"); } String orientation = this.getOrientation(); if (!Orientation.VALUES_COLS.value.equals(orientation) && !Orientation.VALUES_ROWS.value.equals(orientation)) { throw new RuntimeException( "must give valid orientation on eigenvectors: " + orientation); } } } /** * create from matched eigenvectors and eigenvalues. must be of matched * size. * * @param eigenvectors * @param eigenvalues * @param orient * orientation * @throws RuntimeException */ public CMLEigen(CMLMatrix eigenvectors, CMLArray eigenvalues, Orientation orient) { if (eigenvectors == null && eigenvalues == null) { throw new RuntimeException("null eigen argument(s)"); } if (eigenvectors.getRows() != eigenvectors.getColumns()) { throw new RuntimeException("eigenvector matrix must be square: rows(" + eigenvectors.getRows() + ") columns (" + eigenvectors.getColumns() + CMLConstants.S_RBRAK); } if (eigenvalues.getSize() != eigenvectors.getColumns()) { throw new RuntimeException("eigenvector matrix (" + eigenvectors.getColumns() + ") incompatible with eigenvalues (" + eigenvalues.getSize() + CMLConstants.S_RBRAK); } if (!(XSD_DOUBLE.equals(eigenvalues.getDataType()))) { throw new RuntimeException("eigenvalue matrix must be real numbers"); } if (!(XSD_DOUBLE.equals(eigenvectors.getDataType()))) { throw new RuntimeException("eigenvector matrix must be real numbers"); } this.appendChild(eigenvalues); this.appendChild(eigenvectors); this.setOrientation(orient.value); // RealMatrix rm = eigenvectors.getEuclidRealMatrix(); } /** * return size of matrix and array. * * @return the size (or 0 if no valid matrix) */ public int getSize() { int size = 0; CMLArray eigenvalues = this.getEigenvalues(); if (eigenvalues != null) { size = eigenvalues.getDoubles().length; } return size; } /** * gets eigenvectors. note that the orientation is not normalized * * @return eigenvectors */ public CMLMatrix getEigenvectors() { CMLMatrix eigenvectors = (this.getMatrixElements().size() == 1) ? this .getMatrixElements().get(0) : null; if (eigenvectors != null && !XSD_DOUBLE.equals(eigenvectors.getDataType())) { throw new RuntimeException("eigenvectors array must be of type double"); } return eigenvectors; } /** * gets eigenvectors. note that the orientation is not normalized * * @return eigenvectors */ public CMLArray getEigenvalues() { CMLArray eigenvalues = (this.getArrayElements().size() == 1) ? this .getArrayElements().get(0) : null; if (eigenvalues != null && !XSD_DOUBLE.equals(eigenvalues.getDataType())) { throw new RuntimeException("eigenvalues array must be of type double"); } return eigenvalues; } /** * gets given eigenvector. convenience method. Inefficient if many * eigenvectors are required in which case a CMLMatrix should be extracted * and processed. * * @param serial * @return eigenvector or null if none * @throws RuntimeException * if serial is out of range */ public RealArray getEigenvector(int serial) throws RuntimeException { RealArray array = null; if (serial < 0) { throw new RuntimeException("bad index: " + serial); } CMLMatrix matrix = getEigenvectors(); if (matrix != null) { if (serial >= matrix.getRows()) { throw new RuntimeException("bad index: " + serial); } if (matrix != null && serial < matrix.getRows() && XSD_DOUBLE.equals(matrix.getDataType())) { RealMatrix mat = matrix.getEuclidRealMatrix(); if (Orientation.VALUES_COLS.value.equals(this.getOrientation())) { array = mat.extractColumnData(serial); } else if (Orientation.VALUES_ROWS.value.equals(this .getOrientation())) { Util.println("ROW"); array = mat.extractRowData(serial); } else { throw new RuntimeException("unknown orientation: " + this.getOrientation()); } } } return array; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLElectron.java000077500000000000000000000045161477224461000261500ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting electron. * autogenerated from schema use as * a shell which can be edited * */ public class CMLElectron extends AbstractElectron { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** pi electron. */ public final static String PI = C_A+"piElectron"; /** * constructor. */ public CMLElectron() { } /** * constructor. * * @param old */ public CMLElectron(CMLElectron old) { super((AbstractElectron) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLElectron(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLElectron */ public CMLElement makeElementInContext(Element parent) { return new CMLElectron(); } /** simple count of electrons in bond * * @param order * @return 2 for S, 3 for A, 4 for D etc. */ public static int getElectronCount(String order) { int ec = 0; if (order == null) { } else if (CMLBond.isSingle(order)) { ec = 2; } else if (order.equals(CMLBond.AROMATIC)) { ec = 3; } else if (CMLBond.isDouble(order)) { ec = 4; } else if (CMLBond.isTriple(order)) { ec = 6; } return ec; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLElement.java000077500000000000000000000021671477224461000257660ustar00rootroot00000000000000/** * 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; /** * a kludge so that CMLElement can be constructed by name * almost all uses of CMLElement are provided by the superclass */ public class CMLElement extends org.xmlcml.cml.base.CMLElement { /** * constructor. */ public CMLElement() { super(); } /** * constructor. * * @param old */ public CMLElement(CMLElement old) { super((CMLElement) old); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLElementConstants.java000077500000000000000000000014561477224461000276630ustar00rootroot00000000000000/** * 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; /** * not sure. * * @author pmr * */ public interface CMLElementConstants extends CMLReactionConstants { }cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLEntry.java000077500000000000000000000044051477224461000254730ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * The enumerations are managed by the IndexableByIdList mechanism */ public class CMLEntry extends AbstractEntry { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLEntry() { } /** * constructor. * * @param old */ public CMLEntry(CMLEntry old) { super((AbstractEntry) old); } /** * normal constructor. * * @param id of entry (should be unique within dictionary); */ public CMLEntry(String id) { this(); this.setId(id); } /** * copy node . * * @return Node */ public Element copy() { return new CMLEntry(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent of element to be constructed (ignored by default) * @return CMLEntry */ public CMLElement makeElementInContext(Element parent) { return new CMLEntry(); } /** set term if not already set. * if entry already has different term, throw exception * @param term */ public void checkAndSetTerm(String term) { if (term != null) { String thisTerm = this.getTerm(); // make new entry? if (thisTerm != null && !thisTerm.equals(term)) { throw new RuntimeException("current term ["+this.getId()+"] ("+thisTerm+") different from ("+term+")"); } this.setTerm(term); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLExpression.java000077500000000000000000000032211477224461000265240ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting expression. * autogenerated from schema use * as a shell which can be edited * */ public class CMLExpression extends AbstractExpression { /** * constructor. */ public CMLExpression() { } /** * constructor. * * @param old */ public CMLExpression(CMLExpression old) { super((AbstractExpression) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLExpression(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLExpression */ public CMLElement makeElementInContext(Element parent) { return new CMLExpression(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLFormula.java000077500000000000000000002151441477224461000260030ustar00rootroot00000000000000/** * 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 java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; import java.util.StringTokenizer; import nu.xom.Attribute; import nu.xom.Document; import nu.xom.Element; import nu.xom.Elements; import nu.xom.Nodes; import nu.xom.Text; import org.apache.log4j.Logger; import org.xmlcml.cml.base.CMLAttribute; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.euclid.Real; import org.xmlcml.euclid.RealArray; import org.xmlcml.euclid.Util; import org.xmlcml.molutil.ChemicalElement; import org.xmlcml.molutil.ChemicalElement.AS; /** * user-modifiable class supporting formula. * The semantics of formula have * been updated (2005-10) and the relationship between concise attribute and * atomArray children is explicit. This class supports the parsing of a number * of current inline structures but does not guarantee correctness as there are * no agreed community syntax/semantics. This is a particular problem for * charges which could be "2+", "++", "+2", etc. For robust inline interchange * ONLY the concise representation is supported. * * NOTE: The atomArray child, in array format, together with the formalCharge * attribute is the primary means of holding the formula. There is now no lazy * evaluation. The concise attribute can be autogenerated from the atomArray and * formalCharge. If a formula is input with only concise then the atomArray is * automatically generated from it. */ public class CMLFormula extends AbstractFormula { private static Logger LOG = Logger.getLogger(CMLFormula.class); public final static String SMILES = "SMILES"; public final static String SMILES1 = "cml:smiles"; /** type of hydrogen counting * @author pm286 */ public enum HydrogenStrategy { /** use hydorgen count attribute*/ HYDROGEN_COUNT, /** use explicit hydrogens*/ EXPLICIT_HYDROGENS; } /** namespaced element name.*/ public final static String NS = C_E+TAG; /** dewisott */ public final static int NPLACES = 10; /** dewisott */ public final static int NDEC = 4; /** type */ public enum Type { /** * the simplest representation. an input-only format. parsing is * possible but fragile. The charge semantics are not defined. Not * recommended for output. */ NOPUNCTUATION("NoPunctuation", "C2H4Cl2"), /** * another simple representation. an input-only format. parsing is also * fragile as charge sematics are not defined. Not recommended for * output. */ ELEMENT_COUNT_WHITESPACE("Element Count Whitespace", "C2 H4 Cl2"), /** * Yet another simple representation. an input-only format. Element * counts of 1 should always be given. Fragile as charge field is likely * to be undefined. Not recommended for output. */ ELEMENT_WHITESPACE_COUNT("Element Whitespace Count", "C 2 H 4 O 1"), /** * the format used in concise. recommended as the main output form. * Element counts of 1 should always be given. the charge shoudl always * be included. See concise.xsd and formulaType.xsd for syntax. */ CONCISE("CML Concise", "C 2 H 3 O 2 -1"), /** * multipliers for moieties. an input only format. JUMBO will try to * parse this correctly but no guarantee is given. */ MULTIPLIED_ELEMENT_COUNT_WHITESPACE( "Multiplied Element Whitespace Count", "3(C2 H4 Cl2) or (H2 O)3"), /** * hierarchical formula. an input-only format. JUMBO will try to parse * this correctly but no guarantee is given. */ NESTEDBRACKETS("NestedBrackets", "Na2(SO4).10(H2O)"), /** * an input only format. JUMBO will not yet parse this correctly. * comments from IUCr * *

		 *          _chemical_formula_iupac '[V O (H2 O)5] 2(C7 H5 O6 S), 2H2 O'
		 *          _example                    '[Co Re (C12 H22 P)2 (C O)6].0.5C H3 O H'
		 *          _definition
		 *          ;              Formula expressed in conformance with IUPAC rules for inorganic
		 *          and metal-organic compounds where these conflict with the rules
		 *          for any other _chemical_formula_ entries. Typically used for
		 *          formatting a formula in accordance with journal rules. This
		 *          should appear in the data block in addition to the most
		 *          appropriate of the other _chemical_formula_ data names.
		 * 
* * I do not know how to parse the second example! I think it means 0.5 * MeOH solvate. */ IUPAC("IUPAC", "[V O (H2 O)5] 2(C7 H5 O6 S), 2H2 O"), /** * Moiety, used by IUCr. an input-only format. moieties assumed to be * comma separated then ELEMENT_COUNT_WHITESPACE, with optional brackets * and post or pre-multipliers * *
		 *          'C46 H50 Cl2 Hg2 N6 O10, 2C2 H6 O, 4H2 O'
		 *          'C46 H34 Co N5 O3'
		 *          'C18 H25 N O3'
		 *          'C12 H17 N4 O S 1+, C6 H2 N3 O7 1-'
		 *          'C12 H16 N2 O6, 5(H2 O1)'
		 *          "(Cd 2+)3, (C6 N6 Cr 3-)2, 2(H2 O)
		 *          'C40 H66 Mo O4 P2'
		 * 
*/ MOIETY("Moiety", "(Cd 2+)3, (C6 N6 Cr 3-)2, 2(H2 O)"), /** * SubMoiety, used by IUCr. the part of a moiety within the brackets * assumed to b ELEMENT_OPTIONALCOUNT followed by optional FORMULA */ SUBMOIETY("SubMoiety", "C6 N6 Cr 3-"), /** * Structural, used by IUCr. not currently implemented, I think. * probably the same as nested brackets */ STRUCTURAL("STRUCTURAL", "Sn (C2 O4) K F"), /** * any of the above. input-only. */ ANY("Any", "(Cd 2+)3, (C6 N6 Cr 3-)2, 2(H2 O)"); String type; String example; Type(String type, String example) { this.type = type; this.example = example; } } /** sort type */ public enum Sort { /** * sort alphabetically. output only. Not sure where this is */ ALPHABETIC_ELEMENTS("Alphabetic Elements", "AgCFHNOS"), /** * C H and then alphabetically. (output only) */ CHFIRST("C and H first", "CHFNOS"); String type; String example; Sort(String type, String example) { this.type = type; this.example = example; } } static Logger logger = Logger.getLogger(CMLFormula.class); // only edit insertion module! // marks whether concise has been processed before atomArray hass been read private boolean processedConcise; private boolean allowNegativeCounts; /** * normal constructor. * * */ public CMLFormula() { super(); init(); } /** * Constructor that creates a formula element using the atoms in a molecule. * Adds occupancy (default 1.0) to count for each atom Sums charges for * atoms; if any are non-zero then sets formalCharge as sum. else if * molecule has formalCharge attribute uses this uses hydrogenCount if not * null; * * @param molecule * to analyze * @throws RuntimeException * if non-CML elements are present */ public CMLFormula(CMLMolecule molecule) { init(); int formalCharge = 0; // iterate through atoms adding elements, occupancies and charges // HydrogenStrategy strategy = null; for (CMLAtom atom : molecule.getAtoms()) { double occupancy = 1.0; if (atom.getOccupancyAttribute() != null) { occupancy = atom.getOccupancy(); } if (occupancy <= 0.0) { throw new RuntimeException("zero or negative occupancy: " + occupancy); } String elementType = atom.getElementType(); if (elementType == null || ChemicalElement.getChemicalElement(elementType) == null) { throw new RuntimeException( "Missing or invalid elementType for atom : "+atom.getId()+" .. " + elementType); } // if (AS.H.equals(elementType) && strategy == null) { // strategy = HydrogenStrategy.EXPLICIT_HYDROGENS; // } if (!AS.H.equals(elementType) ) { // HydrogenStrategy.EXPLICIT_HYDROGENS == strategy) { this.add(elementType, 1.0); // } if (atom.getFormalChargeAttribute() != null) { formalCharge += atom.getFormalCharge(); } int hydrogenCount = atom.getHydrogenCount(); if (hydrogenCount > 0) { this.add(AS.H.value, hydrogenCount); } } else { // only count a H if it is not bonded to non-hydrogens List oatoms = atom.getLigandAtoms(); boolean countit = true; for (CMLAtom chk : oatoms) { String ctype = chk.getElementType(); if ( !AS.H.equals(ctype)) { countit = false; } } if ( countit ) { this.add(AS.H.value, 1.0); if (atom.getFormalChargeAttribute() != null) { formalCharge += atom.getFormalCharge(); } } } } // has the molecule a net computed charge? if (formalCharge != Integer.MIN_VALUE) { this.setFormalCharge(formalCharge); } else if (molecule.getFormalChargeAttribute() != null) { this.setFormalCharge(molecule.getFormalCharge()); } } /** * copy constructor. * * @param old * to copy */ public CMLFormula(CMLFormula old) { this(); copyAttributesFrom(old); // concise will have triggered the creation of atomArray, so detach if // necessary CMLAtomArray newAtomArray = this.getAtomArrayElements().get(0); if (newAtomArray != null) { this.removeChild(newAtomArray); } copyChildrenFrom(old); copyProperties(old); } /** * * mainly used for software such as Jmol which dislikes * child atomArrays */ public void detachAllAtomArraysAsTheyAreAMenace() { CMLElements atomArrays = this.getAtomArrayElements(); for (CMLAtomArray atomArray : atomArrays) { atomArray.detach(); } } /** * copy node . * * @return Node */ public Element copy() { CMLFormula newForm = new CMLFormula(this); return newForm; } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLFormula */ public CMLElement makeElementInContext(Element parent) { return new CMLFormula(); } /** * shouldn't be necessary. * * @param parent * element */ public void finishMakingElement(Element parent) { super.finishMakingElement(parent); // try { // // DO NOT NORMALIZE //// normalize(); // } catch (RuntimeException e) { // LOG.info("skipped normalize() in finishMakingElement"); // } } // FIXME move to tools /** * normalizes the formula. * formula can be very polymorphic. Information can be in: *
    *
  • concise
  • *
  • inline
  • *
  • text content (not recommended)
  • *
  • atomArray
  • *
* normalize() will test, but NOT resolve inconsistencies * if fields are empty, will fill them, but will not overwrite them. * if content is non-empty and inline is empty, will transfer one to the other * * convention is honoured. There is a special case for SMILES which will be * expanded to a molecule contained within the formula. Others may inform * the creation of concise from inline * * Current precedence: * Concise and atomArray take precedence over inline (which can be difficult * to parse). * *
    *
  • *
  • if two or more atomArrays are present throws CMLRuntime
  • *
  • if no concise or atomArray is present does nothing.
  • *
  • if atomArray is present checks for array format; throws CMLRuntime * if not.
  • *
  • if concise but not atomArray is present, generates atomArray. If * formalCharge is present and in conflict throws CMLRuntime. If non-CML * elements are present or elements are duplicated, throws CMLRuntime. If * format is wrong (should have been detected already) throws CMLRuntime
  • *
  • sorts AtomArray according to CHFIRST
  • *
  • generates concise including trailing charge and overwrites any * previous version
  • *
* * @throws RuntimeException - * see above */ public void normalize() { // create all possible renderings of formula // any or all may be present // concise CMLAttribute conciseAtt = this.getConciseAttribute(); // formal charge int formalCharge = 0; if (this.getFormalChargeAttribute() != null) { formalCharge = this.getFormalCharge(); } String conciseS = (conciseAtt == null) ? null : conciseAtt.getValue(); // convention String convention = this.getConvention(); // inline formula (might be SMILES) String inline = this.getInline(); if (inline != null) { inline = inline.trim(); } // text content (deprecated - use inline) Nodes texts = this.query("text()"); String content = null; for (int i = 0; i < texts.size(); i++) { Text text = (Text) texts.get(i); String s = text.getValue(); s = s.trim(); if (s.length() != 0) { if (content == null) { content = s; } else { throw new RuntimeException("Cannot have 2 non-empty text children"); } } } // atomArray String atomArray2Concise = null; CMLAtomArray atomArray = null; CMLElements atomArrays = this.getAtomArrayElements(); if (atomArrays.size() > 1) { throw new RuntimeException( "Only one atomArray child allowed for formula; found: " + atomArrays.size()); } else if (atomArrays.size() == 1) { atomArray = atomArrays.get(0); atomArray.sort(Sort.CHFIRST); atomArray2Concise = atomArray.generateConcise(formalCharge); } // transfer any content to inline if (content != null) { if (inline == null || inline.equals(S_EMPTY)) { this.setInline(content); for (int i = 0; i < texts.size(); i++) { texts.get(i).detach(); } } else if (!inline.equals(content)) { throw new RuntimeException( "inline ("+inline+") differs from content ("+content+")"); } } // concise from inline if (inline != null) { if (SMILES.equals(convention) || SMILES1.equals(convention)) { // throw new RuntimeException("Move to SMILESTool"); // inline2Concise = getConciseFromSMILES(inline); } } if (conciseS == null) { if (atomArray2Concise != null) { conciseS = atomArray2Concise; } } if (conciseS != null) { conciseS = normalizeConciseAndFormalCharge(conciseS, formalCharge); } // if no atomArray, create if (atomArray == null) { // causes problems with Jmol // if (conciseS != null) { // atomArray = createAndAddAtomArrayAndFormalChargeFromConcise(conciseS); // } } else { checkAtomArrayFormat(atomArray); } if (atomArray != null) { atomArray.sort(Sort.CHFIRST); removeZeroAtomCounts(); } // check consistency if (atomArray2Concise != null && !atomArray2Concise.equals(conciseS)) { throw new RuntimeException("concise ("+conciseS+") and atomArray ("+atomArray2Concise+") differ"); } if (conciseS != null) { // by this time we may have generated a non-zero formal charge, so normalize it into concise conciseS = normalizeConciseAndFormalCharge(conciseS, this.getFormalCharge()); super.setConcise(conciseS); } } private void removeZeroAtomCounts() { } // FIXME move to tools // /** utility to convert SMILES to string. // * @param smiles // * @return string representing concise version // */ // public static String getConciseFromSMILES(String smiles) { // String concise = null; // if (smiles != null) { // SMILESTool smilesTool = new SMILESTool(); // smilesTool.parseSMILES(smiles); // CMLMolecule molecule = smilesTool.getMolecule(); // CMLFormula temp = new CMLFormula(molecule); // if (temp != null) { // concise = temp.getConcise(); // } // } // return concise; // } // /** * strips spaces and redundant 1's from concise * adds subscripts. Returns a span element without namespace * @param concise * @return subscripted concise or empty */ public static Element getSubscriptedConcise(String concise) { Element element = new Element("span"); if (concise != null) { String[] split = concise.split(S_SPACE); int len = split.length; int n = len/2; for (int j = 0; j < 2*n; j+=2) { element.appendChild(split[j]); if (!split[j+1].equals("1")) { Element sub = new Element("sub"); sub.appendChild(split[j+1]); element.appendChild(sub); } } if (len % 2 != 0) { element.appendChild(split[len-1]); } } return element; } CMLAtomArray createAndAddAtomArrayAndFormalChargeFromConcise( String concise) { CMLAtomArray atomArray = new CMLAtomArray(); if (concise != null) { List elements = new ArrayList(); List counts = new ArrayList(); String[] tokens = concise.split(S_WHITEREGEX); int nelement = tokens.length / 2; for (int i = 0; i < nelement; i++) { String elem = tokens[2 * i]; ChemicalElement chemicalElement = ChemicalElement .getChemicalElement(elem); if (chemicalElement == null) { throw new RuntimeException("Unknown chemical element: " + elem); } if (elements.contains(elem)) { throw new RuntimeException("Duplicate element in concise: " + elem); } elements.add(elem); String countS = tokens[2 * i + 1]; try { counts.add(Double.valueOf(countS)); } catch (NumberFormatException nfe) { throw new RuntimeException("Bad element count in concise: " + countS); } } if (tokens.length > nelement * 2) { String chargeS = tokens[nelement * 2]; try { int formalCharge = Integer.parseInt(chargeS); super.setFormalCharge(formalCharge); } catch (NumberFormatException nfe) { throw new RuntimeException("Bad formal charge in concise: " + chargeS); } } double[] countD = new double[nelement]; for (int i = 0; i < nelement; i++) { countD[i] = counts.get(i).doubleValue(); } atomArray.setElementTypeAndCount((String[]) elements.toArray(new String[0]), countD); } setAtomArray(atomArray); return atomArray; } private void setAtomArray(CMLAtomArray atomArray) { for (CMLAtomArray aa : this.getAtomArrayElements()) { aa.detach(); } super.appendChild(atomArray); } /** * checks that atomArray is in array format with unduplicated valid * elements. must have elementType and count attributes of equal lengths. * * @param atomArray * to check (not modified) * @throws RuntimeException * if invalid */ public void checkAtomArrayFormat(CMLAtomArray atomArray) { if (atomArray.getChildElements().size() > 0) { throw new RuntimeException("No children allowed for formula/atomArray"); } String[] elements = atomArray.getElementType(); double[] counts = atomArray.getCount(); if (elements == null || counts == null) { throw new RuntimeException( "formula/atomArray must have elementType and count attributes"); } if (elements.length != counts.length) { throw new RuntimeException( "formula/atomArray must have equal length elementType and count values"); } Set elementSet = new HashSet(); for (int i = 0; i < elements.length; i++) { if (elements[i] != null && !(elements[i].equals("null"))) { if (elementSet.contains(elements[i])) { throw new RuntimeException( "formula/atomArray@elementType has duplicate element: " + elements[i]); } elementSet.add(elements[i]); if (counts[i] <= 0 && !allowNegativeCounts) { throw new RuntimeException( "formula/atomArray@count has nonPositive value: " + counts[i] + " " + elements[i]); } } } } // trap special combinations /** * add child. must not add atomArray * * @param child */ public void appendChild(Element child) { if (child instanceof CMLAtomArray) { throw new RuntimeException("atomArray child of formula is deprecated"); } super.appendChild(child); } /** * removes optional charge field from concise formula. convenience method, * does not affect CMLormula object. * * @param s * concise string (assumed to be valid) * @return string without trailing charge (does NOT check validity) */ public static String removeChargeFromConcise(String s) { String s0 = s.trim(); String ss[] = s0.split(S_SPACE); if (ss.length % 2 != 0) { int idx = s0.lastIndexOf(S_SPACE); s0 = s0.substring(0, idx).trim(); } return s0; } /** * return concise formula without trailing charge. * * @return truncated concise (or null) */ public String getConciseNoCharge() { String concise = this.getConcise(); return (concise == null) ? null : removeChargeFromConcise(concise); } /** * strips spaces and redundant 1's from concise * @param concise * @return stripped concise or empty if null */ public static String getCompactedConcise(String concise) { return getCompactedConcise(concise, false); } /** * strips spaces and redundant 1's from concise * @param concise * @return stripped concise or empty if null */ public static String getCompactedConcise(String concise, boolean html) { String s = CMLConstants.S_EMPTY; if (concise != null) { String[] split = concise.split(S_SPACE); int n = split.length/2; for (int j = 0; j < 2*n; j+=2) { s += split[j]; if (!split[j+1].equals("1")) { if (html) { s += ""; } s += split[j+1]; if (html) { s += ""; } } } if (split.length % 2 != 0) { if (html) { s += ""; } s += makeCharge(split[split.length-1]); if (html) { s += ""; } } } return s; } private static String makeCharge(String ss) { int i = Integer.parseInt(ss); String s = (i < 0) ? CMLConstants.S_MINUS : CMLConstants.S_PLUS; i = Math.abs(i); if (i > 1) { s += i; } return s; } /** * set concise attribute. if atomArray is absent will automatically compute * atomArray and formalCharge, so use with care if atomArray is present will * throw CMLRuntime this logic may need to be revised * * @param value * concise value * @throws RuntimeException * attribute wrong value/type * */ public void setConcise(String value) throws RuntimeException { if (getAtomArrayElements().size() > 0) { throw new RuntimeException("Cannot reset concise if atomArray is present"); } forceConcise(value); } private void forceConcise(String value) { super.setConcise(value); normalize(); // if building, then XOM attributes are processed before children // this flag will allow subsequent atomArray to override processedConcise = true; } // FIXME move to tools private String normalizeConciseAndFormalCharge(String conciseS, int formalCharge) { if (conciseS != null) { CMLAtomArray atomArray = createAndAddAtomArrayAndFormalChargeFromConcise(conciseS); if (atomArray != null) { atomArray.sort(Sort.CHFIRST); conciseS = atomArray.generateConcise(formalCharge); } } return conciseS; } /** * set formal charge. this will re-compute concise if possible. * * @param ch */ public void setFormalCharge(int ch) { super.setFormalCharge(ch); if (this.getConciseAttribute() != null) { String concise = this.getConcise(); concise = CMLFormula.removeChargeFromConcise(concise); this.forceConcise(concise); } normalize(); } void init() { processedConcise = false; } /** * create formula from string. convention defaults to ANY * * @param s * the String describing the formula * @exception RuntimeException * @return the CMLFormula derived from the String s */ public static CMLFormula createFormula(String s) { return createFormula(s, Type.ANY); } /** * create formula from molecule. * @author nwe23 * @param mol * the CMLMolecule * @exception RuntimeException * @return the CMLFormula derived from the CMLMolecule */ public static CMLFormula createFormula(CMLMolecule mol){ if(mol==null){ return null; } return new CMLFormula(mol); } /** * create formula from string. convention defaults to ANY * * @param s the String describing the formula * @param allowNegativeCounts * @exception RuntimeException * @return the CMLFormula derived from the String s */ public static CMLFormula createFormula(String s, boolean allowNegativeCounts) { return createFormula(s, Type.ANY, allowNegativeCounts); } /** * create formula from string using convention. * * @param s * the String describing the formula * @param convention * the convention * @return the CMLFormula derived from the String s */ // shouldn't this be a constructor instead? public static CMLFormula createFormula(String s, Type convention) { CMLFormula docFormula = new CMLFormula(); if (s != null && !s.equals(S_EMPTY)) { docFormula.createFromString(s, convention); } else { docFormula = null; } return docFormula; } /** * create formula from string using convention. * * @param s the String describing the formula * @param convention the convention * @param allowNegativeCounts * @return the CMLFormula derived from the String s */ // shouldn't this be a constructor instead? public static CMLFormula createFormula(String s, Type convention, boolean allowNegativeCounts) { CMLFormula docFormula = new CMLFormula(); docFormula.setAllowNegativeCounts(allowNegativeCounts); docFormula.createFromString(s, convention); return docFormula; } /** * Sets the multiplier. * * Defaults to 1.0. * * @param count * multiplier for this moiety; */ // public void setCount(double count) {this.count = count;} /** * Gets the multplier. * * @return double count multiplier for this moiety; */ // public double getCount() {return count;} /** * Interpret string as a formula and replace contents. * * (Normal usage would be to create an empty Formula and fill it. If * formulaConvention is not ANY then a specific convention is used, for ANY * we try a mixture of heuristics. This allows us to throw exceptions if we * deviate from conventions. Does allow non-integer counts Does not do * brackets at present... * * @param formulaString * the string to interpret * @param formulaConvention * taken from list above * @throws RuntimeException * uninterpretable formula. */ /* * void createFromString(String formulaString, String formulaConvention) * throws CMLRuntime { formulaString = formulaString.trim(); if * (formulaConvention.equals(ELEMENT_WHITESPACE_COUNT) || * formulaConvention.equals(ELEMENT_COUNT_WHITESPACE)) { * parseElementCountWhitespace(formulaString, formulaConvention); } else if * (formulaConvention.equals(MULTIPLIED_ELEMENT_COUNT_WHITESPACE)) { * parseMultipliedElementCountWhitespace(formulaString); } else if * (formulaConvention.equals(MOIETY)) { parseMoiety(formulaString); } else * if (formulaConvention.equals(IUPAC)) { Util.sysout("IUPAC formula * convention not yet supported"); } else if * (formulaConvention.equals(NESTEDBRACKETS) || * formulaConvention.equals(STRUCTURAL)) { * Util.sysout("Nested/structural formula convention not yet * supported"); } else if (formulaConvention.equals(ANY)) { * parseAny(formulaString); } else { throw new CMLRuntime("Unknown formula * convention: "); } } */ void createFromString(String formulaString, Type formulaConvention) { formulaString = formulaString.trim(); if (formulaConvention.equals(Type.ELEMENT_WHITESPACE_COUNT) || formulaConvention.equals(Type.ELEMENT_COUNT_WHITESPACE)) { parseElementCountWhitespace(formulaString, formulaConvention); } else if (formulaConvention.equals(Type.NOPUNCTUATION)) { // parseElementCountWhitespace(formulaString, formulaConvention); parseAny(formulaString /*, formulaConvention*/); } else if (formulaConvention .equals(Type.MULTIPLIED_ELEMENT_COUNT_WHITESPACE)) { parseMultipliedElementCountWhitespace(formulaString); } else if (formulaConvention.equals(Type.MOIETY)) { parseMoiety(formulaString); } else if (formulaConvention.equals(Type.SUBMOIETY)) { parseSubMoiety(formulaString); } else if (formulaConvention.equals(Type.IUPAC)) { LOG.warn("IUPAC formula convention not yet supported"); } else if (formulaConvention.equals(Type.NESTEDBRACKETS) || formulaConvention.equals(Type.STRUCTURAL)) { LOG.debug("Nested/structural formula convention not yet supported"); } else if (formulaConvention.equals(Type.CONCISE)) { setConcise(formulaString); } else if (formulaConvention.equals(Type.ANY)) { parseAny(formulaString); } else { throw new RuntimeException("Unknown formula convention: " + formulaConvention.type); } } private void parseElementCountWhitespace(String formulaString, Type formulaConvention) { StringTokenizer st = new StringTokenizer(formulaString); while (st.hasMoreTokens()) { String s = st.nextToken(); String countS = null; String elTypeS = null; if (formulaConvention.equals(Type.ELEMENT_WHITESPACE_COUNT)) { try { countS = st.nextToken(); } catch (NoSuchElementException e) { throw new RuntimeException("Bad formula: {" + formulaString + CMLConstants.S_RCURLY); } elTypeS = s; } else { elTypeS = CMLConstants.S_EMPTY; int l = s.length(); if (!Character.isUpperCase(s.charAt(0))) { throw new RuntimeException("Bad element 1st char in: " + s); } if (l == 1) { elTypeS = s; countS = "1"; } else { if (Character.isLowerCase(s.charAt(1))) { elTypeS = s.substring(0, 2); countS = s.substring(2); } else { elTypeS = s.substring(0, 1); countS = s.substring(1); } } } double c = 0.0; ChemicalElement element = ChemicalElement .getChemicalElement(elTypeS); if (element == null) { throw new RuntimeException("Bad element (" + elTypeS + ") in: " + s); } if (countS.equals(S_EMPTY)) { c = 1; } else { try { c = Double.valueOf(countS).doubleValue(); } catch (NumberFormatException nfe) { throw new RuntimeException("Bad element count (" + countS + ") in: " + s); } } this.add(elTypeS, c); } String concise = getFormattedString(Type.ELEMENT_WHITESPACE_COUNT, Sort.CHFIRST, false).trim(); if (!concise.equals(S_EMPTY)) { super.setConcise(concise); } } private void parseMultipliedElementCountWhitespace(String formulaString) { formulaString.trim(); // can start with a number :-( int ii = 0; double mult = -1.0; while (ii < formulaString.length()) { if (formulaString.charAt(ii) == '.' || Character.isDigit(formulaString.charAt(ii))) { ii++; } else { break; } } if (ii != 0) { try { mult = Double.valueOf(formulaString.substring(0, ii)).doubleValue(); } catch (NumberFormatException nfe) { throw new RuntimeException( "Cannot interpret start of formula as multiplier: " + formulaString); } formulaString = formulaString.substring(ii); } int lb = formulaString.indexOf(S_LBRAK); int rb = formulaString.indexOf(S_RBRAK); if (lb == -1 && rb == -1) { this.createFromString(formulaString, Type.ANY); } else if (lb == 0 && rb != -1) { if (mult < 0.0) { // possible postmultiplier String r = formulaString.substring(rb + 1); if (r.length() > 0) { try { mult = Double.valueOf(r).doubleValue(); } catch (NumberFormatException nfe) { throw new RuntimeException("Bad multiplier in: " + formulaString); } } else { mult = 1.0; } } this.createFromString(formulaString.substring(1, rb), Type.ANY); } else { throw new RuntimeException( "Unbalanced () in multiplied formula string: " + formulaString); } if (mult > 0.0) { this.setCount(mult); } } /** * splits at commas. then creates nested formula and parses ANY. * * @param formulaString */ private void parseMoiety(String formulaString) { formulaString = formulaString.trim(); StringTokenizer st = new StringTokenizer(formulaString, CMLConstants.S_COMMA); if (st.countTokens() == 1) { parseMoiety0(formulaString); } else { while (st.hasMoreTokens()) { CMLFormula subForm = new CMLFormula(); String f = st.nextToken().trim(); subForm.parseMoiety0(f); this.appendChild(subForm); } } } private void parseMoiety0(String formulaString) { formulaString = formulaString.trim(); // can start with a number :-( int ii = 0; double mult = -1.0; while (ii < formulaString.length()) { if (formulaString.charAt(ii) == C_PERIOD || Character.isDigit(formulaString.charAt(ii))) { ii++; } else { break; } } if (ii != 0) { try { mult = Double.valueOf(formulaString.substring(0, ii)).doubleValue(); } catch (NumberFormatException nfe) { throw new RuntimeException( "Cannot interpret start of formula as multiplier: " + formulaString); } formulaString = formulaString.substring(ii); } int lb = formulaString.indexOf(S_LBRAK); int rb = formulaString.indexOf(S_RBRAK); if (lb == -1 && rb == -1) { this.parseSubMoiety(formulaString); } else if (lb == 0 && rb != -1) { if (mult < 0.0) { // possible postmultiplier String r = formulaString.substring(rb + 1); if (r.length() > 0) { try { mult = Double.valueOf(r).doubleValue(); } catch (NumberFormatException nfe) { throw new RuntimeException("Bad multiplier in: " + formulaString); } } else { mult = 1.0; } } this.parseSubMoiety(formulaString.substring(1, rb)); } else { throw new RuntimeException( "Unbalanced () in multiplied formula string: " + formulaString); } if (mult > 0.0) { this.setCount(mult); } } private void parseSubMoiety(String sm) { sm = sm.trim(); // List elementList = new ArrayList(); int charge = 0; StringTokenizer st = new StringTokenizer(sm); int l = st.countTokens(); for (int i = 0; i < l; i++) { String ss = st.nextToken(); String s = ss; int mult = 0; // charge at the end? if (i == l - 1) { char c = s.charAt(0); if (c == C_PLUS) { mult = 1; s = s.substring(1); } else if (c == C_MINUS) { mult = -1; s = s.substring(1); } else if (s.endsWith(S_PLUS)) { mult = 1; s = s.substring(0, s.length() - 1); } else if (s.endsWith(S_MINUS)) { mult = -1; s = s.substring(0, s.length() - 1); } if (mult != 0) { if (!s.trim().equals(S_EMPTY)) { try { charge = Integer.parseInt(s); } catch (NumberFormatException nfe) { throw new RuntimeException("Bad charge: " + s); } } else { charge = 1; } charge *= mult; } } // found charge if (mult != 0) { break; } s = ss; // get Element+count String elem = CMLConstants.S_EMPTY; double count = 0; if (Character.isUpperCase(s.charAt(0))) { if (s.length() > 1) { if (Character.isLowerCase(s.charAt(1))) { elem = s.substring(0, 2); s = s.substring(2); } else if (!Character.isDigit(s.charAt(1))) { throw new RuntimeException("Bad elementCount: " + s); } else { elem = s.substring(0, 1); s = s.substring(1); } if (s.trim().equals(S_EMPTY)) { count = 1.0; } else { try { count = Double.valueOf(s).doubleValue(); } catch (NumberFormatException nfe) { throw new RuntimeException( "Moiety cannot parse element count: " + s); } } } else { elem = s; count = 1.0; } } else { throw new RuntimeException("Moiety cannot parse element at: " + s); } if (elem.equals(S_EMPTY)) { throw new RuntimeException("Moiety cannot parse element: " + s); } ChemicalElement element = ChemicalElement.getChemicalElement(elem); if (element == null) { throw new RuntimeException("Bad element (" + elem + ") in: " + elem); } this.add(elem, count); } if (charge != 0) { this.setFormalCharge(charge); } } private void parseAny(String formulString) { // ANY - make whitespace separated string and then recurse StringBuilder result = new StringBuilder(); String ss = formulString.trim(); int l = ss.length(); int i = 0; int ii = 0; int charge = 0; while (i < l) { // skip white i = grabWhite(ss, i, l); if (i >= l) { break; // end of line } result.append(S_SPACE); ii = grabElement(ss, i, l); if (ii == i) { ii = grabCharge(ss, i, l); if (ii != i) { charge = parseCharge(ss.substring(i, ii)); } break; } result.append(ss.substring(i, ii)); result.append(S_SPACE); i = ii; i = grabWhite(ss, i, l); ii = grabCount(ss, i, l); if (ii == i) { result.append(1); } else { result.append(ss.substring(i, ii)); } i = ii; i = grabWhite(ss, i, l); } String sss = result.toString().trim(); createFromString(sss, Type.ELEMENT_WHITESPACE_COUNT); if (charge != 0) { this.setFormalCharge(charge); } } private static int parseCharge(String ss) { int i = 0; ss = ss.trim(); if (ss.equals(S_PLUS)) { i = 1; } else if (ss.startsWith(S_PLUS)) { i = Integer.parseInt(ss.substring(1)); } else if (ss.equals(S_MINUS)) { i = -1; } else if (ss.endsWith(S_MINUS)) { i = -Integer.parseInt(ss.substring(0, ss.length()-1)); } else { i = Integer.parseInt(ss); } return i; } private int grabCharge(String ss, int i, int l) { char c = ss.charAt(i); if (i < l && (c == C_MINUS || c == C_PLUS)) { i++; } while (i < l) { c = ss.charAt(i); if (!Character.isDigit(c)) { break; } i++; } return i; } private int grabCount(String ss, int i, int l) { if (allowNegativeCounts && i < l && ss.charAt(i) == C_MINUS) { i++; } while (i < l) { char c = ss.charAt(i); if (c != C_PERIOD && !Character.isDigit(c)) { break; } i++; } return i; } private int grabElement(String ss, int i, int l) { if (i < l && Character.isUpperCase(ss.charAt(i))) { i++; } if (i < l && Character.isLowerCase(ss.charAt(i))) { i++; } return i; } private int grabWhite(String ss, int i, int l) { while (i < l) { if (!Character.isWhitespace(ss.charAt(i))) { break; } i++; } return i; } // private void parseAnyOld(String formulaString) { // // FIXME // // ANY - make whitespace separated string and then recurse // String result = CMLConstants.S_EMPTY; // formulaString += CMLConstants.S_SPACE; // int l = formulaString.length(); // int i = 0; // char c; // int charge = 0; // String count = CMLConstants.S_EMPTY; // while (i < l) { // // skip white // while (formulaString.charAt(i) == C_SPACE) { // if (++i >= l) // break; // } // if (i >= l) // break; // c = formulaString.charAt(i); // // start element or charge // String el = CMLConstants.S_EMPTY; // // finish with -, -1, 1-, 2-, -2, +1, 1+, +2, 2+ ... etc // if (Character.isDigit(c) || c == C_PLUS || c == C_MINUS || c == C_PERIOD) { // if (true) throw new RuntimeException("FIX ME"); // charge = getFinalCharge(formulaString.substring(i).trim()); // break; // } // // upper case required // if (!Character.isUpperCase(c)) { // throw new RuntimeException("Formula: Cannot interpret element (" // + c + ") at char (" + (i + 1) + ") in: " // + formulaString); // } // el += c; // if (++i >= l) { // result += el + " 1"; // break; // } // c = formulaString.charAt(i); // // lower case optional // if (Character.isLowerCase(c)) { // el += c; // i++; // } // // skip white // while (formulaString.charAt(i) == C_SPACE) { // if (++i >= l) // break; // } // if (i >= l) { // result += el + " 1"; // break; // } // // multiplier? // c = formulaString.charAt(i); // // implied count of 1? // count = CMLConstants.S_EMPTY; // if (!Character.isDigit(c)) { // count = "1"; // } else { // while (true) { // c = formulaString.charAt(i); // if (!Character.isDigit(c) && c != C_PERIOD) { // break; // } // count += c; // if (++i == l) // break; // } // } // result += el + CMLConstants.S_SPACE + count + CMLConstants.S_SPACE; // } // createFromString(result, Type.ELEMENT_WHITESPACE_COUNT); // if (charge != 0) { // this.setFormalCharge(charge); // } // } // private int getFinalCharge(String f) { // if (!allowNegativeCounts && f.indexOf(' ') != -1) { // throw new RuntimeException("Charge must be final field: " + f); // } // int sign = 0; // int charge = 0; // String ch = CMLConstants.S_EMPTY; // int l = f.length(); // if (f.charAt(0) == C_PLUS) { // sign = 1; // ch = f.substring(1); // } else if (f.charAt(0) == C_MINUS) { // sign = -1; // ch = f.substring(1); // } else if (f.indexOf(C_PLUS) == l - 1) { // sign = 1; // ch = f.substring(0, l - 1); // } else if (f.indexOf(C_MINUS) == l - 1) { // sign = -1; // ch = f.substring(0, l - 1); // } else { // throw new RuntimeException("Cannot parse as charge field: " + f); // } // if (ch.equals(S_EMPTY)) { // charge = 1; // } else { // try { // charge = Integer.parseInt(ch); // } catch (NumberFormatException nfe) { // throw new RuntimeException("Cannot parse as charge field: " + f + "("+ch+")"); // } // } // return sign * charge; // } /** * Adds element and count to formula. If element is already known, * increments the count. * * @param elementType * the element atomicSymbol * @param count * the element multiplier */ public void add(String elementType, double count) { CMLAtomArray atomArray = (getAtomArrayElements().size() == 0) ? null : getAtomArrayElements().get(0); if (atomArray == null) { // if no atomArray , create from concise normalize(); // if still none, create new one with empty attributes if (atomArray == null) { atomArray = new CMLAtomArray(); setAtomArray(atomArray); atomArray.setElementTypeAndCount(new String[0], new double[0]); } } String[] elements = getElementTypes(); if (elements == null) { elements = new String[0]; } double[] counts = getCounts(); if (counts == null) { counts = new double[0]; } int nelem = elements.length; boolean added = false; for (int i = 0; i < nelem; i++) { if (elements[i].equals(elementType)) { counts[i] += count; added = true; break; } } if (!added) { String[] newElem = new String[nelem + 1]; System.arraycopy(elements, 0, newElem, 0, nelem); newElem[nelem] = elementType; double[] newCount = new double[nelem + 1]; System.arraycopy(counts, 0, newCount, 0, nelem); newCount[nelem] = count; atomArray.setElementTypeAndCount(newElem, newCount); } else { atomArray.setElementTypeAndCount(elements, counts); } int formalCharge = (this.getFormalChargeAttribute() == null) ? 0 : this.getFormalCharge(); String conciseS = atomArray.generateConcise(formalCharge); super.setConcise(conciseS); } /** * Count for corresponding element. * * No defaults. * * @return double[] array of element counts; or null for none. */ public double[] getCounts() { CMLAtomArray atomArray = (getAtomArrayElements().size() == 0) ? null : getAtomArrayElements().get(0); return (atomArray == null) ? null : atomArray.getCount(); } // CMLAtomArray atomArray = (getAtomArrayElements().size() == 0) ? null // : getAtomArrayElements().get(0); // return (atomArray == null) ? null : atomArray.getElementType(); /** get atom count * @return count */ public double getTotalAtomCount() { //nwe23 - Fixed a bug here where getCounts() returns null // for an empty formula, resulting in this crashing rather than // returning 0 as expected for empty formula double[] counts = getCounts(); if(counts==null){ return 0; } double total = 0; for (double count : counts) { total += count; } return total; } /** * Count for corresponding element. * * No defaults. * * @return double[] array of element counts; or null for none. */ public String[] getElementTypes() { CMLAtomArray atomArray = (getAtomArrayElements().size() == 0) ? null : getAtomArrayElements().get(0); return (atomArray == null) ? null : atomArray.getElementType(); } /** * multiply all counts by the same constant factor. this is normally used to * multiply formula which represent a subfragment of a symmetrical molecule * it is distinct from the count attribute which represents two of more * independent entities * * @param d * to multiply by */ public void multiplyBy(double d) { CMLAtomArray atomArray = (getAtomArrayElements().size() == 0) ? null : getAtomArrayElements().get(0); if (atomArray != null) { String[] elems = this.getElementTypes(); double counts[] = getCounts(); for (int i = 0; i < counts.length; i++) { counts[i] *= d; } // atomArray.setCount(counts); atomArray.setElementTypeAndCount(elems, counts); } else { // convoluted! create new formula , multiply it and suck out the // values String concise = this.getConcise(); CMLFormula fNew = new CMLFormula(); fNew.createFromString(concise, Type.ELEMENT_WHITESPACE_COUNT); fNew.multiplyBy(d); String concise1 = fNew.getConcise(); this.setConcise(concise1); CMLAtomArray fAtomArray = fNew.getAtomArrayElements().get(0); fAtomArray.detach(); this.addAtomArray(fAtomArray); } String concise = this.getAtomArrayElements() .get(0).generateConcise((int) (this.getFormalCharge() * d)); super.setConcise(concise); } /** * Adds a child formula to the content. if this is empty formula, no action. * if this has no children, copy this and add as a child, detaching * atomArray and removing concise from this after that f is copied and * appended as child * * @param f * to be copied and added. null is ignored */ public void addFormula(CMLFormula f) { CMLAtomArray atomArray = this.getAtomArrayElements().get(0); CMLElements formulas = this.getFormulaElements(); if (formulas.size() == 0 && atomArray != null) { CMLFormula thisCopy = new CMLFormula(this); super.appendChild(thisCopy); atomArray.detach(); // remove current concise attribute CMLAttribute att = this.getConciseAttribute(); if (att != null) { this.removeAttribute(att); } att = this.getCountAttribute(); if (att != null) { this.removeAttribute(att); } } if (atomArray != null) { CMLFormula ff = new CMLFormula(f); super.appendChild(ff); } } /** * gets single formula representing all contents. * * all formulae are added, using count when present. the current formula is * not modified can be used for adding separate formula * * @return composite formula (no formulaVector child) */ public CMLFormula getAggregateFormula() { CMLFormula newFormula = null; CMLElements formulas = this.getFormulaElements(); if (formulas.size() == 0) { newFormula = this; } else { newFormula = new CMLFormula(); for (CMLFormula formula : formulas) { newFormula = newFormula.createAggregatedFormula(formula); } } return newFormula; } /** * aggregates two formulae including charge. * * if either formula is composite, aggregates them first current formula is * updated to contain aggregate, destroying any structure if no contents, * uses concise attribute * * @param form * to aggregate * @return formula */ public CMLFormula createAggregatedFormula(CMLFormula form) { if (form == null) { throw new RuntimeException("Null formula in createAggregatedFormula"); } CMLFormula newFormula = new CMLFormula(); newFormula.setAllowNegativeCounts(this.allowNegativeCounts | form.allowNegativeCounts); newFormula.aggregate(this); form = form.getAggregateFormula(); newFormula.aggregate(form); return newFormula; } void aggregate(CMLFormula form) { String[] fElements = form.getElementTypes(); double[] fCounts = form.getCounts(); double thisCount = (this.getCountAttribute() == null) ? 1.0 : this .getCount(); double fCount = (form.getCountAttribute() == null) ? 1.0 : form .getCount(); int thisCharge = (this.getFormalChargeAttribute() == null) ? 0 : this .getFormalCharge(); int fCharge = (form.getFormalChargeAttribute() == null) ? 0 : form .getFormalCharge(); if (fElements != null) { for (int i = 0; i < fElements.length; i++) { this.add(fElements[i], fCounts[i] * fCount); } } else { // build from concise String concise = CMLConstants.S_EMPTY; concise = form.getFormattedString(Type.ELEMENT_WHITESPACE_COUNT, Sort.CHFIRST, false).trim(); if (getConciseAttribute() != null) { CMLFormula newForm = new CMLFormula(); newForm.createFromString(concise, Type.ANY); aggregate(newForm); } } // fix charges int newCharge = (int) (thisCharge * thisCount + fCharge * fCount); if (newCharge != 0) { this.setFormalCharge(newCharge); } else if (this.getFormalChargeAttribute() != null) { this.removeAttribute(this.getFormalChargeAttribute()); } // set count to unity/remove Attribute countAttribute = this.getCountAttribute(); if (countAttribute != null) { this.removeAttribute(this.getCountAttribute()); } normalize(); } /** * gets count of formula. defaults to 1.0 * * @return formula count */ public double getCount() { double fCount = 1.0; if (getCountAttribute() != null) { fCount = super.getCount(); if (Math.round((float) fCount) == 0) { fCount = 1.0; this.setCount(fCount); } } return fCount; } public Double getElementCount(String elementType) { String[] elementTypes = getElementTypes(); double[] counts = getCounts(); if (elementTypes != null) { for (int i = 0; i < elementTypes.length; i++) { String el = elementTypes[i]; if (el.equals(elementType)) { return counts[i]; } } } return null; } /** * divide one formula by another. * * requires exactly the same elements are present in each and in the same * order. 'this' should be the largest formula at present expects the * results to be integer. * * @param f * formula to divide into 'this' * @param eps * allowed tolerance between element ratios * @return the multiplier (Double.NaN if operation fails) */ public double divideBy(CMLFormula f, double eps) { double divide = Double.NaN; String[] elementTypes = this.getElementTypes(); double[] counts = this.getCounts(); if (f != null) { String[] fElem = f.getElementTypes(); double[] fCounts = f.getCounts(); if (fElem != null && fElem.length == elementTypes.length) { for (int i = 0; i < fElem.length; i++) { // sorted; check for error if (!elementTypes[i].equals(fElem[i]) || fCounts[i] == 0.0) { divide = Double.NaN; break; } double dd = counts[i] / fCounts[i]; if (Double.isNaN(divide)) { divide = dd; } else if (Math.abs(divide - dd) > eps) { divide = Double.NaN; break; } } } } return divide; } /** * get calculated molecular mass. * * @return calculated molecular mass. * @throws RuntimeException unknown/unsupported element type (Dummy counts as zero mass) */ public double getCalculatedMolecularMass() throws RuntimeException { double mwt = 0.0; Elements formulas = this.getChildElements("formula", CMLConstants.CML_NS); if (formulas.size() > 0) { for (int i = 0; i < formulas.size(); i++) { CMLFormula formula = (CMLFormula) formulas.get(i); mwt += formula.getCalculatedMolecularMass(); } } else { String[] elementTypes = this.getElementTypes(); double[] counts = this.getCounts(); if (counts != null) { for (int i = 0; i < counts.length; i++) { mwt += getAtomicMass(elementTypes[i]) * counts[i]; } } } return getCount() * mwt; } /** * get mass for elementType. * * @param elementType * @return 0.0 if unknown or null */ private static double getAtomicMass(String elementType) { double mass = 0.0; if (elementType != null) { ChemicalElement el = ChemicalElement .getChemicalElement(elementType); mass = (el == null) ? 0.0 : el.getAtomicWeight(); } return mass; } /** convenience to get concise from a string. * uses type ANY * typically used for inline * @param s * @return concise of null */ public static String createConcise(String s) { CMLFormula temp = CMLFormula.createFormula(s, Type.ANY); return (temp == null) ? null : temp.getConcise(); } /** * Get formatted formula. * * @param convention * *
	 *      NOPUNCTUATION      "C2H4Cl2" (default)
	 *      ELEMENT_COUNT_WHITESPACE "C2 H4 Cl2"
	 *      ELEMENT_WHITESPACE_COUNT "C 2 H 4 Cl 2"
	 *      NESTEDBRACKETS     "(Na2)(SO4).10(H2O)"
	 * 
* * @param sort * *
	 *      ALPHABETIC_ELEMENTS    "Br C Cl H"
	 *      CHFIRST      = "C H Br Cl"; (default)
	 * 
* * @param omitCount1 * omit elements count if 1 (default false) * @return String the formatted formula * @throws RuntimeException */ public String getFormattedString(Type convention, Sort sort, boolean omitCount1) throws RuntimeException { if (sort == null) { sort = Sort.CHFIRST; } if (!sort.equals(Sort.CHFIRST) && !sort.equals(Sort.ALPHABETIC_ELEMENTS)) { sort = Sort.CHFIRST; } if (convention == null || convention.equals(S_EMPTY)) { convention = Type.NOPUNCTUATION; } if (!convention.equals(Type.NOPUNCTUATION) && !convention.equals(Type.NESTEDBRACKETS) && !convention.equals(Type.ELEMENT_WHITESPACE_COUNT) && !convention.equals(Type.ELEMENT_COUNT_WHITESPACE)) { convention = Type.NOPUNCTUATION; } normalize(); CMLAtomArray atomArray = (getAtomArrayElements().size() == 0) ? null : getAtomArrayElements().get(0); if (atomArray != null) { atomArray.sort(sort); } StringBuffer sb = new StringBuffer(); Elements formulas = this.getChildElements("formula", CMLConstants.CML_NS); if (convention.equals(Type.NESTEDBRACKETS)) { for (int i = 0; i < formulas.size(); i++) { CMLFormula formula = (CMLFormula) formulas.get(i); String c = Util.outputNumber(NPLACES, NDEC, formula.getCount()); if (!omitCount1 || !c.equals("1")) { sb.append(c); } sb.append(S_LBRAK); sb.append(this.getFormattedString(convention, sort, omitCount1)); sb.append(S_RBRAK); } return sb.toString(); } else { combineSubFormulaElementVectors(); if (atomArray != null) { atomArray.sort(sort); } } String[] elementTypes = this.getElementTypes(); double[] counts = this.getCounts(); if (elementTypes != null && counts != null) { for (int i = 0; i < elementTypes.length; i++) { sb.append(elementTypes[i]); String s = Util.outputNumber(NPLACES, NDEC, counts[i]).trim(); if (!omitCount1 || !s.equals("1")) { if (convention.equals(Type.ELEMENT_WHITESPACE_COUNT)) { sb.append(S_SPACE); } sb.append(s); } if (convention.equals(Type.ELEMENT_WHITESPACE_COUNT) || convention.equals(Type.ELEMENT_COUNT_WHITESPACE)) { sb.append(S_SPACE); } } } // trim any trailing blanks int l = sb.length(); while (l > 0 && sb.charAt(--l) == ' ') { sb.deleteCharAt(l); } String s = getFormalChargeString().trim(); if (!s.equals(S_EMPTY)) { if (!convention.equals(Type.NOPUNCTUATION)) { sb.append(S_SPACE); } sb.append(s); } return sb.toString(); } /** * gets the charge on the formula. * * if there are child Formulas, iterate through, summing. * * @return the charge */ public int getFormalCharge() { int charge = 0; Elements childFormulas = this.getChildElements("formula", CMLConstants.CML_NS); if (childFormulas.size() > 0) { for (int i = 0; i < childFormulas.size(); i++) { CMLFormula childFormula = (CMLFormula) childFormulas.get(i); charge += childFormula.getFormalCharge() * childFormula.getCount(); } } else { if (this.getFormalChargeAttribute() != null) { charge = super.getFormalCharge(); } } return charge; } /** * translates charge to an integer and then to String. * * @return charge as a String */ public String getFormalChargeString() { String s = CMLConstants.S_EMPTY; int iCharge = this.getFormalCharge(); if (iCharge == 0) { ; } else if (iCharge < 0) { for (int i = iCharge; i < 0; i++) { s += CMLConstants.S_MINUS; } } else { for (int i = 0; i < iCharge; i++) { s += CMLConstants.S_PLUS; } } return s; } /** * default formula. * * @return default formula */ public String getFormattedString() { return getFormattedString(null, null, true); } private void combineSubFormulaElementVectors() { Elements formulas = this.getChildElements("formula", CMLConstants.CML_NS); if (formulas.size() > 0) { for (int i = 0; i < formulas.size(); i++) { CMLFormula subFormula = (CMLFormula) formulas.get(i); String[] subElementTypes = subFormula.getElementTypes(); double[] subCounts = subFormula.getCounts(); for (int j = 0; j < subElementTypes.length; j++) { this.add((String) subElementTypes[j], subCounts[j] * subFormula.getCount()); } } } } /** * Calculate molecular mass from vector of element symbols and their counts. * * @param countArray * @param elementTypeVector * @return mass */ public static double getCalculatedMass(List elementTypeVector, RealArray countArray) { if (elementTypeVector == null || countArray == null || elementTypeVector.size() != countArray.size()) { throw new RuntimeException("Bad arguments"); } double mwt = 0.0; for (int i = 0; i < elementTypeVector.size(); i++) { String elType = elementTypeVector.get(i); ChemicalElement el = ChemicalElement.getChemicalElement(elType); if (el == null) { throw new RuntimeException("Unsupported element: " + elType); } mwt += el.getAtomicWeight() * countArray.elementAt(i); } return mwt; } /** * Output debug info to Writer. * * @param w * output * @throws IOException */ public void debug(Writer w) throws IOException { w.write("\n------------formula-------------\n"); w.write(this.toString()); } /** * tests equality of formulae. order of elements should be unimportant * * @param form * to compare with this * @param eps * tolerance for element counts * @return true if formulae are equals */ public boolean equals(CMLFormula form, double eps) { boolean equals = false; String[] thisElem = this.getElementTypes(); String[] formElem = form.getElementTypes(); boolean ee = Arrays.equals(thisElem, formElem); double[] thisCount = this.getCounts(); double[] formCount = form.getCounts(); if (thisCount == null) { thisCount = new double[0]; } if (formCount == null) { formCount = new double[0]; } boolean cc = Real.isEqual(thisCount, formCount, eps); if (ee && cc) { equals = true; } return equals; } /** * compares current concise strings. * could fail if strings have decimal points * * @param f * @return true if equal */ public boolean equalsConcise(CMLFormula f) { boolean equals = false; equals = this.getConcise().equals(f.getConcise()); return equals; } /** * difference between formulas. * * formula is difference between this and f on an element by element basis. * Negative values are used where f has a greater element count that this. * Zero element counts are ommitted * * @param form formula to compare * @return difference (but may contain negative values) */ public CMLFormula getDifference(CMLFormula form) { Map countTable = new HashMap(); String[] elementTypes = this.getElementTypes(); double[] counts = this.getCounts(); double thisCount = (this.getCountAttribute() == null) ? 1.0 : this.getCount(); if (elementTypes != null && counts != null) { for (int i = 0; i < elementTypes.length; i++) { countTable.put(elementTypes[i], Double.valueOf(counts[i])); } } CMLFormula newFormula = new CMLFormula(); newFormula.setAllowNegativeCounts(true); String[] fElementTypes = form.getElementTypes(); double[] fCounts = form.getCounts(); double fCount = (form.getCountAttribute() == null) ? 1.0 : form.getCount(); if (fElementTypes != null && fCounts != null) { for (int i = 0; i < fElementTypes.length; i++) { String element = fElementTypes[i]; Double count = countTable.get(element); // not in this double delta = 0.0; if (count == null) { delta = 0.0 - fCounts[i]; } else { delta = count.doubleValue() * thisCount - fCounts[i] * fCount; } if (Math.abs(delta) > 0.000001) { newFormula.add(element, delta); } countTable.remove(element); } } // not in f for (String element : countTable.keySet()) { Double count = countTable.get(element); if (count != null) { newFormula.add(element, count.doubleValue() * thisCount); } } int charge = (int) Math.round(this.getFormalCharge() * thisCount - form.getFormalCharge() * fCount); if (charge != 0) { newFormula.setFormalCharge(charge); } return newFormula; } /** * are two formulas equal. * * use aggregated formulae as basis * * @param form formula to compare * @return true if equal */ public boolean equalsAggregate(CMLFormula form) { CMLFormula differenceFormula = this.getDifference(form); return differenceFormula.isEmpty(); } /** formula contains no element or elemnts with (near) zero counts * * @return true if empty */ public boolean isEmpty() { boolean zero = true; String[] elementTypes = getElementTypes(); double[] counts = getCounts(); if (elementTypes != null && counts != null) { for (int i = 0; i < elementTypes.length; i++) { if (!Real.isZero(counts[i], Real.getEpsilon())) { zero = false; break; } } } return zero; } /** * create formula string. * * @return the string */ public String toFormulaString() { String s = "count: " + this.getCount() + "; charge: " + this.getFormalCharge() + ": "; CMLElements formulas = this.getFormulaElements(); for (CMLFormula formula : formulas) { s += "\nForm: " + formula.toFormulaString(); } String[] elementTypes = this.getElementTypes(); if (elementTypes != null) { double[] counts = this.getCounts(); for (int i = 0; i < elementTypes.length; i++) { double d = counts[i]; s += elementTypes[i] + ((d > 1.000000001) ? CMLConstants.S_LBRAK + counts[i] + CMLConstants.S_RBRAK : CMLConstants.S_EMPTY); } } return s; } /** * output HTML. * * @param w * @throws IOException */ public void writeHTML(Writer w) throws IOException { w.write(""); CMLElements formulas = this.getFormulaElements(); if (formulas.size() > 0) { for (CMLFormula formula : formulas) { double count = formula.getCount(); w.write(S_LBRAK); formula.writeHTML(w); w.write(S_RBRAK); String cStr = String.valueOf(count); if (cStr.endsWith(".0")) { cStr = cStr.substring(0, cStr.length()-2); } if (!cStr.equals("1")) { w.write(""+cStr+""); } } } else { String[] elementTypes = this.getElementTypes(); if (elementTypes != null) { double[] counts = this.getCounts(); for (int i = 0; i < elementTypes.length; i++) { w.write(elementTypes[i]); double d = counts[i]; int c = (int) Math.round(d); String countS = CMLConstants.S_EMPTY; if (Math.abs(d - c) < EPS) { countS = CMLConstants.S_EMPTY+c; } else { countS = CMLConstants.S_EMPTY+d; } if (!countS.equals("1")) { w.write(""+countS+""); } } if (this.getFormalChargeAttribute() != null) { int fc = this.getFormalCharge(); int signum = Integer.signum(fc); String sign = CMLConstants.S_EMPTY; //no need to assign CMLConstants.S_MINUS to sign if signum is negative as the CMLConstants.S_MINUS will be in the formalChargeAttribute if (signum == 1) { sign = CMLConstants.S_PLUS; } if (fc != 0) { w.write(""+fc+sign+""); } } w.write(""); } } } /** * test. maybe obsolete * * @param args */ public static void mainTest(String[] args) { if (args.length == 0) { Util.println("Usage: FormulaImpl -IN xmlFile -OUT formFile -FORMAT format -MWT"); // format -MWT -HCOUNT|EXPLICIT"); Util.println(" Format NOSPACE EL_SPACE_COUNT EL_COUNT_SPACE"); System.exit(0); } int i = 0; String infile = CMLConstants.S_EMPTY; String outfile = CMLConstants.S_EMPTY; String formatS = CMLConstants.S_EMPTY; Type format = null; // String hCount = MoleculeTool.USE_HYDROGEN_COUNT; while (i < args.length) { if (args[i].equalsIgnoreCase("-IN")) { infile = args[++i]; i++; } else if (args[i].equalsIgnoreCase("-OUT")) { outfile = args[++i]; i++; } else if (args[i].equalsIgnoreCase("-FORMAT")) { formatS = args[++i]; i++; // } else if (args[i].equalsIgnoreCase("-HCOUNT")) { // hCount = MoleculeTool.USE_HYDROGEN_COUNT; // i++; // } else if (args[i].equalsIgnoreCase("-EXPLICIT")) { // hCount = MoleculeTool.USE_EXPLICIT_HYDROGENS; // i++; } else { System.err.println("Bad argument: " + args[i]); i++; } } if (formatS.equals(S_EMPTY)) { formatS = "EL_SPACE_COUNT"; } if (formatS.equals("EL_SPACE_COUNT")) { format = Type.ELEMENT_WHITESPACE_COUNT; } else if (formatS.equals("EL_COUNT_SPACE")) { format = Type.ELEMENT_COUNT_WHITESPACE; } else if (formatS.equals("NOSPACE")) { format = Type.NOPUNCTUATION; } else { System.err.println("Unsupported format: " + formatS); } try { if (!infile.equals(S_EMPTY)) { CMLBuilder builder = new CMLBuilder(); Document document = builder.build(new File(infile)); Elements moleculeVector = document.getRootElement() .getChildElements(CMLMolecule.TAG, CMLConstants.CML_NS); List formulaVector = new ArrayList(); for (i = 0; i < moleculeVector.size(); i++) { CMLMolecule molecule = (CMLMolecule) moleculeVector.get(i); if (molecule == null) { System.err.println("No molecule"); } else { CMLFormula formula = (CMLFormula) molecule .getFirstChildElement("formula", CMLConstants.CML_NS); if (formula != null) { String s = "" + formula.getFormattedString(format, Sort.CHFIRST, false) + ""; formulaVector.add(s); } } } if (!outfile.equals(S_EMPTY)) { FileWriter fw = new FileWriter(outfile); fw.write("\n"); for (i = 0; i < formulaVector.size(); i++) { fw.write(S_EMPTY + formulaVector.get(i) + CMLConstants.S_NL); } fw.write("\n"); fw.close(); } } /*-- "Formula: "+this.toString()+S_NL+ "MWt:"+this.getCalculatedMolecularMass()+S_NL+ this.getFormattedString(CMLFormula.NOPUNCTUATION, CMLFormula.CHFIRST, false)+S_NL+ this.getFormattedString(CMLFormula.ELEMENT_WHITESPACE_COUNT, CMLFormula.CHFIRST, false)+S_NL+ this.getFormattedString(CMLFormula.ELEMENT_COUNT_WHITESPACE, CMLConstants.S_EMPTY, false)+S_NL+ this.getFormattedString(CMLFormula.NESTEDBRACKETS, CMLFormula.CHFIRST, false)+S_NL+ this.getFormattedString(CMLFormula.NOPUNCTUATION, CMLFormula.ALPHABETIC_ELEMENTS, true)+S_NL+ this.getFormattedString(CMLFormula.ELEMENT_WHITESPACE_COUNT, CMLFormula.CHFIRST, true)+S_NL+ this.getFormattedString(CMLFormula.ELEMENT_COUNT_WHITESPACE, CMLConstants.S_EMPTY, true)+S_NL+ this.getFormattedString(CMLFormula.NESTEDBRACKETS, CMLFormula.ALPHABETIC_ELEMENTS, true); --*/ } catch (Exception e) { e.printStackTrace(); } } /** * @return the allowNegativeCounts */ public boolean isAllowNegativeCounts() { return allowNegativeCounts; } /** * @param allowNegativeCounts the allowNegativeCounts to set */ public void setAllowNegativeCounts(boolean allowNegativeCounts) { this.allowNegativeCounts = allowNegativeCounts; } /** * @return the processedConcise */ public boolean isProcessedConcise() { return processedConcise; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLFragment.java000077500000000000000000000071571477224461000261440ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** fragment normally contains molecules. * * * \n \nfragment is a container for a molecule, potentially to be joined * to other fragments. In addition there may be fragmentLists which * represent branches from the molecule. There may also be a join * child which is normally only found if there is a @countExpression. * * user-modifiable class autogenerated from schema if no class exists * use as a shell which can be edited * the autogeneration software will not overwrite an existing class file * * Current thinking on Fragment: * (a) create one or more fragments by processing single child fragment * fragmentList * fragment * * fragmentList * fragment * fragment * fragment * * or by using a countExpression: * fragmentList countExpression() * fragment * * (b) list of fragments to be joined: * fragment * fragment * join * fragment * join * fragment * ... * * creates a single fragment * * (c) fragmentList can hold a list of fragments as above but also can hold * a single fragment which can be expanded through countExpression(). * It must have exactly this format * * fragmentList @countExpression * join * fragment * * produces: * fragment * fragment * join * fragment * join * fragment * ... * * which is the same as (b) abd cab be processed to a single fragment * * (d) branching can only occur from molecules and has the format: * molecule * fragmentList * join * fragment * join * fragment * each fragment must be preceeded by a join , and fragmentList is required * even if there is only one fragment * * (e) fragments usually contain one molecule: * fragment * molecule * */ public class CMLFragment extends AbstractFragment { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** constructor. */ public CMLFragment() { } /** must give simple documentation. * * @param old CMLFragment to copy */ public CMLFragment(CMLFragment old) { super((org.xmlcml.cml.element.AbstractFragment) old); } /** copy node . * shallow copy * @return Node */ public Element copy() { return new CMLFragment(this); } /** create new instance in context of parent, overridable by subclasses. * * @param parent parent of element to be constructed (ignored by default) * @return CMLFragment */ public CMLElement makeElementInContext(Element parent) { return new CMLFragment(); } /** ensure integrity between list and children. * @return CMLFragmentList.class */ public Class getIndexableListClass() { return CMLFragmentList.class; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLFragmentList.java000077500000000000000000000040571477224461000267740ustar00rootroot00000000000000/** * 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. */ // /*======AUTOGENERATED FROM SCHEMA; DO NOT EDIT BELOW THIS LINE ======*/ package org.xmlcml.cml.element; import nu.xom.Element; import org.xmlcml.cml.base.CMLElement; /** A container for one or more fragments and joins. * * * \n \nfragmentList can contain several fragments and joins. \nThe normal content model is\n \njoin fragment join fragment...\n \n * * user-modifiable class autogenerated from schema if no class exists * use as a shell which can be edited * the autogeneration software will not overwrite an existing class file */ public class CMLFragmentList extends AbstractFragmentList { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** constructor * */ public CMLFragmentList() { } /** copy constructor. * * @param old CMLFragmentList to copy */ public CMLFragmentList(CMLFragmentList old) { super((org.xmlcml.cml.element.AbstractFragmentList) old); } /** copy node . * * @return Node */ public Element copy() { return new CMLFragmentList(this); } /** create new instance in context of parent, overridable by subclasses. * * @param parent parent of element to be constructed (ignored by default) * @return CMLFragmentList */ public CMLElement makeElementInContext(Element parent) { return new CMLFragmentList(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLGradient.java000077500000000000000000000033131477224461000261240ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting gradient. * autogenerated from schema use as * a shell which can be edited * */ public class CMLGradient extends AbstractGradient { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLGradient() { } /** * constructor. * * @param old */ public CMLGradient(CMLGradient old) { super((AbstractGradient) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLGradient(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLGradient */ public CMLElement makeElementInContext(Element parent) { return new CMLGradient(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLIdentifier.java000077500000000000000000000034101477224461000264470ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting identifier. * autogenerated from schema use * as a shell which can be edited * */ public class CMLIdentifier extends AbstractIdentifier { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLIdentifier() { } /** * constructor. * * @param old */ public CMLIdentifier(CMLConstants old) { super((AbstractIdentifier) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLIdentifier(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLIdentifier */ public CMLElement makeElementInContext(Element parent) { return new CMLIdentifier(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLIsotope.java000077500000000000000000000033011477224461000260060ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting isotope. * autogenerated from schema use as * a shell which can be edited * */ public class CMLIsotope extends AbstractIsotope { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLIsotope() { } /** * constructor. * * @param old */ public CMLIsotope(CMLIsotope old) { super((AbstractIsotope) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLIsotope(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLIsotope */ public CMLElement makeElementInContext(Element parent) { return new CMLIsotope(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLIsotopeList.java000077500000000000000000000032331477224461000266460ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting isotopeList. * autogenerated from schema use * as a shell which can be edited * */ public class CMLIsotopeList extends AbstractIsotopeList { /** * constructor. */ public CMLIsotopeList() { } /** * constructor. * * @param old */ public CMLIsotopeList(CMLIsotopeList old) { super((AbstractIsotopeList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLIsotopeList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLIsotopeList */ public CMLElement makeElementInContext(Element parent) { return new CMLIsotopeList(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLJoin.java000077500000000000000000000206611477224461000252730ustar00rootroot00000000000000/** * 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. */ // /*======AUTOGENERATED FROM SCHEMA; DO NOT EDIT BELOW THIS LINE ======*/ package org.xmlcml.cml.element; import nu.xom.Element; import nu.xom.ParentNode; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.euclid.Util; /** . * * * \n EXPERIMENTAL. join will normally use atomRefs2 to identify 2 R atoms\n (i.e. elementType='R' that should be joined. The atoms to which the R atoms\n are attached are then joined by a new bond and the R groups are then deleted. It is currently \nan error if these atoms already have a connecting bond. * * user-modifiable class autogenerated from schema if no class exists * use as a shell which can be edited * the autogeneration software will not overwrite an existing class file */ public class CMLJoin extends org.xmlcml.cml.element.AbstractJoin { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** relationship of molecule in moleculeRefs2. * */ public enum MoleculePointer { /** child.*/ CHILD, /** next.*/ NEXT, /** parent.*/ PARENT, /** previous.*/ PREVIOUS; } /** convenience*/ public final static String CHILD_S = MoleculePointer.CHILD.toString(); /** convenience*/ public final static String PARENT_S = MoleculePointer.PARENT.toString(); /** convenience*/ public final static String PREVIOUS_S = MoleculePointer.PREVIOUS.toString(); /** convenience*/ public final static String NEXT_S = MoleculePointer.NEXT.toString(); /** R elementType. */ public final static String R_GROUP = "R"; /** label to define torsion. */ public final static String TORSION_END = C_A+"torsionEnd"; /** find labels with torsions. */ public final static String TORSION_END_QUERY = CMLLabel.NS+"[@dictRef='"+TORSION_END+"']"; /** convention attribute indicating that join contains fragments. */ public final static String FRAGMENT_CONTAINER = "fragmentContainer"; /** must give simple documentation. * */ public CMLJoin() { } /** must give simple documentation. * * @param old CMLJoin to copy */ public CMLJoin(CMLJoin old) { super((org.xmlcml.cml.element.AbstractJoin) old); } /** copy node . * * @return Node */ public Element copy() { return new CMLJoin(this); } /** create new instance in context of parent, overridable by subclasses. * * @param parent parent of element to be constructed (ignored by default) * @return CMLJoin */ public CMLElement makeElementInContext(Element parent) { return new CMLJoin(); } /** * will process repeat attribute. * * @param parent * element */ public void finishMakingElement(Element parent) { super.finishMakingElement(parent); // RepeatAttribute.process(this); } private String getId(CMLMolecule molecule) { String ref = molecule.getRef(); String id = molecule.getId(); return ref+S_UNDER+id; } // /** create atomRefs2 from moleculeRefs2 and atomRefs2. // * // * @param parent // * @param previousFragments // * @param nextFragments // */ // private void processMoleculeRefs2AndAtomRefs2( // CMLFragment previousFragment, CMLFragment nextFragment) { //// //// 1.4 //// 115 //// //// //// //// // String[] moleculeRefs2 = this.getMoleculeRefs2(); // if (moleculeRefs2 == null) { // throw new RuntimeException("No moleculeRefs2 on join"); // } // if (CMLJoin.PARENT_S.equals(moleculeRefs2[0])) { // previousFragment = (CMLFragment) this.getParent(); // if (previousFragment == null) { // throw new RuntimeException("No parent fragment"); // } // } else if (CMLJoin.PREVIOUS_S.equals(moleculeRefs2[0])) { // } // CMLMolecule previousMolecule = FragmentTool.getOrCreateTool(previousFragment).getMolecule(); // if (previousMolecule == null) { // throw new RuntimeException("Cannot find previous molecule to join"); // } // CMLMolecule nextMolecule = null; // if (CMLJoin.NEXT_S.equals(moleculeRefs2[1])) { // nextMolecule = FragmentTool.getOrCreateTool(nextFragment).getMolecule(); // } // if (nextMolecule == null) { // throw new RuntimeException("Cannot find next molecule to join"); // } // processMoleculeRefs2AndAtomRefs2(previousMolecule, nextMolecule); // } /** creates atomRefs2 to join previous/parent molecule to next/child. * * @param previousMolecule * @param nextMolecule */ public void processMoleculeRefs2AndAtomRefs2( CMLMolecule previousMolecule, CMLMolecule nextMolecule) { // // 1.4 // 115 // // // // if (previousMolecule == null) { throw new RuntimeException("null PREVIOUS, check syntax"); } if (nextMolecule == null) { throw new RuntimeException("null NEXT, check syntax"); } String[] atomRefs2 = this.getAtomRefs2(); if (atomRefs2 == null) { throw new RuntimeException("No atomrefs2 on Join"); } this.setAtomRefs2(new String[]{ getId(previousMolecule)+S_UNDER+atomRefs2[0], getId(nextMolecule)+S_UNDER+atomRefs2[1]}); this.setMoleculeRefs2(new String[]{ getId(previousMolecule), getId(nextMolecule)}); } /** get string. * * @return string */ public String getString() { String s = S_EMPTY; String id = this.getId(); if (id != null) { s += id+S_SPACE; } String[] moleculeRefs2 = this.getMoleculeRefs2(); if (moleculeRefs2 != null) { s += Util.concatenate(moleculeRefs2, S_SPACE)+S_SEMICOLON; } String[] atomRefs2 = this.getAtomRefs2(); if (atomRefs2 != null) { s += Util.concatenate(atomRefs2, S_SPACE)+S_SEMICOLON; } return s; } /** * gets the element that is previous or parent to the join, depending * on moleculeRefs2 * * @return */ public Element getParentOrPrevious() { if (getMoleculeRefs2Attribute().getValue().equals(PARENT_S + " " + CHILD_S)) { return (Element) getParent(); } else if (getMoleculeRefs2Attribute().getValue().equals(PREVIOUS_S + " " + NEXT_S)) { ParentNode parent = getParent(); int position = parent.indexOf(this); if (position == 0) return null; return (Element) parent.getChild(position - 1); } return null; } /** * gets the element that is next or child to the join, depending * on moleculeRefs2 * * @return */ public CMLElement getChildOrNext() { if (getMoleculeRefs2Attribute().getValue().equals(PARENT_S + " " + CHILD_S)) { if (getChildCount() > 0) return (CMLElement) getChild(0); } else if (getMoleculeRefs2Attribute().getValue().equals(PREVIOUS_S + " " + NEXT_S)) { ParentNode parent = getParent(); int position = getParent().indexOf(this); if (position == parent.getChildCount() - 1) return null; return (CMLElement) parent.getChild(position + 1); } return null; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLKpoint.java000077500000000000000000000037351477224461000256430ustar00rootroot00000000000000/** * 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. */ // /*======AUTOGENERATED FROM SCHEMA; DO NOT EDIT BELOW THIS LINE ======*/ package org.xmlcml.cml.element; import nu.xom.Element; import org.xmlcml.cml.base.CMLElement; /** * A kpoint. * * * Not yet finalised. * * user-modifiable class autogenerated from schema if no class exists use as a * shell which can be edited the autogeneration software will not overwrite an * existing class file * */ public class CMLKpoint extends AbstractKpoint { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * must give simple documentation. * * */ public CMLKpoint() { } /** * must give simple documentation. * * @param old * CMLKpoint to copy * */ public CMLKpoint(CMLKpoint old) { super((AbstractKpoint) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLKpoint(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLKpoint */ public CMLElement makeElementInContext(Element parent) { return new CMLKpoint(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLKpointList.java000077500000000000000000000037011477224461000264700ustar00rootroot00000000000000/** * 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. */ // /*======AUTOGENERATED FROM SCHEMA; DO NOT EDIT BELOW THIS LINE ======*/ package org.xmlcml.cml.element; import nu.xom.Element; import org.xmlcml.cml.base.CMLElement; /** * A container for kpoints. * * * Experimental. * * user-modifiable class autogenerated from schema if no class exists use as a * shell which can be edited the autogeneration software will not overwrite an * existing class file * */ public class CMLKpointList extends AbstractKpointList { /** * must give simple documentation. * * */ public CMLKpointList() { } /** * must give simple documentation. * * @param old * CMLKpointList to copy * */ public CMLKpointList(CMLKpointList old) { super((AbstractKpointList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLKpointList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLKpointList */ public CMLElement makeElementInContext(Element parent) { return new CMLKpointList(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLLabel.java000077500000000000000000000077331477224461000254200ustar00rootroot00000000000000/** * 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 java.util.List; import nu.xom.Element; import nu.xom.Node; import nu.xom.Text; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLUtil; /** * user-modifiable class supporting label. * autogenerated from schema use as a * shell which can be edited * */ public class CMLLabel extends AbstractLabel { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** used in fragment building * * @author pm286 * */ public enum Position { /** previous molecule */ LEFT, /** next molecule */ RIGHT, /** parent */ PARENT; } /** * constructor. */ public CMLLabel() { } /** * constructor. * * @param old */ public CMLLabel(CMLLabel old) { super((AbstractLabel) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLLabel(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLLabel */ public CMLElement makeElementInContext(Element parent) { return new CMLLabel(); } /** gets value of a label child indicating how to join molecule. * only used in fragment builder * @param element * @param side * @return value of label */ public static String getLabelValue(CMLElement element, Position side) { CMLLabel label = getLabel(element, side); return (label == null) ? null : label.getValue(); } /** gets value of a label child indicating how to join molecule. * only used in fragment builder * @param element * @param side * @return label */ public static CMLLabel getLabel(CMLElement element, Position side) { String dictRef = C_E+side; List nodeList = CMLUtil.getQueryNodes( element, CMLLabel.NS+"[@dictRef='"+dictRef+"']", CMLConstants.CML_XPATH); return (nodeList.size() == 0) ? null : (CMLLabel) nodeList.get(0); } /** sets value of a label child indicating how to join molecule. * only used in fragment builder * @param element * @param side * @param value */ public static void setLabel(CMLElement element, Position side, String value) { CMLLabel label = getLabel(element, side); if (label == null) { label = new CMLLabel(); element.appendChild(label); Text text = new Text(value); label.appendChild(text); label.setDictRef(C_E+side); } else { Text text = CMLUtil.getFirstTextDescendant(label); text.setValue(value); } } /** unsets label child indicating how to join molecule. * only used in fragment builder * @param element * @param side */ public static void removeLabel(CMLElement element, Position side) { CMLLabel label = getLabel(element, side); if (label != null) { label.detach(); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLLattice.java000077500000000000000000000175141477224461000257640ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; /** * user-modifiable class supporting lattice. * autogenerated from schema use as * a shell which can be edited * */ public class CMLLattice extends AbstractLattice { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLLattice() { } /** * constructor. * * @param old */ public CMLLattice(CMLLattice old) { super((AbstractLattice) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLLattice(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLLattice */ public CMLElement makeElementInContext(Element parent) { return new CMLLattice(); } /** * constructor. * * @param lv * latticeVectors */ public CMLLattice(CMLLatticeVector[] lv) { this(); if (lv == null || lv.length != 3) { throw new RuntimeException("Invalid latticeVectors"); } addLatticeVectors(lv[0], lv[1], lv[2]); } /** * constructor. * * @param a * vector * @param b * vector * @param c * vector */ public CMLLattice(CMLLatticeVector a, CMLLatticeVector b, CMLLatticeVector c) { this(); addLatticeVectors(a, b, c); } void addLatticeVectors(CMLLatticeVector a, CMLLatticeVector b, CMLLatticeVector c) { if (a == null) { throw new RuntimeException("Null latticeVector"); } this.appendChild(a); if (b == null) { throw new RuntimeException("Null latticeVector"); } this.appendChild(b); if (c == null) { throw new RuntimeException("Null latticeVector"); } this.appendChild(c); } /** * get cell parameters in crystallographic form. units are angstrom and * degrees * * @return 3 lengths and 3 angles */ public double[] getCellParameters() { CMLVector3 a = this.getLatticeVectorElements().get(0).getCMLVector3(); CMLVector3 b = this.getLatticeVectorElements().get(1).getCMLVector3(); CMLVector3 c = this.getLatticeVectorElements().get(2).getCMLVector3(); double[] params = new double[6]; params[0] = a.getLength(); params[1] = b.getLength(); params[2] = c.getLength(); params[3] = b.getAngleMadeWith(c).getDegrees(); params[4] = c.getAngleMadeWith(a).getDegrees(); params[5] = a.getAngleMadeWith(b).getDegrees(); return params; } /** * get i'th lattice vector as CMLVector. * * @param i * index of vector (0 ≤ i ≤ 2) * @return vector or null */ public CMLVector3 getCMLVector3(int i) { CMLElements abc = this.getLatticeVectorElements(); return (abc == null || i < 0 || i > 2) ? null : abc.get(i) .getCMLVector3(); } /** * get volume. this is a signed quantity, depending on handedness of * vectors. * * @return volume */ public double getVolume() { CMLElements latticeVectors = this .getLatticeVectorElements(); if (latticeVectors.size() != 3) { throw new RuntimeException("Cannot calculate volume without vectors"); } return this.getCMLVector3(0).getScalarTripleProduct( this.getCMLVector3(1), this.getCMLVector3(2)); } /** * get reduced cell. starts with lattice with 3 non-coplanar vectors and * iterates through all sums and differences, continually taking the * shortest 3 vectors. * * @return the new lattice */ public CMLLattice getReducedCell() { if (Math.abs(this.getVolume()) < EPS) { throw new RuntimeException("coplanar vectors"); } List vList = new ArrayList(); for (int i = 0; i < 3; i++) { vList.add(new CMLVector3(this.getCMLVector3(i))); } sort(vList); boolean change = true; int count = 0; while (change || count++ < 10) { change = false; change = newVector(vList, 0, 1); if (!change) { change = newVector(vList, 0, 2); } if (!change) { change = newVector(vList, 1, 2); } } sort(vList); CMLLattice reducedLattice = new CMLLattice(new CMLLatticeVector(vList .get(0)), new CMLLatticeVector(vList.get(1)), new CMLLatticeVector(vList.get(2))); return reducedLattice; } private void sort(List vList) { sort(vList, 0, 1); sort(vList, 1, 2); sort(vList, 0, 1); } private void sort(List vList, int i, int j) { CMLVector3 ti = vList.get(i); CMLVector3 tj = vList.get(j); if (tj.getLength() < ti.getLength()) { vList.set(j, ti); vList.set(i, tj); } } /** * try various combinations of plus and minus vectors. if any are shorter, * replace and return true * * @param vList * @param i * @param j * @return true if change */ private boolean newVector(List vList, int i, int j) { CMLVector3 ti = vList.get(i); double li = ti.getLength(); CMLVector3 tj = vList.get(j); double lj = tj.getLength(); boolean change = false; // compute difference CMLVector3 tij = ti.subtract(tj); // copmare with both lengths if (tij.getLength() < li) { vList.set(i, tij); change = true; } if (!change && tij.getLength() < lj) { vList.set(j, tij); change = true; } // compare sum if (!change) { tij = ti.plus(tj); if (tij.getLength() < li) { vList.set(i, tij); change = true; } if (!change && tij.getLength() < lj) { vList.set(j, tij); change = true; } } return change; } /** * gets a string representation of the lattice. * * @return the string (never null); */ public String getString() { String s = ""; for (CMLLatticeVector lv : this.getLatticeVectorElements()) { s += S_LSQUARE + lv.getStringContent() + S_RSQUARE; s += S_LBRAK + lv.getCMLVector3().getLength() + S_RBRAK; } return s; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLLatticeVector.java000077500000000000000000000044131477224461000271410ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting latticeVector. * autogenerated from schema * use as a shell which can be edited * */ public class CMLLatticeVector extends AbstractLatticeVector { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLLatticeVector() { } /** * constructor. * * @param old */ public CMLLatticeVector(CMLLatticeVector old) { super((AbstractLatticeVector) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLLatticeVector(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLLatticeVector */ public CMLElement makeElementInContext(Element parent) { return new CMLLatticeVector(); } /** * constructor. * @param v */ public CMLLatticeVector(double[] v) { this.setXMLContent(v); } /** * constructor. * * @param v3 * vector3 */ public CMLLatticeVector(CMLVector3 v3) { this.setXMLContent(v3.getXMLContent()); } /** * get vector from latticeVector. * * @return vector */ public CMLVector3 getCMLVector3() { return new CMLVector3(this.getXMLContent()); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLLength.java000077500000000000000000000211151477224461000256100ustar00rootroot00000000000000/** * 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 java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import nu.xom.Element; import nu.xom.Nodes; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Util; /** * user-modifiable class supporting length. * autogenerated from schema use as a * shell which can be edited * */ public class CMLLength extends AbstractLength { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLLength() { } /** * constructor. * * @param old */ public CMLLength(CMLLength old) { super((AbstractLength) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLLength(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLLength */ public CMLElement makeElementInContext(Element parent) { return new CMLLength(); } /** * gets atomIds as list. * * @return the atomIds (null if no atomRefs3) */ public List getAtomIds() { List idList = null; String[] atomRefs2 = getAtomRefs2(); if (atomRefs2 != null) { idList = new ArrayList(); for (String s : atomRefs2) { idList.add(s); } } return idList; } /** * gets atomRefs3 as array of atoms. * * uses the value in <angle> element * @param molecule * @return the atoms (null if no atomRefs3) */ public List getAtoms(CMLMolecule molecule) { List atomList = null; if (molecule != null) { String[] atomRefs2 = this.getAtomRefs2(); if (atomRefs2 != null) { atomList = new ArrayList(); for (String atomRef : atomRefs2) { CMLAtom atom = molecule.getAtomById(atomRef); if (atom == null) { throw new RuntimeException("cannot find atom " + atomRef); } atomList.add(molecule.getAtomById(atomRef)); } } } return atomList; } /** * Finds ancestral molecule and then uses getCalculatedAngle(CMLMolecule) * * @return the angle in degrees (null if cannot calculate) */ public Double getCalculatedLength() { CMLMolecule molecule = CMLMolecule.getAncestorMolecule(this); return (molecule == null) ? null : getCalculatedLength(molecule); } /** * gets value calculated from coordinates. does not set content * * @param molecule * * @return the length (NaN if cannot calculate) */ public double getCalculatedLength(CMLMolecule molecule) { double calculatedLength = Double.NaN; if (molecule == null) { throw new RuntimeException("length requires molecule"); } List atoms = getAtoms(molecule); List coordList = new ArrayList(); if (atoms != null) { for (CMLAtom atom : atoms) { Point3 point = atom.getXYZ3(); if (point != null) { coordList.add(point); } } if (coordList.size() == 2) { calculatedLength = coordList.get(0).getDistanceFromPoint(coordList.get(1)); } } else { throw new RuntimeException("length requires atomRefs2"); } return calculatedLength; } /** translates elements to list. * @param lengthElements * @return the list of lengths * @deprecated try to use List<CMLLength> */ public static List getList(CMLElements lengthElements) { List lengthList = new ArrayList(); for (CMLLength length : lengthElements) { lengthList.add(length); } return lengthList; } /** add ids into list of length atomRefs2. * * @param lengthList lists * @param atom0 * @param atom1 */ public static void addAtomIds( ListlengthList, CMLAtom atom0, CMLAtom atom1 ) { // add explicit atom ids into lengths for (CMLLength length : lengthList) { length.setAtomRefs2(atom0, atom1); } } /** * get lengths indexed by bond hash. * * @param lengths * @return map */ public static Map getIndexedLengths(List lengths) { Map lengthTable = new HashMap(); for (CMLLength length : lengths) { String[] id = length.getAtomRefs2(); String key = CMLBond.atomHash(id[0], id[1]); lengthTable.put(key, length); } return lengthTable; } /** add ids to atomRefs2 * * @param atom0 * @param atom1 */ public void setAtomRefs2(CMLAtom atom0, CMLAtom atom1) { this.setAtomRefs2(new String[]{atom0.getId(), atom1.getId()}); } /** create key from atomRefs2 attribute using CMLBond atomHash. * * @return the hash null if no atomRefs2 */ public String atomHash() { String[] a = this.getAtomRefs2(); return (a == null) ? null : CMLBond.atomHash(a[0], a[1]); } /** get string. * * @return the string */ public String getString() { String s = CMLConstants.S_EMPTY; String[] a = getAtomRefs2(); if (a != null) { s += Util.concatenate(a, CMLConstants.S_MINUS); } s += CMLConstants.S_SPACE; s += this.getXMLContent(); return s; } /** writes lengths as an XHTML table. * columns are atom1.label atom2.label distance in A * @param w writer to output * @param lengthList * @param molecule * @throws IOException */ public static void outputHTML( Writer w, List lengthList, CMLMolecule molecule) throws IOException { if (lengthList.size() > 0) { w.write("\n"); w.write(""); w.write(""); w.write(""); w.write(""); w.write("\n"); for (CMLLength length : lengthList) { List atoms = length.getAtoms(molecule); w.write(""); for (int i = 0; i < 2; i++) { w.write(""); } String s = ""+length.getXMLContent(); w.write(""); w.write("\n"); } w.write("
"); w.write("atom1 (id)"); w.write(""); w.write("atom2 (id)"); w.write(""); w.write("length"); w.write("
"); CMLAtom atom = atoms.get(i); Nodes labelNodes = atom.query( CMLScalar.NS+"[@dictRef='iucr:_atom_site_label']", CMLConstants.CML_XPATH); String label = ((CMLScalar) labelNodes.get(0)).getXMLContent()+" ("+atom.getId()+S_RBRAK; w.write( (label == null) ? atom.getId() : label); w.write(""+s.substring(0, Math.min(6, s.length()))+"
\n"); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLLine3.java000077500000000000000000000214161477224461000253450ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.euclid.Line3; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Real; import org.xmlcml.euclid.Util; import org.xmlcml.euclid.Vector3; /** * user-modifiable class supporting line3. * autogenerated from schema use as a * shell which can be edited * */ public class CMLLine3 extends AbstractLine3 { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * start of point in array. * */ public final static int POINT = 3; /** * start of vector in array. * */ public final static int VECTOR = 0; /** * default. has NO default values (point and vector are null) */ public CMLLine3() { } /** * constructor. * * @param old */ public CMLLine3(CMLLine3 old) { super((AbstractLine3) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLLine3(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLLine3 */ public CMLElement makeElementInContext(Element parent) { return new CMLLine3(); } /** * check line is OK. must have 3 double components * * @param parent * element * @throws RuntimeException * parsing error */ public void finishMakingElement(Element parent) throws RuntimeException { if (this.getPoint3Attribute() == null) { throw new RuntimeException("point3 is now mandatory"); } if (this.getVector3Attribute() == null) { throw new RuntimeException("vector3 is now mandatory"); } } // =========================== additional constructors // ======================== /** * formed from Euclid line. * * @param l */ public CMLLine3(Line3 l) { this(); this.setPoint3(l.getPoint().getArray()); this.setVector3(l.getVector().getArray()); } /** * construct from point and vector. takes doc from p the line will not * necessarily retain the exact point and the vector need not be normalized * p and vector are copied * * @param p * a point on the line * @param v * non-zero vector through the point * @exception RuntimeException * zero length vector */ public CMLLine3(CMLPoint3 p, CMLVector3 v) throws RuntimeException { if (v.isZero()) { throw new RuntimeException("zero vector"); } v.normalize(); setPoint3(p.getXYZ3()); setVector3(v.getXYZ3()); } /** * construct a line from two Point3s. takes doc from p1 the line will not * necessarily retain the exact points * * @param p1 * a point on the line * @param p2 * another point on the line * @exception RuntimeException * points are coincident */ public CMLLine3(CMLPoint3 p1, CMLPoint3 p2) throws RuntimeException { CMLVector3 v = p1.subtract(p2); if (v.isZero()) { throw new RuntimeException("coincident points"); } this.setPoint3(p1.getXYZ3()); this.setVector3(v.getXYZ3()); } // ====================== housekeeping methods ===================== /** * get euclid primitive. * * @return line * @exception RuntimeException */ public Line3 getEuclidLine3() throws RuntimeException { return new Line3(new Point3(this.getPoint3()), new Vector3(this .getVector3())); } // ====================== subsidiary accessors ===================== /** * set vector. will normalize copy of vector * * @param v * the vector */ public void setVector3(CMLVector3 v) { if (v.isZero()) { throw new RuntimeException("Cannot make line with zero vector"); } CMLVector3 vv = new CMLVector3(v); vv.normalize(); super.setVector3(vv.getXMLContent()); } // ====================== functionality ===================== /** * Checks to see if the two lines are represented by the same vector and point * Line3.isEqualTo(Line3 line) will check to see if the lines are equivalent. * * @param l2 * CMLLine3 to compare * @return equals */ public boolean isEqualTo(CMLLine3 l2) { return Util.isEqual(this.getPoint3(), l2.getPoint3(), EPS) && Util.isEqual(this.getVector3(), l2.getVector3(), EPS); } /** * form coincident antiparallel line. * * @return antiparallel line */ public CMLLine3 subtract() { double[] vv = this.getVector3(); for (int i = 0; i < vv.length; i++) { vv[i] = -vv[i]; } this.setVector3(vv); return this; } /** * get transformed line. does not alter this * * @param t * transform * @return transformed line */ public CMLLine3 transform(CMLTransform3 t) { Line3 linee = getEuclidLine3(); Line3 l = linee.transform(t.getEuclidTransform3()); return new CMLLine3(l); } /** * are two lines parallel. (not antiparallel) does not test coincidence * * @param l2 * line to compare * @return true if parallel */ public boolean isParallelTo(CMLLine3 l2) { double[] v = this.getVector3(); double[] v2 = l2.getVector3(); return Util.isEqual(v, v2, EPS); } /** * are two lines antiparallel. (not parallel) does not test coincidence * * @param l2 * line to compare * @return true if antiparallel */ public boolean isAntiparallelTo(CMLLine3 l2) { double[] v = this.getVector3(); Vector3 vv = new Vector3(v); vv = vv.multiplyBy(-1); return Util.isEqual(vv.getArray(), v, EPS); } /** * is a point on a line. tests for Real.isZero() distance from line * * @param p * point * @return true if within Real.isZero() */ public boolean containsPoint(CMLPoint3 p) { double d = p.distanceFromLine(this); return (Real.isZero(d, Real.getEpsilon())); } /** * point on line closest to another point. * * @param p2 * reference point * @return point on line closest to p2 */ public CMLPoint3 getClosestPointTo(CMLPoint3 p2) { Line3 leucl3 = this.getEuclidLine3(); Point3 pp = leucl3.getClosestPointTo(p2.getEuclidPoint3()); return (pp == null) ? null : new CMLPoint3(pp.getArray()); } /** * distance of a point from a line * * @param p * reference point * @return distance from line */ public double getDistanceFromPoint(CMLPoint3 p) { Line3 leucl3 = this.getEuclidLine3(); return leucl3.getDistanceFromPoint(p.getEuclidPoint3()); } /** * point of intersection of line and plane calls * Plane3.getIntersectionWith(CMLPoint3) * * @param pl * plane intersecting line * @return point (null if line parallel to plane) */ public CMLPoint3 getIntersectionWith(CMLPlane3 pl) { Line3 leucl3 = this.getEuclidLine3(); Point3 pp = leucl3.getIntersectionWith(pl.getEuclidPlane3()); return (pp == null) ? null : new CMLPoint3(pp.getArray()); } /** * get string. * * @return the string */ public String getString() { String s = this.getEuclidLine3().toString(); return s; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLLink.java000077500000000000000000000032431477224461000252660ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting link. * autogenerated from schema use as a * shell which can be edited * */ public class CMLLink extends AbstractLink { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLLink() { } /** * constructor. * * @param old */ public CMLLink(CMLLink old) { super((AbstractLink) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLLink(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLLink */ public CMLElement makeElementInContext(Element parent) { return new CMLLink(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLList.java000077500000000000000000000067531477224461000253150ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import nu.xom.Node; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.base.CMLUtil; import org.xmlcml.cml.interfacex.HasDictRef; /** * user-modifiable class supporting list. * autogenerated from schema use as a * shell which can be edited * */ public class CMLList extends org.xmlcml.cml.element.AbstractList implements HasDictRef { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLList() { } /** * constructor. * * @param old */ public CMLList(CMLList old) { super((AbstractList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLList */ public CMLElement makeElementInContext(Element parent) { return new CMLList(); } /** adds the array as a column to the tableRows. * * @param tableRows */ public void addColumnElementsTo(CMLElements tableRows) { List nodes = CMLUtil.getQueryNodes(this, CMLConstants.S_STAR); if (nodes.size() != tableRows.size()) { throw new RuntimeException("inconsistent column size: "+ nodes.size()+" expected "+tableRows.size()); } int j = 0; Class classx = null; for (Node node : nodes) { if (classx == null) { classx = node.getClass(); } else if (classx != node.getClass()) { throw new RuntimeException("incompatible classes "+ node.getClass() +" expected "+classx); } tableRows.get(j++).appendChild(new CMLTableCell((Element)node)); } } /** get size of array. * @return size */ public int getArraySize() { List nodeList = CMLUtil.getQueryNodes(this, CMLConstants.S_STAR); return nodeList.size(); } /** get array elements. * recalcuates each time so best cached for frequent use * @return elements as String */ public List getStringValues() { List nodeList = CMLUtil.getQueryNodes(this, CMLConstants.S_STAR); List stringList = new ArrayList(); for (Node node : nodeList) { stringList.add(node.getValue()); } return stringList; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLMap.java000077500000000000000000000534701477224461000251150ustar00rootroot00000000000000/** * 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 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; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.euclid.Util; /** * user-modifiable class supporting map. these methods support generic links; * although the links may be typed, CMLMap itself does not support type-specific * methods */ public class CMLMap extends org.xmlcml.cml.element.AbstractMap { @SuppressWarnings("unused") private static Logger LOG = Logger.getLogger(CMLMap.class); /** direction of link */ public enum Direction { /** Direction.TO attribute is to be used. * */ TO("to"), /** * Direction.FROM attribute is to be used. * */ FROM("from"), /** * both ends of link matter * */ BOTH("both"), /** * either end of link matters * */ EITHER("either"), /** * neither end of link is involved. NEITHER * can be used when merging maps to ensure that links are only added * when neither the Direction.FROM or Direction.TO ref is represent in * *this* map. */ NEITHER("neither"); /** descriptive string */ public final String value; private Direction(String s) { this.value = s; } /** * to string * * @return string */ public String toString() { return value; } /** * return opposite of TO/FROM else null * @return */ public Direction opposite() { Direction o = null; if (this.equals(TO)) { o = FROM; } else if (this.equals(FROM)) { o = TO; } return o; } } static Logger logger = Logger.getLogger(CMLMap.class.getName()); protected CMLMolecule molecule; // String content protected Map toFromTable; protected Map fromToTable; // Link content protected Map toLinkTable; protected Map fromLinkTable; /** * constructor. */ public CMLMap() { } /** * constructor. * * @param old */ public CMLMap(CMLMap old) { super((AbstractMap) old); copyFields(old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLMap(this); } private void copyFields(CMLMap old) { this.molecule = old.molecule; } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLMap */ public CMLElement makeElementInContext(Element parent) { return new CMLMap(); } /** * shouldn't be necessary. * * @param parent * element */ public void finishMakingElement(Element parent) { super.finishMakingElement(parent); // add links to tables makeTables(); addLinks(); } void addLinks() { CMLElements links = this.getLinkElements(); for (CMLLink link : links) { addLink(link); } } void checkAndCreateTablesAndAddLinks() { if (fromToTable == null || toFromTable == null || toLinkTable == null || fromLinkTable == null) { makeTables(); addLinks(); } } /** * returns the opposite of Direction.TO or Direction.FROM. * * @param toFrom * Direction.TO or Direction.FROM * @return Direction.FROM or Direction.TO or null if other argument */ public static Direction getReverseToFrom(Direction toFrom) { Direction d = null; if (toFrom.equals(Direction.TO)) { d = Direction.FROM; } else if (toFrom.equals(Direction.FROM)) { d = Direction.TO; } return d; } void clearTables() { makeTables(); toFromTable.clear(); fromToTable.clear(); toLinkTable.clear(); fromLinkTable.clear(); } void makeTables() { if (toFromTable == null) { toFromTable = new HashMap(); } if (fromToTable == null) { fromToTable = new HashMap(); } if (toLinkTable == null) { toLinkTable = new HashMap(); } if (fromLinkTable == null) { fromLinkTable = new HashMap(); } } /** routes append to addLink. * * @param link * @deprecated use addLink */ public void appendChild(CMLLink link) { this.addLink(link); } /** * add a link. adds links regardless of current links. normally this is not * safe so addUniqueLink should be used. * * @param link * to add */ public void addLink(CMLLink link) { if (link != null) { addLinkToTable(link); super.addLink(link); } } private String getFromLink(CMLLink link) { return (S_EMPTY.equals(link.getFrom())) ? Util.concatenate(link.getFromSet(), CMLConstants.S_SPACE) : link.getFrom(); } private String getToLink(CMLLink link) { return (S_EMPTY.equals(link.getTo())) ? Util.concatenate(link.getToSet(), CMLConstants.S_SPACE) : link.getTo(); } /** * add a link if consistent with existing ones. checks current to and from * attributes and adds if it does not duplicate existing link or is allowed * to overwrite. if neither to or from exists then link is added no warning * is given if link exists and is overwritten * * @param link to add * @param control * EITHER overwrites any links with same to or same from BOTH * overwrites link with both to and from identical NEITHER adds * link only if to and from are missing in map */ public void addUniqueLink(CMLLink link, Direction control) { String toLinkS = getToLink(link); String fromLinkS = getFromLink(link); if (control.equals(Direction.BOTH)) { CMLLink oldLink = getFromToLink(fromLinkS, toLinkS); if (oldLink != null) { removeLink(oldLink); } addLink(link); } else if (control.equals(Direction.FROM)) { throw new RuntimeException("FROM not implemented"); // CMLLink oldLink = getFromToLink(fromLinkS, toLinkS); // if (oldLink != null) { // removeLink(oldLink); // } // addLink(link); } else if (control.equals(Direction.TO)) { throw new RuntimeException("TO not implemented"); // CMLLink oldLink = getFromToLink(fromLinkS, toLinkS); // if (oldLink != null) { // removeLink(oldLink); // } // addLink(link); } else if (control.equals(Direction.EITHER)) { CMLLink toLink = getLink(toLinkS, Direction.TO); CMLLink fromLink = getLink(fromLinkS, Direction.FROM); if (fromLink == null) { removeLink(fromLink); } if (toLink != null) { removeLink(fromLink); } addLink(link); } else if (control.equals(Direction.NEITHER)) { CMLLink toLink = getLink(toLinkS, Direction.TO); CMLLink fromLink = getLink(fromLinkS, Direction.FROM); if (toLink != null) { // error? if (fromLink != null) { // error? } } else if (fromLink != null) { // error? } else { addLink(link); } } } /** * add map. * * do not check duplicate links. results is simple sum of maps (in order) * map2 is not affected * * @param map2 * with links to add */ public void addMap(CMLMap map2) { for (CMLLink link : map2.getLinkElements()) { CMLLink newLink = new CMLLink(); copyAttributesFromTo(link, newLink); this.addLink(newLink); } } /** * add a link to table. * * @param link to add */ void addLinkToTable(CMLLink link) { makeTables(); if (link != null) { String toLinkS = getToLink(link); String fromLinkS = getFromLink(link); fromToTable.put(fromLinkS, toLinkS); toFromTable.put(toLinkS, fromLinkS); fromLinkTable.put(fromLinkS, link); toLinkTable.put(toLinkS, link); } } /** * remove a link. * * @param link * to remove */ public void removeLink(CMLLink link) { if (link != null) { String to = getToLink(link); String from = getFromLink(link); toFromTable.remove(to); toLinkTable.remove(to); fromLinkTable.remove(from); fromToTable.remove(from); link.detach(); } } /** * gets array of to attributes. does not do toSet * * @return the to attributes */ public List getToRefs() { makeTables(); List toRefs = new ArrayList(); for (CMLLink link : getLinkElements()) { if (link.getTo() != null) { toRefs.add(link.getTo()); } } return toRefs; } /** * gets array of toSet attributes. does not do to * * @return the toSet attributes */ public List getToSetRefs() { makeTables(); List toSetRefs = new ArrayList(); for (CMLLink link : getLinkElements()) { if(link.getToSet() != null) { toSetRefs.add(link.getToSet()); } } return toSetRefs; } /** * gets array of from attributes. does not do fromSet * * @return the from attributes */ public List getFromRefs() { makeTables(); List fromRefs = new ArrayList(); for (CMLLink link : getLinkElements()) { if (link.getFrom() != null) { fromRefs.add(link.getFrom()); } } return fromRefs; } /** * gets array of fromSet attributes. does not do from * * @return the from attributes */ public List getFromSetRefs() { makeTables(); List fromSetRefs = new ArrayList(); for (CMLLink link : getLinkElements()) { if(link.getFromSet() != null) { fromSetRefs.add(link.getFromSet()); } } return fromSetRefs; } /** * gets mapped fromTo atomId. works with sets * * @param fromId * in the from attributes * @return the atomIds in the to attributes */ public String getToRef(String fromId) { makeTables(); return (fromToTable == null) ? null : fromToTable.get(fromId); } /** * gets mapped toFrom atomIds. works with sets * * @param toId * in the to attributes * @return the atomId in the from attributes */ public String getFromRef(String toId) { makeTables(); return (fromToTable == null) ? null : toFromTable.get(toId); } /** * gets mapped fromTo ids. * * @param fromIds * from attributes * @return List of corresponding to attributes (may include nulls if not * found */ public List getToRefs(List fromIds) { makeTables(); List toRefs = new ArrayList(); for (String fromId : fromIds) { String toRef = getToRef(fromId); toRefs.add(toRef); } return toRefs; } /** * gets mapped fromTo ids. * * @param toIds * to attributes * @return List of corresponding from attributes (may include nulls if not * found */ public List getFromRefs(List toIds) { makeTables(); List fromRefs = new ArrayList(); for (String toId : toIds) { fromRefs.add(getFromRef(toId)); } return fromRefs; } /** * gets array of to or from attributes. does not work with sets * * @param toFrom * either Direction.TO or Direction.FROM * @return the to or from attributes */ public List getRefs(Direction toFrom) { makeTables(); List refs = new ArrayList(); for (CMLLink link : getLinkElements()) { refs.add((toFrom.equals(Direction.TO)) ? link.getTo() : link .getFrom()); } return refs; } /** * gets array of mapped to or from attributes. does not work with sets * * if toFrom is Direction.FROM then the returned string are the * Direction.FROM refs corresponding to an array of Direction.TO values * * @param ids * the ids to be mapped, type determined by toFrom * @param toFrom * either Direction.TO or Direction.FROM. * @return the mapped attributes */ public List getRefs(List ids, Direction toFrom) { makeTables(); List ref = new ArrayList(); for (String id : ids) { ref.add((toFrom == Direction.FROM) ? getFromRef(id) : getToRef(id)); } return ref; } /** * gets mapped to or from attribute. works with sets * * if toFrom is Direction.FROM, returns the from attribute corresponding to * the to attribute with value id thus for a map with some link {@code } getRef("t", Direction.FROM) returns "f" * * @param id * the id to be mapped, type determined by toFrom * @param toFrom * either Direction.TO or Direction.FROM. * @return the mapped attribute or null if not matched */ public String getRef(String id, Direction toFrom) { makeTables(); checkAndCreateTablesAndAddLinks(); Map table = (toFrom == Direction.FROM) ? fromToTable : toFromTable; return (table == null || id == null) ? null : table.get(id); } /** * gets link mapped to or from attribute. works with sets * * if toFrom is Direction.FROM, returns the link corresponding to the to * attribute with value id thus for a map with some link {@code } getRef("t", Direction.FROM) returns the link * * @param id * the id to be mapped, type determined by toFrom * @param toFrom * either Direction.TO or Direction.FROM. * @return the mapped link or null if not matched */ public CMLLink getLink(String id, Direction toFrom) { makeTables(); checkAndCreateTablesAndAddLinks(); String ref = getRef(id, toFrom); return (CMLLink) ((id == null || ref == null) ? null : ((toFrom .equals(Direction.FROM)) ? toLinkTable.get(ref) : fromLinkTable .get(ref))); } /** * gets link from to and from attributes. does not work with sets * * @param from value of the from attribute * @param to value of the to attribute * @return the link corresponding to these or null if not exists */ public CMLLink getFromToLink(String from, String to) { makeTables(); CMLLink link = getLink(to, Direction.TO); if (link != null) { link = (link.getFrom().equals(from)) ? link : null; } return link; } /** * merges a map with this. The links in the second map can be added with * varying strategies (control) NEITHER. Only add link if neither from or to * is present in this map BOTH. Add (and therefore replace) link if both to * and from exist in a single link EITHER. Adds link. if either to or from * is present removes old link existing links * * @param addMap * map to add. Not altered (links are copied) * @param control * EITHER, BOTH, NEITHER */ public void mergeMap(CMLMap addMap, Direction control) { if (addMap != null) { for (CMLLink link : addMap.getLinkElements()) { this.addUniqueLink(new CMLLink(link), control); } } } /** * set the Direction.FROM context for all links. * * @param context * to set */ public void setLinkFromContext(String context) { for (CMLLink link : getLinkElements()) { link.setFromContext(context); } } /** * set the Direction.TO context for all links. * * @param context * to set */ public void setLinkToContext(String context) { for (CMLLink link : getLinkElements()) { link.setToContext(context); } } /** * set the Direction.FROM type for all child links. only works on current * list (i,e, if more links are added it should be repeated * * @param type * to set */ public void setLinkFromType(String type) { for (CMLLink link : getLinkElements()) { link.setFromType(type); } } /** * set the Direction.TO type for all links. only works on current list (i,e, * if more links are added it should be repeated * * @param type * to set */ public void setLinkToType(String type) { for (CMLLink link : getLinkElements()) { link.setToType(type); } } /** * extract all links involving particular elements. requires the link to * have fromType='foo' and toType='foo' and toSet and fromSet attributes * does not yet process them * * @param tag * @return all links containing sets of atoms. */ public List getElementLinks(String tag) { List linkList = new ArrayList(); for (CMLLink link : getLinkElements()) { String toType = CMLMap.getType(link, Direction.TO); String fromType = CMLMap.getType(link, Direction.FROM); if (tag.equals(toType) && tag.equals(fromType)) { String toSet = Util.concatenate(link.getToSet(), CMLConstants.S_SPACE); String fromSet = Util.concatenate(link.getFromSet(), CMLConstants.S_SPACE); if (toSet != null && !S_EMPTY.equals(toSet.trim()) && fromSet != null && !S_EMPTY.equals(fromSet.trim())) { linkList.add(link); } } } return linkList; } /** * gets type of link. // FIXME - create LinkTool use toType or fromType on * link, else use toType/fromType on parent CMLMap. probably needs to be * recast for LinkTool when written * * @param link * @param toFrom * Direction.TO or Direction.FROM * @return the to/from type or null */ public static String getType(CMLLink link, Direction toFrom) { String type = (toFrom.equals(Direction.TO)) ? link.getToType() : link .getFromType(); if (type == null || type.trim().equals(S_EMPTY)) { Node parent = link.getParent(); if (parent != null && parent instanceof CMLMap) { CMLMap map = (CMLMap) parent; type = (toFrom.equals(Direction.TO)) ? map.getToType() : map .getFromType(); } } return type; } /** * annote each link with context and type. (often better done in parent map) * * @param fromType * @param fromContext * @param toType * @param toContext */ public void annotateLinks(String fromType, String fromContext, String toType, String toContext) { this.setLinkToContext(toContext); this.setLinkFromContext(fromContext); this.setLinkToType(toType); this.setLinkFromType(fromType); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLMatrix.java000077500000000000000000000466341477224461000256500ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.attribute.DelimiterAttribute; import org.xmlcml.cml.attribute.NamespaceRefAttribute; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLType; import org.xmlcml.cml.interfacex.HasDataType; import org.xmlcml.cml.interfacex.HasDelimiter; import org.xmlcml.cml.interfacex.HasDictRef; import org.xmlcml.cml.interfacex.HasUnits; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.IntMatrix; import org.xmlcml.euclid.RealArray; import org.xmlcml.euclid.RealMatrix; import org.xmlcml.euclid.RealSquareMatrix; import org.xmlcml.euclid.Util; /** * user-modifiable class supporting matrix. * autogenerated from schema use as a * shell which can be edited * */ public class CMLMatrix extends AbstractMatrix implements HasUnits, HasDataType, HasDictRef, HasDelimiter { /** types of matrix. */ public enum Type { /** dewisott */ RECTANGULAR("rectangular"), /** dewisott */ SQUARE("square"), /** dewisott */ SQUARE_SYMMETRIC("squareSymmetric"), /** dewisott */ SQUARE_SYMMETRIC_LT("squareSymmetricLT"), /** dewisott */ SQUARE_SYMMETRIC_UT("squareSymmetricUT"), /** dewisott */ SQUARE_ANTISYMMETRIC("squareAntisymmetric"), /** dewisott */ SQUARE_ANTISYMMETRIC_LT("squareAntisymmetricLT"), /** dewisott */ SQUARE_ANTISYMMETRIC_UT("squareAntisymmetricUT"), /** dewisott */ DIAGONAL("diagonal"), /** dewisott */ UPPER_TRIANGULAR("upperTriangular"), /** dewisott */ UPPER_TRIANGULAR_UT("upperTriangularUT"), /** dewisott */ LOWER_TRIANGULAR("lowerTriangular"), /** dewisott */ LOWER_TRIANGULAR_LT("lowerTriangularLT"), /** dewisott */ UNIT("unit"), /** dewisott */ UNITARY("unitary"), /** dewisott */ ROW_EIGENVECTORS("rowEigenvectors"), /** dewisott */ ROTATION22("rotation22"), /** dewisott */ ROTATION_TRANSLATION32("rotationTranslation32"), /** dewisott */ HOMOGENEOUS33("homogeneous33"), /** dewisott */ ROTATION33("rotation33"), /** dewisott */ ROTATION_TRANSLATION43("rotationTranslation43"), /** dewisott */ HOMOGENEOUS44("homogeneous44") ; /** value */ public String value; private Type(String v) { this.value = v; } } /** namespaced element name.*/ public final static String NS = C_E+TAG; private DelimiterAttribute delimiterAttribute = null; /** * constructor. * */ public CMLMatrix() { } /** * constructor. * * @param old */ public CMLMatrix(CMLMatrix old) { super((AbstractMatrix) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLMatrix(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLMatrix */ public CMLElement makeElementInContext(Element parent) { return new CMLMatrix(); } private void ensureDelimiterAttribute() { if (delimiterAttribute == null) { delimiterAttribute = (DelimiterAttribute) this.getDelimiterAttribute(); } if (delimiterAttribute == null) { delimiterAttribute = new DelimiterAttribute(S_SPACE); } } // =========================== additional constructors // ======================== /** * formed from components. rows and columns are extracted from array * dimensions sets dataType to xsd:double * * @param matrix * rectangular matrix */ public CMLMatrix(double[][] matrix) { this.setMatrix(matrix); } /** * formed from components. rows and columns are extracted from array * dimensions sets dataType to xsd:integer * * @param matrix * rectangular matrix * @throws RuntimeException * wrong matrix shape */ public CMLMatrix(int[][] matrix) { this.setMatrix(matrix); } /** * formed from components. rows and columns are extracted from array * dimensions sets dataType to xsd:double * * @param rows * @param columns * @param array rectangular array * @throws RuntimeException wrong shape */ public CMLMatrix(int rows, int columns, double[] array) { this.setArray(rows, columns, array); } /** * formed from components. rows and columns are extracted from array * dimensions sets dataType to xsd:integer * * @param rows * @param columns * @param array * rectangular array * @throws RuntimeException * wrong matrix shape */ public CMLMatrix(int rows, int columns, int[] array) throws RuntimeException { this.setArray(rows, columns, array); } // FIXME - move to Euclid /** create matrix with special shape. * @param array * @param rows * @param type * @return matrix */ public static CMLMatrix createSquareMatrix(RealArray array, int rows, Type type) { CMLMatrix matrix = null; int n = array.size(); RealSquareMatrix rsm = null; if (type == Type.SQUARE || type == Type.SQUARE_SYMMETRIC // more values later ) { if (rows * rows != n) { throw new RuntimeException("square array size ("+n+ ") incompatible with rows: "+rows); } matrix = new CMLMatrix(rows, rows, array.getArray()); } else if (type == Type.SQUARE_SYMMETRIC_LT) { if ((rows * (rows + 1)) /2 != n) { throw new RuntimeException("triangular array size ("+n+ ") incompatible with rows: "+rows); } rsm = RealSquareMatrix.fromLowerTriangle(array); } else if (type == Type.SQUARE_SYMMETRIC_UT) { rsm = RealSquareMatrix.fromUpperTriangle(array); } if (rsm != null) { if (rsm.getRows() != rows) { throw new RuntimeException("array size ("+n+ ") incompatible with rows: "+rows); } matrix = new CMLMatrix(rows, rows, rsm.getMatrixAsArray()); } return matrix; } // ====================== housekeeping methods ===================== /** * get row count. * * @return count * @throws RuntimeException * if attribute not set */ public int getRows() { if (super.getRowsAttribute() == null) { throw new RuntimeException("rows attribute must be set"); } return super.getRows(); } /** * get column count. * * @return count * @throws RuntimeException * if attribute not set */ public int getColumns() { if (super.getColumnsAttribute() == null) { throw new RuntimeException("columns attribute must be set"); } return super.getColumns(); } // ====================== housekeeping methods ===================== /** * get strings. * * @return strings */ String[] getStrings() { String[] ss = getSplitContent(); return ss; } /** * splits content into tokens. if delimiter is whitespace, trims content and * splits at whitespace (however long) else assume starts and ends with * delimiter * * @return the tokens * @throws RuntimeException * if size attribute is inconsistent */ private String[] getSplitContent() throws RuntimeException { String content = this.getXMLContent().trim(); ensureDelimiterAttribute(); String[] ss = new String[0]; content = content.trim(); if (content.length() > 0) { ensureDelimiterAttribute(); ss = delimiterAttribute.getSplitContent(content); } this.removeWhitespaceDelimiterAttribute(); return ss; } String[] getStringMatrixElements() throws RuntimeException { String delimiter = getDelimiter(); int rows = getRows(); int cols = getColumns(); String content = this.getXMLContent(); String regex = (delimiter == null || delimiter.trim().equals(S_EMPTY)) ? S_WHITEREGEX : delimiter; String[] stringArray = content.split(regex); if (stringArray.length != rows * cols) { throw new RuntimeException("Bad array shape rows: " + rows + " cols: " + cols + " incompatible with elements: " + stringArray.length); } return stringArray; } /** * create new CMLMatrix from RealMatrix. * * @param realMatrix * to create from * @return the matrix */ static CMLMatrix createCMLMatrix(RealMatrix realMatrix) { CMLMatrix cmlMatrix = null; String delimiter = S_SPACE; cmlMatrix = new CMLMatrix(); setXMLContent(cmlMatrix, delimiter, realMatrix.getMatrixAsArray()); cmlMatrix.setColumns(realMatrix.getCols()); cmlMatrix.setRows(realMatrix.getRows()); cmlMatrix.setDelimiter(delimiter); cmlMatrix.removeWhitespaceDelimiterAttribute(); return cmlMatrix; } /** * create new CMLMatrix from IntMatrix. * * @param intMatrix * to create from * @return the matrix */ static CMLMatrix createCMLMatrix(IntMatrix intMatrix) { CMLMatrix cmlMatrix = null; String delimiter = S_SPACE; cmlMatrix = new CMLMatrix(); setXMLContent(cmlMatrix, delimiter, intMatrix.getMatrixAsArray()); cmlMatrix.setColumns(intMatrix.getCols()); cmlMatrix.setRows(intMatrix.getRows()); cmlMatrix.setDelimiter(delimiter); cmlMatrix.removeWhitespaceDelimiterAttribute(); return cmlMatrix; } static void setXMLContent(CMLMatrix cmlMatrix, String delimiter, double[] array) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < array.length; i++) { if (i > 0) { sb.append(delimiter); } sb.append(array[i]); } cmlMatrix.setXMLContent(sb.toString()); } static void setXMLContent(CMLMatrix cmlMatrix, String delimiter, int[] array) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < array.length; i++) { if (i > 0) { sb.append(delimiter); } sb.append(array[i]); } cmlMatrix.setXMLContent(sb.toString()); } /** * wraps content. * * @return the matrix (created not copied) */ public RealMatrix getEuclidRealMatrix() { RealMatrix rm = new RealMatrix(this.getRows(), this.getColumns(), this .getDoubleArray()); return rm; } /** * wraps content. * * @return the matrix (created not copied) */ public IntMatrix getEuclidIntMatrix() { return new IntMatrix(this.getRows(), this.getColumns(), this .getIntegerArray()); } // ====================== subsidiary accessors ===================== /** * sets components. resets dataType * * @param mat * matrix of rowsxcolumns doubles, columns fastest */ public void setMatrix(double[][] mat) { RealMatrix mm = new RealMatrix(mat); String content = Util.concatenate(mm.getMatrixAsArray(), S_SPACE); setRows(mm.getRows()); setColumns(mm.getCols()); setDataType(XSD_DOUBLE); setXMLContent(content); this.removeWhitespaceDelimiterAttribute(); } /** * sets components. resets dataType * * @param mat * matrix of rowsxcolumns ints, columns fastest * @throws EuclidRuntimeException wrong shape */ public void setMatrix(int[][] mat) { IntMatrix mm = new IntMatrix(mat); String content = Util.concatenate(mm.getMatrixAsArray(), S_SPACE); setRows(mm.getRows()); setColumns(mm.getCols()); setDataType(XSD_INTEGER); setXMLContent(content); this.removeWhitespaceDelimiterAttribute(); } /** * sets components. resets dataType * * @param rows * @param columns * @param array * of rowsxcolumns doubles, columns fastest */ public void setArray(int rows, int columns, double[] array) { RealMatrix euclRealMatrix = new RealMatrix(rows, columns, array); setRows(rows); setColumns(columns); setDataType(XSD_DOUBLE); setXMLContent(Util.concatenate(euclRealMatrix.getMatrixAsArray(), S_SPACE)); this.removeWhitespaceDelimiterAttribute(); } /** * sets components. resets dataType * * @param rows * @param columns * @param array * of rowsxcolumns ints, columns fastest * @throws RuntimeException * wrong shape */ public void setArray(int rows, int columns, int[] array) throws RuntimeException { IntMatrix euclIntMatrix = new IntMatrix(rows, columns, array); setRows(rows); setColumns(columns); setDataType(XSD_INTEGER); setXMLContent(Util.concatenate(euclIntMatrix.getMatrixAsArray(), S_SPACE)); this.removeWhitespaceDelimiterAttribute(); } /** * gets dataType. dataType is set by the type of array * * @return data type */ public String getDataType() { String dataType = super.getDataType(); if (dataType == null) { dataType = XSD_STRING; super.setDataType(dataType); } return CMLType.getNormalizedValue(dataType); } /** * gets values as array. * * @return double array (or null if different type) */ public double[] getDoubleArray() { double[] dd = null; if (this.getDataType().equals(XSD_DOUBLE) || this.getDataType().equals(FPX_REAL)) { dd = Util.splitToDoubleArray(this.getXMLContent(), S_WHITEREGEX); } return dd; } /** * gets values as array. * * @return int array (or null if different type) */ public int[] getIntegerArray() { int[] ii = null; if (XSD_INTEGER.equals(this.getDataType())) { try { ii = Util.splitToIntArray(this.getXMLContent(), S_WHITEREGEX); } catch (EuclidRuntimeException e) { throw new RuntimeException("bug " + e); } } return ii; } /** * gets values as matrix. * * @return double matrix (or null if different type) */ public double[][] getDoubleMatrix() { double[][] ddd = null; double[] dd = this.getDoubleArray(); int count = 0; if (dd != null) { int rows = getRows(); int columns = getColumns(); ddd = new double[rows][columns]; for (int i = 0; i < rows; i++) { System.arraycopy(dd, count, ddd[i], 0, columns); count += columns; } } return ddd; } /** * gets values as matrix. * * @return int matrix (or null if different type) */ public int[][] getIntegerMatrix() { int[][] iii = null; int[] ii = this.getIntegerArray(); int count = 0; if (ii != null) { int rows = getRows(); int columns = getColumns(); iii = new int[rows][columns]; for (int i = 0; i < rows; i++) { System.arraycopy(ii, count, iii[i], 0, columns); count += columns; } } return iii; } public CMLScalar getElementAt(int row, int col) { CMLScalar scalar = null; if (row >= 0 && row < getRows() && col >= 0 && col < getColumns()) { String dataType = this.getDataType(); if (dataType == null) { dataType = XSD_STRING; } if (dataType.equals(XSD_DOUBLE)) { Double d = getDoubleMatrix()[row][col]; scalar = new CMLScalar(d); } else if (dataType.equals(XSD_INTEGER)) { Integer ii = getIntegerMatrix()[row][col]; scalar = new CMLScalar(ii); } CMLArray.copyAttributesFromTo(this, scalar); } return scalar; } // ====================== functionality ===================== /** * is matrix square. * * @return columns = rows */ public boolean isSquare() { return getRows() == getColumns(); } /** * are two matrices equal. compare rows columns and array contents * * @param matrix * to compare * @param eps * max allowed difference * @return true if equal */ public boolean isEqualTo(CMLMatrix matrix, double eps) { return (this.getRows() == matrix.getRows() && this.getColumns() == matrix.getColumns() && Util.isEqual( this.getDoubleArray(), matrix.getDoubleArray(), eps)); } /** * concatenate. (I think this is right...) result = this * m2 i.e. if x' = * m2 * x and x'' = this * x'' then x'' = result * x; * * @param m2 * matrix to be concatenated * @return result of applying this to m2 * @throws RuntimeException */ public CMLMatrix multiply(CMLMatrix m2) { RealMatrix t = null; int m2r = m2.getRows(); int m2c = m2.getColumns(); RealMatrix teucl3 = new RealMatrix(m2r, m2c, this.getDoubleArray()); t = teucl3.multiply(m2.getEuclidRealMatrix()); CMLMatrix newMatrix = new CMLMatrix(m2r, m2c, t.getMatrixAsArray()); newMatrix.removeWhitespaceDelimiterAttribute(); return newMatrix; } /** * sets units attribute. requires namespace for unit to be in scope. * * @param prefix for namespace * @param id for unit * @param namespaceURI sets units namespace if not present already */ public void setUnits(String prefix, String id, String namespaceURI) { NamespaceRefAttribute.setUnits((HasUnits)this, prefix, id, namespaceURI); } /** removes attributes of the form * delimiter="" or delimiter=" " */ public void removeWhitespaceDelimiterAttribute() { CMLArray.removeWhitespaceDelimiterAttribute(this); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLMechanism.java000077500000000000000000000033251477224461000262760ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting mechanism. * autogenerated from schema use * as a shell which can be edited * */ public class CMLMechanism extends AbstractMechanism { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLMechanism() { } /** * constructor. * * @param old */ public CMLMechanism(CMLMechanism old) { super((AbstractMechanism) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLMechanism(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLMechanism */ public CMLElement makeElementInContext(Element parent) { return new CMLMechanism(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLMechanismComponent.java000077500000000000000000000034571477224461000301670ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting mechanismComponent. * autogenerated from * schema use as a shell which can be edited * */ public class CMLMechanismComponent extends AbstractMechanismComponent { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLMechanismComponent() { } /** * constructor. * * @param old */ public CMLMechanismComponent(CMLMechanismComponent old) { super((AbstractMechanismComponent) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLMechanismComponent(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLMechanismComponent */ public CMLElement makeElementInContext(Element parent) { return new CMLMechanismComponent(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLMetadata.java000077500000000000000000000075351477224461000261210ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLAttribute; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting metadata. * autogenerated from schema use as * a shell which can be edited * */ public class CMLMetadata extends AbstractMetadata { /** namespaced element name.*/ public final static String NS = C_E+AbstractMetadata.TAG; /** * constructor. */ public CMLMetadata() { } /** * constructor. * * @param old */ public CMLMetadata(CMLMetadata old) { super((AbstractMetadata) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLMetadata(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return ICMLMetadata */ public CMLElement makeElementInContext(Element parent) { return new CMLMetadata(); } /** * Override metadata type. no-op * * @deprecated * @return null */ public CMLAttribute getMetadataTypeAttribute() { return null; } /** * Override metadata type. no-op * * @deprecated * @return null */ public String getMetadataType() { return null; } /** * Override metadata type. no-op * * @deprecated * @param value * do not use * @throws RuntimeException */ public void setMetadataType(String value) throws RuntimeException { } /** * replace setMetadataType. this is because attributeGroup name and * attribute name are not the same * * @param value */ /*-- public void setName(String value) { if (_att_metadataType == null) { _att_metadataType = new StringSTAttribute((StringSTAttribute)CMLAttributeList.getAttribute("metadataType")); super.addAttribute(_att_metadataType); } ((StringSTAttribute)_att_metadataType).setCMLValue(value); } --*/ /** * replace getMetadataType. this is because attributeGroup name and * attribute name are not the same * * @param name */ /*-- public String getName() { if (_att_metadataType == null) { _att_metadataType = (CMLAttribute) getAttribute("metadataType"); } if (_att_metadataType == null) { return null; } return ((StringSTAttribute)_att_metadataType).getString(); // return getAttributeValue("name"); } --*/ /** * override name and metadataType attributes. this is because attributeGroup * and attribute have different names * * @param att */ public void addAttribute(Attribute att) { super.addAttribute(att); String name = att.getLocalName(); String value = att.getValue(); if (name.equals("metadataType")) { super.removeAttribute(att); setName(value); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLMetadataList.java000077500000000000000000000116521477224461000267500ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import nu.xom.Elements; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; /** * user-modifiable class supporting metadataList. * autogenerated from schema * use as a shell which can be edited * */ public class CMLMetadataList extends AbstractMetadataList { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLMetadataList() { } /** * constructor. * * @param old */ public CMLMetadataList(CMLMetadataList old) { super((AbstractMetadataList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLMetadataList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLMetadataList */ public CMLElement makeElementInContext(Element parent) { return new CMLMetadataList(); } /** * gets all nested metadata descendants of arbitrary CMLElement. * * recurses through all metadataList and metadata children, adding the * latter to the list. Order is not preserved. * * @return list of all descendants */ public List getMetadataDescendants() { List mList = new ArrayList(); CMLElements metadataLists = this .getMetadataListElements(); for (CMLMetadataList ml : metadataLists) { mList.addAll(ml.getMetadataDescendants()); } CMLElements metadatas = this.getMetadataElements(); for (CMLMetadata m : metadatas) { mList.add(m); } return mList; } /** * gets all nested metadata descendants of arbitrary CMLElement. * * recurses through all metadataList and metadata children, adding the * latter to the list. Order is not preserved. * * @param parent * with metadata(List) children * @return list of all descendants */ public static List getMetadataDescendants(CMLElement parent) { List mList = new ArrayList(); Elements metadataLists = parent .getChildCMLElements(CMLMetadataList.TAG); for (int i = 0; i < metadataLists.size(); i++) { CMLMetadataList metadataList = (CMLMetadataList) metadataLists .get(i); mList.addAll(metadataList.getMetadataDescendants()); } // generally metadata should be under metadataList parent Elements metadatas = parent.getChildCMLElements(CMLMetadata.TAG); for (int i = 0; i < metadatas.size(); i++) { mList.add((CMLMetadata) metadatas.get(i)); } return mList; } /** * gets metadata elements with a given name. if either param is null, * returns empty list * * @param metadataList * list to filter * @param name * value of name attribute * @return filtered list */ private static List getMetadataDescendantsByName( List metadataList, String name) { List newMetadataList = new ArrayList(); if (name != null && metadataList != null) { for (CMLMetadata metadata : metadataList) { if (name.equals(metadata.getName())) { newMetadataList.add(metadata); } } } return newMetadataList; } /** * gets metadata elements with a given name. if name is null returns empty * list * * @param name * value of name attribute * @return filtered list */ @SuppressWarnings("unused") private List getMetadataDescendantsByName(String name) { return getMetadataDescendantsByName(this.getMetadataDescendants(), name); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLModule.java000077500000000000000000000033731477224461000256220ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.interfacex.HasDictRef; /** * user-modifiable class supporting module. * autogenerated from schema use as a * shell which can be edited * */ public class CMLModule extends AbstractModule implements HasDictRef { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLModule() { } /** * constructor. * * @param old */ public CMLModule(CMLModule old) { super((AbstractModule) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLModule(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLModule */ public CMLElement makeElementInContext(Element parent) { return new CMLModule(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLMolecule.java000077500000000000000000001210531477224461000261360ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import nu.xom.Attribute; import nu.xom.Document; import nu.xom.Element; import nu.xom.Elements; import nu.xom.Node; import nu.xom.Nodes; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.xmlcml.cml.attribute.IdAttribute; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.base.CMLUtil; import org.xmlcml.euclid.Real2; import org.xmlcml.euclid.Real2Vector; /** * Class representing the CML molecule element, this class can be used to * retrieve and manipulate the CMLAtom and CMLBond elements that belong to this * molecule as well as perform simple calculations such as... * * @author Peter Murray-Rust, Ramin Ghorashi (2005) * */ public class CMLMolecule extends AbstractMolecule /*implements Indexable*/ { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** control of hydrogen */ public enum HydrogenControl { // this probably needs more looking at /** expand hydrogens always and add to existing H. */ ADD_TO_EXPLICIT_HYDROGENS, /** add number of explicit H to current hydrogenCount. */ ADD_TO_HYDROGEN_COUNT, /** expand hydrogens only if no explicit hydrogens. */ NO_EXPLICIT_HYDROGENS, /** replace hydrogenCount by number of explicit H. */ REPLACE_HYDROGEN_COUNT, /** use explict H in formula. */ USE_EXPLICIT_HYDROGENS, /** use hydrogenCount in formula. */ USE_HYDROGEN_COUNT; } /** 2-D coordinates. */ public final static int COORD2 = 2; /** 3-D coordinates. */ public final static int COORD3 = 3; /** 2-d coordinates. */ public final static String D2 = "2D"; /** 3-d coordinates. */ public final static String D3 = "3D"; // /** default single or LH R group. // */ // public final static String R1 = "defr1"; // /** RH R group. // */ // public final static String R2 = "defr2"; final static Logger logger; // / @cond DOXYGEN_STATIC_BLOCK_WORKAROUND static { logger = Logger.getLogger(CMLMolecule.class); logger.setLevel(Level.INFO); } // ancillary elements or helpers /** gets the first ancestor molecule * * @return null if none */ public static CMLMolecule getAncestorMolecule(CMLElement element) { try { return (CMLMolecule)(element.query("ancestor::cml:molecule", CML_XPATH)).get(0); } catch (Exception e) { return null; } } /** * get corresponding molecule * * uses parent molecule or grandparent // should be using XPath * * @param elem * @return the molecule (null if none) * @deprecated use getAncetsorMolecule */ public static CMLMolecule getMoleculeAncestor(CMLElement elem) { CMLMolecule mol = null; Node parent = elem; while (true) { parent = parent.getParent(); if (parent == null || parent instanceof Document) { break; } if (parent instanceof CMLMolecule) { mol = (CMLMolecule) parent; break; } } return mol; } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLBond */ public CMLElement makeElementInContext(Element parent) { return new CMLMolecule(); } /** map holding ids of all child molecules idexed by id. */ Map> childMoleculeAtomMap = null; /** map with child molecules indexed by atom. */ Map atomChildMoleculeMap = null; // =========================== main constructors ======================== /** * normal constructor. * */ public CMLMolecule() { super(); init(); } /** recommended creator. * @param id * @return empty molecule. */ public static CMLMolecule createMoleculeWithId(String id) { CMLMolecule molecule = new CMLMolecule(); molecule.setId(id); return molecule; } /** * copy constructor. * PMR I don't trust this... * @param old * molcule to copy */ public CMLMolecule(CMLMolecule old) { super((AbstractMolecule) old); init(); CMLAtomArray atomArray = this.getAtomArray(); if (atomArray != null) { atomArray.indexAtoms(); } CMLBondArray bondArray = this.getBondArray(); if (bondArray != null) { bondArray.indexBonds(); } } /** * The checking included in previous versions of Jumbo has now been removed. This * method is retained for backward compatibility only, and the value of the boolean does * not affect the execution of the code. * @author dmj30 * @param atom * @throws RuntimeException * null, non-uniqueID, etc. */ @Deprecated public void addAtom(CMLAtom atom, boolean check) throws RuntimeException { addAtom(atom); } /** add atom. * * only if in same molecule. If already added returns with no-op * cannot add to child molecule. However if 'this' is a child of * a CMLMolecule throws Exception * @param atom * @throws RuntimeException * null, non-uniqueID, etc. */ public void addAtom(CMLAtom atom) throws RuntimeException { if (atom != null) { //ParentNode parent = this.getParent(); //if (parent instanceof CMLMolecule) { // throw new RuntimeException("Cannot add atom to child molecule"); //} CMLAtomArray atomArray = getOrCreateAtomArray(); // should it be atom array that tests this? String id = atom.getId(); if (id == null) { throw new RuntimeException("Null atom ID"); } CMLAtom oldAtom = atomArray.getAtomById(id); if (oldAtom == null) { atomArray.addAtom(atom); } } else { throw new RuntimeException("Cannot add null atom"); } } /** delete atom. * recurse through descendants and remove first instance of * atom (there should only be one) * @param atom * @return atom deleted */ public CMLAtom deleteAtom(CMLAtom atom) { CMLAtom deletedAtom = null; if (isMoleculeContainer()) { getAtomChildMoleculeMap(); CMLMolecule molecule = atomChildMoleculeMap.get(atom); if (molecule != null) { molecule.deleteAtom(atom); deletedAtom = atom; atomChildMoleculeMap.remove(atom); } } else { CMLAtomArray atomArray = getAtomArray(); if (atomArray != null) { deletedAtom = atomArray.removeAtom(atom); } } removeAtomFromChildMoleculeAtomMap(atom); return deletedAtom; } private void removeAtomFromChildMoleculeAtomMap(CMLAtom atom) { getChildMoleculeAtomMap(); String id = atom.getId(); List atomList = childMoleculeAtomMap.get(id); if (atomList != null && atomList.size() > 1) { atomList.remove(atom); } else { childMoleculeAtomMap.remove(id); } } /** get the atomChildMoleculeMap. * if null, populate it with atoms from child molecules. * */ private void getAtomChildMoleculeMap() { if (atomChildMoleculeMap == null) { atomChildMoleculeMap = new HashMap(); CMLElements moleculeList = this.getMoleculeElements(); for (CMLMolecule molecule : moleculeList) { List atomList = molecule.getAtoms(); for (CMLAtom atom : atomList) { atomChildMoleculeMap.put(atom, molecule); } } } } /** add atomArray. * forbidden. must use addAtom() * @deprecated * @param atomArray * @param pos * @throws RuntimeException */ @Deprecated public void insertAtomArray(CMLAtomArray atomArray, int pos) { throw new RuntimeException("append/insert atomArray forbidden"); } /** remove atomArray. * also removes bondArray * */ public void removeAtomArray() { CMLElements atomArrays= this.getAtomArrayElements(); CMLAtomArray atomArray = (atomArrays.size() == 0) ? null : atomArrays.get(0); if (atomArray != null) { super.removeChild(atomArray); this.removeBondArray(); } } /** add bondArray. * forbidden. must use addBond() * @deprecated * @param bondArray * @param pos * @throws RuntimeException */ public void insertBondArray(CMLBondArray bondArray, int pos) { throw new RuntimeException("append/insert bondArray forbidden"); } /** remove bondArray. * */ public void removeBondArray() { CMLElements bondArrays= this.getBondArrayElements(); CMLBondArray bondArray = (bondArrays.size() == 0) ? null : bondArrays.get(0); if (bondArray != null) { super.removeChild(bondArray); } } /** * The checking included in previous versions of Jumbo has now been removed. This * method is retained for backward compatibility only, and the value of the boolean does * not affect the execution of the code. * @author dmj30 * @param bond * @throws RuntimeException * null, non-uniqueID, etc. */ @Deprecated public void addBond(CMLBond bond, boolean check) throws RuntimeException { addBond(bond); } /** * add bond. * checks for duplicates ; should be changed to use atoms * only if in same molecule. If already added returns with no-op * * @param bond * @throws RuntimeException * null, non-uniqueID, etc. */ public void addBond(CMLBond bond) throws RuntimeException { CMLBondArray bondArray = getOrCreateBondArray(); // should it be bond array that tests this? String id = bond.getId(); if (id == null) { String[] atomRefs2 = bond.getAtomRefs2(); // throw new Runtime("Null bond ID"); id = atomRefs2[0]+S_UNDER+atomRefs2[1]; bond.setId(id); } else { CMLBond oldBond = getBondById(id); if (oldBond != null) { if (oldBond != bond) { throw new RuntimeException("Bond id not unique: " + id); } return; } } bondArray.addBond(bond); } /** delete bond. * recurse through descendants and remove first instance of * bond (there should only be one) * * @param bond * @return bond deleted */ public CMLBond deleteBond(CMLBond bond) { CMLBond deletedBond = null; if (isMoleculeContainer()) { for (CMLMolecule mol : this.getMoleculeElements()) { deletedBond = mol.deleteBond(bond); if (deletedBond != null) { break; } } } else { CMLBondArray bondArray = getBondArray(); if (bondArray != null) { deletedBond = bondArray.removeBond(bond); } } return deletedBond; } /** delete bond. * convenience method. Finds bond and if not null uses deleteBond * * @param atom1 * @param atom2 * @return bond deleted of null */ public CMLBond deleteBond(CMLAtom atom1, CMLAtom atom2) { CMLBond deletedBond = this.getBond(atom1, atom2); if (deletedBond != null) { deleteBond(deletedBond); } return deletedBond; } /** * append a molecule to this one if current molecule has no children, * creates a new parent molecule and adds itself as a child. * in this case strips all attributes except ID. * if children already present adds as sibling * children * * @param newMol * the CMLMolecule to append * @exception RuntimeException * if the DOM operation failed */ public void appendMolecule(CMLMolecule newMol) { Node parent = newMol.getParent(); if (parent != null && parent instanceof Document) { Element dummy = new Element("m_dummy"); ((Document)parent).replaceChild(newMol, dummy); } newMol.detach(); if (this.getMoleculeCount() == 0) { CMLMolecule thisMol = new CMLMolecule(this); for (int i = 0; i < this.getAttributeCount(); i++) { Attribute att = this.getAttribute(i); if (!att.getLocalName().equals(IdAttribute.NAME)) { this.removeAttribute(this.getAttribute(i)); } } this.removeChildren(); this.appendChild(thisMol); } this.appendChild(newMol); } /** delete molecule child. * if the result is a single molecule child does NOT * normalize the result. * @param molecule */ public void deleteMolecule(CMLMolecule molecule) { int nChildMolecule = getMoleculeCount(); if (nChildMolecule == 0) { throw new RuntimeException("molecule has no children to delete"); } else { int idx = this.indexOf(molecule); if (idx == -1) { throw new RuntimeException("Molecule is not a child of this Molecule"); } if (nChildMolecule == 1) { throw new RuntimeException("Cannot have single child molecule"); } else if (nChildMolecule == 2) { molecule.detach(); // do not normalize at this stage } else { molecule.detach(); } removeAtomsFromAtomMap(molecule.getAtoms()); } } private void removeAtomsFromAtomMap(List atomList) { getChildMoleculeAtomMap(); for (CMLAtom atom : atomList) { childMoleculeAtomMap.remove(atom); } } /** normalize molecule has a single molecule child. * transfers children single child molecule to this * and removes childMolecule. * Thus * {@code * * * * * * becomes * * * * } * atom indexing should be reset */ public void normalizeSingleMoleculeChild() { if (this.getMoleculeCount() == 1) { CMLMolecule childMolecule = (CMLMolecule) this.getChildCMLElements(CMLMolecule.TAG).get(0); CMLUtil.transferChildren(childMolecule, this); childMolecule.detach(); } } /** reroutes appendChild() for molecule. * calls addMolecule(molecule) * @param molecule */ public void appendChild(CMLMolecule molecule) { this.addMolecule(molecule); } /** reroutes removeChild() for molecule. * calls deleteMolecule(molecule) * @param molecule */ public void removeChild(CMLMolecule molecule) { this.deleteMolecule(molecule); } /** reroutes appendChild() for atom. * calls addAtom(atom) * @param atom */ public void appendChild(CMLAtom atom) { this.addAtom(atom); } /** reroutes removeChild() for atom. * calls deleteAtom(atom) * @param atom */ public void removeChild(CMLAtom atom) { this.deleteAtom(atom); } /** reroutes appendChild() for bond. * calls addBond(bond) * @param bond */ public void appendChild(CMLBond bond) { this.addBond(bond); } /** reroutes removeChild() for bond. * calls deleteBond(bond) * @param bond */ public void removeChild(CMLBond bond) { this.deleteBond(bond); } /** * Appends a string to the ids for the molecule, atoms and bonds. It also * updates the bond refs to point to the amended atom ids. * * @param s * The string to be appended to all of the ids */ public void appendToIds(final String s) { String id = this.getId(); if ((id != null) && (id.length() > 0)) { this.setId(id + s); } else { this.setId("m" + s); } for (CMLAtom atom : getAtoms()) { id = atom.getId(); if ((id != null) && (id.length() > 0)) { atom.resetId(id + s); } } for (CMLBond bond : getBonds()) { id = bond.getId(); if ((id != null) && (id.length() > 0)) { bond.setId(id + s); } String[] refs = bond.getAtomRefs2(); if (refs != null) { for (int j = refs.length - 1; j >= 0; --j) { refs[j] += s; } } bond.setAtomRefs2(refs); } } /** * calculate formal charge from charges on atoms in the molecule * @return charge */ public int calculateFormalCharge() { int formalCharge = 0; for (CMLAtom atom : this.getAtoms()) { formalCharge += atom.getFormalCharge(); } return formalCharge; } /** * copy node . * * @return Node */ public Element copy() { CMLMolecule newMolecule = new CMLMolecule(this); // newMolecule.moleculesManager = new MoleculeMolecules(this); // newMolecule.moleculesManager.update(); return newMolecule; } /** * will process repeat attribute. * * @param parent * element */ public void finishMakingElement(Element parent) { super.finishMakingElement(parent); // not necessary as done already // indexAtoms(); // this also updates the ligands // indexBonds(); // updateLigands(); // RepeatAttribute.process(this); } void indexAtoms() { if (isMoleculeContainer()) { for (CMLMolecule mol : this.getMoleculeElements()) { mol.indexAtoms(); } } else { CMLAtomArray atomArray = this.getOrCreateAtomArray(); if (atomArray != null) { atomArray.indexAtoms(); } } } void indexBonds() { if (isMoleculeContainer()) { for (CMLMolecule mol : this.getMoleculeElements()) { // these should be indexed as children finish first mol.indexBonds(); } } else { CMLBondArray bondArray = this.getOrCreateBondArray(); bondArray.indexBonds(); } } void updateLigands() { if (isMoleculeContainer()) { for (CMLMolecule mol : this.getMoleculeElements()) { mol.updateLigands(); } } else { CMLBondArray bondArray = this.getBondArray(); if (bondArray != null) { bondArray.updateLigands(); } } } /** * Convenience method for accessing i'th CMLAtom. FRAGILE. Used to iterate * through the atoms of this molecule; however the list is subject to change * and could cause unexpected results. * * Use getAtoms to return a typed list of all the atoms in this molecule. * * @param i * the index of the atoms to access * @return the bond, or null if index is out of bounds. * */ public CMLAtom getAtom(int i) { List atoms = this.getAtoms(); return (i < 0 || i >= atoms.size()) ? null : atoms.get(i); } /** * gets atomArray child. * * @return null if does not exist */ public CMLAtomArray getAtomArray() { return (CMLAtomArray) this.getFirstCMLChild("atomArray"); } /** gets atomMap. * if molecule has single AtomArray child returns its map * if molecule has submolecules returns null; * @return null if */ public Map getAtomMap() { Map map = null; if (this.isMoleculeContainer()) { } else { CMLAtomArray atomArray = this.getAtomArray(); map = (atomArray == null) ? null : atomArray.getAtomMap(); } return map; } /** gets bondMap. * if molecule has single BondArray child returns its map * if molecule has submolecules returns null; * @return null if */ public Map getBondMap() { Map map = null; if (this.isMoleculeContainer()) { } else { CMLBondArray bondArray = this.getBondArray(); map = (bondArray == null) ? null : bondArray.getBondMap(); } return map; } /** gets bondIdMap. * if molecule has single BondArray child returns its map * if molecule has submolecules returns null; * @return null if */ public Map getBondIdMap() { Map map = null; if (this.isMoleculeContainer()) { } else { CMLBondArray bondArray = this.getBondArray(); map = (bondArray == null) ? null : bondArray.getBondIdMap(); } return map; } /** * gets atom by id. * * @param id * @return the atom or null */ public CMLAtom getAtomById(String id) { CMLAtom atom = null; if (id != null) { CMLAtomArray atomArray = getAtomArray(); // use atomArray first in case there are child molecules if (atomArray != null) { // crude check for update index if (atomArray.atomMap.size() != atomArray.getAtomElements().size()) { atomArray.indexAtoms(); } atom = atomArray.getAtomById(id); } else if (getMoleculeCount() > 0) { getChildMoleculeAtomMap(); List atomList = childMoleculeAtomMap.get(id); if (atomList != null && atomList.size() == 1) { atom = atomList.get(0); } } } return atom; } /** * gets atom by id. * * @param id * @return the atom or null */ public CMLAtom getAtomByIdXX(String id) { CMLAtom atom = null; if (getMoleculeCount() > 0) { getChildMoleculeAtomMap(); List atomList = childMoleculeAtomMap.get(id); if (atomList != null && atomList.size() == 1) { atom = atomList.get(0); } } else { CMLAtomArray atomArray = getAtomArray(); if (atomArray != null) { atom = atomArray.getAtomById(id); } } return atom; } /** * gets atoms by id. * only works on child molecules (as ids should be unique) * @param id * @return the atomList (may be null, should not be empty) */ public List getAtomsById(String id) { getChildMoleculeAtomMap(); return childMoleculeAtomMap.get(id); } /** get list of child molecules. * * @param mol * @return list (empty if none) */ public static List getChildMoleculeList(CMLMolecule mol) { List moleculeList = new ArrayList(); Elements mols = mol.getChildElements("molecule", CMLConstants.CML_NS); for (int i = 0; i < mols.size(); i++) { moleculeList.add((CMLMolecule) mols.get(i)); } return moleculeList; } private Map> getChildMoleculeAtomMap() { if (childMoleculeAtomMap == null) { childMoleculeAtomMap = new HashMap>(); if (this.isMoleculeContainer()) { CMLElements molList = this.getMoleculeElements(); for (CMLMolecule molecule : molList) { molecule.indexAtomIds(childMoleculeAtomMap); } } else { this.indexAtomIds(childMoleculeAtomMap); } } return childMoleculeAtomMap; } private void indexAtomIds(Map> childMoleculeAtomMap) { List atomList = this.getAtoms(); for (CMLAtom atom : atomList) { String id = atom.getId(); List aList = childMoleculeAtomMap.get(id); if (aList == null) { aList = new ArrayList(); childMoleculeAtomMap.put(id, aList); } aList.add(atom); } } /** * does the CMLMolecule contain atoms that are too close together? * * @return boolean */ public boolean hasCloseContacts() { if (this.getCloseContacts().size() > 0) { return true; } else { return false; } } /** * * @return map where each entry corresponds to 2 atoms involved in a close contact. */ public Map getCloseContacts() { Map contactMap = new HashMap(); for (CMLAtom atom : this.getAtoms()) { for (CMLAtom ligand : atom.getLigandAtoms()) { if (!contactMap.containsKey(ligand)) { double valenceDist = atom.getChemicalElement().getCovalentRadius()+ligand.getChemicalElement().getCovalentRadius(); double dist = atom.getDistanceTo(ligand); if ((valenceDist/2) > dist) { contactMap.put(atom, ligand); } } } } return contactMap; } /** * gets bond by id * * @param id * @return the bond or null */ public CMLBond getBondById(String id) { CMLBondArray bondArray = getBondArray(); return (bondArray == null) ? null : bondArray.getBondById(id); } /** * get bond for atom ids * * @param id1 * @param id2 * @return bond or null */ public CMLBond getBondByAtomIds(String id1, String id2) { CMLAtom atom1 = this.getAtomById(id1); CMLAtom atom2 = this.getAtomById(id2); return this.getBond(atom1, atom2); } /** * gets atoms by id. can be used to resolve attributes such as atomRefs2, * atomRefs, etc. * * @param ids * (if null returns zero length list) * @return list of atoms (zero length if none or if has child molecules) */ public List getAtomListByIds(String[] ids) { List atomList = new ArrayList(); if (!this.isMoleculeContainer()) { if (ids != null) { for (String id : ids) { CMLAtom atom = this.getAtomById(id); if (atom != null) { atomList.add(atom); } } } } return atomList; } /** * gets atom by its label attribute. * * if there are duplicate labels, behaviour is undefined * * @param label * (attribute for atom) should be unique * @return the atom or null if not found */ public CMLAtom getAtomByLabel(String label) { CMLAtom atom1 = null; if (label != null) { for (CMLAtom atom : this.getAtoms()) { for (CMLLabel label1 : atom.getLabelElements()) { if (label.equals(label1.getCMLValue())) { atom1 = atom; break; } } if (atom1 != null) { break; } } } return atom1; } /** * Gets atom count. * * @return int the atom count */ public int getAtomCount() { return getAtoms().size(); } /** * get atoms. * * @return the atoms (none returns emptyList) */ public List getAtoms() { List atomList = new ArrayList(); for (CMLMolecule molecule : this.getDescendantsOrMolecule()) { CMLAtomArray atomArray = molecule.getAtomArray(); if (atomArray != null) { atomList.addAll(atomArray.getAtoms()); } } /* if (isMoleculeContainer()) { atomList = new ArrayList(); for (CMLMolecule mol : this.getMoleculeElements()) { atomList.addAll(mol.getAtoms()); } } else { CMLAtomArray atomArray = this.getAtomArray(); if (atomArray != null) { atomList = atomArray.getAtoms(); } } */ // else return a blank list return atomList; } /** * get bond connecting 2 atoms. * * @param a1 * first atom * @param a2 * second atom * @return bond or null if not found */ public CMLBond getBond(CMLAtom a1, CMLAtom a2) { String atomHash = CMLBond.atomHash(a1, a2); if (atomHash != null) { for (CMLBond bond : getBonds()) { String bondHash = CMLBond.atomHash(bond); if (bondHash.equals(atomHash)) { return bond; } } } return null; } /** * gets bondArray child. * * @return null if does not exist */ public CMLBondArray getBondArray() { return (CMLBondArray) this.getFirstCMLChild(CMLBondArray.TAG); } /** * Gets the number of bonds in this molecule * * @return int the Bond count */ public int getBondCount() { List bonds = getBonds(); return bonds.size(); } /** * gets a typed list containing all the bonds in this molecule * * @return a typed list */ public List getBonds() { List bondList = new ArrayList(); for (CMLMolecule molecule : this.getDescendantsOrMolecule()) { CMLBondArray bondArray = molecule.getBondArray(); if (bondArray != null) { bondList.addAll(bondArray.getBonds()); } } return bondList; } /** * Calculate formalCharge from atomCharges. * * @param control * @return calculated formal charge * @throws RuntimeException * if control=NO_DEFAULT and som atoms have no formalCharge */ public int getCalculatedFormalCharge(FormalChargeControl control) throws RuntimeException { int charge = 0; for (CMLAtom atom : getAtoms()) { charge += atom.getFormalCharge(control); } return charge; } /** * calculate 2D centroid. * * @return centroid of 2D coords or null */ public Real2 calculateCentroid2D() { Real2Vector p2Vector = getCoordinates2D(); return p2Vector.getCentroid(); } /** * identify double bonds. * * @return the bonds (zero length if none) */ public List getDoubleBonds() { setNormalizedBondOrders(); List dbVector = new ArrayList(); for (CMLBond bond : getBonds()) { String order = bond.getOrder(); if (CMLBond.isDouble(order)) { dbVector.add(bond); } } return dbVector; } // /** // * gets nearest ancestor molecule element. // * // * @param element // * descendant of molecule // * @return the owner molecule or null if not found // */ // public static CMLMolecule getMolecule(CMLElement element) { // CMLMolecule molecule = null; // Node node = element; // while (true) { // ParentNode parent = node.getParent(); // if (parent == null) { // break; // } else if (parent instanceof CMLMolecule) { // molecule = (CMLMolecule) parent; // } // node = parent; // } // return molecule; // } /** * get count of daughter molecules. further descendants are not counted. * * @return the count ; 0 if no molecule children */ public int getMoleculeCount() { return getMoleculeElements().size(); } // /** get variable in repeat attribute. // * // * @return the name of the variable or null // */ // public String getRepeatName() { // return this.getRepeatStrings()[0]; // } // /** get the starting index. // * // * @return the start // */ // public int getRepeatStart() { // int start = -1; // String startS = this.getRepeatStrings()[1]; // try { // start = Integer.parseInt(startS); // } catch (NumberFormatException e) { // throw new RuntimeException("Bad start value: "+startS); // } // return start; // } // /** get end of repeat (inclusive). // * // * @return the index // */ // public int getRepeatEnd() { // int end = -1; // String endS = this.getRepeatStrings()[2]; // try { // end = Integer.parseInt(endS); // } catch (NumberFormatException e) { // throw new RuntimeException("Bad end value: "+endS); // } // return end; // } // String[] getRepeatStrings() { // String repeat = this.getRepeat(); // if (repeat == null) { // throw new RuntimeException("null repeat attribute"); // } // String[] strings = repeat.trim().split("\\s+"); // if (strings.length != 3) { // throw new RuntimeException("repeat must have 3 components"); // } // return strings; // } /** get molecule or its descendants. i.e. the actual molecules rather than * the container * * @return list of molecules */ public List getDescendantsOrMolecule() { List moleculeList = new ArrayList(); CMLElements moleculeElements = this.getMoleculeElements(); if (moleculeElements.size() == 0) { moleculeList.add(this); } else { for (CMLMolecule molecule : moleculeElements) { moleculeList.add(molecule); } } return moleculeList; } /** gets the childAtomArray. * if not present adds and empty atomArray child to this * use carefully * @return the atomArray */ public CMLAtomArray getOrCreateAtomArray() { CMLAtomArray atomArray = this.getAtomArray(); if (atomArray == null) { atomArray = new CMLAtomArray(); this.addAtomArray(atomArray); } return atomArray; } /** gets the childBondArray. * if not present adds and empty bondArray child to this * use carefully * @return the bondArray */ public CMLBondArray getOrCreateBondArray() { CMLBondArray bondArray = this.getBondArray(); if (bondArray == null) { bondArray = new CMLBondArray(); this.addBondArray(bondArray); } return bondArray; } /** * gets vector of 2D coordinates. * * all atoms must have coordinates * * @return the vector (empty if missing 2D coordinates) */ public Real2Vector getCoordinates2D() { Real2Vector p2Vector = new Real2Vector(); boolean ok = true; for (CMLAtom atom : getAtoms()) { Real2 p = atom.getXY2(); if (p != null) { p2Vector.add(p); } } if (!ok) { p2Vector = new Real2Vector(); } return p2Vector; } /** * Convenience method for determing if molecule has coordinates of a given * type. if hasSubMolecules returns true if any submolecules fit * * @param type of coordinates * @param omitHydrogen akip hydrogens without coordinates * @return has coords */ public boolean hasCoordinates(CoordinateType type, boolean omitHydrogen) { boolean has = true; for (CMLAtom atom : getAtoms()) { if (omitHydrogen && "H".equals(atom.getElementType())) { continue; } has = atom.hasCoordinates(type); if (!has) break; } return has; } /** * Convenience method for determing if molecule has coordinates of a given * type. if hasSubMolecules returns true if any submolecules fit * * @param type of coordinates * @return has coords */ public boolean hasCoordinates(CoordinateType type) { boolean has = true; for (CMLAtom atom : getAtoms()) { has = atom.hasCoordinates(type); if (!has) break; } return has; } void init() { // logger.log(Level.INFO, ">>>>>>>>>>>NEW MOLECULE"); } /** * determines if this molecule contains child molecules * * @return true is this molecule is a container, false otherwise */ public boolean isMoleculeContainer() { return (this.getMoleculeElements().size() > 0); } // ====================== functionality ===================== /** * scale the coordinates. * * this should normally only be done for display purposes so only COORD2 is * supported * * @param scale * the scalefactor */ public void multiply2DCoordsBy(double scale) { for (CMLAtom atom : getAtoms()) { Real2 xy = atom.getXY2(); if (xy == null) { continue; } xy.x *= scale; xy.y *= scale; atom.setXY2(xy); } } /** * rename AtomIDs in molecule and update atomRefs. * * AtomIDs in atoms, and atomRefs are consistently changed. * * @param oldIds * vector of original IDs * @param newIds * vector of new IDs * * @throws RuntimeException * IDs do not correspond, or have duplicates */ public void renameAtomIDs(List oldIds, List newIds) { Map mapTable = new HashMap(); Map newTable = new HashMap(); List atoms = this.getAtoms(); if (oldIds.size() != atoms.size() || newIds.size() != atoms.size()) { throw new RuntimeException("Lists (" + oldIds.size() + CMLConstants.S_SLASH + newIds.size() + ") must be same length as atomCount (" + atoms.size() + CMLConstants.S_RBRAK); } for (int i = 0; i < atoms.size(); i++) { String oldId = oldIds.get(i); if (this.getAtomById(oldId) == null) { throw new RuntimeException("Unknown atom id: " + oldId); } String newId = newIds.get(i); if (newTable.containsKey(newId)) { throw new RuntimeException("Duplicate new id: " + newId); } else { newTable.put(newId, CMLConstants.S_EMPTY); } mapTable.put(oldId, newId); } for (CMLAtom atom : atoms) { String oldId = atom.getId(); atom.resetId(mapTable.get(oldId)); } indexAtoms(); for (CMLBond bond : getBonds()) { String[] atomRefs2 = bond.getAtomRefs2(); String ar0 = mapTable.get(atomRefs2[0]); String ar1 = mapTable.get(atomRefs2[1]); bond.setAtomRefs2(ar0, ar1); bond.setId(bond.createId()); } indexBonds(); } /** * Round the atomCoords to within a multiple of epsilon currently always * rounds down (e.g. 3.9996 with epsilon = 0.001 => 3.999, not 4) * * @param epsilon * @param coordinateType */ public void roundCoords(double epsilon, CoordinateType coordinateType) { CMLElements molecules = this.getMoleculeElements(); if (molecules.size() > 0) { for (CMLMolecule molecule : molecules) { molecule.roundCoords(epsilon, coordinateType); } } else { for (CMLAtom atom : getAtoms()) { atom.roundCoords(epsilon, coordinateType); } } } /** * Sets all bond orders to given value. * * @param order * must not be null */ public void setBondOrders(String order) { if (order != null) { for (CMLBond bond : getBonds()) { bond.setOrder(order); } } } /** * Sets all existing bond orders to normaliaed values. * In practice this only happens when the XML version is parsed. * getOrder and setOrder normalize by default. So this routine * should only be required immediately after parsing * values (S->1, D->2, T->3) * *IMPORTANT NOTE; we have changed this 2009 to be the reverse. * 1->S, 2->D 3->T */ public void setNormalizedBondOrders() { List bonds = this.getBonds(); for (CMLBond bond : bonds) { try { String order = bond.getOrder(); if (order != null) { // synonyms if (CMLBond.isSingle(order)) { order = CMLBond.SINGLE_S; } else if (CMLBond.isDouble(order)) { order = CMLBond.DOUBLE_D; } else if (CMLBond.isTriple(order)) { order = CMLBond.TRIPLE_T; } bond.setOrder(order); } } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("BUG " + e); } } } /** * translate molecule in 2D. * * @param delta2 * add to all 2D coordinates */ public void translate2D(Real2 delta2) { for (CMLAtom atom : getAtoms()) { if (atom.hasCoordinates(CoordinateType.TWOD)) { atom.setX2(atom.getX2() + delta2.x); atom.setY2(atom.getY2() + delta2.y); } } } /** * unlabel all atoms in molecule. * * this cannot be reversed. It is mainly for adding labelled fragments to * build up a molecule * */ public void unlabelAllAtoms() { for (CMLAtom atom : getAtoms()) { for (CMLLabel label : atom.getLabelElements()) { label.detach(); } } } public void normalizeFormulas() { CMLFormula formula = new CMLFormula(this); String concise = formula.getConcise(); Nodes formulaElements = this.query("./cml:formula", CML_XPATH); for (int i = 0; i < formulaElements.size(); i++) { CMLFormula formulaElement = (CMLFormula) formulaElements.get(i); String conciseString = formulaElement.getConcise(); if (conciseString == null) { formulaElement.setConcise(concise); } else if (conciseString.equals(concise)) { // no need to update } else { throw new RuntimeException("incompatible concise formulae; was "+ conciseString+"; now "+concise); } // remove any spurious atomArrays Nodes atomArrays = formulaElement.query("./cml:atomArray", CML_XPATH); for (int j = 0; j < atomArrays.size(); j++) { atomArrays.get(j).detach(); } } } public CMLFormula getFirstConciseFormula() { Nodes nodes = this.query("./*[local-name()='"+CMLFormula.TAG+"' and @concise]"); return (nodes.size() > 0) ? (CMLFormula) nodes.get(0) : null; } public String getFirstConciseFormulaString() { CMLFormula formula = this.getFirstConciseFormula(); return (formula == null) ? null : formula.getConcise(); } public void addName(String nameString) { CMLName name = new CMLName(); name.setXMLContent(nameString); this.addName(name); } /** * Calculates the hydrogen count of a molecule. Includes hydrogenCount * attribute and does not double count bridging hydrogens. */ public int calculateHydrogenCount() { /* beware bridging hydrogens - simply returning the sum of the atom * hydrogen counts may not work! */ int totalImplicitHydrogenCount = 0; Set uniqueHydrogens = new HashSet(); for (CMLAtom atom : getAtoms()) { int hydrogenCount = atom.getHydrogenCount(); List explicitHydrogens = atom.getLigandHydrogenAtoms(); int implicitHydrogenCount = hydrogenCount - explicitHydrogens.size(); if (implicitHydrogenCount > 0) { totalImplicitHydrogenCount += implicitHydrogenCount; } uniqueHydrogens.addAll(explicitHydrogens); } return totalImplicitHydrogenCount + uniqueHydrogens.size(); } /** makes a new list composed of the molecules in the list * * @param elements * @return */ public static List extractMolecules(List elements) { List moleculeList = new ArrayList(); for (Element element : elements) { if (element instanceof CMLMolecule) { moleculeList.add((CMLMolecule) element); } } return moleculeList; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLMoleculeList.java000077500000000000000000000043641477224461000267770ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** A container for one or more molecules. * * * moleculeList can contain several molecules. * These may be related in many ways and there is/are controlled * semantics. However it should not be used for a molecule * consisting of descendant molecules for which molecule * should be used. * A moleculeList can contain nested moleculeLists. * * user-modifiable class autogenerated from schema if no class exists * use as a shell which can be edited * the autogeneration software will not overwrite an existing class file */ public class CMLMoleculeList extends AbstractMoleculeList { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** argument name to identify id. */ public final static String IDX = "idx"; /** constructor. * */ public CMLMoleculeList() { } /** must give simple documentation. * * @param old CMLMoleculeList to copy */ public CMLMoleculeList(CMLMoleculeList old) { super((org.xmlcml.cml.element.AbstractMoleculeList) old); } /** copy node . * * @return Node */ public Element copy() { return new CMLMoleculeList(this); } /** create new instance in context of parent, overridable by subclasses. * * @param parent parent of element to be constructed (ignored by default) * @return CMLMoleculeList */ public CMLElement makeElementInContext(Element parent) { return new CMLMoleculeList(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLName.java000077500000000000000000000032651477224461000252550ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting name. * autogenerated from schema use as a * shell which can be edited * */ public class CMLName extends AbstractName { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLName() { super(); } /** * constructor. * * @param old */ public CMLName(CMLName old) { super((AbstractName) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLName(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLName */ public CMLElement makeElementInContext(Element parent) { return new CMLName(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLObject.java000077500000000000000000000031511477224461000255750ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting object. * autogenerated from schema use as a * shell which can be edited * */ public class CMLObject extends AbstractObject { /** * constructor. */ public CMLObject() { } /** * constructor. * * @param old */ public CMLObject(CMLObject old) { super((AbstractObject) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLObject(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLObject */ public CMLElement makeElementInContext(Element parent) { return new CMLObject(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLObservation.java000077500000000000000000000032331477224461000266630ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting observation. * autogenerated from schema use * as a shell which can be edited * */ public class CMLObservation extends AbstractObservation { /** * constructor. */ public CMLObservation() { } /** * constructor. * * @param old */ public CMLObservation(CMLObservation old) { super((AbstractObservation) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLObservation(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLObservation */ public CMLElement makeElementInContext(Element parent) { return new CMLObservation(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLOperator.java000077500000000000000000000031751477224461000261700ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting operator. * autogenerated from schema use as * a shell which can be edited * */ public class CMLOperator extends AbstractOperator { /** * constructor. */ public CMLOperator() { } /** * constructor. * * @param old */ public CMLOperator(CMLOperator old) { super((AbstractOperator) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLOperator(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLOperator */ public CMLElement makeElementInContext(Element parent) { return new CMLOperator(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLParameter.java000077500000000000000000000135241477224461000263140ustar00rootroot00000000000000/** * 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 java.util.List; import nu.xom.Element; import nu.xom.Nodes; import org.xmlcml.cml.attribute.DictRefAttribute; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.interfacex.HasDataType; import org.xmlcml.cml.interfacex.HasDictRef; /** * user-modifiable class supporting parameter. * autogenerated from schema use * as a shell which can be edited * */ public class CMLParameter extends AbstractParameter implements HasDictRef { /** namespaced element name.*/ public final static String NS = C_E+TAG; private HasDataType child; /** * constructor. */ public CMLParameter() { } /** * constructor. * * @param old */ public CMLParameter(CMLParameter old) { super((AbstractParameter) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLParameter(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLParameter */ public CMLElement makeElementInContext(Element parent) { return new CMLParameter(); } /** null * @return String */ public String getDictRef() { DictRefAttribute att = (DictRefAttribute) this.getDictRefAttribute(); if (att == null) { return null; } return att.getString(); } /** gets descendant parameter elements. * may either thave the dictRef on the parameter element or on * its child. * properties are normalized * @param parent * @param dictRef * @return parameterList containing references (normally 1 or 0 entries) */ public static CMLParameterList getParameterList(CMLElement parent, String dictRef) { CMLParameterList parameterList = new CMLParameterList(); Nodes nodes = parent.query("./cml:parameter", CMLConstants.CML_XPATH); for (int i = 0; i < nodes.size(); i++ ) { CMLParameter parameter = (CMLParameter) nodes.get(i); parameter.canonicalize(); if (dictRef.equals(parameter.getAttributeValue("dictRef"))) { parameterList.addParameter(parameter); } } return parameterList; } /** gets single parameter. * if zero or many properties with gievn dictRef returns null * @param parent * @param dictRef * @return parameter or null */ public static CMLParameter getParameter(CMLElement parent, String dictRef) { CMLParameterList parameterList = CMLParameter.getParameterList(parent, dictRef); CMLElements properties = parameterList.getParameterElements(); CMLParameter parameter = null; if (properties.size() == 1) { parameter = properties.get(0); } return parameter; } // ------------------------ analogous to CMLProperty ------------------- /** makes sure property has the structure: * {@code ...} * if zero or many children (scalar, array, matrix) no-op * */ public void canonicalize() { CMLProperty.staticCanonicalize(this); } /** * @return units on child */ public String getUnits() { return CMLProperty.getStaticUnits(this); } /** * gets real value of scalar child * * @return the value (NaN if not set) */ public double getDouble() { return CMLProperty.getStaticDouble(this); } /** * gets String value. dataType must be XSD_STRING. * * @return the value (null if not set) */ public String getString() { return CMLProperty.getStaticString(this); } /** * gets int value. dataType must be XSD_INTEGER. * * @return the value * @throws RuntimeException * if different type */ public int getInt() { return CMLProperty.getStaticInt(this); } /** get array elements. * recalculates each time so best cached for frequent use * @return elements as String */ public List getStringValues() { return CMLProperty.getStaticStringValues(this); } /** * gets values of element; * * @return integer values */ public int[] getInts() { return CMLProperty.getStaticInts(this); } /** * gets values of element; * * @return double values */ public double[] getDoubles() { return CMLProperty.getStaticDoubles(this); } /** * requires exactly one child of type scalar array matrix * @return the child */ public HasDataType getChild() { if (child == null) { child = CMLProperty.getStaticChild(this); } return child; } /** * @param child the child to set */ public void setChild(HasDataType child) { this.child = child; } /** gets dataType * @return dataType as string */ public String getDataType() { return CMLProperty.getStaticDataType(this); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLParameterList.java000077500000000000000000000123701477224461000271460ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import nu.xom.Elements; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; /** * user-modifiable class supporting parameterList. * autogenerated from schema * use as a shell which can be edited * */ public class CMLParameterList extends AbstractParameterList { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLParameterList() { } /** * constructor. * * @param old */ public CMLParameterList(CMLParameterList old) { super((AbstractParameterList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLParameterList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLParameterList */ public CMLElement makeElementInContext(Element parent) { return new CMLParameterList(); } /** * gets all nested parameter descendants of arbitrary CMLElement. * * recurses through all parameterList and parameter children, adding the * latter to the list. Order is not preserved. * * @return list of all descendants */ public List getParameterDescendants() { List mList = new ArrayList(); CMLElements parameterLists = this .getParameterListElements(); for (CMLParameterList ml : parameterLists) { mList.addAll(ml.getParameterDescendants()); } CMLElements parameters = this.getParameterElements(); for (CMLParameter m : parameters) { mList.add(m); } return mList; } /** * gets all nested parameter descendants of arbitrary CMLElement. * * recurses through all parameterList and parameter children, adding the * latter to the list. Order is not preserved. * * @param parent with parameter(List) children * @return list of all descendants */ public static List getParameterDescendants(CMLElement parent) { List mList = new ArrayList(); Elements parameterLists = parent .getChildCMLElements(CMLParameterList.TAG); for (int i = 0; i < parameterLists.size(); i++) { CMLParameterList parameterList = (CMLParameterList) parameterLists .get(i); mList.addAll(parameterList.getParameterDescendants()); } // generally parameter should be under parameterList parent Elements parameters = parent.getChildCMLElements(CMLParameter.TAG); for (int i = 0; i < parameters.size(); i++) { mList.add((CMLParameter) parameters.get(i)); } return mList; } /** * gets parameter elements with a given dictRef. if either param is null, * returns empty list * * @param parameterList list to filter * @param dictRef value of dictRef attribute * @return filtered list */ public static List getParameterDescendantsByDictRef( List parameterList, String dictRef) { List newParameterList = new ArrayList(); if (dictRef != null && parameterList != null) { for (CMLParameter parameter : parameterList) { if (dictRef.equals(parameter.getDictRef())) { newParameterList.add(parameter); } } } return newParameterList; } /** * gets parameter elements with a given name attribute. * * @param name (if null returns null) * @return filtered list or null */ public List getParameterDescendantsByName(String name) { List parameterList = this.getParameterDescendants(); List newParameterList = new ArrayList(); if (name != null && parameterList != null) { for (CMLParameter parameter : parameterList) { if (name.equals(parameter.getName())) { newParameterList.add(parameter); } } } return newParameterList; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLParticle.java000077500000000000000000000033131477224461000261320ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting particle. * autogenerated from schema use as * a shell which can be edited * */ public class CMLParticle extends AbstractParticle { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLParticle() { } /** * constructor. * * @param old */ public CMLParticle(CMLParticle old) { super((AbstractParticle) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLParticle(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLParticle */ public CMLElement makeElementInContext(Element parent) { return new CMLParticle(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLPeak.java000077500000000000000000000036511477224461000252540ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.interfacex.PeakOrGroup; /** * user-modifiable class supporting peak. * autogenerated from schema use as a * shell which can be edited * */ public class CMLPeak extends AbstractPeak implements PeakOrGroup { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLPeak() { } /** * constructor. * * @param old */ public CMLPeak(CMLPeak old) { super((AbstractPeak) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLPeak(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLPeak */ public CMLElement makeElementInContext(Element parent) { return new CMLPeak(); } // OBSOLETE? // /** ensure integrity between list and children. // * @return CMLPeakList.class // */ // public Class getIndexableListClass() { // return CMLPeakList.class; // } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLPeakGroup.java000077500000000000000000000034351477224461000262710ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.interfacex.PeakOrGroup; /** * user-modifiable class supporting peakGroup. * autogenerated from schema use * as a shell which can be edited * */ public class CMLPeakGroup extends AbstractPeakGroup implements PeakOrGroup { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLPeakGroup() { } /** * constructor. * * @param old */ public CMLPeakGroup(CMLPeakGroup old) { super((AbstractPeakGroup) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLPeakGroup(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLPeakGroup */ public CMLElement makeElementInContext(Element parent) { return new CMLPeakGroup(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLPeakList.java000077500000000000000000000071151477224461000261070ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import nu.xom.Nodes; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.interfacex.PeakOrGroup; /** * user-modifiable class supporting peakList. * NO INTERNAL index of peaks (uses XPATH) */ public class CMLPeakList extends AbstractPeakList { /** type of comparsion */ public enum Type { /** dewisott */ XVALUE, /** dewisott */ YVALUE; } /** namespaced element name.*/ public final static String NS = C_E+TAG; /** argument name to identify id. */ public final static String IDX = "idx"; /** * constructor. */ public CMLPeakList() { } /** * constructor. * * @param old */ public CMLPeakList(CMLPeakList old) { super((AbstractPeakList) old); } /** * COPY constructor from list of peaks * @param peakList */ public CMLPeakList(List peakList) { for (CMLPeak peak : peakList) { this.addPeak(peak); } } /** * copy node . * * @return Node */ public Element copy() { return new CMLPeakList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLPeakList */ public CMLElement makeElementInContext(Element parent) { return new CMLPeakList(); } /** * update Index * @param parent element */ public void finishMakingElement(Element parent) { } /** * @return list of peak children (not peakGroups or descendants) */ public List getPeakChildren() { Nodes nodes = this.query("./cml:peak", CMLConstants.CML_XPATH); List peaks = new ArrayList(); for (int i = 0; i < nodes.size(); i++) { peaks.add((CMLPeak) nodes.get(i)); } return peaks; } /** * @return list of peak descendants (not peakGroups) */ public List getPeakDescendants() { Nodes nodes = this.query(".//cml:peak", CMLConstants.CML_XPATH); List peaks = new ArrayList(); for (int i = 0; i < nodes.size(); i++) { peaks.add((CMLPeak) nodes.get(i)); } return peaks; } /** * @return list of peak or peakGroup children (not descendants) */ public List getPeakOrGroupChildren() { Nodes nodes = this.query("./cml:peak | ./cml:peakGroup", CMLConstants.CML_XPATH); List peaks = new ArrayList(); for (int i = 0; i < nodes.size(); i++) { peaks.add((PeakOrGroup) nodes.get(i)); } return peaks; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLPeakStructure.java000077500000000000000000000074451477224461000272020ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import nu.xom.Node; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; /** * The structure of a peak. * * * \n A peakStructure can describe:\n \nfine structure such as coupling or * splitting constants\n components such as shoulders or inflexions\n \na peak * can have more than one peakStructure which can be used to\n describe more * than one coupling. A doublet of doublets might have two \npeakStructures with * the larger one first, but there are no controlled \nsemantics.\n * * user-modifiable class autogenerated from schema if no class exists use as a * shell which can be edited the autogeneration software will not overwrite an * existing class file * */ public class CMLPeakStructure extends AbstractPeakStructure { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * must give simple documentation. * */ public CMLPeakStructure() { } /** * copy constructor. * * @param old */ public CMLPeakStructure(CMLPeakStructure old) { super((AbstractPeakStructure) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLPeakStructure(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLPeakStructure */ public CMLElement makeElementInContext(Element parent) { return new CMLPeakStructure(); } /** * gets atoms referenced as targets of coupling. requires type="coupling" * * @param molecule * owning atoms; if null returns zero length List * @return list of atoms (zero length if none found) */ public List getCouplingsFrom(CMLMolecule molecule) { List atoms = new ArrayList(); if ("coupling".equals(this.getType()) && molecule != null) { atoms = molecule.getAtomListByIds(this.getAtomRefs()); } return atoms; } /** * validates nested peakStructure. must have a parent peak with an atomRefs * attribute of the same size as the number of children of this. * * @return true if has children of same size as parent atomRefs */ public boolean hasValidNestedPeakStructure() { boolean has = false; CMLElements ps = this.getPeakStructureElements(); if (ps.size() > 0) { if (this.getPeakStructureElements().size() > 0) { Node parent = this.getParent(); if (parent != null && parent instanceof CMLPeak) { String[] atomRefs = ((CMLPeak) parent).getAtomRefs(); if (atomRefs != null) { has = ps.size() == atomRefs.length; } } } } return has; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLPlane3.java000077500000000000000000000257651477224461000255300ustar00rootroot00000000000000/** * 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.Element; import org.apache.log4j.Logger; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.Line3; import org.xmlcml.euclid.Plane3; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Util; import org.xmlcml.euclid.Vector3; /** * user-modifiable class supporting plane3. * autogenerated from schema use as a * shell which can be edited * */ public class CMLPlane3 extends AbstractPlane3 { /** namespaced element name.*/ public final static String NS = C_E+TAG; private final static Logger LOG = Logger.getLogger(CMLPlane3.class.getName()); /** * default. do not use. * public because of newInstance() */ public CMLPlane3() { } /** * constructor. * * @param old */ public CMLPlane3(CMLPlane3 old) { super((AbstractPlane3) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLPlane3(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLPlane3 */ public CMLElement makeElementInContext(Element parent) { return new CMLPlane3(); } /** * check plane is OK. must have 3 double components * * @param parent * element * @throws RuntimeException * parsing error */ public void finishMakingElement(Element parent) throws RuntimeException { double[] array = this.getXMLContent(); if (array == null) { LOG.warn("plane must not be empty"); } else if (array.length != 4) { LOG.warn("plane must have 4 double components"); } } // =========================== additional constructors // ======================== /** * formed from components. * * @param array * 4-component */ public CMLPlane3(double[] array) { this.setArray(array); } /** * formed from euclid plane. * * @param plane */ public CMLPlane3(Plane3 plane) { this(); setArrayNoCheck(plane.getArray()); } /** * formed from separate components. * * @param lmn * component * @param d * distance * @throws RuntimeException */ public CMLPlane3(double[] lmn, double d) { this(); try { Util.check(lmn, 3); Plane3 pp = new Plane3(lmn, d); this.setArrayNoCheck(pp.getArray()); } catch (EuclidRuntimeException e) { throw new RuntimeException("" + e); } } /** * formed from vector and distance. takes doc from vector * * @param v * vector * @param d * distance * @throws RuntimeException */ public CMLPlane3(CMLVector3 v, double d) throws RuntimeException { Plane3 pp; try { pp = new Plane3(v.getEuclidVector3(), d); this.setArrayNoCheck(pp.getArray()); } catch (Exception e) { throw new RuntimeException("" + e); } } /** * make a plane from three points. takes doc from points * * @param p1 * point * @param p2 * point * @param p3 * point */ public CMLPlane3(CMLPoint3 p1, CMLPoint3 p2, CMLPoint3 p3) { Plane3 pp= new Plane3(p1.getEuclidPoint3(), p2.getEuclidPoint3(), p3 .getEuclidPoint3()); this.setArrayNoCheck(pp.getArray()); } /** * make a plane from a line and a point not on the line. takes doc from line * * @param l * point * @param p * point */ public CMLPlane3(CMLLine3 l, CMLPoint3 p) { Plane3 pp = new Plane3(l.getEuclidLine3(), p.getEuclidPoint3()); this.setArrayNoCheck(pp.getArray()); } // ====================== housekeeping methods ===================== // assumes plane3 != null /** * get euclid primitive. * * @return plane * @exception RuntimeException */ public Plane3 getEuclidPlane3() throws RuntimeException { Plane3 pleucl3 = null; try { pleucl3 = new Plane3(this.getXMLContent()); } catch (EuclidRuntimeException e) { throw new RuntimeException("" + e); } return pleucl3; } // ====================== subsidiary accessors ===================== /** * sets components. * * @param array * 4 components */ public void setArray(double[] array) { Util.check(array, 4); setArrayNoCheck(array); } private void setArrayNoCheck(double[] array) throws RuntimeException { Vector3 v = new Vector3(array[0], array[1], array[2]); if (v.isZero()) { throw new RuntimeException("Cannot make plane with zero vector"); } v.normalize(); double[] vv = v.getArray(); double[] aa = new double[4]; aa[0] = vv[0]; aa[1] = vv[1]; aa[2] = vv[2]; aa[3] = array[3]; this.setXMLContent(aa); } /** * gets components. * * @return 4-component array */ public double[] getArray() { Plane3 pleucl3 = this.getEuclidPlane3(); return pleucl3.getArray(); } /** * get vector. * * @return the vector */ public CMLVector3 getVector() { Plane3 pleucl3 = this.getEuclidPlane3(); return CMLVector3.createCMLVector3(pleucl3.getVector()); } /** * get distance from origin. * * @return the distance */ public double getDistance() { Plane3 pleucl3 = this.getEuclidPlane3(); return pleucl3.getArray()[3]; } // ====================== functionality ===================== /** * reverse direction of plane. */ public void negative() { Plane3 pleucl3 = this.getEuclidPlane3(); pleucl3.negative(); this.setXMLContent(pleucl3.getArray()); } /** * are two planes coincident and parallel. * * @param pl2 * plane to compare * @return true if equal within Real.isEqual() */ public boolean isEqualTo(CMLPlane3 pl2) { Plane3 pleucl3 = this.getEuclidPlane3(); return pleucl3.isEqualTo(pl2.getEuclidPlane3()); } /** * form coincident antiparallel plane. * * @return antiparallel plane */ public CMLPlane3 subtract() { Plane3 pleucl3 = this.getEuclidPlane3(); return new CMLPlane3(pleucl3.subtract()); } /** * distance of point from plane. will be a signed quantity * * @param p * the point * @return the distance */ public double getDistanceFromPoint(CMLPoint3 p) { Plane3 pleucl3 = this.getEuclidPlane3(); return pleucl3.getDistanceFromPoint(p.getEuclidPoint3()); } /** * are two planes parallel. not antiparallel * * @param pl2 * the plane * @return true if parallel within Real.isEqual() */ public boolean isParallelTo(CMLPlane3 pl2) { Plane3 pleucl3 = this.getEuclidPlane3(); return pleucl3.isParallelTo(pl2.getEuclidPlane3()); } /** * are two planes antiparallel. not parallel * * @param pl2 * the plane * @return true if antiparallel within Real.isEqual() */ public boolean isAntiparallelTo(CMLPlane3 pl2) { Plane3 pleucl3 = this.getEuclidPlane3(); return pleucl3.isAntiparallelTo(pl2.getEuclidPlane3()); } /** * is a point on the plane. * * @param p * the point * @return true if within Real.isEqual() */ public boolean containsPoint(CMLPoint3 p) { double d = this.getDistanceFromPoint(p); return (Math.abs(d) < EPS); } /** * point on plane closest to another point. if p2 is on plane then result * will coincide * * @param p2 * other point * @return the closest point */ public CMLPoint3 getClosestPointTo(CMLPoint3 p2) { Plane3 pleucl3 = this.getEuclidPlane3(); Point3 p = pleucl3.getClosestPointTo(p2.getEuclidPoint3()); return new CMLPoint3(p); } /** * point of intersection of plane and line. * * @param l * line * @return intersection point */ public CMLPoint3 getIntersectionWith(CMLLine3 l) { Plane3 pleucl3 = this.getEuclidPlane3(); Point3 p = pleucl3.getIntersectionWith(l.getEuclidLine3()); return (p == null) ? null : new CMLPoint3(p); } /** * get line as intersection of two planes. * * @param pl2 * plane * @return intersection line */ public CMLLine3 getIntersectionWith(CMLPlane3 pl2) { Plane3 pleucl3 = this.getEuclidPlane3(); Line3 l = pleucl3.getIntersectionWith(pl2.getEuclidPlane3()); return (l == null) ? null : new CMLLine3(l); } /** * point where three planes intersect * * @param pl2 * plane * @param pl3 * plane * @return intersection point */ public CMLPoint3 getIntersectionWith(CMLPlane3 pl2, CMLPlane3 pl3) { Plane3 pleucl3 = this.getEuclidPlane3(); Point3 p = pleucl3.getIntersectionWith(pl2.getEuclidPlane3(), pl3 .getEuclidPlane3()); return (p == null) ? null : new CMLPoint3(p); } /** * the angle between 2 planes. * * @param pl2 * plane * @return the angle (unsigned radians) */ public double getAngleMadeWith(CMLPlane3 pl2) { Plane3 pleucl3 = this.getEuclidPlane3(); return pleucl3.getAngleMadeWith(pl2.getEuclidPlane3()).getRadian(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLPoint3.java000077500000000000000000000422161477224461000255500ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.euclid.Angle; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Util; import org.xmlcml.euclid.Vector3; /** * user-modifiable class supporting point3. * autogenerated from schema use as a * shell which can be edited NOTE: points must contain values (empty points not * allowed) * */ public class CMLPoint3 extends AbstractPoint3 { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** empty point. * required so as to create newInstance */ public CMLPoint3() { } /** * constructor. * * @param old */ public CMLPoint3(CMLPoint3 old) { super((AbstractPoint3) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLPoint3(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLPoint3 */ public CMLElement makeElementInContext(Element parent) { return new CMLPoint3(); } /** * check point is OK. must have 3 double components * * @param parent * element * @throws RuntimeException * parsing error */ public void finishMakingElement(Element parent) throws RuntimeException { double[] array = this.getXMLContent(); if (array == null) { throw new RuntimeException("point must not be empty"); } else if (array.length != 3) { throw new RuntimeException("point must have 3 double components"); } } // =========================== additional constructors // ======================== /** * formed from components. * * @param array * 3-component * @throws RuntimeException * length not 3 */ public CMLPoint3(double[] array) { this.setXYZ3(array); } /** * formed from Euclid point. * * @param p */ public CMLPoint3(Point3 p) { this(p.getArray()); } /** * create from doubles. * * @param x * @param y * @param z */ public CMLPoint3(double x, double y, double z) { this(); this.setXMLContent(new double[] { x, y, z }); } // ====================== housekeeping methods ===================== /** * gets Point3. cannot be null (will throw CMLRutnime) * * @return the point - cannot be null * @exception RuntimeException * does not have 3 valid coordinates */ public Point3 getEuclidPoint3() throws RuntimeException { return new Point3(this.getXMLContent()); } // ====================== subdiary accessors ===================== /** * sets components. * * @param xyz3 * 3 components * @throws RuntimeException * xyz3 must be of length 3 */ public void setXYZ3(double[] xyz3) { if (xyz3.length != 3) { throw new RuntimeException("xyz3 must be of length 3"); } this.setXMLContent(xyz3); } /** * gets components. * * @return 3-component array */ public double[] getXYZ3() { return this.getXMLContent(); } // ====================== functionality ===================== /** * are two points identical. compares content of points with Real.isEqual() * * @param p * point to compare * @return equal if coordinates are equal within Real.epsilon */ public boolean isEqualTo(CMLPoint3 p) { Point3 peucl3 = getEuclidPoint3(); return (peucl3 == null) ? null : peucl3.isEqualTo(p.getEuclidPoint3()); } /** * are two points identical. compares content of points with Real.isEqual() * * @param p * point to compare * @param eps * tolerance for comparison on each coordinate * @return equal if coordinates are equal within Real.epsilon */ public boolean isEqualTo(CMLPoint3 p, double eps) { double[] xyz = this.getXYZ3(); double[] xyzP = p.getXYZ3(); return Util.isEqual(xyz, xyzP, eps); } /** * are two crystallographic points identical. shifts x, y, z by +-1.0 if * necessary compares content of crystallographically normalised points with * Real.isEqual() * * @param p * point to compare * @return equal if coordinates are equal within CRYSTALFRACTEPSILON */ public boolean equalsCrystallographically(CMLPoint3 p) { Point3 peucl3 = getEuclidPoint3(); return (peucl3 == null) ? false : peucl3.equalsCrystallographically(p .getEuclidPoint3()); } /** * is point invariant wrt symmetry operation. * * tolerance is decided by Real.isEqual() * * @param t3 * the transformation * @param translate * allow crystallographic translations (+-1) * @return true if t3 transforms this onto itself */ public boolean isInvariant(CMLTransform3 t3, boolean translate) { Point3 peucl3 = getEuclidPoint3(); return (peucl3 == null) ? false : peucl3.isInvariant(t3 .getEuclidTransform3(), translate); } /** * vector between two points. * * @param p2 * point to subtract * @return vector */ public CMLVector3 subtract(CMLPoint3 p2) { Point3 peucl3 = getEuclidPoint3(); Vector3 v = (peucl3 == null) ? null : peucl3.subtract(p2 .getEuclidPoint3()); return (peucl3 == null) ? null : CMLVector3.createCMLVector3(v); } /** * New point by adding points as vectors. used for finding centroids, etc. * does NOT alter this * * @param p * to add * @return NEW point */ public CMLPoint3 plus(CMLPoint3 p) { Point3 peucl3 = getEuclidPoint3(); Point3 pp = (peucl3 == null) ? null : peucl3.plus(p.getEuclidPoint3()); return (pp == null) ? null : new CMLPoint3(pp); } /** * Move this CMLPoint3. alters this * * @param pt * point to shift by */ public void plusEquals(final CMLPoint3 pt) { Point3 peucl3 = getEuclidPoint3(); if (peucl3 != null) { peucl3.plusEquals(pt.getEuclidPoint3()); this.setXMLContent(peucl3.getArray()); } } /** * New point from point and vector. does NOT alter this * * @param v * to add * @return NEW point */ public CMLPoint3 plus(CMLVector3 v) { Point3 peucl3 = getEuclidPoint3(); Point3 vv = (peucl3 == null) ? null : peucl3.plus(v.getEuclidVector3()); return (vv == null) ? null : new CMLPoint3(vv); } /** * point from point and vector. alters this * * @param v * to add */ public void plusEquals(CMLVector3 v) { Point3 peucl3 = getEuclidPoint3(); if (peucl3 != null) { peucl3.plusEquals(v.getEuclidVector3()); this.setXMLContent(peucl3.getArray()); } } /** * New point from point minus vector. does NOT alter this * * @param v * to subtract * @return NEW point */ public CMLPoint3 subtract(CMLVector3 v) { Point3 pp = getEuclidPoint3().subtract(v.getEuclidVector3()); return (pp == null) ? null : new CMLPoint3(pp); } /** * Shift point from point. does alter this * * @param pt * the CMLPoint3 to subtract from this */ public void subtractEquals(final CMLPoint3 pt) { Point3 peucl3 = getEuclidPoint3(); peucl3.subtractEquals(pt.getEuclidPoint3()); this.setXMLContent(peucl3.getArray()); } /** * Shift point from CMLVector3. does alter this * * @param vec3 * the CMLVector3 to subtract from this */ public void subtractEquals(final CMLVector3 vec3) { Point3 peucl3 = getEuclidPoint3(); peucl3.subtractEquals(vec3.getEuclidVector3()); this.setXMLContent(peucl3.getArray()); } /** * scale point does NOT alter this * * @param f * factor to multiply by * @return NEW point */ public CMLPoint3 multiplyBy(double f) { Point3 pp = getEuclidPoint3().multiplyBy(f); return (pp == null) ? null : new CMLPoint3(pp); } /** * scale point. alters this * * @param f * factor to multiply by */ public void multiplyEquals(final double f) { Point3 peucl3 = getEuclidPoint3(); peucl3.multiplyEquals(f); this.setXMLContent(peucl3.getArray()); } /** * scale point. does NOT alter this * * @param f * factor to divide by * @return NEW point (components are Infinity or NaN if divide by zero) * @throws RuntimeException */ public CMLPoint3 divideBy(double f) throws RuntimeException { Point3 pp = getEuclidPoint3().divideBy(f); return (pp == null) ? null : new CMLPoint3(pp); } /** * subscript operator. * * @param n * the index * @return the element * @throws RuntimeException */ public double elementAt(int n) throws RuntimeException { Point3 peucl3 = getEuclidPoint3(); try { return peucl3.elementAt(n); } catch (EuclidRuntimeException e) { throw new RuntimeException("" + e); } } /** * sets element. * * @param n * the index * @param d * the value * @throws RuntimeException * bad value of n */ public void setElementAt(int n, double d) { Point3 peucl3 = getEuclidPoint3(); try { peucl3.setElementAt(n, d); } catch (EuclidRuntimeException e) { throw new RuntimeException("" + e); } this.setXMLContent(peucl3.getArray()); } /** * get transformed point. does NOT modify 'this' * * @param t * the transform * @return new point */ public CMLPoint3 transform(CMLTransform3 t) { Point3 pp = getEuclidPoint3().transform(t.getEuclidTransform3()); return (pp == null) ? null : new CMLPoint3(pp); } /** * distance of point from origin. * * @return distance */ public double getDistanceFromOrigin() { Point3 peucl3 = getEuclidPoint3(); return (peucl3 == null) ? Double.NaN : peucl3.getDistanceFromOrigin(); } /** * Gets the squared Distance between this point and another. * * @param p2 * the other point to get the distance from * @return the squared distance */ public double getSquaredDistanceFromPoint(final CMLPoint3 p2) { Point3 peucl3 = getEuclidPoint3(); return peucl3.getSquaredDistanceFromPoint(p2.getEuclidPoint3()); } /** * distance of point from another point * * @param p2 * the other point to get the distance from * @return the distance */ public double getDistanceFromPoint(CMLPoint3 p2) { Point3 peucl3 = getEuclidPoint3(); return peucl3.getDistanceFromPoint(p2.getEuclidPoint3()); } /** * distance of point from plane. * * @param pl * the plane * @return the distance */ public double distanceFromPlane(CMLPlane3 pl) { Point3 peucl3 = getEuclidPoint3(); return (peucl3 == null) ? Double.NaN : peucl3.distanceFromPlane(pl .getEuclidPlane3()); } /** * get closest point on line. * * @param l * the line * @return the point where distance is shortest */ public CMLPoint3 getClosestPointOnLine(CMLLine3 l) { Point3 pp = getEuclidPoint3().getClosestPointOnLine(l.getEuclidLine3()); return (pp == null) ? null : new CMLPoint3(pp); } /** * is point on line. * * @param l * the line * @return true if within Real.isEqual() of line */ public boolean isOnLine(CMLLine3 l) { return getEuclidPoint3().isOnLine(l.getEuclidLine3()); } /** * is point on plane. * * @param pl * the plane * @return true if within Real.isEqual() of plane */ public boolean isOnPlane(CMLPlane3 pl) { return getEuclidPoint3().isOnPlane(pl.getEuclidPlane3()); } /** * distance from line. BROKEN - DO NOT USE * * @param l * the line * @return the distance */ public double distanceFromLine(CMLLine3 l) { double d = getEuclidPoint3().distanceFromLine(l.getEuclidLine3()); return d; } /** * mid-point of two points. * * @param p2 * the other point * @return the midPoint */ public CMLPoint3 getMidPoint(CMLPoint3 p2) { Point3 pp = getEuclidPoint3().getMidPoint(p2.getEuclidPoint3()); return (pp == null) ? null : new CMLPoint3(pp); } /** * get angle. this-p2-p3 * * @param p2 * the vertex point * @param p3 * the remote point * @return angle null if points are coincident */ public Angle getAngle(CMLPoint3 p2, CMLPoint3 p3) { return Point3.getAngle(getEuclidPoint3(), p2.getEuclidPoint3(), p3 .getEuclidPoint3()); } /** * torsion angle. this-p2-p3-p4 * * @param p2 * @param p3 * @param p4 * @return angle unsigned radians * @throws RuntimeException */ public double getTorsion(CMLPoint3 p2, CMLPoint3 p3, CMLPoint3 p4) { Point3 peucl3 = getEuclidPoint3(); double torsion = Double.NaN; if (peucl3 != null) { torsion = Point3.getTorsion(peucl3, p2.getEuclidPoint3(), p3.getEuclidPoint3(), p4.getEuclidPoint3()).getRadian(); } return torsion; } /** * add point using internal coordinates. used for z-matrix like building * this-p2-p3-newPoint * * @param p2 * existing point * @param p3 * existing point * @param length * p3-p4 * @param angle * p2-p3-p4 radians * @param torsion * this-p2-p3-p4 radians * @exception RuntimeException * two points are coincident or three points are colinear * @return new point */ public CMLPoint3 calculateFromInternalCoordinates(CMLPoint3 p2, CMLPoint3 p3, double length, double angle, double torsion) { Point3 peucl3 = getEuclidPoint3(); Point3 pp = null; if (peucl3 != null) { try { pp = Point3.calculateFromInternalCoordinates(peucl3, p2 .getEuclidPoint3(), p3.getEuclidPoint3(), length, new Angle(angle), new Angle(torsion)); } catch (EuclidRuntimeException je) { throw new RuntimeException("bug " + je); } } return (pp == null) ? null : new CMLPoint3(pp); } /** * is a point at Origin * * @return is this within Real.isEqual() of origin */ public boolean isOrigin() { Point3 peucl3 = getEuclidPoint3(); boolean ok = true; for (double d : peucl3.getArray()) { if (Math.abs(d) > EPS) { ok = false; break; } } return ok; } /** * to string. * * @return the string */ public String getString() { return this.getEuclidPoint3().toString(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLPotential.java000077500000000000000000000033251477224461000263310ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting potential. * autogenerated from schema use * as a shell which can be edited * */ public class CMLPotential extends AbstractPotential { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLPotential() { } /** * constructor. * * @param old */ public CMLPotential(CMLPotential old) { super((AbstractPotential) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLPotential(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLPotential */ public CMLElement makeElementInContext(Element parent) { return new CMLPotential(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLPotentialForm.java000077500000000000000000000033751477224461000271620ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting potentialForm. * autogenerated from schema * use as a shell which can be edited * */ public class CMLPotentialForm extends AbstractPotentialForm { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLPotentialForm() { } /** * constructor. * * @param old */ public CMLPotentialForm(CMLPotentialForm old) { super((AbstractPotentialForm) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLPotentialForm(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLPotentialForm */ public CMLElement makeElementInContext(Element parent) { return new CMLPotentialForm(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLPotentialList.java000077500000000000000000000033751477224461000271720ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting potentialList. * autogenerated from schema * use as a shell which can be edited * */ public class CMLPotentialList extends AbstractPotentialList { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLPotentialList() { } /** * constructor. * * @param old */ public CMLPotentialList(CMLPotentialList old) { super((AbstractPotentialList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLPotentialList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLPotentialList */ public CMLElement makeElementInContext(Element parent) { return new CMLPotentialList(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLProduct.java000077500000000000000000000103461477224461000260130ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import nu.xom.Elements; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting product. * autogenerated from schema use as * a shell which can be edited * */ public class CMLProduct extends AbstractProduct implements ReactionComponent { // TODO /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLProduct() { } /** * constructor. * * @param old */ public CMLProduct(CMLProduct old) { super((AbstractProduct) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLProduct(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLProduct */ public CMLElement makeElementInContext(Element parent) { return new CMLProduct(); } /** * get molecule. * * @return molecule */ public CMLMolecule getMolecule() { return CMLProduct.getMoleculeX(this); } static CMLMolecule getMoleculeX(CMLElement element) { CMLMolecule molecule = null; Elements moleculeChildElements = element .getChildCMLElements(CMLMolecule.TAG); if (moleculeChildElements.size() == 1) { molecule = (CMLMolecule) moleculeChildElements.get(0); } return molecule; } /** * get all descendant atoms. * * @return list of descendant atoms */ public List getAtoms() { return CMLReaction.getAtoms(this); } /** * get all descendant bonds. * * @return list of descendant bonds */ public List getBonds() { return CMLReaction.getBonds(this); } // /** // * get all descendant formulas. // * // * @return list of descendant formulas // */ // public List getFormulas() { // return CMLReaction.getFormulas(this); // } // /** // * get all descendant molecules. // * // * @return list of descendant molecules // */ // public List getMolecules() { // return CMLReaction.getMolecules(this); // } /** * gets descendant reactionComponents. only for interface compatibility * * @return always empty list */ public List getReactionComponentDescendants() { return new ArrayList(); } /** * gets child reactionComponents. only for interface compatibility * * @return always empty list */ public List getReactionComponentChildren() { return new ArrayList(); } /** * get formula. if has single child Formula use that. else create from child * Molecule * * @return null if cannot create formula */ public CMLFormula getOrCreateFormula() { return CMLReactant.getOrCreateFormula(this); } /** * @return all formula objects */ public List getFormulas() { return CMLReaction.getFormulas(this); } /** * @return all molecules */ public List getMolecules() { return CMLReaction.getMolecules(this); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLProductList.java000077500000000000000000000073071477224461000266520ustar00rootroot00000000000000/** * 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 java.util.List; import nu.xom.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting productList. * autogenerated from schema use * as a shell which can be edited * */ public class CMLProductList extends AbstractProductList implements ReactionComponent { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLProductList() { } /** * constructor. * * @param old */ public CMLProductList(CMLProductList old) { super((AbstractProductList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLProductList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLProductList */ public CMLElement makeElementInContext(Element parent) { return new CMLProductList(); } /** * get all descendant atoms. * * @return list of descendant atoms */ public List getAtoms() { return CMLReaction.getAtoms(this); } /** * get all descendant bonds. * * @return list of descendant bonds */ public List getBonds() { return CMLReaction.getBonds(this); } /** * get all descendant formulas. * * @return list of descendant formulas */ public List getFormulas() { return CMLReaction.getFormulas(this); } /** * get all descendant molecules. * * @return list of descendant molecules */ public List getMolecules() { return CMLReaction.getMolecules(this); } /** * gets descendant reactionComponents. note that this will return all * containers as well as contained. thus calling this on: {@code * } will return 2 * components, reactantList, followed by reactant. * * @return empty if no components (some components such as CMLProduct will * always return this) */ public List getReactionComponentDescendants() { return CMLReaction.getReactionComponentDescendants(this, true); } /** * gets child reactionComponents. note that this will return containers but * not their contents. thus calling this on: {@code * } will return 1 components, * reactantList. * * @return empty if no components (some components such as CMLProduct will * always return this) */ public List getReactionComponentChildren() { return CMLReaction.getReactionComponentDescendants(this, false); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLProperty.java000077500000000000000000000302651477224461000262210ustar00rootroot00000000000000/** * 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 java.util.HashMap; import java.util.List; import java.util.Map; import nu.xom.Element; import nu.xom.Nodes; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.base.CMLType; import org.xmlcml.cml.interfacex.HasArraySize; import org.xmlcml.cml.interfacex.HasDataType; import org.xmlcml.cml.interfacex.HasDictRef; import org.xmlcml.cml.interfacex.HasScalar; /** * user-modifiable class supporting property. * autogenerated from schema use as * a shell which can be edited * */ public class CMLProperty extends AbstractProperty implements HasDictRef { /** basic properties (in dictionary) */ public enum DictRef { /** */ APPEARANCE("appearance"), /** */ AUTO_IGNITION("autoIgnition"), /** */ BPT("bpt"), /** */ DENSITY("density"), /** */ DIPOLE("dipole"), /** */ FLASH_POINT("flashPoint"), /** */ KH("kh"), /** */ LOGP("logP"), /** */ LOGPOW("logPow"), /** */ MOLARMASS("molarMass"), /** */ MPT("mpt"), /** */ MWT("mwt"), /** */ PKA("pka"), /** */ PKB("pkb"), /** */ REFRACTIVE_INDEX("refractiveIndex"), /** */ RELATIVE_DENSITY("relativeDensity"), /** */ RELATIVE_VAPOUR_DENSITY("relativeVapourDensity"), /** */ SOLUBILITY("solubility"), /** */ VAPOR_PRESSURE("vaporPressure"), /** */ VISCOSITY("viscosity"), /** */ WATER_SOLUBILITY("waterSolubility"), ; /** value */ public String v; private Map map = new HashMap(); private DictRef(String v) { this.v = v; map.put(v, this); } /** get DictRef for string * * @param v * @return dictRef */ public DictRef get(String v) { return map.get(v); } } /** namespaced element name.*/ public final static String NS = C_E+TAG; /** type of property */ public enum Type { /** intensive properties do not depend on amoount*/ INTENSIVE("intensive"), /** extensive properties depend on amount*/ EXTENSIVE("extensive"), /** semintensive properties are intensive properties * which also depend on polymer size*/ SEMINTENSIVE("semintensive"), ; /** value */ public String value; private Type(String t) { this.value = t; } } /** common properties */ public enum Prop { /** density*/ DENSITY("cml:density"), /** molar mass*/ MOLAR_MASS("cml:molarMass"), /** molar mass*/ MOLAR_VOLUME("cml:molarVolume"), ; /** value of dictRef */ public final String value; private Prop(String s) { value = s; } } private HasDataType child; /** * constructor. */ public CMLProperty() { } /** * constructor. * * @param old */ public CMLProperty(CMLProperty old) { super((AbstractProperty) old); } /** * construct as property with child scalar * @param dictRef * @param value * @param units */ public CMLProperty(String dictRef, double value, String units) { this(); CMLScalar scalar = new CMLScalar(value); scalar.setUnits(units); this.appendChild(scalar); this.setDictRef(dictRef); } /** * copy node . * * @return Node */ public Element copy() { return new CMLProperty(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLProperty */ public CMLElement makeElementInContext(Element parent) { return new CMLProperty(); } /** gets descendant property elements. * may either thave the dictRef on the property element or on * its child. * properties are normalized * @param parent * @param dictRef * @return propertyList containg references (normally 1 or 0 entries) */ public static CMLPropertyList getPropertyList(CMLElement parent, String dictRef) { CMLPropertyList propertyList = new CMLPropertyList(); Nodes nodes = parent.query("./cml:property", CMLConstants.CML_XPATH); for (int i = 0; i < nodes.size(); i++ ) { CMLProperty property = (CMLProperty) nodes.get(i); property.canonicalize(); if (dictRef.equals(property.getAttributeValue("dictRef"))) { propertyList.addProperty(property); } } return propertyList; } /** gets single property. * if zero or many properties with gievn dictRef returns null * @param parent * @param dictRef * @return property or null */ public static CMLProperty getProperty(CMLElement parent, String dictRef) { CMLPropertyList propertyList = CMLProperty.getPropertyList(parent, dictRef); CMLElements properties = propertyList.getPropertyElements(); CMLProperty property = null; if (properties.size() == 1) { property = properties.get(0); } return property; } /** makes sure property has the structure: * {@code ... } * if zero or many children (scalar, array, matrix) no-op * */ public void canonicalize() { CMLProperty.staticCanonicalize(this); } static void staticCanonicalize(CMLElement element) { HasDataType child = CMLProperty.getStaticChild(element); if (child != null) { String thisDictRef = ((HasDictRef)element).getDictRef(); String childDictRef = ((HasDictRef) child).getDictRef(); if (thisDictRef == null) { if (childDictRef == null) { throw new RuntimeException("No dictRef attribute given: "); } // copy to property ((HasDictRef)element).setDictRef(childDictRef); } else { if (childDictRef == null) { } else if (thisDictRef.equals(childDictRef)) { // OK } else { throw new RuntimeException("inconsistent dictRefs: "+thisDictRef+" // "+childDictRef); } } String units = CMLProperty.getStaticUnits(element); String dataType = CMLType.getNormalizedValue(child.getDataType()); if (units != null) { if (!dataType.equals(XSD_DOUBLE)) { ((HasDataType) child).setDataType(XSD_DOUBLE); throw new RuntimeException("units require data type of double"); } } else { if (dataType.equals(XSD_DOUBLE)) { throw new RuntimeException("dataType not double"); } } } } /** * @return units on child */ public String getUnits() { return CMLProperty.getStaticUnits(this); } /** * gets real value of scalar child * * @return the value (NaN if not set) */ public double getDouble() { return CMLProperty.getStaticDouble(this); } /** * gets String value. dataType must be XSD_STRING. * * @return the value (null if not set) */ public String getString() { return CMLProperty.getStaticString(this); } /** * gets int value. dataType must be XSD_INTEGER. * * @return the value * @throws RuntimeException * if different type */ public int getInt() { return CMLProperty.getStaticInt(this); } /** get array elements. * recalculates each time so best cached for frequent use * @return elements as String */ public List getStringValues() { return CMLProperty.getStaticStringValues(this); } /** * gets values of element; * * @return integer values */ public int[] getInts() { return CMLProperty.getStaticInts(this); } /** * gets values of element; * * @return double values */ public double[] getDoubles() { return CMLProperty.getStaticDoubles(this); } /** * requires exactly one child of type scalar array matrix * @return the child */ public HasDataType getChild() { if (child == null) { child = getStaticChild(this); } return child; } /** * @param child the child to set */ public void setChild(HasDataType child) { this.child = child; } /** gets dataType * @return dataType as string */ public String getDataType() { return getStaticDataType(this); } // -------------------------- helpers --------------------------- static String getStaticUnits(CMLElement element) { HasDataType child = getStaticChild(element); String units = ((CMLElement) child).getAttributeValue("units"); return units; } static double getStaticDouble(CMLElement element) { HasDataType child = getStaticChild(element); double result = Double.NaN; String dataType = CMLType.getNormalizedValue(getStaticDataType(child)); if (XSD_DOUBLE.equals(dataType) && child instanceof HasScalar) { result = ((HasScalar) child).getDouble(); } return result; } static String getStaticDataType(HasDataType hasDataType) { return hasDataType.getDataType(); } static String getStaticString(CMLElement element) { HasDataType child = getStaticChild(element); String result = null; if (XSD_STRING.equals(child.getDataType()) && (child instanceof HasScalar) ) { result = ((HasScalar) child).getString(); } return result; } static int getStaticInt(CMLElement element) { HasDataType child = getStaticChild(element); int result = Integer.MIN_VALUE; String dataType = CMLType.getNormalizedValue(child.getDataType()); if (XSD_INTEGER.equals(dataType) && (child instanceof HasScalar)) { result = ((HasScalar) child).getInt(); } return result; } static List getStaticStringValues(CMLElement element) { HasDataType child = getStaticChild(element); List result = null; String dataType = CMLType.getNormalizedValue(child.getDataType()); if (XSD_STRING.equals(dataType) && child instanceof HasArraySize) { result = ((HasArraySize) child).getStringValues(); } return result; } static int[] getStaticInts(CMLElement element) { HasDataType child = getStaticChild(element); int[] result = null; String dataType = CMLType.getNormalizedValue(child.getDataType()); if (XSD_INTEGER.equals(dataType) && child instanceof HasArraySize) { result = ((HasArraySize) child).getInts(); } return result; } static double[] getStaticDoubles(CMLElement element) { HasDataType child = getStaticChild(element); double[] result = null; String dataType = CMLType.getNormalizedValue(child.getDataType()); if (XSD_DOUBLE.equals(dataType) && child instanceof HasArraySize) { result = ((HasArraySize) child).getDoubles(); } return result; } static HasDataType getStaticChild(CMLElement element) { HasDataType dataType = null; Nodes nodes = element.query("cml:scalar | cml:array | cml:matrix", CMLConstants.CML_XPATH); if (nodes.size() == 1) { dataType = (HasDataType) nodes.get(0); } return dataType; } static String getStaticDataType(CMLElement element) { HasDataType child = getStaticChild(element); String dataType = (child == null) ? null : ((HasDataType) child).getDataType(); return CMLType.getNormalizedValue(dataType); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLPropertyList.java000077500000000000000000000117051477224461000270530ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import nu.xom.Elements; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; /** * user-modifiable class supporting propertyList. * autogenerated from schema * use as a shell which can be edited * */ public class CMLPropertyList extends AbstractPropertyList { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLPropertyList() { } /** * constructor. * * @param old */ public CMLPropertyList(CMLPropertyList old) { super((AbstractPropertyList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLPropertyList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLPropertyList */ public CMLElement makeElementInContext(Element parent) { return new CMLPropertyList(); } /** * gets all nested property descendants of arbitrary CMLElement. * * recurses through all propertyList and property children, adding the * latter to the list. Order is not preserved. * * @return list of all descendants */ public List getPropertyDescendants() { List mList = new ArrayList(); CMLElements propertyLists = this .getPropertyListElements(); for (CMLPropertyList ml : propertyLists) { mList.addAll(ml.getPropertyDescendants()); } CMLElements propertys = this.getPropertyElements(); for (CMLProperty m : propertys) { mList.add(m); } return mList; } /** * gets all nested property descendants of arbitrary CMLElement. * * recurses through all propertyList and property children, adding the * latter to the list. Order is not preserved. * * @param parent * with property(List) children * @return list of all descendants */ public static List getPropertyDescendants(CMLElement parent) { List mList = new ArrayList(); Elements propertyLists = parent .getChildCMLElements(CMLPropertyList.TAG); for (int i = 0; i < propertyLists.size(); i++) { CMLPropertyList propertyList = (CMLPropertyList) propertyLists .get(i); mList.addAll(propertyList.getPropertyDescendants()); } // generally property should be under propertyList parent Elements propertys = parent.getChildCMLElements(CMLProperty.TAG); for (int i = 0; i < propertys.size(); i++) { mList.add((CMLProperty) propertys.get(i)); } return mList; } /** * gets property elements with a given dictRef. if either param is null, * returns empty list * * @param propertyList * list to filter * @param dictRef * value of dictRef attribute * @return filtered list */ public static List getPropertyDescendantsByDictRef( List propertyList, String dictRef) { List newPropertyList = new ArrayList(); if (dictRef != null && propertyList != null) { for (CMLProperty property : propertyList) { if (dictRef.equals(property.getDictRef())) { newPropertyList.add(property); } } } return newPropertyList; } /** * gets property elements with a given dictRef. if dictRef is null returns * empty list * * @param dictRef * value of dictRef attribute * @return filtered list */ public List getPropertyDescendantsByName(String dictRef) { return getPropertyDescendantsByDictRef(this.getPropertyDescendants(), dictRef); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLReactant.java000077500000000000000000000106621477224461000261350ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting reactant. * autogenerated from schema use as * a shell which can be edited * */ public class CMLReactant extends AbstractReactant implements ReactionComponent { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLReactant() { } /** * constructor. * * @param old */ public CMLReactant(CMLReactant old) { super((AbstractReactant) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLReactant(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLReactant */ public CMLElement makeElementInContext(Element parent) { return new CMLReactant(); } /** * get molecule. * * @return molecule */ public CMLMolecule getMolecule() { return CMLProduct.getMoleculeX(this); } /** * get all descendant atoms. * * @return list of descendant atoms */ public List getAtoms() { return CMLReaction.getAtoms(this); } /** * get all descendant bonds. * * @return list of descendant bonds */ public List getBonds() { return CMLReaction.getBonds(this); } /** * get all descendant formulas. these are explicit CMLFormula children * * @return list of descendant formulas */ public List getFormulas() { return CMLReaction.getFormulas(this); } /** * get all descendant molecules. * * @return list of descendant molecules */ public List getMolecules() { return CMLReaction.getMolecules(this); } /** * gets descendant reactionComponents. only for interface compatibility * * @return always empty list */ public List getReactionComponentDescendants() { return new ArrayList(); } /** * gets child reactionComponents. only for interface compatibility * * @return always empty list */ public List getReactionComponentChildren() { return new ArrayList(); } /** * get formula. if has single child Formula use that. else create from child * Molecule * * @return null if cannot create formula */ public CMLFormula getOrCreateFormula() { return CMLReactant.getOrCreateFormula(this); } static CMLFormula getOrCreateFormula(ReactionComponent component) { // TODO CMLFormula formula = null; List formulaList = CMLReaction.getFormulas(component); if (formulaList.size() == 1) { formula = formulaList.get(0); } else { List molecules = component.getMolecules(); if (molecules == null) { ((CMLElement)component).debug("NO MOLECULES"); } if (molecules.size() == 1) { CMLMolecule molecule = molecules.get(0); if (molecule.getFormulaElements().size() == 1) { formula = molecule.getFormulaElements().get(0); } else { formula = new CMLFormula(molecule); } } } return formula; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLReactantList.java000077500000000000000000000073221477224461000267700ustar00rootroot00000000000000/** * 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 java.util.List; import nu.xom.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting reactantList. * autogenerated from schema * use as a shell which can be edited * */ public class CMLReactantList extends AbstractReactantList implements ReactionComponent { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLReactantList() { } /** * constructor. * * @param old */ public CMLReactantList(CMLReactantList old) { super((AbstractReactantList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLReactantList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLReactantList */ public CMLElement makeElementInContext(Element parent) { return new CMLReactantList(); } /** * get all descendant atoms. * * @return list of descendant atoms */ public List getAtoms() { return CMLReaction.getAtoms(this); } /** * get all descendant bonds. * * @return list of descendant bonds */ public List getBonds() { return CMLReaction.getBonds(this); } /** * get all descendant formulas. * * @return list of descendant formulas */ public List getFormulas() { return CMLReaction.getFormulas(this); } /** * get all descendant molecules. * * @return list of descendant molecules */ public List getMolecules() { return CMLReaction.getMolecules(this); } /** * gets descendant reactionComponents. note that this will return all * containers as well as contained. thus calling this on: {@code * } will return 2 * components, reactantList, followed by reactant. * * @return empty if no components (some components such as CMLProduct will * always return this) */ public List getReactionComponentDescendants() { return CMLReaction.getReactionComponentDescendants(this, true); } /** * gets child reactionComponents. note that this will return containers but * not their contents. thus calling this on: {@code * } will return 1 components, * reactantList. * * @return empty if no components (some components such as CMLProduct will * always return this) */ public List getReactionComponentChildren() { return CMLReaction.getReactionComponentDescendants(this, false); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLReaction.java000077500000000000000000000463211477224461000261410ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import nu.xom.Elements; import nu.xom.Nodes; import org.apache.log4j.Logger; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; /** * user-modifiable class supporting reaction. * autogenerated from schema use as * a shell which can be edited * */ public class CMLReaction extends AbstractReaction implements ReactionComponent { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** mappings */ public enum Mapping { /** */ FROM_SPECTATOR_PRODUCT_TO_REACTANT, /** */ FROM_PRODUCT_TO_REACTANT, /** */ MAP_REACTION_ATOM_MAP_COMPLETE, ; } /** not quite sure.*/ @Deprecated public enum Index { /** product index CHECK */ REACTANT_I(1), ; /** index*/ public int index; private Index(int i) { index = i; } } private static String ANYTAG = CMLReactant.TAG + " || "+ CMLProduct.TAG + " || "+ CMLSpectator.TAG; /** component type */ public enum Component { /** */ REACTANT(CMLReactant.TAG, 0), /** */ PRODUCT(CMLProduct.TAG, 1), /** */ SPECTATOR(CMLSpectator.TAG, 2), /** */ ANY(ANYTAG, 3), /** */ REACTANTLIST(CMLReactantList.TAG, 0), /** */ PRODUCTLIST(CMLProductList.TAG, 1), /** */ SPECTATORLIST(CMLSpectatorList.TAG, 2), /** */ ANYLIST(ANYTAG, 3); /** */ public String name; /** * symbolic integer, can be used in subscripts, etc. */ public int number; private Component(String name, int number) { this.name = name; this.number = number; } } /** * Ignore bond orders in mapping. * */ public final static String IGNORE_ORDER = "/IgnoreBondOrders"; /** * a complete atom map for the reaction. often used as the dictRef value */ public final static String MAP_REACTION_ATOM_MAP_COMPLETE = "cml:REACTION_ATOM_MAP_COMPLETE"; /** * an incomplete atom map for the reaction. often used as the dictRef value */ public final static String MAP_REACTION_ATOM_MAP_INCOMPLETE = "cml:REACTION_ATOM_MAP_INCOMPLETE"; /** * direction of mapping * */ public final static String FROM_PRODUCT_TO_REACTANT = "from product to product"; /** * direction of mapping * */ public final static String FROM_SPECTATOR_PRODUCT_TO_REACTANT = "from cmlSpectator product to product"; /** * constructor. */ public CMLReaction() { } /** * constructor. * * @param old */ public CMLReaction(CMLReaction old) { super((AbstractReaction) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLReaction(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLReaction */ public CMLElement makeElementInContext(Element parent) { return new CMLReaction(); } final static Logger logger = Logger.getLogger(CMLReaction.class.getName()); /** * gets an id for generic product or product context. * * For example used when there is no productList id or an atomSet * consistiing of product atoms * * @param type * REACTANT or PRODUCT * @return an id including the reaction id and type */ public String getId(String type) { return this.getId() + CMLConstants.S_PERIOD + type; } /** * merge productLists into single productList. * */ public void mergeProductLists() { mergePRLists(Component.PRODUCTLIST, Component.PRODUCT); } /** * merge reactantLists into single reactantList. * */ public void mergeReactantLists() { mergePRLists(Component.REACTANTLIST, Component.REACTANT); } /** * merge spectatorLists into single spectatorList. * */ public void mergeSpectatorLists() { mergePRLists(Component.SPECTATORLIST, Component.SPECTATOR); } private void mergePRLists(Component prListC, Component prC) { Elements prLists = this.getChildCMLElements(prListC.name); if (prLists.size() > 1) { for (int i = 1; i < prLists.size(); i++) { CMLElement prList = (CMLElement) prLists.get(i); Elements prs = prList.getChildCMLElements(prC.name); for (int j = 0; j < prs.size(); j++) { Element pr = prs.get(j); pr.detach(); prLists.get(0).appendChild(pr); } prList.detach(); } } } /** * convenience method to get ReactantList. * * merges ReactantLists * * @return the productListTool or null */ public CMLReactantList getReactantList() { mergeReactantLists(); CMLReactantList productList = (CMLReactantList) this .getFirstCMLChild(CMLReactantList.TAG); return productList; } /** * convenience method to get ProductList. * * merges ProductLists * * @return the productList or null */ public CMLProductList getProductList() { mergeProductLists(); CMLProductList productList = (CMLProductList) this .getFirstCMLChild(CMLProductList.TAG); return productList; } /** * convenience method to get SpectatorList. * * merges SpectatorLists * * @return the spectatorList or null */ public CMLSpectatorList getSpectatorList() { mergeSpectatorLists(); CMLSpectatorList spectatorList = (CMLSpectatorList) this .getFirstCMLChild(CMLSpectatorList.TAG); return spectatorList; } /** * gets filename from components of CMLReaction. uses * CMLName/@dictRef='cml:filename' content * else reaction.getId() * * @return the filename or null */ public String getFilename() { String s = null; Elements nameNodes = this.getChildCMLElements(CMLName.TAG); for (int i = 0; i < nameNodes.size(); i++) { CMLName name = (CMLName) nameNodes.get(i); if (name.getDictRef().equals(CMLReaction.CML_FILENAME)) { s = name.getXMLContent(); } } return (s == null) ? this.getId() : s; } /** * gets cmlSpectator molecules in order. * * assumes order is spectators under spectatorList, each with two molecules, * identical in connection table but not necessarily ids or atom order * * @param reactOrProd * 0 for product spectators 1 for product * @return molecules in these spectators or null */ public List getSpectatorMolecules(int reactOrProd) { List moleculeList = new ArrayList(); CMLSpectatorList spectatorList = (CMLSpectatorList) this .getFirstCMLChild(CMLSpectatorList.TAG); Elements spectators = spectatorList.getChildCMLElements("spectator"); for (int i = 0; i < spectators.size(); i++) { Elements moleculeNodes = ((CMLElement) spectators.get(i)) .getChildCMLElements(CMLMolecule.TAG); moleculeList.add((CMLMolecule) moleculeNodes.get(reactOrProd)); } return moleculeList; } /** * delete any substance with only a name. I think this is obsolescent... * */ public void removeOrphanSubstances() { CMLSubstanceList substanceList = (CMLSubstanceList) this .getFirstCMLChild("substanceList"); if (substanceList != null) { Elements substances = substanceList .getChildCMLElements("substance"); for (int i = 0; i < substances.size(); i++) { Elements childNodes = substances.get(i).getChildElements(); if (childNodes.size() == 1 && childNodes.get(0) instanceof CMLName) { substances.get(i).detach(); } } } } /** * get all descendant atoms. * * @return list of descendant atoms */ public List getAtoms() { return CMLReaction.getAtoms(this); } /** * get all descendant bonds. * * @return list of descendant bonds */ public List getBonds() { return CMLReaction.getBonds(this); } /** * get all descendant formulas. * * @return list of descendant formulas */ public List getFormulas() { return CMLReaction.getFormulas(this); } /** * get all descendant molecules. * * @return list of descendant molecules */ public List getMolecules() { return CMLReaction.getMolecules(this); } /** * @param reactant */ public void addReactant(CMLReactant reactant) { CMLReactantList reactantList = getOrCreateReactantList(); reactantList.addReactant(reactant); } public void addReactant(CMLMolecule molecule) { CMLReactant reactant = new CMLReactant(); reactant.addMolecule(molecule); addReactant(reactant); } /** * create if necessary * @return productList */ public CMLReactantList getOrCreateReactantList() { CMLReactantList reactantList = this.getReactantList(); if (reactantList == null) { reactantList = new CMLReactantList(); this.addReactantList(reactantList); } return reactantList; } public void addProduct(CMLProduct product) { CMLProductList productList = getOrCreateProductList(); productList.addProduct(product); } public void addProduct(CMLMolecule molecule) { CMLProduct product = new CMLProduct(); product.addMolecule(molecule); addProduct(product); } public CMLProductList getOrCreateProductList() { CMLProductList productList = this.getProductList(); if (productList == null) { productList = new CMLProductList(); this.addProductList(productList); } return productList; } /** * utility for any ReactionComponent classes. * * @param component * @return list of descendant atoms */ static List getAtoms(ReactionComponent component) { List atomList = new ArrayList(); List elementList = ((CMLElement) component).getElements(".//"+CMLAtom.NS); for (CMLElement element : elementList) { atomList.add((CMLAtom) element); } return atomList; } /** * utility for any ReactionComponent classes. * * @param component * @return list of descendant bonds */ static List getBonds(ReactionComponent component) { List bondList = new ArrayList(); List elementList = ((CMLElement) component).getElements(".//"+CMLBond.NS); for (CMLElement element : elementList) { bondList.add((CMLBond) element); } return bondList; } /** * utility for any ReactionComponent classes. * requires element to exist * @param component * @return list of non-nested descendant formulas */ static List getFormulas(ReactionComponent component) { List formulaList = new ArrayList(); List elementList = ((CMLElement) component).getElements(".//"+CMLFormula.NS); for (CMLElement element : elementList) { formulaList.add((CMLFormula) element); } return formulaList; } /** * utility for any ReactionComponent classes. * @param component * @return list of non-nested descendant formulas */ static List getOrCreateFormulas(ReactionComponent component) { return getFormulas(component); } /** * utility for any ReactionComponent classes. * * @param component * @return list of non-nested descendant molecules */ static List getMolecules(ReactionComponent component) { List moleculeList = new ArrayList(); List elementList = ((CMLElement) component).getElements(".//"+CMLMolecule.NS); for (CMLElement element : elementList) { moleculeList.add((CMLMolecule) element); } return moleculeList; } /** * utility for any ReactionComponent classes. * * @param component * @nested recurse to grandchildren * @return list of non-nested descendant molecules */ static List getReactionComponentDescendants( ReactionComponent component, boolean nested) { List componentList = new ArrayList(); List childElements = ((CMLElement) component) .getChildCMLElements(); for (CMLElement child : childElements) { if (child instanceof ReactionComponent) { componentList.add((ReactionComponent) child); if (nested) { List descendantList = CMLReaction .getReactionComponentDescendants( (ReactionComponent) child, nested); componentList.addAll(descendantList); } } } return componentList; } /** * gets list of descendant products. convenience class * * @return list of descendant products */ public List getDescendantReactants() { List elems = this.getElements(".//"+CMLReactant.NS); List productList = new ArrayList(); for (CMLElement elem : elems) { productList.add((CMLReactant) elem); } return productList; } /** * gets list of descendant products. convenience class * * @return list of descendant products */ public List getDescendantProducts() { List elems = this.getElements(".//"+CMLProduct.NS); List productList = new ArrayList(); for (CMLElement elem : elems) { productList.add((CMLProduct) elem); } return productList; } /** gets all molecules of given type. * @param type (REACTANT, PRODUCT, SPECTATOR) * @return list of molecules */ public List getMolecules(Component type) { String typeS = null; if (type == null) { throw new RuntimeException("null component type"); } else if (Component.PRODUCT.equals(type)) { } else if (Component.REACTANT.equals(type)) { typeS = "cml:reactant"; } else if (Component.SPECTATOR.equals(type)) { typeS = "cml:spectator"; } else { throw new RuntimeException("bad component type: "+type ); } List moleculeList = new ArrayList(); Nodes nodes = null; if (typeS == null) { } else if(typeS.equals(CMLReaction.Component.ANY)) { nodes = this.query(".//cml:molecule", CMLConstants.CML_XPATH); } else { String qs = ".//"+typeS+"/cml:molecule"; nodes = this.query(qs, CMLConstants.CML_XPATH); } if (nodes != null) { for (int i = 0; i < nodes.size(); i++) { moleculeList.add((CMLMolecule) nodes.get(i)); } } return moleculeList; } /** * @param type (REACTANT, PRODUCT, ANY, SPECTATOR) * @return list of atoms (assumed to be unique but no guarantee */ public List getAtoms(Component type) { List allAtomList = new ArrayList(); List moleculeList = getMolecules(type); for (CMLMolecule molecule : moleculeList) { List atomList = molecule.getAtoms(); for (CMLAtom atom : atomList) { allAtomList.add(atom); } } return allAtomList; } /** * @param type (REACTANT, PRODUCT, ANY, SPECTATOR) * @return list of bonds (assumed to be unique but no guarantee */ public List getBonds(Component type) { List allBondList = new ArrayList(); List moleculeList = getMolecules(type); for (CMLMolecule molecule : moleculeList) { List bondList = molecule.getBonds(); for (CMLBond bond : bondList) { allBondList.add(bond); } } return allBondList; } /** * gets list of descendant spectators. convenience class * * @return list of descendant spectators */ public List getDescendantSpectators() { List elems = this.getElements(".//"+CMLSpectator.NS); List spectatorList = new ArrayList(); for (CMLElement elem : elems) { spectatorList.add((CMLSpectator) elem); } return spectatorList; } public void addSpectator(CMLMolecule molecule) { CMLSpectator spectator = new CMLSpectator(); spectator.addMolecule(molecule); addSpectator(spectator); } public void addSpectator(CMLSpectator spectator) { CMLSpectatorList spectatorList = getOrCreateSpectatorList(); spectatorList.addSpectator(spectator); } public CMLSpectatorList getOrCreateSpectatorList() { CMLElements spectatorLists = this.getSpectatorListElements(); CMLSpectatorList spectatorList = null; if (spectatorLists.size() == 0) { spectatorList = new CMLSpectatorList(); this.addSpectatorList(spectatorList); } else { spectatorList = spectatorLists.get(0); } return spectatorList; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLReactionConstants.java000077500000000000000000000040101477224461000300230ustar00rootroot00000000000000/** * 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; /** * constants for reaction elements. * * @author pmr * */ public interface CMLReactionConstants { /** * symbolic integer for reactant. [0] can be used in subscripts, etc. */ int REACTANT_I = 0; /** * symbolic integer for product. [1] can be used in subscripts, etc. */ int PRODUCT_I = 1; /** * symbolic string for reactant. [0] can be used in subscripts, etc. */ String REACTANT_S = CMLReactant.TAG; /** * symbolic string for product. [1] can be used in subscripts, etc. */ String PRODUCT_S = CMLProduct.TAG; /** * Ignore bond orders in mapping. * */ String IGNORE_ORDER = "/IgnoreBondOrders"; /** * a complete atom map for the reaction. often used as the dictRef value */ String MAP_REACTION_ATOM_MAP_COMPLETE = "REACTION ATOM MAP COMPLETE"; /** * an incomplete atom map for the reaction. often used as the dictRef value */ String MAP_REACTION_ATOM_MAP_INCOMPLETE = "REACTION ATOM MAP INCOMPLETE"; /** * direction of mapping * */ String FROM_PRODUCT_TO_REACTANT = "from product to reactant"; /** * direction of mapping * */ String FROM_SPECTATOR_PRODUCT_TO_REACTANT = "from cmlSpectator product to reactant"; }cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLReactionList.java000077500000000000000000000033611477224461000267720ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting reactionList. * autogenerated from schema * use as a shell which can be edited * */ public class CMLReactionList extends AbstractReactionList { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLReactionList() { } /** * contructor. * * @param old */ public CMLReactionList(CMLReactionList old) { super((AbstractReactionList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLReactionList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLReactionList */ public CMLElement makeElementInContext(Element parent) { return new CMLReactionList(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLReactionScheme.java000077500000000000000000000034051477224461000272620ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting reactionScheme. * autogenerated from schema * use as a shell which can be edited * */ public class CMLReactionScheme extends AbstractReactionScheme { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLReactionScheme() { } /** * contructor. * * @param old */ public CMLReactionScheme(CMLReactionScheme old) { super((AbstractReactionScheme) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLReactionScheme(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLReactionScheme */ public CMLElement makeElementInContext(Element parent) { return new CMLReactionScheme(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLReactionStep.java000077500000000000000000000033611477224461000267720ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting reactionStep. * autogenerated from schema * use as a shell which can be edited * */ public class CMLReactionStep extends AbstractReactionStep { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLReactionStep() { } /** * contructor. * * @param old */ public CMLReactionStep(CMLReactionStep old) { super((AbstractReactionStep) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLReactionStep(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLReactionStep */ public CMLElement makeElementInContext(Element parent) { return new CMLReactionStep(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLReactionStepList.java000077500000000000000000000034311477224461000276240ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting reactionStepList. * autogenerated from * schema use as a shell which can be edited * */ public class CMLReactionStepList extends AbstractReactionStepList { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLReactionStepList() { } /** * contructor. * * @param old */ public CMLReactionStepList(CMLReactionStepList old) { super((AbstractReactionStepList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLReactionStepList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLReactionStepList */ public CMLElement makeElementInContext(Element parent) { return new CMLReactionStepList(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLReactiveCentre.java000077500000000000000000000034051477224461000272740ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting reactiveCentre. * autogenerated from schema * use as a shell which can be edited * */ public class CMLReactiveCentre extends AbstractReactiveCentre { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLReactiveCentre() { } /** * contructor. * * @param old */ public CMLReactiveCentre(CMLReactiveCentre old) { super((AbstractReactiveCentre) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLReactiveCentre(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLReactiveCentre */ public CMLElement makeElementInContext(Element parent) { return new CMLReactiveCentre(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLRegion.java000077500000000000000000000032651477224461000256200ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting region. * autogenerated from schema use as a * shell which can be edited * */ public class CMLRegion extends AbstractRegion { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLRegion() { } /** * contructor. * * @param old */ public CMLRegion(CMLRegion old) { super((AbstractRegion) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLRegion(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLRegion */ public CMLElement makeElementInContext(Element parent) { return new CMLRegion(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLRelatedEntry.java000077500000000000000000000032431477224461000267730ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting relatedEntry. * autogenerated from schema * use as a shell which can be edited * */ public class CMLRelatedEntry extends AbstractRelatedEntry { /** * contructor. */ public CMLRelatedEntry() { } /** * contructor. * * @param old */ public CMLRelatedEntry(CMLRelatedEntry old) { super((AbstractRelatedEntry) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLRelatedEntry(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLRelatedEntry */ public CMLElement makeElementInContext(Element parent) { return new CMLRelatedEntry(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLSample.java000077500000000000000000000032651477224461000256160ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting sample. * autogenerated from schema use as a * shell which can be edited * */ public class CMLSample extends AbstractSample { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLSample() { } /** * contructor. * * @param old */ public CMLSample(CMLSample old) { super((AbstractSample) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLSample(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLSample */ public CMLElement makeElementInContext(Element parent) { return new CMLSample(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLScalar.java000077500000000000000000000336711477224461000256060ustar00rootroot00000000000000/** * 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 java.text.ParseException; import nu.xom.Element; import org.apache.log4j.Logger; import org.joda.time.DateTime; import org.xmlcml.cml.attribute.DictRefAttribute; import org.xmlcml.cml.attribute.NamespaceRefAttribute; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLType; import org.xmlcml.cml.interfacex.HasDataType; import org.xmlcml.cml.interfacex.HasDictRef; import org.xmlcml.cml.interfacex.HasScalar; import org.xmlcml.cml.interfacex.HasUnits; import org.xmlcml.euclid.JodaDate; import org.xmlcml.euclid.Util; /** * user-modifiable class supporting scalar. * autogenerated from schema use as a * shell which can be edited * */ public class CMLScalar extends AbstractScalar implements HasUnits, HasScalar, HasDictRef, HasDataType { @SuppressWarnings("unused") private static Logger LOG = Logger.getLogger(CMLScalar.class); /** namespaced element name. */ public final static String NS = C_E + TAG; /** * default constructor. NOTE creates a CMLScalar with dataType = XSD_STRING * and content CMLConstants.S_EMPTY. * */ public CMLScalar() { init(); } void init() { // setXMLContent(S_EMPTY); } /** * contructor. * * @param old */ public CMLScalar(CMLScalar old) { super((AbstractScalar) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLScalar(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLScalar */ public CMLElement makeElementInContext(Element parent) { return new CMLScalar(); } /** * check scalar is OK. * * @param parent * element * @throws RuntimeException * parsing error */ public void finishMakingElement(Element parent) throws RuntimeException { String dataType = this.getDataType(); if (dataType.equals(XSD_STRING)) { } else if (dataType.equals(XSD_BOOLEAN)) { this.getBoolean(); } else if (XSD_DOUBLE.equals(CMLType.getNormalizedValue(dataType))) { this.getDouble(); } else if (dataType.equals(XSD_INTEGER)) { this.getInt(); } else if (dataType.equals(XSD_DATE)) { this.getDate(); } else { throw new RuntimeException("scalar does not support dataType: " + dataType); } } // =========================== additional constructors // ======================== /** * formed from components. sets dataType to xsd:boolean * * @param scalar */ public CMLScalar(Boolean scalar) { this.setValue(scalar); } /** * formed from components. sets dataType to xsd:date * * @param scalar */ public CMLScalar(DateTime scalar) { this.setValue(scalar); } /** * formed from components. sets dataType to xsd:string * * @param scalar */ public CMLScalar(String scalar) { this.setValue(scalar); } /** * formed from components. sets dataType to xsd:double * * @param scalar */ public CMLScalar(double scalar) { this.setValue(scalar); } /** * formed from components. sets dataType to xsd:integer * * @param scalar */ public CMLScalar(int scalar) { this.setValue(scalar); } /** * gets boolean. dataType must be XSD_BOOLEAN. * * @return the value (null if not set) */ public Boolean getBoolean() { Boolean result = null; if (getDataType().equals(XSD_BOOLEAN)) { String content = getXMLContent(); if (content != null) { result = Boolean.valueOf(content); } } return result; } /** * gets real value. dataType must be XSD_DATE * * @return the value (NaN if not set) */ public DateTime getDate() { DateTime result = null; if (getDataType().equals(XSD_DATE)) { String content = getXMLContent(); if (content != null) { try { result = JodaDate.parseDate(content); } catch (Exception e) { throw new RuntimeException("bad date", e); } } } return result; } /** * gets real value. dataType must be XSD_DOUBLE. * * @return the value (NaN if not set) */ public double getDouble() { double result = Double.NaN; if (getDataType().equals(XSD_DOUBLE)) { String content = getXMLContent(); if (content != null) { try { result = (Util.parseFlexibleDouble(content)); } catch (ParseException e) { throw new RuntimeException("Bad double :" + content, e); } } } return result; } /** * gets String value. dataType must be XSD_STRING. * * @return the value (null if not set) */ public String getString() { String result = null; if (getDataType().equals(XSD_STRING)) { result = getXMLContent(); } return result; } /** * gets int value. dataType must be XSD_INTEGER. * * @return the value * @throws RuntimeException * if different type */ public int getInt() { int result = Integer.MIN_VALUE; if (getDataType().equals(XSD_INTEGER)) { String content = getXMLContent(); if (content != null && !content.trim().equals(S_EMPTY)) { try { result = Integer.parseInt(content); } catch (NumberFormatException e) { throw new RuntimeException("bad integer content: " + content); } } } else { throw new RuntimeException("wrong dataType for int " + getDataType()); } return result; } // ====================== subsidiary accessors ===================== /** * sets value to boolean.. updates dataType. * * @param scalar */ public void setValue(Boolean scalar) { setXMLContent(S_EMPTY + scalar); super.setDataType(XSD_BOOLEAN); } /** * sets value to date. updates dataType. * * @param scalar */ public void setValue(DateTime scalar) { String date = JodaDate.formatDate(scalar); setXMLContent(date); super.setDataType(XSD_DATE); } /** * sets value to String.. updates dataType. * TRIMS value * @param scalar no action if null */ public void setValue(String scalar) { if (scalar != null) { setXMLContent(scalar); super.setDataType(XSD_STRING); } } /** * sets value to String.. updates dataType. * does NOT trim value or normalize whitespace * @param scalar no action if null */ public void setValueNoTrim(String scalar) { if (scalar != null) { this.removeChildren(); this.appendChild(scalar); this.setDataType(XSD_STRING); } } /** * sets value to double. updates dataType. * * @param scalar */ public void setValue(double scalar) { setXMLContent(S_EMPTY + scalar); super.setDataType(XSD_DOUBLE); } /** * sets value to int.. updates dataType. * * @param scalar */ public void setValue(int scalar) { setXMLContent(S_EMPTY + scalar); super.setDataType(XSD_INTEGER); } /** * get dataType. if attribute not set, reset to String. * * @return dataType (default XSD_STRING) */ public String getDataType() { String dataType = super.getDataType(); if (dataType == null) { dataType = XSD_STRING; super.setDataType(dataType); } return CMLType.getNormalizedValue(dataType); } /** * get class. if attribute not set, reset to String. * * @return class, default String.class */ public Class getDataTypeClass() { Class clazz = null; String dataType = getDataType(); if (XSD_STRING.equals(dataType)) { clazz = String.class; } else if (XSD_DOUBLE.equals(dataType)) { clazz = Double.class; } else if (XSD_INTEGER.equals(dataType)) { clazz = Integer.class; } else if (XSD_BOOLEAN.equals(dataType)) { clazz = Boolean.class; } else if (XSD_DATE.equals(dataType)) { clazz = DateTime.class; } else { } return clazz; } /** * set dataType. this may not be set independently of the value, so simply * throws CMLRuntime only place it is usable is within copy constructor * * @param dType * @throws RuntimeException * attempt to reset datatype */ public void setDataType(String dType) { if (this.getAttributeValue("dataType") == null) { super.setDataType(dType); } else { throw new RuntimeException( "Must not reset dataType; use SetValue(...)"); } } // ====================== functionality ===================== /** * can two scalars be used for arithmetic. checks that both scalars are * numeric and of same dataType and of same size * * @param scalar * the scalar to test; can have different owner * @throws RuntimeException * if not of same numeric data type */ void checkNumericConformability(CMLScalar scalar) { if (!this.getDataType().equals(scalar.getDataType())) { throw new RuntimeException( "Unsuitable dataTypes for numeric operations / " + this.getDataType() + CMLConstants.S_SLASH + scalar.getDataType()); } } /** * subtract an scalar from this.. * * result = this - scalar, owner document = this does not alter this only * works if both scalars are numeric and of same dataType * * @param scalar * the scalar to subtract; can have different owner * @throws RuntimeException * inappropriate dataTypes * @return new scalar */ public CMLScalar subtract(CMLScalar scalar) { checkNumericConformability(scalar); CMLScalar resultScalar = null; if (this.getDataType().equals(XSD_DOUBLE)) { resultScalar = new CMLScalar(this.getDouble() - scalar.getDouble()); } else if (this.getDataType().equals(XSD_INTEGER)) { resultScalar = new CMLScalar(this.getInt() - scalar.getInt()); } return resultScalar; } /** * subtract an scalar from this.. * * this -= scalar, owner document = this alters this only works if both * scalars are numeric and of same dataType * * @param scalar * the scalar to subtract; can have different owner * @throws RuntimeException * inappropriate dataTypes, unequal scalars */ public void subtractEquals(CMLScalar scalar) { checkNumericConformability(scalar); if (this.getDataType().equals(XSD_DOUBLE)) { this.setValue(this.getDouble() - scalar.getDouble()); } else if (this.getDataType().equals(XSD_INTEGER)) { this.setValue(this.getInt() - scalar.getInt()); } } /** * add a scalar to this.. * * result = this + scalar does not alter this only works if both scalars are * numeric and of same dataType * * @param scalar * the scalar to add; * @throws RuntimeException * inappropriate dataTypes * @return new scalar */ public CMLScalar plus(CMLScalar scalar) { checkNumericConformability(scalar); CMLScalar resultScalar = null; if (this.getDataType().equals(XSD_DOUBLE)) { resultScalar = new CMLScalar(this.getDouble() + scalar.getDouble()); } else if (this.getDataType().equals(XSD_INTEGER)) { resultScalar = new CMLScalar(this.getInt() + scalar.getInt()); } return resultScalar; } /** * subtract an scalar from this.. * * this += scalar, owner document = this alters this only works if both * scalars are numeric and of same dataType * * @param scalar * the scalar to subtract; * @throws RuntimeException * inappropriate dataTypes, unequal scalars */ public void plusEquals(CMLScalar scalar) { checkNumericConformability(scalar); if (this.getDataType().equals(XSD_DOUBLE)) { this.setValue(this.getDouble() + scalar.getDouble()); } else if (this.getDataType().equals(XSD_INTEGER)) { this.setValue(this.getInt() + scalar.getInt()); } } /** * gets dictRef OR from parent. see * DictRefAttribute.getDictRefFromElementOrParent() * * @return the attribute or null */ public DictRefAttribute getDictRefFromElementOrParent() { return DictRefAttribute.getDictRefFromElementOrParent(this); } /** * sets units attribute. requires namespace for unit to be in scope. * * @param prefix * for namespace * @param id * for unit * @param namespaceURI * sets units namespace if not present already */ public void setUnits(String prefix, String id, String namespaceURI) { NamespaceRefAttribute.setUnits((HasUnits) this, prefix, id, namespaceURI); } /** null * @param value title value * THIS MENDS A BUG IN AUTOGENERATION OF AbstractScalar */ @Override public void setUnitType(String value) throws RuntimeException { NamespaceRefAttribute att = null; if (_att_unittype == null) { _att_unittype = new NamespaceRefAttribute("unitType", value); 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); } public Double getNumberAsDouble() { Double d = getDouble(); if (d == null || Double.isNaN(d)) { try { Integer i = getInt(); d = (double) i; } catch (Exception e) { // null } } return d; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLSpectator.java000077500000000000000000000302601477224461000263340ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import nu.xom.Elements; import nu.xom.Nodes; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; /** * user-modifiable class supporting spectator. * autogenerated from schema use * as a shell which can be edited * */ public class CMLSpectator extends AbstractSpectator implements ReactionComponent { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLSpectator() { } /** * contructor. * * @param old */ public CMLSpectator(CMLSpectator old) { super((AbstractSpectator) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLSpectator(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLSpectator */ public CMLElement makeElementInContext(Element parent) { return new CMLSpectator(); } // /** // * gets formula for cmlSpectator. // * // * If cmlSpectator has a child formula, returns it, else returns the formula // * on molecules, else null. Holds result in CMLFormula. // * // * @return the cmlSpectator stoichiometry // */ // public CMLFormula getFormula() { // CMLFormula formula = null; // CMLMolecule molecule = (CMLMolecule) this // .getFirstCMLChild(CMLMolecule.TAG); // if (molecule != null) { // formula = (CMLFormula) molecule.getFirstCMLChild("formula"); // if (formula == null) { // formula = molecule.calculateFormula( // CMLMolecule.HydrogenControl.USE_EXPLICIT_HYDROGENS); // } // } // return formula; // } /** * merge child molecules. * * A reaction may initally be created with the same cmlSpectator on both * sides (such as pseudo-reactant and pseudo-product). A true cmlSpectator * will remain unchanged in most respects (e.g. formalCharge, bondOrders) * but could have changes in 2D or 3D coordinates. This routine will merge * two such molecules into a normalized form. Thus: * *
     *      <cmlSpectator>
     *      <label dictRef="macie:sideChain" value="B-Glu147"/>
     *      <label dictRef="macie:hba" value="B-Glu147"/>
     *      <molecule id="0001.stg02.r.5">
     *      <atomArray>
     *      <atom id="a16" elementType="C" x2="-1.212" y2="0.6047"/>
     *      <atom id="a17" elementType="O" x2="-1.5775" y2="1.1841"/>
     *      <atom id="a18" elementType="O" x2="-1.5976" y2="0.1057"/>
     *      <atom id="a38" elementType="R" x2="-0.4945" y2="0.5889">
     *      <label value="B-Glu147"/>
     *      </atom>
     *      <atom id="a19" elementType="H" x2="-1.8016038" y2="-0.15829869"/>
     *      </atomArray>
     *      <bondArray id="b6">
     *      <bond atomRefs2="a16 a17" order="D" id="b2"/>
     *      <bond atomRefs2="a16 a18" order="S" id="b3"/>
     *      <bond atomRefs2="a38 a16" order="S" id="b4"/>
     *      <bond atomRefs2="a18 a19" order="S" id="b6"/>
     *      </bondArray>
     *      </molecule>
     *      <molecule id="0001.stg02.p.5">
     *      <atomArray>
     *      <atom id="a17" elementType="C" x2="11.6172" y2="0.5839"/>
     *      <atom id="a18" elementType="O" x2="11.2559" y2="1.1633"/>
     *      <atom id="a19" elementType="O" x2="11.2358" y2="0.0849"/>
     *      <atom id="a38" elementType="R" x2="12.3346" y2="0.5681">
     *      <label value="B-Glu147"/>
     *      </atom>
     *      <atom id="a20" elementType="H" x2="11.033881" y2="-0.17927846"/>
     *      </atomArray>
     *      <bondArray id="b8">
     *      <bond atomRefs2="a17 a18" order="D" id="b5"/>
     *      <bond atomRefs2="a17 a19" order="S" id="b6"/>
     *      <bond atomRefs2="a38 a17" order="S" id="b7"/>
     *      <bond atomRefs2="a19 a20" order="S" id="b8"/>
     *      </bondArray>
     *      </molecule>
     *      </cmlSpectator>
     *
     * 
* * would be changed to: * *
     *      <cmlSpectator>
     *      <label dictRef="macie:sideChain" value="B-Glu147"/>
     *      <label dictRef="macie:hba" value="B-Glu147"/>
     *      <molecule id="0001.stg02.r.5">
     *      <atomArray>
     *      <atom id="a16" elementType="C" x2="-1.212" y2="0.6047"/>
     *      <atom id="a17" elementType="O" x2="-1.5775" y2="1.1841"/>
     *      <atom id="a18" elementType="O" x2="-1.5976" y2="0.1057"/>
     *      <atom id="a38" elementType="R" x2="-0.4945" y2="0.5889">
     *      <label value="B-Glu147"/>
     *      </atom>
     *      <atom id="a19" elementType="H" x2="-1.8016038" y2="-0.15829869"/>
     *      </atomArray>
     *      <bondArray id="b6">
     *      <bond atomRefs2="a16 a17" order="D" id="b2"/>
     *      <bond atomRefs2="a16 a18" order="S" id="b3"/>
     *      <bond atomRefs2="a38 a16" order="S" id="b4"/>
     *      <bond atomRefs2="a18 a19" order="S" id="b6"/>
     *      </bondArray>
     *      </molecule>
     *      <molecule dx2="12.82" dy2="-0.02"/>
     *      </cmlSpectator>
     * 
* * note that the atomIds must match, but that the bondIds need not and are * replaced by the first set of bondIds. * * The method requires exactly two child molecules, with identical atom and * bond information (number, attributes/children, but not order). Bonds are * identified by their atomRefs, not their bondIDs. * * @throws RuntimeException * molecules cannot be matched */ public void mergeChildMolecules() { Elements molecules = this.getChildCMLElements(CMLMolecule.TAG); if (molecules.size() != 2) { throw new RuntimeException( "mergeChildMolecules requires exactly two child molecules"); } @SuppressWarnings("unused") CMLMolecule molecule0 = (CMLMolecule) molecules.get(0); @SuppressWarnings("unused") CMLMolecule molecule1 = (CMLMolecule) molecules.get(1); // molecule1.setIgnoreBondIDs(); this doesnt do anything // molecule0.mustEqual(molecule1); } /** * moves any pair of reactant and product with label to be child of * cmlSpectator. both reactant and product mut have at least one label * identical to the labelRef in the cmlSpectator * * @param reactProd * reactant or product to be moved * @param ref * labelRef (probably from this) * @throws RuntimeException */ public void moveLabelledReactantsProducts(Elements reactProd, String ref) { boolean matched = false; if (reactProd != null) { for (int j = 0; j < reactProd.size(); j++) { Elements labels = ((CMLElement) reactProd.get(j)) .getChildCMLElements(CMLLabel.TAG); for (int k = 0; k < labels.size(); k++) { CMLLabel label = (CMLLabel) labels.get(k); if (label.getValue().equals(ref)) { CMLMolecule molecule = (CMLMolecule) ((CMLElement) reactProd .get(j)).getFirstCMLChild(CMLMolecule.TAG); try { reactProd.get(j).detach(); this.appendChild(molecule); matched = true; } catch (NullPointerException e) { throw new RuntimeException("BUG " + e); } break; } } if (matched) { break; } } } if (!matched) { // Cannot find cmlSpectator "+ref+" for // "+((CMLReaction)cmlSpectator.getParentNode().getParentNode()).getId()); } } /** * get all descendant atoms. * * @return list of descendant atoms */ public List getAtoms() { return CMLReaction.getAtoms(this); } /** * get all descendant bonds. * * @return list of descendant bonds */ public List getBonds() { return CMLReaction.getBonds(this); } /** * get all descendant formulas. * * @return list of descendant formulas */ public List getFormulas() { return CMLReaction.getFormulas(this); } /** * get all descendant molecules. * * @return list of descendant molecules */ public List getMolecules() { return CMLReaction.getMolecules(this); } /** * gets descendant reactionComponents. only for interface compatibility * * @return always empty list */ public List getReactionComponentDescendants() { return new ArrayList(); } /** * gets child reactionComponents. only for interface compatibility * * @return always empty list */ public List getReactionComponentChildren() { return new ArrayList(); } public CMLMolecule getMolecule() { Nodes molecules = this.query("./*[local-name()='"+CMLMolecule.TAG+"']"); return (molecules.size() == 1) ? (CMLMolecule) molecules.get(0) : null; } public void addAmount(AbstractAmount amount) { amount.detach(); this.appendChild(amount); } public CMLElements getAmountElements() { Elements elements = this.getChildElements("amount", CMLConstants.CML_NS); return new CMLElements(elements); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLSpectatorList.java000077500000000000000000000133731477224461000271760ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import nu.xom.Elements; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; /** * user-modifiable class supporting spectatorList. * autogenerated from schema * use as a shell which can be edited * */ public class CMLSpectatorList extends AbstractSpectatorList implements ReactionComponent { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLSpectatorList() { } /** * contructor. * * @param old */ public CMLSpectatorList(CMLSpectatorList old) { super((AbstractSpectatorList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLSpectatorList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLSpectatorList */ public CMLElement makeElementInContext(Element parent) { return new CMLSpectatorList(); } /** * gets CMLSpectatorList from SpectatorListTool. * * gets molecules from all child spectators, distinguishing between * instances on product or reactant side * * @param productReactant * either SpectatorTool.PRODUCT or SpectatorTool.REACTANT * @return the molecules within all spectators or empty array if none */ public List getSpectatorMolecules(String productReactant) { Elements spectators = this.getChildCMLElements("spectator"); int serial = (productReactant.equals(CMLReactant.TAG)) ? 0 : 1; List moleculeList = new ArrayList(); for (int i = 0; i < spectators.size(); i++) { CMLMolecule molecule = (CMLMolecule) ((CMLSpectator) spectators .get(i)).getChildCMLElement(CMLMolecule.TAG, serial); if (molecule != null) { moleculeList.add(molecule); } } return moleculeList; } /** * get all descendant atoms. * * @return list of descendant atoms */ public List getAtoms() { return CMLReaction.getAtoms(this); } /** * get all descendant bonds. * * @return list of descendant bonds */ public List getBonds() { return CMLReaction.getBonds(this); } /** * get all descendant formulas. * * @return list of descendant formulas */ public List getFormulas() { return CMLReaction.getFormulas(this); } /** * get all descendant molecules. * * @return list of descendant molecules */ public List getMolecules() { return CMLReaction.getMolecules(this); } /** gets CMLSpectatorList from SpectatorListTool. * * gets molecules from all child spectators, distinguishing between instances on * product or reactant side * @param productReactant either SpectatorTool.PRODUCT or SpectatorTool.REACTANT * @return the molecules within all spectators or empty array if none */ public List getMolecules(ReactionComponent.Type productReactant) { CMLElements spectators = this.getSpectatorElements(); int serial = (productReactant.equals(ReactionComponent.Type.REACTANT)) ? 0 : 1; List moleculeList = new ArrayList(); for (CMLSpectator spectator : spectators) { CMLMolecule molecule = spectator.getMoleculeElements().get(serial); if (molecule != null) { moleculeList.add(molecule); } } return moleculeList; } /** * gets descendant reactionComponents. note that this will return all * containers as well as contained. thus calling this on: {@code * } will return 2 * components, reactantList, followed by reactant. * * @return empty if no components (some components such as CMLProduct will * always return this) */ public List getReactionComponentDescendants() { return CMLReaction.getReactionComponentDescendants(this, true); } /** * gets child reactionComponents. note that this will return containers but * not their contents. thus calling this on: {@code * } will return 1 components, * reactantList. * * @return empty if no components (some components such as CMLProduct will * always return this) */ public List getReactionComponentChildren() { return CMLReaction.getReactionComponentDescendants(this, false); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLSpectrum.java000077500000000000000000000162431477224461000261770ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import nu.xom.Node; import nu.xom.ParentNode; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; /** * user-modifiable class supporting spectrum. * autogenerated from schema use as * a shell which can be edited * */ public class CMLSpectrum extends AbstractSpectrum { public enum SpectrumType { /* * JCAMP has public final static int UNKNOWN = 0; public final static int INFRARED = 2 << 0; public final static int IR = 2 << 0; public final static int RAMAN = 2 << 1; public final static int ULTRAVIOLET = 2 << 2; public final static int UV = 2 << 2; public final static int FLUORESCENCE = 2 << 3; public final static int NMR = 2 << 4; public final static int MASS = 2 << 5; public final static int MS = 2 << 5; public final static int CHROMATOGRAM = 2 << 16; public final static int GC = 2 << 17 | CHROMATOGRAM; public final static int LC = 2 << 18 | CHROMATOGRAM; public final static int FID = 2 << 23; public final static int SPEC2D = 2 << 24; public final static int NMRFID = NMR | FID; public final static int NMR2D = NMR | SPEC2D; public final static int FLUORESCENCE2D = FLUORESCENCE | SPEC2D; public final static int GCMS = MS | GC; public final static int LCMS = MS | LC; */ UNKNOWN, IR, RAMAN, UV, FLUORESCENCE, NMR, MASS, CHROMATOGRAM, UNSUPPORTED } /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLSpectrum() { } /** * contructor. * * @param old */ public CMLSpectrum(CMLSpectrum old) { super((AbstractSpectrum) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLSpectrum(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLSpectrum */ public CMLElement makeElementInContext(Element parent) { return new CMLSpectrum(); } /** * gets molecule context for spectrum. In simple documents we assume that * molecules will occur as siblings of spectrum elements. There may be * several spectrums but only one molecule is allowed. * * @return the sibling molecule or null. * @throws RuntimeException * if there are duplicate sibling molecules */ public CMLMolecule getSiblingMolecule() { CMLMolecule molecule = null; ParentNode parent = this.getParent(); if (parent != null) { for (int i = 0; i < parent.getChildCount(); i++) { Node node = parent.getChild(i); if (node instanceof CMLMolecule) { if (molecule != null) { throw new RuntimeException("duplicate sibling molecules"); } molecule = (CMLMolecule) node; } } } return molecule; } /** * gets nearest ancestor spectrum element. * * @param element * descendant of spectrum * @return the owner spectrum or null if not found */ public static CMLSpectrum getSpectrum(CMLElement element) { CMLSpectrum spectrum = null; Node node = element; while (true) { ParentNode parent = node.getParent(); if (parent == null) { break; } else if (parent instanceof CMLSpectrum) { spectrum = (CMLSpectrum) parent; } node = parent; } return spectrum; } /** * returns aunt molecule of ancestor spectrum. * * @param element * to find aunt of. * @return the molecule or null if not found */ public static CMLMolecule getAuntMolecule(CMLElement element) { CMLMolecule molecule = null; CMLSpectrum spectrum = CMLSpectrum.getSpectrum(element); if (spectrum != null) { molecule = spectrum.getSiblingMolecule(); } return molecule; } /** * gets all peaks in this spectrum which couple to an atom * * @param atom * the atom the peaks should couple to * @return list of atom (zero length if none found) */ public List getCouplingsTo(CMLAtom atom) { List peaksFound = new ArrayList(); CMLMolecule molecule = atom.getMolecule(); CMLElements peakLists = getPeakListElements(); for (CMLPeakList peakList : peakLists) { CMLElements peaks = peakList.getPeakElements(); for (CMLPeak peak : peaks) { CMLElements peakStructures = peak .getPeakStructureElements(); for (CMLPeakStructure peakStructure : peakStructures) { List atoms = molecule.getAtomListByIds(peakStructure .getAtomRefs()); if (atoms.contains(atom)) peaksFound.add(peak); } } } return peaksFound; } /** * gets all descendant peaks. these can be in PeakList, PeakGroup or nested * PeakGroup * * @param element * which owns the descendants (normally a Spectrum, PeakList or * PeakGroup * @return list of peaks (zero length if null) */ public static List getDescendantPeaks(CMLElement element) { List peakList = new ArrayList(); getDescendantPeaks(element, peakList); return peakList; } private static void getDescendantPeaks(CMLElement element, List peakList) { if (element != null && element instanceof CMLElement) { for (CMLElement child : element.getChildCMLElements()) { if (child instanceof CMLPeak) { peakList.add((CMLPeak) child); } else { getDescendantPeaks(child, peakList); } } } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLSpectrumData.java000077500000000000000000000033611477224461000267660ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting spectrumData. * autogenerated from schema * use as a shell which can be edited * */ public class CMLSpectrumData extends AbstractSpectrumData { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLSpectrumData() { } /** * contructor. * * @param old */ public CMLSpectrumData(CMLSpectrumData old) { super((AbstractSpectrumData) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLSpectrumData(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLSpectrumData */ public CMLElement makeElementInContext(Element parent) { return new CMLSpectrumData(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLSpectrumList.java000077500000000000000000000033611477224461000270300ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting spectrumList. * autogenerated from schema * use as a shell which can be edited * */ public class CMLSpectrumList extends AbstractSpectrumList { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLSpectrumList() { } /** * contructor. * * @param old */ public CMLSpectrumList(CMLSpectrumList old) { super((AbstractSpectrumList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLSpectrumList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLSpectrumList */ public CMLElement makeElementInContext(Element parent) { return new CMLSpectrumList(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLSphere3.java000077500000000000000000000032771477224461000257110ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting sphere3. * autogenerated from schema use as * a shell which can be edited * */ public class CMLSphere3 extends AbstractSphere3 { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLSphere3() { } /** * contructor. * * @param old */ public CMLSphere3(CMLSphere3 old) { super((AbstractSphere3) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLSphere3(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLSphere3 */ public CMLElement makeElementInContext(Element parent) { return new CMLSphere3(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLSubstance.java000077500000000000000000000033231477224461000263170ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting substance. * autogenerated from schema use * as a shell which can be edited * */ public class CMLSubstance extends AbstractSubstance { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLSubstance() { } /** * contructor. * * @param old */ public CMLSubstance(CMLSubstance old) { super((AbstractSubstance) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLSubstance(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLSubstance */ public CMLElement makeElementInContext(Element parent) { return new CMLSubstance(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLSubstanceList.java000077500000000000000000000035001477224461000271500ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting substanceList. * autogenerated from schema * use as a shell which can be edited * */ public class CMLSubstanceList extends AbstractSubstanceList { /** */ public final static String TAG = "substanceList"; /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLSubstanceList() { } /** * contructor. * * @param old */ public CMLSubstanceList(CMLSubstanceList old) { super((AbstractSubstanceList) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLSubstanceList(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLSubstanceList */ public CMLElement makeElementInContext(Element parent) { return new CMLSubstanceList(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLSymmetry.java000077500000000000000000000352041477224461000262240ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.List; import nu.xom.Element; import nu.xom.Nodes; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.euclid.Point3; /** * user-modifiable class supporting symmetry. * autogenerated from schema use as * a shell which can be edited * */ public class CMLSymmetry extends AbstractSymmetry { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * constructor. */ public CMLSymmetry() { } /** * constructor. * * @param old */ public CMLSymmetry(CMLSymmetry old) { super((AbstractSymmetry) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLSymmetry(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLSymmetry */ public CMLSymmetry makeElementInContext(Element parent) { return new CMLSymmetry(); } /** * create from crystallographic operators. example: "x, y, z", "-x+1/2, -y, * z+1/2", "x+1/2, -y+1/2, -z", "-x, y+1/2, -z+1/2", "-x, -y, -z", "x-1/2, * y, -z-1/2", "-x-1/2, y-1/2, z", "x, -y-1/2, z-1/2", for spacegroup Pbca * * @param xyz * the strings */ public CMLSymmetry(String[] xyz) { this(); for (String s : xyz) { CMLTransform3 t = new CMLTransform3(s); this.addTransform3(t); } } /** * create from list of transforms. does not check any validity (e.g. may not * be a group) * * @param trList transforms to add */ public CMLSymmetry(List trList) { this(); for (CMLTransform3 tr : trList) { this.addTransform3(tr); } } /** * create from list of transforms. does not check any validity (e.g. may not * be a group) * * @param trStringList transforms to add * @return the symmetry operations */ public static CMLSymmetry createFromXYZStrings(List trStringList) { List trList = new ArrayList(); for (String trString : trStringList) { trList.add(new CMLTransform3(trString)); } return new CMLSymmetry(trList); } /** * creates a new symmetry as the product of two others. combines each * element of this with each of sym and elimnates duplicates brute force - * multiplying two cubic space groups might take a little time * * @param sym * @return CMLSymmetry contains CMLTransform for * this.t[i].concatenate(sym.t[j]) */ public CMLSymmetry convolute(CMLSymmetry sym) { List trList = new ArrayList(); for (CMLTransform3 tr2 : this.getTransform3Elements()) { for (CMLTransform3 tr3 : sym.getTransform3Elements()) { CMLTransform3 trNew = tr2.concatenate(tr3); if (CMLTransform3.indexOf(trList, trNew, EPS) == -1) { trList.add(trNew); } } } return new CMLSymmetry(trList); } /** * are two symmetrys equal. * iterates through all elements in case order varies. * * @param sym to compare * @param eps max deviation of elements * @return true if equal */ public boolean isEqualTo(CMLSymmetry sym, double eps) { // first check in case they are lexically equivalent boolean equals = false; // boolean equals = CMLUtil.equalsCanonically(this, sym, true); // if (!equals) { CMLElements thisTrs = this.getTransform3Elements(); CMLElements symTrs = sym.getTransform3Elements(); if (thisTrs.size() == symTrs.size()) { for (int i = 0; i < thisTrs.size(); i++) { equals = false; for (int j = 0; j < symTrs.size(); j++) { if (thisTrs.get(i).isEqualTo(symTrs.get(j), eps)) { equals = true; break; } } if (!equals) { break; } } } // } return equals; } /** normalizes all transform3 children. see * CMLTransform.normalizeCrystallographically() * */ public void normalizeCrystallographically() { for (CMLTransform3 t : this.getTransform3Elements()) { t.normalizeCrystallographically(); } } /** * gets all symmetry operations that do not have translations. uses * CMLTransform3.hasNonZeroTranslationComponent the result may or may not be * a group or spacegroup but will (I think) be group generators * * @return the symmetry */ public CMLSymmetry getNonTranslations() { CMLSymmetry newSymmetry = new CMLSymmetry(); CMLElements symmetryElements = this.getTransform3Elements(); for (CMLTransform3 tr : symmetryElements) { if (!tr.hasNonZeroTranslationComponent() && !tr.isUnit()) { newSymmetry.addTransform3(new CMLTransform3(tr)); } } return newSymmetry; } /** gets all symmetry operations that have pure translations. uses * CMLTransform3.isPureTranslation does not include the identity operation * the result should provide the centering for the cell. * * @return the symmetry */ public List getPureTranslations() { List translations = new ArrayList(); CMLElements symmetryElements = this .getTransform3Elements(); for (CMLTransform3 tr : symmetryElements) { if (tr.isPureTranslation()) { translations.add(new CMLTransform3(tr)); } } return translations; } /** * gets centring from symmetry operators. * * @return centering or UNKNOWN */ public CMLCrystal.Centering getCentering() { return CMLSymmetry.getCentering(this.getPureTranslations()); } /** * matches list of translations into centering type. * * @param transformList * @return centering */ static CMLCrystal.Centering getCentering(List transformList) { CMLCrystal.Centering centering = CMLCrystal.Centering.P; if (transformList.size() == 0) { } else if (transformList.size() == 1) { if (transformList.get(0).isEqualTo( CMLCrystal.Centering.A.translations.get(0))) { centering = CMLCrystal.Centering.A; } else if (transformList.get(0).isEqualTo( CMLCrystal.Centering.B.translations.get(0))) { centering = CMLCrystal.Centering.B; } else if (transformList.get(0).isEqualTo( CMLCrystal.Centering.C.translations.get(0))) { centering = CMLCrystal.Centering.C; } else if (transformList.get(0).isEqualTo( CMLCrystal.Centering.I.translations.get(0))) { centering = CMLCrystal.Centering.I; } else { centering = CMLCrystal.Centering.UNKNOWN; } } else if (transformList.size() == 2) { centering = CMLCrystal.Centering.R; for (CMLTransform3 transform : transformList) { if (transform.isEqualTo(CMLCrystal.Centering.R.translations .get(0)) || transform .isEqualTo(CMLCrystal.Centering.R.translations .get(1))) { } else { centering = CMLCrystal.Centering.UNKNOWN; break; } } } else if (transformList.size() == 3) { centering = CMLCrystal.Centering.F; for (CMLTransform3 transform : transformList) { if (transform.isEqualTo(CMLCrystal.Centering.F.translations .get(0)) || transform .isEqualTo(CMLCrystal.Centering.F.translations .get(1)) || transform .isEqualTo(CMLCrystal.Centering.F.translations .get(2))) { } else { centering = CMLCrystal.Centering.UNKNOWN; break; } } } return centering; } /** * do the elements form a group. translation is included but not normalized * (see isSpaceGroup()) iterates through all n^2 combinations (a*b and b*a) * and tests them against group members. therefore O(n^3) and expensive for * (say) spacegroups with 192 elements * * @return true if group */ public boolean isGroup() { this.normalizeCrystallographically(); CMLElements transform3s = this.getTransform3Elements(); int i = 0; boolean group = false; for (CMLTransform3 tr1 : transform3s) { int j = 0; for (CMLTransform3 tr2 : transform3s) { CMLTransform3 tr3 = tr1.concatenate(tr2); group = false; for (CMLTransform3 tr : transform3s) { if (tr.isEqualTo(tr3, EPS)) { group = true; break; } } if (!group) { // LOG.debug("operators "+i+" and "+j+" do not // generate a group element: "); break; } j++; } i++; } return group; } /** * do the elements form a spacegroup. operates on a cpoy so does not * normalize this translation is normalized to range 0 -> 1-eps iterates * through all n^2 combinations (a*b and b*a) and tests them against group * members * * @return true if group */ public boolean isSpaceGroup() { CMLSymmetry symmetryCopy = new CMLSymmetry(this); symmetryCopy.normalizeCrystallographically(); CMLElements transform3s = symmetryCopy .getTransform3Elements(); int i = 0; boolean group = false; for (CMLTransform3 tr1 : transform3s) { int j = 0; for (CMLTransform3 tr2 : transform3s) { CMLTransform3 tr3 = tr1.concatenate(tr2); tr3.normalizeCrystallographically(); group = false; for (CMLTransform3 tr : transform3s) { if (tr.isEqualTo(tr3, EPS)) { group = true; break; } } if (!group) { // LOG.debug("operators "+i+" and "+j+" do not generate a group element: "); break; } j++; } i++; } return group; } /** * gets count of operations which transform point into itself. applies all * opertions to point and count which transform point into itself WITHOUT * crystallographic normalisation * * @param point * @param eps * tolerance for agreement * @return the multiplicity */ public int getPointGroupMultiplicity(Point3 point, double eps) { int operatorCount = 0; CMLElements transforms = this.getTransform3Elements(); for (CMLTransform3 tr : transforms) { Point3 newPoint = tr.transform(point); if (newPoint.isEqualTo(point, eps)) { operatorCount++; } } return operatorCount; } /** gets count of operations which transform point into itself. applies all * operations to point and count which transform point into itself WITH * crystallographic normalisation * * @param point * @return multiplicity */ public int getSpaceGroupMultiplicity(Point3 point) { int operatorCount = 0; if (point != null) { CMLElements transforms = this.getTransform3Elements(); for (CMLTransform3 tr : transforms) { Point3 newPoint = tr.transform(point); if (newPoint.equalsCrystallographically(point)) { operatorCount++; } } } return operatorCount; } /** convenience method to get a single symmetry descendant of an element. * * @param element to search under * @return the symmetry * @throws RuntimeException if 0 or >1 nodes */ //TODO should this really call a RunTimeException? public static CMLSymmetry getContainedSymmetry(CMLElement element) throws RuntimeException { Nodes symmetryNodes = element.query(".//"+CMLSymmetry.NS, CMLConstants.CML_XPATH); if (symmetryNodes.size() == 0) { throw new RuntimeException("NO FOUND"); } else if (symmetryNodes.size() > 1) { throw new RuntimeException("TOO MANY FOUND "+symmetryNodes.size()); } return (CMLSymmetry) symmetryNodes.get(0); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLSystem.java000077500000000000000000000032651477224461000256610ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting system. * autogenerated from schema use as a * shell which can be edited * */ public class CMLSystem extends AbstractSystem { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLSystem() { } /** * contructor. * * @param old */ public CMLSystem(CMLSystem old) { super((AbstractSystem) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLSystem(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLSystem */ public CMLElement makeElementInContext(Element parent) { return new CMLSystem(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLTable.java000077500000000000000000000327051477224461000254250ustar00rootroot00000000000000/** * 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 java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.List; import nu.xom.Element; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; /** * user-modifiable class supporting table. * * A table is not valid unless it has a tableType attribute set to * one of the allowed values of the TableType enum. Each of these requires * further constraints * @see AbstractTable * */ public class CMLTable extends AbstractTable { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** types of table. * @author pm286 * */ public enum TableType { /** columns */ COLUMN_BASED("columnBased"), /** rows */ ROW_BASED("rowBased"), /** content */ CONTENT_BASED("contentBased"); /** string value */ public String value; private TableType(String v) { this.value = v; } /** get type. * * @param t * @return type */ public static TableType getTableType(String t) { TableType tt = null; for (TableType v : TableType.values()) { if (v.value.equals(t)) { tt = v; break; } } return tt; } } /** * contructor. */ public CMLTable() { } /** * contructor. * * @param old */ public CMLTable(CMLTable old) { super((AbstractTable) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLTable(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLTable */ public CMLElement makeElementInContext(Element parent) { return new CMLTable(); } /** * gets the row count. first from rows attribute and if missing from the * actual count. * * @return row count (0 if none or no columns) * @throws RuntimeException * irregular table */ public int getRows() { int rows = 0; if (this.getRowsAttribute() != null) { rows = super.getRows(); } else { CMLArrayList arrayList = (CMLArrayList) this.getFirstCMLChild(CMLArrayList.TAG); if (arrayList != null) { rows = arrayList.getRowCount(); } } return rows; } /** old method for accessing table columns. * @deprecated * @return arrayElements or null */ public CMLElements getArrayElements() { CMLElements arrayElements = null; CMLArrayList arrayList = (CMLArrayList) this.getFirstCMLChild(CMLArrayList.TAG); if (arrayList != null) { arrayElements = arrayList.getArrayElements(); } return arrayElements; } /** set type. * overrides simple set and checks content * @param t * @throws RuntimeException for inconsistent table */ public void setTableType(String t) { TableType tt = TableType.getTableType(t); if (tt == null) { throw new RuntimeException("Bad table type: "+t); } if (check(tt)) { super.setTableType(t); } else { throw new RuntimeException("bad table"); } } /** sets table type through enum. * This is the safest way to set the type as it is guaranteed * to use a known type. * @param tt */ public void setTableType(TableType tt) { if (tt != null) { this.setTableType(tt.value); } } /** get type of table as enum. * @return null if tableType attribute is null or unknown */ public TableType getTableTypeEnum() { String tableType =this.getTableType(); return TableType.getTableType(tableType); } @SuppressWarnings("unused") private void checkRowsAndColumns() { if (this.getRowsAttribute() == null || this.getColumnsAttribute() == null) { throw new RuntimeException("Must give rows and columns attributes"); } } /** checkes compatibility of current table with table type. * See schema for details * @param t * @return validity */ public boolean check(TableType t) { CMLTableHeader header = (CMLTableHeader) this.getFirstCMLChild(CMLTableHeader.TAG); CMLArrayList arrayList = (CMLArrayList) this.getFirstCMLChild(CMLArrayList.TAG); CMLTableContent content = (CMLTableContent) this.getFirstCMLChild(CMLTableContent.TAG); CMLTableRowList rowList = (CMLTableRowList) this.getFirstCMLChild(CMLTableRowList.TAG); boolean check = false; // attributes are set before content if (header == null && arrayList == null && content == null && rowList == null) { check = true; } else if (t == null) { check = header == null && arrayList == null && content == null && rowList == null; } else if (TableType.COLUMN_BASED.equals(t)) { check = header == null && arrayList != null && content == null && rowList == null; } else if (TableType.CONTENT_BASED.equals(t)) { check = header != null && arrayList == null && content != null && rowList == null; } else if (TableType.ROW_BASED.equals(t)) { check = header != null && arrayList == null && content == null && rowList != null; } return check; } /** gets arrayList or creates one if allowed. * if arrayList does not exist, creates it if table is of * type columnBased */ private CMLArrayList getOrCreateArrayList() { CMLArrayList arrayList = (CMLArrayList) this.getFirstCMLChild(CMLArrayList.TAG); if (arrayList == null && TableType.COLUMN_BASED.value.equals(this.getTableType())) { if (this.getTableContentElements().size() == 0 && this.getTableRowListElements().size() == 0) { arrayList = new CMLArrayList(); this.appendChild(arrayList); } } return arrayList; } /** gets tableRowList or creates one if allowed. * if tableRowList does not exist, creates it if table is of * type rowBased */ private CMLTableRowList getOrCreateTableRowList() { CMLTableRowList tableRowList = (CMLTableRowList) this.getFirstCMLChild(CMLTableRowList.TAG); if (tableRowList == null && TableType.ROW_BASED.value.equals(this.getTableType())) { if (this.getTableContentElements().size() == 0 && this.getTableRowListElements().size() == 0) { tableRowList = new CMLTableRowList(); this.appendChild(tableRowList); } } return tableRowList; } /** old method for adding column. * @deprecated (why?) use TableTool for cells * @param array column to add */ public void addArray(CMLArray array) { if (check(TableType.COLUMN_BASED)) { CMLArrayList arrayList = this.getOrCreateArrayList(); arrayList.appendChild(array); } } /** * get column count. uses value of columns attribute if present else counts * arrays. * * @return column count */ public int getColumns() { int columns = -1; if (this.getColumnsAttribute() != null) { columns = super.getColumns(); } else { CMLArrayList arrayList = (CMLArrayList) this.getFirstCMLChild(CMLArrayList.TAG); CMLTableHeader tableHeader = (CMLTableHeader) this.getFirstCMLChild(CMLTableHeader.TAG); if (arrayList != null) { columns = arrayList.getArraysCount(); } else if (tableHeader != null) { columns = tableHeader.getColumnCount(); } } return columns; } @SuppressWarnings("unused") private CMLElements getTableRowElements() { CMLElements tableRowElements = null; if (check(TableType.ROW_BASED)) { CMLTableRowList tableRowList = this.getOrCreateTableRowList(); tableRowElements = tableRowList.getTableRowElements(); } return tableRowElements; } /** * get values columnwise. * * @return List of column Values (zero length if none) * @throws RuntimeException * columns inconsistent */ public List> getColumnValuesList() { List> stringListList = new ArrayList>(); CMLElements arrays = this.getArrayElements(); int rows = -1; for (CMLArray array : arrays) { List strings = array.getStringValues(); int nr = strings.size(); if (rows == -1) { rows = nr; } else if (rows != nr) { throw new RuntimeException("inconsistent row lengths: " + rows + CMLConstants.S_SLASH + nr); } stringListList.add(strings); } return stringListList; } @SuppressWarnings("unused") private void writeArrays(Writer w, List> stringListList) throws IOException { if (check(TableType.COLUMN_BASED)) { int columnCount = stringListList.size(); int rowCount = stringListList.get(0).size(); CMLElements arrays = this.getArrayListElements(); // titles w.write("\n"); for (Object object : arrays) { w.write(""); w.write(((Element)object).getAttributeValue("title")); w.write(""); } w.write(""); for (int i = 0; i < rowCount; i++) { w.write("\n"); for (int j = 0; j < columnCount; j++) { w.write(""); List col = stringListList.get(j); w.write(col.get(i)); w.write(""); } w.write(""); } } } @SuppressWarnings("unused") private void writeRows(Writer w, CMLTableHeader header, CMLElements rows) throws IOException { header.writeHTML(w); int ncols = -1; for (CMLTableRow row : rows) { int nc = row.getTableCellElements().size(); if (ncols == -1) { nc = ncols; } else if (nc != ncols) { throw new RuntimeException("inconsistent column length in rows: " + nc + CMLConstants.S_SLASH + ncols); } row.writeHTML(w); } } @SuppressWarnings("unused") private void writeContent(Writer w, CMLTableHeader header, CMLTableContent content) throws IOException, RuntimeException { header.writeHTML(w); int ncols = header.getColumnCount(); String[] strings = content.getStrings(); if (strings.length % ncols != 0) { throw new RuntimeException("non-rectangular table: " + strings.length + CMLConstants.S_SLASH + ncols); } int count = 0; for (String string : strings) { if (count % ncols == 0) { w.write("\n"); } w.write("" + string + ""); if (++count % ncols == 0) { w.write(""); } } } /** makes a list of CMLTables * * @param elements * @return List<CMLTable> */ public static List extractTables(List elements) { List tableList = new ArrayList(); for (Element element : elements) { if (element instanceof CMLTable) { tableList.add((CMLTable) element); } } return tableList; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLTableCell.java000077500000000000000000000116361477224461000262250ustar00rootroot00000000000000/** * 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. */ // /*======AUTOGENERATED FROM SCHEMA; DO NOT EDIT BELOW THIS LINE ======*/ package org.xmlcml.cml.element; import java.io.IOException; import java.io.Writer; import nu.xom.Element; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLUtil; /** A cell in a row of a table. * * * tableCell \nis a data container of the table. Normally it contains\n simpleType, but may also contain a single child element. \nIt should NOT directly contain multiple children of any sort. * * user-modifiable class autogenerated from schema if no class exists * use as a shell which can be edited * the autogeneration software will not overwrite an existing class file */ public class CMLTableCell extends org.xmlcml.cml.element.AbstractTableCell { /** must give simple documentation. * */ public CMLTableCell() { } /** must give simple documentation. * * @param old CMLTableCell to copy */ public CMLTableCell(CMLTableCell old) { super((org.xmlcml.cml.element.AbstractTableCell) old); } /** constructor. * * @param s string content */ public CMLTableCell(String s) { this(); CMLUtil.setXMLContent(this, s); } /** constructor. * * @param d double content */ public CMLTableCell(double d) { this(); CMLUtil.setXMLContent(this, CMLConstants.S_EMPTY+d); } /** constructor. * * @param i int content */ public CMLTableCell(int i) { this(); CMLUtil.setXMLContent(this, CMLConstants.S_EMPTY+i); } /** constructor. * * @param element content */ public CMLTableCell(Element element) { this(); this.appendChild(element); } /** copy node . * * @return Node */ public Element copy() { return new CMLTableCell(this); } /** create new instance in context of parent, overridable by subclasses. * * @param parent parent of element to be constructed (ignored by default) * @return CMLTableCell */ public CMLElement makeElementInContext(Element parent) { return new CMLTableCell(); } /** gets double. * does not check dataType at present. * @return double */ public double getDouble() { double d = Double.NaN; try { d = Double.valueOf(this.getValue()).doubleValue(); } catch (NumberFormatException e) { throw new RuntimeException(e); } return d; } /** gets integer. * does not check dataType at present. * @return integer */ public double getInt() { int i = -Integer.MAX_VALUE; try { i =Integer.parseInt(this.getValue()); } catch (NumberFormatException e) { throw new RuntimeException(e); } return i; } /** * write cell to HTML table. * * @param w * writer * @throws IOException */ public void writeHTML(Writer w) throws IOException { w.write(""); String s = this.getStringContent(); w.write((s == null) ? CMLConstants.S_EMPTY : s); w.write(""); } /** append value of cell to array. * checks dataType. * @param dataType * @param array */ public void appendValueTo(String dataType, CMLArray array) { if (array == null) { throw new RuntimeException("cannot add null array"); } if (XSD_DOUBLE.equals(dataType)) { if (!XSD_DOUBLE.equals(array.getDataType())) { throw new RuntimeException("Inconsistent dataTypes: " +dataType+S_SPACE+array.getDataType()); } array.append(this.getDouble()); } else if (XSD_INTEGER.equals(dataType)) { if (!XSD_INTEGER.equals(array.getDataType())) { throw new RuntimeException("Inconsistent dataTypes: " +dataType+S_SPACE+array.getDataType()); } array.append(this.getInt()); } else { array.append(this.getValue()); } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLTableContent.java000077500000000000000000000075541477224461000267640ustar00rootroot00000000000000/** * 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. */ // /*======AUTOGENERATED FROM SCHEMA; DO NOT EDIT BELOW THIS LINE ======*/ package org.xmlcml.cml.element; import nu.xom.Element; import org.xmlcml.cml.base.CMLElement; /** * Unmarked content of a table. * * * \n Metadata for rows must be defined in tableHeader. The elements of the\n * table are ASCII strings in this content. They can be separated by * whitespace\n or by a defined single character delimiter (see array for more * information).\n \n * * user-modifiable class autogenerated from schema if no class exists use as a * shell which can be edited the autogeneration software will not overwrite an * existing class file * */ public class CMLTableContent extends AbstractTableContent { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * must give simple documentation. */ public CMLTableContent() { } /** * must give simple documentation. * * @param old * CMLTableContent to copy * */ public CMLTableContent(CMLTableContent old) { super((AbstractTableContent) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLTableContent(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLTableContent */ public CMLElement makeElementInContext(Element parent) { return new CMLTableContent(); } /** sets delimiter if non-nul or non-whitespace. * if slashDelim is null or whitespace removes the attribute * @param delim */ public void setDelimiter(String delim) { if (delim == null || S_EMPTY.equals(delim.trim())) { this.removeAttribute("delimiter"); } else { super.setDelimiter(delim); } } /** * get content as strings. not yet edited for delimiters * * @return strings */ public String[] getStrings() { String content = this.getStringContent().trim(); String delimiter = (this.getDelimiterAttribute() == null) ? S_WHITEREGEX : this.getDelimiter(); // trim leading and trailing delimiters if (content.startsWith(delimiter)) { content = content.substring(1); } if (content.startsWith(delimiter)) { content = content.substring(0, content.length()-1); } return content.split(delimiter); } StringBuilder sb = null; void append(String s, String delimiter) { String dd = (delimiter == null || S_EMPTY.equals(delimiter.trim())) ? S_SPACE : delimiter; if (sb == null) { sb = new StringBuilder(); } else { sb.append(dd); } sb.append(s); } void finishAppendingStrings(String delimiter) { if (sb != null) { if (delimiter != null) { sb.append(delimiter); } this.setXMLContent(sb.toString()); } sb = null; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLTableHeader.java000077500000000000000000000066761477224461000265460ustar00rootroot00000000000000/** * 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. */ // /*======AUTOGENERATED FROM SCHEMA; DO NOT EDIT BELOW THIS LINE ======*/ package org.xmlcml.cml.element; import java.io.IOException; import java.io.Writer; import nu.xom.Element; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; /** * Header for a table. * * * \n Used when the content is tableRows or tableContent. Contains the metadata * as \narrays.\n * * user-modifiable class autogenerated from schema if no class exists use as a * shell which can be edited the autogeneration software will not overwrite an * existing class file * */ public class CMLTableHeader extends AbstractTableHeader { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * must give simple documentation. */ public CMLTableHeader() { } /** * must give simple documentation. * * @param old * CMLTableHeader to copy * */ public CMLTableHeader(CMLTableHeader old) { super((AbstractTableHeader) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLTableHeader(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLTableHeader */ public CMLElement makeElementInContext(Element parent) { return new CMLTableHeader(); } /** write header to HTML table. * * @param w * writer * @throws IOException */ public void writeHTML(Writer w) throws IOException { w.write("\n"); CMLElements tableHeaderCells = this.getTableHeaderCellElements(); for (CMLTableHeaderCell tableHeaderCell : tableHeaderCells) { tableHeaderCell.writeHTML(w); } w.write(""); } // /** // * get titles. searches for row with dictRef='title' // * // * @return list of strings in that row or empty list // */ // public List getTitles() { // List titleList = new ArrayList(); // CMLElements cells = this.getTableHeaderCellElements(); // for (CMLTableHeaderCell cell : cells) { // titleList.add(cell.getTitle()); // } // return titleList; // } // /** * gets count of columns. * * @return count (or -1) * @throws RuntimeException * inconsistent count */ public int getColumnCount() throws RuntimeException { int ncols = this.getTableHeaderCellElements().size(); return ncols; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLTableHeaderCell.java000077500000000000000000000062631477224461000273360ustar00rootroot00000000000000/** * 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. */ // /*======AUTOGENERATED FROM SCHEMA; DO NOT EDIT BELOW THIS LINE ======*/ package org.xmlcml.cml.element; import java.io.IOException; import java.io.Writer; import nu.xom.Element; import org.xmlcml.cml.base.CMLElement; /** Metadata for a column of a table. * * * Must be used in conjunction with multiplierToSI and/or constantToSI * * user-modifiable class autogenerated from schema if no class exists * use as a shell which can be edited * the autogeneration software will not overwrite an existing class file */ public class CMLTableHeaderCell extends org.xmlcml.cml.element.AbstractTableHeaderCell { /** must give simple documentation. * */ public CMLTableHeaderCell() { } /** must give simple documentation. * * @param old CMLTableHeaderCell to copy */ public CMLTableHeaderCell(CMLTableHeaderCell old) { super((org.xmlcml.cml.element.AbstractTableHeaderCell) old); } /** copy node . * * @return Node */ public Element copy() { return new CMLTableHeaderCell(this); } /** create new instance in context of parent, overridable by subclasses. * * @param parent parent of element to be constructed (ignored by default) * @return CMLTableHeaderCell */ public CMLElement makeElementInContext(Element parent) { return new CMLTableHeaderCell(); } /** create CMLArray with attributes from this. * * @return array */ public CMLArray createCMLArray() { CMLArray array = new CMLArray(); if (this.getDataTypeAttribute() != null) { array.setDataType(this.getDataType()); } if (this.getDictRefAttribute() != null) { array.setDictRef(this.getDictRef()); } if (this.getTitleAttribute() != null) { array.setTitle(this.getTitle()); } if (this.getConventionAttribute() != null) { array.setConvention(this.getConvention()); } if (this.getIdAttribute() != null) { array.setId(this.getId()); } return array; } /** write as HTML. * * @param w writer * @throws IOException */ public void writeHTML(Writer w) throws IOException { String dictRef = this.getDictRef(); w.write(""); w.write(this.getTitle()); w.write(""); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLTableRow.java000077500000000000000000000072221477224461000261110ustar00rootroot00000000000000/** * 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. */ // /*======AUTOGENERATED FROM SCHEMA; DO NOT EDIT BELOW THIS LINE ======*/ package org.xmlcml.cml.element; import java.io.IOException; import java.io.Writer; import nu.xom.Element; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.base.CMLUtil; /** * Explicit row of a table. * * * \n Metadata for rows must be defined in tableHeader.\n * * user-modifiable class autogenerated from schema if no class exists use as a * shell which can be edited the autogeneration software will not overwrite an * existing class file * */ public class CMLTableRow extends AbstractTableRow { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * must give simple documentation. * * */ public CMLTableRow() { } /** * must give simple documentation. * * @param old * CMLTableRow to copy * */ public CMLTableRow(CMLTableRow old) { super((AbstractTableRow) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLTableRow(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLTableRow */ public CMLElement makeElementInContext(Element parent) { return new CMLTableRow(); } /** * write row to HTML table. * * @param w * writer * @throws IOException */ public void writeHTML(Writer w) throws IOException { w.write("\n"); CMLElements tableCells = this.getTableCellElements(); for (CMLTableCell tableCell : tableCells) { tableCell.writeHTML(w); } w.write(""); } /** delimited string. * if delimiter is space (generic whitespace) interposes single * spaces. If content strings already have whitespace throws * exception. If delimiter is not whitspace adds delimiter at * inside row but not at ends * @param delimiter * @return delimited string */ public String getDelimitedString(String delimiter) { String delim = (delimiter == null || S_EMPTY.equals(delimiter)) ? S_SPACE : delimiter; boolean trim = S_SPACE.equals(delim); StringBuilder sb = new StringBuilder(); CMLElements tableCells = this.getTableCellElements(); int count = 0; int last = tableCells.size(); for (CMLTableCell tableCell : tableCells) { String s = CMLUtil.getXMLContent(tableCell); if (trim) { s.trim(); } sb.append(s); if (count++ < last-1) { sb.append(delim); } } return sb.toString(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLTableRowList.java000077500000000000000000000036561477224461000267540ustar00rootroot00000000000000/** * 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. */ // /*======AUTOGENERATED FROM SCHEMA; DO NOT EDIT BELOW THIS LINE ======*/ package org.xmlcml.cml.element; import nu.xom.Element; import org.xmlcml.cml.base.CMLElement; /** List of rows in rowBased table. * * * \n Metadata for rows must be defined in tableHeader.\n * * user-modifiable class autogenerated from schema if no class exists * use as a shell which can be edited * the autogeneration software will not overwrite an existing class file */ public class CMLTableRowList extends AbstractTableRowList { /** must give simple documentation. * */ public CMLTableRowList() { } /** must give simple documentation. * * @param old CMLTableRowList to copy */ public CMLTableRowList(CMLTableRowList old) { super((org.xmlcml.cml.element.AbstractTableRowList) old); } /** copy node . * * @return Node */ public Element copy() { return new CMLTableRowList(this); } /** create new instance in context of parent, overridable by subclasses. * * @param parent parent of element to be constructed (ignored by default) * @return CMLTableRowList */ public CMLElement makeElementInContext(Element parent) { return new CMLTableRowList(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLTorsion.java000077500000000000000000000266441477224461000260400ustar00rootroot00000000000000/** * 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 java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import nu.xom.Element; import nu.xom.Nodes; import org.apache.log4j.Logger; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.euclid.Angle; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Util; /** * user-modifiable class supporting torsion. * autogenerated from schema use as * a shell which can be edited * */ public class CMLTorsion extends AbstractTorsion { final static Logger logger = Logger.getLogger(CMLTorsion.class.getName()); /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLTorsion() { } /** * contructor. * * @param old */ public CMLTorsion(CMLTorsion old) { super((AbstractTorsion) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLTorsion(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLTorsion */ public CMLElement makeElementInContext(Element parent) { return new CMLTorsion(); } /** * gets atomIds as list. * * @return the atomIds (null if no atomRefs4) */ public List getAtomIds() { List idList = null; String[] atomRefs4 = getAtomRefs4(); if (atomRefs4 != null) { idList = new ArrayList(); for (String s : atomRefs4) { idList.add(s); } } return idList; } /** * gets atomRefs4 as list of atoms. * * uses the value in 'torsion' element * * @param molecule * @return the atoms (null if no atomRefs4) */ public List getAtoms(CMLMolecule molecule) { List atomList = null; String[] atomRefs4 = this.getAtomRefs4(); if (atomRefs4 == null || molecule == null) { throw new RuntimeException( "torsion must have molecule ("+molecule+") and atomRefs4 ("+atomRefs4+") to get atoms: "+this.toXML()); } else { atomList = new ArrayList(); for (String atomRef : atomRefs4) { CMLAtom atom = molecule.getAtomById(atomRef); if (atom == null) { throw new RuntimeException("cannot find atom " + atomRef); } atomList.add(atom); } } return atomList; } /** * gets atomRefs4 as list of atoms. * * uses the value in 'torsion' element * * @param atomSet * @return the atoms (null if no atomRefs4) */ public List getAtoms(CMLAtomSet atomSet) { List atomList = null; String[] atomRefs4 = this.getAtomRefs4(); if (atomRefs4 == null || atomSet == null) { throw new RuntimeException( "torsion must have atomSet and atomRefs4 to get atoms"); } else { atomList = new ArrayList(); for (String atomRef : atomRefs4) { CMLAtom atom = atomSet.getAtomById(atomRef); if (atom == null) { throw new RuntimeException("cannot find atom " + atomRef); } atomList.add(atom); } } return atomList; } /** create key from atomRefs4 attribute and atomHash * * @return the hash null if no atomRefs4 */ public String atomHash() { String[] a = this.getAtomRefs4(); return (a == null) ? null : atomHash(a[0], a[1], a[2], a[3]); } /** * Finds ancestral molecule and then uses getCalculatedAngle(CMLMolecule) * * @return the angle in degrees (null if cannot calculate) */ public Double getCalculatedTorsion() { CMLMolecule molecule = CMLMolecule.getAncestorMolecule(this); return (molecule == null) ? null : getCalculatedTorsion(molecule); } /** * Finds ancestral molecule and then uses getCalculatedAngle(CMLMolecule) * tacky - should really return * @return the angle in radians (null if cannot calculate) */ public Double getCalculatedTorsionRadians() { Double ang = getCalculatedTorsion(); return ang == null ? null : ang*Angle.DEGREES_IN_RADIAN; } /** * gets value calculated from coordinates. * * @param molecule * @return the torsion (NaN if cannot calculate) */ public double getCalculatedTorsion(CMLMolecule molecule) { List atomList = this.getAtoms(molecule); return this.getCalculatedTorsion(atomList); } /** * gets value calculated from coordinates. * * @param atomList * @return the torsion (NaN if cannot calculate) */ public double getCalculatedTorsion(List atomList) { double calculatedTorsion = Double.NaN; if (atomList == null || atomList.size() != 4) { throw new RuntimeException("atom list must have 4 elements"); } Point3[] coord = new Point3[4]; for (int i = 0; i < 4; i++) { coord[i] = atomList.get(i).getXYZ3(); if (coord[i] == null) { break; } } try { Angle torsion = Point3.getTorsion(coord[0], coord[1], coord[2], coord[3]); calculatedTorsion = torsion.getDegrees(); } catch (Exception e) { throw new RuntimeException("ERROR in torsion " + e); } return calculatedTorsion; } /** * hash for atoms. * * @param atomId1 * @param atomId2 * @param atomId3 * @param atomId4 * @return hash */ public static String atomHash(String atomId1, String atomId2, String atomId3, String atomId4) { if (atomId1 == null || atomId2 == null || atomId3 == null || atomId4 == null) { return null; } if (atomId1.compareTo(atomId4) < 0) { String temp = atomId4; atomId4 = atomId1; atomId1 = temp; temp = atomId3; atomId3 = atomId2; atomId2 = temp; } return atomId1 + CMLBond.HASH_SYMB + atomId2 + CMLBond.HASH_SYMB + atomId3 + CMLBond.HASH_SYMB + atomId4; } /** translates elements to list. * @param torsionElements * @return the list of lengths */ public static List getList(CMLElements torsionElements) { List torsionList = new ArrayList(); for (CMLTorsion torsion : torsionElements) { torsionList.add(torsion); } return torsionList; } /** * torsions indexed by atom hash. * * @param torsions * @return map */ public static Map getIndexedTorsions(List torsions) { Map torsionTable = new HashMap(); for (CMLTorsion torsion : torsions) { String[] id = torsion.getAtomRefs4(); String key = atomHash(id[0], id[1], id[2], id[3]); torsionTable.put(key, torsion); } return torsionTable; } /** set atomRefs4 attribute. * * @param rGroup0 * @param atom0 * @param atom1 * @param rGroup1 */ public void setAtomRefs4( CMLAtom rGroup0, CMLAtom atom0, CMLAtom atom1, CMLAtom rGroup1) { this.setAtomRefs4( new String[]{ rGroup0.getId(),atom0.getId(), atom1.getId(),rGroup1.getId(), }); } /** writes torsions to an XHTML table. * columns are atom1.label atom2.label atom3.label atom4.label torsion in deg * @param w writer to output * @param torsionList * @param molecule * @throws IOException */ public static void outputHTML( Writer w, List torsionList, CMLMolecule molecule) throws IOException { if (torsionList.size() > 0) { w.write("\n"); w.write(""); w.write(""); w.write(""); w.write(""); w.write(""); w.write(""); w.write("\n"); for (CMLTorsion torsion : torsionList) { List atoms = torsion.getAtoms(molecule); w.write(""); for (int i = 0; i < 4; i++) { w.write(""); } String s = "UNSET"; try { s = CMLConstants.S_EMPTY+torsion.getXMLContent(); } catch (RuntimeException e) { // } w.write(""); w.write("\n"); } w.write("
"); w.write("atom1 (id)"); w.write(""); w.write("atom2 (id)"); w.write(""); w.write("atom3 (id)"); w.write(""); w.write("atom4 (id)"); w.write(""); w.write("torsion"); w.write("
"); CMLAtom atom = atoms.get(i); Nodes labelNodes = atom.query( CMLScalar.NS+"[@dictRef='iucr:_atom_site_label']", CMLConstants.CML_XPATH); String label = ((CMLScalar) labelNodes.get(0)).getXMLContent()+" ("+atom.getId()+S_RBRAK; w.write( (label == null) ? atom.getId() : label); w.write(""+s.substring(0, Math.min(6, s.length()))+"
\n"); } } /** string representation. * * @return string */ public String getString() { String s = CMLConstants.S_EMPTY; String[] aa = this.getAtomRefs4(); if (aa != null) { s += Util.concatenate(aa, CMLConstants.S_MINUS); } // torsion might be unset String ss = "UNSET"; try { double dd = this.getXMLContent(); ss += dd; } catch (RuntimeException e) { // } s += ": "+ss; return s; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLTransform3.java000077500000000000000000000451711477224461000264350ustar00rootroot00000000000000/** * 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 java.util.List; import nu.xom.Element; import org.xmlcml.euclid.Angle; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.RealArray; import org.xmlcml.euclid.Transform3; import org.xmlcml.euclid.Util; import org.xmlcml.euclid.Vector3; import org.xmlcml.euclid.Axis.Axis3; import org.xmlcml.euclid.Transform3.Type; /** * user-modifiable class supporting transform3. * autogenerated from schema use * as a shell which can be edited * */ public class CMLTransform3 extends AbstractTransform3 { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * transformation matrix size */ public final static int SIZE = 16; /** * unit matrix */ public final static double[] UNIT44 = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; /** * default constructor. does NOT create unit matrix. * do not use, except for reflection */ public CMLTransform3() { } /** * contructor. * * @param old */ public CMLTransform3(CMLTransform3 old) { super((AbstractTransform3) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLTransform3(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLTransform3 */ public CMLTransform3 makeElementInContext(Element parent) { return new CMLTransform3(); } /** * check transform has right shape. cannot easily check values here * * @param parent * element * @throws RuntimeException * parsing error */ public void finishMakingElement(Element parent) throws RuntimeException { double[] array = this.getXMLContent(); if (array == null) { throw new RuntimeException("line must not be empty"); } else if (array.length != SIZE) { throw new RuntimeException("line must have 16 double components"); } setMatrix(array); } // =========================== additional constructors // ======================== /** create from primitive components. * * @param transform3 * the components (4x4) */ public CMLTransform3(Transform3 transform3) { this.setMatrix(transform3.getMatrixAsArray()); } /** create from primitive components. * * @param array * the components (4x4) * @throws RuntimeException * must be 16 elements */ public CMLTransform3(double[] array) throws RuntimeException { this.setMatrix(array); } /** * This gives a default unit matrix of type t. * * @param t * type */ public CMLTransform3(Type t) { Transform3 teucl3 = new Transform3(t); this.setMatrix(teucl3.getMatrixAsArray()); } /** * identity matrix with translation component. T = I|vector * * @param v * translation vector */ public CMLTransform3(CMLVector3 v) { Transform3 teucl3 = new Transform3(v.getEuclidVector3()); this.setMatrix(teucl3.getMatrixAsArray()); } /** * from rotation about an axis. (use (Choice3.X), etc * * @param axis * 1=X, etc * @param angle * radians to rotate by */ public CMLTransform3(int axis, double angle) { Angle rot = new Angle(angle); Axis3 ax = null; if (axis == 1) { ax = Axis3.X; } else if (axis == 2) { ax = Axis3.Y; } else if (axis == 3) { ax = Axis3.Z; } Transform3 teucl3 = new Transform3(ax, rot); this.setMatrix(teucl3.getMatrixAsArray()); } /** * from rotation about the three orthogonal axes. rotX then rotY then rotZ * * @param xrot * radians * @param yrot * radians * @param zrot * radians */ public CMLTransform3(double xrot, double yrot, double zrot) { double[] matrix = UNIT44; // there is a bug in Transform3 - if all 3 angles are 0 if (xrot != 0. || yrot != 0. || zrot != 0.0) { Transform3 teucl3 = new Transform3(new Angle(xrot), new Angle(yrot), new Angle(zrot)); matrix = teucl3.getMatrixAsArray(); } this.setMatrix(matrix); } /** * from rotation about a point. * * @param t * rotation matrix * @param p * point to rotate about */ public CMLTransform3(CMLTransform3 t, CMLPoint3 p) { Transform3 teucl3 = new Transform3(t.getEuclidTransform3(), p .getEuclidPoint3()); this.setMatrix(teucl3.getMatrixAsArray()); } /** * from rotation about a vector. * * @param v * vector to rotate about * @param a * angle to rotate by */ public CMLTransform3(CMLVector3 v, double a) { Transform3 teucl3 = new Transform3(v.getEuclidVector3(), new Angle(a)); this.setMatrix(teucl3.getMatrixAsArray()); } /** * Rotation about a line. chooses any point on line as centre of rotation * * @param l * line to rotate about * @param a * angle to rotate by in radians */ public CMLTransform3(CMLLine3 l, double a) { Transform3 teucl3 = new Transform3(l.getEuclidLine3(), new Angle(a)); double[] array = teucl3.getMatrixAsArray(); this.setMatrix(array); } /** * rotation of one vector onto another. this documentation has not been * checked * * @param v1 * vector to rotate * @param v2 * vector to rotate v1 onto * @exception RuntimeException * {@code v1 or v2 } is zero length */ public CMLTransform3(CMLVector3 v1, CMLVector3 v2) { Transform3 teucl3 = new Transform3(v1.getEuclidVector3(), v2 .getEuclidVector3()); this.setMatrix(teucl3.getMatrixAsArray()); } /** * from 3 vector components. NOT checked fills rows of T with v1, v2, v3 * * @param v1 * first row of T * @param v2 * second row of T * @param v3 * third row of T */ public CMLTransform3(CMLVector3 v1, CMLVector3 v2, CMLVector3 v3) { Transform3 teucl3 = new Transform3(v1.getEuclidVector3(), v2 .getEuclidVector3(), v3.getEuclidVector3()); this.setMatrix(teucl3.getMatrixAsArray()); } /** * from a crystallographic operator. * * @param opString * for example 1/2-x,1/2+y,-z */ public CMLTransform3(String opString) { Transform3 teucl3 = new Transform3(opString); double[] array = teucl3.getMatrixAsArray(); // fix bug array[15] = 1.0; this.setMatrix(array); } // ====================== housekeeping methods ===================== /** * create new CMLTransform3 from Transform3. * * @param tool * to provide document context * @param t * Transform3 to create from */ /*-- static CMLTransform3 createCMLTransform3(Transform3 t) { CMLTransform3 tnew = null; tnew = new CMLTransform3(); tnew.setXMLContent(t.getMatrixAsArray()); return tnew; } --*/ // assumes Transform3 != null /** * gets euclid transform. this may be useful for low level calculations * * @return the transform */ public Transform3 getEuclidTransform3() { return new Transform3(this.getXMLContent()); } // ====================== main accessors ===================== /** * sets components. * * @param matrixAsArray * 16 components * @throws RuntimeException * matrix must be of length 16 */ public void setMatrix(double[] matrixAsArray) throws RuntimeException { if (matrixAsArray.length != SIZE) { throw new RuntimeException("xyz3 must be of length " + SIZE); } this.setXMLContent(matrixAsArray); } /** * gets component matrix. * * @return 16-component array */ public double[] getMatrixAsArray() { Transform3 teucl3 = this.getEuclidTransform3(); return teucl3.getMatrixAsArray(); } // ====================== functionality ===================== /** * equality of two transforms. based on equality of RealSquareMatrix * * @param m * transform to compare * @return true if equal within Real.isEqual() */ public boolean isEqualTo(CMLTransform3 m) { Transform3 teucl3 = this.getEuclidTransform3(); return teucl3.isEqualTo(m.getEuclidTransform3()); } /** * concatenate. (I think this is right...) result = this * m2 i.e. if x' = * m2 * x and x'' = this * x'' then x'' = result * x; * * @param m2 * transform to be concatenated * @return result of applying this to m2 */ public CMLTransform3 concatenate(CMLTransform3 m2) { Transform3 teucl3 = this.getEuclidTransform3(); Transform3 t = teucl3.concatenate(m2.getEuclidTransform3()); CMLTransform3 tt = new CMLTransform3(t.getMatrixAsArray()); return tt; } /** * set transformation type. * * @param option * the type * @return 0 if ok else 1 */ public int setTransformationType(Type option) { Transform3 teucl3 = this.getEuclidTransform3(); return teucl3.setTransformationType(option); } /** * get transformation type. * * @return the type */ public Type getTransformationType() { Transform3 teucl3 = this.getEuclidTransform3(); return teucl3.getTransformationType(); } /** * interpret current matrix as rotation about general axis. * * @return double[4] 3 vector components and one angle (radian) */ public double[] getAxisAndAngle() { Transform3 teucl3 = this.getEuclidTransform3(); Vector3 v = new Vector3(); Angle ang = new Angle(); teucl3.getAxisAndAngle(v, ang); double[] d = new double[4]; System.arraycopy(v.getArray(), 0, d, 0, 3); d[3] = ang.getRadian(); return d; } /** * get translation component. * * @return the translation */ public CMLVector3 getTranslation() { Transform3 teucl3 = this.getEuclidTransform3(); Vector3 v = teucl3.getTranslation(); return CMLVector3.createCMLVector3(v); } /** * get centre of rotation. if R is rotation and t is translation compute p = * ~(I - R) . t * * @return the centre */ public CMLPoint3 getCentreOfRotation() { Transform3 teucl3 = this.getEuclidTransform3(); Point3 p = teucl3.getCentreOfRotation(); return new CMLPoint3(p); } /** * get scales. * * @return 3-element RealArray) */ public double[] getScales() { Transform3 teucl3 = this.getEuclidTransform3(); RealArray ra = teucl3.getScales(); return ra.getArray(); } /** * get contents as 3*4 CMLMatrix. * * @return the matrix */ public CMLMatrix getMatrix() { double[] array = new double[12]; System.arraycopy(this.getMatrixAsArray(), 0, array, 0, 12); return new CMLMatrix(3, 4, array); } /** * does operator have a translation component. true if any operator is of * form a+xyz where a is non-zero and xyz is x, y, z this should extract * screw axis, glide and centering operations. at present probably only * useful for orthorhombic and below * * @return true if has component. */ public boolean hasNonZeroTranslationComponent() { boolean nonZeroTranslation = false; double[] matrix = this.getMatrixAsArray(); for (int i = 0; i < 3; i++) { int offset = 4 * i; // non-zero translation if (Math.abs(matrix[offset + 3]) > 0.001) { for (int j = 0; j < 3; j++) { // non inversion if (matrix[offset + j] > 0.001) { nonZeroTranslation = true; break; } } } } return nonZeroTranslation; } /** * does operator have only translation components. true if operators are of * form a+x, b+y, c+z where at least one of a, b, c is non-zero this should * extract centering operations. * * @return true if has component. */ public boolean isPureTranslation() { boolean hasTranslation = false; boolean unit = true; double[] matrix = this.getMatrixAsArray(); for (int i = 0; i < 3; i++) { int offset = 4 * i; // at least one non-zero translation if (Math.abs(matrix[offset + 3]) > 0.001) { hasTranslation = true; } for (int j = 0; j < 3; j++) { if (i == j) { if (Math.abs(matrix[offset + j] - 1.0) > 0.001) { unit = false; break; } } else { if (Math.abs(matrix[offset + j]) > 0.001) { unit = false; break; } } } } return (unit == true && hasTranslation); } /** * true if transform is unit matrix. * * @return true if unit matrix */ public boolean isUnit() { boolean unit = true; double[] matrix = this.getMatrixAsArray(); int count = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (i == j) { if (!(Math.abs(matrix[count] - 1.0) < 0.00000000001)) { unit = false; break; } } else { if (!(Math.abs(matrix[count]) < 0.00000000001)) { unit = false; break; } } count++; } } return unit; } /** * gets row. rows 0,1,2 of length 4 * * @param iRow * row * @return copy of row of length 4 or null if bad iRow */ public double[] getRow(int iRow) { double row[] = null; if (iRow >= 0 && iRow <= 2) { row = new double[4]; double[] matrix = this.getMatrixAsArray(); System.arraycopy(matrix, 4 * iRow, row, 0, 4); } return row; } /** * are two matrices equal. compare rows columns and array contents * * @param tr2 * to compare * @param eps * max allowed difference * @return true if equal */ public boolean isEqualTo(CMLTransform3 tr2, double eps) { return (Util.isEqual(this.getXMLContent(), tr2.getXMLContent(), eps)); } /** * adjusts translation to be inside unit cell. range is 0 (inclusive) to 1 * (exclusive) * */ public void normalizeCrystallographically() { double[] dd = this.getXMLContent(); boolean change = false; for (int i = 0; i < 3; i++) { double t = dd[4 * i + 3]; while (t < 0) { t += 1.0; change = true; } while (t >= 1.0) { t -= 1.0; change = true; } if (change) { dd[4 * i + 3] = t; } } if (change) { this.setXMLContent(dd); } } /** * index of transform in list. compares by content * * @param trList * the list * @param tr * the search transform * @param eps * maximum deviation in elements * @return the index or -1 not found */ public static int indexOf(List trList, CMLTransform3 tr, double eps) { int idx = -1; for (int i = 0; i < trList.size(); i++) { if (tr.isEqualTo(trList.get(i), eps)) { idx = i; break; } } return idx; } /** * get transformed point. * * @param point * @return point. */ public Point3 transform(Point3 point) { Point3 newPoint = null; if (point != null) { newPoint = point.transform(this.getEuclidTransform3()); } return newPoint; } /** * to string. * * @return string */ public String getString() { return this.getEuclidTransform3().toString(); } /** is identity matrix. * * @return is identity */ public boolean isIdentity() { if (this.getValue().equals("1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0")) { return true; } else { return false; } } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLTransitionState.java000077500000000000000000000034171477224461000275270ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting transitionState. * autogenerated from schema * use as a shell which can be edited * */ public class CMLTransitionState extends AbstractTransitionState { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLTransitionState() { } /** * contructor. * * @param old */ public CMLTransitionState(CMLTransitionState old) { super((AbstractTransitionState) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLTransitionState(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLTransitionState */ public CMLElement makeElementInContext(Element parent) { return new CMLTransitionState(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLVector3.java000077500000000000000000000336031477224461000257210ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.euclid.Angle; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.Util; import org.xmlcml.euclid.Vector3; /** * user-modifiable class supporting vector3. * autogenerated from schema use as * a shell which can be edited * */ public class CMLVector3 extends AbstractVector3 { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * default. do not use * public for reflection */ public CMLVector3() { } /** * contructor. * * @param old */ public CMLVector3(CMLVector3 old) { super((AbstractVector3) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLVector3(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLVector3 */ public CMLElement makeElementInContext(Element parent) { return new CMLVector3(); } /** * check vector is OK. must have 3 double components * * @param parent * element * @throws RuntimeException * parsing error */ public void finishMakingElement(Element parent) throws RuntimeException { double[] array = this.getXMLContent(); if (array == null) { throw new RuntimeException("vector must not be empty"); } else if (array.length != 3) { throw new RuntimeException("vector must have 3 double components"); } } // =========================== additional constructors // ======================== /** * create from primitive components. this can be used with * jumbo.euclid.Vector3.getArray() * * @param array * the 3-components */ public CMLVector3(double[] array) { this.setXYZ3(array); } /** * create from Vector3. * * @param v * the vector (can be zero length) */ public CMLVector3(Vector3 v) { this(); this.setXYZ3(v.getArray()); } /** * create from origin to CMLPoint3. vector is from origin to point owning * document is taken from CMLPoint3 * * @param p * the point */ public CMLVector3(CMLPoint3 p) { Vector3 v = new Vector3(p.getEuclidPoint3()); this.setXYZ3(v.getArray()); } /** * create from components. * * @param x * @param y * @param z */ public CMLVector3(double x, double y, double z) { this(); this.setXYZ3(new double[] { x, y, z }); } // ====================== housekeeping methods ===================== // convenience routine /*-- static Vector3 getEuclidVector3(CMLVector3 vector) { return (vector == null) ? null : vector.getEuclidVector3(); } --*/ /** * create new CMLVector3 from Vector3. * * @param vector * Vector3 to create from * @return the vector */ static CMLVector3 createCMLVector3(Vector3 v) { CMLVector3 vnew = new CMLVector3(); vnew.setXMLContent(v.getArray()); return vnew; } // assumes vector3 != null /** * get euclid primitive. * * @return vector3 */ public Vector3 getEuclidVector3() { // does CMLVector contain array elements? return new Vector3(this.getXMLContent()); } // ====================== subsidiary accessors ===================== /** * sets components. * * @param xyz3 * 3 components * @throws RuntimeException * xyz3 must be of length 3 */ public void setXYZ3(double[] xyz3) throws RuntimeException { if (xyz3.length != 3) { throw new RuntimeException("xyz3 must be of length 3; found: " + xyz3.length); } this.setXMLContent(xyz3); } /** * gets components. * * @return 3-component array */ public double[] getXYZ3() { return this.getXMLContent(); } // ====================== functionality ===================== /** * are two vectors equal. uses EPS to test all differences. vectors are NOT * normalized * * @param v * vector to test * @return true if equal within error */ public boolean isEqualTo(CMLVector3 v) { return isEqualTo(v, EPS); } /** * are two vectors equal. vectors are NOT normalized * * @param v * vector to test * @param eps * maximum absolute distance between vector components * @return true if equal within error */ public boolean isEqualTo(CMLVector3 v, double eps) { boolean ok = true; for (int i = 0; i < 3; i++) { if (Math.abs(this.getXYZ3()[i] - v.getXYZ3()[i]) > eps) { ok = false; break; } } return ok; } /** * gets length. * * @return double the length */ public double getLength() { Vector3 veucl3 = this.getEuclidVector3(); return (veucl3 == null) ? Double.NaN : veucl3.getLength(); } /** * gets cross product. * * @param v3 * vector * @return the cross product */ public CMLVector3 getCrossProduct(CMLVector3 v3) { Vector3 veucl3 = this.getEuclidVector3(); Vector3 v = veucl3.cross(v3.getEuclidVector3()); return (v == null) ? null : CMLVector3.createCMLVector3(v); } /** * is one vector longer than another. * * @param v * vector to compare * @return true if this > vector */ public boolean longerThan(CMLVector3 v) { Vector3 veucl3 = this.getEuclidVector3(); return (veucl3 == null) ? false : veucl3.longerThan(v .getEuclidVector3()); } /** * scalar multiplication. create new vector vector = this*f does not alter this * * @param f * multiplier for all components * @return scaled vector */ public CMLVector3 multiplyBy(double f) { Vector3 veucl3 = this.getEuclidVector3(); Vector3 v = (veucl3 == null) ? null : veucl3.multiplyBy(f); return (v == null) ? null : CMLVector3.createCMLVector3(v); } /** * vector addition. create new vector result = this + v3 does not alter this * * @param v3 * vector to add * @return resultant vector */ public CMLVector3 plus(CMLVector3 v3) { Vector3 veucl3 = this.getEuclidVector3(); Vector3 v = (veucl3 == null) ? null : veucl3 .plus(v3.getEuclidVector3()); return (v == null) ? null : CMLVector3.createCMLVector3(v); } /** * vector subtraction. create new vector result = this - v3 does not alter * this * * @param v3 * vector to subtract * @return resultant vector */ public CMLVector3 subtract(CMLVector3 v3) { Vector3 veucl3 = this.getEuclidVector3(); Vector3 v = (veucl3 == null) ? null : veucl3.subtract(v3 .getEuclidVector3()); return (v == null) ? null : CMLVector3.createCMLVector3(v); } /** * get component. * * @param n * the zero-based index * @return the n'th component * @throws RuntimeException */ public double elementAt(int n) throws RuntimeException { Util.check(n, 0, 2); Vector3 veucl3 = this.getEuclidVector3(); return (veucl3 == null) ? Double.NaN : veucl3.elementAt(n); } /** * set component. * * @param n * the zero-based index * @param f * component value * @throws EuclidRuntimeException */ public void setElementAt(int n, double f) throws EuclidRuntimeException { Util.check(n, 0, 2); Vector3 veucl3 = this.getEuclidVector3(); veucl3.setElementAt(n, f); this.setXMLContent(veucl3.getArray()); } /** * is vector of zero length. uses Real.isEqual * * @return if zero within tolerance */ public boolean isZero() { Vector3 veucl3 = this.getEuclidVector3(); return (veucl3 == null) ? false : veucl3.isZero(); } /** * create transformed vector. does not alter this. * * @param t * transform * @return tranformed vector */ public CMLVector3 transform(CMLTransform3 t) { Vector3 veucl3 = this.getEuclidVector3(); Vector3 v = (veucl3 == null) ? null : veucl3.transform(t .getEuclidTransform3()); return (v == null) ? null : CMLVector3.createCMLVector3(v); } /** * normalize vector. alters this this = this.normalize() if zero vector * throws CMLRuntim * * @return vector of unit length * @throws RuntimeException * zero vector */ public CMLVector3 normalize() throws RuntimeException { if (this.isZero()) { throw new RuntimeException("Cannot normalize zero vector"); } Vector3 veucl3 = this.getEuclidVector3(); if (veucl3 != null) { veucl3.normalize(); setXMLContent(veucl3.getArray()); } return this; } /** * create dot product. result = this . v3 does not alter this. * * @param v3 * vector to multiply * @return dot product */ public double dot(CMLVector3 v3) { Vector3 veucl3 = this.getEuclidVector3(); return (veucl3 == null) ? Double.NaN : veucl3 .dot(v3.getEuclidVector3()); } /** * calculate unsigned angle between vectors result = angle between this and * v2 uses acos(this.dot.v2) so angle is unsigned does not alter this. * * @param v2 * vector to multiply * @return angle in radians or Double.NaN if either vector is zero */ public Angle getAngleMadeWith(CMLVector3 v2) { Vector3 veucl3 = this.getEuclidVector3(); return (veucl3 == null) ? null : veucl3.getAngleMadeWith(v2 .getEuclidVector3()); } /** * calculate scalar triple product between vectors. result = this.(v2 x v3) * does not alter this. * * @param v2 * vector to multiply * @param v3 * vector to multiply * @return stp */ public double getScalarTripleProduct(CMLVector3 v2, CMLVector3 v3) { Vector3 veucl3 = this.getEuclidVector3(); return (veucl3 == null) ? null : veucl3.getScalarTripleProduct(v2 .getEuclidVector3(), v3.getEuclidVector3()); } /** * projection of this onto vector. does not alter this. result = vector.norm() * * (this.norm() dot vector.norm()) * * @param v * vector to project onto * @return projected vector (null if zero length vectors) */ public CMLVector3 projectOnto(CMLVector3 v) { Vector3 veucl3 = this.getEuclidVector3(); Vector3 vv = null; try { vv = (veucl3 == null) ? null : veucl3.projectOnto(v .getEuclidVector3()); } catch (EuclidRuntimeException je) { } return (vv == null) ? null : CMLVector3.createCMLVector3(vv); } /** * are two vectors colinear. also returns true if one or more vectors are * zero * * @param v * vector to test with this * @return true if cross product isZero() */ public boolean isColinearVector(CMLVector3 v) { Vector3 veucl3 = this.getEuclidVector3(); return (veucl3 == null) ? false : veucl3.isColinearVector(v .getEuclidVector3()); } /** * get any vector not colinear with this. returns any axis which is not * colinear with this * * @return either XV or YV (even if this is zero) */ public CMLVector3 getNonColinearVector() { Vector3 v = this.getEuclidVector3().getNonColinearVector(); return (v == null) ? null : CMLVector3.createCMLVector3(v); } /** * get any vector perpendicular to this. useful for creating cartesian axes * containing this * * @return vector perpendicular to this (zero if this is zero) */ public CMLVector3 getPerpendicularVector() { Vector3 v = this.getEuclidVector3().getPerpendicularVector(); return (v == null) ? null : CMLVector3.createCMLVector3(v); } /** * get string. * * @return string */ public String getString() { return this.getEuclidVector3().toString(); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLXaxis.java000077500000000000000000000034001477224461000254600ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting xaxis. * autogenerated from schema use as a * shell which can be edited * */ public class CMLXaxis extends AbstractXaxis implements CMLAxis { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLXaxis() { } /** * contructor. * * @param old */ public CMLXaxis(CMLXaxis old) { super((AbstractXaxis) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLXaxis(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLXaxis */ public CMLElement makeElementInContext(Element parent) { return new CMLXaxis(); } public AxisType getAxisType() { return AxisType.X; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLYaxis.java000077500000000000000000000033741477224461000254730ustar00rootroot00000000000000/** * 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.Element; import org.xmlcml.cml.base.CMLElement; /** * user-modifiable class supporting yaxis. * autogenerated from schema use as a * shell which can be edited * */ public class CMLYaxis extends AbstractYaxis implements CMLAxis { /** namespaced element name.*/ public final static String NS = C_E+TAG; /** * contructor. */ public CMLYaxis() { } /** * contructor. * * @param old */ public CMLYaxis(CMLYaxis old) { super((AbstractYaxis) old); } /** * copy node . * * @return Node */ public Element copy() { return new CMLYaxis(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLYaxis */ public CMLElement makeElementInContext(Element parent) { return new CMLYaxis(); } public AxisType getAxisType() { return AxisType.Y; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/CMLZMatrix.java000077500000000000000000000633001477224461000257670ustar00rootroot00000000000000/** * 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 java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import nu.xom.Element; import nu.xom.Elements; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Util; import org.xmlcml.euclid.Vector3; /** * user-modifiable class supporting zMatrix. * autogenerated from schema use as * a shell which can be edited * */ public class CMLZMatrix extends AbstractZMatrix { /** namespaced element name.*/ public final static String NS = C_E+TAG; //temporary storage List lengthList = null; List angleList = null; List torsionList = null; Map lengthByAtomHashMap; Map angleByAtomHashMap; Map> torsionByAtomMap; // Set currentAtomSet; // atoms no longer involved in additional torsions Set deadAtomSet; // final atom set Set finalAtomSet; // torsions involving current atoms Set currentTorsionSet; List deadTorsionList; List deadLengthList; List deadAngleList; /** * contructor. */ public CMLZMatrix() { } /** * contructor. * * @param old */ public CMLZMatrix(CMLZMatrix old) { super((AbstractZMatrix) old); } /** construct from element which has has geometric children. * use length, angle, torsion children. * reorder them so that they describe a ZMatrix * @param element * @exception RuntimeException cannot form ZMatrix */ public CMLZMatrix(CMLElement element) throws RuntimeException { makeZMatrix(element); } /** * copy node . * * @return Node */ public Element copy() { return new CMLZMatrix(this); } /** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLZMatrix */ public CMLElement makeElementInContext(Element parent) { return new CMLZMatrix(); } /** calculate cartesians and adds to molecule. * * @param molecule */ public void addCartesiansTo(CMLMolecule molecule) { Elements lengthElements = this.getChildCMLElements(CMLLength.TAG); Elements angleElements = this.getChildCMLElements(CMLAngle.TAG); Elements torsionElements = this.getChildCMLElements(CMLTorsion.TAG); if (lengthElements.size() == 0) { // nothing to do! } else if (lengthElements.size() == 1) { CMLLength length = (CMLLength) lengthElements.get(0); // String id = length.getAtomRefs2()[0]; String id = length.getAtomRefs2()[1]; CMLAtom atom0 = molecule.getAtomById(id); if (atom0 == null) { throw new RuntimeException("Cannot find atom: "+id); } // id = length.getAtomRefs2()[1]; id = length.getAtomRefs2()[0]; CMLAtom atom1 = molecule.getAtomById(id); if (atom1 == null) { throw new RuntimeException("Cannot find atom: "+id); } atom0.setXYZ3(new Point3(0, 0, 0)); atom1.setXYZ3(new Point3(length.getXMLContent(), 0, 0)); } else if (lengthElements.size() == 2) { setCoordinates((CMLAngle) angleElements.get(0), (CMLLength) lengthElements.get(0), (CMLLength) lengthElements.get(1), molecule); } else if (angleElements.size() == 0) { this.debug("BAD ZMATRIX"); throw new RuntimeException("Bad zMatrix"); } else { setCoordinates((CMLAngle) angleElements.get(0), (CMLLength) lengthElements.get(0), (CMLLength) lengthElements.get(1), molecule); for (int itors = 0; itors < torsionElements.size(); itors++) { setXYZ3( (CMLLength) lengthElements.get(itors+2), (CMLAngle) angleElements.get(itors+1), (CMLTorsion) torsionElements.get(itors), molecule); } } } private void setCoordinates(CMLAngle angle, CMLLength length0, CMLLength length1, CMLMolecule molecule) { int i0 = -1; int i2 = -1; if (CMLBond.atomHash(length0.getAtomRefs2()).equals(CMLBond.atomHash( angle.getAtomRefs3()[0], angle.getAtomRefs3()[1]))) { i0 = 0; i2 = 2; } else if (CMLBond.atomHash(length0.getAtomRefs2()).equals(CMLBond.atomHash( angle.getAtomRefs3()[2], angle.getAtomRefs3()[1]))) { i0 = 2; i2 = 0; } else { throw new RuntimeException("Cannot match lengths to angle"); } String id = angle.getAtomRefs3()[i0]; CMLAtom atom0 = molecule.getAtomById(id); if (atom0 == null) { throw new RuntimeException("Cannot find atom: "+id); } id = angle.getAtomRefs3()[1]; CMLAtom atom1 = molecule.getAtomById(id); if (atom1 == null) { throw new RuntimeException("Cannot find atom: "+id); } id = angle.getAtomRefs3()[i2]; CMLAtom atom2 = molecule.getAtomById(id); atom0.setXYZ3(new Point3(0, 0, 0)); double l0 = length0.getXMLContent(); atom1.setXYZ3(new Point3(l0, 0, 0)); double l1 = length1.getXMLContent(); double anglex = angle.getXMLContent()*Math.PI / 180.; double sina = Math.sin(anglex); double cosa = Math.cos(anglex); atom2.setXYZ3(new Point3(l0 - l1*cosa, l1*sina, 0)); } /** set cartesian coordinates on atom from internal coordinates. * all parameters must be organised in ZMatrix convention * coordinates on a4 are altered. atoms a1, a2, a3, a4 must exist * and a1, a2, a3 must have coordinates (XYZ3) * @param length a3-a4 * @param angle a2-a3-a4 * @param torsion a1-a2-a3-a4 * @param molecule */ public void setXYZ3(CMLLength length, CMLAngle angle, CMLTorsion torsion, CMLMolecule molecule) { String[] atomRefs4 = torsion.getAtomRefs4(); CMLAtom atom0 = molecule.getAtomById(atomRefs4[0]); CMLAtom atom1 = molecule.getAtomById(atomRefs4[1]); CMLAtom atom2 = molecule.getAtomById(atomRefs4[2]); CMLAtom atom3 = molecule.getAtomById(atomRefs4[3]); Point3 p0 = atom0.getXYZ3(); Point3 p1 = atom1.getXYZ3(); Point3 p2 = atom2.getXYZ3(); Point3 p3 = atom3.getXYZ3(); if (p0 == null) { throw new RuntimeException("should not be null p0 "+atom0.getId()); } if (p1 == null) { throw new RuntimeException("should not be null p1 "+atom1.getId()); } if (p2 == null) { throw new RuntimeException("should not be null p2 "+atom2.getId()); } if (p3 != null) { throw new RuntimeException("should be null p3 "+atom3.getId()); } Vector3 v01 = p0.subtract(p1); Vector3 v12 = p2.subtract(p1); Vector3 cross1 = v01.cross(v12); cross1 = cross1.normalize(); Vector3 cross2 = v12.cross(cross1); cross2 = cross2.normalize(); double tangle = torsion.getXMLContent()*Math.PI / 180.; Vector3 cross1a = cross1.multiplyBy(Math.sin(-tangle)); Vector3 cross2a = cross2.multiplyBy(Math.cos(tangle)); Vector3 cross3 = cross1a.plus(cross2a); cross3 = cross3.normalize(); Vector3 v12a = v12.normalize(); double len = length.getXMLContent(); double ang = angle.getXMLContent()*Math.PI / 180.; p3 = new Point3(p2); p3 = p3.plus(cross3.multiplyBy(len * Math.sin(ang))); p3 = p3.subtract(v12a.multiplyBy(len * Math.cos(ang))); atom3.setXYZ3(p3); } void makeZMatrix(CMLElement element) { lengthList = makeLengthList(element); angleList = makeAngleList(element, lengthList.size()); torsionList = makeTorsionList(element, lengthList.size()); currentAtomSet = new HashSet(); deadAtomSet = new HashSet(); torsionByAtomMap = new HashMap>(); currentTorsionSet = new HashSet(); finalAtomSet = new HashSet(); deadTorsionList = new ArrayList(); deadLengthList = new ArrayList(); deadAngleList = new ArrayList(); lengthByAtomHashMap = new HashMap(); for (CMLLength length : lengthList) { lengthByAtomHashMap.put(length.atomHash(), length); } // LOG.debug("LBYATOM "+lengthByAtomHashMap.size()); angleByAtomHashMap = new HashMap(); for (CMLAngle angle : angleList) { angleByAtomHashMap.put(angle.atomHash(), angle); } makeTorsionByAtomMap(); if (lengthList.size() == 1) { this.appendChild(new CMLLength(lengthList.get(0))); } else if (lengthList.size() == 2) { this.appendChild(new CMLLength(lengthList.get(0))); this.appendChild(new CMLLength(lengthList.get(1))); this.appendChild(new CMLAngle((CMLAngle)angleList.get(0))); } else { addFirstFullTorsion(); while (true) { Sprout sprout = getNextSprout(); if (sprout == null) { if (torsionList.size() != 0) { // for (CMLTorsion torsion : torsionList) { // LOG.debug("UNUSED TOR: "+torsion.getString()); // } // debugSprout(); throw new RuntimeException("UNUSED TORSIONs"); } break; } addSprout(sprout); // debugPrint(); } } } // a full torsion is one with 2 angles and 3 lengths private void addFirstFullTorsion() { // LOG.debug("=============FIRST FULL TORSION"); CMLTorsion torsion = null; for (CMLTorsion t : torsionList) { FullTorsion ft = getFullTorsion(t); if (ft != null) { addFullTorsion(ft); torsion = t; break; } } if (torsion == null) { throw new RuntimeException("Cannot find a first full torsion"); } } private void addFullTorsion(FullTorsion ft) { CMLTorsion tNew = getNewTorsion(ft.torsion); String[] at = tNew.getAtomRefs4(); addAtom(at[0]); addAtom(at[1]); addAtom(at[2]); addToMolecule(ft.length1); addToMolecule(ft.length2); addToMolecule(ft.angle12); addToMolecule(ft.length3); addToMolecule(ft.angle23); addToMolecule(ft.torsion); // debugPrint(); } void addToMolecule(CMLLength l) { CMLLength l1 = getNewLength(l); lengthList.remove(l); deadLengthList.add(l); appendChild(l1); } void addToMolecule(CMLAngle a) { CMLAngle a1 = getNewAngle(a); angleList.remove(a); deadAngleList.add(a); appendChild(a1); } void addToMolecule(CMLTorsion tor) { CMLTorsion t1 = getNewTorsion(tor); String atomRef = t1.getAtomRefs4()[3]; if (!finalAtomSet.contains(atomRef)) { // LOG.debug("............. added "+atomRef); addAtom(atomRef); } else { throw new RuntimeException("Atom already in atomSet: "+atomRef); // System.err.println("Added atom already in atomSet"); } appendChild(t1); // LOG.debug("added torsion "+tor.getString()); torsionList.remove(tor); deadTorsionList.add(tor); List removedAtomIds = removeTorsion(torsionByAtomMap, tor); for (String atomId : removedAtomIds) { // LOG.debug(".............removedAtom: "+atomId); deadAtomSet.add(atomId); currentAtomSet.remove(atomId); } currentTorsionSet.remove(tor); // debugPrint(); } void debugPrint() { Util.println("------DEAD ATOMS------"); for (String dead : deadAtomSet) { Util.println(dead); } Util.println("------DEAD LENGTH------"); for (CMLLength dead : deadLengthList) { Util.println(dead.getString()); } Util.println("------DEAD ANGLE------"); for (CMLAngle dead : deadAngleList) { Util.println(dead.getString()); } Util.println("------DEAD TORSION------"); for (CMLTorsion dead : deadTorsionList) { Util.println(dead.getString()); } Util.println("-------CURRENT ATOMS---------"); for (String current : currentAtomSet) { Util.println(current); } Util.println("-------FINAL ATOM SET---------"); for (String finalx : finalAtomSet) { Util.println(finalx); } Util.println("-------LENGTH LIST---------"); for (CMLLength l : lengthList) { Util.println(l.getString()); } Util.println("--------ANGLE LIST--------"); for (CMLAngle a : angleList) { Util.println(""+a.getString()); } Util.println("-------TORSION LIST---------"); for (CMLTorsion t : torsionList) { Util.println(t.getString()); } Util.println("-------CURRENT TORSION SET---------"); // for (CMLTorsion t : currentTorsionSet) { // Util.sysout(t.getString()); // } } void addAtom(String atomRef) { currentAtomSet.add(atomRef); finalAtomSet.add(atomRef); List tList = torsionByAtomMap.get(atomRef); if (tList != null) { for (CMLTorsion t : tList) { currentTorsionSet.add(t); } } } void addSprout(Sprout sprout) { // LOG.debug(".........SPROUT "+sprout); addToMolecule(sprout.length); addToMolecule(sprout.angle); addToMolecule(sprout.torsion); // LOG.debug("............TOR............."+sprout.torsion.getString()); finalAtomSet.add(sprout.atom); } CMLLength getNewLength(CMLLength l) { String[] a = l.getAtomRefs2(); CMLLength length = new CMLLength(l); if (finalAtomSet.contains(a[1])) { String[] aa = new String[2]; aa[0] = a[1]; aa[1] = a[0]; length.setAtomRefs2(aa); } return length; } CMLAngle getNewAngle(CMLAngle ang) { String[] a = ang.getAtomRefs3(); CMLAngle angle = new CMLAngle(ang); if (finalAtomSet.contains(a[2])) { String[] aa = new String[3]; aa[0] = a[2]; aa[1] = a[1]; aa[2] = a[0]; angle.setAtomRefs3(aa); } return angle; } CMLTorsion getNewTorsion(CMLTorsion tor) { String[] a = tor.getAtomRefs4(); CMLTorsion torsion = new CMLTorsion(tor); if (finalAtomSet.contains(a[3])) { String[] aa = new String[4]; aa[0] = a[3]; aa[1] = a[2]; aa[2] = a[1]; aa[3] = a[0]; torsion.setAtomRefs4(aa); } return torsion; } Sprout getNextSprout() { Sprout sprout = null; // LOG.debug("SIZE "+currentTorsionSet.size()); for (CMLTorsion t : currentTorsionSet) { // LOG.debug("............TORS "+t.getString()); List freeAtomList = getFreeAtomList(t); if (freeAtomList.size()== 1) { String atom = freeAtomList.get(0); // LOG.debug("ATOM "+atom); if (!deadAtomSet.contains(atom)) { // LOG.debug("+++++++ATOM "+atom); sprout = getSprout(t, atom); if (sprout != null) { // LOG.debug("?????ATOM "+atom); break; } } } else if (freeAtomList.size() > 1) { // for (String freeAtom : freeAtomList) { // LOG.debug("FREE ATOM "+t.getString()+"..."+freeAtom); // } // LOG.debug("..................."); } else { // LOG.debug("NO FREE ATOM "+t.getString()); } } return sprout; } Sprout getSprout(CMLTorsion t, String atom) { String[] atomRefs4 = t.getAtomRefs4(); CMLLength length = null; CMLAngle angle = null; if (atom.equals(atomRefs4[0])) { // LOG.debug("00000000000000000"); length = lengthByAtomHashMap.get( CMLBond.atomHash(atomRefs4[0], atomRefs4[1])); angle = angleByAtomHashMap.get( CMLAngle.atomHash(atomRefs4[0], atomRefs4[1], atomRefs4[2])); } else if (atom.equals(atomRefs4[3])) { // LOG.debug("3... "+Util.concatenate(atomRefs4, S_SPACE+S_MINUS+S_SPACE)); length = lengthByAtomHashMap.get( CMLBond.atomHash(atomRefs4[2], atomRefs4[3])); if (length == null) { // for (String key : lengthByAtomHashMap.keySet()) { // LOG.debug("...K..."+key); // } } angle = angleByAtomHashMap.get( CMLAngle.atomHash(atomRefs4[1], atomRefs4[2], atomRefs4[3])); } else { throw new RuntimeException("Sprout cannot be in middle of torsion"); } // LOG.debug("L "+length+" -- A "+angle); return (length != null && angle != null) ? new Sprout(atom, length, angle, t) : null; } private List getFreeAtomList(CMLTorsion t) { List list = new ArrayList(); String[] atomRefs4 = t.getAtomRefs4(); for (String atomRef : atomRefs4) { if (!finalAtomSet.contains(atomRef)) { list.add(atomRef); } } return list; } private FullTorsion getFullTorsion(CMLTorsion torsion) { String[] a = torsion.getAtomRefs4(); boolean ok = true; CMLLength length1 = null; CMLLength length2 = null; CMLAngle angle12 = null; CMLLength length3 = null; CMLAngle angle23 = null; length1 = lengthByAtomHashMap.get(CMLBond.atomHash(a[0], a[1])); if (length1 == null) { ok = false; } if (ok) { length2 = lengthByAtomHashMap.get(CMLBond.atomHash(a[1], a[2])); if (length2 == null) { ok = false; } } if (ok) { angle12 = angleByAtomHashMap.get(CMLAngle.atomHash(a[0], a[1], a[2])); if (angle12 == null) { ok = false; } } if (ok) { length3 = lengthByAtomHashMap.get(CMLBond.atomHash(a[2], a[3])); if (length3 == null) { ok = false; } } if (ok) { angle23 = angleByAtomHashMap.get(CMLAngle.atomHash(a[1], a[2], a[3])); if (angle23 == null) { ok = false; } } return (!ok) ? null : new FullTorsion(length1, length2, angle12, length3, angle23, torsion); } private void makeTorsionByAtomMap() { for (CMLTorsion torsion : torsionList) { String[] atomRefs4 = torsion.getAtomRefs4(); addTorsion(torsionByAtomMap, atomRefs4[0], torsion); addTorsion(torsionByAtomMap, atomRefs4[1], torsion); addTorsion(torsionByAtomMap, atomRefs4[2], torsion); addTorsion(torsionByAtomMap, atomRefs4[3], torsion); } for (String atomId : torsionByAtomMap.keySet()) { List torsionList = torsionByAtomMap.get(atomId); String s = atomId+": "; for (CMLTorsion torsion : torsionList) { s += " ("+torsion.getString()+S_RBRAK; } // LOG.debug(s); } } private void addTorsion(Map> torsionByAtomMap, String atomId, CMLTorsion torsion) { List torsionList = torsionByAtomMap.get(atomId); if (torsionList == null) { torsionList = new ArrayList(); torsionByAtomMap.put(atomId, torsionList); } torsionList.add(torsion); } /** remove torsion from map * * @param torsionByAtomMap * @param torsion * @return list of torsions? */ private List removeTorsion( Map> torsionByAtomMap, CMLTorsion torsion) { List deadAtomList = new ArrayList(); for (String atomRef : torsion.getAtomRefs4()) { List torsionList = removeTorsion(torsionByAtomMap, atomRef, torsion); if (torsionList == null || torsionList.size() == 0) { deadAtomList.add(atomRef); } } return deadAtomList; } private List removeTorsion( Map> torsionByAtomMap, String atomId, CMLTorsion torsion) { List torsionList = torsionByAtomMap.get(atomId); if (torsionList != null) { torsionList.remove(torsion); } return torsionList; } private List makeLengthList(CMLElement element) { Elements lengthElements = element.getChildCMLElements(CMLLength.TAG); List lengthList = new ArrayList(); for (int i = 0; i < lengthElements.size(); i++) { lengthList.add((CMLLength)lengthElements.get(i)); } if (lengthList.size() == 0) { throw new RuntimeException("no length elements in ZMatrix"); } return lengthList; } private List makeAngleList(CMLElement element, int nlength) { Elements angleElements = element.getChildCMLElements(CMLAngle.TAG); List angleList = new ArrayList(); for (int i = 0; i < angleElements.size(); i++) { angleList.add((CMLAngle)angleElements.get(i)); } int nangle = angleList.size(); if (nangle + 1 != nlength) { throw new RuntimeException("wrong number of angle elements ("+nangle+ ") for length Elements ("+nlength+") in ZMatrix"); } return angleList; } private List makeTorsionList(CMLElement element, int nlength) { Elements torsionElements = element.getChildCMLElements(CMLTorsion.TAG); List torsionList = new ArrayList(); for (int i = 0; i < torsionElements.size(); i++) { torsionList.add((CMLTorsion)torsionElements.get(i)); } int ntorsion = torsionList.size(); if (ntorsion + 2 != nlength) { throw new RuntimeException("wrong number of torsion elements ("+ntorsion+ ") for length Elements ("+nlength+") in ZMatrix"); } return torsionList; } }; class Sprout { String atom; CMLLength length; CMLAngle angle; CMLTorsion torsion; /** constructor. * * @param atom * @param length * @param angle * @param torsion */ public Sprout(String atom, CMLLength length, CMLAngle angle, CMLTorsion torsion) { this.atom = atom; this.length = length; this.angle = angle; this.torsion = torsion; } /** to string. * @return string */ public String toString() { return "Sprout: "+atom+"; "+length.getString()+"; "+ angle.getString()+"; "+torsion.getString(); } }; class FullTorsion { CMLLength length1; CMLLength length2; CMLAngle angle12; CMLLength length3; CMLAngle angle23; CMLTorsion torsion; /** constructor. * * @param l1 * @param l2 * @param a12 * @param l3 * @param a23 * @param t */ public FullTorsion( CMLLength l1, CMLLength l2, CMLAngle a12, CMLLength l3, CMLAngle a23, CMLTorsion t) { length1 = l1; length2 = l2; angle12 = a12; length3 = l3; angle23 = a23; torsion = t; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/ReactionComponent.java000077500000000000000000000053271477224461000274710ustar00rootroot00000000000000/** * 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 java.util.List; import org.xmlcml.cml.base.CMLConstants; /** * tags CMLReactant, CMLProduct, CMLReactantList, CMLProductList CMLSpectator as * a reaction component. Main current purpose is so that the same operation * (e.g. getAtoms()) can be carried out for any of these */ public interface ReactionComponent extends CMLConstants { /** type of component.*/ public enum Type { /** product.*/ PRODUCT, /** reactant.*/ REACTANT, ; } /** * gets descendant molecules. * * @return empty if no molecules */ public List getMolecules(); /** * gets descendant atoms. * * @return empty if no atoms */ public List getAtoms(); /** * gets descendant bonds. * * @return empty if no bonds */ public List getBonds(); /** * gets descendant formulae. * * @return empty if no formulae */ public List getFormulas(); // /** // * gets descendant reactionComponents. note that this will return all // * containers as well as contained. thus calling this on: // * will return 2 // * components, reactantList, followed by reactant. // * // * @return empty if no components (some components such as CMLProduct will // * always return this) // */ // public List getReactionComponentDescendants(); // // /** // * gets child reactionComponents. note that this will return containers but // * not their contents. thus calling this on: // * will return 1 components, // * reactantList. // * // * @return empty if no components (some components such as CMLProduct will // * always return this) // */ // public List getReactionComponentChildren(); // } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/size.txt000077500000000000000000000332751477224461000247150ustar00rootroot00000000000000 Volume in drive D is Data Volume Serial Number is 7814-AF37 Directory of D:\workspace\cmlxom\src\main\java\org\xmlcml\cml\element 01/02/2012 14:21 . 01/02/2012 14:21 .. 18/07/2011 18:26 14,914 AbstractAbundance.java 18/07/2011 18:26 26,176 AbstractAction.java 18/07/2011 18:26 25,029 AbstractActionList.java 18/07/2011 18:26 12,119 AbstractAmount.java 18/07/2011 18:26 23,244 AbstractAngle.java 18/07/2011 18:26 32,068 AbstractArg.java 18/07/2011 18:26 38,048 AbstractArray.java 18/07/2011 18:26 12,017 AbstractArrayList.java 18/07/2011 18:26 83,757 AbstractAtom.java 18/07/2011 18:26 48,775 AbstractAtomArray.java 18/07/2011 18:26 21,503 AbstractAtomicBasisFunction.java 18/07/2011 18:26 13,638 AbstractAtomParity.java 18/07/2011 18:26 14,957 AbstractAtomSet.java 18/07/2011 18:26 17,169 AbstractAtomType.java 18/07/2011 18:26 12,354 AbstractAtomTypeList.java 18/07/2011 18:26 18,576 AbstractBand.java 18/07/2011 18:26 10,063 AbstractBandList.java 18/07/2011 18:26 14,659 AbstractBasisSet.java 18/07/2011 18:26 23,677 AbstractBond.java 18/07/2011 18:26 20,760 AbstractBondArray.java 18/07/2011 18:26 14,187 AbstractBondSet.java 18/07/2011 18:26 18,148 AbstractBondStereo.java 18/07/2011 18:26 15,732 AbstractBondType.java 18/07/2011 18:26 12,354 AbstractBondTypeList.java 18/07/2011 18:26 16,097 AbstractCellParameter.java 18/07/2011 18:26 14,363 AbstractCml.java 18/07/2011 18:26 9,568 AbstractComplexObject.java 18/07/2011 18:26 15,220 AbstractConditionList.java 18/07/2011 18:26 13,472 AbstractCrystal.java 18/07/2011 18:26 22,187 AbstractDictionary.java 18/07/2011 18:26 16,130 AbstractEigen.java 18/07/2011 18:26 20,947 AbstractElectron.java 18/07/2011 18:26 49,196 AbstractEntry.java 18/07/2011 18:26 12,841 AbstractExpression.java 18/07/2011 18:26 19,103 AbstractFormula.java 18/07/2011 18:26 16,357 AbstractFragment.java 18/07/2011 18:26 15,244 AbstractFragmentList.java 18/07/2011 18:26 11,482 AbstractGradient.java 18/07/2011 18:26 2,957 AbstractHTMLContainer.java 18/07/2011 18:26 13,987 AbstractIdentifier.java 18/07/2011 18:26 17,151 AbstractIsotope.java 18/07/2011 18:26 11,361 AbstractIsotopeList.java 18/07/2011 18:26 24,606 AbstractJoin.java 18/07/2011 18:26 15,971 AbstractKpoint.java 18/07/2011 18:26 10,107 AbstractKpointList.java 18/07/2011 18:26 8,288 AbstractLabel.java 18/07/2011 18:26 16,798 AbstractLattice.java 18/07/2011 18:26 16,290 AbstractLatticeVector.java 18/07/2011 18:26 23,193 AbstractLength.java 18/07/2011 18:26 18,297 AbstractLine3.java 18/07/2011 18:26 43,932 AbstractLink.java 18/07/2011 18:26 10,941 AbstractList.java 18/07/2011 18:26 25,358 AbstractMap.java 18/07/2011 18:26 30,059 AbstractMatrix.java 18/07/2011 18:26 11,127 AbstractMechanism.java 18/07/2011 18:26 9,618 AbstractMechanismComponent.java 18/07/2011 18:26 13,520 AbstractMetadata.java 18/07/2011 18:26 14,339 AbstractMetadataList.java 18/07/2011 18:26 12,440 AbstractModule.java 18/07/2011 18:26 39,033 AbstractMolecule.java 18/07/2011 18:26 12,887 AbstractMoleculeList.java 18/07/2011 18:26 8,933 AbstractName.java 18/07/2011 18:26 15,258 AbstractObject.java 18/07/2011 18:26 13,675 AbstractObservation.java 18/07/2011 18:26 10,985 AbstractOperator.java 18/07/2011 18:26 21,571 AbstractParameter.java 18/07/2011 18:26 15,364 AbstractParameterList.java 18/07/2011 18:26 19,546 AbstractParticle.java 18/07/2011 18:26 61,716 AbstractPeak.java 18/07/2011 18:26 62,792 AbstractPeakGroup.java 18/07/2011 18:26 11,789 AbstractPeakList.java 18/07/2011 18:26 23,785 AbstractPeakStructure.java 18/07/2011 18:26 12,962 AbstractPlane3.java 18/07/2011 18:26 12,341 AbstractPoint3.java 18/07/2011 18:26 11,619 AbstractPotential.java 18/07/2011 18:26 13,608 AbstractPotentialForm.java 18/07/2011 18:26 10,173 AbstractPotentialList.java 18/07/2011 18:26 22,774 AbstractProduct.java 18/07/2011 18:26 18,437 AbstractProductList.java 18/07/2011 18:26 15,631 AbstractProperty.java 18/07/2011 18:26 14,575 AbstractPropertyList.java 18/07/2011 18:26 22,789 AbstractReactant.java 18/07/2011 18:26 18,475 AbstractReactantList.java 18/07/2011 18:26 45,437 AbstractReaction.java 18/07/2011 18:26 14,128 AbstractReactionList.java 18/07/2011 18:26 26,999 AbstractReactionScheme.java 18/07/2011 18:26 20,013 AbstractReactionStep.java 18/07/2011 18:26 20,233 AbstractReactionStepList.java 18/07/2011 18:26 11,698 AbstractReactiveCentre.java 18/07/2011 18:26 18,482 AbstractRegion.java 18/07/2011 18:26 5,499 AbstractRelatedEntry.java 18/07/2011 18:26 14,903 AbstractSample.java 18/07/2011 18:26 28,811 AbstractScalar.java 18/07/2011 18:26 14,002 AbstractSpectator.java 18/07/2011 18:26 10,173 AbstractSpectatorList.java 18/07/2011 18:26 24,803 AbstractSpectrum.java 18/07/2011 18:26 11,797 AbstractSpectrumData.java 18/07/2011 18:26 14,795 AbstractSpectrumList.java 18/07/2011 18:26 12,643 AbstractSphere3.java 18/07/2011 18:26 21,099 AbstractSubstance.java 18/07/2011 18:26 15,959 AbstractSubstanceList.java 18/07/2011 18:26 19,190 AbstractSymmetry.java 18/07/2011 18:26 15,809 AbstractSystem.java 18/07/2011 18:26 18,528 AbstractTable.java 18/07/2011 18:26 9,528 AbstractTableCell.java 18/07/2011 18:26 11,754 AbstractTableContent.java 18/07/2011 18:26 10,225 AbstractTableHeader.java 18/07/2011 18:26 19,963 AbstractTableHeaderCell.java 18/07/2011 18:26 10,123 AbstractTableRow.java 18/07/2011 18:26 10,151 AbstractTableRowList.java 18/07/2011 18:26 22,912 AbstractTorsion.java 18/07/2011 18:26 11,227 AbstractTransform3.java 18/07/2011 18:26 10,714 AbstractTransitionState.java 18/07/2011 18:26 12,370 AbstractVector3.java 18/07/2011 18:26 17,036 AbstractXaxis.java 18/07/2011 18:26 17,036 AbstractYaxis.java 18/07/2011 18:26 10,999 AbstractZMatrix.java 18/07/2011 18:26 1,949 CMLAbundance.java 18/07/2011 18:26 1,663 CMLAction.java 18/07/2011 18:26 1,701 CMLActionList.java 18/07/2011 18:26 1,767 CMLAmount.java 18/07/2011 18:26 9,695 CMLAngle.java 18/07/2011 18:26 22,365 CMLArg.java 18/07/2011 18:26 32,083 CMLArray.java 18/07/2011 18:26 9,086 CMLArrayList.java 18/07/2011 18:26 35,339 CMLAtom.java 18/07/2011 18:26 28,723 CMLAtomArray.java 18/07/2011 18:26 4,543 CMLAtomicBasisFunction.java 18/07/2011 18:26 6,023 CMLAtomParity.java 18/07/2011 18:26 42,611 CMLAtomSet.java 18/07/2011 18:26 1,757 CMLAtomType.java 18/07/2011 18:26 1,721 CMLAtomTypeList.java 18/07/2011 18:26 1,641 CMLBand.java 18/07/2011 18:26 1,681 CMLBandList.java 18/07/2011 18:26 10,044 CMLBasisSet.java 18/07/2011 18:26 25,081 CMLBond.java 20/07/2011 23:04 11,209 CMLBondArray.java 18/07/2011 18:26 17,930 CMLBondSet.java 18/07/2011 18:26 3,430 CMLBondStereo.java 18/07/2011 18:26 1,681 CMLBondType.java 18/07/2011 18:26 1,721 CMLBondTypeList.java 18/07/2011 18:26 8,745 CMLCellParameter.java 18/07/2011 18:26 1,731 CMLCml.java 18/07/2011 18:26 2,183 CMLComplexObject.java 18/07/2011 18:26 1,731 CMLConditionList.java 18/07/2011 18:26 27,404 CMLCrystal.java 18/07/2011 18:26 1,707 CMLDefinition.java 18/07/2011 18:26 1,706 CMLDescription.java 20/07/2011 23:01 7,930 CMLDictionary.java 18/07/2011 18:26 8,103 CMLEigen.java 18/07/2011 18:26 2,402 CMLElectron.java 18/07/2011 18:26 814 CMLElementConstants.java 18/07/2011 18:26 2,329 CMLEntry.java 18/07/2011 18:26 1,701 CMLExpression.java 18/07/2011 18:26 72,278 CMLFormula.java 18/07/2011 18:26 3,715 CMLFragment.java 18/07/2011 18:26 2,115 CMLFragmentList.java 18/07/2011 18:26 1,759 CMLGradient.java 18/07/2011 18:26 1,820 CMLIdentifier.java 18/07/2011 18:26 1,749 CMLIsotope.java 18/07/2011 18:26 1,711 CMLIsotopeList.java 18/07/2011 18:26 8,643 CMLJoin.java 18/07/2011 18:26 2,033 CMLKpoint.java 18/07/2011 18:26 2,005 CMLKpointList.java 18/07/2011 18:26 4,056 CMLLabel.java 18/07/2011 18:26 8,028 CMLLattice.java 18/07/2011 18:26 2,335 CMLLatticeVector.java 18/07/2011 18:26 8,426 CMLLength.java 18/07/2011 18:26 8,994 CMLLine3.java 18/07/2011 18:26 1,719 CMLLink.java 18/07/2011 18:26 3,560 CMLList.java 18/07/2011 18:26 22,330 CMLMap.java 18/07/2011 18:26 19,880 CMLMatrix.java 18/07/2011 18:26 1,769 CMLMechanism.java 18/07/2011 18:26 1,859 CMLMechanismComponent.java 18/07/2011 18:26 3,953 CMLMetadata.java 18/07/2011 18:26 5,054 CMLMetadataList.java 18/07/2011 18:26 1,807 CMLModule.java 18/07/2011 18:26 40,677 CMLMolecule.java 18/07/2011 18:26 2,312 CMLMoleculeList.java 18/07/2011 18:26 1,737 CMLName.java 18/07/2011 18:26 1,661 CMLObject.java 18/07/2011 18:26 1,711 CMLObservation.java 18/07/2011 18:26 1,681 CMLOperator.java 18/07/2011 18:26 5,982 CMLParameter.java 18/07/2011 18:26 5,388 CMLParameterList.java 18/07/2011 18:26 1,759 CMLParticle.java 18/07/2011 18:26 1,981 CMLPeak.java 18/07/2011 18:26 1,841 CMLPeakGroup.java 18/07/2011 18:26 3,679 CMLPeakList.java 18/07/2011 18:26 3,874 CMLPeakStructure.java 18/07/2011 18:26 11,269 CMLPlane3.java 18/07/2011 18:26 17,558 CMLPoint3.java 18/07/2011 18:26 1,769 CMLPotential.java 18/07/2011 18:26 1,809 CMLPotentialForm.java 18/07/2011 18:26 1,809 CMLPotentialList.java 18/07/2011 18:26 4,346 CMLProduct.java 18/07/2011 18:26 3,787 CMLProductList.java 18/07/2011 18:26 12,478 CMLProperty.java 18/07/2011 18:26 5,081 CMLPropertyList.java 18/07/2011 18:26 4,550 CMLReactant.java 18/07/2011 18:26 3,797 CMLReactantList.java 18/07/2011 18:26 19,682 CMLReaction.java 18/07/2011 18:26 2,056 CMLReactionConstants.java 18/07/2011 18:26 1,797 CMLReactionList.java 18/07/2011 18:26 1,817 CMLReactionScheme.java 18/07/2011 18:26 1,797 CMLReactionStep.java 18/07/2011 18:26 1,837 CMLReactionStepList.java 18/07/2011 18:26 1,817 CMLReactiveCentre.java 18/07/2011 18:26 1,737 CMLRegion.java 18/07/2011 18:26 1,719 CMLRelatedEntry.java 18/07/2011 18:26 1,737 CMLSample.java 18/07/2011 18:26 14,028 CMLScalar.java 18/07/2011 18:26 12,478 CMLSpectator.java 18/07/2011 18:26 5,887 CMLSpectatorList.java 18/07/2011 18:26 7,328 CMLSpectrum.java 18/07/2011 18:26 1,797 CMLSpectrumData.java 18/07/2011 18:26 1,797 CMLSpectrumList.java 18/07/2011 18:26 1,747 CMLSphere3.java 18/07/2011 18:26 1,767 CMLSubstance.java 18/07/2011 18:26 1,876 CMLSubstanceList.java 18/07/2011 18:26 14,994 CMLSymmetry.java 18/07/2011 18:26 1,737 CMLSystem.java 18/07/2011 18:26 13,402 CMLTable.java 18/07/2011 18:26 5,038 CMLTableCell.java 18/07/2011 18:26 3,968 CMLTableContent.java 18/07/2011 18:26 3,538 CMLTableHeader.java 18/07/2011 18:26 3,271 CMLTableHeaderCell.java 18/07/2011 18:26 3,750 CMLTableRow.java 18/07/2011 18:26 1,986 CMLTableRowList.java 18/07/2011 18:26 10,671 CMLTorsion.java 18/07/2011 18:26 19,072 CMLTransform3.java 18/07/2011 18:26 1,827 CMLTransitionState.java 18/07/2011 18:26 14,248 CMLVector3.java 18/07/2011 18:26 1,727 CMLXaxis.java 18/07/2011 18:26 1,727 CMLYaxis.java 18/07/2011 18:26 26,324 CMLZMatrix.java 18/07/2011 18:26 2,775 ReactionComponent.java 01/02/2012 14:21 0 size.txt 239 File(s) 3,089,048 bytes 2 Dir(s) 160,747,040,768 bytes free cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/element/size1.txt000077500000000000000000000063601477224461000247710ustar00rootroot0000000000000018/07/2011 18:26 22,365 CMLArg.java 18/07/2011 18:26 32,083 CMLArray.java 18/07/2011 18:26 9,086 CMLArrayList.java 18/07/2011 18:26 35,339 CMLAtom.java 18/07/2011 18:26 28,723 CMLAtomArray.java 18/07/2011 18:26 4,543 CMLAtomicBasisFunction.java 18/07/2011 18:26 6,023 CMLAtomParity.java 18/07/2011 18:26 42,611 CMLAtomSet.java 18/07/2011 18:26 10,044 CMLBasisSet.java 18/07/2011 18:26 25,081 CMLBond.java 20/07/2011 23:04 11,209 CMLBondArray.java 18/07/2011 18:26 17,930 CMLBondSet.java 18/07/2011 18:26 3,430 CMLBondStereo.java 18/07/2011 18:26 8,745 CMLCellParameter.java 18/07/2011 18:26 27,404 CMLCrystal.java 20/07/2011 23:01 7,930 CMLDictionary.java 18/07/2011 18:26 8,103 CMLEigen.java 18/07/2011 18:26 72,278 CMLFormula.java 18/07/2011 18:26 3,715 CMLFragment.java 18/07/2011 18:26 2,115 CMLFragmentList.java 18/07/2011 18:26 8,643 CMLJoin.java 18/07/2011 18:26 2,033 CMLKpoint.java 18/07/2011 18:26 2,005 CMLKpointList.java 18/07/2011 18:26 4,056 CMLLabel.java 18/07/2011 18:26 8,028 CMLLattice.java 18/07/2011 18:26 8,426 CMLLength.java 18/07/2011 18:26 8,994 CMLLine3.java 18/07/2011 18:26 3,560 CMLList.java 18/07/2011 18:26 22,330 CMLMap.java 18/07/2011 18:26 19,880 CMLMatrix.java 18/07/2011 18:26 3,953 CMLMetadata.java 18/07/2011 18:26 5,054 CMLMetadataList.java 18/07/2011 18:26 40,677 CMLMolecule.java 18/07/2011 18:26 5,982 CMLParameter.java 18/07/2011 18:26 5,388 CMLParameterList.java 18/07/2011 18:26 3,679 CMLPeakList.java 18/07/2011 18:26 3,874 CMLPeakStructure.java 18/07/2011 18:26 11,269 CMLPlane3.java 18/07/2011 18:26 17,558 CMLPoint3.java 18/07/2011 18:26 4,346 CMLProduct.java 18/07/2011 18:26 3,787 CMLProductList.java 18/07/2011 18:26 12,478 CMLProperty.java 18/07/2011 18:26 5,081 CMLPropertyList.java 18/07/2011 18:26 4,550 CMLReactant.java 18/07/2011 18:26 3,797 CMLReactantList.java 18/07/2011 18:26 19,682 CMLReaction.java 18/07/2011 18:26 14,028 CMLScalar.java 18/07/2011 18:26 12,478 CMLSpectator.java 18/07/2011 18:26 5,887 CMLSpectatorList.java 18/07/2011 18:26 7,328 CMLSpectrum.java 18/07/2011 18:26 14,994 CMLSymmetry.java 18/07/2011 18:26 13,402 CMLTable.java 18/07/2011 18:26 5,038 CMLTableCell.java 18/07/2011 18:26 3,968 CMLTableContent.java 18/07/2011 18:26 3,538 CMLTableHeader.java 18/07/2011 18:26 3,271 CMLTableHeaderCell.java 18/07/2011 18:26 3,750 CMLTableRow.java 18/07/2011 18:26 10,671 CMLTorsion.java 18/07/2011 18:26 19,072 CMLTransform3.java 18/07/2011 18:26 14,248 CMLVector3.java 18/07/2011 18:26 26,324 CMLZMatrix.java cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/interfacex/000077500000000000000000000000001477224461000236645ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/interfacex/HasArraySize.java000077500000000000000000000024611477224461000271020ustar00rootroot00000000000000/** * 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.interfacex; import java.util.List; /** * interface for CMLArray or CMLList */ public interface HasArraySize extends HasDataType { /** get size of array. * @return size */ int getArraySize(); /** get array elements. * recalcuates each time so best cached for frequent use * @return elements as String */ List getStringValues(); /** * gets values of element; * * @return integer values */ int[] getInts(); /** * gets values of element; * * @return double values */ double[] getDoubles(); } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/interfacex/HasDataType.java000077500000000000000000000027701477224461000267070ustar00rootroot00000000000000/** * 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.interfacex; /** * attached to elements that can carry dataType. * examples are scalar, array, matrix * * @author pmr * */ public interface HasDataType extends HasDictRef { /** * Sets value on dataType attribute. example: setDataType("xsd:double"); * * @param type type of data */ void setDataType(String type); /** * Gets value on dataType attribute. example: setDataType("xsd:double"); * * @return type type of data */ String getDataType(); /** * Gets value of element/ * * @return data returns the XML as a String */ String getXMLContent(); /** * Sets value of element. * * @param content sets the XML content */ void setXMLContent(String content); }cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/interfacex/HasDelimiter.java000077500000000000000000000023271477224461000271100ustar00rootroot00000000000000/** * 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.interfacex; import nu.xom.Attribute; /** * interface for CMLArray or CMLMatrix */ public interface HasDelimiter { /** * * @return delimiter string */ String getDelimiter(); /** * sets delimiter (should be a single printable character or single space (char)32 * @param delim */ void setDelimiter(String delim); /** removes any attribute of the form * delimiter=" " or delimiter="" */ void removeWhitespaceDelimiterAttribute(); Attribute getDelimiterAttribute(); } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/interfacex/HasDictRef.java000077500000000000000000000030501477224461000265040ustar00rootroot00000000000000/** * 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.interfacex; import org.xmlcml.cml.base.CMLAttribute; /** * attached to elements that can carry dictRef. * examples are scalar, array, matrix, property * * @author pmr * */ public interface HasDictRef { // /** // * sets value on dictRef attribute. // * example: setDictRef("myRef", "floop"); // * // * @param prefix // * @param idRef // * @param namespaceURI // */ // void setDictRef(String prefix, String idRef, String namespaceURI); /** get dictRef attribute. * * @return attribute (must be CMLAttribute to be compatible with autogenerated code) */ CMLAttribute getDictRefAttribute(); /** get dictRef value. * * @return value */ String getDictRef(); /** set dictRef value. * * @param dictRef */ void setDictRef(String dictRef); }cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/interfacex/HasScalar.java000077500000000000000000000021411477224461000263710ustar00rootroot00000000000000/** * 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.interfacex; /** * interface for CMLScalar */ public interface HasScalar extends HasDataType { /** * gets value of element; * * @return data */ String getString(); /** * gets value of element; * * @return integer value */ int getInt(); /** * gets value of element; * * @return double value */ double getDouble(); } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/interfacex/HasUnits.java000077500000000000000000000031031477224461000262650ustar00rootroot00000000000000/** * 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.interfacex; /** * attached to elements that can carry units. * examples are scalar, array, matrix * * @author pmr * */ public interface HasUnits { /** * sets value on units attribute. example: setUnits("myUnits", "floop"); * * @param prefix * @param idRef * @param namespaceURI */ void setUnits(String prefix, String idRef, String namespaceURI); /** * * @return units as String */ String getUnits(); // removed in this version // /** // * converts a real scalar to SI. only affects scalar with units attribute // * and dataType='xsd:double' replaces the value with the converted value and // * the units with the SI Units // * // * @param unitListMap // * map to resolve the units attribute // */ // void convertToSI(NamespaceToUnitListMap unitListMap); }cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/interfacex/PeakOrGroup.java000077500000000000000000000035571477224461000267420ustar00rootroot00000000000000/** * 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.interfacex; /** * tags a CMLPeak or a CMLPeakGroup (normally as potential children * of CMLPeakList */ public interface PeakOrGroup { // these are all from attributes /** * @return xvalue */ double getXValue(); /** * @return xmin */ double getXMin(); /** * @return xmax */ double getXMax(); /** * @return xwidth */ double getXWidth(); /** * @return xunits */ String getXUnits(); /** * @return yalue */ double getYValue(); /** * @return ymin */ double getYMin(); /** * @return ymax */ double getYMax(); /** * @return ywidth */ double getYWidth(); /** * @return yunits */ String getYUnits(); /** * @return atomrefs */ String[] getAtomRefs(); /** * @return bondrefs */ String[] getBondRefs(); /** * @return id */ String getId(); /** * @return integral */ String getIntegral(); /** * @return height */ double getPeakHeight(); /** * @return multiplicity */ String getPeakMultiplicity(); /** * @return shape */ String getPeakShape(); /** * @return units */ String getPeakUnits(); } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/testutils/000077500000000000000000000000001477224461000235745ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/testutils/CMLAssert.java000066400000000000000000000471261477224461000262460ustar00rootroot00000000000000/** * 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.testutils; import java.io.File; import java.util.HashSet; import java.util.List; import java.util.Set; import org.apache.log4j.Logger; import org.junit.Assert; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLUtil; import org.xmlcml.cml.element.CMLArray; import org.xmlcml.cml.element.CMLAtomSet; import org.xmlcml.cml.element.CMLBondSet; import org.xmlcml.cml.element.CMLCellParameter; import org.xmlcml.cml.element.CMLFormula; import org.xmlcml.cml.element.CMLLatticeVector; import org.xmlcml.cml.element.CMLLine3; import org.xmlcml.cml.element.CMLMatrix; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.CMLPlane3; import org.xmlcml.cml.element.CMLPoint3; import org.xmlcml.cml.element.CMLTransform3; import org.xmlcml.cml.element.CMLVector3; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Vector3; public class CMLAssert { private static final Logger LOG = Logger.getLogger(CMLAssert.class); /** * tests equality against list of ids. (order of elements in set is * undefined) * * @param message * @param expectedAtomIds * @param atomSet */ public static void assertEquals(String message, String[] expectedAtomIds, CMLAtomSet atomSet) { Assert.assertEquals(message + "; unequal sizes; expected " + expectedAtomIds.length + ", found: " + atomSet.size(), expectedAtomIds.length, atomSet.size()); Set expectedSet = new HashSet(); for (String es : expectedAtomIds) { expectedSet.add(es); } Set foundSet = new HashSet(); String[] fss = atomSet.getAtomIDs(); for (String fs : fss) { foundSet.add(fs); } Assert.assertTrue("compare atom sets", expectedSet.equals(foundSet)); } /** * resource */ public final static String TOOLS_RESOURCE = "org" + CMLConstants.U_S + "xmlcml" + CMLConstants.U_S + "cml" + CMLConstants.U_S + "tools"; /** * examples */ public final static String TOOLS_EXAMPLES = TOOLS_RESOURCE + CMLConstants.U_S + "examples"; /** * crystal examples */ public final static String CRYSTAL_EXAMPLES = TOOLS_EXAMPLES + CMLConstants.U_S + "cryst"; public static void alwaysFail(String message) { Assert.fail("should always throw " + message); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLArray test, CMLArray expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); if ((test.getDataType() == null || test.getDataType() .equals(CMLConstants.XSD_STRING)) && (expected.getDataType() == null || expected.getDataType() .equals(CMLConstants.XSD_STRING))) { Assert.assertEquals(msg, test.getStrings(), expected.getStrings()); } else if (test.getDataType().equals(CMLConstants.XSD_DOUBLE) && expected.getDataType().equals(CMLConstants.XSD_DOUBLE)) { CMLXOMTestUtils.assertEquals(msg, test.getDoubles(), expected.getDoubles(), epsilon); } else if (test.getDataType().equals(CMLConstants.XSD_INTEGER) && expected.getDataType().equals(CMLConstants.XSD_INTEGER)) { Assert.assertEquals(msg, test.getInts(), expected.getInts()); } else { Assert.fail("inconsistent dataTypes" + test.getDataType() + " / " + expected.getDataType()); } } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, CMLArray expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); if (!expected.getDataType().equals(CMLConstants.XSD_DOUBLE)) { Assert.fail("expected should be double"); } CMLXOMTestUtils.assertEquals(msg, test, expected.getDoubles(), epsilon); } /** * equality test. true if both args not null and equal * * @param msg * message * @param test * @param expected */ public static void assertEquals(String msg, int[] test, CMLArray expected) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); if (!expected.getDataType().equals(CMLConstants.XSD_INTEGER)) { Assert.fail("expected should be int"); } Assert.assertEquals(msg, test, expected.getInts()); } /** * equality test. true if both args not null and equal * * @param msg * message * @param test * @param expected */ public static void assertEquals(String msg, String[] test, CMLArray expected) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); if (expected.getDataType() != null && !expected.getDataType().equals(CMLConstants.XSD_STRING)) { Assert.fail("expected should be String"); } Assert.assertEquals(msg, test, expected.getStrings()); } /** * asserts equality of double arrays. * * checks for non-null, then equality of length, then individual elements * * @param message * @param formula1 * expected formula * @param formula2 * actual formula * @param eps * tolerance for agreement */ public static void assertEqualsConcise(String message, CMLFormula formula1, CMLFormula formula2, double eps) { if (formula1 == null) { Assert.fail(CMLXOMTestUtils.getAssertFormat(message, "formula", "null")); } if (formula2 == null) { Assert.fail(CMLXOMTestUtils.getAssertFormat(message, "formula", "null")); } Assert.assertEquals("equal concise", true, formula1.equals(formula2, eps)); } /** * compare two molecules. ignore whitespace nodes in either. * * @param mol * to compare * @param filename * containing molecule as root element */ public static void assertEqualsCanonically(CMLMolecule mol, String filename) { CMLMolecule mol1 = null; try { mol1 = (CMLMolecule) new CMLBuilder().build(new File(filename)) .getRootElement(); } catch (Exception e) { throw new RuntimeException(e); } assertEqualsCanonically(mol, mol1); } /** * compare two molecules. ignore whitespace nodes in either. * * @param mol * to compare * @param mol1 * .mol1 other molecule */ public static void assertEqualsCanonically(CMLMolecule mol, CMLMolecule mol1) { mol = new CMLMolecule(mol); CMLUtil.removeWhitespaceNodes(mol); mol1 = new CMLMolecule(mol1); CMLUtil.removeWhitespaceNodes(mol1); String molS = mol.getCanonicalString(); String mol1S = mol1.getCanonicalString(); Assert.assertEquals("MOLECUL equality: ", molS, mol1S); CMLXOMTestUtils.assertEqualsCanonically("molecule equality", mol, mol1); } /** * tests equality against list of ids. (order of elements in set is * undefined) * * @param message * @param expectedBondIds * @param bondSet */ public static void assertEquals(String message, String[] expectedBondIds, CMLBondSet bondSet) { Assert.assertEquals(message + "; unequal sizes; expected " + expectedBondIds.length + ", found: " + bondSet.size(), expectedBondIds.length, bondSet.size()); Set expectedSet = new HashSet(); for (String es : expectedBondIds) { expectedSet.add(es); } Set foundSet = new HashSet(); List fss = bondSet.getBondIDs(); for (String fs : fss) { foundSet.add(fs); } Assert.assertTrue("compare atom sets", expectedSet.equals(foundSet)); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLCellParameter test, CMLCellParameter expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getXMLContent(), expected.getXMLContent(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param type * of parameter * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, String type, double[] test, CMLCellParameter expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("type should not be null (" + msg + CMLConstants.S_RBRAK, type); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertNotNull("expected should not have null type (" + msg + CMLConstants.S_RBRAK, expected.getType()); Assert.assertEquals("types must be equal", 3, test.length); CMLXOMTestUtils.assertEquals(msg, test, expected.getXMLContent(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLLatticeVector test, CMLLatticeVector expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getXMLContent(), expected.getXMLContent(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 3 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, CMLLatticeVector expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test, expected.getXMLContent(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLLine3 test, CMLLine3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getEuclidLine3(), expected.getEuclidLine3(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param testVector * @param testPoint * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLPoint3 testPoint, CMLVector3 testVector, CMLLine3 expected, double epsilon) { Assert.assertNotNull("testVector should not be null (" + msg + CMLConstants.S_RBRAK, testVector); Assert.assertNotNull("testPoint should not be null (" + msg + CMLConstants.S_RBRAK, testPoint); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, testVector.getEuclidVector3(), new Vector3(expected .getVector3()), epsilon); CMLXOMTestUtils.assertEquals(msg, testPoint.getEuclidPoint3(), new Point3(expected .getPoint3()), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLMatrix test, CMLMatrix expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); if (test.getEuclidRealMatrix() != null) { CMLXOMTestUtils.assertEquals(msg, test.getEuclidRealMatrix(), expected .getEuclidRealMatrix(), epsilon); } else if (test.getEuclidIntMatrix() != null) { Assert.assertEquals(msg, test.getEuclidIntMatrix(), expected .getEuclidIntMatrix()); } else { Assert.fail("both matrices must be either real or int" + test); } } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param rows * @param cols * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, int rows, int cols, double[] test, CMLMatrix expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertEquals("rows ", rows, expected.getRows()); Assert.assertEquals("columns ", cols, expected.getColumns()); CMLXOMTestUtils.assertEquals(msg, rows, cols, test, expected.getEuclidRealMatrix(), epsilon); } /** * equality test. true if both args not null and equal * * @param msg * message * @param rows * @param cols * @param test * @param expected */ public static void assertEquals(String msg, int rows, int cols, int[] test, CMLMatrix expected) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertEquals("rows ", rows, expected.getRows()); Assert.assertEquals("columns ", cols, expected.getColumns()); CMLXOMTestUtils.assertEquals(msg, rows, cols, test, expected.getEuclidIntMatrix()); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLPlane3 test, CMLPlane3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getArray(), expected.getArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 3 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, CMLPlane3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertEquals("must be of length 4", 4, test.length); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test, expected.getArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLPoint3 test, CMLPoint3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getXYZ3(), expected.getXYZ3(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 3 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, CMLPoint3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test, expected.getXYZ3(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLTransform3 test, CMLTransform3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getEuclidTransform3(), expected .getEuclidTransform3(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 3 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, CMLTransform3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertEquals("must be of length 16", 16, test.length); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test, expected.getEuclidTransform3(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLVector3 test, CMLVector3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getXYZ3(), expected.getXYZ3(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 3 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, CMLVector3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test, expected.getXYZ3(), epsilon); } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/cml/testutils/CMLXOMTestUtils.java000066400000000000000000001364121477224461000273260ustar00rootroot00000000000000/** * 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.testutils; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.StringWriter; import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import junit.framework.AssertionFailedError; import junit.framework.ComparisonFailure; import nu.xom.Attribute; import nu.xom.Comment; import nu.xom.Element; import nu.xom.Elements; import nu.xom.Node; import nu.xom.ProcessingInstruction; import nu.xom.Text; import nu.xom.tests.XOMTestCase; import org.apache.log4j.Logger; import org.joda.time.DateTime; import org.junit.Assert; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLUtil; import org.xmlcml.cml.element.CMLMap; import org.xmlcml.euclid.EC; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.IntArray; import org.xmlcml.euclid.IntMatrix; import org.xmlcml.euclid.IntSet; import org.xmlcml.euclid.JodaDate; import org.xmlcml.euclid.Line3; import org.xmlcml.euclid.Plane3; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Point3Vector; import org.xmlcml.euclid.Real; import org.xmlcml.euclid.Real2; import org.xmlcml.euclid.Real2Vector; import org.xmlcml.euclid.Real3Range; import org.xmlcml.euclid.RealArray; import org.xmlcml.euclid.RealMatrix; import org.xmlcml.euclid.RealRange; import org.xmlcml.euclid.RealSquareMatrix; import org.xmlcml.euclid.Transform2; import org.xmlcml.euclid.Transform3; import org.xmlcml.euclid.Util; import org.xmlcml.euclid.Vector2; import org.xmlcml.euclid.Vector3; /** * *

* Utility library of common methods for unit tests *

* * @author Peter Murray-Rust * @version 5.0 * */ public final class CMLXOMTestUtils implements CMLConstants { /** logger */ public final static Logger logger = Logger.getLogger(CMLXOMTestUtils.class); public static final String OUTPUT_DIR_NAME = "target/test-outputs"; /** * tests 2 XML objects for equality using canonical XML. uses * XOMTestCase.assertEquals. This treats different prefixes as different and * compares floats literally. * * @param message * @param refNode * first node * @param testNode * second node */ public static void assertEqualsCanonically(String message, Node refNode, Node testNode) { try { XOMTestCase.assertEquals(message, refNode, testNode); } catch (ComparisonFailure e) { reportXMLDiff(message, e.getMessage(), refNode, testNode); } catch (AssertionFailedError e) { reportXMLDiff(message, e.getMessage(), refNode, testNode); } } /** * compares two XML nodes and checks float near-equivalence (can also be * used for documents without floats) usesTestUtils.assertEqualsCanonically * and only uses PMR code if fails * * @param message * @param refNode * @param testNode * @param eps */ public static void assertEqualsIncludingFloat(String message, Node refNode, Node testNode, boolean stripWhite, double eps) { if (stripWhite && refNode instanceof Element && testNode instanceof Element) { refNode = stripWhite((Element) refNode); testNode = stripWhite((Element) testNode); } try { assertEqualsIncludingFloat(message, refNode, testNode, eps); } catch (AssertionError e) { logger.warn(e); reportXMLDiffInFull(message, e.getMessage(), refNode, testNode); } } public static void assertEqualsIncludingFloat(String message, String expectedS, Node testNode, boolean stripWhite, double eps) { assertEqualsIncludingFloat(message, CMLXOMTestUtils .parseValidString(expectedS), testNode, stripWhite, eps); } private static void assertEqualsIncludingFloat(String message, Node refNode, Node testNode, double eps) { try { Assert.assertEquals(message + ": classes", testNode.getClass(), refNode.getClass()); if (refNode instanceof Text) { testStringDoubleEquality(message + " on node: " + path(testNode), refNode.getValue().trim(), testNode .getValue().trim(), eps); } else if (refNode instanceof Comment) { Assert.assertEquals(message + " comment", refNode.getValue(), testNode.getValue()); } else if (refNode instanceof ProcessingInstruction) { Assert.assertEquals(message + " pi", (ProcessingInstruction) refNode, (ProcessingInstruction) testNode); } else if (refNode instanceof Element) { int refNodeChildCount = refNode.getChildCount(); int testNodeChildCount = testNode.getChildCount(); String path = path(testNode); // FIXME? fails to resolve in tests // Assert.assertEquals("number of children of " + path, // refNodeChildCount, testNodeChildCount); if (refNodeChildCount != testNodeChildCount) { Assert.fail("number of children of " + path + " "+ refNodeChildCount + " != " + testNodeChildCount); } for (int i = 0; i < refNodeChildCount; i++) { assertEqualsIncludingFloat(message, refNode.getChild(i), testNode.getChild(i), eps); } Element refElem = (Element) refNode; Element testElem = (Element) testNode; Assert.assertEquals(message + " name", refElem.getLocalName(), testElem.getLocalName()); Assert.assertEquals(message + " namespace", refElem .getNamespaceURI(), testElem.getNamespaceURI()); Assert.assertEquals(message + " attributes on " + refElem.getClass(), refElem.getAttributeCount(), testElem.getAttributeCount()); for (int i = 0; i < refElem.getAttributeCount(); i++) { Attribute refAtt = refElem.getAttribute(i); String attName = refAtt.getLocalName(); String attNamespace = refAtt.getNamespaceURI(); Attribute testAtt = testElem.getAttribute(attName, attNamespace); if (testAtt == null) { // CMLUtil.debug((Element)refNode, "XXXXXXXXXXX"); // CMLUtil.debug((Element)testNode, "TEST"); Assert.fail(message + " attribute on ref not on test: " + attName); } testStringDoubleEquality(message + " attribute " + path(testAtt) + " values differ:", refAtt .getValue(), testAtt.getValue(), eps); } } else { Assert.fail(message + "cannot deal with XMLNode: " + refNode.getClass()); } } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } } private static String path(Node testNode) { List fullpath = path(testNode, new ArrayList()); Collections.reverse(fullpath); StringBuilder sb = new StringBuilder(); for (String p : fullpath) { sb.append(p); } return sb.toString(); } private static List path(Node testNode, List path) { if (testNode instanceof Element) { Element e = (Element) testNode; StringBuilder frag = new StringBuilder("/"); if (!"".equals(e.getNamespacePrefix())) { frag.append(e.getNamespacePrefix()).append(":"); } path.add(frag.append(e.getLocalName()).append("[").append( siblingOrdinal(e)).append("]").toString()); } else if (testNode instanceof Attribute) { Attribute a = (Attribute) testNode; path.add(new StringBuilder("@").append(a.getNamespacePrefix()) .append(":").append(a.getLocalName()).toString()); } else if (testNode instanceof Text) { path.add("/text()"); } return (testNode.getParent() != null) ? path(testNode.getParent(), path) : path; } private static int siblingOrdinal(Element e) { Element parent = (Element) e.getParent(); if (parent == null) { return 0; } else { Elements els = parent.getChildElements(e.getLocalName(), e .getNamespaceURI()); for (int i = 0; i < els.size(); i++) { if (els.get(i).equals(e)) { return i; } } throw new RuntimeException( "Element was not a child of its parent. Most perplexing!"); } } private static void testStringDoubleEquality(String message, String refValue, String testValue, double eps) { testValue = testValue.trim(); refValue = refValue.trim(); // maybe if (testValue.endsWith(" ") || refValue.endsWith(" ")) { throw new RuntimeException("trim error"); } if (!testValue.equals(refValue)) { boolean fail = true; try { compareAsFloats(message, refValue, testValue, eps); fail = false; } catch (Exception e) { } if (fail) { try { compareAsFloatArrays(message, refValue, testValue, eps); fail = false; } catch (Exception e) { } } if (fail) { try { compareAsDates(message, refValue, testValue, eps); fail = false; } catch (Exception e) { } } if (fail) { Assert.fail("Cannot equate: "+refValue+" != "+testValue); } } else { Assert.assertEquals(message, refValue, testValue); } } private static void compareAsFloats(String message, String refValue, String testValue, double eps) { double testVal = Double.NaN; double refVal = Double.NaN; Error ee = null; try { try { testVal = Double.valueOf(testValue).doubleValue(); refVal = Double.valueOf(refValue).doubleValue(); Assert.assertEquals(message + " doubles ", refVal, testVal, eps); } catch (NumberFormatException e) { Assert.assertEquals(message + " String ", refValue, testValue); } } catch (ComparisonFailure e) { ee = e; } catch (AssertionError e) { ee = e; } if (ee != null) { throw new RuntimeException("["+testValue+"] != ["+refValue+"]" ,ee); } } /** I am still haveing problems with dates * if these ARE both dates assume they are equal (because of time zones * sorry) * @param message * @param refValue * @param testValue * @param eps */ private static void compareAsDates(String message, String refValue, String testValue, double eps) { DateTime testVal = null; DateTime refVal = null; try { testVal = JodaDate.parseDate(testValue); refVal = JodaDate.parseDate(refValue); // Assert.assertEquals(message + " date ", refVal, testVal); } catch (Exception e) { Assert.fail("unequal strings "+testValue+" != "+refValue); } } private static void compareAsFloatArrays(String message, String refValue, String testValue, double eps) { Error ee = null; try { try { RealArray testArray = new RealArray(testValue); RealArray refArray = new RealArray(refValue); assertEquals(message, testArray, refArray, eps); } catch (NumberFormatException e) { Assert.assertEquals(message + " String ", refValue, testValue); } } catch (ComparisonFailure e) { ee = e; } catch (AssertionError e) { ee = e; } if (ee != null) { throw new RuntimeException("["+testValue+"] != ["+refValue+"]" ,ee); } } private static Element stripWhite(Element refNode) { refNode = new Element(refNode); CMLUtil.removeWhitespaceNodes(refNode); return refNode; } public static void alwaysFail(String message) { Assert.fail("should always throw " + message); } // ====================== CML and Euclid =================== public static String testEquals(String message, double[] a, double[] b, double eps) { String msg = testEquals(a, b, eps); return (msg == null) ? null : message+"; "+msg; } // Real2 /** * returns a message if arrays differ. * * @param a array to compare * @param b array to compare * @param eps tolerance * @return null if arrays are equal else indicative message */ public static String testEquals(Real2 a, Real2 b, double eps) { String s = null; if (a == null) { s = "a is null"; } else if (b == null) { s = "b is null"; } else { if (!Real.isEqual(a.x, b.x, eps) || !Real.isEqual(a.y, b.y, eps)) { s = ""+a+" != "+b; } } return s; } // double arrays and related /** * Asserts equality of double arrays. * * checks for non-null, then equality of length, then individual elements * * @param message * @param a * expected array * @param b * actual array * @param eps * tolerance for agreement */ public static void assertEquals(String message, double[] a, double[] b, double eps) { String s = testEquals(a, b, eps); if (s != null) { Assert.fail(message + "; " + s); } } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 4 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, Plane3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertEquals("must be of length 4", 4, test.length); Assert.assertNotNull("ref should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test, expected.getArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 3 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, Point3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test, expected.getArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 3 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, Point3Vector expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertEquals("must be of equal length ", test.length, expected .getArray().length); CMLXOMTestUtils.assertEquals(msg, test, expected.getArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 2 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, Real2 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertEquals("must be of length 2", 2, test.length); Assert.assertNotNull("ref should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test, expected.getXY(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 3 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, Real2Vector expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertEquals("must be of equal length ", test.length, expected .getXY().getArray().length); CMLXOMTestUtils.assertEquals(msg, test, expected.getXY().getArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 3 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, RealArray expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertEquals("must be of equal length ", test.length, expected .getArray().length); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * 16 values * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, Transform2 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertEquals("test should have 16 elements (" + msg + CMLConstants.S_RBRAK, 9, test.length); Assert.assertNotNull("ref should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test, expected.getMatrixAsArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * 16 values * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, Transform3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertEquals("test should have 16 elements (" + msg + CMLConstants.S_RBRAK, 16, test.length); Assert.assertNotNull("ref should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test, expected.getMatrixAsArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 3 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, Vector3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test, expected.getArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param rows * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, int rows, double[] test, RealSquareMatrix expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("ref should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertEquals("rows should be equal (" + msg + CMLConstants.S_RBRAK, rows, expected.getRows()); CMLXOMTestUtils.assertEquals(msg, test, expected.getMatrixAsArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param rows * @param cols * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, int rows, int cols, double[] test, RealMatrix expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("ref should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertEquals("rows should be equal (" + msg + CMLConstants.S_RBRAK, rows, expected.getRows()); Assert.assertEquals("columns should be equal (" + msg + CMLConstants.S_RBRAK, cols, expected.getCols()); CMLXOMTestUtils.assertEquals(msg, test, expected.getMatrixAsArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param rows * @param cols * @param test * @param expected */ public static void assertEquals(String msg, int rows, int cols, int[] test, IntMatrix expected) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("ref should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertEquals("rows should be equal (" + msg + CMLConstants.S_RBRAK, rows, expected.getRows()); Assert.assertEquals("columns should be equal (" + msg + CMLConstants.S_RBRAK, cols, expected.getCols()); Assert.assertEquals(msg, test, expected.getMatrixAsArray()); } /** * Asserts equality of int arrays. * * checks for non-null, then equality of length, then individual elements * * @param message * @param a * expected array * @param b * actual array */ public static void assertEquals(String message, int[] a, int[] b) { String s = testEquals(a, b); if (s != null) { Assert.fail(message + "; " + s); } } /** * equality test. true if both args not null and equal * * @param msg * message * @param test * @param expected */ public static void assertEquals(String msg, int[] test, IntArray expected) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertEquals("must be of equal length ", test.length, expected .getArray().length); Assert.assertEquals(msg, test, expected.getArray()); } /** * equality test. true if both args not null and equal * * @param msg * message * @param test * @param expected */ public static void assertEquals(String msg, int[] test, IntSet expected) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertEquals("must be of equal length ", test.length, expected .getElements().length); Assert.assertEquals(msg, test, expected.getElements()); } /** * equality test. true if both args not null and equal * * @param msg * message * @param test * @param expected */ public static void assertEquals(String msg, IntArray test, IntArray expected) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertEquals(msg, test.getArray(), expected.getArray()); } /** * equality test. true if both args not null and equal within epsilon and * rows are present and equals and columns are present and equals * * @param msg * message * @param test * @param expected */ public static void assertEquals(String msg, IntMatrix test, IntMatrix expected) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertNotNull("expected should have columns (" + msg + CMLConstants.S_RBRAK, expected.getCols()); Assert.assertNotNull("expected should have rows (" + msg + CMLConstants.S_RBRAK, expected.getRows()); Assert.assertNotNull("test should have columns (" + msg + CMLConstants.S_RBRAK, test .getCols()); Assert.assertNotNull("test should have rows (" + msg + CMLConstants.S_RBRAK, test .getRows()); Assert.assertEquals("rows should be equal (" + msg + CMLConstants.S_RBRAK, test .getRows(), expected.getRows()); Assert.assertEquals("columns should be equal (" + msg + CMLConstants.S_RBRAK, test .getCols(), expected.getCols()); Assert.assertEquals(msg, test.getMatrixAsArray(), expected.getMatrixAsArray()); } /** * equality test. true if both args not null and equal * * @param msg * message * @param test * @param expected */ public static void assertEquals(String msg, IntSet test, IntSet expected) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertEquals(msg, test.getElements(), expected.getElements()); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, Line3 test, Line3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("ref should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getPoint(), expected.getPoint(), epsilon); CMLXOMTestUtils.assertEquals(msg, test.getVector(), expected.getVector(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, Plane3 test, Plane3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("ref should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getArray(), expected.getArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, Point3 test, Point3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("ref should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getArray(), expected.getArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param testPoint * @param testVector * @param expected * @param epsilon */ public static void assertEquals(String msg, Point3 testPoint, Vector3 testVector, Line3 expected, double epsilon) { Assert.assertNotNull("testPoint should not be null (" + msg + CMLConstants.S_RBRAK, testPoint); Assert.assertNotNull("testVector should not be null (" + msg + CMLConstants.S_RBRAK, testVector); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, testPoint, expected.getPoint(), epsilon); CMLXOMTestUtils.assertEquals(msg, testVector, expected.getVector(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, Point3Vector test, Point3Vector expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getArray(), expected.getArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, Real2 test, Real2 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getXY(), expected.getXY(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, Real2Vector expected, Real2Vector test, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, expected.getXY().getArray(), test.getXY().getArray(), epsilon); } /** * test ranges for equality. * * @param msg * @param r3ref * @param r3 * @param epsilon */ public static void assertEquals(String msg, Real3Range r3ref, Real3Range r3, double epsilon) { CMLXOMTestUtils.assertEquals("xRange", r3.getXRange(), r3ref.getXRange(), epsilon); CMLXOMTestUtils.assertEquals("yRange", r3.getYRange(), r3ref.getYRange(), epsilon); CMLXOMTestUtils.assertEquals("zRange", r3.getZRange(), r3ref.getZRange(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, RealArray test, RealArray expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getArray(), expected.getArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon and * rows are present and equals and columns are present and equals * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, RealMatrix test, RealMatrix expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertNotNull("expected should have columns (" + msg + CMLConstants.S_RBRAK, expected.getCols()); Assert.assertNotNull("expected should have rows (" + msg + CMLConstants.S_RBRAK, expected.getRows()); Assert.assertNotNull("test should have columns (" + msg + CMLConstants.S_RBRAK, test .getCols()); Assert.assertNotNull("test should have rows (" + msg + CMLConstants.S_RBRAK, test .getRows()); Assert.assertEquals("rows should be equal (" + msg + CMLConstants.S_RBRAK, test .getRows(), expected.getRows()); Assert.assertEquals("columns should be equal (" + msg + CMLConstants.S_RBRAK, test .getCols(), expected.getCols()); CMLXOMTestUtils.assertEquals(msg, test.getMatrixAsArray(), expected.getMatrixAsArray(), epsilon); } /** * tests equality of ranges. * * @param msg * message * @param ref * @param r * @param epsilon */ public static void assertEquals(String msg, RealRange ref, RealRange r, double epsilon) { Assert.assertEquals(msg + " min", r.getMin(), ref.getMin(), epsilon); Assert.assertEquals(msg + " max", r.getMax(), ref.getMax(), epsilon); } /** * equality test. true if both args not null and equal within epsilon and * rows are present and equals and columns are present and equals * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, RealSquareMatrix test, RealSquareMatrix expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertNotNull("expected should have columns (" + msg + CMLConstants.S_RBRAK, expected.getCols()); Assert.assertNotNull("expected should have rows (" + msg + CMLConstants.S_RBRAK, expected.getRows()); Assert.assertNotNull("test should have columns (" + msg + CMLConstants.S_RBRAK, test .getCols()); Assert.assertNotNull("test should have rows (" + msg + CMLConstants.S_RBRAK, test .getRows()); Assert.assertEquals("rows should be equal (" + msg + CMLConstants.S_RBRAK, test .getRows(), expected.getRows()); Assert.assertEquals("columns should be equal (" + msg + CMLConstants.S_RBRAK, test .getCols(), expected.getCols()); CMLXOMTestUtils.assertEquals(msg, test.getMatrixAsArray(), expected.getMatrixAsArray(), epsilon); } /** * Asserts equality of String arrays. * * convenience method where test is a whitespace-separated set of tokens * * @param message * @param a * expected array as space concatenated * @param b * actual array may not include nulls */ public static void assertEquals(String message, String a, String[] b) { String[] aa = a.split(EC.S_SPACE); String s = testEquals(aa, b); if (s != null) { Assert.fail(message + "; " + s); } } /** * Asserts equality of String arrays. * * checks for non-null, then equality of length, then individual elements * equality if individual elements are equal or both elements are null * * @param message * @param a * expected array may include nulls * @param b * actual array may include nulls */ public static void assertEquals(String message, String[] a, String[] b) { String s = testEquals(a, b); if (s != null) { Assert.fail(message + "; " + s + "("+Util.concatenate(a, "~")+" != "+Util.concatenate(b, "~")); } } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, Transform2 test, Transform2 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getMatrixAsArray(), expected.getMatrixAsArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, Transform3 test, Transform3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getMatrixAsArray(), expected.getMatrixAsArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, Vector2 test, Vector2 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getXY(), expected.getXY(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, Vector3 test, Vector3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLXOMTestUtils.assertEquals(msg, test.getArray(), expected.getArray(), epsilon); } /** * tests 2 XML objects for equality using canonical XML. * * @param message * @param refNode * first node * @param testNode * second node * @param stripWhite * if true remove w/s nodes */ public static void assertEqualsCanonically(String message, Element refNode, Element testNode, boolean stripWhite) { assertEqualsCanonically(message, refNode, testNode, stripWhite, true); } /** * tests 2 XML objects for equality using canonical XML. * * @param message * @param refXMLString * first node * @param testNode * second node * @param stripWhite * if true remove w/s nodes */ public static void assertEqualsCanonically(String message, String refXMLString, Element testNode, boolean stripWhite) { assertEqualsCanonically(message, CMLXOMTestUtils.parseValidString(refXMLString), testNode, stripWhite, true); } public static void assertEqualsCanonically(String message, CMLMap refNode, CMLMap testNode) { Assert.assertEquals("from refs", new HashSet(refNode.getFromRefs()), new HashSet(testNode.getFromRefs())); Assert.assertEquals("to refs", new HashSet(refNode.getToRefs()), new HashSet(testNode.getToRefs())); for (String fromRef : refNode.getFromRefs()) { String toRef = refNode.getToRef(fromRef); Assert.assertEquals("from/to refs", toRef, testNode.getToRef(fromRef)); } } /** * tests 2 XML objects for equality using canonical XML. * * @param message * @param refNode * first node * @param testNode * second node * @param stripWhite * if true remove w/s nodes */ private static void assertEqualsCanonically(String message, Element refNode, Element testNode, boolean stripWhite, boolean reportError) throws Error { if (stripWhite) { refNode = stripWhite(refNode); testNode = stripWhite(testNode); } Error ee = null; try { XOMTestCase.assertEquals(message, refNode, testNode); } catch (ComparisonFailure e) { ee = e; } catch (AssertionFailedError e) { ee = e; } if (ee != null) { if (reportError) { reportXMLDiffInFull(message, ee.getMessage(), refNode, testNode); } else { throw (ee); } } } /** * compares two XML nodes and checks float near-equivalence (can also be * used for documents without floats) uses CMLXOMTestUtils.assertEqualsCanonically and only * uses PMR code if fails * * @param message * @param refNode * @param testNode * @param eps */ public static void assertEqualsIncludingFloat(String message, Node refNode, Node testNode, boolean stripWhite, double eps, boolean report) { if (stripWhite && refNode instanceof Element && testNode instanceof Element) { refNode = stripWhite((Element) refNode); testNode = stripWhite((Element) testNode); } try { assertEqualsIncludingFloat(message, refNode, testNode, eps); } catch (RuntimeException e) { if (report) { reportXMLDiffInFull(message, e.getMessage(), refNode, testNode); } } } /** * Asserts non equality of double arrays. * * checks for non-null, then equality of length, then individual elements * * @param message * @param a * expected array * @param b * actual array * @param eps * tolerance for agreement */ public static void assertNotEquals(String message, double[] a, double[] b, double eps) { String s = testEquals(a, b, eps); if (s == null) { Assert.fail(message + "; arrays are equal"); } } /** * Asserts non equality of double arrays. * * checks for non-null, then equality of length, then individual elements * * @param message * @param a * expected array * @param b * actual array */ public static void assertNotEquals(String message, int[] a, int[] b) { String s = testEquals(a, b); if (s == null) { Assert.fail(message + "; arrays are equal"); } } /** * Asserts non equality of String arrays. * * checks for non-null, then equality of length, then individual elements * * @param message * @param a * expected array * @param b * actual array */ public static void assertNotEquals(String message, String[] a, String[] b) { String s = testEquals(a, b); if (s == null) { Assert.fail(message + "; arrays are equal"); } } /** * tests 2 XML objects for non-equality using canonical XML. * * @param message * @param node1 * first node * @param node2 * second node */ public static void assertNotEqualsCanonically(String message, Node node1, Node node2) { try { Assert.assertEquals(message, node1, node2); String s1 = CMLUtil.getCanonicalString(node1); String s2 = CMLUtil.getCanonicalString(node2); Assert.fail(message + "nodes should be different " + s1 + " != " + s2); } catch (ComparisonFailure e) { } catch (AssertionFailedError e) { } } public static void assertObjectivelyEquals(String message, double[] a, double[] b, double eps) { String s = null; if (a == null) { s = "a is null"; } else if (b == null) { s = "b is null"; } else if (a.length != b.length) { s = "unequal arrays: " + a.length + CMLConstants.S_SLASH + b.length; } else { for (int i = 0; i < a.length; i++) { if (!(((Double) a[i]).equals(b[i]) || !Real.isEqual(a[i], b[i], eps))) { s = "unequal element at (" + i + "), " + a[i] + " != " + b[i]; break; } } } if (s != null) { Assert.fail(message + "; " + s); } } /** * test the writeHTML method of element. * * @param element * to test * @param expected * HTML string */ public static void assertWriteHTML(CMLElement element, String expected) { StringWriter sw = new StringWriter(); try { element.writeHTML(sw); sw.close(); } catch (IOException e) { Assert.fail("should not throw " + e); } String s = sw.toString(); Assert.assertEquals("HTML output ", expected, s); } /** * used by Assert routines. copied from Assert * * @param message * prepends if not null * @param expected * @param actual * @return message */ public static String getAssertFormat(String message, Object expected, Object actual) { String formatted = ""; if (message != null) { formatted = message + CMLConstants.S_SPACE; } return formatted + "expected:<" + expected + "> but was:<" + actual + ">"; } public static void neverFail(Exception e) { Assert.fail("should never throw " + e); } public static void neverThrow(Exception e) { throw new EuclidRuntimeException("should never throw " + e); } /** * convenience method to parse test file. uses resource * * @param filename * relative to classpath * @return root element */ public static Element parseValidFile(String filename) { Element root = null; try { URL url = Util.getResource(filename); root = new CMLBuilder().build(new File(url.toURI())) .getRootElement(); } catch (Exception e) { e.printStackTrace(); } return root; } /** * convenience method to parse test file. * @param file relative to classpath * @return root element */ public static Element parseValidFile(File file) { Element root = null; try { root = new CMLBuilder().build(new FileInputStream(file)).getRootElement(); } catch (Exception e) { throw new RuntimeException("BUG ", e); } return root; } /** * convenience method to parse test string. * * @param s * xml string (assumed valid) * @return root element */ public static Element parseValidString(String s) { Element element = null; if (s == null) { throw new RuntimeException("NULL VALID JAVA_STRING"); } try { element = new CMLBuilder().parseString(s); } catch (Exception e) { e.printStackTrace(); System.err.println("ERROR " + e + e.getMessage() + "..." + s.substring(0, Math.min(100, s.length()))); Util.BUG(e); } return element; } static protected void reportXMLDiff(String message, String errorMessage, Node refNode, Node testNode) { Assert.fail(message + " ~ " + errorMessage); } static protected void reportXMLDiffInFull(String message, String errorMessage, Node refNode, Node testNode) { try { System.err.println("Error: "+errorMessage); System.err.println("==========XMLDIFF reference========="); CMLUtil.debug((Element) refNode, System.err, 2); System.err.println("------------test---------------------"); String s = testNode.toXML().replace("><", ">\n<"); System.err.println(s); System.err.println("==============" + message + "==================="); } catch (Exception e) { throw new RuntimeException(e); } Assert.fail(message + " ~ " + errorMessage); } /** * returns a message if arrays differ. * * @param a * array to compare * @param b * array to compare * @param eps * tolerance * @return null if arrays are equal else indicative message */ static String testEquals(double[] a, double[] b, double eps) { String s = null; if (a == null) { s = "a is null"; } else if (b == null) { s = "b is null"; } else if (a.length != b.length) { s = "unequal arrays: " + a.length + CMLConstants.S_SLASH + b.length; } else { for (int i = 0; i < a.length; i++) { if (!Real.isEqual(a[i], b[i], eps)) { s = "unequal element at (" + i + "), " + a[i] + " != " + b[i]; break; } } } return s; } /** * returns a message if arrays of arrays differ. * * @param a * array to compare * @param b * array to compare * @param eps * tolerance * @return null if array are equal else indicative message */ static String testEquals(double[][] a, double[][] b, double eps) { String s = null; if (a == null) { s = "a is null"; } else if (b == null) { s = "b is null"; } else if (a.length != b.length) { s = "unequal arrays: " + a.length + CMLConstants.S_SLASH + b.length; } else { for (int i = 0; i < a.length; i++) { if (a[i].length != b[i].length) { s = "row (" + i + ") has unequal lengths: " + a[i].length + CMLConstants.S_SLASH + b[i].length; break; } for (int j = 0; j < a[i].length; j++) { if (!Real.isEqual(a[i][j], b[i][j], eps)) { s = "unequal element at (" + i + ", " + j + "), (" + a[i][j] + " != " + b[i][j] + CMLConstants.S_RBRAK; break; } } } } return s; } /** * compare integer arrays. * * @param a * @param b * @return message or null */ public static String testEquals(int[] a, int[] b) { String s = null; if (a == null) { s = "a is null"; } else if (b == null) { s = "b is null"; } else if (a.length != b.length) { s = "unequal arrays: " + a.length + CMLConstants.S_SLASH + b.length; } else { for (int i = 0; i < a.length; i++) { if (a[i] != b[i]) { s = "unequal element (" + i + "), " + a[i] + " != " + b[i]; break; } } } return s; } /** * match arrays. error is a == null or b == null or a.length != b.length or * a[i] != b[i] nulls match * * @param a * @param b * @return message if errors else null */ public static String testEquals(String[] a, String[] b) { String s = null; if (a == null) { s = "a is null"; } else if (b == null) { s = "b is null"; } else if (a.length != b.length) { s = "unequal arrays: " + a.length + CMLConstants.S_SLASH + b.length; } else { for (int i = 0; i < a.length; i++) { if (a[i] == null && b[i] == null) { // both null, match } else if (a[i] == null || b[i] == null || !a[i].equals(b[i])) { s = "unequal element (" + i + "), expected: " + a[i] + " found: " + b[i]; break; } } } return s; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/molutil/000077500000000000000000000000001477224461000224465ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/molutil/ChemicalElement.java000077500000000000000000000755211477224461000263450ustar00rootroot00000000000000/** * 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.molutil; import java.awt.Color; import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; import java.util.Hashtable; import java.util.List; import java.util.Set; import nu.xom.Document; import nu.xom.Element; import nu.xom.Elements; import org.apache.log4j.Logger; import org.xmlcml.cml.base.CMLUtil; //import jumbo.euclid.RealArray; /** * Supports the elements. * * @author (C) P. Murray-Rust, 1996 * @author (C) S. Adams, 2004 */ public class ChemicalElement { /** type of element. * An element may have several types * we shall generate a List<Type> for each * element * More to be added... * @author pm286 * */ public enum Type { /** transition metal */ TRANSITION_METAL, /** pblock top right*/ PBLOCK, /** metal any sort*/ METAL, /** metal any sort*/ METAL_NOT_SEMI_METAL, /** group A (number to be given separately)*/ GROUP_A, /** group B (number to be given separately)*/ GROUP_B, /** row (number to be given separately)*/ ROW, /** lanthanide*/ LANTHANIDE, /** actinide*/ ACTINIDE, /** non-metal*/ NON_METAL, /** semi-metal*/ SEMI_METAL, /** halogen **/ HALOGEN; ; private Type() { } } /** types of radius. */ public enum RadiusType { /** dewisott */ ATOMIC, /** dewisott */ COVALENT, /** dewisott */ IONIC, /** dewisott */ VDW; private RadiusType() { } } /** enumeration of element in symbolic form. * * @author pm286 * */ public enum AS { /** element symbol*/ H ("H", 1), /** element symbol*/ He("He", 2), /** element symbol*/ Li("Li", 3), /** element symbol*/ Be("Be", 4), /** element symbol*/ B ("B", 5), /** element symbol*/ C ("C", 6), /** element symbol*/ N ("N", 7), /** element symbol*/ O ("O", 8), /** element symbol*/ F ("F", 9), /** element symbol*/ Ne("Ne", 10), /** element symbol*/ Na("Na", 11), /** element symbol*/ Mg("Mg", 12), /** element symbol*/ Al("Al", 13), /** element symbol*/ Si("Si", 14), /** element symbol*/ P ("P", 15), /** element symbol*/ S ("S", 16), /** element symbol*/ Cl("Cl", 17), /** element symbol*/ Ar("Ar", 18), /** element symbol*/ Br("Br", 35), /** element symbol*/ I("I", 53), /** element symbol*/ R("R", 119), ; /** element symbol*/ public String value; /** atomic number */ public int n; private AS(String symbol, int n) { this.value = symbol; this.n = n; } /** compare element symbols. * * @param elSym element symbol * @return true if not null and equal */ public boolean equals(String elSym) { return (elSym != null && elSym.equals(value)); } }; final static Logger logger = Logger.getLogger(ChemicalElement.class); /** * maximum number of elements. */ /** * atoms count from 1. so max at number is MAXELEM-1 * */ public static final int MAXELEM = 150; /** XML file containing elemental details. */ final static String ELEMENT_FILE = "org/xmlcml/molutil/elementdata.xml"; final static double DEFAULT_ATOMIC_RADIUS = 1.6; final static double DEFAULT_COVALENT_RADIUS = 1.4; final static double DEFAULT_VDW_RADIUS = 2.0; final static double DEFAULT_BONDING_RADIUS_TOLERANCE = 0.2; static double bondingRadiusTolerance = DEFAULT_BONDING_RADIUS_TOLERANCE; /** Hashtable of elements, indexed by atomicSymbol. */ static Hashtable pTable; /** Atomic number to atomicSymbol array. */ public static ChemicalElement[] periodicTable; static { pTable = new Hashtable(); periodicTable = new ChemicalElement[MAXELEM]; }; protected final int atomicNumber; protected final double atomicWeight; protected final String atomicSymbol; protected int group; protected int period; protected String electronicGroundState; protected int[] isotopeMasses; protected double[] isotopeAbundances; protected double[] isotopePreciseMasses; /** Covalent radius, in angstrom. */ protected double covalentRadius; /** Atomic radius, in angstrom. */ protected double atomicRadius; /** Van der Waals radius, in angstrom. */ protected double vanderwaalsRadius; /** Pauling electronegativity. */ protected double electronegativity; /** Display colour. */ protected Color color; /** * constructor of a new element * * @param symbol the symbol * @param atomicNumber the atomic number * @param atomicWeight the atomic weight */ public ChemicalElement(String symbol, int atomicNumber, double atomicWeight) { this.atomicSymbol = symbol; this.atomicNumber = atomicNumber; this.atomicWeight = atomicWeight; periodicTable[atomicNumber] = this; } /** * get symbol. * * @return symbol */ public String getSymbol() { return atomicSymbol; } /** * get atomic number. * * @return atomic number */ public int getAtomicNumber() { return atomicNumber; } /** * get atomic weight. * * @return atomic weight */ public double getAtomicWeight() { return atomicWeight; } /** * get group. * * @return group */ public int getGroup() { return group; } /** * get period. * * @return period */ public int getPeriod() { return period; } /** * get ground state. * * @return ground state */ public String getElectronicGroundState() { return electronicGroundState; } /** * @param masses mass information of the isotopes * @param abundances abundancy information of the isotopes * @deprecated use setIsotopes. */ public void addIsotope(int[] masses, double[] abundances) { setIsotopes(masses, abundances); } /** * set isotopes. * * @param masses mass information of the isotopes * @param abundances abundancy information of the isotopes */ public void setIsotopes(int[] masses, double[] abundances) { isotopeMasses = masses; isotopeAbundances = abundances; } /** * set precise masses for the isotopes of this element * * @param preciseMasses precise mass information of the isotopes */ public void setIsotopePreciseMasses(double [] preciseMasses) { isotopePreciseMasses = preciseMasses; } /** * @return array of isotope masses, or null if isotopes not known. */ public int[] getIsotopeMasses() { return isotopeMasses; } /** * @return array of isotope abundances, or null if isotopes not known. */ public double[] getIsotopeAbundances() { return isotopeAbundances; } /** * @return array of precise isotope masses, or null if isotopes not known. * Double.NaN is used where precise mass has not been added to elementdata.xml */ public double[] getIsotopePreciseMasses() { return isotopePreciseMasses; } /** * get the mass of the most abundant isotope. * * @return mass of most abundant isotope, or -1 if not found. */ public int getMainIsotope() { double max = -1.0; int mainMass = -1; for (int i = 0; i < isotopeMasses.length; i++) { if (isotopeAbundances[i] > max) { max = isotopeAbundances[i]; mainMass = isotopeMasses[i]; } } return mainMass; } /** * set covalent radius. * * @param cov covalent radius of the element */ public void setCovalentRadius(double cov) { covalentRadius = cov; } /** * get covalent radius. * * @return the radius */ public double getCovalentRadius() { return (covalentRadius > 0.1) ? covalentRadius : DEFAULT_COVALENT_RADIUS; } /** get various types of radii * * @param radiusType type of the radius to return the value of * @return radius */ public double getRadius(RadiusType radiusType) { double radius = Double.NaN; if (radiusType.equals(RadiusType.ATOMIC)) { radius = getAtomicRadius(); } else if (radiusType.equals(RadiusType.COVALENT)) { radius = getCovalentRadius(); } else if (radiusType.equals(RadiusType.IONIC)) { // radius = getIonicRadius(); } else if (radiusType.equals(RadiusType.VDW)) { radius = getVDWRadius(); } return radius; } /** * @return cov rad */ public double getTypeAdjustedCovalentRadius() { double radius = this.getCovalentRadius(); if (this.isChemicalElementType(Type.ACTINIDE) || this.isChemicalElementType(Type.LANTHANIDE)) { radius = radius * 1.35; } else if (this.isChemicalElementType(Type.TRANSITION_METAL)) { radius = radius * 1.25; } else if (this.isChemicalElementType(Type.GROUP_B) || this.isChemicalElementType(Type.GROUP_A)){ radius = radius * 1.2; } else { radius = radius * 1.15; } return radius; } /** * set atomic radius. * * @param cov the atomic radius */ public void setAtomicRadius(double cov) { atomicRadius = cov; } /** * get atomic radius. * * @return radius */ public double getAtomicRadius() { return (atomicRadius > 0.1) ? atomicRadius : DEFAULT_ATOMIC_RADIUS; } /** * set vdw radius. * * @param vdw the vanderwaals radius */ public void setVDWRadius(double vdw) { vanderwaalsRadius = vdw; } /** * get vdw radius * * @return radius */ public double getVDWRadius() { return (vanderwaalsRadius > 0.1) ? vanderwaalsRadius : DEFAULT_VDW_RADIUS; } /** * set electronegativity. * * @param eneg the new electronegativity of the element */ public void setElectronegativity(double eneg) { electronegativity = eneg; } /** * get electronegativity. * * @return eneg */ public double getElectronegativity() { return electronegativity; } /** * set color * * @param color the new color of the element */ public void setColor(Color color) { this.color = color; } /** * get color. * * @return color */ public Color getColor() { return this.color; } /** * gets color as hex string. includes leading '#' and 6 hex digits * * @return the color as a string */ public String getColorString() { String red = Integer.toHexString(color.getRed()); if (red.length() == 1) red = "0" + red; String green = Integer.toHexString(color.getGreen()); if (green.length() == 1) green = "0" + green; String blue = Integer.toHexString(color.getBlue()); if (blue.length() == 1) blue = "0" + blue; return "#" + red + green + blue; } /** * valence electrons defined as p-block-like - available for bonding. * * @return electron count */ public int getValenceElectrons() { if (atomicNumber < 2) return atomicNumber; // first row if (atomicNumber < 10) return atomicNumber - 2; // second row if (atomicNumber < 18) return atomicNumber - 10; // first row tm if (atomicNumber < 28) return atomicNumber - 18; // third row if (atomicNumber < 36) return atomicNumber - 28; // second row tm if (atomicNumber < 46) return atomicNumber - 36; // fourth row if (atomicNumber < 54) return atomicNumber - 46; // not done if (atomicNumber < 78) return atomicNumber - 54; // up to 86 // fifth row p block if (atomicNumber < 86) return atomicNumber - 78; return -1; } /** * to string. * * @return string */ public String toString() { return atomicSymbol + ": " + atomicWeight; } /** Outputs details of element. */ public void debug() { ChemicalElement.debug(this); } /** * is element a transition metal. FIXME - I haven't checked values * @param type * GROUP_A, GROUP_B or ROW * @param value * or row or group * * @return true if is TM */ public boolean isChemicalElementType( Type type, int value) { int atNum = this.getAtomicNumber(); // String symbol = chemicalElement.getSymbol(); boolean isType = false; if (type.equals(Type.ROW)) { isType = value == 1 && atNum >= 3 && atNum <= 10 || value == 2 && atNum >= 11 && atNum <= 18 || value == 3 && atNum >= 19 && atNum <= 36 || value == 4 && atNum >= 37 && atNum <= 54 || value == 5 && atNum >= 55 && atNum <= 86 || value == 6 && atNum >= 87; } else if (type.equals(Type.GROUP_A)) { if (value == 1 || value == 2) { isType = atNum == 2 + value || atNum == 10 + value || atNum == 18 + value || atNum == 36 + value || atNum == 54 + value; } else if (value >= 3 && value <= 8) { isType = atNum == 2 + value || atNum == 10 + value || atNum == 28 + value || atNum == 46 + value || atNum == 78 + value; } } else if (type.equals(Type.GROUP_B)) { if (value >= 1 || value <= 10) { isType = atNum == 18 + value || atNum == 36 + value || atNum == 56 + value; } } else { throw new RuntimeException("Bad type for " + type + ": " + value); } return isType; } /** * is element of given type. * @param type * TRANSITION METAL, LANTHANIDE, ACTINIDE, METAL, * NON_METAL, PBLOCK, GROUP_A, GROUP_B * * @return true if of type */ public boolean isChemicalElementType( Type type) { int atNum = this.getAtomicNumber(); // String symbol = chemicalElement.getSymbol(); boolean isType = false; if (type.equals(Type.TRANSITION_METAL)) { isType = (atNum > 20 && atNum <= 30) || (atNum > 38 && atNum <= 48) || (atNum > 56 && atNum <= 80); } else if (type.equals(Type.LANTHANIDE)) { isType = (atNum >= 58 && atNum <= 71); } else if (type.equals(Type.ACTINIDE)) { isType = atNum >= 90 && atNum <= 103; } else if (type.equals(Type.METAL)) { isType = isChemicalElementType(Type.TRANSITION_METAL) || isChemicalElementType(Type.LANTHANIDE) || isChemicalElementType(Type.ACTINIDE) || isChemicalElementType(Type.GROUP_A) || isChemicalElementType(Type.GROUP_B) || // include metalloids on left of step (atNum == 13) || (atNum >= 31 && atNum <= 32) || (atNum >= 49 && atNum <= 51) || (atNum >= 81 && atNum <=84); } else if (type.equals(Type.METAL_NOT_SEMI_METAL)) { isType = isChemicalElementType(Type.TRANSITION_METAL) || isChemicalElementType(Type.LANTHANIDE) || isChemicalElementType(Type.ACTINIDE) || isChemicalElementType(Type.GROUP_A) || isChemicalElementType(Type.GROUP_B); } else if (type.equals(Type.NON_METAL)) { isType = atNum >=5 && atNum <= 10 || atNum >=14 && atNum <= 18 || atNum >=33 && atNum <= 36 || atNum >=52 && atNum <= 54 || atNum >=85 && atNum <= 86; } else if (type.equals(Type.PBLOCK)) { isType = atNum >= 5 && atNum <= 10 || // B, C, N, O, F,Ne atNum >= 14 && atNum <= 18 || // Si, P, S,Cl,Ar atNum >= 32 && atNum <= 36 || // Ge,As,Se,Br,Kr atNum >= 53 && atNum <= 54 // I,Xe ; } else if (type.equals(Type.GROUP_A)) { isType = atNum == 3 || atNum == 11 || atNum == 19 || atNum == 37 || atNum == 55 || atNum ==87; } else if (type.equals(Type.GROUP_B)) { isType = atNum == 4 || atNum == 12 || atNum == 20 || atNum == 38 || atNum == 56 || atNum ==88; } else if (type.equals(Type.SEMI_METAL)) { isType = atNum == 13 || atNum == 31 || atNum == 32 || atNum >= 49 && atNum <= 51 || atNum >= 81 && atNum <= 84 ; } else if (type.equals(Type.HALOGEN)) { isType = atNum == 9 || atNum == 17 || atNum == 35 || atNum == 53 || atNum == 85; ; } else { throw new RuntimeException("Bad type for " + type); } return isType; } /** * get the element corresponding to a (case-insensitive) atomicSymbol; else * returns null. * * @param symbol the case insensitive symbol of the element to return * @return element or null if not found */ public static ChemicalElement getChemicalElementIgnoreCase(String symbol) { symbol = symbol.toUpperCase(); return pTable.get(symbol); } /** get the element corresponding to a CASE-SENSITIVE atomicSymbol. * * @param symbol the case sensitive symbol of the element to return * @return element or null if not found */ public static ChemicalElement getChemicalElement(String symbol) { return pTable.get(symbol); } /** get the element corresponding to a Type. * not all elements are present * @param as atom symbol * @return element or null if not found */ public static ChemicalElement getChemicalElement(AS as) { return pTable.get(as.value); } /** gets chemical element corresponding to first 2 or 1 chars. * looks at first two character to see if they are a double-char * element (case-sensitive) else looks ate first char * length of string can be found with getSymbol().length() * @param s string to analyze (NOT trimmed) * @return element or null if not found */ public static ChemicalElement grabChemicalElement(String s) { ChemicalElement element = null; if (s == null || s.length() == 0) { // } else if (s.length() == 1) { element = ChemicalElement.getChemicalElement(s); } else { String ss = s.substring(0,2); element = ChemicalElement.getChemicalElement(ss); if (element == null) { element = ChemicalElement.getChemicalElement(s.substring(0,1)); } } return element; } /** * get the element corresponding to atomic number; else returns null. * * @param atomicNumber the atomic number of the element to return * @return element */ public static ChemicalElement getElement(int atomicNumber) { if (atomicNumber < 1 || atomicNumber >= MAXELEM) { return null; } return periodicTable[atomicNumber]; } /** generates periodic table. * Element sysmbols are CASE-SENSITIVE * */ // / @cond DOXYGEN_STATIC_BLOCK_WORKAROUND static { ChemicalElement el; // Reads elemental data from ELEMENT_FILE // ClassLoader l = ClassLoader.getSystemClassLoader(); Document document = null; try { document = CMLUtil.getXMLResource(ELEMENT_FILE); } catch (IOException e1) { throw new RuntimeException("BUG: cannot read PT resource file: "+ ELEMENT_FILE); } document = null; try { document = CMLUtil.getXMLResource(ELEMENT_FILE); } catch (IOException e1) { throw new RuntimeException("BUG: cannot read PT resource file: "+ ELEMENT_FILE); } Elements elements = ((Element) document.getRootElement()) .getChildElements("element"); for (int i = 0; i < elements.size(); i++) { Element element = (Element) elements.get(i); String symbol = element.getAttributeValue("id"); // logger.info("Adding element: " + atomicSymbol); int atNum = Integer.parseInt(element .getAttributeValue("atomicnumber")); double atWeight = getWeight(element, "webelements"); el = new ChemicalElement(symbol, atNum, atWeight); // pTable.put(el.atomicSymbol.toUpperCase(), el); pTable.put(el.atomicSymbol, el); String sGroup = element.getAttributeValue("group"); if (sGroup != null) { el.group = Integer.parseInt(sGroup); } else { el.group = 0; } String sPeriod = element.getAttributeValue("period"); if (sPeriod != null) { el.period = Integer.parseInt(sPeriod); } else { el.period = 0; } double d = getRadius(element, "webelements", "covalent", "empirical"); el.setCovalentRadius(d); d = getRadius(element, "webelements", "atomic", "empirical"); el.setAtomicRadius(d); d = getRadius(element, "webelements", "vanderwaals", null); el.setVDWRadius(d); el.setElectronegativity(getElectronegativity(element, "webelements", "pauling")); el.electronicGroundState = getElectronicState(element, "webelements", "groundstate"); Elements nodelist = element.getChildElements("isotopes"); int[] ii = {}; double[] aa = {}; double[] preciseMasses = {}; if (nodelist.size() > 0) { Element node = (Element) nodelist.get(0); Elements isotopes = node.getChildElements("isotope"); if (isotopes.size() > 0) { ii = new int[isotopes.size()]; aa = new double[isotopes.size()]; preciseMasses = new double[isotopes.size()]; for (int j = 0; j < isotopes.size(); j++) { Element isotope = (Element) isotopes.get(j); try { ii[j] = Integer.parseInt(isotope .getAttributeValue("mass")); aa[j] = Double.parseDouble(isotope .getAttributeValue("abundance")); String preciseMass = isotope.getAttributeValue("preciseMass"); if (preciseMass == null) { preciseMasses[j] = Double.NaN; } else { preciseMasses[j] = Double.parseDouble(preciseMass); } } catch (NullPointerException e) { //FIXME squish the nullpointer and leave the value set to 0? this doesn't look right... ; } } } } el.addIsotope(ii, aa); el.setIsotopePreciseMasses(preciseMasses); nodelist = element.getChildElements("rgb"); if (nodelist.size() > 0) { Element node = (Element) nodelist.get(0); float red = Float.parseFloat(node.getAttributeValue("red")); float green = Float.parseFloat(node.getAttributeValue("green")); float blue = Float.parseFloat(node.getAttributeValue("blue")); el.setColor(new Color(red, green, blue)); } } } // / @endcond private static double getWeight(Element element, String source) { Elements weights = element.getChildElements("mass"); for (int i = 0; i < weights.size(); i++) { Element weight = (Element) weights.get(i); if (source != null && source.equals(weight.getAttributeValue("source"))) { return Double.parseDouble(weight.getValue()); } } return 0; } private static double getRadius(Element element, String source, String type, String context) { Elements radiiList = element.getChildElements("radii"); for (int i = 0; i < radiiList.size(); i++) { Element radii = (Element) radiiList.get(i); if (source != null && !source.equals(radii.getAttributeValue("source"))) { continue; } Elements radiusList = radii.getChildElements("radius"); for (int j = 0; j < radiusList.size(); j++) { Element radius = (Element) radiusList.get(j); if (type != null && type.equals(radius.getAttributeValue("type")) && (context == null || context.equals(radius.getAttributeValue("context")))) { double rad = Double.parseDouble(radius.getValue()); if (radius.getAttributeValue("unit").equals("pm")) { rad /= 100.0; } return rad; } } } return 0; } private static double getElectronegativity(Element element, String source, String type) { Elements enegList = element.getChildElements("electronegativity"); for (int i = 0; i < enegList.size(); i++) { Element eneg = (Element) enegList.get(i); if (source != null && source.equals(eneg.getAttributeValue("source")) && type != null && type.equals(eneg.getAttributeValue("type"))) { return Double.parseDouble(eneg.getValue()); } } return 0; } private static String getElectronicState(Element element, String source, String type) { Elements eStates = element.getChildElements("electronicconfiguration"); for (int i = 0; i < eStates.size(); i++) { Element estate = (Element) eStates.get(i); if (source != null && source.equals(estate.getAttributeValue("source")) && type != null && type.equals(estate.getAttributeValue("type"))) { return estate.getValue(); } } return ""; } /** * Outputs details of element. * * @param el element to output */ public static void debug(ChemicalElement el) { logger.info("ChemicalElement:"); logger.info(" > AS: " + el.getSymbol()); logger.info(" > Atomic number: " + el.getAtomicNumber()); logger.info(" > Group: " + el.getGroup()); logger.info(" > Period: " + el.getPeriod()); logger.info(" > Atomic weight: " + el.getAtomicWeight()); logger.info(" > Main isotope: " + el.getMainIsotope()); logger.info(" > Valence electrons: " + el.getValenceElectrons()); logger.info(" > Ground state config: " + el.getElectronicGroundState()); logger.info(" > Electronegativity: " + el.getElectronegativity()); logger.info(" > Atomic radius: " + el.getAtomicRadius()); logger.info(" > Covalent radius: " + el.getCovalentRadius()); logger.info(" > Van-der-Waal's radius: " + el.getVDWRadius()); logger.info(" > Isotopes:"); int[] isoMass = el.getIsotopeMasses(); double[] isoAbun = el.getIsotopeAbundances(); for (int i = 0; i < isoMass.length; i++) { logger.info(" > " + isoMass[i] + " (" + isoAbun[i] + "%)"); } logger.info(" > Color: " + el.getColor().toString()); logger.info("----------------------------------------"); } /** * gets default tolerance from sum of covalent radii. * * @return the tolerance (default 0.2) */ public static double getBondingRadiusTolerance() { return bondingRadiusTolerance; } /** * sets boding radius tolerance. * * @param tol the tolerance */ public static void setBondingRadiusTolerance(double tol) { bondingRadiusTolerance = (tol > 0.0) ? tol : bondingRadiusTolerance; } /** get set of elements defined by symbols. * silently skips any strings which are not elements or * duplicates * @param symbols list of symbols * @return set of elements */ public static Set getElementSet(String[] symbols) { List symbolList = new ArrayList(); for (String symbol : symbols) { symbolList.add(symbol); } return getElementSet(symbolList); } /** get set of elements defined by symbols. * silently skips any strings which are not elements or * duplicates * @param symbolList list of symbols * @return set of elements */ public static Set getElementSet(List symbolList) { Set set = new HashSet(); for (String symbol : symbolList) { ChemicalElement element = ChemicalElement.getChemicalElement(symbol); if (element != null) { set.add(element); } } return set; } } cmlxom-cmlxom-4.11/src/main/java/org/xmlcml/molutil/Molutils.java000077500000000000000000000432331477224461000251310ustar00rootroot00000000000000/** * 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.molutil; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Vector3; /** * utilities for molecular operations * * @author pm286 * */ public abstract class Molutils extends java.lang.Object implements CMLConstants { final static Logger logger = Logger.getLogger(Molutils.class.getName()); /** * trigonal angle in radians */ public final static double TRIGONAL_ANGLE = 2.0 * Math.acos(1.0 / 2.0); /** * tetrahedral angle in radians */ public final static double TETRAHEDRAL_ANGLE = 2.0 * Math.acos(1.0 / Math .sqrt(3.0)); /** * default geometry */ public final static int DEFAULT = 0; /** * no specified geometry */ public final static int ANY = 1; /** * linear */ public final static int LINEAR = 2; /** * trigonal planar */ public final static int TRIGONAL = 3; /** * tetrahedral */ public final static int TETRAHEDRAL = 4; /** * calculates bondlength. uses sum of covalent radii. if covalent radii * cannot be found, use bond length of 1.0 * * @param el1 * element * @param el2 * element * @return length */ public static double getBondLength(ChemicalElement el1, ChemicalElement el2) { double d1 = el1.getCovalentRadius(); double d2 = el2.getCovalentRadius(); // in case we have no covalent radii, set to 1.0 return (d1 < 0.1 || d2 < 0.1) ? 1.0 : d1 + d2; } /** * Calculates substituent points. Calculate substituent points for (0) zero * ligands of aPoint. The resultant points are randomly oriented: (i) 1 * points required; +x,0,0 (ii) 2 points: use +x,0,0 and -x,0,0 (iii) 3 * points: equilateral triangle in xy plane (iv) 4 points x,x,x, x,-x,-x, * -x,x,-x, -x,-x,x where 3x**2 = bond length * * @param aPoint * to which substituents are added * @param geometry * from: ANY, LINEAR, TRIGONAL, TETRAHEDRAL * @param length * from aPoint * * @throws EuclidRuntimeException if the geometry parameter is invalid * @return Point3[] ANY => 1, LINEAR => 2, TRIGONAL => 3, TETRAHEDRAL => 4 */ public static List calculate3DCoordinates0(Point3 aPoint, int geometry, double length) throws EuclidRuntimeException { if (geometry < ANY || geometry > TETRAHEDRAL) { throw new EuclidRuntimeException("Unknown value of geometry: " + geometry); } List points = new ArrayList(geometry); if (geometry == ANY) { points.add(new Point3(aPoint) .plus(new Vector3(length, 0.0, 0.0))); } else if (geometry == LINEAR) { points.add(new Point3(aPoint) .plus(new Vector3(length, 0.0, 0.0))); points.add(new Point3(aPoint) .plus(new Vector3(-length, 0.0, 0.0))); } else if (geometry == TRIGONAL) { points.add(new Point3(aPoint) .plus(new Vector3(length, 0.0, 0.0))); points.add(new Point3(aPoint).plus(new Vector3(-length * 0.5, -length * 0.5 * Math.sqrt(3.0), 0.0f))); points.add(new Point3(aPoint).plus(new Vector3(-length * 0.5, length * 0.5 * Math.sqrt(3.0), 0.0f))); } else if (geometry == TETRAHEDRAL) { double dx = length / Math.sqrt(3.0); points.add(new Point3(aPoint).plus(new Vector3(dx, dx, dx))); points.add(new Point3(aPoint).plus(new Vector3(dx, -dx, -dx))); points.add(new Point3(aPoint).plus(new Vector3(-dx, -dx, dx))); points.add(new Point3(aPoint).plus(new Vector3(-dx, dx, -dx))); } return points; } /** * Calculate new point(s) X in a B-A system to form B-A-X. Use C as * reference for * staggering about the B-A bond the X-A-B-C angle is 2*pi * * (1a) 1 ligand(B) of refAtom (A) which itself has a ligand (C) (i) 1 * points required; vector along AB vector (ii) 2 points: 2 vectors in ABC * plane, staggered and eclipsed wrt C (iii) 3 points: 1 staggered wrt C, * the others +- gauche wrt C If C is null, a random non-colinear C is * generated * * Note: If a pyramidal geometry (e.g. for C-N(-H)-H) is wanted, use * TETRAHEDRAL and the user must decide which point(s) to use * * @param aPoint * to which substituents are added * @param bPoint * reference ligand * @param cPoint * further ligand of bPoint to generate stagger * @param geometry * from: LINEAR, TRIGONAL, TETRAHEDRAL * @param length * A-X length * @param angle * B-A-X angle in radians * * @throws EuclidRuntimeException if the geometry is not LINEAR, TRIGONAL, or TETRAHEDRAL * @return Point3d[] nwanted points (or zero if failed) */ public static List calculate3DCoordinates1(Point3 aPoint, Point3 bPoint, Point3 cPoint, int geometry, double length, double angle) throws EuclidRuntimeException { if (geometry < LINEAR || geometry > TETRAHEDRAL) { throw new EuclidRuntimeException("Unknown value of geometry: " + geometry); } List points = new ArrayList(geometry - 1); // BA vector Vector3 ba = new Vector3(aPoint).subtract(new Vector3(bPoint)) .normalize(); if (geometry == LINEAR) { Vector3 ax = ba.multiplyBy(length); points.add(0, aPoint.plus(ax)); } else { // if no cPoint, generate a random reference if (cPoint == null) { cPoint = new Point3(ba.getNonColinearVector()); } // CB vector Vector3 cb = new Vector3(bPoint).subtract(new Vector3(cPoint)) .normalize(); // if A, B, C colinear, replace C by random point if (cb.isColinearVector(ba)) { Vector3 cVector = ba.getNonColinearVector(); cPoint = new Point3(cVector); cb = new Vector3(bPoint).subtract(new Vector3(cPoint)); } // cbxba = c x b Vector3 cbxba = cb.cross(ba).normalize(); // create three perp axes ba, cbxba, and ax Vector3 ax = ba.cross(cbxba).normalize(); int nrot = geometry - 1; double drot = Math.PI * 2.0 / (double) nrot; Point3 temp = new Point3(aPoint); double length1 = length * Math.sin(angle); for (int i = 0; i < nrot; i++) { double rot = (double) i * drot; Vector3 vx = new Vector3(ba); vx = vx.multiplyBy(-Math.cos(angle) * length); Vector3 vy = new Vector3(ax); vy = vy.multiplyBy(Math.cos(rot) * length1); Vector3 vz = new Vector3(cbxba); vz = vz.multiplyBy(Math.sin(rot) * length1); points.add(i, temp.subtract(vx).subtract(vy).subtract(vz)); } } return points; } /** * Calculate new point(s) X in a B-A-C system. It forms form a B-A(-C)-X * system. * * (2) 2 ligands(B, C) of refAtom A (i) 1 points required; vector in ABC * plane bisecting AB, AC. If ABC is linear, no points (ii) 2 points: 2 * points X1, X2, X1-A-X2 = angle about 2i vector * * Note: If a pyramidal geometry (e.g. for C-N(-C)-H) is wanted, use * TETRAHEDRAL * * @param aPoint * to which substituents are added * @param bPoint * first ligand of A * @param cPoint * second ligand of A * @param geometry * from: TRIGONAL, TETRAHEDRAL * @param length * A-X length * @param angle * B-A-X angle * * @throws EuclidRuntimeException if the geometry is not TRIGONAL or TETRAHEDRAL * @return Point3d[] nwanted points (or zero if failed) */ public static List calculate3DCoordinates2(Point3 aPoint, Point3 bPoint, Point3 cPoint, int geometry, double length, double angle) throws EuclidRuntimeException { if (geometry < TRIGONAL || geometry > TETRAHEDRAL) { throw new EuclidRuntimeException("Unknown value of geometry: " + geometry); } List points = new ArrayList(geometry - 2); double ang2 = angle / 2.0; Vector3 ba = new Vector3(aPoint).subtract(new Vector3(bPoint)); Vector3 ca = new Vector3(aPoint).subtract(new Vector3(cPoint)); Vector3 baxca = ba.cross(ca); if (ba.isColinearVector(ca)) { } else if (geometry == TRIGONAL) { Vector3 ax = new Vector3(ba).plus(ca).normalize() .multiplyBy(length); points.add(0, new Point3(aPoint).plus(ax)); } else if (geometry == TETRAHEDRAL) { baxca = baxca.normalize().multiplyBy(Math.sin(ang2) * length); Vector3 ax = new Vector3(ba).plus(ca).normalize().multiplyBy( Math.cos(ang2) * length); Point3 temp = new Point3(aPoint).subtract(ax); points.add(0, temp.plus(baxca)); points.add(1, temp.subtract(baxca)); } return points; } /** * Calculate new point X in a B-A(-D)-C system. It forms a B-A(-D)(-C)-X * system. * * (3) 3 ligands(B, C, D) of refAtom A (i) 1 points required; if A, B, C, D * coplanar, no points. else vector is resultant of BA, CA, DA * * @param aPoint * to which substituents are added * @param bPoint * first ligand of A * @param cPoint * second ligand of A * @param dPoint * third ligand of A * @param length * A-X length * * @return required point (or null if failed (coplanar)) */ public static Point3 calculate3DCoordinates3(Point3 aPoint, Point3 bPoint, Point3 cPoint, Point3 dPoint, double length) { Vector3 v1 = new Vector3(aPoint).subtract(new Vector3(bPoint)); Vector3 v2 = new Vector3(aPoint).subtract(new Vector3(cPoint)); Vector3 v3 = new Vector3(aPoint).subtract(new Vector3(dPoint)); // FIXME Vector3 vector = new Vector3(bPoint).plus(new // Vector3(cPoint)).plus(new Vector3(dPoint)); Vector3 v = new Vector3(v1).plus(new Vector3(v2)).plus(new Vector3(v3)); if (v.getLength() < 0.00001) { return null; } v = v.normalize().multiplyBy(length); Point3 point = new Point3(aPoint).plus(v); return point; } /** * tests the calculation of ligand coordinates */ public static void testCalculate3DCoordinates() { logger.info("\nadd ligand coordinates...\n"); final Point3 pZero = new Point3(10., 10., 10.); final Point3 pOne = new Point3(8., 10., 10.); final Point3 pStaggered = new Point3(8., 8., 10.); final Point3 pTwoa = new Point3(9., 9., 10.); final Point3 pTwob = new Point3(9., 11., 10.); final Point3 pThreea = new Point3(9., 9., 11.); final Point3 pThreeb = new Point3(9., 11., 9.); final Point3 pThreec = new Point3(11., 9., 9.); double length = 1.5; double angle = TETRAHEDRAL_ANGLE; double angles[] = { TETRAHEDRAL_ANGLE, TRIGONAL_ANGLE, TETRAHEDRAL_ANGLE, }; logger.info("\n\nadd ligands to atom with no ligands"); logger.info("add ligands to: " + pZero + "; length: " + length + "; angle: " + angle); for (int geometry = ANY; geometry <= TETRAHEDRAL; geometry++) { logger.info("\nType of geometry: " + geometry + CMLConstants.S_COLON); try { List ligands = calculate3DCoordinates0(pZero, geometry, length); for (int i = 0; i < ligands.size(); i++) { logger.info("...ligand:" + ligands.get(i)); } } catch (EuclidRuntimeException e) { logger.info("Exception: " + e); } } logger.info("\n\nadd ligands to atom with one ligand"); logger.info("add ligands to: " + pZero + "; length: " + length + "; angle: " + angle); logger.info("reference atom: " + pOne); for (int geometry = LINEAR; geometry <= TETRAHEDRAL; geometry++) { logger.info("\nType of geometry: " + geometry + CMLConstants.S_COLON); List ligands = calculate3DCoordinates1(pZero, pOne, pStaggered, geometry, length, angles[geometry - 2]); for (int i = 0; i < ligands.size(); i++) { logger.info("...ligand:" + ligands.get(i)); } for (int i = 0; i < ligands.size(); i++) { logger.info("distance: ref-" + i + " = " + ligands.get(i).getDistanceFromPoint(pZero)); } for (int i = 0; i < ligands.size(); i++) { for (int j = i + 1; j < ligands.size(); j++) { logger.info("angle: " + i + "-ref-" + j + " = " + Point3.getAngle(ligands.get(i), pZero, ligands.get(j))); } logger.info("angle: lig-ref-refa = " + Point3.getAngle(ligands.get(i), pZero, pOne)); } for (int i = 0; i < ligands.size(); i++) { logger.info("torsion: " + i + "-ref-ref1-ref2 = " + Point3.getTorsion(ligands.get(i), pZero, pOne, pStaggered)); } } logger.info("\n\nadd ligands to atom with two ligands"); logger.info("add ligands to: " + pZero + "; length: " + length + "; angle: " + angle); logger.info("reference atoms: " + pTwoa + CMLConstants.S_SLASH + pTwob); for (int geometry = TRIGONAL; geometry <= TETRAHEDRAL; geometry++) { logger.info("\nType of geometry: " + geometry + CMLConstants.S_COLON); List ligands = calculate3DCoordinates2(pZero, pTwoa, pTwob, geometry, length, angles[geometry - 2]); for (int i = 0; i < ligands.size(); i++) { logger.info("...ligand:" + ligands.get(i)); } for (int i = 0; i < ligands.size(); i++) { logger.info("distance: ref-" + i + " = " + ligands.get(i).getDistanceFromPoint(pZero)); } for (int i = 0; i < ligands.size(); i++) { for (int j = i + 1; j < ligands.size(); j++) { logger.info("angle: " + i + "-ref-" + j + " = " + Point3.getAngle(ligands.get(i), pZero, ligands.get(j))); } logger.info("angle: lig-ref-refa = " + Point3.getAngle(ligands.get(i), pZero, pTwoa)); logger.info("angle: lig-ref-refb = " + Point3.getAngle(ligands.get(i), pZero, pTwob)); } } logger.info("\n\nadd ligand to atom with three ligands"); logger.info("reference atoms: " + pThreea + CMLConstants.S_SLASH + pThreeb + CMLConstants.S_SLASH + pThreec); Point3 ligand = calculate3DCoordinates3(pZero, pThreea, pThreeb, pThreec, length); logger.info("Ligand: " + ligand); logger .info("distance: ref-lig = " + ligand.getDistanceFromPoint(pZero)); logger.info("angle: lig-ref-refa = " + Point3.getAngle(ligand, pZero, pThreea)); logger.info("angle: lig-ref-refb = " + Point3.getAngle(ligand, pZero, pThreeb)); logger.info("angle: lig-ref-refc = " + Point3.getAngle(ligand, pZero, pThreec)); } /** * main. * * @param args */ public static void main(String[] args) { logger.info("Runs tests..."); testCalculate3DCoordinates(); } } cmlxom-cmlxom-4.11/src/main/resources/000077500000000000000000000000001477224461000177675ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/000077500000000000000000000000001477224461000226565ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/000077500000000000000000000000001477224461000234545ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/attributes/000077500000000000000000000000001477224461000256425ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/attributes/attributes.rnc000077500000000000000000000242001477224461000305350ustar00rootroot00000000000000namespace cml = "http://www.xml-cml.org/schema" namespace fpx = "http://www.uszla.me.uk/fpx" namespace xsd = "http://www.w3.org/2001/XMLSchema" namespace dc = "http://purl.org/dc/elements/1.1/" namespace local = "" namespace inherit = inherit include "../types/XMLFP.rnc" inherit = inherit include "../types/cmltypes.rnc" inherit = inherit dc:title [ "cmlattributes: the CML attributes used in CML Lite." ] dc:description [ "RELAX NG schema for the attributes used in CML Lite." ] dc:author [ "Peter Murray-Rust" ] dc:author [ "J A Townsend" ] dc:rights [ "© Copyright J A Townsend 2008." ] dc:date ["20081905"] ## We require that dictRef attributes be a QName dictRef = attribute dictRef { xsd:QName } # 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. # # perhaps instead of being string context it might be better to have it as # qname - in the same way as dictionaries work - so we can define what we mean... # convention = attribute convention { refType } #convention = attribute convention { xsd:string } # The count of the object. # Typically used for nested complex formulae Na2 S2O4 10H2O or molecules count = attribute count { xsd:double { minInclusive='0.0' } } # We require the formalCharge be integer. formalCharge = attribute formalCharge { xsd:integer } # Normally for a molecule but may be for an atom. # This attribute gives the spin multiplicity of the # molecule and is independent of any atomic information. spinMultiplicity = attribute spinMultiplicity { xsd:positiveInteger } # A reference to a list of atoms. # Although the definition only gives refType dataType, these # MUST be atom ids atomRefs = attribute atomRefs { list { refType + } } # A reference to a list of bonds. # Although the definition only gives refType dataType, these # MUST be bond ids bondRefs = attribute bondRefs { list { refType + } } ## References to two different atoms. atomRefs2 = attribute atomRefs2 { list { refType, refType } } # A reference to four distinct existing atoms in order. # Although the definition only gives refType dataType, these # MUST be atom ids atomRefs4 = attribute atomRefs4 { list { refType, refType, refType, refType } } ## The chirality of a system or molecule. ## This is being actively investigated by a IUPAC committee (2002) ## so the convention is likely to change. No formal default. chirality = attribute chirality { chiralityType } ## A concise formula. ## The string represents an (unstructured) formula i.e. no submolecules. ## Recommended to use the format "H 2 O 1", etc. concise = attribute concise { formulaType } # The data type of the object. # Normally applied to scalar/array objects but may extend to more complex ones. # dataType = attribute dataType { "xsd:string" | "xsd:boolean" | "xsd:float" | "xsd:double" | "xsd:decimal" | "xsd:duration" | "xsd:dateTime" | "xsd:time" | "xsd:date" | "xsd:gYearMonth" | "xsd:gYear" | "xsd:gMonthDay" | "xsd:gDay" | "xsd:gMonth" | "xsd:hexBinary" | "xsd:base64Binary" | "xsd:anyURI" | "xsd:QName" | "xsd:NOTATION" | "xsd:normalizedString" | "xsd:token" | "xsd:language" | "xsd:IDREFS" | "xsd:ENTITIES" | "xsd:NMTOKEN" | "xsd:NMTOKENS" | "xsd:Name" | "xsd:NCName" | "xsd:ID" | "xsd:IDREF" | "xsd:ENTITY" | "xsd:integer" | "xsd:nonPositiveInteger" | "xsd:negativeInteger" | "xsd:long" | "xsd:int" | "xsd:short" | "xsd:byte" | "xsd:nonNegativeInteger" | "xsd:unsignedLong" | "xsd:unsignedInt" | "xsd:unsignedShort" | "xsd:unsignedByte" | "xsd:positiveInteger" } ## The identity of a chemical element. ## The periodic table up to element number 118. ## In addition the following strings are allowed: ## Du - ("dummy") This does not correspond to a "real" atom and can ## support a point in space or within a chemical graph. ## R - ("R-group") This indicates that an atom or group of atoms ## could be attached at this point. elementType = attribute elementType { elementTypeType } ## A unique ID for an element. ## IMPORTANT NOTE. ## A CML id is *NOT* an XML id. This is a deliberate policy choice on PMR's part. ## The id may appear as a QName but is not interpreted as such - any use of this ## representation is only for human readability (i.e. m1:a1 may refer to atom 1 ## (a1) in the first molcule (m1)) id = attribute id { refType } ## An inline representation of the object. ## This can represent a wide range of information from formal serialization ## as ASCII through to domain-specific textual representations. It will often be used in conjunction ## with the "convention" attribute. For example it could be used to represent IUPAC formula, ## SMILES strings, TeX equations, etc. Characters should conform to the XML character set, ## and XML markup (lt and amp) should be escaped. IT SHOULD NEVER BE USED FOR INLINE XML inline = attribute inline { xsd:string }## ## The integer number for an isotope isotopeNumber = attribute isotopeNumber { xsd:positiveInteger } ## The maximum value allowed for an element or attribute. max = attribute max { xsd:string } ## The minimum INCLUSIVE value allowed for an element or attribute. min = attribute min { xsd:string } ## The namespace for a data item. \namespace = attribute \namespace { xsd:string { pattern='http://[A-Za-z][A-Za-z0-9_\.\-]*(/[A-Za-z0-9_\.\-]+)+' } } ## The order of the bond. order = attribute order { orderType } ## Multiplicity of a peak. ## === NEEDS WORK, SHOULD BE NAMESPACED IE DICT REF TYPE ? === peakMultiplicity = attribute peakMultiplicity { xsd:string } ## Shape of a peak. ## Semi-controlled vocabulary such as broad or sharp. ## === NEEDS WORKS, SHOULD IT BE NAMESPACED IE DICT REF TYPE ? === peakShape = attribute peakShape { xsd:string } ## A reference to an element of given type. ## ref modifies an element into a reference to an existing element of that type ## within the document. This is similar to a pointer and it can be thought of a ## strongly typed hyperlink. It may also be used for "subclassing" or "overriding" elements. ## When referring to an element most of the "data" such as attribute values and element content ## will be on the full instantiated element. Therefore ref (and possibly id) will normally be ## the only attributes on the pointing element. However there may be some attributes (title, count, ## etc.) which have useful semantics, but these are element-specific ref = attribute ref { refType } ## A term in a dictionary. ## The term should be a noun or nounal phrase, with a separate definition and further description. term = attribute term { xsd:string } ## A title on an element. ## No controlled value. title = attribute title { xsd:string } ## Scientific units on an element. ## These must be taken from a dictionary ## of units. There should be some mechanism for validating the type ## of the units against the possible values of the element. units = attribute units { xsd:QName } ## The version of the element. ## cml or identifier elements can currently have ## versions. They may be dependent on the date of release and this ## attribute is highly recommended. version = attribute version { xsd:string } ## x coordinate for an object in 2D (not related to 3D). ## axis orientation matters as this could change chirality. x2 = attribute x2 { realNumberWithExponent } ## x coordinate for an object in 3D in Angstrom. ## Objects are always described with a right-handed coordinate system x3 = attribute x3 { realNumberWithExponent } ## Maximum xValue. ## Annotates x-axis data with a maximum ## value. This need not be algorithmically deducible from the data ## and is typically used for the extent of a _peak_ or _peakGroup_. ## It uses xUnits or the same units as the data. There may or may not ## be a _xMin_ attribute but if so xMax should be greater than or ## equals to it. xMax = attribute xMax { realNumberWithExponent } ## Minimum xValue. ## Annotates x-axis data with a minimum ## value. This need not be algorithmically deducible from the data ## and is typically used for the extent of a _peak_ or _peakGroup_. ## It uses xUnits or the same units as the data. There may or may not ## be a _xMax_ attribute but if so xMin should be less than or equals ## to it. xMin = attribute xMin { realNumberWithExponent } ## Units for x axis. ## All x-axis data must have unambiguous units. xUnits = attribute xUnits { xsd:QName } ## Value along an x axis. ## Annotates x-axis data with a value. It ## is typically used for the location of a _peak_ or _peakGroup_. It ## uses xUnits. xValue = attribute xValue { realNumberWithExponent } ## y coordinate for an object in 2D (not related to 3D). ## axis orientation matters as this could change chirality. y2 = attribute y2 { realNumberWithExponent } ## y coordinate for an object in 3D in Angstrom. ## Objects are always described with a right-handed coordinate system y3 = attribute y3 { realNumberWithExponent } ## Units for y axis. ## All y-axis data must have unambiguous units. yUnits = attribute yUnits { xsd:QName } ## Value along an y axis. ## Annotates y-axis data with a value. It ## is typically used for the location of a _peak_ or _peakGroup_. It ## uses yUnits. yValue = attribute yValue { realNumberWithExponent } ## z coordinate for an object in 3D in Angstrom. ## Objects are always described with a right-handed coordinate system z3 = attribute z3 { realNumberWithExponent } cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/elements/000077500000000000000000000000001477224461000252705ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/elements/elements.rnc000077500000000000000000000576071477224461000276320ustar00rootroot00000000000000namespace cmlns = "http://www.xml-cml.org/schema" namespace xsd = "http://www.w3.org/2001/XMLSchema" namespace dc = "http://purl.org/dc/elements/1.1/" namespace h = "http://www.w3.org/1999/xhtml" namespace local = "" namespace inherit = inherit include "../attributes/attributes.rnc" dc:creator [ "Joseph A. Townsend jat45@cantab.net" ] dc:contributor [ "Peter Murray-Rust pm286@cam.ac.uk" ] dc:contributor [ "Jim Downing ojd20@cam.ac.uk" ] dc:rights [ "This " h:span [ href="http://purl.org/dc/dcmitype/Text" rel="dc:type" "work" ] " is licenced under a " h:a[ rel="license" href="http://creativecommons.org/licenses/by-nd/2.0/uk/" "Creative Commons Licence." ] ] dc:title [ "CMLLite element definitions" ] dc:description [ "CMLLite element definitions" ] ## the ANY equivalent from DTD any = (element *- ( cmlns:label |cmlns:name | cmlns:atomParity | cmlns:bondStereo | cmlns:scalar | cmlns:entry | cmlns:atom | cmlns:atomArray | cmlns:bond | cmlns:bondArray | cmlns:dictionary | cmlns:formula | cmlns:peakStructure | cmlns:peak | cmlns:peakList | cmlns:property |cmlns:spectrum |cmlns:cml | cmlns:molecule ) { attribute * { text }*, any } | text)* nonCMLElement = (element *- ( cmlns:label |cmlns:name | cmlns:atomParity | cmlns:bondStereo | cmlns:scalar | cmlns:entry | cmlns:atom | cmlns:atomArray | cmlns:bond | cmlns:bondArray | cmlns:dictionary | cmlns:formula | cmlns:peakStructure | cmlns:peak | cmlns:peakList | cmlns:property |cmlns:spectrum |cmlns:cml | cmlns:molecule ) { attribute * { text } *, nonCMLElement } ) anyElement = (element *- ( cmlns:label |cmlns:name | cmlns:atomParity | cmlns:bondStereo | cmlns:scalar | cmlns:entry | cmlns:atom | cmlns:atomArray | cmlns:bond | cmlns:bondArray | cmlns:dictionary | cmlns:formula | cmlns:peakStructure | cmlns:peak | cmlns:peakList | cmlns:property |cmlns:spectrum |cmlns:cml | cmlns:molecule ) { attribute * { text } *, anyElement } )* | label | name | atomParity | bondStereo | scalar | entry | atom | atomArray | bond | bondArray | dictionary | formula | peakStructure | peak | peakList | property | spectrum | cml | molecule # ELEMENTS THAT HAVE SIMPLE (i.e. NOT ELEMENT) CHILDREN label = [ xsd:documentation [ h:div [ class='summary' "A text string qualifying an object." ] h:div [ class='description' h:p [ "A label can be used to identify or distinguish elements, add keywords or classifications and similar processes. It is usually interpretable by domain-aware humans (e.g. C3'-endo, but not a34561). It is usually either built in a semantically rich fashion (e.g. C2'-alpha-H) or belongs to a controlled vocabulary. It is possibly accessed by software in a domain-specific manner. It differs from " h:tt [ "description" ] " which is free text. The distinction between titles, names and labels is fuzzy, but we think this is worth making. Labels may be necesssary to identify objects within programs, while names are more likely to be reserved for database searches. Titles are likely to be freer text and not recommended for precise object retrieval." ] ] h:div [ class='note' "Labels should not contain whitespace. Punctuation marks are often necessary, but should not be gratuitously used. Punctuation clashing with XML character entities should be avoided; if this is not possible it should be escaped." ] ]] element cmlns:label { id ?, dictRef ?, convention ?, # should have convention attribute *- (cmlns:*|local:*) { text } *, # element content type ( xsd:string ) } name = element cmlns:name { [ xsd:documentation [ h:div [ class='summary' "A string identifying a object." ] h:div [ class='description' h:p [ h:tt [ "name" ] " is used for chemical names (formal and trivial) for molecules and also for identifiers such as CAS registry and RTECS. It can also be used for labelling atoms. It should be used in preference to the " h:tt [ "title" ] " attribute because it is repeatable and can be linked to a dictionary." ] h:p [ "Constraining patterns can be described in the dictionary and used to validate " h:tt [ "name" ] "s." ] ] ]] id ?, convention ?, attribute *- (cmlns:*|local:*) { text } *, # element content type xsd:string } atomParity = element cmlns:atomParity { [ xsd:documentation [ h:div [ class='summary' "The stereochemistry round an atom centre." ] h:div [ class='description' h:p [ "It follows the convention of the MIF format, and uses 4 distinct atoms to define the chirality. These can be any atoms (though they are normally bonded to the current atom). There is no default order and the order is defined by the atoms in the atomRefs4 attribute. If there are only 3 ligands, the current atom should be included in the 4 atomRefs." ] h:p [ "The value of the parity is a signed number. (It can only be " "zero if two or more atoms are coincident or the configuration is " "planar). The sign is the sign of the chiral volume created by the " "four atoms (a1, a2, a3, a4):" h:pre [ "| 1 1 1 1 |" ] h:pre [ "| x1 x2 x3 x4 |" ] h:pre [ "| y1 y2 y3 y4 |" ] h:pre [ "| z1 z2 z3 z4 |" ] ] ] ]] atomRefs4, id ?, attribute *- (cmlns:*|local:*) { text } *, # element content type realNumberWithExponent } ## A container supporting cis trans wedge hatch and other stereochemistry. ## An explict list of atomRefs4 must be given for cis/trans. There are no implicit conventions such ## as E/Z. This will be extended to other types of stereochemistry. bondStereo = element cmlns:bondStereo { # mandatory attributes atomRefs4 ?, #not necessary for wedge/hatch convention, # optional attributes id ?, attribute *- (cmlns:*|local:*) { text } *, # element content type xsd:string } scalar = element cmlns:scalar { [ xsd:documentation [ h:div [ class='summary' "An element to hold scalar data." ] h:div [ class='description' h:p [ h:tt [ "scalar" ] " holds scalar data under a single generic container. The semantics are usually resolved by linking to a dictionary. " h:b [ "scalar" ] " defaults to a scalar string but has attributes which affect the type." ] h:p [ h:tt [ "scalar" ] " does not necessarily reflect a physical object. It may reflect a property of an object" " such as temperature, size, etc. " ] h:p [ "Note that normal Schema validation tools cannot validate the data type of " h:b [ "scalar" ] " (it is defined as " h:tt [ "string" ] "), but that a temporary schema " "can be constructed from the type and used for validation. Also the type " "can be contained in a dictionary and software could decide to retrieve this " "and use it for validation." ] ] ]] # mandatory attributes # although the content type of the element is string the dataType attribute allows the specification of how this should be interpreted dataType, units, id ?, # scalar must have one or more of max, min and content (text node) max ?, min ?, attribute *- (cmlns:*|local:*) { text } *, # element content type xsd:string } entry = element cmlns:entry { [ xsd:documentation [ h:div [ class='summary' "A dictionary entry." ] h:div [ class='description' h:p [ "The original design for validation with attribute-based constraints is ponderous and fragile. In future constraints will be added through " h:tt [ "appinfo" ] " in " h:tt [ "annotation" ] ". We shall develop this further in the near future." ] ] ]] id, dataType, term, title, convention ?, attribute *- (cmlns:*|local:*) { text } *, # child elements # === might be xhtml, RDF, cml etc. === # the entry might be only human understandable but acts as a # URI for, or may contain machine understandable limitations # on the possible values (eg m.p. > 0 K) any } # NOW DEFINE ELEMENTS THAT HAVE COMPLEX (i.e. ELEMENT) CHILDREN atom = element cmlns:atom { [ xsd:documentation [ h:div [ class='summary' "An atom." ] h:div [ documentation='general' h:p [ "Atoms can only be chosen from the periodic table and superatoms such as 'Phe' or 'Tyr' are not allowed. The elementType of an atom is identified by that attribute. There are two additional elementTypes, 'Du' (for an object which does not have an identifiable nucleus but is useful in calculations and definitions (such as a centroid); and 'R' which describes a generic fragment. Although atoms have an elementType, they do not, by default, support arbitrary atomTypes for which the element should be used." ] ] ]] # mandatory attributes elementType, id, # optional attributes x2 ?, y2 ?, x3 ?, y3 ?, z3 ?, isotopeNumber ?, title ?, formalCharge ?, attribute *- (cmlns:*|local:*) { text } *, # child elements ( label* & name* & atomParity? ) } atomArray = element cmlns:atomArray { [ xsd:documentation [ h:div [ class='summary' "A container for a list of atoms." ] h:div [ class='description' h:p [ "A child of _molecule_ and contains _atom_ information. There are two strategies:" h:ul [ h:li [ "Create individual _atom_ elements under _atomArray_ (in any order). This gives the greatest flexibility but is the most verbose." ] h:li [ "Create " h:tt [ "*Array" ] " attributes (e.g. of" h:tt [ "elementTypeArrayType" ] " under " h:tt[ "atomArray" ] ". This requires all arrays to be of identical lengths with explicit values for all atoms in every array. This is NOT suitable for complexType atom children such as atomParity. It also cannot be checked as easily by schema- and schematron validation. The _atomIDArray_ attribute is mandatory. It is allowed (though not yet recommended) to add _*Array_ children such as _floatArray_" ] ] "The attributes are directly related to the scalar attributes under " h:tt [ "atom" ] " which should be consulted for more info." ] ] ]] id ?, attribute *- (cmlns:*|local:*) { text } *, # child elements atom + } bond = element cmlns:bond { [ xsd:documentation [ h:div [ class='summary' "A bond between atoms, or between atoms and bonds." ] h:div [ class='description' h:p [ "_bond_ is a child of _bondArray_ and contains bond information. Bond must refer to at least two atoms (normally using _atomRefs2_) but may also refer to more for multicentre bonds. Bond is often EMPTY but may contain _electron_, _length_ or _bondStereo_ elements." ] ] ]] id, atomRefs2, # optional attributes order ?, title ?, attribute *- (cmlns:*|local:*) { text } *, # child elements ( label* & name* & bondStereo? ) } bondArray = element cmlns:bondArray { [ xsd:documentation [ h:div [ class='summary' "A container for a number of bonds." ] h:div [ class='description' h:p [ "_bondArray_ is a child of _molecule_ and contains _bond_ information. There are two strategies:" h:ul [ h:li [ "Create individual " h:tt [ "bond" ] " elements under " h:tt [ "bondArray" ] " (in any order). This gives the greatest flexibility but is the most verbose." ] h:li [ "Create " h:tt [ "*Array" ] " attributes (e.g. of " h:tt [ "orderArrayType" ] " under " h:tt [ "bondArray" ] ". This requires all arrays to be of identical lengths with explicit values for all bonds in every array. This is NOT suitable for complexType bond children such as _bondStereo_ nor can IDs be added to bonds.. It also cannot be checked as easily by schema- and schematron validation. The _atomRef1Array_ and _atomRef2Array_ attributes are then mandatory. It is allowed (though not yet recommended) to add _*Array_ children such as _floatArray_" ] ] ] h:p [ "The attributes are directly related to the scalar attributes under _atom_ which should be consulted for more info." ] ] ]] id ?, attribute *- (cmlns:*|local:*) { text } *, # child elements bond+ } dictionary = element cmlns:dictionary { [ xsd:documentation [ h:div [ class='name' "dictionary" ] h:div [ class='summary' "A dictionary." ] h:div [ class='description' h:p [ "A dictionary is a container for _entry_ elements. Dictionaries can also contain unit-related information. The dictRef attribute on a dictionary element sets a namespace-like prefix allowing the dictionary to be referenced from within the document. In general dictionaries are referenced from an element using the __dictRef__ attribute." ] ] ]] convention, title, \namespace, # optional attributes id ?, attribute *- (cmlns:*|local:*) { text } *, # child elements entry + } formula = element cmlns:formula { [ xsd:documentation [ h:div [ class='summary' "A molecular formula." ] h:div [ class='description' h:p [ "It is defined by " h:tt [ "atomArray" ] "s each with a list of elementTypes and their counts. All other information in the " h:tt [ "atomArray" ] " is ignored. " h:tt [ "formula" ] " are nestable so that aggregates (e.g. hydrates, salts, etc.) can be described. CML does not require that formula information is consistent with (say) crystallographic information; this allows for experimental variance." ] h:p [ "An alternative briefer representation is also available through the " h:tt [ "concise" ] ". This must include whitespace round all elements and their counts, which must be explicit." ] ] ]] # optional attributes id ?, convention ?, title ?, count ?, # must have a count if child of formula, otherwise no count formalCharge ?, concise ?, # should have concise if possible inline ?, attribute *- (cmlns:*|local:*) { text } *, # child elements ( empty | atomArray | ( formula, formula + ) ) } peakStructure = element cmlns:peakStructure { [ xsd:documentation [ h:div [ class='summary' "The structure of a peak in a spectrum." ] h:div [ class='description' h:p [ "Primarily to record couplings and other fine structure. At present we have tested this on HNMR spectra, C13 NMR and simple IR. We believe that other types of spectroscopy (ESR, NQR, etc) can be represented to some extent, but there may be systems beyond the current expressive power." ] ] ]] dictRef, id ?, title ?, atomRefs ?, bondRefs ?, peakShape ?, attribute *- (cmlns:*|local:*) { text } *, ( name * & label * ) } peak = element cmlns:peak { [ xsd:documentation [ h:div [ class='name' "peak" ] h:div [ class='summary' "A peak; annotated by human or machine." ] h:div [ class='description' h:p [ "A " h:tt [ "peak" ] " can describe:" h:ul [ h:li [ "A single point in a spectrum. Usually a maximum but could be a shoulder, inflexion or indeed any point of interest." ] h:li [ "A continuous range of values within a spectrum, defined by maximum and minimum values on either/both axes." ] ] ] h:p [ "A peak may be described by specifying xValue " h:i [ "or" ] " by giving xMax " h:i [ "and" ] " xMin. It seems reasonable to also allow xValue and xMax and xMin." ] h:p [ "If yValue is given on a peak then it must also be specified for all peaks within the containing peakList." ] ] h:div [ class='note' h:p [ "The finer structure of the peak can be given with one or more peakStructure children." ] ] h:div [ class='question' h:p [ "Do we want to support expressions such as 'a carbonyl peak is typically seen over 190 ppm'." ] ] ]] id, title ?, atomRefs ?, bondRefs ?, yValue ?, xValue ?, xMax ?, xMin ?, peakMultiplicity ?, attribute *- (cmlns:*|local:*) { text } *, # child elements ( label * & name * & peakStructure * ) } ## A list of peaks. ## Distinguish between peakList (primarily a navigational container) ## and peakGroup where the peaks (or groups) have some close relation ## not shared by all peaks. All peaks and peakGroups should use the same ## units. peakList = element cmlns:peakList { [ xsd:documentation [ h:div [ class='summary' "A list of peaks or peakGroups." ] h:div [ class='description' h:p [ "Distinguish between " h:tt [ "peakList" ] " (primarily a navigational container) and " h:tt [ "peakGroup" ] " where the peaks (or groups) have some close relation not shared by all peaks. All peaks and peakGroups should use the same units." ] ] ]] xUnits, id ?, title ?, yUnits ?, attribute *- (cmlns:*|local:*) { text } *, # child elements peak + } ## A container for a property. ## property can contain one or more children, usually scalar, ## array or matrix. The dictRef attribute is required, even if ## there is a single scalar child with the same dictRef. The ## property may have a different dictRef from the child, thus ## providing an extension mechanism. property = element cmlns:property { [ xsd:documentation [ h:div [ class='summary' "A container for a property." ] h:div [ class='description' h:p [ h:tt [ "property" ] " can contain one or more children, usually " h:tt [ "scalar" ] ", " h:tt [ "array" ] " or " h:tt [ "matrix" ] ". The " h:tt [ "dictRef" ] " attribute is required, even if there is a single scalar child with the same dictRef. The property may have a different dictRef from the child, thus providing an extension mechanism." ] h:p [ "Properties may have a " h:tt [ "state" ] " attribute to distinguish the state of matter" ] ] ]] dictRef, id ?, title ?, attribute *- (cmlns:*|local:*) { text } *, # child elements ( name * & label * & ( scalar ? | property + ) ) } spectrum = element cmlns:spectrum { [ xsd:documentation [ h:div [ class='summary' "A spectrum and relevant data or metadata." ] h:div [ class='description' h:p [ "The " h:tt [ "spectrum" ] " construct can hold " h:tt [ "metadataList" ] ", " h:tt [ "sample" ] " (which can contain molecule), " h:tt [ "conditionList" ] " (mainly for physical/chemical conditions, not instrumental), " h:tt [ "spectrumData" ] " for the actual data and instrumental settings/procedure and " h:tt [ "peakList" ] " for the assigned peaks. This approach puts the spectrum as the primary object of interest. It could also be possible to make " h:tt [ "spectrum" ] " a child of " h:tt [ "molecule" ] " (although a reference using " h:tt [ "ref" ] " might be preferable)." ] ] ]] dictRef, # optional attributes id ?, convention ?, title ?, attribute *- (cmlns:*|local:*) { text } *, # child elements ( peakList & property * ) } ## A general container for CML elements. ## Often the root of the CML (sub)document. ## Has no explicit function but can serve to hold the dictionary and ## namespace and version information, and is a useful tag to alert ## CML processors and search/XMLQuery tools that there is chemistry in the document. ## Can contain any content, but usually a list of molecules and other CML components. cml = element cmlns:cml { # optional attributes id ?, convention ?, # convention is mandatory on the eldest cml element title ?, version ?, # mandatory on the eldest cml element attribute *- (cmlns:*|local:*) { text } *, # any cml child element is allowed as a child anyElement # we don't allow mixed content in CML but it may be wrapped by html for example } ## A container for atoms, bonds and submolecules. ## molecule is a container for atoms, bonds and submolecules along ## with properties such as crystal and non-built in properties. It should either ## contain molecule or *Array for atoms and bonds. A molecule can be empty (e.g. ## we just know its name, id, etc.) ## "Molecule" need not represent a chemically meaningful molecule. It ## can contain atoms with bonds (as in the solid-sate) and it could ## simply carry a name (e.g. "taxol") without formal representation ## of the structure. It can contain "sub molecules", which are often ## discrete subcomponents (e.g. guest-host). molecule = element cmlns:molecule { # mandatory attributes id, # optional attributes title ?, # must have count if not eldest molecule element count ?, # formalCharge on a molecule takes presidence over formalCharge on any younger elements formalCharge ?, spinMultiplicity ?, ref ?, chirality ?, attribute *- (cmlns:*|local:*) { text } *, # child elements ( atomArray ? & bondArray ? & formula ? & label * & molecule * & name * & property * & spectrum * & cml* ) } cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/elements/elements.rng000077500000000000000000001107421477224461000276240ustar00rootroot00000000000000 Joseph A. Townsend jat45@cantab.net Peter Murray-Rust pm286@cam.ac.uk Jim Downing ojd20@cam.ac.uk This work is licenced under a Creative Commons Licence. CMLLite element definitions CMLLite element definitions the ANY equivalent from DTD cmlns:label cmlns:name cmlns:atomParity cmlns:bondStereo cmlns:scalar cmlns:entry cmlns:atom cmlns:atomArray cmlns:bond cmlns:bondArray cmlns:dictionary cmlns:formula cmlns:peakStructure cmlns:peak cmlns:peakList cmlns:property cmlns:spectrum cmlns:cml cmlns:molecule cmlns:label cmlns:name cmlns:atomParity cmlns:bondStereo cmlns:scalar cmlns:entry cmlns:atom cmlns:atomArray cmlns:bond cmlns:bondArray cmlns:dictionary cmlns:formula cmlns:peakStructure cmlns:peak cmlns:peakList cmlns:property cmlns:spectrum cmlns:cml cmlns:molecule cmlns:label cmlns:name cmlns:atomParity cmlns:bondStereo cmlns:scalar cmlns:entry cmlns:atom cmlns:atomArray cmlns:bond cmlns:bondArray cmlns:dictionary cmlns:formula cmlns:peakStructure cmlns:peak cmlns:peakList cmlns:property cmlns:spectrum cmlns:cml cmlns:molecule A text string qualifying an object. A label can be used to identify or distinguish elements, add keywords or classifications and similar processes. It is usually interpretable by domain-aware humans (e.g. C3'-endo, but not a34561). It is usually either built in a semantically rich fashion (e.g. C2'-alpha-H) or belongs to a controlled vocabulary. It is possibly accessed by software in a domain-specific manner. It differs from description which is free text. The distinction between titles, names and labels is fuzzy, but we think this is worth making. Labels may be necesssary to identify objects within programs, while names are more likely to be reserved for database searches. Titles are likely to be freer text and not recommended for precise object retrieval. Labels should not contain whitespace. Punctuation marks are often necessary, but should not be gratuitously used. Punctuation clashing with XML character entities should be avoided; if this is not possible it should be escaped. A string identifying a object. name is used for chemical names (formal and trivial) for molecules and also for identifiers such as CAS registry and RTECS. It can also be used for labelling atoms. It should be used in preference to the title attribute because it is repeatable and can be linked to a dictionary. Constraining patterns can be described in the dictionary and used to validate name s. The stereochemistry round an atom centre. It follows the convention of the MIF format, and uses 4 distinct atoms to define the chirality. These can be any atoms (though they are normally bonded to the current atom). There is no default order and the order is defined by the atoms in the atomRefs4 attribute. If there are only 3 ligands, the current atom should be included in the 4 atomRefs. The value of the parity is a signed number. (It can only be zero if two or more atoms are coincident or the configuration is planar). The sign is the sign of the chiral volume created by the four atoms (a1, a2, a3, a4):| 1 1 1 1 | | x1 x2 x3 x4 | | y1 y2 y3 y4 | | z1 z2 z3 z4 | A container supporting cis trans wedge hatch and other stereochemistry. An explict list of atomRefs4 must be given for cis/trans. There are no implicit conventions such as E/Z. This will be extended to other types of stereochemistry. An element to hold scalar data. scalar holds scalar data under a single generic container. The semantics are usually resolved by linking to a dictionary. scalar defaults to a scalar string but has attributes which affect the type. scalar does not necessarily reflect a physical object. It may reflect a property of an object such as temperature, size, etc. Note that normal Schema validation tools cannot validate the data type of scalar (it is defined as string ), but that a temporary schema can be constructed from the type and used for validation. Also the type can be contained in a dictionary and software could decide to retrieve this and use it for validation. A dictionary entry. The original design for validation with attribute-based constraints is ponderous and fragile. In future constraints will be added through appinfo in annotation . We shall develop this further in the near future. An atom. Atoms can only be chosen from the periodic table and superatoms such as 'Phe' or 'Tyr' are not allowed. The elementType of an atom is identified by that attribute. There are two additional elementTypes, 'Du' (for an object which does not have an identifiable nucleus but is useful in calculations and definitions (such as a centroid); and 'R' which describes a generic fragment. Although atoms have an elementType, they do not, by default, support arbitrary atomTypes for which the <atomType> element should be used. A container for a list of atoms. A child of _molecule_ and contains _atom_ information. There are two strategies: Create individual _atom_ elements under _atomArray_ (in any order). This gives the greatest flexibility but is the most verbose. Create *Array attributes (e.g. ofelementTypeArrayType under atomArray . This requires all arrays to be of identical lengths with explicit values for all atoms in every array. This is NOT suitable for complexType atom children such as atomParity. It also cannot be checked as easily by schema- and schematron validation. The _atomIDArray_ attribute is mandatory. It is allowed (though not yet recommended) to add _*Array_ children such as _floatArray_ The attributes are directly related to the scalar attributes under atom which should be consulted for more info. A bond between atoms, or between atoms and bonds. _bond_ is a child of _bondArray_ and contains bond information. Bond must refer to at least two atoms (normally using _atomRefs2_) but may also refer to more for multicentre bonds. Bond is often EMPTY but may contain _electron_, _length_ or _bondStereo_ elements. A container for a number of bonds. _bondArray_ is a child of _molecule_ and contains _bond_ information. There are two strategies: Create individual bond elements under bondArray (in any order). This gives the greatest flexibility but is the most verbose. Create *Array attributes (e.g. of orderArrayType under bondArray . This requires all arrays to be of identical lengths with explicit values for all bonds in every array. This is NOT suitable for complexType bond children such as _bondStereo_ nor can IDs be added to bonds.. It also cannot be checked as easily by schema- and schematron validation. The _atomRef1Array_ and _atomRef2Array_ attributes are then mandatory. It is allowed (though not yet recommended) to add _*Array_ children such as _floatArray_ The attributes are directly related to the scalar attributes under _atom_ which should be consulted for more info. dictionary A dictionary. A dictionary is a container for _entry_ elements. Dictionaries can also contain unit-related information. The dictRef attribute on a dictionary element sets a namespace-like prefix allowing the dictionary to be referenced from within the document. In general dictionaries are referenced from an element using the __dictRef__ attribute. A molecular formula. It is defined by atomArray s each with a list of elementTypes and their counts. All other information in the atomArray is ignored. formula are nestable so that aggregates (e.g. hydrates, salts, etc.) can be described. CML does not require that formula information is consistent with (say) crystallographic information; this allows for experimental variance. An alternative briefer representation is also available through the concise . This must include whitespace round all elements and their counts, which must be explicit. The structure of a peak in a spectrum. Primarily to record couplings and other fine structure. At present we have tested this on HNMR spectra, C13 NMR and simple IR. We believe that other types of spectroscopy (ESR, NQR, etc) can be represented to some extent, but there may be systems beyond the current expressive power. peak A peak; annotated by human or machine. A peak can describe: A single point in a spectrum. Usually a maximum but could be a shoulder, inflexion or indeed any point of interest. A continuous range of values within a spectrum, defined by maximum and minimum values on either/both axes. A peak may be described by specifying xValue or by giving xMax and xMin. It seems reasonable to also allow xValue and xMax and xMin. If yValue is given on a peak then it must also be specified for all peaks within the containing peakList. The finer structure of the peak can be given with one or more peakStructure children. Do we want to support expressions such as 'a carbonyl peak is typically seen over 190 ppm'. A list of peaks. Distinguish between peakList (primarily a navigational container) and peakGroup where the peaks (or groups) have some close relation not shared by all peaks. All peaks and peakGroups should use the same units. A list of peaks or peakGroups. Distinguish between peakList (primarily a navigational container) and peakGroup where the peaks (or groups) have some close relation not shared by all peaks. All peaks and peakGroups should use the same units. A container for a property. property can contain one or more children, usually scalar, array or matrix. The dictRef attribute is required, even if there is a single scalar child with the same dictRef. The property may have a different dictRef from the child, thus providing an extension mechanism. A container for a property. property can contain one or more children, usually scalar , array or matrix . The dictRef attribute is required, even if there is a single scalar child with the same dictRef. The property may have a different dictRef from the child, thus providing an extension mechanism. Properties may have a state attribute to distinguish the state of matter A spectrum and relevant data or metadata. The spectrum construct can hold metadataList , sample (which can contain molecule), conditionList (mainly for physical/chemical conditions, not instrumental), spectrumData for the actual data and instrumental settings/procedure and peakList for the assigned peaks. This approach puts the spectrum as the primary object of interest. It could also be possible to make spectrum a child of molecule (although a reference using ref might be preferable). A general container for CML elements. Often the root of the CML (sub)document. Has no explicit function but can serve to hold the dictionary and namespace and version information, and is a useful tag to alert CML processors and search/XMLQuery tools that there is chemistry in the document. Can contain any content, but usually a list of molecules and other CML components. A container for atoms, bonds and submolecules. molecule is a container for atoms, bonds and submolecules along with properties such as crystal and non-built in properties. It should either contain molecule or *Array for atoms and bonds. A molecule can be empty (e.g. we just know its name, id, etc.) "Molecule" need not represent a chemically meaningful molecule. It can contain atoms with bonds (as in the solid-sate) and it could simply carry a name (e.g. "taxol") without formal representation of the structure. It can contain "sub molecules", which are often discrete subcomponents (e.g. guest-host). cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/schematron/000077500000000000000000000000001477224461000256175ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/schematron/build.bat000077500000000000000000000017361477224461000274200ustar00rootroot00000000000000@REM @REM Copyright 2011 Peter Murray-Rust et. al. @REM @REM Licensed under the Apache License, Version 2.0 (the "License"); @REM you may not use this file except in compliance with the License. @REM You may obtain a copy of the License at @REM @REM http://www.apache.org/licenses/LICENSE-2.0 @REM @REM Unless required by applicable law or agreed to in writing, software @REM distributed under the License is distributed on an "AS IS" BASIS, @REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @REM See the License for the specific language governing permissions and @REM limitations under the License. @REM @echo off echo cleaning del .\xsl\cml-lite.xsl echo building xsl/cml-lite.xsl java -jar y:/saxon/saxon9.jar -o:./xsl/cml-lite.xsl -s:cml-lite.sch -xsl:./xsl/iso_svrl.xsl echo generating documentation java -jar y:/saxon/saxon9.jar -o:./doc/index.html -s:cml-lite.sch -xsl:./xsl/extract-doc.xslcmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/schematron/clean.bat000077500000000000000000000013101477224461000273670ustar00rootroot00000000000000@REM @REM Copyright 2011 Peter Murray-Rust et. al. @REM @REM Licensed under the Apache License, Version 2.0 (the "License"); @REM you may not use this file except in compliance with the License. @REM You may obtain a copy of the License at @REM @REM http://www.apache.org/licenses/LICENSE-2.0 @REM @REM Unless required by applicable law or agreed to in writing, software @REM distributed under the License is distributed on an "AS IS" BASIS, @REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @REM See the License for the specific language governing permissions and @REM limitations under the License. @REM @echo off del *.report.xmlcmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/schematron/cml-lite.sch000077500000000000000000000274031477224461000300350ustar00rootroot00000000000000 CMLLite schematron file J. A. Townsend, jat45@cantab.net Peter Murray-Rust pm286@cam.ac.uk Jim Downing ojd21@cam.ac.uk ¤ Copyright J. A. Townsend jat45@cantab.net 2008 Checks that the elements and attributes being used conform to the structure and subset as agreed upon by MS and UCC. CMLLite schematron file

Checks that the elements and attributes being used conform to the structure and subset as agreed upon by MS and UCC. NOTE : the CMLLite schema defines the allowed attributes on elements, and their allowed children, however it can not perform further validation such as; the eldest cml:cml element MUST have version and convention specified the ids of all the atoms referenced in a bond (via atomRefs2) must be defined within that molecule This stylesheet does not attempt to perform any chemical validation (other than that which is absolutely necessary for the document to make consistent sense - such as the rule about atom ids above) this is performed later.

check for CMLLite Report date: the document does not contain any valid CMLLite CML element checks

Describe what further limitations we have put on the cml element

the eldest cml element must have @convention the eldest cml element must have @version

This schematron is designed to validate CMLLite, therefore if the convention is not CMLLite we should be worried - however, it is possible that we want to validate more than just CMLLite (many of the restrictions placed on ordering etc make it easier to use this form of CML rather than the more general form) maybe we can introduce a flag to turn on CMLLite validation or looser validation

'CMLLite' expected as @convention on the eldest cml element
scalar element checks

Describe what further limitations we have put on the cml element

scalar must have one or more max, min or content
label element checks

labels should have convention specified if at all possible

label should have convention specified if at all possible
molecule element checks

how unique should the ids of molecule be?

molecule children of molecule require a count @count must be integer
formula element checks

Describe what further limitations we have put on the atom element

formula children of formula require a count @count must be integer a formula should have @concise if at all possible
peak element checks

if peak has yValue then all peaks in this peakList should have yValue

if peak has yValue then all peaks should have yValue

A peak must have xMax if xMin is specified and visa versa, it must also always have a value - whether this is specified using xMax and xMin just by xValue.

the peak must have xValue and/or (xMax and xMin) peak must not have an isolated xMax attribute peak must not have an isolated xMin attribute
peakList element checks

peakList must containt at least one peak

peakList must contain at least one peak element

peakList must have yUnits specified if any of the peaks have yValue

if peaks have y values then peakList must specify yUnits
atom element checks

Describe what further limitations we have put on the atom element

Check that the id of this atom is unique within the eldest containing molecule The schema validation specifies that each atom must have an id, this check tests the uniqueness

the id of a atom must be unique within the eldest containing molecule (duplicate found: )

If x2 is present the y2 must be present

if atom has @x2 then it must have @y2

If y2 is present the x2 must be present

if atom has @y2 then it must have @x2

If x3 is present then y3 and z3 must be present

if atom has @x3 then it must have @y3 and @z3

If y3 is present then x3 and z3 must be present

if atom has @32 then it must have @x3 and @z3

If x3 is present then y3 and z3 must be present

if atom has @z3 then it must have @x3 and @y3
bond element checks

Describe what further limitations we have put on the atom element

Check that the first atom in the atomRefs2 attribute exists within the same molecule

the atoms in the atomRefs2 must be within the eldest containing molecule (found )

Check that the second atom in the atomRefs2 attribute exists within the same molecule

the atoms in the atomRefs2 must be within the eldest containing molecule (found )

Check that the first atom and second atom in atomRefs2 are not the same

a bond must be between different atoms

Check that the id of this bond is unique within the eldest containing molecule The schema validation specifies that each bond must have an id, this check tests the uniqueness

the id of a bond must be unique within the eldest containing molecule (duplicate found: )
bondStereo element checks

Describe what further limitations we have put on the bondStereo element

CMLLite only supports wedge/hatch and cis/trans bonds but CML allows for any convention to be used can we have a flag? only cml:wedgehatch and cml:cistrans bondStereo are currently supported atomRefs4 should not be present for wedge/hatch bondStereo atomRefs4 are required for cis/trans bondStereo (to define what is cis or trans to what) If the convention is cml:wedgehatch then the content should be either W or H should we normalise space ?? if the convention is cml:wedgehatch then the content should be either W or H If the convention is cml:cistrans then the content should be either C or T should we normalise space ?? if the convention is cml:cistrans then the content should be either C or T
atomArray element checks

atomArray must be in either molecule or formula but could be enclosed in a cml element (perhaps for some bizarre grouping)

atomArray must be found in either a molecule or a formula an atomArray must contain atoms an atomArray must contain atoms
cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/schematron/xsl/000077500000000000000000000000001477224461000264255ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/schematron/xsl/cml-lite.xsl000077500000000000000000001327521477224461000307000ustar00rootroot00000000000000 / *: [namespace-uri()=' '] [ ] @*[local-name()='schema' and namespace-uri()='http://purl.oclc.org/dsdl/schematron'] . Checks that the elements and attributes being used conform to the structure and subset as agreed upon by MS and UCC. NOTE : the CMLLite schema defines the allowed attributes on elements, and their allowed children, however it can not perform further validation such as; the eldest cml:cml element MUST have version and convention specified the ids of all the atoms referenced in a bond (via atomRefs2) must be defined within that molecule This stylesheet does not attempt to perform any chemical validation (other than that which is absolutely necessary for the document to make consistent sense - such as the rule about atom ids above) this is performed later. doc.checks check for CMLLite check for CMLLite cml.checks CML element checks CML element checks Describe what further limitations we have put on the cml element scalar.checks scalar element checks scalar element checks Describe what further limitations we have put on the cml element label.checks label element checks label element checks labels should have convention specified if at all possible molecule.checks molecule element checks molecule element checks
how unique should the ids of molecule be?
formula.checks formula element checks formula element checks Describe what further limitations we have put on the atom element peak.checks peak element checks peak element checks peakList.checks peakList element checks peakList element checks atom.checks atom element checks atom element checks Describe what further limitations we have put on the atom element bond.checks bond element checks bond element checks Describe what further limitations we have put on the atom element bondStereo.checks bondStereo element checks bondStereo element checks Describe what further limitations we have put on the bondStereo element atomArray.checks atomArray element checks atomArray element checks atomArray must be in either molecule or formula but could be enclosed in a cml element (perhaps for some bizarre grouping)
CMLLite schematron file check for CMLLite Report date: the document does not contain any valid CMLLite CML element checks the eldest cml element must have @convention the eldest cml element must have @version 'CMLLite' expected as @convention on the eldest cml element scalar element checks scalar must have one or more max, min or content label element checks label should have convention specified if at all possible molecule element checks molecule children of molecule require a count @count must be integer formula element checks formula children of formula require a count @count must be integer a formula should have @concise if at all possible peak element checks if peak has yValue then all peaks should have yValue the peak must have xValue and/or (xMax and xMin) peak must not have an isolated xMax attribute peak must not have an isolated xMin attribute peakList element checks peakList must contain at least one peak element if peaks have y values then peakList must specify yUnits atom element checks the id of a atom must be unique within the eldest containing molecule (duplicate found: ) if atom has @x2 then it must have @y2 if atom has @y2 then it must have @x2 if atom has @x3 then it must have @y3 and @z3 if atom has @32 then it must have @x3 and @z3 if atom has @z3 then it must have @x3 and @y3 bond element checks the atoms in the atomRefs2 must be within the eldest containing molecule (found ) the atoms in the atomRefs2 must be within the eldest containing molecule (found ) a bond must be between different atoms the id of a bond must be unique within the eldest containing molecule (duplicate found: ) bondStereo element checks only cml:wedgehatch and cml:cistrans bondStereo are currently supported atomRefs4 should not be present for wedge/hatch bondStereo atomRefs4 are required for cis/trans bondStereo (to define what is cis or trans to what) if the convention is cml:wedgehatch then the content should be either W or H if the convention is cml:cistrans then the content should be either C or T atomArray element checks atomArray must be found in either a molecule or a formula an atomArray must contain atoms
cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/schematron/xsl/extract-doc.xsl000077500000000000000000000202041477224461000313730ustar00rootroot00000000000000 ]]> <xsl:choose> <xsl:when test="dc:title"> <xsl:value-of select="dc:title" /> </xsl:when> <xsl:otherwise> schematron documentation </xsl:otherwise> </xsl:choose> DC.

(context = )

assert-rule report-rule rule

cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/schematron/xsl/iso_schematron_skeleton.xsl000077500000000000000000001505141477224461000341070ustar00rootroot00000000000000 #ALL true true Schema error: Schematron elements in old and new namespaces found Schema error: in the queryBinding attribute, use 'xslt' This XSLT was automatically generated from a Schematron schema. Fail: This implementation of ISO Schematron does not work with schemas using the "" query language. PHASES PROLOG KEYS DEFAULT RULES SCHEMA METADATA SCHEMATRON PATTERNS Phase Error: no phase with name has been defined. MODE: SCHEMATRON-FULL-PATH / *: [namespace-uri()=' '] [ ] @ @*[local-name()=' ' and namespace-uri()=' '] MODE: GENERATE-ID-FROM-PATH . Strip characters Markup Error: no pattern attribute in <active> Reference Error: the pattern "" has been activated but is not declared Markup Error: no test attribute in <assert ASSERT Markup Error: no test attribute in <report> REPORT Markup Error: no id attribute in <diagnostic> Markup Error: no rule attribute in <extends> Reference Error: the abstract rule "" has been referenced but is not declared Markup Error: no name attribute in <key> Markup Error: no path or use attribute in <key> Markup Error: no path or use attribute in <key> Schema error: The key element is not in the ISO Schematron namespace. Use the XSLT namespace. Warning: Variables should not be used with the "xpath" query language binding. Markup Error: no uri attribute in <ns> Markup Error: no prefix attribute in <ns> Schema implementation error: This schema has abstract patterns, yet they are supposed to be preprocessed out already PATTERN Markup Error: no id attribute in <phase> Markup Error: no context attribute in <rule> RULE Markup Error: no id attribute on abstract <rule> Markup Error: (2) context attribute on abstract <rule> Markup Error: context attribute on abstract <rule> Markup Error: no select attribute in <value-of> Warning: must not contain any child elements Reference error: A diagnostic "" has been referenced but is not declared Using the XSLT namespace with a prefix other than "xsl" in Schematron rules is not supported in this processor: Warning: unrecognized element Warning: unrecognized element skel: title context is title cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/schematron/xsl/iso_svrl.xsl000077500000000000000000000423751477224461000310330ustar00rootroot00000000000000 #ALL true true xslt2 Diagnostics called up with no value. cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/schematron/xsl/svrl2html.xsl000077500000000000000000000074271477224461000311270ustar00rootroot00000000000000 ]]> schematron failed unit tests

cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/types/000077500000000000000000000000001477224461000246205ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/types/XMLFP.rnc000077500000000000000000000031301477224461000262120ustar00rootroot00000000000000namespace dc = "http://purl.org/dc/elements/1.1/" namespace h = "http://www.w3.org/1999/xhtml" dc:title [ "fpx: Floating Point numbers in XML" ] dc:description [ "RELAX NG schema for lexical representations of floating point numbers. Ultimately this is essentially a datatypeLibrary for use in RelaxNG, although not yet implemented as such." ] dc:author [ "Toby White" ] dc:rights [ "© Copyright Toby White 2006, 2007." ] dc:date ["20072901"] boolean = xsd:token { pattern = "true|false" } listOfBooleans = xsd:token { pattern = "(true|false)(\s+(true|false))*" } positiveInteger = xsd:token { pattern = "\d+" } listOfPositiveIntegers = xsd:token { pattern = "(\d+)(\s+\d+)*" } integer = xsd:token { pattern = "[+\-]?\d+" } listOfIntegers = xsd:token { pattern = "([+\-]?\d+)(\s+[+\-]?\d+)*" } realNumber = xsd:token { pattern = "[+\-]\d+(\.\d*)?" } listOfRealNumbers = xsd:token { pattern = "([+\-]\d+(\.\d*)?)(\s+[+\-]\d+(\.\d*)?)*" } realNumberWithExponent = xsd:token { pattern = "[+\-]?\d+(\.\d*)?([dDeE][+\-]?\d+)?" } listOfRealNumbersWithExponent = xsd:token { pattern = "([+\-]?\d+(\.\d*)?([dDeE][+\-]?\d+)?)(\s+[+\-]?\d+(\.\d*)?([dDeE][+\-]?\d+)?)*" } complexNumberWithExponent = xsd:token { pattern = "\(\s*[+\-]?\d+(\.\d*)?([dDeE][+\-]?\d+)?\s*\)\+i\(\s*[+\-]?\d+(\.\d*)?([dDeE][+\-]?\d+)?\s*\)" } listOfComplexNumbersWithExponent = xsd:token { pattern = "\(\s*[+\-]?\d+(\.\d*)?([dDeE][+\-]?\d+)?\s*\)\+i\(\s*[+\-]?\d+(\.\d*)?([dDeE][+\-]?\d+)?\s*\)(\s+\(\s*[+\-]?\d+(\.\d*)?([dDeE][+\-]?\d+)?\s*\)\+i\(\s*[+\-]?\d+(\.\d*)?([dDeE][+\-]?\d+)?\s*\))*" } cmlxom-cmlxom-4.11/src/main/resources/cmllite-schema/pmr/types/cmltypes.rnc000077500000000000000000000044141477224461000271720ustar00rootroot00000000000000namespace dc = "http://purl.org/dc/elements/1.1/" namespace h = "http://www.w3.org/1999/xhtml" dc:title [ "cmltypes: non FPX and XSD types for CML" ] dc:description [ "RELAX NG schema for lexical representations of floating point numbers. Ultimately this is essentially a datatypeLibrary for use in RelaxNG, although not yet implemented as such." ] dc:author [ "Peter Murray-Rust" ] dc:author [ "J A Townsend" ] dc:rights [ "© Copyright J A Townsend 2008." ] dc:date ["20081905"] # FIRST DEFINE SIMPLE TYPES refType = xsd:token { pattern='([A-Za-z_][A-Za-z0-9_\-]*:)?[A-Za-z_][A-Za-z0-9_\-]*' } chiralityType = xsd:token { pattern='enantiomer|racemate|unknown|other' } elementTypeType = xsd:token { pattern='Ac|Al|Ag|Am|Ar|As|At|Au|B|Ba|Bh|Bi|Be|Bk|Br|C|Ca|Cd|Ce|Cf|Cl|Cm|Co|Cr|Cs|Cu|Db|Dy|Er|Es|Eu|F|Fe|Fm|Fr|Ga|Gd|Ge|H|He|Hf|Hg|Ho|Hs|I|In|Ir|K|Kr|La|Li|Lr|Lu|Md|Mg|Mn|Mo|Mt|N|Na|Nb|Nd|Ne|Ni|No|Np|O|Os|P|Pa|Pb|Pd|Pm|Po|Pr|Pt|Pu|Ra|Rb|Re|Rf|Rh|Rn|Ru|S|Sb|Sc|Se|Sg|Si|Sm|Sn|Sr|Ta|Tb|Tc|Te|Th|Ti|Tl|Tm|U|Uun|Uuu|Uub|Uut|Uuq|Uup|Uuh|Uus|Uuo|V|W|Xe|Y|Yb|Zn|Zr|Du|R'} # #A concise representation for a molecular formula. ## This MUST adhere to a whitespaced syntax so that it is trivially ## machine-parsable. Each element is followed by its count (which may be decimal), ## and the string is optionally ended by a formal charge (of form d or -d, i.e. no '+') ## NO brackets or other nesting is allowed. formulaType = xsd:string { pattern='\s*([A-Z][a-z]?\s+(([0-9]+(\.[0-9]*)?)|(\.[0-9]*))?\s*)+(\s+[\-|+]?[0-9]+)?\s*' } #dc:description [ # h:div [ "Bond order." ] # h:p [ "This is purely conventional and used # for bond/electron counting. There is no default value. # The emptyString attribute can be used to indicate a bond of # unknown or unspecified type. The interpretation of this is outside # the scope of CML-based algorithms. It may be accompanied by a " # h:tt [ "convention" ] # " attribute on the " # h:tt [ "bond" ] # " which links to a dictionary." # ] # ] # ] orderType = xsd:token { pattern='hbond|S|D|T|A|U|P' } # NOW DEFINE LISTS OF SIMPLE TYPES cmlxom-cmlxom-4.11/src/main/resources/header.txt000077500000000000000000000011371477224461000217650ustar00rootroot00000000000000 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.cmlxom-cmlxom-4.11/src/main/resources/log4j.properties000077500000000000000000000016441477224461000231340ustar00rootroot00000000000000# # 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. # log4j.rootLogger=DEBUG, A1 log4j.appender.A1=org.apache.log4j.ConsoleAppender log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n log4j.logger.uk.ac.cam=DEBUG log4j.logger.org.xmlcml.cml.converters.molecule.cml.CML2CMLConverter=ALL cmlxom-cmlxom-4.11/src/main/resources/org/000077500000000000000000000000001477224461000205565ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/resources/org/xmlcml/000077500000000000000000000000001477224461000220525ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/resources/org/xmlcml/cml/000077500000000000000000000000001477224461000226255ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/resources/org/xmlcml/cml/base/000077500000000000000000000000001477224461000235375ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/resources/org/xmlcml/cml/base/attributes.xsd000077500000000000000000004300721477224461000264560ustar00rootroot00000000000000 Abbreviation. Abbreviation for units, terms, etc. Describes whether child elements are sequential or parallel. There is no default. The type of an alternative. This adds semantics to an _alternative_ and might be used by an RDF or related engine. Restricts units to radians or degrees. An array of atom IDs. Normally an attribute of an array-based element. A reference to a map providing mappings between atoms The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking atoms. The topology of the linking is defined by the application - it could be overlay of molecular fragments, reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of atoms are of equal size and have 1:1 mapping between each id. This is another way of saying that the atoms mapped by a given ID are "the same atom". A reference to an atom. Used by bond, electron, etc. The first atoms in each bond. Currently only used in bondArray in CML2 array mode. The second atoms in each bond. Only used in bondArray in CML2 array mode. An array of references to atoms. Typical use would be to atoms defining a plane. A reference to a list of atoms. Used by bonds, electrons, atomSets, etc. References to two different atoms. Available for any reference to atoms but normally will be the normal reference attribute on the bond element. The order of atoms is preserved and may matter for some conventions (e.g. wedge/hatch or donor bonds. A list of three references to atoms. Typically used for defining angles, but could also be used to define a three-centre bond. 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. An atomSet describing the region. Any point falling within atomOffset of any atom in the set lies within the region. This means the region could consist of disjoint fragments. The IDs for an array of bond. Required in CML2 array mode. A reference to a map providing mappings between bonds The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking bonds. The topology of the linking is defined by the application - it could be overlay of molecular fragments, reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of bonds are of equal size and have 1:1 mapping between each id. This is another way of saying that the bonds mapped by a given ID are "the same bond". A reference to a bond. used by electron, etc. A reference to a list of bonds. Used by electrons, bondSets, etc. A parallelipiped box. By default the box uses isometric Cartesians axes but can also be linked to lattice Vector. Any point falling within the box or on a boundary is within the regio. builtin children. CML1-only - now deprecated. Error array for cellParameter 3 numbers giving error limits on paremters. The type of a cellParameter. length or angle The chirality of a system or molecule. This is being actively investigated by a IUPAC committee (2002) so the convention is likely to change. No formal default. Number of columns. A concise formula. The string represents an (unstructured) formula i.e. no submolecules. Recommended to use the format "H 2 O 1", etc. The constant to add to the raw data. add *after* applying any multiplier. 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. Constraint on a parameter. Semantics not yet finalised. We anticipate "fixed", "none" and symbolic relationships to other parameters. content of metadata. 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. The value of an element with a _convention_. When convention is used this attribute must be present and element content must be empty. 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. Array of object counts. No fixed semantics or default, normally integral. It is presumed that the element can be multiplied by the count value. General formula for the repeat count of the element. Experimental. No fixed semantics or default. The cyclic nature of a bond. This is an assertion by a human or program about the cyclic nature of a bond. It need not correspond to what is deducible from the connection table (e.g. a bond in a ring might be labelled as 'acyclic' or 'unknown') The data type of the object. Normally applied to scalar/array objects but may extend to more complex one. default value in an enumeration. A non-whitespace string (value is irrelevant) indicates that the content of this enumeration is the default value (usually of a scalar). It is an error to have more than one default. If the scalar in an instance document has no value (i.e. is empty or contains only whitespace) its value is given by the default. If the scalar in the instance is empty and no enumerations have a default attribute, an application may throw an error. 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. 2006-05-21: PMR added attribute. A delimiter character for arrays and matrices. By default array components ('elements' in the non-XML sense) are whitespace-separated. This fails for components with embedded whitespace or missing completely: Example: In the protein database ' CA' and 'CA' are different atom types, and and array could be: <array delimiter="/" dictRef="pdb:atomTypes">/ N/ CA/CA/ N/</array> Note that the array starts and ends with the delimiter, which must be chosen to avoid accidental use. There is currently no syntax for escaping delimiters. The namespacePrefix for a data item. The dictionaryPrefix is associated with elements such as dictionaries and units and allows them to be referenced namespaces. The dictionaryPrefix is normally unbound but it may be necessary to hardcode them occasionally. Thus if a value is fixed (e.g. "xsd:double") the prefix must be identified and fixed. A reference to a dictionary entry. Elements in data instances such as _scalar_ may have a dictRef attribute to point to an entry in a dictionary. To avoid excessive use of (mutable) filenames and URIs we recommend a namespace prefix, mapped to a namespace URI in the normal manner. In this case, of course, the namespace URI must point to a real XML document containing _entry_ elements and validated against STMML Schema. Where there is concern about the dictionary becoming separated from the document the dictionary entries can be physically included as part of the data instance and the normal XPointer addressing mechanism can be used. This attribute can also be used on _dictionary_ elements to define the namespace prefix Dimensionality of a coordinate system. Note that this means that coordinates of higher dimensionality are ignored or an error is flagged. Thus z3 and dimensionality='2' are incompatible. At present higher dimensionalities than 3 (cf. Wondratschek) are not supported. The labelling of the axes id not controlled. ?? should we have an explicit attribute for labelling convention?. The basis of the dimension. Normally taken from the seven SI types but possibly expandable. The duration of the action. Semantics undefined. The orientation of the eigenvector matrix. Describes whether the vectors are columns or rows. No default, so effectively mandatory unless you want to make implementers guess and break applications. A reference to a map providing mappings between electrons The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking electrons. The topology of the linking is defined by the application - it could be reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of electrons are of equal size and have 1:1 mapping between each id. This is another way of saying that the electrons mapped by a given ID are "the same electron". The identity of a chemical element. Normally mandatory on _atom_, _isotope_, etc. The identity of a chemical element. Normally mandatory on _atom_, _isotope_, etc. The end value. The end value in any allowable XSD representation of data. 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. Basis of the error estimate. Value of the error. Reports the author's estimate of the error in a scalar value. Only meaningful for dataTypes mapping to real number. 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. 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 2006-05-21: PMR added attribute. Information identifying the name of a file or other resource. This allows an element (such as cml) to carry limited information about provenance such as the name of the document used to provide the content. It is not a complete solution but can help to protect a document becoming separated from its external metadata. It is restricted to the basic XML character set (printable ANSI) and whitespace (which should anyway be discouraged) is normalized to single space (attribute values cannot carry newlines). Quotation marks and other horrors (as used in some OS) should be avoided. A reference to a functional form. Currently used for potential. 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. 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. Format of a spectrum. The data structure of the spectrum. (Not the format of the data). This describes how the data structure is to be interpreted. Simple chemical formula. This attribute should only be used for simple formulae (i.e. without brackets or other nesting for which a _formula_ child element should be used. The attribute might be used as a check on the child elements or for ease of representation. Essentially the same as _concise_ attribute on _formula. Number of digits after the point. This is used in dictionaries to define precision. However it might be replaced by xsd:facet. The base of one or more links. On link elements the value is the single id of an element within the document or context specified in map@fromRef attributes. It must identify the element uniquely. The reserved value 'null' implies that no mapping has been provided for the object(s) in the 'to' attribute. This implies no semantics but may be used by software to keep count of which elements have been mapped. For multiple targets use 'fromSet'. 2005-06-18: updated docs The context for the 'from' links in a map. A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. 2005-06-18: created A set of ids representing the base of a link. For a partial mapping where a number of 'from' elements are known to link to a number of 'to' elements it can be useful to aggregate these into a single attribute value. The primary use is to assert that n links exist between a set of n 'from' elements and n 'to' elements but that the precise links are unknown. The semantics of the reference are the same as for 'from' and all the elements must be of the same type (which can be specified with 'fromType' either on the link or the containing map). No order information is implied. In general there will be the same number of idRefs in the 'toSet' and all implicit links will share the same attributes (e.g. 'role'). In many cases the sets will be later split into discrete links thorugh further calculation or experiment (e.g. peak assignment). Sets should never be used as a lazy or concise alternative where the all the links are explicitly known. 2005-06-18: created The type of the base of a link. The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. 2005-06-18: created Domain of an FT spectrum. Indicates whether a spectrum is raw FID or has been transforme. address of a resource. Links to another element in the same or other file. For dictionary/@dictRef requires the prefix and the physical URI address to be contained within the same file. We can anticipate that better mechanisms will arise - perhaps through XMLCatalogs. At least it works at present. 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. 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. A unique ID for an element. Id is used for machine identification of elements and in general should not have application semantics. It is similar to the XML ID type as containing only alphanumerics, '_', ',' and '-' and and must start with an alphabetic character. Ids are case sensitive. Ids should be unique within local scope, thus all atoms within a molecule should have unique ids, but separated molecules within a document (such as a published article) might have identical ids. Software should be able to search local scope (e.g. all atoms within a molecule). However this is under constant review. Allows a referring element to generate a unique id. idgen can hold a unique identifier which is copied into the id attribute of the referenced element. This avoids multiple copies of the referenced object with duplicate ids. EXPERIMENTAL 2006-05-22: PMR added. Inheritance mechanism. A reference to an existing element can be used to supplement values such as coordinates. The inheritance attribute determines whether the values are supplemented, overwritten or deleted. In the example: <molecule id="m1" view="initial"> <atomArray> <atom id="a1" x3="0.1"/> </atomArray> </molecule> <!-- this adds more information --> <molecule ref="m1" view="initial" inherit="supplement"> <atomArray> <atom id="a1" hydrogenCount="1"/> </atomArray> </molecule> <!-- this will overwrite the previous values --> <molecule ref="m1" inherit="overwrite" view="final" id="m2"> <atomArray> <atom id="a1" x3="0.1"/> </atomArray> </molecule> <!-- this will delete the previous values --> <molecule ref="m1" inherit="delete" view="restart"> <atomArray> <atom id="a1" hydrogenCount=""/> </atomArray> </molecule> The first molecule/@ref adds complementary information, the second changes the values. Software is allowed to generate two independent copies of the molecule and reference them by different IDs ( m1 and m2). This mechanism is necessary to manage the implied inheritance of partial information during minimisations and dynamics. It requires careful software implementation. An inline representation of the object. This can represent a wide range of information from formal serialization as ASCII through to domain-specific textual representations. It will often be used in conjunction with the "convention" attribute. For example it could be used to represent IUPAC formula, SMILES strings, TeX equations, etc. Characters should conforma to the XML character set, and XML markup (lt and amp) should be escaped. IT SHOULD NEVER BE USED FOR INLINE XML Area under a peak. Unfortunately units are usually arbitrary and not related to the x- and y- axis units, and in this case _peakUnits_ should be use. A symmetry species. No fixed semantics, though we may provide a controlled-extensible list in the future. The isotope for an element. A real number describing the isotope. Probably obsolet. 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.. 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). Reference to a fuller description of the isotope. The description may be found in an external collection (e.g. IUPAC) or within the current document. indicates whether a unit is an SI or derived SI unit. required on SI unit elements with value 'true'. Optional on other units with attribute 'false'. A unitList should contain either SI units or non-SI units but not both. The k vector. The k-vector with 3 components. A reference to a kpoint. Used by band, etc. 2006-01-21: PMR. Created The secondary quantum number. takes values 0, 1, etc. A label. The semantics of label are not defined in the schema but are normally commonly used standard or semi-standard text strings. This attribute has the the same semantics as the more common _label_ element. The primitivity of a lattice. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency between spacegroups, symmetry operators, etc. Length of an array or . Probably will be replaced with xsd:schema tool. The type of the link. A list of values. Normally for iterations. 2006-06-09: PMR Created.. symbolic represention of l amd m. takes avlues of s, p, px, dxy, dx2y2, f, etc. The azimuthal quantum number. takes values -1, 0, 1, etc. An attribute providing a mandatory unique ID for an element. This is a horrible hack. It should be possible to add 'required' to the attributeGroup where used... (Maybe it is and I am still fighting Schema Wars. Type of matrix. Mainly square, but extensible through the _xsd:union_ mechanis. Maximum value allowed for an element or attribute. maximum exclusive value. by analogy with xsd:schema. minimum inclusive value. by analogy with xsd:schem. maximum length of a scalar. by analogy with xsd:schem. Maximum values for numeric _matrix_ or _array. A whitespace-separated list of the same length as the array in the parent element. Type of spectral measurement. The nature of the measured data. This is not an exhaustive list and should only be used if it affects the storage or immediate processing. The metadata type. This is likely to be the Dublin Core name or something similar. The use of "type" is an infelicitous misnomer and we shall try to remove it. The minimum value allowed for an element or attribute. minimum exclusive value. by analogy with xsd:schema. minimum inclusive value. by analogy with xsd:schema. minimum length of a scalar. by analogy with xsd:schema. Minimum values for numeric _matrix_ or _array. A whitespace-separated lists of the same length as the array in the parent element. A reference to a molecule. Used by spectrum, etc. A reference to one or more molecules. Uses the id attribute as the target identification. The order of molecules is preserved. It is not necessarily an error to have repeated references to the same molecule 2005-11-22: PMR. added this attribute. References to two different molecules. Available for any reference to molecules but normally will be the normal reference attribute on the join element. The order of molecules is preserved and may matter. 2006-11-24: PMR created The scale by which to multiply raw data or a unit. The scale is applied *before* adding any constant. The attribute may be found on a data item (scalar, array, matrix, etc.) or a user-defined unit. 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. The principal quantum number. Takes values 1, 2, 3, etc. 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. The namespace for a data item. The namespace is associated with elements such as dictionaries and units and allows them to be referenced through free namespace prefixes. A number determined by context Used for isotope number in isotope, and rotational symmetry number in symmetry for calculation of entropy, etc. 2003-03-30: added number attribut. The class of an object. The type of this information. This is not controlled, but examples might include: label summary note usage qualifier It might be used to control display or XSL filtering. The attribute is named 'objectClass' to avoid clashes with other class attributes and inappropriate conversion to foo.getClass(). 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. Array of occupancies. Normally only found in crystallography. Defaults to 1.0. The occupancy is required to calculate the molecular formula from the atoms. The order of the bond. There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. The order of the bond. There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. parameter name passed to an element This is still experimental. 2006-06-09: PMR added attribute. raplaces attribute on parent This is still experimental. Creates, overwriting if necessary, an attribute on parent. Example: <foo> <arg parentAttribute="bar">zubbo</arg> will create an attribute bar="zubbo" on <foo> 2006-06-09: PMR added attribute. A dictRef-like reference to the id of the parent SI unit. This parent should occur in this or another dictionary and be accessible through the dictRef mechanism. This attribute is forbidden for SI Units themselves. The mechanism holds for base SI units (7) and all compound (derived) units made by combinations of base Units. Pattern constraint. Based on xsd:schema. Height of a peak. For 1-dimensional data (e.g. y vs x) hould use the same units as the appropriate axis (e.g. y). Multiplicity of a peak. Uses a semi-controlled vocabulary. Shape of a peak. Semi-controlled vocabulary such as broad or sharp. Type of this structure. Semi-controlled vocabulary such as coupling or splitting. Units for a peak or peak integral. For 2-dimensional spectra the units represent the observation. For an integral they are usually arbitrary and not related to the x- and y- axis units. Thus NMR spectra may use hydrogen count as the units for the peak area. Is the axis periodic. Any or all of the axes may be periodic or aperiodic. An example could be a surface where 2 periodic axes (not necessarily orthogonal) are used to describe the coordinates in the surface, perhaps representing lattice vectors of a 3D crystal or 2D layer. The third vector is orthogonal and represents coordinates normal to the surface. In this case only the direction, not the magnitude of the vector is important. Periodicity of the system. This represents the number of dimensions (or coordinate axes) along periodic behaviour occurs and can be supported by symmetry operators or other transformations. Periodicity must never exceed dimensionality. A point in 3 dimensions. can be used for any complex geometrical object, such as line. A point group. No fixed semantics, though Schoenflies is recommended over Hermann-Mauguin. We may provide a controlled-extensible list in the future. 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. The power to which a dimension should be raised. Normally an integer. Must be included, even if unity. The power to which a dimension should be raised. Normally an integer. Must be included, even if unity. Is the dimension preserved during algebra. Experimental. The idea is to support concepts like volume/volume where algebraically these cancel out. preserve="yes" is intending to support preservation during derivation of new unitTypes. Keyword signifying how object is to be processed. Semantics depend on the parent element 2006-05-20: PMR added A ratio in the range 0 to 1. Currently used for ratios between brached reactions but re-usable for other concepts. Format of the reaction component. Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. Role of the reaction. The sequence of steps in a reactionStepList. By default the reactions in a reactionStepList are assumed to take place in sequence (e.g. one or more products of reaction n are used in reaction n+1 or later. However there are cases where it is known that reactions take place in parallel (e.g. if there is no overlap of molecular identities). Alternatively there are points at which there are two or more competing reactions which may depend on conditions or concentrations. A small semi-controlled vocabulary is suggested. The semantic of these are not fully explored, but we suggest that consecutive and simultaneous should be the first to be supported Type of the reaction. Recommended unit. a facet on a numeric dictionary entry. A reference to an element of given type. ref modifies an element into a reference to an existing element of that type within the document. This is similar to a pointer and it can be thought of a strongly typed hyperlink. It may also be used for "subclassing" or "overriding" elements.
When referring to an element most of the "data" such as attribute values and element content will be on the full instantiated element. Therefore ref (and possibly id) will normally be the only attributes on the pointing element. However there may be some attributes (title, count, etc.) which have useful semantics, but these are element-specific
A list of regions creating a union. The union of a series of regions produces a larger region (possibly disjoint). Any point belonging to any of the referenced regions is a member of this region. Type of relatedEntry. Type represents a the type of relationship in a relatedEntry element. Role of the object. How the object functions or its position in the architecture. No controlled vocabulary. Number of rows. The sequence of steps in a reactionList. By default the reactions in a reactionStepList are assumed to take place in sequence (e.g. one or more products of reaction n are used in reaction n+1 or later. However there are cases where it is known that reactions take place in parallel (e.g. if there is no overlap of molecular identities). Alternatively there are points at which there are two or more competing reactions which may depend on conditions or concentrations. A small semi-controlled vocabulary is suggested. Serial number or other id. Currently only on module. Modules with the same _role_ attribute can be distinguished by _serial_. This is often an integer but other schemes may be used. shape of object. Mainly square, but extensible through the _xsd:union_ mechanism. The namespace for SI Units dictionary. Main use is on unitList to identify the dictionary holding the SI Units. Array of namespaces locating SI Units dictionaries. Main use is on unitList to identify the dictionaries holding the SI Units. The size of an array or matrix. A space group. No fixed semantics, though Hermann-Mauguin or Hall is recommended over Schoenflies. We may provide a controlled-extensible list in the future. 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. The spaceType of the lattice. Usually real or reciprocal. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency for unitTypes, etc. The type of the spectrum. A sphere. Currently describes a region. Any point falling within the sphere or on its surface is within the region. The spin of a system. Supports fractional values. Currently the spin of a nucleus. The normal fraction representing the spin of the isotope. 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. The start value. The start value in any allowable XSD representation 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. The physical state of the substance. No fixed semantics or default. The step value. The step value in any allowable XSD representation Type of the substanceList. Extension is allowed through the "other" value. 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 2006-05-21: PMR added attribute. 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. Is the molecule oriented to the symmetry No formal default, but a molecule is assumed to be oriented according to any _symmetry_ children. This is required for crystallographic data, but some systems for isolated molecules allow specification of arbitrary Cartesian or internal coordinates, which must be fitted or refined to a prescribed symmetry. In this case the attribute value is false. type of table. controls content Indicates whether the structure is a tautomer. Currently used with IChI _identifier_ element. Semantics, vocabulary and usage are application-dependent. A term in a dictionary. The term should be a noun or nounal phrase, with a separate definition and further description. The test condition on an if element. No controlled format yet. 2006-06-09: PMR Created.. A title on an element. No controlled value. The target of one or more links. On link elements the value is the single id of an element within the document or context specified in map@toContext attributes. It must identify the element uniquely. The reserved value 'null' implies that no mapping has been provided for the object(s) in the 'from' attribute. This implies no semantics but may be used by software to keep count of which elements have been mapped. For multiple targets use 'toSet'. 2005-06-18: updated docs The context for the 'from' links in a map. A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. 2005-06-18: created A set of ids representing the base of a link. For a partial mapping where a number of 'to' elements are known to link to a number of 'from' elements it can be useful to aggregate these into a single attribute value. The primary use is to assert that n links exist between a set of n 'to' elements and n 'from' elements but that the precise links are unknown. The semantics of the reference are the same as for 'to' and all the elements must be of the same type (which can be specified with 'toType' either on the link or the containing map). No order information is implied. In general there will be the same number of idRefs in the 'fromSet' and all implicit links will share the same attributes (e.g. 'role'). In many cases the sets will be later split into discrete links thorugh further calculation or experiment (e.g. peak assignment). Sets should never be used as a lazy or concise alternative where the all the links are explicitly known. 2005-06-18: created total digits in a scalar. based on xsd:schema. The type of the base of a link. The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. 2005-06-18: created Type of the object. A qualifier which may affect the semantics of the object. A reference to the type of a unit. Needed to differentiate the rather unhappy polymorphism of unitList/unit and unitList/unitType. 2005-12-17 PMR: Added Scientific units on an element. These must be taken from a dictionary of units. There should be some mechanism for validating the type of the units against the possible values of the element. unitsRef attribute on CML1 elements. CML1-only - now deprecated. A reference to the type of a unit. Used in defining the unit and doing symbolic algebra on the dimensionality. Value of a scalar object. The value must be consistent with the dataType of the object. A vector in 3 dimensions. can be used for any complex geometrical object, such as line. The version of the element cml or identifier elements can currently have versions. They may be dependent on the date of release and this attribute is highly recommended. There is no controlled syntax. Weight of the element. Currently the weight of the kPoint, derived from the symmetry such as the inverse of the multiplicity in real space. Thus a point at 0,0,0 in monoclinic space might be 0.25. The lowest value possible is probably 1/48.0 (in m3m). 2003-09-15 (added at suggestion of Jon Wakelin). Whitespace. Attached to entry. This may be obsolete. 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. 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. 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. An array of x3 coordinate. Normally used in CML2 array mode. Fractional x coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. Array of fractional x coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. Maximum xValue. Annotates x-axis data with a maximum value. This need not be algorithmically deducible from the data and is typically used for the extent of a _peak_ or _peakGroup_. It uses xUnits or the same units as the data. There may or may not be a _xMin_ attribute but if so xMax should be greater than or equals to it. Minimum xValue. Annotates x-axis data with a minimum value. This need not be algorithmically deducible from the data and is typically used for the extent of a _peak_ or _peakGroup_. It uses xUnits or the same units as the data. There may or may not be a _xMax_ attribute but if so xMin should be less than or equals to it. Units for x axis. All x-axis data must have unambiguous units. Ideally the data and _xMin_ or _xValue_ should share the same units but different xUnits can be used as long as it is clear.. Value along an x axis. Annotates x-axis data with a value. It is typically used for the location of a _peak_ or _peakGroup_. It uses xUnits or the same units as the data. An unsigned interval along an x axis. It is typically used for the width of a _peak_ or _peakGroup_ but could be used for any range. It uses xUnits or the same units as the data. 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. 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. 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. An array of y3 coordinate. Normally used in CML2 array mode. Fractional y coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. Array of fractional y coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. Yield of a reaction or reactionStep. Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. Maximum yValue. Annotates y-axis data with a maximum value. This need not be algorithmically deducible from the data and is typically used for the extent of a _peak_ or _peakGroup_. It uses yUnits or the same units as the data. There may or may not be a _yMin_ attribute but if so yMax should be greater than or equals to it. Minimum yValue. Annotates y-axis data with a minimum value. This need not be algorithmically deducible from the data and is typically used for the extent of a _peak_ or _peakGroup_. It uses yUnits or the same units as the data. There may or may not be a _yMax_ attribute but if so yMin should be less than or equal to it. Units for y axis. All y-axis data must have unambiguous units. Ideally the data and _yMin_ or _yValue_ should share the same units but different yUnits can be used as long as it is clear. Value along a y axis. Annotates y-axis data with a value. It is typically used for the location of a _peak_ or _peakGroup_. It uses yUnits or the same units as the data. An unsigned interval along a y axis. It is typically used for the width of a _peak_ or _peakGroup_ but could be used for any range. It uses yUnits or the same units as the data. The number of molecules per cell. Molecules are defined as the _molecule_ which directly contains the _crystal_ element. 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. An array of z3 coordinate. Normally used in CML2 array mode. Fractional y coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. Array of fractional z coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur.
cmlxom-cmlxom-4.11/src/main/resources/org/xmlcml/cml/base/elements.xsd000077500000000000000000007636361477224461000261230ustar00rootroot00000000000000 The abundance of an isotope. The abundance of an isotope in an isotopeList. Values are expressed in percentages. An action which might occur in scientific data or narrative. An action which might occur in scientific data or narrative. The definition is deliberately vague, intending to collect examples of possible usage. Thus an action could be addition of materials, measurement, application of heat or radiation. The content model is unrestricted. _action_ iself is normally a child of _actionList_. The start, end and duration attributes should be interpreted as XSD dateTimes and XSD durations. This allows precise recording of time of day, etc, or duration after start of actionList. A convention="xsd" attribute should be used to enforce XSD. a numerical value, with a units attribute linked to a dictionary. a human-readable string (unlikely to be machine processable) startCondition and endCondition values are not constrained, which allows XSL-like test attribute values. The semantics of the conditions are yet to be defined and at present are simply human readable. The order of the action elements in the document may, but will not always, define the order that they actually occur in. A delay can be shown by an action with no content. Repeated actions or actionLists are indicated through the count attribute. Number of times the action should be repeated. A container for a group of actions. ActionList contains a series of actions or nested actionLists. An alternative name for an entry. At present a child of _entry_ which represents an alternative string that refers to the concept. There is a partial controlled vocabulary in _alternativeType_ with values such as : synonym acronym abbreviation The amount of a substance. The units attribute is mandatory and can be customised to support mass, volumes, moles, percentages, or ratios (e.g. ppm). An angle between three atoms. It can be used for: Recording experimentally determined bond angles (e.g. in a crystallographic paper). Providing the angle component for internal coordinates (e.g. z-matrix). A documentation container similar to annotation in XML Schema. A documentation container similar to annotation in XML Schema. At present this is experimental and designed to be used for dictionaries, units, etc. One approach is to convert these into XML Schemas when the documentation and appinfo children will emerge in their correct position in the derived schema. It is possible that this may develop as a useful tool for annotating components of complex objects such as molecules. A container similar to appinfo in XML Schema. A container for machine processable documentation for an entry. This is likely to be platform and/or language specific. It is possible that XSLT, RDF or XBL will emerge as generic languages. See _annotation_ and _documentation_ for further information. An example in XSLT where an element _foo_ calls a bespoke template. Allows a processor to inspect the role of the appinfo and process accordingly. An argument for a function. Arguments can be typed and have explicit or free values. They can also carry out substitutions in the parent element and its children (substitute, still experiemental) and delete itself after this. 2006-02-14: PMR. Added atomType as child 2006-05-21: PMR. Added substitute and delete attributes A homogenous 1 dimensional array of similar object. These can be encoded as strings (i.e. XSD-like datatypes) and are concatenated as string content. The size of the array should always be >= 1. The default delimiter is whitespace. The _normalize-space()_ function of XSLT could be used to normalize all whitespace to single spaces and this should not affect the value of the array elements. To extract the elements __java.lang.StringTokenizer__ could be used. If the elements themselves contain whitespace then a different delimiter must be used and is identified through the delimiter attribute. This method is mandatory if it is required to represent empty strings. If a delimiter is used it MUST start and end the array - leading and trailing whitespace is ignored. Thus size+1 occurrences of the delimiter character are required. If non-normalized whitespace is to be encoded (e.g. newlines, tabs, etc) you are recommended to translate it character-wise to XML character entities. Note that normal Schema validation tools cannot validate the elements of array (they are defined as string) However if the string is split, a temporary schema can be constructed from the type and used for validation. Also the type can be contained in a dictionary and software could decide to retrieve this and use it for validation. When the elements of the array are not simple scalars (e.g. scalars with a value and an error, the scalars should be used as the elements. Although this is verbose, it is simple to understand. If there is a demand for more compact representations, it will be possible to define the syntax in a later version. the size attribute is not mandatory but provides a useful validity check): Alternative to units Must be used in conjunction with unitType 2005-10-26: added Alternative to units Must be used in conjunction with unitType 2005-10-26: added Alternative to units Must be used in conjunction with multiplierToSI and/or constantToSI 2005-10-26: added A list of arrays or lists. A major use of arrayList is to contain data within rectangular tables. However there is no absolute requirement and the table can have any shape. The shape attribute hould be used to assert rectangularity. 2006-11-03: created An atom. Atoms can only be chosen from the periodic table and superatoms such as "Phe" or "Tyr" are not allowed. The elementType of an atom is identified by that attribute. There are two additional elementTypes, "Du" (for an object which does not have an identifiable nucleus but is useful in calculations and definitions (such as a centroid); and "R" which describes a generic fragment. Although atoms have an elementType, they do not, by default, support arbitrary atomTypes for which the <atomType> element should be used. 2006-01-12: PMR. Added vector3 child to support accelerations, velocities, dipole, etc. 2006-06-01: PMR. Added documentation. The main content model of the atom. name can be used for atom labels, etc. More than one name can be used if required. scalar contains any scalar properties of the atom (examples are chemical shift, B-value, etc.) linked through dictRef (CmlDictRefType). array contains any properties of the atom describable by a homogeneous array linked through dictRef (CmlDictRefType). matrix contains any properties of the atom describable by a homogeneous matrix linked through dictRef (CmlDictRefType). An example is the polarizability tensor atomParity (CmlAtomParityElement) the required way of defining atom-based chirality electron a away of associating electron(s) with the atom Most useful in _formula_ but possibly useful in _atomArray_ where coordinates and connectivity is not defined. No formal default, but assumed to be 1. This can be used to describe the purpose of atoms whose _elementType_s are __dummy__ or __locant__. Vocabulary not controlled. 2005-11-27: Added PMR 2005-11-27: Added PMR A container for a list of atoms. A child of _molecule_ and contains _atom_ information. There are two strategies: Create individual _atom_ elements under _atomArray_ (in any order). This gives the greatest flexibility but is the most verbose. Create *Array attributes (e.g. of _elementTypeArrayType_ under _atomArray_. This requires all arrays to be of identical lengths with explicit values for all atoms in every array. This is NOT suitable for complexType atom children such as _atomParity_. It also cannot be checked as easily by schema- and schematron validation. The _atomIDArray_ attribute is mandatory. It is allowed (though not yet recommended) to add _*Array_ children such as _floatArray_ The attributes are directly related to the scalar attributes under _atom_ which should be consulted for more info. Example - these are exactly equivalent representations An atomicBasisFunction. An atomic atomicBasisFunction which can be linked to atoms, eigenvalues/vectors etc. Normally contained within _basisSet_ Normally these are atom-centered functions, but they can also serve as "ghost" functions which are centered on points. These can be dummy atoms so that the atomRef mechanism can still be used. This information is required to interpret the eignevector components and map them onto the atom list. However this mapping is normally implicit in the program and so it may be necessary to generate basisSet information for some programs before XML technology can be automatically used to link the components of the CCML document. The atom owning this atomicBasisFunction. This reference is required to tie the reported eigenvector components to the list of atoms. This is provided for completeness but we do not see it being widely used and the symbolic representation (lm) is more valuable. This is a local annotation of the ABF and unlikely to be enumeratable. Thus a split s-orbital could have 3 ABFs with "s", "s'", "s''" but they would all have lm="s". This is a "standard" representation of the ABF, but not enumerated until we decide whether it can be formalised. Examples are "px", "dxy", etc. Note that d-orbitals and higher may be represented with redundant ABFs, e.g. 6 d-orbitals. The more standard the representation, the more useful this will be for searching. The stereochemistry round an atom centre. It follows the convention of the MIF format, and uses 4 distinct atoms to define the chirality. These can be any atoms (though they are normally bonded to the current atom). There is no default order and the order is defined by the atoms in the atomRefs4 attribute. If there are only 3 ligands, the current atom should be included in the 4 atomRefs. The value of the parity is a signed number. (It can only be zero if two or more atoms are coincident or the configuration is planar). The sign is the sign of the chiral volume created by the four atoms (a1, a2, a3, a4): | 1 1 1 1 | | x1 x2 x3 x4 | | y1 y2 y3 y4 | | z1 z2 z3 z4 | Note that atomParity cannot be used with the *Array syntax for atoms. A set of references to atoms. An atomSet consists of a number of unique references to atoms throught their ids. atomSets need not be related to molecules (which are generally created by aggregation of explicit atoms). Two or more atomSets may reference the same atom, and atomSets may be empty. atomSets have many potential uses such as: identifying functional groups results of substructure matching identifying atoms with particular roles in a calculation The atomSet may be referenced from elsewhere in the document and you are encouraged to use locally unique id attributes on atomSets. An atomType. atomTypes are used in a wide variety of ways in computational chemistry. They are normally labels added to existing atoms (or dummy atoms) in the molecule and have a number of defined properties. These properties are usually in addition to those deducible from the elementType of the atom. AtomTypes usually depend on the chemical or geometrical environment of the atom and are frequently assigned by algorithms with chemical perception. However they are often frequently set or "tweaked" by humans initiating a program run. AtomTypes on an atom have no formal relation to its elementType, which only describe the number of protons in the nucleus. It is not unknown (though potentially misleading) to use an "incompatible" atomType to alter the computational properties of an atom (e.g. pretend this K+ is a Ca++ to increase its effective charge). atomTypes will also be required to describe pseudoAtoms such as "halogen" (generic) or "methyl group" (unified atom). Atoms in computations can therefore have an atomType child with a "ref" attribute. An atomType contains numeric or other quantities associated with it (charges, masses, use in force-fields, etc.) and also description of any perception algorithms (chemical and/or geometrical) which could be used to compute or constrain it. This is still experimental. atomTypes are referred to by their mandatory name attribute. An atom refers to one or more atomTypes through atomType/@ref children examples not yet teste. The name will usually be namespaced as 'gulp:si', 'tripos:c.3', etc. It must occur except for atomType/@re. A container for one or more atomTypes. It can contain several atomTypes. A band or Brillouin zone. Not yet finalised. 2006-01-21: PMR. added kpointRef and deprecated kpointList. Band energies associated with this kpoint. The energy units must be given. kpoints should be described in kpointList and referenced. A container for bands. Experimental. A container for one or more atomicBasisFunctions. This can contain several orbitals. A bond between atoms, or between atoms and bonds. _bond_ is a child of _bondArray_ and contains bond information. Bond must refer to at least two atoms (normally using _atomRefs2_) but may also refer to more for multicentre bonds. Bond is often EMPTY but may contain _electron_, _length_ or _bondStereo_ elements. Validate Bonds One or more electrons associated with the bond. The _bondRef_ on the _electron_ should point to the id on the bond. We may relax this later and allow reference by context. The stereo convention for the bond. only one convention allowed. This is designed for multicentre bonds (as in delocalised systems or electron-deficient centres. The semantics are experimental at this stage. As an example, a B-H-B bond might be described as <bond atomRefs="b1 h2 b2"/. This is designed for pi-bonds and other systems where formal valence bonds are not drawn to atoms. The semantics are experimental at this stage. As an example, a Pt-|| bond (as the Pt-ethene bond in Zeise's salt) might be described as <bond atomRefs="pt1" bondRefs="b32"/. A user- or machine- assertion about the cyclic nature of a bond. Need NOT agree with the apparent cyclicity from the connection table. A container for a number of bonds. _bondArray_ is a child of _molecule_ and contains _bond_ information. There are two strategies: Create individual bond elements under bondArray (in any order). This gives the greatest flexibility but is the most verbose. Create *Array attributes (e.g. of orderArrayType under bondArray. This requires all arrays to be of identical lengths with explicit values for all bonds in every array. This is NOT suitable for complexType bond children such as _bondStereo_ nor can IDs be added to bonds.. It also cannot be checked as easily by schema- and schematron validation. The _atomRef1Array_ and _atomRef2Array_ attributes are then mandatory. It is allowed (though not yet recommended) to add _*Array_ children such as _floatArray_ The attributes are directly related to the scalar attributes under _atom_ which should be consulted for more info. Example - these are exactly equivalent representations A set of references to bonds. An bondSet consists of a number of unique references to bonds throught their ids. bondSets need not be related to molecules (which are generally created by aggregation of explicit bonds). Two or more bondSets may reference the same bond, and bondSets may be empty. bondSets have many potential uses such as: identifying functional groups results of substructure matching identifying bonds with particular roles in a calculation The bondSet may be referenced from elsewhere in the document and you are encouraged to use locally unique id attributes on bondSets. A container supporting cis trans wedge hatch and other stereochemistry. An explict list of atomRefs must be given, or it must be a child of bond. There are no implicit conventions such as E/Z. This will be extended to other types of stereochemistry. At present the following are supported: No atomRefs attribute. Deprecated, but probably unavoidable. This must be a child of bond where it picks up the two atomRefs in the atomRefs2 attribute. Possible values are C/T (which only makes sense if there is exactly one ligand at each end of the bond) and W/H. The latter should be raplaced by atomParity wherever possible. Note that W/H makes no sense without 2D atom coordinates. atomRefs4 attribute. The 4 atoms represent a cis or trans configuration. This may or may not be a child of bond; if so the second and third atomRefs should be identical with the two atomRefs in the bond. This structure can be used to guide processors in processing stereochemistry and is recommended, since there is general agreement on the semantics. The semantics of bondStereo not related to bonds is less clear (e.g. cumulenes, substituted ring nuclei) etc.It is currently an error to have more than one bondStereo referring to the same ordered 4-atom list atomRefs attribute. There are other stereochemical conventions such as cis/trans for metal complexes which require a variable number of reference atoms. This allows users to create their own - at present we do not see CML creating exhaustive tables. For example cis/trans square-planar complexes might require 4 (or 5) atoms for their definition, octahedral 6 or 7, etc. In principle this is very powerful and could supplement or replace the use of cis-, mer-, etc. the atomRefs and atomRefs4 attributes cannot be used simultaneously. The type of a bond. Bond types are used to describe the behaviour of bonds in forcefields, functional groups, reactions and many other domains. They are not as well formalised as atomTypes and we provide less semantic support. BondTypes are referred to by their mandatory _name_ attribute. The bondType name. The name will usually be namespaced as 'gulp:si', 'tripos:c.3', etc. It must occur except when the ref attribute is given. A container for one or more bondTypes. _bondTypeList_ can contain several bondTypes. A set of 3 cell parameters. Either 3 lengths or 3 angles. A general container for CML elements. Often the root of the CML (sub)document. Has no explicit function but can serve to hold the dictionary and namespace and version information, and is a useful tag to alert CML processors and search/XMLQuery tools that there is chemistry in the document. Can contain any content, but usually a list of molecules and other CML components. The fileId attribute can be used to preserve the origin of the information, though metadat should also be used. Can be nested. No specific restrictions.. An element to hold any combination of heterogeneous element children complexObject can be used as it stands but will often be extended by schema definitions in dictionary entries. A container for one or more experimental conditions. This can contain several conditions. These include (but are not limited to) intensive physical properties (temperature, pressure, etc.), apparatus (test-tube, rotary evaporator, etc.). Actions can be represented elsewhere by actionList and solvents or other substances by substanceList. A crystallographic cell. Required if fractional coordinates are provided for a molecule. Originally there were precisely SIX child scalars to represent the cell lengths and angles in that order. There are no default values; the spacegroup is also included. This is now deprecated and replaced by cellParameter 2006-03-06 PMR: added cellParameter child OLD STYLE: All 6 cell parameters must be given, even where angles are fixed by symmetry. The order is fixed as a,b,c,alpha,beta,gamma and software can neglect any title or dictRef attributes. Error estimates can be given if required. Any units can be used, but the defaults are Angstrom (10^-10 m) and degrees. NEW STYLE: Two cellParameter children are given The definition for an entry. The definition should be a short nounal phrase defining the subject of the entry. Definitions should not include commentary, implementations, equations or formulae (unless the subject is one of these) or examples. The definition can be in any markup language, but normally XHTML will be used, perhaps with links to other XML namespaces such as CML for chemistry. From the IUPAC Dictionary of Medicinal Chemistry Descriptive information. This can occur in objects which require textual comment such as entry. Entries should have at least one separate definitions. description is then used for most of the other information, including examples. The class attribute has an uncontrolled vocabulary and can be used to clarify the purposes of the description elements. A dictionary. A dictionary is a container for _entry_ elements. Dictionaries can also contain unit-related information. The dictRef attribute on a dictionary element sets a namespace-like prefix allowing the dictionary to be referenced from within the document. In general dictionaries are referenced from an element using the __dictRef__ attribute. 2005-12-15. PMR. added namespace and dictionaryPrefix. A dimension supporting scientific unit. This will be primarily used within the definition of units. Two dimensions are of the same type if their 'name' attributes are (case-sensitive) identical. Dimensions of the same typecan be algebraically combined using the 'power' attributes. Normally dimensions will be aggregated and cancelled algebraically, but the 'preserve' attribute can be used to prevent this. Thus a velocity gradient over length can be defined as: whereas cancelling the dimensions would give: Documentation in the annotation of an entry. A container similar to documentation in XML Schema. This is NOT part of the textual content of an entry but is designed to support the transformation of dictionary entrys into schemas for validation. This is experimental and should only be used for dictionaries, units, etc. One approach is to convert these into XML Schemas when the documentation and appinfo children will emerge in their correct position in the derived schema. Do NOT confuse documentation with the description or the definition which are part of the content of the dictionary If will probably only be used when there is significant appinfo in the entry or where the entry defines an XSD-like datatype of an element in the document. An element to hold eigenstuff. Holds an array of eigenvalues and a matrix of eigenvectors. No current semantics. Suggest it is developed for the chemical/physical role, e.g. "molecular obitals", "inertial matrix", "vibrational modes", "phonons", etc. An electron. Since there is very little use of electrons in current chemical information this is a fluid concept. I expect it to be used for electron counting, input and output of theochem operations, descriptions of orbitals, spin states, oxidation states, etc. Electrons can be associated with atoms, bonds and combinations of these. At present there is no hardcoded semantics. However, _atomRef_ and similar attributes can be used to associate electrons with atoms or bond. A dictionary entry. The original design for validation with attribute-based constraints is ponderous and fragile. In future constraints will be added through appinfo in annotation. We shall develop this further in the near future. 2003-03-30: added metadataList to content mode. 2007-01-20: added unitType. 2007-01-20: deprecated alternative, relatedEntry. These require approaches outside CMLSchema (e.g. RDF) An enumeration of value. An enumeration of string values. Used where a dictionary entry constrains the possible values in a document instance. The dataTypes (if any) must all be identical and are defined by the dataType of the containing element. An expression that can be evaluated. Experimental. This is essentially a mathematical function, expressed currently in reverse Polish notation but we expect to move to MathML. CML-1 dataType DEPRECATED. CML-1 dataType DEPRECATED. A molecular formula. It is defined by atomArrays each with a list of elementTypes and their counts (or default=1). All other information in the atomArray is ignored. formula are nestable so that aggregates (e.g. hydrates, salts, etc.) can be described. CML does not require that formula information is consistent with (say) crystallographic information; this allows for experimental variance. An alternative briefer representation is also available through the concise. This must include whitespace round all elements and their counts, which must be explicit. 2005-10-16. The semantics are now the following. A formula must have one or both: A concise attribute A single atomArray child, using array format. it must also have a formalCharge attribute if atomArray is used and the charge is non-zero. The concise, formalCharge and atomArrary information must always be consistent and software should throw an error if not. Until now there was no way of holding inline formula other than concise (although JUMBO5.0 is capable of reading them). We now extend formula.xsd to incorporate this through the attribute "inline" which requires the use of the "convention" attribute. The contents of inline are purely textual. It can be used with or without atomArray or concise but there is no guarantee that it can be interpreted as a meaningful chemical formula or that there is consistency. In some cases a document supplies several formula representations (e.g. the IUCr's CIF). In this case a molecule (or crystal) element might contain several formula children. The semantics of which to use are application dependent. Allows for fractional components. The charge on the formula. Mandatory if non-zero (i.e. cannot rely on concise) An inline representation of the formula. There are no controlled semantics and it need not be compatible with concise or atomArray. A container for a fragment fragment is a container for a molecule, potentially to be joined to other fragments. In addition there may be fragmentLists which represent branches from the molecule. There may also be a join child which is normally only found if there is a @countExpression. 2006-11-23: created fragment normally contains molecules branches from the moelcule. the inter-fragment join. Normally it only makes sense with @countExpression. No formal semantics (yet). A container for one or more fragments and joins. fragmentList can contain several fragments and joins. The normal content model is join fragment join fragment... 2006-07-20: PMR Added 2007-01-03: PMR Added role attribute A gradient. A container for a quantity or quantities representing the gradient of other quantities. At present just takes a scalar child. A structured identifier. Supports compund identifiers such as IChI. At present uses the V0.9 IChI XML representation verbatim but will almost certainly change with future IChIs. The inclusion of elements from other namespaces causes problems with validation. The content model is deliberately LAX but the actual elements in IChI will fail the validation as they are not declared in CML. For simple scalar values the value attribute can be used with empty content. Where an identifier has several components a series of label elements can be used. 2003-07-10: Fixed count on identifier children.. 2003-03-12: Added isotopic and atoms.. CML-1 dataType DEPRECATED. CML-1 dataType DEPRECATED. A specific isotope. Defines an isotope in terms of exact mass and spin. Differentiate from isotopeList which defines a mixture of isotope. A container for one or more isotopes. Can contain several isotopes. These may be related in several ways. This allows the definition of natural abundance and averged enrichment. Command to join two groups. EXPERIMENTAL. join will normally use atomRefs2 to identify 2 R atoms (i.e. elementType="R" that should be joined. The atoms to which the R atoms are attached are then joined by a new bond and the R groups are then deleted. It is currently an error if these atoms already have a connecting bond. 2006-05-20: PMR added. 2006-11-24: PMR deleted @left, @linkOnParent, @right, @repeat. 2006-11-24: PMR modified content model 2006-11-24: PMR added @moleculeRefs2 A kpoint. Not yet finalised. 2006-01-21: PMR. Created A container for kpoints. Experimental. A text string qualifying an object. A label can be used to identify or distinguish elements, add keywords or classifications and similar processes. It is usually interpretable by domain-aware humans (e.g. C3'-endo, but not a34561). It is usually either built in a semantically rich fashion (e.g. C2'-alpha-H) or belongs to a controlled vocabulary. It is possibly accessed by software in a domain-specific manner. It differs from description which is free text. The distinction between titles, names and labels is fuzzy, but we think this is worth making. Labels may be necesssary to identify objects within programs, while names are more likely to be reserved for database searches. Titles are likely to be freer text and not recommended for precise object retrieval. Labels should not contain whitespace. Punctuation marks are often necessary, but should not be gratuitously used. Punctuation clashing with XML character entities should be avoided; if this is not possible it should be escaped. From IUPAC Dictionary of Medicinal Chemistry A lattice of dimension 3 or less. Lattice is a general approach to describing periodic systems. It can have variable dimensionality or periodicity, and could be finite. _lattice_ is more general than _crystal_ in cmlCore which is used primarily for reporting crystallographic experiments.`A lattice can be described by latticeVectors, cell axes and angles, or metric tensors, etc. (only axes/angles are allowed under crystal). The dimensionality is enforced through a _system_ parent element. All appropriate cell parameters must be given, even where angles are fixed by symmetry. The order is fixed as a,b,c,alpha,beta,gamma and software can neglect any title or dictRef attributes. Error estimates can be given if required. Any units can be used, but the defaults are Angstrom (10^-10 m) and degrees. To be developed for lower dimensionality. A vector3 representing a lattice axis. a lattice can be represented by 1-3 non-linearly dependent latticeVectors. If the dimensionality is less than 3 latticeVectors are the preferred method. Similarly, if the axes show a mixture of periodicity and non-periodicity latticeVectors can support this. The number of periodic vectors must correspond with the periodicity attribute on a system element. The vector must not be zero and units must be given. (Zero vectors must not be used to reduce dimensionality). A lattice vector defaults to periodic.. Any or all of the axes may be periodic or aperiodic. An example could be a surface where 2 periodic axes (not necessarily orthogonal) are used to describe the coordinates in the surface, perhaps representing lattice vectors of a 3D crystal or 2D layer. The third vector is orthogonal and represents coordinates normal to the surface. In this case only the direction, not the magnitude of the vector is important. A length between two atoms. This is either an experimental measurement or used to build up internal coordinates (as in a z-matrix) (only one allowed). We expect to move length as a child of _molecule_ and remove it from here. A line in 3-space. A line characterised by one or two endpoints. 2006-01-02: the 6-number content has caused much confusion and will be obsoleted in favour of the point3 and vector3 attributes An internal or external link to other objects. Semantics are similar to XLink, but simpler and only a subset is implemented. This is intended to make the instances easy to create and read, and software relatively easy to implement. The architecture is: A single element ( link) used for all linking purposes. The link types are determined by the type attribute and can be: . locator. This points to a single target and must carry either a ref or href attribute. locator links are usually children of an extended link. arc. This is a 1:1 link with both ends ( from and to) defined. extended. This is usually a parent of several locator links and serves to create a grouping of link ends (i.e. a list of references in documents). Many-many links can be built up from arcs linking extended elements All links can have optional role attributes. The semantics of this are not defined; you are encouraged to use a URI as described in the XLink specification. There are two address spaces: The href attribute on locators behaves in the same way as href in HTML and is of type xsd:anyURI. Its primary use is to use XPointer to reference elements outside the document. The ref attribute on locators and the from and to attributes on arcs refer to IDs ( without the '#' syntax). Note: several other specific linking mechanisms are defined elsewhere in STM. relatedEntry should be used in dictionaries, and dictRef should be used to link to dictionaries. There are no required uses of link in STMML but we have used it to map atoms, electrons and bonds in reactions in CML Relation to XLink. At present (2002) we are not aware of generic XLink processors from which we would benefit, so the complete implementation brings little extra value. Among the simplifications from Xlink are: type supports only extended, locator and arc label is not supported and ids are used as targets of links. show and actuate are not supported. xlink:title is not supported (all STM elements can have a title attribute). xlink:role supports any string (i.e. does not have to be a namespaced resource). This mechanism can, of course, still be used and we shall promote it where STM benefits from it The to and from attributes point to IDs rather than labels The xlink namespace is not used It is not intended to create independent linkbases, although some collections of links may have this property and stand outside the documents they link to The type of the object/element in the 'from' attributes. Requires the objects referenced by the 'from' attributes to have a given elementType. Can be overridden by 'from' attributes in individual links. 2005-06-18: created The type of the object/element in the 'to' attributes. Requires the objects referenced by the 'to' attributes to have a given elementType. Can be overridden by 'to' attributes in individual links. 2005-06-18: created The set of ids in the base of the link. 2005-06-18: created The set of ids in the target of the link. 2005-06-18: created The id of the ancestral element of objects referenced by 'from' attributes. Provides a context for uniquifying the references in the 'from' attributes. Thus atoms referenced by ids should be unique within a given molecule and the id of this could be the 'fromContext'. 2005-06-18: created The id of the ancestral element of objects referenced by 'to' attributes. Provides a context for uniquifying the references in the 'to' attributes. Thus atoms referenced by ids should be unique within a given molecule and the id of this could be the 'toContext'. 2005-06-18: created The role of the link. Xlink adds semantics through a URI; we shall not be this strict. We shall not normally use this mechanism and use dictionaries instead. The target of the (locator) link, outside the document. A generic container with no implied semantics. A generic container with no implied semantics. It just contains things and can have attributes which bind conventions to it. It could often act as the root element in an STM document. A container for links Usage is now standardized with map as the container and link as the individual links. The links are often effectively typed pointers to other parts of the document. The type can be set for all links by the 'fromType' and 'toType' attributes, either in the map, which then applied to all links by default, or in individual links, when it overrides the map setting. Since ids may not be unique within a document the refs can be given context with the 'fromRef' and 'toRef' attributes in the map element. If more than one context is used it may be better to use multiple maps. The role of map, and its relationship to RDF is still being developed. Currently (2005) map has primarily been used to map atoms between reactants and products, but we also expect shortly to extend it to peak assignments and several otherr areas. A map consists of a number of links, which can be directional, relating two elements through their ids. Reference is through the mandatory 'to' and 'from' attributes which must point to existing id attributes on elements. The type of the dereferenced element can be specified in 'toType' and 'fromType' which, while redundant, is an aid to software and acts as a check on referential type integrity. In principle any element can be linked to any other, with 1:1, 1:n, and n:m topology. We expect maps to be used for precise chemical concepts such as reactions, peak assignments, electron management, molecular superpositions, etc. and that these are supported by bespoke code. For other links, especially with complex topology, users should consider whether RDF may be more appropriate. In some cases partial mapping is known (e.g. one set of atoms maps to another set), but the precise links are unknown. (This is not the same as n:m mapping where n*m precise links would be expected). In some cases there may be objects such as atomSets or peakGroups which could be linked to support this. Alternatively the 'fromSet' and 'toSet' attributes can be used to hold a list of ids. Thus from='a1 a2' to='b3 b4' might imply that there were two precise links (either {a1=>b3, a2=>b4} or {a1=>b4, a2=>b3}). This is most likely to be used in intermediate documents where more precise semantics can be added later. The ids must all refer to elements of the same type. Note that a 'to' link referencing a single atomSet (toType='atomSet') is not the same as a 'toSet' of toType='atom' with multiple atomIds. The first would require an 'atomSet' element in the document; the second would not. The precise semantics such as the order of ids are application-dependent. If the order is known in both the toSet and fromSet then individual links should be used rather than adding the burden of deconstruction on the implementer. 2005-06-18: added typing and role and updated docs. 2006-08-05: added ref attribute. The type of the object/element in the 'from' attributes. Requires the objects referenced by the 'from' attributes to have a given elementType. Can be overridden by 'from' attributes in individual links. 2005-06-18: created The type of the object/element in the 'to' attributes. Requires the objects referenced by the 'to' attributes to have a given elementType. Can be overridden by 'to' attributes in individual links. 2005-06-18: created The id of the ancestral element of objects referenced by 'from' attributes. Provides a context for uniquifying the references in the 'from' attributes. Thus atoms referenced by ids should be unique within a given molecule and the id of this could be the 'fromContext'. 2005-06-18: created The id of the ancestral element of objects referenced by 'to' attributes. Provides a context for uniquifying the references in the 'to' attributes. Thus atoms referenced by ids should be unique within a given molecule and the id of this could be the 'toContext'. 2005-06-18: created The role of the map. Semantics are undefined, and can be used to provide a small semi-controlled vocabulary for identifying maps of different types. 2005-06-18: created A rectangular matrix of any quantities. By default matrix represents a rectangular matrix of any quantities representable as XSD or STMML dataTypes. It consists of rows*columns elements, where columns is the fasting moving index. Assuming the elements are counted from 1 they are ordered V[1,1],V[1,2],...V[1,columns],V[2,1],V[2,2],...V[2,columns], ...V[rows,1],V[rows,2],...V[rows,columns] By default whitespace is used to separate matrix elements; see array for details. There are NO characters or markup delimiting the end of rows; authors must be careful!. The columns and rows attributes have no default values; a row vector requires a rows attribute of 1. matrix also supports many types of square matrix, but at present we require all elements to be given, even if the matrix is symmetric, antisymmetric or banded diagonal. The matrixType attribute allows software to validate and process the type of matrix. The mechanism of a reaction. In some cases this may be a simple textual description or reference within a controlled vocabulary. In others it may describe the complete progress of the reaction, including topological or cartesian movement of atoms, bonds and electrons and annotation with varying quantities (e.g. energies). For named reaction mechanisms ("Diels-Alder", "ping-pong", "Claisen rearrangement", etc.) the name element should be used. For classification (e.g. "hydrolysis"), the label may be more appropriate. In more detailed cases the mechanism refers to components of the reaction element. Thus bond23 might be cleaved while bond19 is transformed (mapped) to bond99. The mechanismComponent can be used to refer to components and add annotation. This is still experimental. IUPAC Compendium of Chemical Terminology 2nd Edition (1997) describes a mechanism as: A detailed description of the process leading from the reactants to the products of a reaction, including a characterization as complete as possible of the composition, structure, energy and other properties of reaction intermediates, products and transition states. An acceptable mechanism of a specified reaction (and there may be a number of such alternative mechanisms not excluded by the evidence) must be consistent with the reaction stoichiometry, the rate law and with all other available experimental data, such as the stereochemical course of the reaction. Inferences concerning the electronic motions which dynamically interconvert successive species along the reaction path (as represented by curved arrows, for example) are often included in the description of a mechanism. It should be noted that for many reactions all this information is not available and the suggested mechanism is based on incomplete experimental data. It is not appropriate to use the term mechanism to describe a statement of the probable sequence in a set of stepwise reactions. That should be referred to as a reaction sequence, and not a mechanism. CMLReact provides reactionScheme and annotions to describe the reaction sequence and both it and mechanism could co-occur within a reactionScheme container. 2006-02-28 PMR: changed content model to choice. An information component within a reaction mechanism. Information components can represent both physical constituents of the reaction or abstract concepts (types of bond cleavage, thermodynamics, etc.). There are several ways that components of the reaction can be annotated and/or quantified. One approach will be to refer to specific bonds and atoms through their ids and use mechanismComponent to describe their role, properties, etc. Another is to use mechanismComponent to identify types of bond formed/broken without reference to actual atoms and bonds (initially through the name element). Yet another will be to include information on the reaction profile. This is still experimental. A general container for metadata. A general container for metadata, including at least Dublin Core (DC) and CML-specific metadata In its simple form each element provides a name and content in a similar fashion to the meta element in HTML. metadata may have simpleContent (i.e. a string for adding further information - this is not controlled). A general container for metadata elements. MetadataLists can have local roles (e.g. a bibliographic reference could be a single meteadatList with, say, 3-6 components). The role attribute is used in an uncontrolled manner for this. MetadataLists can also be nested, but metadata and metadataList children should not occur on the same level of the hierarchy. A module in a calculation. Many programs are based on discrete modules which produce chunks of output. There are also conceptual chunks such as initialisation, calculation and summary/final which often have finer submodules such as cycle, iteration, snapshot, etc. There is no controlled vocabulary but a typical structure is shown in the example. One of the challenges of CCML is to find communality between different programs and to use agreed abstractions for the modules. The module can have a program-specific name through its title or dictRef (e.g. "MINIM", "l201") and a generic role ("dynamicsCalculation", "equilibration", etc.). In general role will be controlled by CCML. A container for atoms, bonds and submolecules. molecule is a container for atoms, bonds and submolecules along with properties such as crystal and non-builtin properties. It should either contain molecule or *Array for atoms and bonds. A molecule can be empty (e.g. we just know its name, id, etc.) "Molecule" need not represent a chemically meaningful molecule. It can contain atoms with bonds (as in the solid-sate) and it could simply carry a name (e.g. "taxol") without formal representation of the structure. It can contain "sub molecules", which are often discrete subcomponents (e.g. guest-host). Molecule can contain a <list> element to contain data related to the molecule. Within this can be string/float/integer and other nested lists Normally molecule will not contain fragment or fragmentList Revised content model to allow any order of lengths, angles, torsions 2003-01-01.. Added role attribute 2003-03-19.. 2006-05-21. PMR changed content model to (A|B|C...)* 2006-11-24. PMR removed @tail, @head, @countExpression, @repeat The float|integer|string children are for compatibility with CML-1 and are deprecated. scalar|array|matrix should be used instead. No formal semantics (yet). The role describes the purpose of the molecule element at this stage in the information. Examples can be "conformation", "dynamicsStep", "vibration", "valenceBondIsomer", etc. This attribute may be used by applications to determine how to present a set of molecule elements. A container for one or more molecules. moleculeList can contain several molecules. These may be related in many ways and there is are controlled semantics. However it should not be used for a molecule consisting of descendant molecules for which molecule should be used. A moleculeList can contain nested moleculeLists. 2006-07-20: PMR Added metadataList contains metadata. list is for experimental and other data. moleculeList normally contains molecules but we make provision for nested moleculeLists if required. The molecules can be a set of reference molecules which occur in the molecules and can be referenced. This makes the molecules more readable and normalizes data when molecules are used more than once. A string identifying a object. name is used for chemical names (formal and trivial) for molecules and also for identifiers such as CAS registry and RTECS. It can also be used for labelling atoms. It should be used in preference to the title attribute because it is repeatable and can be linked to a dictionary. Constraining patterns can be described in the dictionary and used to validate names. An object which might occur in scientific data or narrative. Deliberately vague. Thus an instrument might be built from sub component objects, or a program could be composed of smaller modules (objects). object could be used to encapsulate graphical primitives (e.g. in reaction schemes, drawings of apparatus, etc.). Unrestricted content model. An observation or occurrence. A container for any events that need to be recorded, whether planned or not. They can include notes, measurements, conditions that may be referenced elsewhere, etc. There are no controlled semantics. An operator within an expression. Experimental. An operator acts on one or more arguments (at present the number is fixed by the type). The formulation is reverse Polish so the result (with its dataType) is put on a stack for further use. A parameter describing the computation. A parameter is a broad concept and can describe numeric quantities, objects, keywords, etc. The distinction between keywords and parameters is often fuzzy. ("MINIM" might mean "minimize", while "MINIM=3" might require three iterations to be run. It may help to think of control keywords as boolean parameters. Numeric parameters can describe values in molecules, forcefields or other objects. Often the parameters will be refined or otherwise varied during the calculation. Some parameters may be fixed at particular values or relaxed at different stages in the calculation. Parameters can have errors, gradients and other indications of uncertainty. String/character parameters are often abbreviated in program input, and this is supported through the regex and ignoreCase attributes. ????? Parameters will usually be defined separately from the objects and use the ref attribute to reference them. Parameters can be used to describe additional constraints. This will probably require the development of a microlanguage and until then may use program-specific mechanisms. A common approach will be to use an array of values (or objects) to represent different input values for (parts of) the calculation. Thus a conformational change could be specified by an array of several torsion angles. A parameter will frequently have a dictRef pointing to a dictionary which may have more information about how the parameter is to be used or the values it can take. The allowable content of parameters may be shown by a "template" in the appinfo; this is stil experimental. This is a shorthand for a single scalar value of the parameter. It should only be used with the ref attribute as it inherits all the dataTyping of the referenced element. It must not be used for defining new parameters as it has no mechanism for units and dataTyping. [This may change?]. Used to define concepts such as independent and dependent variables A container for one or more parameters. parameterList can contain several parameters. 2006-02-16:PMR. Added parameterList as child An object in space carrying a set of properties. particles have many of the characteristics of atoms but without an atomic nucleus. It does not have an elementType and cannot be involved in bonding, etc. It has coordinates, may carry charge and might have a mass. It represents some aspect of a computational model and should not be used for purely geometrical concepts such as centroid. Examples of particles are "shells" (e.g. in GULP) which are linked to atoms for modelling polarizability or lonepairs and approximations to multipoles. Properties such as charge, mass should be scalar/array/matrix children. Used in a similar manner to atomType. Examples might be "lonePair", "polarizable Oxygen", etc. A peak; annotated by human or machine. A peak can describe: A single point in a spectrum. Usually a maximum but could be a shoulder, inflexion or indeed any point of interest. A continuous range of values within a spectrum, defined by maximum and minimum values on either/both axes The finer structure of the peak can be given with one or more peakStructure children The units should always be given. (The raw spectral data may unfortunately use different units and no assumptions should be made). The content model includes atom, bond, molecule, but these are deprecated and should be replaced by atomRefs, etc. 2005-11-22: PMR. Added moleculeRefs Allows inter alia the provenance of the peak assignment to be recorde. 2005-11-9. DEPRECATED; use atomRefs 2005-11-9. DEPRECATED; use bondRefs 2005-11-9. DEPRECATED; use moleculeRefs when developed 2005-11-9. PMR, added Atoms contributing to this peak The primary set of atoms responsible for the peak such as an NMR peak. Coupling constants and similar splitting should not use this but peakStructure. At present there is no substructure to this attribute or concept and only one attribute is allowed. It may be combined with bondRefs. Even single atoms should use atomRefs, not atomRef. Bonds contributing to this peak The primary set of bonds responsible for the peak such as an IR frequency. At present there is no substructure to this attribute or concept and only one attribute is allowed. It may be combined with atomRefs. Molecule(s) contributing to this peak The molecule or molecule responsible for the peak. At present there is no substructure to this attribute or concept and only one attribute is allowed. This might, for example, be used to manage a mass spectrum or chromatogram A list of closely related peaks or peakGroups. Distinguish between peakList (primarily a navigational container) and peakGroup where the peaks (or groups) have some close relation not shared by all peaks. All descendants must use consistent units. 2005-11-22. added atomRefs, bondRefs and moleculeRefs and deprecated atom, bond, molecule children Allows inter alia the provenance of the peak assignment to be recorde. 2005-11-22. DEPRECATED; use atomRefs 2005-11-22. DEPRECATED; use bondRefs 2005-11-22. DEPRECATED; use moleculeRefs Atoms contributing to this peak The primary set of atoms responsible for the peak such as an NMR peak. Coupling constants and similar splitting should not use this but peakStructure. At present there is no substructure to this attribute or concept and only one attribute is allowed. It may be combined with bondRefs. Even single atoms should use atomRefs, not atomRef. Bonds contributing to this peak The primary set of bonds responsible for the peak such as an IR frequency. At present there is no substructure to this attribute or concept and only one attribute is allowed. It may be combined with atomRefs. Molecule(s) contributing to this peak The molecule or molecule responsible for the peak. At present there is no substructure to this attribute or concept and only one attribute is allowed. This might, for example, be used to manage a mass spectrum or chromatogram A list of peaks or peakGroups. Distinguish between peakList (primarily a navigational container) and peakGroup where the peaks (or groups) have some close relation not shared by all peaks. All peaks and peakGroups should use the same units. Allows inter alia the provenance of the peak assignment to be recorde. The structure of a peak. Primarily to record couplings and other fine structure. At present we have tested this on HNMR spectra, C13 NMR and simple IR. We believe that other types of spectroscopy (ESR, NQR, etc) can be represented to some extent, but there may be systems beyond the current expressive power. For molecules without symmetry we believe that most of the important types of NMR coupling can be represented. Thus an atom which gives rise to two couplings can have two child PeakStructures, and this is shown in example1. <cml xmlns="http://www.xml-cml.org/schema"> <!-- Ha ... Hb ... Hc1, Hc2 --> <molecule id="m1"> <atomArray> <atom id="a1" elementType="H"> <label value="Ha"/> </atom> <atom id="a2" elementType="H"> <label value="Hb"/> </atom> <atom id="a3" elementType="H"> <label value="Hc1"/> </atom> <atom id="a4" elementType="H"> <label value="Hc2"/> </atom> </atomArray> </molecule> <spectrum id="spectrum2" title="test peaks"> <peakList> <peak id="p1" title="Ha" atomRefs="a1" peakShape="sharp" xUnits="unit:ppm" xValue="6.0"> <peakStructure type="coupling" peakMultiplicity="doublet11" value="12" units="unit:hertz" atomRefs="a2"/> </peak> <peak id="p2" title="Hb" atomRefs="a2" peakShape="sharp" xUnits="unit:ppm" xValue="7.0"> <peakStructure type="coupling" peakMultiplicity="doublet11" value="12" units="unit:hertz" atomRefs="a1"/> <peakStructure type="coupling" peakMultiplicity="triplet121" value="15" units="unit:hertz" atomRefs="a3 a4"/> </peak> <peak id="p3" title="Hc" atomRefs="a3 a4" peakShape="sharp" xUnits="unit:ppm" xValue="8.0"> <peakStructure type="coupling" peakMultiplicity="doublet11" value="15" units="unit:hertz" atomRefs="a2"/> </peak> </peakList> </spectrum> </cml> Where a peak is due to symmetry-related atoms there are different couplings to symmetrical atoms. Thus in an AA'BB' system there can be two couplings to the A atoms and we need nested peakStructures to represent these. In this case the order of the atoms in the peak@atomRefs maps to the order of the grandchildren. See example2. <!-- AA'BB' where there are 2 Ha and 2 Hb with two couplings J1 Ha ... Hb and Ha' ... Hb' J2 Ha ... Hb' and Ha' ... Hb --> <molecule id="m1"> <atomArray> <atom id="a1" elementType="H"> <label value="Ha"/> </atom> <atom id="a2" elementType="H"> <label value="Ha'"/> </atom> <atom id="a3" elementType="H"> <label value="Hb"/> </atom> <atom id="a4" elementType="H"> <label value="Hb'"/> </atom> </atomArray> </molecule> <spectrum id="spectrum2" title="test peaks"> <peakList> <!-- the ORDER of a1 and a2 is linked to the ORDER of the grandchildren elements, i.e. a1 couples to atoms in ps11 and ps21 while a2 relates to atoms is ps21 and ps22 --> <peak id="p1" title="Ha" atomRefs="a1, a2" peakShape="sharp" xUnits="unit:ppm" xValue="6.0"> <peakStructure id="ps1" type="coupling" peakMultiplicity="doublet" value="10" units="unit:hertz"> <peakStructure id="ps11" atomRefs="a3"/> <peakStructure id="ps12" atomRefs="a4"/> </peakStructure> <peakStructure id="ps2" type="coupling" peakMultiplicity="doublet" value="2" units="unit:hertz"> <peakStructure id="ps21" atomRefs="a4"/> <peakStructure id="ps22" atomRefs="a3"/> </peakStructure> </peak> </peakList> </spectrum> </cml> Allows inter alia the provenance of the peakStructure assignment to be recorded. Allows identification of couplings in symmetric systems. May also be usable for other complicated systems. The atoms to which the peakStructure refers. Allows identification of the atoms to which the peak is coupled (not the atoms contributing to the primnary reference for which peak should be used). It may be combined with bondRefs. Even single atoms should use atomRefs, not atomRef. Bonds contributing to this peakStructure Even a single bond should use bondRefs, not bondRef A plane in 3-space. An oriented plane of indefinite extent. A point in 3-space. An explicit potential. This represents the actual function for the potential (i.e. with explicit values) rather than the functional form, which will normally be referenced from this. The functional form of a potential. This has generic arguments and parameters rather than explicit ones. It is essentially a mathematical function, expressed currently in reverse Polish notation. A container for explicit potentials. Experimental. A product within a productList. product describes a product species which is produced in a reaction. See reactant for discussion of catalysis and solvents. A product will normally be identified by name(s), formula, or molecule and at least one of these should normally be given. Amount(s) of product can be given after this identification and can describe mass, volume, percent yield, etc. but not stoichiometry A container for one or more products. productList can contain several products. These may be related in several ways, including single list of products grouping of products of parallel reactions . A productList can contain nested productLists. The semantics of this are currently undefined. The number of copies of the productList involved in the stoichiometric reaction. Probably not useful for simple reactions but could be used for parallel reactions. A container for a property. property can contain one or more children, usually scalar, array or matrix. The dictRef attribute is required, even if there is a single scalar child with the same dictRef. The property may have a different dictRef from the child, thus providing an extension mechanism. Properties may have a state attribute to distinguish the state of matter Semantics are not yet controlled but could include thermochemistry, kinetics or other common properties. A container for one or more properties. propertyList can contain several properties. These include (but are not limited to) observations, or numeric quantities. A reactant within a reactantList. reactant describes a reactant species which takes part in a reaction. Catalysts and supports are not normally classified as reactants, but this is subjective. Enzymes (or parts of enzymes) may well be reactants, as could be substances which underwent chemical change but were restored to their original state. reactant is a powerful concept as it can support stoichiometry (atom and molecule counting), mapping (for mechanisms), etc. Solvents are best contained within substanceList. A reactant will normally be identified by name(s), formula, or molecule and at least one of these should normally be given. Amount(s) of reactant can be given after this identification and can describe mass, volume, etc. but not stoichiometr. The role of the reactant within a reactantList. Semantics are not yet controlled but could be limiting, oxidant, etc. TODO: a reactant might have multiple roles so this may have to become an element. The number of copies of the reactant involved in the stoichiometric reaction. Could be non-integer but should not be used for actual ratios of materials added (for which amount should be used). A container for one or more reactants. reactantList can contain several reactants. These may be related in several ways, including lists of related reactants reactant schemes multi-step reactants parallel and/or coupled reactants . A reactantList can contain nested reactantLists. The semantics of this are currently undefined. A chemical reaction or reaction step. reaction is a container for reactants, products, conditions, properties and possibly other information relating to the reaction, often within a reactionList. Partial semantics exist: name the name(s) of the reaction reactantList (normally only one) the grouped reactants spectatorList substances with well-defined chemistry which are involved in the reaction but do not change. Examples are side groups in proteins, cofactors, etc. The division between specattor and substance is subjective. substance or substanceList substances present in the reaction but not classified as reactants. Examples might be enzymes, catalysts, solvents, supports, workup, etc. condition conditions of the reaction. These may be text strings, but ideally will have clearer semantics such as scalars for temperature, etc. productList the grouped products. This allows for parallel reactions or other semantics. property properties (often physical) associated with the reaction. Examples might be heat of formation, kinetics or equilibrium constant. Reaction normally refers to an overall reaction or a step within a reactionList. For a complex "reaction", such as in enzymes or chain reactions, it may be best to use reactionScheme to hold the overall reaction and a reactionList of the individual reaction steps. The semantics of the content model are metadataList for general metadata label for classifying or describing the reaction (e.g. "hydrolysis") identifier for unique identification. This could be a classification such as EC (enzyme commission) or an IChI-like string generated from the components. these are followed by the possible components of the reaction and/or a reactionList of further details. . This allows any objects to be attached to the reaction, but particularly graphical primitives such as lines, arrows, etc. These should be provided as elements where possible (e.g. SVG) and should have references to the chemical objects they interact with (i.e. not simply relying on geometry). Markers with IDs can be included as part of the graphics object and their ids linked to the chemical elements using link. The yield of the reaction. Note that this lies in the range 0-1. A container for one or more reactions or reactionSchemes with no interrelations. A reactionList aggregates reactions and reactionSchemes but implies no semantics. The most common uses are to create small collections of reactions (e.g. databases or publications). A container for two or more related reactions and their relationships. Where reactions are closely related (and often formally dependent on each other) they should be contained within the reactionStepList of a reactionScheme. The semantics which have informed this design include: Steps within an organic synthesis. Two or more individual (primitive) steps provding the detailed mechanism for an overall reaction. Coupled or sequential reactions within biochemical pathways. This design is general because "reaction" is used in several ways. A biochemical pathway (e.g. oxidation of glucose to CO2 and water) involves many coupled enzyme reactions proceeding both in parallel and in sequence. Each of these steps ("reactions" in their own right) is itself complex and can include several mechanistics steps which are themselves reactions with products, reactants, etc. reactionScheme can therefore include reactionStepLists (with more reactionScheme children) which provide a more detailed view of the individual components. Where a set of reactions are primitives... The semantics of the content model are metadataList for general metadata label for classifying or describing the reaction (e.g. "hydrolysis") identifier for unique identification. This could be a classification such as EC (enzyme commission) or an IChI-like string generated from the components. these are followed by the possible components of the reaction and/or a reactionList of further details. A child of reactionStepList and a container for reaction or reactionScheme. reactionStep is always contained within reactionStepList and is designed to manage "sub-reactions" which have close relationships. These will often involve reactions which, taken together, describe a higher level reaction or reaction type. Examples are: biochemical pathways synthetic reaction schemes multi-step reactions parallel and/or coupled reactions . A reactionStep normally contains a single reaction or reactionScheme. It can have attributes such as yield and ratio which can be used by the parent reactionStepList. The name applies to the overall schema of reactions. label is for additional textual information and classification. reactionStepList normally contains reactions but we make provision for nested reactionSchemes if required. The yield of the reactionStep. Note that this lies in the range 0-1. The ratio of this step to one or more sibling steps. Note that this lies in the range 0-1. It is meaningless to use this unless there are siblings, in which case it refers to the relative molar fluxes through each. The "percentage yields" will need to be transformed to this range. There is no requirement that the sum of fluxes through a group of siblings sum to 1.0, though they should not sum to more. A container for one or more related reactionSteps. reactionStepList is always contained within reactionScheme and is designed to manage "sub-reactions" which have close relationships. These will often involve reactions which, taken together, describe a higher level reaction or reaction type. Examples are: biochemical pathways synthetic reaction schemes multi-step reactions parallel and/or coupled reactions . A reactionStepList contains reactionSteps (each of which contains reactions and/or reactionSchemes (e.g. where part of the process is known in greater detail)). It may not directly contain child reactionStepLists. The child reactionSteps can have attributes such as yield and ratio which describe the relationship of the component steps. Guidance on use: reactionScheme describes a complex of reactions with metadata, one (or more) overall reactions and a reactionStepList with the overall component reactions. reactionStepList aggregates and structures the individual subreactions. reactionList is a container for reactions and reactionSchemes with no semantics (e.g. a book or database of selected reactions). The name applies to the overall schema of reactions. label is for additional textual information and classification. reactionStepList normally contains reactionSteps. The reactiveCentre in a reaction. This describes the set(s) of bonds and atoms involved in the reaction. The semantics are flexible, but a common usage would be to create atomSet(s) and bondSet(s) mapping to groups which undergo changes. A region of the system. Under development. A subdivision of the system to which special protocols or properties may be attached. Typical regions could be defined by the presence of atoms belonging to an atomSet or geometrical boundaries. A region element will not always contain other elements, but may have references from other elements. It may create a protocol, e.g. atoms within a region might be replaced by a continuum model or be subject to a field. Semantics yet to be determined. Regions can be created by the unions of two or more regions. This allows a region to be built from a series of (say) spheres or boxes filling space. An entry related in some way to a dictionary entry. The range of relationships is not restricted but should include parents, aggregation, seeAlso and so on. DataCategories from ISO12620 can be referenced through the namespaced mechanism. The related entry. An analytical or spectral sample. The sample should contain information on what things were in the sample and their roles. It can include molecule, substance and substanceList. Typical rolos include solvent, mulling agents, salt disks, molecular supports, etc. but should not cover apparatus or conditions. A molecular description. A substance in the sample. A list of substances in the sample. An element to hold scalar data. scalar holds scalar data under a single generic container. The semantics are usually resolved by linking to a dictionary. scalar defaults to a scalar string but has attributes which affect the type. scalar does not necessarily reflect a physical object (for which object should be used). It may reflect a property of an object such as temperature, size, etc. Note that normal Schema validation tools cannot validate the data type of scalar (it is defined as string), but that a temporary schema can be constructed from the type and used for validation. Also the type can be contained in a dictionary and software could decide to retrieve this and use it for validation. Alternative to units Must be used in conjunction with unitType 2005-10-26: added Alternative to units Must be used in conjunction with unitType 2005-10-26: added Alternative to units Must be used in conjunction with multiplierToSI and/or constantToSI 2005-10-26: added A spectator object in a reaction. Objects are often present during a reaction which are not formally involved in bond breaking/formation and which are not modified during the reaction. They may be catalysts, but may also be objects which in some way constrain or help the reaction to take place (surfaces, micelles, groups in enzyme active sites, etc.). In some cases molecules present in a reaction mixture may act as spectators in steps in which they are not transformed. No controlled vocabulary. Examples could be 'host', 'hydrophobic ligand', 'charge-stabilizer', etc.. A container for spectators in a reaction. A spectrum and relevant data or metadata. The spectrum construct can hold metadataList, sample (which can contain molecule), conditionList (mainly for physical/chemical conditions, not instrumental), spectrumData for the actual data and instrumental settings/procedure and peakList for the assigned peaks. This approach puts the spectrum as the primary object of interest. It could also be possible to make spectrum a child of molecule (although a reference using ref might be preferable). A (complete) description of the thing to which the spectrum relates. May contain molecule or substanceList. Solvents, mulls, etc should be described here. The conditions relating to the spectrum (complementary to substanceList. A list of peaks. This may occur independently of the xaxis/yaxis data. The molecule to which the spectrum refers. Although this may also be contained in the sample element it is useful to state it here. No default. Data for the spectrum. This is primarily to record the data in interchangeable format and machine and manufacturers settings and can include other MLs in this area (AniML, SpectroML, etc.). We recommend ASCII representations of data and this is the only format that CMLSpect implementers have to support, but we also allow for the carriage of JCAMP and other data (in ML wrappers such as AniML). All numeric data should carry units and dictionary references if possible to allow for semantic interoperability. The x-axis/es, usually including the list of points at which data are recorded. Mandatory if y-axis data are given. Multiple x-axes are initially reserved for multiple scales rather than different measurements (for which an additional spectrum should be used). The y-axis/es, usually including the list of points at which data are recorded. Mandatory if x-axis data are given. Multiple y-axes are initially reserved for multiple scales rather than different measurements (for which an additional spectrum should be used). A container for one or more spectra. spectrumList can contain several spectra. These may be related in several ways, including lists of related spectra bundle of common analytical spectra (NMR, IR, UV...) repeat measurements . A spectrumList can contain nested spectrumLists. metadataList contains metadata. list is for experimental and other data. spectrumList normally contains spectrums but we make provision for nested spectrumLists if required. The molecules can be a set of reference molecules which occur in the spectrums and can be referenced. This makes the spectrums more readable and normalizes data when molecules are used more than once. A sphere in 3-space. An element to hold stmml data. stmml holds stmml data under a single generic container. Other namespaces may be present as children. No semantics implied. CML-1 dataType (DEPRECATED). CML-1 dataType DEPRECATED. A chemical substance. substance represents a chemical substance which is deliberately very general. It can represent things that may or may not be molecules, can and cannot be stored in bottles and may or may not be microscopic. Solutions and mixtures can be described by _substanceList_s of substances. The type attribute can be used to give qualitative information characterising the substance ("granular", "90%", etc.) and _role_ to describe the role in process ("desiccant", "support", etc.). There is currently no controlled vocabulary. Note that reaction is likely to have more precise semantics. The amount of a substance is controlled by the optional _amount_ child. Added property as a child 2002-12-29 role depends on context, and indicates some purpose associated with the substance. It might indicate 'catalyst', 'solvent', 'antoxidant', etc. but is not limited to any vocabulary. A list of chemical substances. Deliberately very general - see substance. substanceList is designed to manage solutions, mixtures, etc. and there is a small enumerated controlled vocabulary, but this can be extended through dictionaries. substanceList can have an amount child. This can indicate the amount of a solution or mixture; this example describes 100 ml of 0.1M NaOH(aq). Although apparently longwinded it is precise and fully machine-interpretable Added role attribute, 2003-03-12. Molecular, crystallographic or other symmetry. symmetry provides a label and/or symmetry operations for molecules or crystals. Point and spacegroups can be specified by strings, though these are not enumerated, because of variability in syntax (spaces, case-sensitivity, etc.), potential high symmetries (e.g. TMV disk is D17) and non-standard spacegroup settings. Provision is made for explicit symmetry operations through <matrix> child elements. By default the axes of symmetry are defined by the symbol - thus C2v requires z to be the unique axis, while P21/c requires b/y. Spacegroups imply the semantics defined in International Tables for Crystallography, (Int Union for Cryst., Munksgaard). Point groups are also defined therein. The element may also be used to give a label for the symmetry species (irreducible representation) such as "A1u" for a vibration or orbital. The matrices should be 3x3 for point group operators and 3x4 for spacegroup operators. The use of crystallographic notation ("x,1/2+y,-z") is not supported - this would be <matrix>1 0 0 0.0 0 1 0 0.5 0 0 1 0.0<matrix>. The default convention for point group symmetry is Schoenflies and for spacegroups is "H-M". Other conventions (e.g. "Hall") must be specfied through the convention attribute. This element implies that the Cartesians or fractional coordinates in a molecule are oriented appropriately. In some cases it may be useful to specify the symmetry of an arbitarily oriented molecule and the <molecule> element has the attribute symmetryOriented for this purpose. It may be better to use transform3 to hold the symmetry as they have fixed shape and have better defined mathematical operators. 2005-11-03 PMR. Added transform3 as children. The rotational symmetry number. Used for calculation of entropy, etc. The complete system of components in a calculation. There is no controlled vocabulary. A rectangular table of any quantities. By default table represents a rectangular table of any simple quantities representable as XSD or CML dataTypes. There are three layouts, columnwise, rowwise and without markup. In all cases it is essential that the columns, whether explicit or otherwise, are homogeneous within the column. Also the metadata for each column must be given explicitly.
  • columns: There is a single arrayList child containing (homogeneous) child elements ( array or listof size rows data. This is the "normal" orientation of data tables but the table display could be transposed by XSLT transformation if required. Access is to columns, and thence to the data within them. DataTyping, delimiters, etc are delegated to the arrays or lists, which must all be of the same size.
  • rows: with explicit trows. The metadata is carried in a theader element of size cols. Within each trow the data are contained in tcells
  • content: The metadata is carried in a theader element of size cols. data are contained in a single tableContent with columns moving fastest. Within the content the data are whitespace (or delimiter) separated.
For verification it is recommended that tables carry rows and columns attributes. The type of the tables should also be carried in a tableTypeattribute>
Validity contraints (XPath expression in table context) type @tableType @rows actual rowCount @columns actual columnCount tableHeader arrayList tableRowList tableContent column based columnBased recommended ./arrayList/@size or arrayList/*[self::array or self::list]/@size optional ./arrayList/@size or count(arrayList/*[self::array or self::list]) forbidden required forbidden forbidden row based rowBased recommended ./tableRowList/@size or count(tableRowList/tableRow) recommended count(tableHeader/tableHeaderCell) or count(tableRowList/tableRow/tableCell) required forbidden required forbidden content based contentBased required only by analysing tde table recommended count(tableHeader/tableHeaderCell) required forbidden forbidden required
A cell in a row of a table. tableCell is a data container of the table and only occurs as a child of tableRow. Normally it contains simpleContent, but may also contain a single child element (which could itself have complex or mixed content). However tableCell should NOT directly contain multiple children of any sort or mixed content. (It is declared as mixed content here to allow either text or element content, but not both.). The metadata for tableCells must be declared in a tableHeader/tableHeaderCell system Unmarked content of a table. This only occurs as simpleContent or a tableContent elements. It contains table/@rows * table/@columns items arranged rowwise (i.e. columns is fastest moving). Metadata for columns must be defined in tableHeader. The items of the table are ASCII strings. They can be separated by whitespace or by a defined single character delimiter as in array. The data must be rectangular and each implicit column must have consistent semantics. It can be used to hold CSV-like data (indeed CSV data can be directly entered as long as there are no quoted commas in which cas a different delimiter (or the safer tableRowList) should be used. Unlike tableRowList or arrayList (both of which can hold ASCII strings or XML elements, tableContent can only hold strings. Header for a table. Used for rowBased or contentBased tables when it is mandatory. Contains the metadata as tableHeaderCells which should match the (implicit) columns in number and semantic type. It is forbidden for arrayList tables as each array/list contains the metadata. Metadata for a column of a table. Only used when in rowBased or contentBased tables, and then as a direct child of tableHeader. There must be as many tableHeaderCells as there are implicit columns in tableRowList or tableContent. These cells carry the metadata and/or semantics for each column. These are similar to the attributes in array but without the lsist of minValue, errors etc. However they can (and should) carry all the units metadata. Alternative to units Must be used in conjunction with unitType 2005-10-26: added Alternative to units Must be used in conjunction with unitType 2005-10-26: added Alternative to units Must be used in conjunction with multiplierToSI and/or constantToSI 2005-10-26: added A row in a rowBased table. A direct child of tableRowList containing tableCells. At present all tableRows in a tableRowList must have the same count of tableCells and their semantics must correspond to the tableHeader in the table. No cells can be omitted and there is no spanning of cells. There is no need for a size attribute as the count is simply count(tableCell). List of rows in rowBased table. Metadata for rows must be defined in tableHeader. A torsion angle ("dihedral") between 4 distinct atoms. The atoms need not be formally bonded. It can be used for: Recording experimentally determined torsion angles (e.g. in a crystallographic paper). Providing the torsion component for internal coordinates (e.g. z-matrix). Note that the order of atoms is important. 2006-02-07: PMR. Fixed torsionAngleUnits A transform in 3-space. A 3-D transform. Conventionally a 4x4 matrix. The transition state in a reaction. This will normally contain a molecule which in its 2D representation will have partial bonds. These are yet to be formalized for the molecule element. Although spectators may stabilise or otherwise interact with the transitionState they are not contained within it. A propertyList is provided to capture transitionState properties. Still experimental. A scientific unit. A scientific unit. Units are of the following types: SI Units. These may be one of the seven fundamental types (e.g. meter) or may be derived (e.g. joule). An SI unit is identifiable because it has no parentSI attribute and will have a unitType attribute. 2005-122-17 - this may be obsolete; PMR nonSI Units. These will normally have a parent SI unit (e.g. calorie has joule as an SI parent). Constructed units. These use a syntax of the form: <unit id="g.s-1" name="gram per second" unitType="myUnitType:massPerTime"> <unit units="units:g" power="1"/> <unit units="siUnits:s" power="-1"/> </unit> This defines a new unit (g.s-1) which is composed from two existing units (units:g and siUnits:s) to create a new unit. The conversion to SI is computed from the two child units and may be added as a 'multiplierToSI' attribute. Only siUnits or units with 'multiplierToSI' can be used as child units; 'constantToSI cannot be used yet. If the new unit points to a unitType then the dimension can be checked. Thus if the published dimension of massPerTime does not agree with mass.length-1 an error is throwable. Alternatively a new unitType can be added as a child. The relationship of a unit to its SI parent is potentially complex and inconsistencies may arise. The following are available: parentSI. This points to the ID of a parent SI unit. If this ID is the same as the current unit the implication is that this is an SI unit. isSI. a boolean indicating whether the current unit is SI. multiplierToSI and constantToSI. If these are 1.0 and 0.0 (or missing) the implication is that this unit is SI. However this is fragile as units can be defined without these attributes and a unit could coincidentally have no numeric differences but not be an SI unit. 2003:04-09 Description or parentSI attribute enhanced. 2006:03-21 Added metadata and metadataList to content. Child unit used to build new unit. These children must have 'units' and 'power' attributes. Child unitType describing type of new unit. This can be added by the author (in which case they are responsible for checking consistency) or calculated by the software from the child units. Reference to a unit. This is used for the identification of child units when new units are composed from existing ones. Athough the syntax looks unusual it takes advantage of the tools for resolving units. See above for syntax. Abbreviation for the unit. This may be obsolete and symbol should be preferred. Symbol for the unit. This may be used for typographical display but NOT for identification as there is considerable variation in use. 2006-01-29: PMR. Added attribute. Power of unit used to create new one. Only allowed on child units A container for several unit entries. Usually forms the complete units dictionary (along with metadata). Note: this used to hold both units and unitTypes (though in separate files). This was unwieldy and unitTypeList has been created to hold unitTypes. Implementers are recommended to change any unitList/unitType to unitTypeList/unitType 2005-12-15. PMR. added namespace and dictionaryPrefix. 2005-12-17. PMR. added siNamespace . 2006-01-28. PMR. deprecated use for holding unitType. 2006-01-28: PMR. use unitTypeList. 2006-01-28: PMR. use unitTypeList. Maps dictRef prefix to the location of a dictionary. This requires the prefix and the physical URI address to be contained within the same file. We can anticipate that better mechanisms will arise - perhaps through XMLCatalogs. At least it works at present. The type of a scientific unit. Mandatory for SI Units, optional for nonSI units since they should be able to obtain this from their parent. For complex derived units without parents it may be useful. Used within a unitList Distinguish carefully from unitsType which is primarily used for attributes describing the units that elements carry 2006-02-06: PMR. Added preserve and symbol attributes. A container for several unitType entries. Usually forms the complete unitTypes dictionary (along with metadata). Note: unitTypes used to be held under unitList, but this was complicated to implement and unitTypeList makes a clean separation. 2006-01-28. PMR. created. Maps dictRef prefix to the location of a dictionary. This requires the prefix and the physical URI address to be contained within the same file. We can anticipate that better mechanisms will arise - perhaps through XMLCatalogs. At least it works at present. A vector in 3-space. The vector may have magnitude but is not rooted on any points (use line3). The x-axis. A container for all information relating to the x-axis (including scales, offsets, etc.) and the data themselves (in an array). Note: AniML uses "xValues" so avoid confusion with this. The x-data. These must match the y-data in number and order. There are tools to allow scaling and transformation (though unscaled data must be very carefully defined). The y-axis. A container for all information relating to the y-axis (including scales, offsets, etc.) and the data themselves (in an array). The y-data. These must match the x-data in number and order. There are tools to allow scaling and transformation (though unscaled data must be very carefully defined). A zMatrix. A container for length, angle and torsion, which must be arranged in the conventional zMatrix format.
cmlxom-cmlxom-4.11/src/main/resources/org/xmlcml/cml/base/schema.xsd000077500000000000000000017540071477224461000255400ustar00rootroot00000000000000 The abundance of an isotope. The abundance of an isotope in an isotopeList. Values are expressed in percentages. An action which might occur in scientific data or narrative. An action which might occur in scientific data or narrative. The definition is deliberately vague, intending to collect examples of possible usage. Thus an action could be addition of materials, measurement, application of heat or radiation. The content model is unrestricted. _action_ iself is normally a child of _actionList_. The start, end and duration attributes should be interpreted as XSD dateTimes and XSD durations. This allows precise recording of time of day, etc, or duration after start of actionList. A convention="xsd" attribute should be used to enforce XSD. a numerical value, with a units attribute linked to a dictionary. a human-readable string (unlikely to be machine processable) startCondition and endCondition values are not constrained, which allows XSL-like test attribute values. The semantics of the conditions are yet to be defined and at present are simply human readable. The order of the action elements in the document may, but will not always, define the order that they actually occur in. A delay can be shown by an action with no content. Repeated actions or actionLists are indicated through the count attribute. Number of times the action should be repeated. A container for a group of actions. ActionList contains a series of actions or nested actionLists. An alternative name for an entry. At present a child of _entry_ which represents an alternative string that refers to the concept. There is a partial controlled vocabulary in _alternativeType_ with values such as : synonym acronym abbreviation The amount of a substance. The units attribute is mandatory and can be customised to support mass, volumes, moles, percentages, or ratios (e.g. ppm). An angle between three atoms. It can be used for: Recording experimentally determined bond angles (e.g. in a crystallographic paper). Providing the angle component for internal coordinates (e.g. z-matrix). A documentation container similar to annotation in XML Schema. A documentation container similar to annotation in XML Schema. At present this is experimental and designed to be used for dictionaries, units, etc. One approach is to convert these into XML Schemas when the documentation and appinfo children will emerge in their correct position in the derived schema. It is possible that this may develop as a useful tool for annotating components of complex objects such as molecules. A container similar to appinfo in XML Schema. A container for machine processable documentation for an entry. This is likely to be platform and/or language specific. It is possible that XSLT, RDF or XBL will emerge as generic languages. See _annotation_ and _documentation_ for further information. An example in XSLT where an element _foo_ calls a bespoke template. Allows a processor to inspect the role of the appinfo and process accordingly. An argument for a function. Arguments can be typed and have explicit or free values. They can also carry out substitutions in the parent element and its children (substitute, still experiemental) and delete itself after this. 2006-02-14: PMR. Added atomType as child 2006-05-21: PMR. Added substitute and delete attributes A homogenous 1 dimensional array of similar object. These can be encoded as strings (i.e. XSD-like datatypes) and are concatenated as string content. The size of the array should always be >= 1. The default delimiter is whitespace. The _normalize-space()_ function of XSLT could be used to normalize all whitespace to single spaces and this should not affect the value of the array elements. To extract the elements __java.lang.StringTokenizer__ could be used. If the elements themselves contain whitespace then a different delimiter must be used and is identified through the delimiter attribute. This method is mandatory if it is required to represent empty strings. If a delimiter is used it MUST start and end the array - leading and trailing whitespace is ignored. Thus size+1 occurrences of the delimiter character are required. If non-normalized whitespace is to be encoded (e.g. newlines, tabs, etc) you are recommended to translate it character-wise to XML character entities. Note that normal Schema validation tools cannot validate the elements of array (they are defined as string) However if the string is split, a temporary schema can be constructed from the type and used for validation. Also the type can be contained in a dictionary and software could decide to retrieve this and use it for validation. When the elements of the array are not simple scalars (e.g. scalars with a value and an error, the scalars should be used as the elements. Although this is verbose, it is simple to understand. If there is a demand for more compact representations, it will be possible to define the syntax in a later version. the size attribute is not mandatory but provides a useful validity check): Alternative to units Must be used in conjunction with unitType 2005-10-26: added Alternative to units Must be used in conjunction with unitType 2005-10-26: added Alternative to units Must be used in conjunction with multiplierToSI and/or constantToSI 2005-10-26: added A list of arrays or lists. A major use of arrayList is to contain data within rectangular tables. However there is no absolute requirement and the table can have any shape. The shape attribute hould be used to assert rectangularity. 2006-11-03: created An atom. Atoms can only be chosen from the periodic table and superatoms such as "Phe" or "Tyr" are not allowed. The elementType of an atom is identified by that attribute. There are two additional elementTypes, "Du" (for an object which does not have an identifiable nucleus but is useful in calculations and definitions (such as a centroid); and "R" which describes a generic fragment. Although atoms have an elementType, they do not, by default, support arbitrary atomTypes for which the <atomType> element should be used. 2006-01-12: PMR. Added vector3 child to support accelerations, velocities, dipole, etc. 2006-06-01: PMR. Added documentation. The main content model of the atom. name can be used for atom labels, etc. More than one name can be used if required. scalar contains any scalar properties of the atom (examples are chemical shift, B-value, etc.) linked through dictRef (CmlDictRefType). array contains any properties of the atom describable by a homogeneous array linked through dictRef (CmlDictRefType). matrix contains any properties of the atom describable by a homogeneous matrix linked through dictRef (CmlDictRefType). An example is the polarizability tensor atomParity (CmlAtomParityElement) the required way of defining atom-based chirality electron a away of associating electron(s) with the atom Most useful in _formula_ but possibly useful in _atomArray_ where coordinates and connectivity is not defined. No formal default, but assumed to be 1. This can be used to describe the purpose of atoms whose _elementType_s are __dummy__ or __locant__. Vocabulary not controlled. 2005-11-27: Added PMR 2005-11-27: Added PMR A container for a list of atoms. A child of _molecule_ and contains _atom_ information. There are two strategies: Create individual _atom_ elements under _atomArray_ (in any order). This gives the greatest flexibility but is the most verbose. Create *Array attributes (e.g. of _elementTypeArrayType_ under _atomArray_. This requires all arrays to be of identical lengths with explicit values for all atoms in every array. This is NOT suitable for complexType atom children such as _atomParity_. It also cannot be checked as easily by schema- and schematron validation. The _atomIDArray_ attribute is mandatory. It is allowed (though not yet recommended) to add _*Array_ children such as _floatArray_ The attributes are directly related to the scalar attributes under _atom_ which should be consulted for more info. Example - these are exactly equivalent representations An atomicBasisFunction. An atomic atomicBasisFunction which can be linked to atoms, eigenvalues/vectors etc. Normally contained within _basisSet_ Normally these are atom-centered functions, but they can also serve as "ghost" functions which are centered on points. These can be dummy atoms so that the atomRef mechanism can still be used. This information is required to interpret the eignevector components and map them onto the atom list. However this mapping is normally implicit in the program and so it may be necessary to generate basisSet information for some programs before XML technology can be automatically used to link the components of the CCML document. The atom owning this atomicBasisFunction. This reference is required to tie the reported eigenvector components to the list of atoms. This is provided for completeness but we do not see it being widely used and the symbolic representation (lm) is more valuable. This is a local annotation of the ABF and unlikely to be enumeratable. Thus a split s-orbital could have 3 ABFs with "s", "s'", "s''" but they would all have lm="s". This is a "standard" representation of the ABF, but not enumerated until we decide whether it can be formalised. Examples are "px", "dxy", etc. Note that d-orbitals and higher may be represented with redundant ABFs, e.g. 6 d-orbitals. The more standard the representation, the more useful this will be for searching. The stereochemistry round an atom centre. It follows the convention of the MIF format, and uses 4 distinct atoms to define the chirality. These can be any atoms (though they are normally bonded to the current atom). There is no default order and the order is defined by the atoms in the atomRefs4 attribute. If there are only 3 ligands, the current atom should be included in the 4 atomRefs. The value of the parity is a signed number. (It can only be zero if two or more atoms are coincident or the configuration is planar). The sign is the sign of the chiral volume created by the four atoms (a1, a2, a3, a4): | 1 1 1 1 | | x1 x2 x3 x4 | | y1 y2 y3 y4 | | z1 z2 z3 z4 | Note that atomParity cannot be used with the *Array syntax for atoms. A set of references to atoms. An atomSet consists of a number of unique references to atoms throught their ids. atomSets need not be related to molecules (which are generally created by aggregation of explicit atoms). Two or more atomSets may reference the same atom, and atomSets may be empty. atomSets have many potential uses such as: identifying functional groups results of substructure matching identifying atoms with particular roles in a calculation The atomSet may be referenced from elsewhere in the document and you are encouraged to use locally unique id attributes on atomSets. An atomType. atomTypes are used in a wide variety of ways in computational chemistry. They are normally labels added to existing atoms (or dummy atoms) in the molecule and have a number of defined properties. These properties are usually in addition to those deducible from the elementType of the atom. AtomTypes usually depend on the chemical or geometrical environment of the atom and are frequently assigned by algorithms with chemical perception. However they are often frequently set or "tweaked" by humans initiating a program run. AtomTypes on an atom have no formal relation to its elementType, which only describe the number of protons in the nucleus. It is not unknown (though potentially misleading) to use an "incompatible" atomType to alter the computational properties of an atom (e.g. pretend this K+ is a Ca++ to increase its effective charge). atomTypes will also be required to describe pseudoAtoms such as "halogen" (generic) or "methyl group" (unified atom). Atoms in computations can therefore have an atomType child with a "ref" attribute. An atomType contains numeric or other quantities associated with it (charges, masses, use in force-fields, etc.) and also description of any perception algorithms (chemical and/or geometrical) which could be used to compute or constrain it. This is still experimental. atomTypes are referred to by their mandatory name attribute. An atom refers to one or more atomTypes through atomType/@ref children examples not yet teste. The name will usually be namespaced as 'gulp:si', 'tripos:c.3', etc. It must occur except for atomType/@re. A container for one or more atomTypes. It can contain several atomTypes. A band or Brillouin zone. Not yet finalised. 2006-01-21: PMR. added kpointRef and deprecated kpointList. Band energies associated with this kpoint. The energy units must be given. kpoints should be described in kpointList and referenced. A container for bands. Experimental. A container for one or more atomicBasisFunctions. This can contain several orbitals. A bond between atoms, or between atoms and bonds. _bond_ is a child of _bondArray_ and contains bond information. Bond must refer to at least two atoms (normally using _atomRefs2_) but may also refer to more for multicentre bonds. Bond is often EMPTY but may contain _electron_, _length_ or _bondStereo_ elements. Validate Bonds One or more electrons associated with the bond. The _bondRef_ on the _electron_ should point to the id on the bond. We may relax this later and allow reference by context. The stereo convention for the bond. only one convention allowed. This is designed for multicentre bonds (as in delocalised systems or electron-deficient centres. The semantics are experimental at this stage. As an example, a B-H-B bond might be described as <bond atomRefs="b1 h2 b2"/. This is designed for pi-bonds and other systems where formal valence bonds are not drawn to atoms. The semantics are experimental at this stage. As an example, a Pt-|| bond (as the Pt-ethene bond in Zeise's salt) might be described as <bond atomRefs="pt1" bondRefs="b32"/. A user- or machine- assertion about the cyclic nature of a bond. Need NOT agree with the apparent cyclicity from the connection table. A container for a number of bonds. _bondArray_ is a child of _molecule_ and contains _bond_ information. There are two strategies: Create individual bond elements under bondArray (in any order). This gives the greatest flexibility but is the most verbose. Create *Array attributes (e.g. of orderArrayType under bondArray. This requires all arrays to be of identical lengths with explicit values for all bonds in every array. This is NOT suitable for complexType bond children such as _bondStereo_ nor can IDs be added to bonds.. It also cannot be checked as easily by schema- and schematron validation. The _atomRef1Array_ and _atomRef2Array_ attributes are then mandatory. It is allowed (though not yet recommended) to add _*Array_ children such as _floatArray_ The attributes are directly related to the scalar attributes under _atom_ which should be consulted for more info. Example - these are exactly equivalent representations A set of references to bonds. An bondSet consists of a number of unique references to bonds throught their ids. bondSets need not be related to molecules (which are generally created by aggregation of explicit bonds). Two or more bondSets may reference the same bond, and bondSets may be empty. bondSets have many potential uses such as: identifying functional groups results of substructure matching identifying bonds with particular roles in a calculation The bondSet may be referenced from elsewhere in the document and you are encouraged to use locally unique id attributes on bondSets. A container supporting cis trans wedge hatch and other stereochemistry. An explict list of atomRefs must be given, or it must be a child of bond. There are no implicit conventions such as E/Z. This will be extended to other types of stereochemistry. At present the following are supported: No atomRefs attribute. Deprecated, but probably unavoidable. This must be a child of bond where it picks up the two atomRefs in the atomRefs2 attribute. Possible values are C/T (which only makes sense if there is exactly one ligand at each end of the bond) and W/H. The latter should be raplaced by atomParity wherever possible. Note that W/H makes no sense without 2D atom coordinates. atomRefs4 attribute. The 4 atoms represent a cis or trans configuration. This may or may not be a child of bond; if so the second and third atomRefs should be identical with the two atomRefs in the bond. This structure can be used to guide processors in processing stereochemistry and is recommended, since there is general agreement on the semantics. The semantics of bondStereo not related to bonds is less clear (e.g. cumulenes, substituted ring nuclei) etc.It is currently an error to have more than one bondStereo referring to the same ordered 4-atom list atomRefs attribute. There are other stereochemical conventions such as cis/trans for metal complexes which require a variable number of reference atoms. This allows users to create their own - at present we do not see CML creating exhaustive tables. For example cis/trans square-planar complexes might require 4 (or 5) atoms for their definition, octahedral 6 or 7, etc. In principle this is very powerful and could supplement or replace the use of cis-, mer-, etc. the atomRefs and atomRefs4 attributes cannot be used simultaneously. The type of a bond. Bond types are used to describe the behaviour of bonds in forcefields, functional groups, reactions and many other domains. They are not as well formalised as atomTypes and we provide less semantic support. BondTypes are referred to by their mandatory _name_ attribute. The bondType name. The name will usually be namespaced as 'gulp:si', 'tripos:c.3', etc. It must occur except when the ref attribute is given. A container for one or more bondTypes. _bondTypeList_ can contain several bondTypes. A set of 3 cell parameters. Either 3 lengths or 3 angles. A general container for CML elements. Often the root of the CML (sub)document. Has no explicit function but can serve to hold the dictionary and namespace and version information, and is a useful tag to alert CML processors and search/XMLQuery tools that there is chemistry in the document. Can contain any content, but usually a list of molecules and other CML components. The fileId attribute can be used to preserve the origin of the information, though metadat should also be used. Can be nested. No specific restrictions.. An element to hold any combination of heterogeneous element children complexObject can be used as it stands but will often be extended by schema definitions in dictionary entries. A container for one or more experimental conditions. This can contain several conditions. These include (but are not limited to) intensive physical properties (temperature, pressure, etc.), apparatus (test-tube, rotary evaporator, etc.). Actions can be represented elsewhere by actionList and solvents or other substances by substanceList. A crystallographic cell. Required if fractional coordinates are provided for a molecule. Originally there were precisely SIX child scalars to represent the cell lengths and angles in that order. There are no default values; the spacegroup is also included. This is now deprecated and replaced by cellParameter 2006-03-06 PMR: added cellParameter child OLD STYLE: All 6 cell parameters must be given, even where angles are fixed by symmetry. The order is fixed as a,b,c,alpha,beta,gamma and software can neglect any title or dictRef attributes. Error estimates can be given if required. Any units can be used, but the defaults are Angstrom (10^-10 m) and degrees. NEW STYLE: Two cellParameter children are given The definition for an entry. The definition should be a short nounal phrase defining the subject of the entry. Definitions should not include commentary, implementations, equations or formulae (unless the subject is one of these) or examples. The definition can be in any markup language, but normally XHTML will be used, perhaps with links to other XML namespaces such as CML for chemistry. From the IUPAC Dictionary of Medicinal Chemistry Descriptive information. This can occur in objects which require textual comment such as entry. Entries should have at least one separate definitions. description is then used for most of the other information, including examples. The class attribute has an uncontrolled vocabulary and can be used to clarify the purposes of the description elements. A dictionary. A dictionary is a container for _entry_ elements. Dictionaries can also contain unit-related information. The dictRef attribute on a dictionary element sets a namespace-like prefix allowing the dictionary to be referenced from within the document. In general dictionaries are referenced from an element using the __dictRef__ attribute. 2005-12-15. PMR. added namespace and dictionaryPrefix. A dimension supporting scientific unit. This will be primarily used within the definition of units. Two dimensions are of the same type if their 'name' attributes are (case-sensitive) identical. Dimensions of the same typecan be algebraically combined using the 'power' attributes. Normally dimensions will be aggregated and cancelled algebraically, but the 'preserve' attribute can be used to prevent this. Thus a velocity gradient over length can be defined as: whereas cancelling the dimensions would give: Documentation in the annotation of an entry. A container similar to documentation in XML Schema. This is NOT part of the textual content of an entry but is designed to support the transformation of dictionary entrys into schemas for validation. This is experimental and should only be used for dictionaries, units, etc. One approach is to convert these into XML Schemas when the documentation and appinfo children will emerge in their correct position in the derived schema. Do NOT confuse documentation with the description or the definition which are part of the content of the dictionary If will probably only be used when there is significant appinfo in the entry or where the entry defines an XSD-like datatype of an element in the document. An element to hold eigenstuff. Holds an array of eigenvalues and a matrix of eigenvectors. No current semantics. Suggest it is developed for the chemical/physical role, e.g. "molecular obitals", "inertial matrix", "vibrational modes", "phonons", etc. An electron. Since there is very little use of electrons in current chemical information this is a fluid concept. I expect it to be used for electron counting, input and output of theochem operations, descriptions of orbitals, spin states, oxidation states, etc. Electrons can be associated with atoms, bonds and combinations of these. At present there is no hardcoded semantics. However, _atomRef_ and similar attributes can be used to associate electrons with atoms or bond. A dictionary entry. The original design for validation with attribute-based constraints is ponderous and fragile. In future constraints will be added through appinfo in annotation. We shall develop this further in the near future. 2003-03-30: added metadataList to content mode. 2007-01-20: added unitType. 2007-01-20: deprecated alternative, relatedEntry. These require approaches outside CMLSchema (e.g. RDF) An enumeration of value. An enumeration of string values. Used where a dictionary entry constrains the possible values in a document instance. The dataTypes (if any) must all be identical and are defined by the dataType of the containing element. An expression that can be evaluated. Experimental. This is essentially a mathematical function, expressed currently in reverse Polish notation but we expect to move to MathML. CML-1 dataType DEPRECATED. CML-1 dataType DEPRECATED. A molecular formula. It is defined by atomArrays each with a list of elementTypes and their counts (or default=1). All other information in the atomArray is ignored. formula are nestable so that aggregates (e.g. hydrates, salts, etc.) can be described. CML does not require that formula information is consistent with (say) crystallographic information; this allows for experimental variance. An alternative briefer representation is also available through the concise. This must include whitespace round all elements and their counts, which must be explicit. 2005-10-16. The semantics are now the following. A formula must have one or both: A concise attribute A single atomArray child, using array format. it must also have a formalCharge attribute if atomArray is used and the charge is non-zero. The concise, formalCharge and atomArrary information must always be consistent and software should throw an error if not. Until now there was no way of holding inline formula other than concise (although JUMBO5.0 is capable of reading them). We now extend formula.xsd to incorporate this through the attribute "inline" which requires the use of the "convention" attribute. The contents of inline are purely textual. It can be used with or without atomArray or concise but there is no guarantee that it can be interpreted as a meaningful chemical formula or that there is consistency. In some cases a document supplies several formula representations (e.g. the IUCr's CIF). In this case a molecule (or crystal) element might contain several formula children. The semantics of which to use are application dependent. Allows for fractional components. The charge on the formula. Mandatory if non-zero (i.e. cannot rely on concise) An inline representation of the formula. There are no controlled semantics and it need not be compatible with concise or atomArray. A container for a fragment fragment is a container for a molecule, potentially to be joined to other fragments. In addition there may be fragmentLists which represent branches from the molecule. There may also be a join child which is normally only found if there is a @countExpression. 2006-11-23: created fragment normally contains molecules branches from the moelcule. the inter-fragment join. Normally it only makes sense with @countExpression. No formal semantics (yet). A container for one or more fragments and joins. fragmentList can contain several fragments and joins. The normal content model is join fragment join fragment... 2006-07-20: PMR Added 2007-01-03: PMR Added role attribute A gradient. A container for a quantity or quantities representing the gradient of other quantities. At present just takes a scalar child. A structured identifier. Supports compund identifiers such as IChI. At present uses the V0.9 IChI XML representation verbatim but will almost certainly change with future IChIs. The inclusion of elements from other namespaces causes problems with validation. The content model is deliberately LAX but the actual elements in IChI will fail the validation as they are not declared in CML. For simple scalar values the value attribute can be used with empty content. Where an identifier has several components a series of label elements can be used. 2003-07-10: Fixed count on identifier children.. 2003-03-12: Added isotopic and atoms.. CML-1 dataType DEPRECATED. CML-1 dataType DEPRECATED. A specific isotope. Defines an isotope in terms of exact mass and spin. Differentiate from isotopeList which defines a mixture of isotope. A container for one or more isotopes. Can contain several isotopes. These may be related in several ways. This allows the definition of natural abundance and averged enrichment. Command to join two groups. EXPERIMENTAL. join will normally use atomRefs2 to identify 2 R atoms (i.e. elementType="R" that should be joined. The atoms to which the R atoms are attached are then joined by a new bond and the R groups are then deleted. It is currently an error if these atoms already have a connecting bond. 2006-05-20: PMR added. 2006-11-24: PMR deleted @left, @linkOnParent, @right, @repeat. 2006-11-24: PMR modified content model 2006-11-24: PMR added @moleculeRefs2 A kpoint. Not yet finalised. 2006-01-21: PMR. Created A container for kpoints. Experimental. A text string qualifying an object. A label can be used to identify or distinguish elements, add keywords or classifications and similar processes. It is usually interpretable by domain-aware humans (e.g. C3'-endo, but not a34561). It is usually either built in a semantically rich fashion (e.g. C2'-alpha-H) or belongs to a controlled vocabulary. It is possibly accessed by software in a domain-specific manner. It differs from description which is free text. The distinction between titles, names and labels is fuzzy, but we think this is worth making. Labels may be necesssary to identify objects within programs, while names are more likely to be reserved for database searches. Titles are likely to be freer text and not recommended for precise object retrieval. Labels should not contain whitespace. Punctuation marks are often necessary, but should not be gratuitously used. Punctuation clashing with XML character entities should be avoided; if this is not possible it should be escaped. From IUPAC Dictionary of Medicinal Chemistry A lattice of dimension 3 or less. Lattice is a general approach to describing periodic systems. It can have variable dimensionality or periodicity, and could be finite. _lattice_ is more general than _crystal_ in cmlCore which is used primarily for reporting crystallographic experiments.`A lattice can be described by latticeVectors, cell axes and angles, or metric tensors, etc. (only axes/angles are allowed under crystal). The dimensionality is enforced through a _system_ parent element. All appropriate cell parameters must be given, even where angles are fixed by symmetry. The order is fixed as a,b,c,alpha,beta,gamma and software can neglect any title or dictRef attributes. Error estimates can be given if required. Any units can be used, but the defaults are Angstrom (10^-10 m) and degrees. To be developed for lower dimensionality. A vector3 representing a lattice axis. a lattice can be represented by 1-3 non-linearly dependent latticeVectors. If the dimensionality is less than 3 latticeVectors are the preferred method. Similarly, if the axes show a mixture of periodicity and non-periodicity latticeVectors can support this. The number of periodic vectors must correspond with the periodicity attribute on a system element. The vector must not be zero and units must be given. (Zero vectors must not be used to reduce dimensionality). A lattice vector defaults to periodic.. Any or all of the axes may be periodic or aperiodic. An example could be a surface where 2 periodic axes (not necessarily orthogonal) are used to describe the coordinates in the surface, perhaps representing lattice vectors of a 3D crystal or 2D layer. The third vector is orthogonal and represents coordinates normal to the surface. In this case only the direction, not the magnitude of the vector is important. A length between two atoms. This is either an experimental measurement or used to build up internal coordinates (as in a z-matrix) (only one allowed). We expect to move length as a child of _molecule_ and remove it from here. A line in 3-space. A line characterised by one or two endpoints. 2006-01-02: the 6-number content has caused much confusion and will be obsoleted in favour of the point3 and vector3 attributes An internal or external link to other objects. Semantics are similar to XLink, but simpler and only a subset is implemented. This is intended to make the instances easy to create and read, and software relatively easy to implement. The architecture is: A single element ( link) used for all linking purposes. The link types are determined by the type attribute and can be: . locator. This points to a single target and must carry either a ref or href attribute. locator links are usually children of an extended link. arc. This is a 1:1 link with both ends ( from and to) defined. extended. This is usually a parent of several locator links and serves to create a grouping of link ends (i.e. a list of references in documents). Many-many links can be built up from arcs linking extended elements All links can have optional role attributes. The semantics of this are not defined; you are encouraged to use a URI as described in the XLink specification. There are two address spaces: The href attribute on locators behaves in the same way as href in HTML and is of type xsd:anyURI. Its primary use is to use XPointer to reference elements outside the document. The ref attribute on locators and the from and to attributes on arcs refer to IDs ( without the '#' syntax). Note: several other specific linking mechanisms are defined elsewhere in STM. relatedEntry should be used in dictionaries, and dictRef should be used to link to dictionaries. There are no required uses of link in STMML but we have used it to map atoms, electrons and bonds in reactions in CML Relation to XLink. At present (2002) we are not aware of generic XLink processors from which we would benefit, so the complete implementation brings little extra value. Among the simplifications from Xlink are: type supports only extended, locator and arc label is not supported and ids are used as targets of links. show and actuate are not supported. xlink:title is not supported (all STM elements can have a title attribute). xlink:role supports any string (i.e. does not have to be a namespaced resource). This mechanism can, of course, still be used and we shall promote it where STM benefits from it The to and from attributes point to IDs rather than labels The xlink namespace is not used It is not intended to create independent linkbases, although some collections of links may have this property and stand outside the documents they link to The type of the object/element in the 'from' attributes. Requires the objects referenced by the 'from' attributes to have a given elementType. Can be overridden by 'from' attributes in individual links. 2005-06-18: created The type of the object/element in the 'to' attributes. Requires the objects referenced by the 'to' attributes to have a given elementType. Can be overridden by 'to' attributes in individual links. 2005-06-18: created The set of ids in the base of the link. 2005-06-18: created The set of ids in the target of the link. 2005-06-18: created The id of the ancestral element of objects referenced by 'from' attributes. Provides a context for uniquifying the references in the 'from' attributes. Thus atoms referenced by ids should be unique within a given molecule and the id of this could be the 'fromContext'. 2005-06-18: created The id of the ancestral element of objects referenced by 'to' attributes. Provides a context for uniquifying the references in the 'to' attributes. Thus atoms referenced by ids should be unique within a given molecule and the id of this could be the 'toContext'. 2005-06-18: created The role of the link. Xlink adds semantics through a URI; we shall not be this strict. We shall not normally use this mechanism and use dictionaries instead. The target of the (locator) link, outside the document. A generic container with no implied semantics. A generic container with no implied semantics. It just contains things and can have attributes which bind conventions to it. It could often act as the root element in an STM document. A container for links Usage is now standardized with map as the container and link as the individual links. The links are often effectively typed pointers to other parts of the document. The type can be set for all links by the 'fromType' and 'toType' attributes, either in the map, which then applied to all links by default, or in individual links, when it overrides the map setting. Since ids may not be unique within a document the refs can be given context with the 'fromRef' and 'toRef' attributes in the map element. If more than one context is used it may be better to use multiple maps. The role of map, and its relationship to RDF is still being developed. Currently (2005) map has primarily been used to map atoms between reactants and products, but we also expect shortly to extend it to peak assignments and several otherr areas. A map consists of a number of links, which can be directional, relating two elements through their ids. Reference is through the mandatory 'to' and 'from' attributes which must point to existing id attributes on elements. The type of the dereferenced element can be specified in 'toType' and 'fromType' which, while redundant, is an aid to software and acts as a check on referential type integrity. In principle any element can be linked to any other, with 1:1, 1:n, and n:m topology. We expect maps to be used for precise chemical concepts such as reactions, peak assignments, electron management, molecular superpositions, etc. and that these are supported by bespoke code. For other links, especially with complex topology, users should consider whether RDF may be more appropriate. In some cases partial mapping is known (e.g. one set of atoms maps to another set), but the precise links are unknown. (This is not the same as n:m mapping where n*m precise links would be expected). In some cases there may be objects such as atomSets or peakGroups which could be linked to support this. Alternatively the 'fromSet' and 'toSet' attributes can be used to hold a list of ids. Thus from='a1 a2' to='b3 b4' might imply that there were two precise links (either {a1=>b3, a2=>b4} or {a1=>b4, a2=>b3}). This is most likely to be used in intermediate documents where more precise semantics can be added later. The ids must all refer to elements of the same type. Note that a 'to' link referencing a single atomSet (toType='atomSet') is not the same as a 'toSet' of toType='atom' with multiple atomIds. The first would require an 'atomSet' element in the document; the second would not. The precise semantics such as the order of ids are application-dependent. If the order is known in both the toSet and fromSet then individual links should be used rather than adding the burden of deconstruction on the implementer. 2005-06-18: added typing and role and updated docs. 2006-08-05: added ref attribute. The type of the object/element in the 'from' attributes. Requires the objects referenced by the 'from' attributes to have a given elementType. Can be overridden by 'from' attributes in individual links. 2005-06-18: created The type of the object/element in the 'to' attributes. Requires the objects referenced by the 'to' attributes to have a given elementType. Can be overridden by 'to' attributes in individual links. 2005-06-18: created The id of the ancestral element of objects referenced by 'from' attributes. Provides a context for uniquifying the references in the 'from' attributes. Thus atoms referenced by ids should be unique within a given molecule and the id of this could be the 'fromContext'. 2005-06-18: created The id of the ancestral element of objects referenced by 'to' attributes. Provides a context for uniquifying the references in the 'to' attributes. Thus atoms referenced by ids should be unique within a given molecule and the id of this could be the 'toContext'. 2005-06-18: created The role of the map. Semantics are undefined, and can be used to provide a small semi-controlled vocabulary for identifying maps of different types. 2005-06-18: created A rectangular matrix of any quantities. By default matrix represents a rectangular matrix of any quantities representable as XSD or STMML dataTypes. It consists of rows*columns elements, where columns is the fasting moving index. Assuming the elements are counted from 1 they are ordered V[1,1],V[1,2],...V[1,columns],V[2,1],V[2,2],...V[2,columns], ...V[rows,1],V[rows,2],...V[rows,columns] By default whitespace is used to separate matrix elements; see array for details. There are NO characters or markup delimiting the end of rows; authors must be careful!. The columns and rows attributes have no default values; a row vector requires a rows attribute of 1. matrix also supports many types of square matrix, but at present we require all elements to be given, even if the matrix is symmetric, antisymmetric or banded diagonal. The matrixType attribute allows software to validate and process the type of matrix. The mechanism of a reaction. In some cases this may be a simple textual description or reference within a controlled vocabulary. In others it may describe the complete progress of the reaction, including topological or cartesian movement of atoms, bonds and electrons and annotation with varying quantities (e.g. energies). For named reaction mechanisms ("Diels-Alder", "ping-pong", "Claisen rearrangement", etc.) the name element should be used. For classification (e.g. "hydrolysis"), the label may be more appropriate. In more detailed cases the mechanism refers to components of the reaction element. Thus bond23 might be cleaved while bond19 is transformed (mapped) to bond99. The mechanismComponent can be used to refer to components and add annotation. This is still experimental. IUPAC Compendium of Chemical Terminology 2nd Edition (1997) describes a mechanism as: A detailed description of the process leading from the reactants to the products of a reaction, including a characterization as complete as possible of the composition, structure, energy and other properties of reaction intermediates, products and transition states. An acceptable mechanism of a specified reaction (and there may be a number of such alternative mechanisms not excluded by the evidence) must be consistent with the reaction stoichiometry, the rate law and with all other available experimental data, such as the stereochemical course of the reaction. Inferences concerning the electronic motions which dynamically interconvert successive species along the reaction path (as represented by curved arrows, for example) are often included in the description of a mechanism. It should be noted that for many reactions all this information is not available and the suggested mechanism is based on incomplete experimental data. It is not appropriate to use the term mechanism to describe a statement of the probable sequence in a set of stepwise reactions. That should be referred to as a reaction sequence, and not a mechanism. CMLReact provides reactionScheme and annotions to describe the reaction sequence and both it and mechanism could co-occur within a reactionScheme container. 2006-02-28 PMR: changed content model to choice. An information component within a reaction mechanism. Information components can represent both physical constituents of the reaction or abstract concepts (types of bond cleavage, thermodynamics, etc.). There are several ways that components of the reaction can be annotated and/or quantified. One approach will be to refer to specific bonds and atoms through their ids and use mechanismComponent to describe their role, properties, etc. Another is to use mechanismComponent to identify types of bond formed/broken without reference to actual atoms and bonds (initially through the name element). Yet another will be to include information on the reaction profile. This is still experimental. A general container for metadata. A general container for metadata, including at least Dublin Core (DC) and CML-specific metadata In its simple form each element provides a name and content in a similar fashion to the meta element in HTML. metadata may have simpleContent (i.e. a string for adding further information - this is not controlled). A general container for metadata elements. MetadataLists can have local roles (e.g. a bibliographic reference could be a single meteadatList with, say, 3-6 components). The role attribute is used in an uncontrolled manner for this. MetadataLists can also be nested, but metadata and metadataList children should not occur on the same level of the hierarchy. A module in a calculation. Many programs are based on discrete modules which produce chunks of output. There are also conceptual chunks such as initialisation, calculation and summary/final which often have finer submodules such as cycle, iteration, snapshot, etc. There is no controlled vocabulary but a typical structure is shown in the example. One of the challenges of CCML is to find communality between different programs and to use agreed abstractions for the modules. The module can have a program-specific name through its title or dictRef (e.g. "MINIM", "l201") and a generic role ("dynamicsCalculation", "equilibration", etc.). In general role will be controlled by CCML. A container for atoms, bonds and submolecules. molecule is a container for atoms, bonds and submolecules along with properties such as crystal and non-builtin properties. It should either contain molecule or *Array for atoms and bonds. A molecule can be empty (e.g. we just know its name, id, etc.) "Molecule" need not represent a chemically meaningful molecule. It can contain atoms with bonds (as in the solid-sate) and it could simply carry a name (e.g. "taxol") without formal representation of the structure. It can contain "sub molecules", which are often discrete subcomponents (e.g. guest-host). Molecule can contain a <list> element to contain data related to the molecule. Within this can be string/float/integer and other nested lists Normally molecule will not contain fragment or fragmentList Revised content model to allow any order of lengths, angles, torsions 2003-01-01.. Added role attribute 2003-03-19.. 2006-05-21. PMR changed content model to (A|B|C...)* 2006-11-24. PMR removed @tail, @head, @countExpression, @repeat The float|integer|string children are for compatibility with CML-1 and are deprecated. scalar|array|matrix should be used instead. No formal semantics (yet). The role describes the purpose of the molecule element at this stage in the information. Examples can be "conformation", "dynamicsStep", "vibration", "valenceBondIsomer", etc. This attribute may be used by applications to determine how to present a set of molecule elements. A container for one or more molecules. moleculeList can contain several molecules. These may be related in many ways and there is are controlled semantics. However it should not be used for a molecule consisting of descendant molecules for which molecule should be used. A moleculeList can contain nested moleculeLists. 2006-07-20: PMR Added metadataList contains metadata. list is for experimental and other data. moleculeList normally contains molecules but we make provision for nested moleculeLists if required. The molecules can be a set of reference molecules which occur in the molecules and can be referenced. This makes the molecules more readable and normalizes data when molecules are used more than once. A string identifying a object. name is used for chemical names (formal and trivial) for molecules and also for identifiers such as CAS registry and RTECS. It can also be used for labelling atoms. It should be used in preference to the title attribute because it is repeatable and can be linked to a dictionary. Constraining patterns can be described in the dictionary and used to validate names. An object which might occur in scientific data or narrative. Deliberately vague. Thus an instrument might be built from sub component objects, or a program could be composed of smaller modules (objects). object could be used to encapsulate graphical primitives (e.g. in reaction schemes, drawings of apparatus, etc.). Unrestricted content model. An observation or occurrence. A container for any events that need to be recorded, whether planned or not. They can include notes, measurements, conditions that may be referenced elsewhere, etc. There are no controlled semantics. An operator within an expression. Experimental. An operator acts on one or more arguments (at present the number is fixed by the type). The formulation is reverse Polish so the result (with its dataType) is put on a stack for further use. A parameter describing the computation. A parameter is a broad concept and can describe numeric quantities, objects, keywords, etc. The distinction between keywords and parameters is often fuzzy. ("MINIM" might mean "minimize", while "MINIM=3" might require three iterations to be run. It may help to think of control keywords as boolean parameters. Numeric parameters can describe values in molecules, forcefields or other objects. Often the parameters will be refined or otherwise varied during the calculation. Some parameters may be fixed at particular values or relaxed at different stages in the calculation. Parameters can have errors, gradients and other indications of uncertainty. String/character parameters are often abbreviated in program input, and this is supported through the regex and ignoreCase attributes. ????? Parameters will usually be defined separately from the objects and use the ref attribute to reference them. Parameters can be used to describe additional constraints. This will probably require the development of a microlanguage and until then may use program-specific mechanisms. A common approach will be to use an array of values (or objects) to represent different input values for (parts of) the calculation. Thus a conformational change could be specified by an array of several torsion angles. A parameter will frequently have a dictRef pointing to a dictionary which may have more information about how the parameter is to be used or the values it can take. The allowable content of parameters may be shown by a "template" in the appinfo; this is stil experimental. This is a shorthand for a single scalar value of the parameter. It should only be used with the ref attribute as it inherits all the dataTyping of the referenced element. It must not be used for defining new parameters as it has no mechanism for units and dataTyping. [This may change?]. Used to define concepts such as independent and dependent variables A container for one or more parameters. parameterList can contain several parameters. 2006-02-16:PMR. Added parameterList as child An object in space carrying a set of properties. particles have many of the characteristics of atoms but without an atomic nucleus. It does not have an elementType and cannot be involved in bonding, etc. It has coordinates, may carry charge and might have a mass. It represents some aspect of a computational model and should not be used for purely geometrical concepts such as centroid. Examples of particles are "shells" (e.g. in GULP) which are linked to atoms for modelling polarizability or lonepairs and approximations to multipoles. Properties such as charge, mass should be scalar/array/matrix children. Used in a similar manner to atomType. Examples might be "lonePair", "polarizable Oxygen", etc. A peak; annotated by human or machine. A peak can describe: A single point in a spectrum. Usually a maximum but could be a shoulder, inflexion or indeed any point of interest. A continuous range of values within a spectrum, defined by maximum and minimum values on either/both axes The finer structure of the peak can be given with one or more peakStructure children The units should always be given. (The raw spectral data may unfortunately use different units and no assumptions should be made). The content model includes atom, bond, molecule, but these are deprecated and should be replaced by atomRefs, etc. 2005-11-22: PMR. Added moleculeRefs Allows inter alia the provenance of the peak assignment to be recorde. 2005-11-9. DEPRECATED; use atomRefs 2005-11-9. DEPRECATED; use bondRefs 2005-11-9. DEPRECATED; use moleculeRefs when developed 2005-11-9. PMR, added Atoms contributing to this peak The primary set of atoms responsible for the peak such as an NMR peak. Coupling constants and similar splitting should not use this but peakStructure. At present there is no substructure to this attribute or concept and only one attribute is allowed. It may be combined with bondRefs. Even single atoms should use atomRefs, not atomRef. Bonds contributing to this peak The primary set of bonds responsible for the peak such as an IR frequency. At present there is no substructure to this attribute or concept and only one attribute is allowed. It may be combined with atomRefs. Molecule(s) contributing to this peak The molecule or molecule responsible for the peak. At present there is no substructure to this attribute or concept and only one attribute is allowed. This might, for example, be used to manage a mass spectrum or chromatogram A list of closely related peaks or peakGroups. Distinguish between peakList (primarily a navigational container) and peakGroup where the peaks (or groups) have some close relation not shared by all peaks. All descendants must use consistent units. 2005-11-22. added atomRefs, bondRefs and moleculeRefs and deprecated atom, bond, molecule children Allows inter alia the provenance of the peak assignment to be recorde. 2005-11-22. DEPRECATED; use atomRefs 2005-11-22. DEPRECATED; use bondRefs 2005-11-22. DEPRECATED; use moleculeRefs Atoms contributing to this peak The primary set of atoms responsible for the peak such as an NMR peak. Coupling constants and similar splitting should not use this but peakStructure. At present there is no substructure to this attribute or concept and only one attribute is allowed. It may be combined with bondRefs. Even single atoms should use atomRefs, not atomRef. Bonds contributing to this peak The primary set of bonds responsible for the peak such as an IR frequency. At present there is no substructure to this attribute or concept and only one attribute is allowed. It may be combined with atomRefs. Molecule(s) contributing to this peak The molecule or molecule responsible for the peak. At present there is no substructure to this attribute or concept and only one attribute is allowed. This might, for example, be used to manage a mass spectrum or chromatogram A list of peaks or peakGroups. Distinguish between peakList (primarily a navigational container) and peakGroup where the peaks (or groups) have some close relation not shared by all peaks. All peaks and peakGroups should use the same units. Allows inter alia the provenance of the peak assignment to be recorde. The structure of a peak. Primarily to record couplings and other fine structure. At present we have tested this on HNMR spectra, C13 NMR and simple IR. We believe that other types of spectroscopy (ESR, NQR, etc) can be represented to some extent, but there may be systems beyond the current expressive power. For molecules without symmetry we believe that most of the important types of NMR coupling can be represented. Thus an atom which gives rise to two couplings can have two child PeakStructures, and this is shown in example1. <cml xmlns="http://www.xml-cml.org/schema"> <!-- Ha ... Hb ... Hc1, Hc2 --> <molecule id="m1"> <atomArray> <atom id="a1" elementType="H"> <label value="Ha"/> </atom> <atom id="a2" elementType="H"> <label value="Hb"/> </atom> <atom id="a3" elementType="H"> <label value="Hc1"/> </atom> <atom id="a4" elementType="H"> <label value="Hc2"/> </atom> </atomArray> </molecule> <spectrum id="spectrum2" title="test peaks"> <peakList> <peak id="p1" title="Ha" atomRefs="a1" peakShape="sharp" xUnits="unit:ppm" xValue="6.0"> <peakStructure type="coupling" peakMultiplicity="doublet11" value="12" units="unit:hertz" atomRefs="a2"/> </peak> <peak id="p2" title="Hb" atomRefs="a2" peakShape="sharp" xUnits="unit:ppm" xValue="7.0"> <peakStructure type="coupling" peakMultiplicity="doublet11" value="12" units="unit:hertz" atomRefs="a1"/> <peakStructure type="coupling" peakMultiplicity="triplet121" value="15" units="unit:hertz" atomRefs="a3 a4"/> </peak> <peak id="p3" title="Hc" atomRefs="a3 a4" peakShape="sharp" xUnits="unit:ppm" xValue="8.0"> <peakStructure type="coupling" peakMultiplicity="doublet11" value="15" units="unit:hertz" atomRefs="a2"/> </peak> </peakList> </spectrum> </cml> Where a peak is due to symmetry-related atoms there are different couplings to symmetrical atoms. Thus in an AA'BB' system there can be two couplings to the A atoms and we need nested peakStructures to represent these. In this case the order of the atoms in the peak@atomRefs maps to the order of the grandchildren. See example2. <!-- AA'BB' where there are 2 Ha and 2 Hb with two couplings J1 Ha ... Hb and Ha' ... Hb' J2 Ha ... Hb' and Ha' ... Hb --> <molecule id="m1"> <atomArray> <atom id="a1" elementType="H"> <label value="Ha"/> </atom> <atom id="a2" elementType="H"> <label value="Ha'"/> </atom> <atom id="a3" elementType="H"> <label value="Hb"/> </atom> <atom id="a4" elementType="H"> <label value="Hb'"/> </atom> </atomArray> </molecule> <spectrum id="spectrum2" title="test peaks"> <peakList> <!-- the ORDER of a1 and a2 is linked to the ORDER of the grandchildren elements, i.e. a1 couples to atoms in ps11 and ps21 while a2 relates to atoms is ps21 and ps22 --> <peak id="p1" title="Ha" atomRefs="a1, a2" peakShape="sharp" xUnits="unit:ppm" xValue="6.0"> <peakStructure id="ps1" type="coupling" peakMultiplicity="doublet" value="10" units="unit:hertz"> <peakStructure id="ps11" atomRefs="a3"/> <peakStructure id="ps12" atomRefs="a4"/> </peakStructure> <peakStructure id="ps2" type="coupling" peakMultiplicity="doublet" value="2" units="unit:hertz"> <peakStructure id="ps21" atomRefs="a4"/> <peakStructure id="ps22" atomRefs="a3"/> </peakStructure> </peak> </peakList> </spectrum> </cml> Allows inter alia the provenance of the peakStructure assignment to be recorded. Allows identification of couplings in symmetric systems. May also be usable for other complicated systems. The atoms to which the peakStructure refers. Allows identification of the atoms to which the peak is coupled (not the atoms contributing to the primnary reference for which peak should be used). It may be combined with bondRefs. Even single atoms should use atomRefs, not atomRef. Bonds contributing to this peakStructure Even a single bond should use bondRefs, not bondRef A plane in 3-space. An oriented plane of indefinite extent. A point in 3-space. An explicit potential. This represents the actual function for the potential (i.e. with explicit values) rather than the functional form, which will normally be referenced from this. The functional form of a potential. This has generic arguments and parameters rather than explicit ones. It is essentially a mathematical function, expressed currently in reverse Polish notation. A container for explicit potentials. Experimental. A product within a productList. product describes a product species which is produced in a reaction. See reactant for discussion of catalysis and solvents. A product will normally be identified by name(s), formula, or molecule and at least one of these should normally be given. Amount(s) of product can be given after this identification and can describe mass, volume, percent yield, etc. but not stoichiometry A container for one or more products. productList can contain several products. These may be related in several ways, including single list of products grouping of products of parallel reactions . A productList can contain nested productLists. The semantics of this are currently undefined. The number of copies of the productList involved in the stoichiometric reaction. Probably not useful for simple reactions but could be used for parallel reactions. A container for a property. property can contain one or more children, usually scalar, array or matrix. The dictRef attribute is required, even if there is a single scalar child with the same dictRef. The property may have a different dictRef from the child, thus providing an extension mechanism. Properties may have a state attribute to distinguish the state of matter Semantics are not yet controlled but could include thermochemistry, kinetics or other common properties. A container for one or more properties. propertyList can contain several properties. These include (but are not limited to) observations, or numeric quantities. A reactant within a reactantList. reactant describes a reactant species which takes part in a reaction. Catalysts and supports are not normally classified as reactants, but this is subjective. Enzymes (or parts of enzymes) may well be reactants, as could be substances which underwent chemical change but were restored to their original state. reactant is a powerful concept as it can support stoichiometry (atom and molecule counting), mapping (for mechanisms), etc. Solvents are best contained within substanceList. A reactant will normally be identified by name(s), formula, or molecule and at least one of these should normally be given. Amount(s) of reactant can be given after this identification and can describe mass, volume, etc. but not stoichiometr. The role of the reactant within a reactantList. Semantics are not yet controlled but could be limiting, oxidant, etc. TODO: a reactant might have multiple roles so this may have to become an element. The number of copies of the reactant involved in the stoichiometric reaction. Could be non-integer but should not be used for actual ratios of materials added (for which amount should be used). A container for one or more reactants. reactantList can contain several reactants. These may be related in several ways, including lists of related reactants reactant schemes multi-step reactants parallel and/or coupled reactants . A reactantList can contain nested reactantLists. The semantics of this are currently undefined. A chemical reaction or reaction step. reaction is a container for reactants, products, conditions, properties and possibly other information relating to the reaction, often within a reactionList. Partial semantics exist: name the name(s) of the reaction reactantList (normally only one) the grouped reactants spectatorList substances with well-defined chemistry which are involved in the reaction but do not change. Examples are side groups in proteins, cofactors, etc. The division between specattor and substance is subjective. substance or substanceList substances present in the reaction but not classified as reactants. Examples might be enzymes, catalysts, solvents, supports, workup, etc. condition conditions of the reaction. These may be text strings, but ideally will have clearer semantics such as scalars for temperature, etc. productList the grouped products. This allows for parallel reactions or other semantics. property properties (often physical) associated with the reaction. Examples might be heat of formation, kinetics or equilibrium constant. Reaction normally refers to an overall reaction or a step within a reactionList. For a complex "reaction", such as in enzymes or chain reactions, it may be best to use reactionScheme to hold the overall reaction and a reactionList of the individual reaction steps. The semantics of the content model are metadataList for general metadata label for classifying or describing the reaction (e.g. "hydrolysis") identifier for unique identification. This could be a classification such as EC (enzyme commission) or an IChI-like string generated from the components. these are followed by the possible components of the reaction and/or a reactionList of further details. . This allows any objects to be attached to the reaction, but particularly graphical primitives such as lines, arrows, etc. These should be provided as elements where possible (e.g. SVG) and should have references to the chemical objects they interact with (i.e. not simply relying on geometry). Markers with IDs can be included as part of the graphics object and their ids linked to the chemical elements using link. The yield of the reaction. Note that this lies in the range 0-1. A container for one or more reactions or reactionSchemes with no interrelations. A reactionList aggregates reactions and reactionSchemes but implies no semantics. The most common uses are to create small collections of reactions (e.g. databases or publications). A container for two or more related reactions and their relationships. Where reactions are closely related (and often formally dependent on each other) they should be contained within the reactionStepList of a reactionScheme. The semantics which have informed this design include: Steps within an organic synthesis. Two or more individual (primitive) steps provding the detailed mechanism for an overall reaction. Coupled or sequential reactions within biochemical pathways. This design is general because "reaction" is used in several ways. A biochemical pathway (e.g. oxidation of glucose to CO2 and water) involves many coupled enzyme reactions proceeding both in parallel and in sequence. Each of these steps ("reactions" in their own right) is itself complex and can include several mechanistics steps which are themselves reactions with products, reactants, etc. reactionScheme can therefore include reactionStepLists (with more reactionScheme children) which provide a more detailed view of the individual components. Where a set of reactions are primitives... The semantics of the content model are metadataList for general metadata label for classifying or describing the reaction (e.g. "hydrolysis") identifier for unique identification. This could be a classification such as EC (enzyme commission) or an IChI-like string generated from the components. these are followed by the possible components of the reaction and/or a reactionList of further details. A child of reactionStepList and a container for reaction or reactionScheme. reactionStep is always contained within reactionStepList and is designed to manage "sub-reactions" which have close relationships. These will often involve reactions which, taken together, describe a higher level reaction or reaction type. Examples are: biochemical pathways synthetic reaction schemes multi-step reactions parallel and/or coupled reactions . A reactionStep normally contains a single reaction or reactionScheme. It can have attributes such as yield and ratio which can be used by the parent reactionStepList. The name applies to the overall schema of reactions. label is for additional textual information and classification. reactionStepList normally contains reactions but we make provision for nested reactionSchemes if required. The yield of the reactionStep. Note that this lies in the range 0-1. The ratio of this step to one or more sibling steps. Note that this lies in the range 0-1. It is meaningless to use this unless there are siblings, in which case it refers to the relative molar fluxes through each. The "percentage yields" will need to be transformed to this range. There is no requirement that the sum of fluxes through a group of siblings sum to 1.0, though they should not sum to more. A container for one or more related reactionSteps. reactionStepList is always contained within reactionScheme and is designed to manage "sub-reactions" which have close relationships. These will often involve reactions which, taken together, describe a higher level reaction or reaction type. Examples are: biochemical pathways synthetic reaction schemes multi-step reactions parallel and/or coupled reactions . A reactionStepList contains reactionSteps (each of which contains reactions and/or reactionSchemes (e.g. where part of the process is known in greater detail)). It may not directly contain child reactionStepLists. The child reactionSteps can have attributes such as yield and ratio which describe the relationship of the component steps. Guidance on use: reactionScheme describes a complex of reactions with metadata, one (or more) overall reactions and a reactionStepList with the overall component reactions. reactionStepList aggregates and structures the individual subreactions. reactionList is a container for reactions and reactionSchemes with no semantics (e.g. a book or database of selected reactions). The name applies to the overall schema of reactions. label is for additional textual information and classification. reactionStepList normally contains reactionSteps. The reactiveCentre in a reaction. This describes the set(s) of bonds and atoms involved in the reaction. The semantics are flexible, but a common usage would be to create atomSet(s) and bondSet(s) mapping to groups which undergo changes. A region of the system. Under development. A subdivision of the system to which special protocols or properties may be attached. Typical regions could be defined by the presence of atoms belonging to an atomSet or geometrical boundaries. A region element will not always contain other elements, but may have references from other elements. It may create a protocol, e.g. atoms within a region might be replaced by a continuum model or be subject to a field. Semantics yet to be determined. Regions can be created by the unions of two or more regions. This allows a region to be built from a series of (say) spheres or boxes filling space. An entry related in some way to a dictionary entry. The range of relationships is not restricted but should include parents, aggregation, seeAlso and so on. DataCategories from ISO12620 can be referenced through the namespaced mechanism. The related entry. An analytical or spectral sample. The sample should contain information on what things were in the sample and their roles. It can include molecule, substance and substanceList. Typical rolos include solvent, mulling agents, salt disks, molecular supports, etc. but should not cover apparatus or conditions. A molecular description. A substance in the sample. A list of substances in the sample. An element to hold scalar data. scalar holds scalar data under a single generic container. The semantics are usually resolved by linking to a dictionary. scalar defaults to a scalar string but has attributes which affect the type. scalar does not necessarily reflect a physical object (for which object should be used). It may reflect a property of an object such as temperature, size, etc. Note that normal Schema validation tools cannot validate the data type of scalar (it is defined as string), but that a temporary schema can be constructed from the type and used for validation. Also the type can be contained in a dictionary and software could decide to retrieve this and use it for validation. Alternative to units Must be used in conjunction with unitType 2005-10-26: added Alternative to units Must be used in conjunction with unitType 2005-10-26: added Alternative to units Must be used in conjunction with multiplierToSI and/or constantToSI 2005-10-26: added A spectator object in a reaction. Objects are often present during a reaction which are not formally involved in bond breaking/formation and which are not modified during the reaction. They may be catalysts, but may also be objects which in some way constrain or help the reaction to take place (surfaces, micelles, groups in enzyme active sites, etc.). In some cases molecules present in a reaction mixture may act as spectators in steps in which they are not transformed. No controlled vocabulary. Examples could be 'host', 'hydrophobic ligand', 'charge-stabilizer', etc.. A container for spectators in a reaction. A spectrum and relevant data or metadata. The spectrum construct can hold metadataList, sample (which can contain molecule), conditionList (mainly for physical/chemical conditions, not instrumental), spectrumData for the actual data and instrumental settings/procedure and peakList for the assigned peaks. This approach puts the spectrum as the primary object of interest. It could also be possible to make spectrum a child of molecule (although a reference using ref might be preferable). A (complete) description of the thing to which the spectrum relates. May contain molecule or substanceList. Solvents, mulls, etc should be described here. The conditions relating to the spectrum (complementary to substanceList. A list of peaks. This may occur independently of the xaxis/yaxis data. The molecule to which the spectrum refers. Although this may also be contained in the sample element it is useful to state it here. No default. Data for the spectrum. This is primarily to record the data in interchangeable format and machine and manufacturers settings and can include other MLs in this area (AniML, SpectroML, etc.). We recommend ASCII representations of data and this is the only format that CMLSpect implementers have to support, but we also allow for the carriage of JCAMP and other data (in ML wrappers such as AniML). All numeric data should carry units and dictionary references if possible to allow for semantic interoperability. The x-axis/es, usually including the list of points at which data are recorded. Mandatory if y-axis data are given. Multiple x-axes are initially reserved for multiple scales rather than different measurements (for which an additional spectrum should be used). The y-axis/es, usually including the list of points at which data are recorded. Mandatory if x-axis data are given. Multiple y-axes are initially reserved for multiple scales rather than different measurements (for which an additional spectrum should be used). A container for one or more spectra. spectrumList can contain several spectra. These may be related in several ways, including lists of related spectra bundle of common analytical spectra (NMR, IR, UV...) repeat measurements . A spectrumList can contain nested spectrumLists. metadataList contains metadata. list is for experimental and other data. spectrumList normally contains spectrums but we make provision for nested spectrumLists if required. The molecules can be a set of reference molecules which occur in the spectrums and can be referenced. This makes the spectrums more readable and normalizes data when molecules are used more than once. A sphere in 3-space. An element to hold stmml data. stmml holds stmml data under a single generic container. Other namespaces may be present as children. No semantics implied. CML-1 dataType (DEPRECATED). CML-1 dataType DEPRECATED. A chemical substance. substance represents a chemical substance which is deliberately very general. It can represent things that may or may not be molecules, can and cannot be stored in bottles and may or may not be microscopic. Solutions and mixtures can be described by _substanceList_s of substances. The type attribute can be used to give qualitative information characterising the substance ("granular", "90%", etc.) and _role_ to describe the role in process ("desiccant", "support", etc.). There is currently no controlled vocabulary. Note that reaction is likely to have more precise semantics. The amount of a substance is controlled by the optional _amount_ child. Added property as a child 2002-12-29 role depends on context, and indicates some purpose associated with the substance. It might indicate 'catalyst', 'solvent', 'antoxidant', etc. but is not limited to any vocabulary. A list of chemical substances. Deliberately very general - see substance. substanceList is designed to manage solutions, mixtures, etc. and there is a small enumerated controlled vocabulary, but this can be extended through dictionaries. substanceList can have an amount child. This can indicate the amount of a solution or mixture; this example describes 100 ml of 0.1M NaOH(aq). Although apparently longwinded it is precise and fully machine-interpretable Added role attribute, 2003-03-12. Molecular, crystallographic or other symmetry. symmetry provides a label and/or symmetry operations for molecules or crystals. Point and spacegroups can be specified by strings, though these are not enumerated, because of variability in syntax (spaces, case-sensitivity, etc.), potential high symmetries (e.g. TMV disk is D17) and non-standard spacegroup settings. Provision is made for explicit symmetry operations through <matrix> child elements. By default the axes of symmetry are defined by the symbol - thus C2v requires z to be the unique axis, while P21/c requires b/y. Spacegroups imply the semantics defined in International Tables for Crystallography, (Int Union for Cryst., Munksgaard). Point groups are also defined therein. The element may also be used to give a label for the symmetry species (irreducible representation) such as "A1u" for a vibration or orbital. The matrices should be 3x3 for point group operators and 3x4 for spacegroup operators. The use of crystallographic notation ("x,1/2+y,-z") is not supported - this would be <matrix>1 0 0 0.0 0 1 0 0.5 0 0 1 0.0<matrix>. The default convention for point group symmetry is Schoenflies and for spacegroups is "H-M". Other conventions (e.g. "Hall") must be specfied through the convention attribute. This element implies that the Cartesians or fractional coordinates in a molecule are oriented appropriately. In some cases it may be useful to specify the symmetry of an arbitarily oriented molecule and the <molecule> element has the attribute symmetryOriented for this purpose. It may be better to use transform3 to hold the symmetry as they have fixed shape and have better defined mathematical operators. 2005-11-03 PMR. Added transform3 as children. The rotational symmetry number. Used for calculation of entropy, etc. The complete system of components in a calculation. There is no controlled vocabulary. A rectangular table of any quantities. By default table represents a rectangular table of any simple quantities representable as XSD or CML dataTypes. There are three layouts, columnwise, rowwise and without markup. In all cases it is essential that the columns, whether explicit or otherwise, are homogeneous within the column. Also the metadata for each column must be given explicitly.
  • columns: There is a single arrayList child containing (homogeneous) child elements ( array or listof size rows data. This is the "normal" orientation of data tables but the table display could be transposed by XSLT transformation if required. Access is to columns, and thence to the data within them. DataTyping, delimiters, etc are delegated to the arrays or lists, which must all be of the same size.
  • rows: with explicit trows. The metadata is carried in a theader element of size cols. Within each trow the data are contained in tcells
  • content: The metadata is carried in a theader element of size cols. data are contained in a single tableContent with columns moving fastest. Within the content the data are whitespace (or delimiter) separated.
For verification it is recommended that tables carry rows and columns attributes. The type of the tables should also be carried in a tableTypeattribute>
Validity contraints (XPath expression in table context) type @tableType @rows actual rowCount @columns actual columnCount tableHeader arrayList tableRowList tableContent column based columnBased recommended ./arrayList/@size or arrayList/*[self::array or self::list]/@size optional ./arrayList/@size or count(arrayList/*[self::array or self::list]) forbidden required forbidden forbidden row based rowBased recommended ./tableRowList/@size or count(tableRowList/tableRow) recommended count(tableHeader/tableHeaderCell) or count(tableRowList/tableRow/tableCell) required forbidden required forbidden content based contentBased required only by analysing tde table recommended count(tableHeader/tableHeaderCell) required forbidden forbidden required
A cell in a row of a table. tableCell is a data container of the table and only occurs as a child of tableRow. Normally it contains simpleContent, but may also contain a single child element (which could itself have complex or mixed content). However tableCell should NOT directly contain multiple children of any sort or mixed content. (It is declared as mixed content here to allow either text or element content, but not both.). The metadata for tableCells must be declared in a tableHeader/tableHeaderCell system Unmarked content of a table. This only occurs as simpleContent or a tableContent elements. It contains table/@rows * table/@columns items arranged rowwise (i.e. columns is fastest moving). Metadata for columns must be defined in tableHeader. The items of the table are ASCII strings. They can be separated by whitespace or by a defined single character delimiter as in array. The data must be rectangular and each implicit column must have consistent semantics. It can be used to hold CSV-like data (indeed CSV data can be directly entered as long as there are no quoted commas in which cas a different delimiter (or the safer tableRowList) should be used. Unlike tableRowList or arrayList (both of which can hold ASCII strings or XML elements, tableContent can only hold strings. Header for a table. Used for rowBased or contentBased tables when it is mandatory. Contains the metadata as tableHeaderCells which should match the (implicit) columns in number and semantic type. It is forbidden for arrayList tables as each array/list contains the metadata. Metadata for a column of a table. Only used when in rowBased or contentBased tables, and then as a direct child of tableHeader. There must be as many tableHeaderCells as there are implicit columns in tableRowList or tableContent. These cells carry the metadata and/or semantics for each column. These are similar to the attributes in array but without the lsist of minValue, errors etc. However they can (and should) carry all the units metadata. Alternative to units Must be used in conjunction with unitType 2005-10-26: added Alternative to units Must be used in conjunction with unitType 2005-10-26: added Alternative to units Must be used in conjunction with multiplierToSI and/or constantToSI 2005-10-26: added A row in a rowBased table. A direct child of tableRowList containing tableCells. At present all tableRows in a tableRowList must have the same count of tableCells and their semantics must correspond to the tableHeader in the table. No cells can be omitted and there is no spanning of cells. There is no need for a size attribute as the count is simply count(tableCell). List of rows in rowBased table. Metadata for rows must be defined in tableHeader. A torsion angle ("dihedral") between 4 distinct atoms. The atoms need not be formally bonded. It can be used for: Recording experimentally determined torsion angles (e.g. in a crystallographic paper). Providing the torsion component for internal coordinates (e.g. z-matrix). Note that the order of atoms is important. 2006-02-07: PMR. Fixed torsionAngleUnits A transform in 3-space. A 3-D transform. Conventionally a 4x4 matrix. The transition state in a reaction. This will normally contain a molecule which in its 2D representation will have partial bonds. These are yet to be formalized for the molecule element. Although spectators may stabilise or otherwise interact with the transitionState they are not contained within it. A propertyList is provided to capture transitionState properties. Still experimental. A scientific unit. A scientific unit. Units are of the following types: SI Units. These may be one of the seven fundamental types (e.g. meter) or may be derived (e.g. joule). An SI unit is identifiable because it has no parentSI attribute and will have a unitType attribute. 2005-122-17 - this may be obsolete; PMR nonSI Units. These will normally have a parent SI unit (e.g. calorie has joule as an SI parent). Constructed units. These use a syntax of the form: <unit id="g.s-1" name="gram per second" unitType="myUnitType:massPerTime"> <unit units="units:g" power="1"/> <unit units="siUnits:s" power="-1"/> </unit> This defines a new unit (g.s-1) which is composed from two existing units (units:g and siUnits:s) to create a new unit. The conversion to SI is computed from the two child units and may be added as a 'multiplierToSI' attribute. Only siUnits or units with 'multiplierToSI' can be used as child units; 'constantToSI cannot be used yet. If the new unit points to a unitType then the dimension can be checked. Thus if the published dimension of massPerTime does not agree with mass.length-1 an error is throwable. Alternatively a new unitType can be added as a child. The relationship of a unit to its SI parent is potentially complex and inconsistencies may arise. The following are available: parentSI. This points to the ID of a parent SI unit. If this ID is the same as the current unit the implication is that this is an SI unit. isSI. a boolean indicating whether the current unit is SI. multiplierToSI and constantToSI. If these are 1.0 and 0.0 (or missing) the implication is that this unit is SI. However this is fragile as units can be defined without these attributes and a unit could coincidentally have no numeric differences but not be an SI unit. 2003:04-09 Description or parentSI attribute enhanced. 2006:03-21 Added metadata and metadataList to content. Child unit used to build new unit. These children must have 'units' and 'power' attributes. Child unitType describing type of new unit. This can be added by the author (in which case they are responsible for checking consistency) or calculated by the software from the child units. Reference to a unit. This is used for the identification of child units when new units are composed from existing ones. Athough the syntax looks unusual it takes advantage of the tools for resolving units. See above for syntax. Abbreviation for the unit. This may be obsolete and symbol should be preferred. Symbol for the unit. This may be used for typographical display but NOT for identification as there is considerable variation in use. 2006-01-29: PMR. Added attribute. Power of unit used to create new one. Only allowed on child units A container for several unit entries. Usually forms the complete units dictionary (along with metadata). Note: this used to hold both units and unitTypes (though in separate files). This was unwieldy and unitTypeList has been created to hold unitTypes. Implementers are recommended to change any unitList/unitType to unitTypeList/unitType 2005-12-15. PMR. added namespace and dictionaryPrefix. 2005-12-17. PMR. added siNamespace . 2006-01-28. PMR. deprecated use for holding unitType. 2006-01-28: PMR. use unitTypeList. 2006-01-28: PMR. use unitTypeList. Maps dictRef prefix to the location of a dictionary. This requires the prefix and the physical URI address to be contained within the same file. We can anticipate that better mechanisms will arise - perhaps through XMLCatalogs. At least it works at present. The type of a scientific unit. Mandatory for SI Units, optional for nonSI units since they should be able to obtain this from their parent. For complex derived units without parents it may be useful. Used within a unitList Distinguish carefully from unitsType which is primarily used for attributes describing the units that elements carry 2006-02-06: PMR. Added preserve and symbol attributes. A container for several unitType entries. Usually forms the complete unitTypes dictionary (along with metadata). Note: unitTypes used to be held under unitList, but this was complicated to implement and unitTypeList makes a clean separation. 2006-01-28. PMR. created. Maps dictRef prefix to the location of a dictionary. This requires the prefix and the physical URI address to be contained within the same file. We can anticipate that better mechanisms will arise - perhaps through XMLCatalogs. At least it works at present. A vector in 3-space. The vector may have magnitude but is not rooted on any points (use line3). The x-axis. A container for all information relating to the x-axis (including scales, offsets, etc.) and the data themselves (in an array). Note: AniML uses "xValues" so avoid confusion with this. The x-data. These must match the y-data in number and order. There are tools to allow scaling and transformation (though unscaled data must be very carefully defined). The y-axis. A container for all information relating to the y-axis (including scales, offsets, etc.) and the data themselves (in an array). The y-data. These must match the x-data in number and order. There are tools to allow scaling and transformation (though unscaled data must be very carefully defined). A zMatrix. A container for length, angle and torsion, which must be arranged in the conventional zMatrix format. Abbreviation. Abbreviation for units, terms, etc. Describes whether child elements are sequential or parallel. There is no default. The type of an alternative. This adds semantics to an _alternative_ and might be used by an RDF or related engine. Restricts units to radians or degrees. An array of atom IDs. Normally an attribute of an array-based element. A reference to a map providing mappings between atoms The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking atoms. The topology of the linking is defined by the application - it could be overlay of molecular fragments, reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of atoms are of equal size and have 1:1 mapping between each id. This is another way of saying that the atoms mapped by a given ID are "the same atom". A reference to an atom. Used by bond, electron, etc. The first atoms in each bond. Currently only used in bondArray in CML2 array mode. The second atoms in each bond. Only used in bondArray in CML2 array mode. An array of references to atoms. Typical use would be to atoms defining a plane. A reference to a list of atoms. Used by bonds, electrons, atomSets, etc. References to two different atoms. Available for any reference to atoms but normally will be the normal reference attribute on the bond element. The order of atoms is preserved and may matter for some conventions (e.g. wedge/hatch or donor bonds. A list of three references to atoms. Typically used for defining angles, but could also be used to define a three-centre bond. 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. An atomSet describing the region. Any point falling within atomOffset of any atom in the set lies within the region. This means the region could consist of disjoint fragments. The IDs for an array of bond. Required in CML2 array mode. A reference to a map providing mappings between bonds The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking bonds. The topology of the linking is defined by the application - it could be overlay of molecular fragments, reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of bonds are of equal size and have 1:1 mapping between each id. This is another way of saying that the bonds mapped by a given ID are "the same bond". A reference to a bond. used by electron, etc. A reference to a list of bonds. Used by electrons, bondSets, etc. A parallelipiped box. By default the box uses isometric Cartesians axes but can also be linked to lattice Vector. Any point falling within the box or on a boundary is within the regio. builtin children. CML1-only - now deprecated. Error array for cellParameter 3 numbers giving error limits on paremters. The type of a cellParameter. length or angle The chirality of a system or molecule. This is being actively investigated by a IUPAC committee (2002) so the convention is likely to change. No formal default. Number of columns. A concise formula. The string represents an (unstructured) formula i.e. no submolecules. Recommended to use the format "H 2 O 1", etc. The constant to add to the raw data. add *after* applying any multiplier. 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. Constraint on a parameter. Semantics not yet finalised. We anticipate "fixed", "none" and symbolic relationships to other parameters. content of metadata. 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. The value of an element with a _convention_. When convention is used this attribute must be present and element content must be empty. 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. Array of object counts. No fixed semantics or default, normally integral. It is presumed that the element can be multiplied by the count value. General formula for the repeat count of the element. Experimental. No fixed semantics or default. The cyclic nature of a bond. This is an assertion by a human or program about the cyclic nature of a bond. It need not correspond to what is deducible from the connection table (e.g. a bond in a ring might be labelled as 'acyclic' or 'unknown') The data type of the object. Normally applied to scalar/array objects but may extend to more complex one. default value in an enumeration. A non-whitespace string (value is irrelevant) indicates that the content of this enumeration is the default value (usually of a scalar). It is an error to have more than one default. If the scalar in an instance document has no value (i.e. is empty or contains only whitespace) its value is given by the default. If the scalar in the instance is empty and no enumerations have a default attribute, an application may throw an error. 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. 2006-05-21: PMR added attribute. A delimiter character for arrays and matrices. By default array components ('elements' in the non-XML sense) are whitespace-separated. This fails for components with embedded whitespace or missing completely: Example: In the protein database ' CA' and 'CA' are different atom types, and and array could be: <array delimiter="/" dictRef="pdb:atomTypes">/ N/ CA/CA/ N/</array> Note that the array starts and ends with the delimiter, which must be chosen to avoid accidental use. There is currently no syntax for escaping delimiters. The namespacePrefix for a data item. The dictionaryPrefix is associated with elements such as dictionaries and units and allows them to be referenced namespaces. The dictionaryPrefix is normally unbound but it may be necessary to hardcode them occasionally. Thus if a value is fixed (e.g. "xsd:double") the prefix must be identified and fixed. A reference to a dictionary entry. Elements in data instances such as _scalar_ may have a dictRef attribute to point to an entry in a dictionary. To avoid excessive use of (mutable) filenames and URIs we recommend a namespace prefix, mapped to a namespace URI in the normal manner. In this case, of course, the namespace URI must point to a real XML document containing _entry_ elements and validated against STMML Schema. Where there is concern about the dictionary becoming separated from the document the dictionary entries can be physically included as part of the data instance and the normal XPointer addressing mechanism can be used. This attribute can also be used on _dictionary_ elements to define the namespace prefix Dimensionality of a coordinate system. Note that this means that coordinates of higher dimensionality are ignored or an error is flagged. Thus z3 and dimensionality='2' are incompatible. At present higher dimensionalities than 3 (cf. Wondratschek) are not supported. The labelling of the axes id not controlled. ?? should we have an explicit attribute for labelling convention?. The basis of the dimension. Normally taken from the seven SI types but possibly expandable. The duration of the action. Semantics undefined. The orientation of the eigenvector matrix. Describes whether the vectors are columns or rows. No default, so effectively mandatory unless you want to make implementers guess and break applications. A reference to a map providing mappings between electrons The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking electrons. The topology of the linking is defined by the application - it could be reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of electrons are of equal size and have 1:1 mapping between each id. This is another way of saying that the electrons mapped by a given ID are "the same electron". The identity of a chemical element. Normally mandatory on _atom_, _isotope_, etc. The identity of a chemical element. Normally mandatory on _atom_, _isotope_, etc. The end value. The end value in any allowable XSD representation of data. 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. Basis of the error estimate. Value of the error. Reports the author's estimate of the error in a scalar value. Only meaningful for dataTypes mapping to real number. 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. 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 2006-05-21: PMR added attribute. Information identifying the name of a file or other resource. This allows an element (such as cml) to carry limited information about provenance such as the name of the document used to provide the content. It is not a complete solution but can help to protect a document becoming separated from its external metadata. It is restricted to the basic XML character set (printable ANSI) and whitespace (which should anyway be discouraged) is normalized to single space (attribute values cannot carry newlines). Quotation marks and other horrors (as used in some OS) should be avoided. A reference to a functional form. Currently used for potential. 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. 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. Format of a spectrum. The data structure of the spectrum. (Not the format of the data). This describes how the data structure is to be interpreted. Simple chemical formula. This attribute should only be used for simple formulae (i.e. without brackets or other nesting for which a _formula_ child element should be used. The attribute might be used as a check on the child elements or for ease of representation. Essentially the same as _concise_ attribute on _formula. Number of digits after the point. This is used in dictionaries to define precision. However it might be replaced by xsd:facet. The base of one or more links. On link elements the value is the single id of an element within the document or context specified in map@fromRef attributes. It must identify the element uniquely. The reserved value 'null' implies that no mapping has been provided for the object(s) in the 'to' attribute. This implies no semantics but may be used by software to keep count of which elements have been mapped. For multiple targets use 'fromSet'. 2005-06-18: updated docs The context for the 'from' links in a map. A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. 2005-06-18: created A set of ids representing the base of a link. For a partial mapping where a number of 'from' elements are known to link to a number of 'to' elements it can be useful to aggregate these into a single attribute value. The primary use is to assert that n links exist between a set of n 'from' elements and n 'to' elements but that the precise links are unknown. The semantics of the reference are the same as for 'from' and all the elements must be of the same type (which can be specified with 'fromType' either on the link or the containing map). No order information is implied. In general there will be the same number of idRefs in the 'toSet' and all implicit links will share the same attributes (e.g. 'role'). In many cases the sets will be later split into discrete links thorugh further calculation or experiment (e.g. peak assignment). Sets should never be used as a lazy or concise alternative where the all the links are explicitly known. 2005-06-18: created The type of the base of a link. The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. 2005-06-18: created Domain of an FT spectrum. Indicates whether a spectrum is raw FID or has been transforme. address of a resource. Links to another element in the same or other file. For dictionary/@dictRef requires the prefix and the physical URI address to be contained within the same file. We can anticipate that better mechanisms will arise - perhaps through XMLCatalogs. At least it works at present. 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. 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. A unique ID for an element. Id is used for machine identification of elements and in general should not have application semantics. It is similar to the XML ID type as containing only alphanumerics, '_', ',' and '-' and and must start with an alphabetic character. Ids are case sensitive. Ids should be unique within local scope, thus all atoms within a molecule should have unique ids, but separated molecules within a document (such as a published article) might have identical ids. Software should be able to search local scope (e.g. all atoms within a molecule). However this is under constant review. Allows a referring element to generate a unique id. idgen can hold a unique identifier which is copied into the id attribute of the referenced element. This avoids multiple copies of the referenced object with duplicate ids. EXPERIMENTAL 2006-05-22: PMR added. Inheritance mechanism. A reference to an existing element can be used to supplement values such as coordinates. The inheritance attribute determines whether the values are supplemented, overwritten or deleted. In the example: <molecule id="m1" view="initial"> <atomArray> <atom id="a1" x3="0.1"/> </atomArray> </molecule> <!-- this adds more information --> <molecule ref="m1" view="initial" inherit="supplement"> <atomArray> <atom id="a1" hydrogenCount="1"/> </atomArray> </molecule> <!-- this will overwrite the previous values --> <molecule ref="m1" inherit="overwrite" view="final" id="m2"> <atomArray> <atom id="a1" x3="0.1"/> </atomArray> </molecule> <!-- this will delete the previous values --> <molecule ref="m1" inherit="delete" view="restart"> <atomArray> <atom id="a1" hydrogenCount=""/> </atomArray> </molecule> The first molecule/@ref adds complementary information, the second changes the values. Software is allowed to generate two independent copies of the molecule and reference them by different IDs ( m1 and m2). This mechanism is necessary to manage the implied inheritance of partial information during minimisations and dynamics. It requires careful software implementation. An inline representation of the object. This can represent a wide range of information from formal serialization as ASCII through to domain-specific textual representations. It will often be used in conjunction with the "convention" attribute. For example it could be used to represent IUPAC formula, SMILES strings, TeX equations, etc. Characters should conforma to the XML character set, and XML markup (lt and amp) should be escaped. IT SHOULD NEVER BE USED FOR INLINE XML Area under a peak. Unfortunately units are usually arbitrary and not related to the x- and y- axis units, and in this case _peakUnits_ should be use. A symmetry species. No fixed semantics, though we may provide a controlled-extensible list in the future. The isotope for an element. A real number describing the isotope. Probably obsolet. 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.. 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). Reference to a fuller description of the isotope. The description may be found in an external collection (e.g. IUPAC) or within the current document. indicates whether a unit is an SI or derived SI unit. required on SI unit elements with value 'true'. Optional on other units with attribute 'false'. A unitList should contain either SI units or non-SI units but not both. The k vector. The k-vector with 3 components. A reference to a kpoint. Used by band, etc. 2006-01-21: PMR. Created The secondary quantum number. takes values 0, 1, etc. A label. The semantics of label are not defined in the schema but are normally commonly used standard or semi-standard text strings. This attribute has the the same semantics as the more common _label_ element. The primitivity of a lattice. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency between spacegroups, symmetry operators, etc. Length of an array or . Probably will be replaced with xsd:schema tool. The type of the link. A list of values. Normally for iterations. 2006-06-09: PMR Created.. symbolic represention of l amd m. takes avlues of s, p, px, dxy, dx2y2, f, etc. The azimuthal quantum number. takes values -1, 0, 1, etc. An attribute providing a mandatory unique ID for an element. This is a horrible hack. It should be possible to add 'required' to the attributeGroup where used... (Maybe it is and I am still fighting Schema Wars. Type of matrix. Mainly square, but extensible through the _xsd:union_ mechanis. Maximum value allowed for an element or attribute. maximum exclusive value. by analogy with xsd:schema. minimum inclusive value. by analogy with xsd:schem. maximum length of a scalar. by analogy with xsd:schem. Maximum values for numeric _matrix_ or _array. A whitespace-separated list of the same length as the array in the parent element. Type of spectral measurement. The nature of the measured data. This is not an exhaustive list and should only be used if it affects the storage or immediate processing. The metadata type. This is likely to be the Dublin Core name or something similar. The use of "type" is an infelicitous misnomer and we shall try to remove it. The minimum value allowed for an element or attribute. minimum exclusive value. by analogy with xsd:schema. minimum inclusive value. by analogy with xsd:schema. minimum length of a scalar. by analogy with xsd:schema. Minimum values for numeric _matrix_ or _array. A whitespace-separated lists of the same length as the array in the parent element. A reference to a molecule. Used by spectrum, etc. A reference to one or more molecules. Uses the id attribute as the target identification. The order of molecules is preserved. It is not necessarily an error to have repeated references to the same molecule 2005-11-22: PMR. added this attribute. References to two different molecules. Available for any reference to molecules but normally will be the normal reference attribute on the join element. The order of molecules is preserved and may matter. 2006-11-24: PMR created The scale by which to multiply raw data or a unit. The scale is applied *before* adding any constant. The attribute may be found on a data item (scalar, array, matrix, etc.) or a user-defined unit. 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. The principal quantum number. Takes values 1, 2, 3, etc. 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. The namespace for a data item. The namespace is associated with elements such as dictionaries and units and allows them to be referenced through free namespace prefixes. A number determined by context Used for isotope number in isotope, and rotational symmetry number in symmetry for calculation of entropy, etc. 2003-03-30: added number attribut. The class of an object. The type of this information. This is not controlled, but examples might include: label summary note usage qualifier It might be used to control display or XSL filtering. The attribute is named 'objectClass' to avoid clashes with other class attributes and inappropriate conversion to foo.getClass(). 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. Array of occupancies. Normally only found in crystallography. Defaults to 1.0. The occupancy is required to calculate the molecular formula from the atoms. The order of the bond. There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. The order of the bond. There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. parameter name passed to an element This is still experimental. 2006-06-09: PMR added attribute. raplaces attribute on parent This is still experimental. Creates, overwriting if necessary, an attribute on parent. Example: <foo> <arg parentAttribute="bar">zubbo</arg> will create an attribute bar="zubbo" on <foo> 2006-06-09: PMR added attribute. A dictRef-like reference to the id of the parent SI unit. This parent should occur in this or another dictionary and be accessible through the dictRef mechanism. This attribute is forbidden for SI Units themselves. The mechanism holds for base SI units (7) and all compound (derived) units made by combinations of base Units. Pattern constraint. Based on xsd:schema. Height of a peak. For 1-dimensional data (e.g. y vs x) hould use the same units as the appropriate axis (e.g. y). Multiplicity of a peak. Uses a semi-controlled vocabulary. Shape of a peak. Semi-controlled vocabulary such as broad or sharp. Type of this structure. Semi-controlled vocabulary such as coupling or splitting. Units for a peak or peak integral. For 2-dimensional spectra the units represent the observation. For an integral they are usually arbitrary and not related to the x- and y- axis units. Thus NMR spectra may use hydrogen count as the units for the peak area. Is the axis periodic. Any or all of the axes may be periodic or aperiodic. An example could be a surface where 2 periodic axes (not necessarily orthogonal) are used to describe the coordinates in the surface, perhaps representing lattice vectors of a 3D crystal or 2D layer. The third vector is orthogonal and represents coordinates normal to the surface. In this case only the direction, not the magnitude of the vector is important. Periodicity of the system. This represents the number of dimensions (or coordinate axes) along periodic behaviour occurs and can be supported by symmetry operators or other transformations. Periodicity must never exceed dimensionality. A point in 3 dimensions. can be used for any complex geometrical object, such as line. A point group. No fixed semantics, though Schoenflies is recommended over Hermann-Mauguin. We may provide a controlled-extensible list in the future. 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. The power to which a dimension should be raised. Normally an integer. Must be included, even if unity. The power to which a dimension should be raised. Normally an integer. Must be included, even if unity. Is the dimension preserved during algebra. Experimental. The idea is to support concepts like volume/volume where algebraically these cancel out. preserve="yes" is intending to support preservation during derivation of new unitTypes. Keyword signifying how object is to be processed. Semantics depend on the parent element 2006-05-20: PMR added A ratio in the range 0 to 1. Currently used for ratios between brached reactions but re-usable for other concepts. Format of the reaction component. Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. Role of the reaction. The sequence of steps in a reactionStepList. By default the reactions in a reactionStepList are assumed to take place in sequence (e.g. one or more products of reaction n are used in reaction n+1 or later. However there are cases where it is known that reactions take place in parallel (e.g. if there is no overlap of molecular identities). Alternatively there are points at which there are two or more competing reactions which may depend on conditions or concentrations. A small semi-controlled vocabulary is suggested. The semantic of these are not fully explored, but we suggest that consecutive and simultaneous should be the first to be supported Type of the reaction. Recommended unit. a facet on a numeric dictionary entry. A reference to an element of given type. ref modifies an element into a reference to an existing element of that type within the document. This is similar to a pointer and it can be thought of a strongly typed hyperlink. It may also be used for "subclassing" or "overriding" elements.
When referring to an element most of the "data" such as attribute values and element content will be on the full instantiated element. Therefore ref (and possibly id) will normally be the only attributes on the pointing element. However there may be some attributes (title, count, etc.) which have useful semantics, but these are element-specific
A list of regions creating a union. The union of a series of regions produces a larger region (possibly disjoint). Any point belonging to any of the referenced regions is a member of this region. Type of relatedEntry. Type represents a the type of relationship in a relatedEntry element. Role of the object. How the object functions or its position in the architecture. No controlled vocabulary. Number of rows. The sequence of steps in a reactionList. By default the reactions in a reactionStepList are assumed to take place in sequence (e.g. one or more products of reaction n are used in reaction n+1 or later. However there are cases where it is known that reactions take place in parallel (e.g. if there is no overlap of molecular identities). Alternatively there are points at which there are two or more competing reactions which may depend on conditions or concentrations. A small semi-controlled vocabulary is suggested. Serial number or other id. Currently only on module. Modules with the same _role_ attribute can be distinguished by _serial_. This is often an integer but other schemes may be used. shape of object. Mainly square, but extensible through the _xsd:union_ mechanism. The namespace for SI Units dictionary. Main use is on unitList to identify the dictionary holding the SI Units. Array of namespaces locating SI Units dictionaries. Main use is on unitList to identify the dictionaries holding the SI Units. The size of an array or matrix. A space group. No fixed semantics, though Hermann-Mauguin or Hall is recommended over Schoenflies. We may provide a controlled-extensible list in the future. 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. The spaceType of the lattice. Usually real or reciprocal. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency for unitTypes, etc. The type of the spectrum. A sphere. Currently describes a region. Any point falling within the sphere or on its surface is within the region. The spin of a system. Supports fractional values. Currently the spin of a nucleus. The normal fraction representing the spin of the isotope. 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. The start value. The start value in any allowable XSD representation 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. The physical state of the substance. No fixed semantics or default. The step value. The step value in any allowable XSD representation Type of the substanceList. Extension is allowed through the "other" value. 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 2006-05-21: PMR added attribute. 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. Is the molecule oriented to the symmetry No formal default, but a molecule is assumed to be oriented according to any _symmetry_ children. This is required for crystallographic data, but some systems for isolated molecules allow specification of arbitrary Cartesian or internal coordinates, which must be fitted or refined to a prescribed symmetry. In this case the attribute value is false. type of table. controls content Indicates whether the structure is a tautomer. Currently used with IChI _identifier_ element. Semantics, vocabulary and usage are application-dependent. A term in a dictionary. The term should be a noun or nounal phrase, with a separate definition and further description. The test condition on an if element. No controlled format yet. 2006-06-09: PMR Created.. A title on an element. No controlled value. The target of one or more links. On link elements the value is the single id of an element within the document or context specified in map@toContext attributes. It must identify the element uniquely. The reserved value 'null' implies that no mapping has been provided for the object(s) in the 'from' attribute. This implies no semantics but may be used by software to keep count of which elements have been mapped. For multiple targets use 'toSet'. 2005-06-18: updated docs The context for the 'from' links in a map. A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. 2005-06-18: created A set of ids representing the base of a link. For a partial mapping where a number of 'to' elements are known to link to a number of 'from' elements it can be useful to aggregate these into a single attribute value. The primary use is to assert that n links exist between a set of n 'to' elements and n 'from' elements but that the precise links are unknown. The semantics of the reference are the same as for 'to' and all the elements must be of the same type (which can be specified with 'toType' either on the link or the containing map). No order information is implied. In general there will be the same number of idRefs in the 'fromSet' and all implicit links will share the same attributes (e.g. 'role'). In many cases the sets will be later split into discrete links thorugh further calculation or experiment (e.g. peak assignment). Sets should never be used as a lazy or concise alternative where the all the links are explicitly known. 2005-06-18: created total digits in a scalar. based on xsd:schema. The type of the base of a link. The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. 2005-06-18: created Type of the object. A qualifier which may affect the semantics of the object. A reference to the type of a unit. Needed to differentiate the rather unhappy polymorphism of unitList/unit and unitList/unitType. 2005-12-17 PMR: Added Scientific units on an element. These must be taken from a dictionary of units. There should be some mechanism for validating the type of the units against the possible values of the element. unitsRef attribute on CML1 elements. CML1-only - now deprecated. A reference to the type of a unit. Used in defining the unit and doing symbolic algebra on the dimensionality. Value of a scalar object. The value must be consistent with the dataType of the object. A vector in 3 dimensions. can be used for any complex geometrical object, such as line. The version of the element cml or identifier elements can currently have versions. They may be dependent on the date of release and this attribute is highly recommended. There is no controlled syntax. Weight of the element. Currently the weight of the kPoint, derived from the symmetry such as the inverse of the multiplicity in real space. Thus a point at 0,0,0 in monoclinic space might be 0.25. The lowest value possible is probably 1/48.0 (in m3m). 2003-09-15 (added at suggestion of Jon Wakelin). Whitespace. Attached to entry. This may be obsolete. 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. 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. 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. An array of x3 coordinate. Normally used in CML2 array mode. Fractional x coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. Array of fractional x coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. Maximum xValue. Annotates x-axis data with a maximum value. This need not be algorithmically deducible from the data and is typically used for the extent of a _peak_ or _peakGroup_. It uses xUnits or the same units as the data. There may or may not be a _xMin_ attribute but if so xMax should be greater than or equals to it. Minimum xValue. Annotates x-axis data with a minimum value. This need not be algorithmically deducible from the data and is typically used for the extent of a _peak_ or _peakGroup_. It uses xUnits or the same units as the data. There may or may not be a _xMax_ attribute but if so xMin should be less than or equals to it. Units for x axis. All x-axis data must have unambiguous units. Ideally the data and _xMin_ or _xValue_ should share the same units but different xUnits can be used as long as it is clear.. Value along an x axis. Annotates x-axis data with a value. It is typically used for the location of a _peak_ or _peakGroup_. It uses xUnits or the same units as the data. An unsigned interval along an x axis. It is typically used for the width of a _peak_ or _peakGroup_ but could be used for any range. It uses xUnits or the same units as the data. 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. 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. 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. An array of y3 coordinate. Normally used in CML2 array mode. Fractional y coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. Array of fractional y coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. Yield of a reaction or reactionStep. Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. Maximum yValue. Annotates y-axis data with a maximum value. This need not be algorithmically deducible from the data and is typically used for the extent of a _peak_ or _peakGroup_. It uses yUnits or the same units as the data. There may or may not be a _yMin_ attribute but if so yMax should be greater than or equals to it. Minimum yValue. Annotates y-axis data with a minimum value. This need not be algorithmically deducible from the data and is typically used for the extent of a _peak_ or _peakGroup_. It uses yUnits or the same units as the data. There may or may not be a _yMax_ attribute but if so yMin should be less than or equal to it. Units for y axis. All y-axis data must have unambiguous units. Ideally the data and _yMin_ or _yValue_ should share the same units but different yUnits can be used as long as it is clear. Value along a y axis. Annotates y-axis data with a value. It is typically used for the location of a _peak_ or _peakGroup_. It uses yUnits or the same units as the data. An unsigned interval along a y axis. It is typically used for the width of a _peak_ or _peakGroup_ but could be used for any range. It uses yUnits or the same units as the data. The number of molecules per cell. Molecules are defined as the _molecule_ which directly contains the _crystal_ element. 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. An array of z3 coordinate. Normally used in CML2 array mode. Fractional y coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. Array of fractional z coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. Describes whether child elements are sequential or parallel. There is no default. The type of an alternative. This adds semantics to an _alternative_ and might be used by an RDF or related engine. An enumeration of allowed angle units. May be obsolete. An identifier for an atom. Of the form prefix:suffix where prefix and suffix are purely alphanumeric (with _ and -) and prefix is optional. This is similar to XML IDs (and we promote this as good practice for atomIDs. Other punctuation and whitespace is forbidden, so IDs from (say) PDB files are not satisfactory. The prefix is intended to form a pseudo-namespace so that atom IDs in different molecules may have identical suffixes. It is also useful if the prefix is the ID for the molecule (though this clearly has its limitation). Atom IDs should not be typed as XML IDs since they may not validate. 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. A reference to two distinct existing atoms in order. A reference to three distinct existing atoms in order. A reference to four distinct existing atoms in order. A reference to an existing atom. An array of references to bonds. The references cannot (yet) cannot be schema- or schematron-validated. Instances of this type will be used in array-style representation of electron counts, etc. It can also be used for arrays of bondIDTypes such as in complex stereochemistry, geometrical definitions, bond groupings, etc. A reference to an existing bond. A reference to a bond may be made by atoms (e.g. for multicentre or pi-bonds), electrons (for annotating reactions or describing electronic properties) or possibly other bonds (no examples yet). The semantics are relatively flexible. A box in 3-space. Defined by 6 real numbers (x1 y1 z1 x2 y2 z2). By default these are Cartesian coordinates (with units specified elsewhere - responsibility of schema creator.) If there is a means of specifying oblique axes (e.g. crystallographic cell) the box may be a parallelipiped. The components are grouped in threes ans separated by a semicolon to avoid problems of guessing the convention. enumerated type of cellParameter The chirality of a system or molecule. This is being actively investigated by a IUPAC committee (2002) so the convention is likely to change. No formal default. A pair of floats representing a complex number. This example is schema-invalid as it has three floats An x/y coordinate pair. An x/y coordinate pair consisting of two real numbers, separated by whitespace or a comma. In arrays and matrices, it may be useful to set a separate delimiter An x/y/z coordinate triple. An x/y/z coordinate triple consisting of three real numbers, separated by whitespace or commas. In arrays and matrices, it may be useful to set a separate delimiter. An array of coordinateComponents for a single coordinate. An array of coordinateComponents for a single coordinate where these all refer to an X-coordinate (NOT x,y,z).Instances of this type will be used in array-style representation of 2-D or 3-D coordinates. Currently no machine validation. Currently not used in STMML, but re-used by CML (see example). Array of counts. Normally, but not always, integers. can be used with a number of elements 2005-11-01: PMR the combination of dataType and list does not work with JUMBO5.0 - so for the meantime we have removed the restriction A count multiplier for an object. Many elements represent objects which can occur an arbitrary number of times in a scientific context. Examples are action, object or molecules. 2005-10-16. Changed to positiveNumerType. The cyclic nature of a bond. Used for indicating the cyclic nature of a bond. It may or may not agree with the actually connection table (i.e. a user may assert that a bond is a/cyclic). an enumerated type for all dataTypes in STM. dataTypeType represents an enumeration of allowed dataTypes (at present identical with those in XML-Schemas (Part2- datatypes). This means that implementers should be able to use standard XMLSchema-based tools for validation without major implementation problems. It will often be used an an attribute on scalar, array or matrix elements. Note: the attribute xsi:type might be used to enforce the type-checking but I haven't worked this through yet. A single non-whitespace character to separate components in arrays. Some STMML elements (such as array) have content representing concatenated values. The default separator is whitespace (which can be normalised) and this should be used whenever possible. However in some cases the values are empty, or contain whitespace or other problematic punctuation, and a delimiter is required. Note that the content string MUST start and end with the delimiter so there is no ambiguity as to what the components are. Only printable characters from the ASCII character set should be used, and character entities should be avoided. When delimiters are used to separate precise whitespace this should always consist of spaces and not the other allowed whitespace characters (newline, tabs, etc.). If the latter are important it is probably best to redesign the application. At present there is a controlled pattern of characters selected so as not to collide with common usage in XML document The values in the array are "A", "B12", "" (empty string) and "D and E" note the spaces A dictionaryPrefix used to identify a dictionary, units, convention or other metadata. 2005-12-12: PMR. Added for use with dictionary The dictionary prefix must conform to XSD. Allowed values for dimension Types in quantities. These are the 7 types prescribed by the SI system, together with the "dimensionless" type. We intend to be somewhat uncoventional and explore enhanced values of "dimensionless", such as "angle". This may be heretical, but we find the present system impossible to implement in many cases. Used for constructing entries in a dictionary of units An angl. (formally dimensionless, but useful to have units). Orientation of the eigenvector matrix. Specifies whether the rows or columns of the (square) matrix correspond to the eigenvectors. For example, in molecular orbitals the vectors are normally represented as columns, and each column would correspond to a different eigenvalue 2006-01-13: PMR. Created. The columns are the eigenvectors. The columns are the eigenvectors. An array of elementTypes. Instances of this type will be used in array-style representation of atoms. Allowed elementType values. The periodic table (up to element number 118. In addition the following strings are allowed: Du. ("dummy") This does not correspond to a "real" atom and can support a point in space or within a chemical graph. R. ("R-group") This indicates that an atom or group of atoms could be attached at this point. Any isotope of hydrogen. There are no special element symbols for D and T which should use the isotope attribute. A point or object with no chemical semantics. Examples can be centroids, bond-midpoints, orienting "atoms" in small z-matrices. Note "Dummy" has the same semantics but is now deprecated. A point at which an atom or group might be attached. Examples are abbreviated organic functional groups, Markush representations, polymers, unknown atoms, etc. Semantics may be determined by the role attribute on the atom. The basis of an error value. Errors in values can be of several types and this simpleType provides a small controlled vocabulary. Array of error estimate values. An observed or calculated estimate of the error in the value of a numeric quantity. It should be ignored for dataTypes such as URL, date or string. The statistical basis of the errorValueType is not defined - it could be a range, an estimated standard deviation, an observed standard error, etc. This information can be added through _errorBasisType_. An estimate of the error in the value of a quantity. An observed or calculated estimate of the error in the value of a numeric quantity. It should be ignored for dataTypes such as URL, date or string. The statistical basis of the errorValueType is not defined - it could be a range, an estimated standard deviation, an observed standard error, etc. This information can be added through _errorBasisType_. OBSOLETE An array of floats. An array of floats or other real numbers. Not used in STM Schema, but re-used by CML and other languages. Array of formalCharges. Used for electron-bookeeping. This has no relation to its calculated (fractional) charge or oxidation state. The formal charge on an object. Used for electron-bookeeping. This has no relation to its calculated (fractional) charge or oxidation state. Format of a spectrum. The data structure of the spectrum. (Not the format of the data). This describes how the data structure is to be interpreted. one dimensional spectru. Data are represented by two _array_s, one representing the independent variable (e.g. wavelength, mass number) and the other the measured dependent variable (absorption, intensity, etc.). This can normally be plotted directly with the independent variable as the x-axis. The order of the points is not necessarily significant and may be increasing or decreasing. Two dimensional spectru. Data are represented by a single symmetric _matrix_ with both axes identical (i.e. the same independent variable). A typical example is a "2D 1HNMR spectrum". The dependent variable is represented by the matrix elements. This can normally be plotted as a square symmentric about a diagonal. Two dimensional spectrum with different axe. Data are represented by non-square _matrix_ with independent axes. A typical example is a "2D 1H 13C NMR spectrum". The dependent variable is represented by the matrix elements. . A concise representation for a molecular formula. This MUST adhere to a whitespaced syntax so that it is trivially machine-parsable. Each element is followed by its count (which may be decimal), and the string is optionally ended by a formal charge (of form d or -d, i.e. no '+') NO brackets or other nesting is allowed. 2005-08-30: allowed decimal points Domain of an FT spectrum. Indicates whether a spectrum is raw FID or has been transforme. Data are raw, so will normally require transforming. Data have been transformed. This value indicates that an FT experiment and transformation have been performe. This was not known to be an FT experiment. (It may have been, but the author or abstracter omitted to mention it). The head linker in a polymeric repeat unit A polymeric chain may be described by liniing the head of one repeat unit to the tail or head of another. The head attribute indicates the atom id (normally on an atom of elementType="R") which acts as the head 2006-05-20: PMR added Array of hydrogenCounts. The total number of hydrogen atoms bonded to an atom or contained in a molecule, whether explicitly included as atoms or not. It is an error to have hydrogen count less than the explicit hydrogen count. There is no default value and no assumptions about hydrogen Count can be made if it is not given. If hydrogenCount is given on every atom, then the values can be summed to give the total hydrogenCount for the (sub)molecule. Because of this hydrogenCount should not be used where hydrogen atoms bridge 2 or more atoms. The total number of hydrogen atoms bonded to an object. The total number of hydrogen atoms bonded to an atom or contained in a molecule, whether explicitly included as atoms or not. It is an error to have hydrogen count less than the explicit hydrogen count. There is no default value and no assumptions about hydrogen Count can be made if it is not given. If hydrogenCount is given on every atom, then the values can be summed to give the total hydrogenCount for the (sub)molecule. Because of this hydrogenCount should not be used where hydrogen atoms bridge 2 or more atoms. An array of ids or idRefs. See idType. A unique ID for an element. This is not formally of type ID (an XML NAME which must start with a letter and contain only letters, digits and .-_:). It is recommended that IDs start with a letter, and contain no punctuation or whitespace. The function in XSLT will generate semantically void unique IDs. It is difficult to ensure uniqueness when documents are merged. We suggest namespacing IDs, perhaps using the containing elements as the base. Thus mol3:a1 could be a useful unique ID. However this is still experimental. Inheritance mechanism. A reference to an existing element can be used to supplement values such as coordinates. The inheritance attribute determines whether the values are supplemented, overwritten or deleted. In the example: <molecule id="m1" view="initial"> <atomArray> <atom id="a1" x3="0.1"/> </atomArray> </molecule> <!-- this adds more information --> <molecule ref="m1" view="initial" inherit="supplement"> <atomArray> <atom id="a1" hydrogenCount="1"/> </atomArray> </molecule> <!-- this will overwrite the previous values --> <molecule ref="m1" inherit="overwrite" view="final" id="m2"> <atomArray> <atom id="a1" x3="0.1"/> </atomArray> </molecule> <!-- this will delete the previous values --> <molecule ref="m1" inherit="delete" view="restart"> <atomArray> <atom id="a1" hydrogenCount=""/> </atomArray> </molecule> The first molecule/@ref adds complementary information, the second changes the values. Software is allowed to generate two independent copies of the molecule and reference them by different IDs ( m1 and m2). This mechanism is necessary to manage the implied inheritance of partial information during minimisations and dynamics. It requires careful software implementation. Values from this element will be merged. The merging is element-specific with the intention that information from the current element will not conflict with the existing information. It is an error if there is a conflict. Values from this element will replace existing information. The merging is element-specific with the intention that information from the current element will replace the existing information. Components of this element will de deleted if they exist. An array of integers. An array of integers; for re-use by other schemas. Not machine-validatable. The numeric representation of an isotope. In core CML this represents a single number; either the combined proton/neutron count or a more accurate estimate of the nuclear mass. This is admittedly fuzzy, and requires a more complex object (which can manage conventions, lists of isotopic masses, etc.) See isotope. The default is "natural abundance" - whatever that can be interpreted as. Delta values (i.e. deviations from the most abundant istopic mass) are never allowed. A fractional representation of the spin of the nucleus. Allowed lattice types. lattice with A centering. A lattice which uses the translation operator {0, 0.5, 0.5}. User-defined lattice-type. This definition must be by reference to a namespaced dictionary entry. An unbounded line in 3-space. Defined by 6 real numbers, conventionally an arbitrary point on the line and a vector3. There is no significance to the point (i.e. it is not the "end of the line") and there are an infinite number of ways of representing the line. DANGER. Line3 now uses the point3 and vector3 attributes and the line3Type may be OBSOLETED. The type of the link. A container for locators. A link to an element. A labelled link. symbolic represention of l amd m. takes avlues of s, p, px, dxy, dx2y2, f, etc. A 4x4 transformation matrix This is the base for extending the transform3 element. Allowed matrix types. Many are square matrices. By default all elements must be included. For symmetric, antisymmetric and diagonal matrices some compression is possible by not reporting the identical or forced zero elements. These have their own subtypes, usually with UT or LT appended. Use these with caution as there is chance of confusion and you cannot rely on standard software to read these. The matrix type fixes the order and semantics of the elements in the XML element but does not mandate any local syntax. Thus an application may insert newline characters after each row or use a <row> element. Rectangular with no semantic constraints and ordered rowwise (i.e. the column index runs fastest). 1 2 3 4 0 3 5 6 Square with no semantic constraints. 1 2 78 3 4 -1 -34 2 7 Square symmetric with all elements explicit. 1 2 3 2 7 1 3 1 9 Square symmetric with the diagonal and lower triangle explicit and the upper triangle omitted. Rows are of length 1, 2, 3... 1 2 7 3 1 9 is equivalent to 1 2 3 2 7 1 3 1 9 Square symmetric with the diagonal and upper triangle explicit. Rows are of length n, n-1, ... 2, 1 1 7 9 2 -1 34 is equivalent to 1 7 9 7 2 -1 9 -1 34 Square antisymmetric with all elements explicit. The diagonal is necessarily zero. 0 -2 3 2 0 1 -3 -1 0 Square symmetric with the lower triangle explicit and diagonal and upper triangle omitted. Rows are of length 1, 2,... n-1. -7 -9 1 is equivalent to 0 7 9 -7 0 -1 -9 1 0 Square symmetric with the upper triangle explicit and diagonal and lower triangle omitted. Rows are of length n-1, n-2,... 2,1. 7 9 -1 is equivalent to 0 7 9 -7 0 -1 -9 1 0 Symmetric. Elements are zero except on the diagonal. No compressed representation available (use array element). 1 0 0 0 3 0 0 0 4 Square. Elements are zero below the diagonal 1 2 3 4 0 3 5 6 0 0 4 8 0 0 0 2 Square. Elements below the diagonal are zero and omitted, and rows are of length n, n-1, ... , 2, 1. 1 2 3 4 3 5 6 4 8 2 is equivalent to 1 2 3 4 0 3 5 6 0 0 4 8 0 0 0 2 Square. Elements are zero above the diagonal 1 0 0 7 3 0 9 2 4 Square. Elements above the diagonal are zero and omitted, and rows are of length 1, 2, ...n. 1 3 7 9 2 3 is equivalent to 1 0 0 3 7 0 9 2 3 Square. Diagonal elements are 1 and off-diagonal are zero. 1 0 0 0 1 0 0 0 1 Square. When multiplied by its transpose gives the unit matrix. 0 -1 0 1 0 0 0 0 1 Square. Each row corresponds to an eigenvector of a square matrix. Elements are real. The length of the eigenvectors is undefined, i.e. they are not required to be normalised to 1. 0 -1 0 1 0 0 0 0 1 The rotation is defined by the matrix premultiplyin a column vector (x, y) . 0 -1 1 0 produces (-y, x), i.e. a rotation of -90 degrees. A third column defining the translation is added to a rotation22. 0 -1 22 1 0 33 produces (-y + 22, x + 33), i.e. a rotation of -90 degrees followed by a translation of (22, 33). User-defined matrix-type. This definition must be by reference to a namespaced dictionary entry. The maximum INCLUSIVE value of a quantity. The maximum INCLUSIVE value of a sortable quantity such as numeric, date or string. It should be ignored for dataTypes such as URL. The use of min and max attributes can be used to give a range for the quantity. The statistical basis of this range is not defined. The value of max is usually an observed quantity (or calculated from observations). To restrict a value, the maxExclusive type in a dictionary should be used. The type of the maximum is the same as the quantity to which it refers - numeric, date and string are currently allowed Type of spectral measurement. The nature of the measured data. This is not an exhaustive list and should only be used if it affects the storage or immediate processing. Data are transmittance, so "peaks" are usually troughs. Data are absorbanc. so "peaks" are normally peaks. The name of the metadata. Metadata consists of name-value pairs (value is in the "content" attribute). The names are from a semi-restricted vocabulary, mainly Dublin Core. The content is unrestricted. The order of metadata has no implied semantics at present. Users can create their own metadata names using the namespaced prefix syntax (e.g. foo:institution). Ideally these names should be defined in an STMML dictionary. 2003-03-05: Added UNION to manage non-controlled name. The extent or scope of the content of the resource. Coverage will typically include spatial location (a place name or geographic coordinates), temporal period (a period label, date, or date range) or jurisdiction (such as a named administrative entity). Recommended best practice is to select a value from a controlled vocabulary (for example, the Thesaurus of Geographic Names [TGN]) and that, where appropriate, named places or time periods be used in preference to numeric identifiers such as sets of coordinates or date ranges. An account of the content of the resource. Description may include but is not limited to: an abstract, table of contents, reference to a graphical representation of content or a free-text account of the content. An unambiguous reference to the resource within a given context. Recommended best practice is to identify the resource by means of a string or number conforming to a formal identification system. Example formal identification systems include the Uniform Resource Identifier (URI) (including the Uniform Resource Locator (URL)), the Digital Object Identifier (DOI) and the International Standard Book Number (ISBN). The physical or digital manifestation of the resource. Typically, Format may include the media-type or dimensions of the resource. Format may be used to determine the software, hardware or other equipment needed to display or operate the resource. Examples of dimensions include size and duration. Recommended best practice is to select a value from a controlled vocabulary (for example, the list of Internet Media Types [MIME] defining computer media formats). A reference to a related resource. Recommended best practice is to reference the resource by means of a string or number conforming to a formal identification system. Information about rights held in and over the resource. Typically, a Rights element will contain a rights management statement for the resource, or reference a service providing such information. Rights information often encompasses Intellectual Property Rights (IPR), Copyright, and various Property Rights. If the Rights element is absent, no assumptions can be made about the status of these and other rights with respect to the resource. The topic of the content of the resource. Typically, a Subject will be expressed as keywords, key phrases or classification codes that describe a topic of the resource. Recommended best practice is to select a value from a controlled vocabulary or formal classification scheme. A name given to the resource. Typically, a Title will be a name by which the resource is formally known. The nature or genre of the content of the resource. Type includes terms describing general categories, functions, genres, or aggregation levels for content. Recommended best practice is to select a value from a controlled vocabulary (for example, the working draft list of Dublin Core Types [DCT1]). To describe the physical or digital manifestation of the resource, use the FORMAT element. An entity responsible for making contributions to the content of the resource. Examples of a Contributor include a person, an organisation, or a service. Typically, the name of a Contributor should be used to indicate the entity. An entity primarily responsible for making the content of the resource. Examples of a Creator include a person, an organisation, or a service. Typically, the name of a Creator should be used to indicate the entity. An entity responsible for making the resource available. Examples of a Publisher include a person, an organisation, or a service. Typically, the name of a Publisher should be used to indicate the entity. A Reference to a resource from which the present resource is derived. The present resource may be derived from the Source resource in whole or in part. Recommended best practice is to reference the resource by means of a string or number conforming to a formal identification system. A language of the intellectual content of the resource. Recommended best practice for the values of the Language element is defined by RFC 1766 [RFC1766] which includes a two-letter Language Code (taken from the ISO 639 standard [ISO639]), followed optionally, by a two-letter Country Code (taken from the ISO 3166 standard [ISO3166]). For example, 'en' for English, 'fr' for French, or 'en-uk' for English used in the United Kingdom. A date associated with an event in the life cycle of the resource. Typically, Date will be associated with the creation or availability of the resource. Recommended best practice for encoding the date value is defined in a profile of ISO 8601 [W3CDTF] and follows the YYYY-MM-DD format. Entry contains information relating to chemical safety. Typically the content will be a reference to a handbook, MSDS, threshhold or other human-readable strin. Part or whole of the information was computer-generated. Typically the content will be the name of a method or a progra. 3D structure included. details include. The minimum INCLUSIVE value of a quantity. The minimum INCLUSIVE value of a sortable quantity such as numeric, date or string. It should be ignored for dataTypes such as URL. The use of min and min attributes can be used to give a range for the quantity. The statistical basis of this range is not defined. The value of min is usually an observed quantity (or calculated from observations). To restrict a value, the minExclusive type in a dictionary should be used. The type of the minimum is the same as the quantity to which it refers - numeric, date and string are currently allowed An identifier for an molecule. Of the form prefix:suffix where prefix and suffix are purely alphanumeric (with _ and -) and prefix is optional. This is similar to XML IDs (and we promote this as good practice for moleculeIDs. Other punctuation and whitespace is forbidden, so IDs from (say) PDB files are not satisfactory. The prefix is intended to form a pseudo-namespace so that molecule IDs in different molecules may have identical suffixes. It is also useful if the prefix is the ID for the molecule (though this clearly has its limitation). molecule IDs should not be typed as XML IDs since they may not validate. 2006-11-24: PMR created. An array of moleculeRefs. Typical applications are the annotation of peaks in chromatograms and mapping reactions. The context of the id resolution is the childOrSibling concept. A reference to two distinct existing molecules in order. At present used for joining molecules or fragments(with join). 2006-11-24: PMR created A reference to an existing molecule. An array of namespaceURIs with required protocol. used to identify dictionaries, units, conventions or other metadata. 2005-12-17: PMR. Added for use with unitList An XML QName with required prefix. A string referencing a dictionary, units, convention or other metadata. The purpose is to allow authors to extend the vocabulary through their own namespaces without altering the schema. The prefix is mandatory. This convention is only used within CML and related languages; it is NOT a generic URI. The namespace prefix must start with an alpha character and can only contain alphanumeric and '_'. The suffix can have characters from the XML ID specification (alphanumeric, '_', '.' and '-' A namespaceURI with required protocol. used to identify a dictionary, units, convention or other metadata. Not yet confirmant with XSD 2005-12-10: PMR. Added for use with dictionary The namespace prefix must start with a protocol. The number of non-hydrogen atoms attached to an atom. Obsolete in core CML. Only useful in CML queries. A non-signed angle. Re-used by _angle_. Note that we also provide positiveAngleType (e.g. for cell angles) and torsionAngleType for _torsion_. A nonNegative number. Note that we also provide positiveNumber to avoid inclusive zero. The maximum number is 1.0E+999 since 'unbounded' is more difficult to implement. This is greater than Eddington's estimate of the number of particles in the universe so it should work for most people. Array of atomic occupancies. Primarily for crystallography. Values outside 0-1 are not allowed. A floating point number between 0 and 1 inclusive Originally for crystallographic occupancy but re-usable for fractional yield, etc. An array of bond orders. See order. Bond order. This is purely conventional and used for bond/electron counting. There is no default value. The emptyString attribute can be used to indicate a bond of unknown or unspecified type. The interpretation of this is outside the scope of CML-based algorithms. It may be accompanied by a convention attribute on the bond which links to a dictionary. Example: <bond convention="ccdc:9" atomRefs2="a1 a2"/> could represent a delocalised bond in the CCDC convention. Hydrogen bond. Carries no semantics but will normally be between a hydrogen atom and an element with lone pairs. Partial bond. Can be used for a partial bond in a transition state, intermolecular interaction, etc. There is no numeric value associated and the bond order could be anywhere between 0 and single. Single bond. synonymous with "1. Single bond. Intermediate between 1 and . Could be used for a transition state or a delocalised system. Double bond. Double bond. Intermediate between 2 and . Could be used for a transition state or a delocalised system. Triple bond. Triple bond. Aromatic bond. Multiplicity of a peak. Uses a semi-controlled vocabulary. A single maximum within the peak rang. Two maxima (not necessarily equal) within the peak rang. Three maxima (not necessarily equal) within the peak rang. Four maxima (not necessarily equal) within the peak rang. Five maxima (not necessarily equal) within the peak rang. Six maxima (not necessarily equal) within the peak rang. Several maxima (not necessarily equal) within the peak rang. User contributed vocabulary of type foo:ba. Shape of a peak. Semi-controlled vocabulary such as broad or sharp. A sharp peak. A broad peak. A brodening of a peak suggesting the presence of a smaller incompletely resolved component. User contributed vocabulary of type foo:bar. type of a peakStructure. Semi-controlled vocabulary such as coupling or splitting. A coupling such as in NMR. A splitting such as in NMR. User contributed vocabulary. The width of a peak. At present we allow a peakWidth to be positive or exactly zero (to signal that the peak should not be integrated). An unbounded plane in 3-space. Defined by 4 real numbers, conventionally a vector3 normal to the plane and a signed scalar representing the distance to the origin. The vector must not be of zero length (and need not be normalized. The first three numbers are the vector, followed by the distance A point in 3-space. The 3 components can have any signed value. A non-signed angle such as a cell angle. Re-used by _crystal_. Note that we also provide nonNegativeAngleType (e.g. for bond angles). A positive number. Note that we also provide nonNegativeNumber with inclusive zero. The maximum number is (quite large) since 'unbounded' is more difficult to implement. The format of the reaction. This is provided for machine-understanding of the format of the reaction steps and components. Semantics are semi-controlled. The commonest representation with reactantList and productList. A list of molecules representing snap shots on a reaction pathway. The role of the reaction within a reactionList. Semantics are semi-controlled. On reactionList signifies that the children are the complete description of the reaction. The overall reaction in a multi-step reaction. Normally this would be the first reaction in a reactionList and the individual steps are held in a following sibling reactionList. The rate-determining step in a multi-step reaction. This implies also that the reaction has a role of step. A step in a multi-step reaction. This reaction will normally be a child of reactionList. a reactionList containing steps Examples could be "myDict:step1", "foo:chainPropagation", etc. The sequence of steps in a reactionStepList. By default the reactions in a reactionStepList are assumed to take place in sequence (e.g. one or more products of reaction n are used in reaction n+1 or later. However there are cases where it is known that reactions take place in parallel (e.g. if there is no overlap of molecular identities). Alternatively there are points at which there are two or more competing reactions which may depend on conditions or concentrations. A small semi-controlled vocabulary is suggested. The semantic of these are not fully explored, but we suggest that consecutive and simultaneous should be the first to be supported The order of the steps is unknown. The reaction proceeds through the steps in the order given. The reaction may proceed through either (or possibly both) of the contained reactions or reactionScheme, but it may not be known which. The two or more independent reaction/List children proceed independently. The semantic type of the reaction. This is provided for machine-understanding of the topology or logic of the reaction steps and components (i.e. not for a general classification for which label is more appropriate.) Semantics are semi-controlled. Some terms are appropriate to multistep reactions, and can be used with or without explicit steps. A reaction in which one or more reactive reaction intermediates (frequently radicals) are continuously regenerated, usually through a repetitive cycle of elementary steps (the 'propagation step') (IUPAC GoldBook). A reaction or process generating free radicals (or some other reactive reaction intermediates) which then induce a chain reaction. For example, in the chlorination of alkanes by a radical mechanism the initiation step is the dissociation of molecular chlorine. IUPAC Compendium of Chemical Terminology 2nd Edition (1997). The steps in a chain reaction in which reactive intermediates are destroyed or rendered inactive, thus ending the chain. IUPAC Compendium of Chemical Terminology 2nd Edition (1997) . A reaction which can proceed in the forward direction as readily as in the reverse direction (IUPAC GoldBook). A reference to an existing object. A reference to an existing element in the document. The target of the ref attribute must exist. The test for validity will normally occur in the element's _appinfo_. Any DOM Node created from this element will normally be a reference to another Node, so that if the target node is modified a the dereferenced content is modified. At present there are no deep copy semantics hardcoded into the schema. The semantic of reference are normally identical to an idType (e.g. "a123b"). Howevere there are some cases where compound references are required, such as "a123b:pq456". It is likely that this will be superseded at by RDF or Xpointer, but as long as we have non-uniqueIds this is a problem Type of relatedEntry. Type represents a the type of relationship in a relatedEntry element. instruction to create repeat of the object. The attribute contains an index, its start value (normally 1) and its end value as in "i 3 10" which would make 8 repeat of the object. In selected attribute values the string _i_ acts as a macro and would be replaced by the value of i. EXPERIMENTAL. It can also have variables as the values. 2006-05-20: PMR added. The sequence of steps in a reactionList. By default the reactions in a reactionStepList are assumed to take place in sequence (e.g. one or more products of reaction n are used in reaction n+1 or later. However there are cases where it is known that reactions take place in parallel (e.g. if there is no overlap of molecular identities). Alternatively there are points at which there are two or more competing reactions which may depend on conditions or concentrations. A small semi-controlled vocabulary is suggested. The order of the steps is unknow. The reaction proceeds through the steps in the order give. The reaction may proceed through either of the contained reactions or reactionScheme. The two or more independent reaction/List children proceed independently. This can be extended to synthetic chemistry where two parts of the synthesis are conducted in parallel. Allowed shapes of arrayList. Rectangular, triangular or irregular. Rectangular. Triangular decreasing in size from ncols to 1. Triangular increasing in size from 1 to ncols. Irregular shape. User-defined arrayList-type. This definition must be by reference to a namespaced dictionary entry. The size of an array. The size of an array. Redundant, but serves as a check for processing software (useful if delimiters are used). Signifies real or reciprocal space. Likely to be used on types such as lattice, plane, point. A synonym for reciprocal. A synonym for reciprocal. User-defined space-type. No obvious possibilities, but who know. The type of the spectrum. An infrared spectrum. The measurement should denote transmittance or absorbanc. A "simple" mass spectrum. This excludes experiments such as GC/MS, MS/MS, etc. though these could be constructed out of individual spectra with some care. The spectrum may be continuous ( data or a peakList). An NMR spectrum. This can include any experiment which creates a "1D" or "2D" data array. The symmetry of the spectrum can be specified but the details of the NMR experiment (COSY, NOESY, etc.) are not part of CMLSpect. They can be described though the normal dictRef mechanism. A spectrum somewhere in the UV VIS region of the spectrum. The measurement should denote transmittance or absorbance. A sphere in 3-space. Defined by 4 real numbers, conventionally a point3 at the centre of the sphere and a nonNegative scalar for the radius. State of a substance or property. The state(s) of matter appropriate to a substance or property. It follows a partially controlled vocabulary. It can be extended through namespace codes to dictionaries. An aqueous solutio. Gas or vapor. The default state for computation on isolated molecule. A glassy stat. Normally pure liquid (use solution where appropriate. The nematic phas. The smectic phas. A soli. A solid solutio. A (liquid) solutio. Bond stereochemistry as a string. This is purely conventional. There is no default value. The emptyString attribute can be used to indicate a bond of unknown or unspecified type. The interpretation of this is outside the scope of CML-based algorithms. It may be accompanied by a convention attribute which links to a dictionary. A cis bond. A trans bond. A wedge bond. A hatch bond. empty or missing. An array of strings, separated by whitespace. An array of strings, separated by whitespace. If the strings have embedded whitespace or may be empty (zero-length), a non-whitespace single-character delimiter must be used. At present no machine validation Type of the substanceList. Extension is allowed through the "other" value. Allowed types of table. rowBased, arrayBased, contentBased. 2006-11-03: formlized 3 table types rowBased. Based on child arrayList containing arrays or lists child tableContent User-defined table-type. This definition must be by reference to a namespaced dictionary entry. The tail linker in a polymeric repeat unit A polymeric chain may be described by liniing the tail of one repeat unit to the head or tail of another. The tail attribute indicates the atom id (normally on an atom of elementType="R") which acts as the tail 2006-05-20: PMR added The type of a torsion angle. Type of unitList. Required to differentiate between the two types of unitList (units and unitTypes) child elements are unit child elements are unitType Scientific units. These will be linked to dictionaries of units with conversion information, using namespaced references (e.g. si:m). Distinguish carefully from _unitType_ which is an element describing a type of a unit in a _unitList_. A vector in 3-space. No constraints on magnitude (i.e. could be zero. Version of a document or code. Forms include 1, 0.9, 1.1.3, 1.2alpha, etc. The name of an XMLElement. (Distinguish from a chemical element as in elementTypeType). Currently used for assigning XMLElement types to references (e.g. to='a1' toType='atom'). Semantics are not controlled and in principle elements outside the CML tagSet could be used. Implementers cannot assume that namespace prefixes can be resolved and default usage is probably the local name.
cmlxom-cmlxom-4.11/src/main/resources/org/xmlcml/cml/base/types.xsd000077500000000000000000004132561477224461000254410ustar00rootroot00000000000000 Describes whether child elements are sequential or parallel. There is no default. The type of an alternative. This adds semantics to an _alternative_ and might be used by an RDF or related engine. An enumeration of allowed angle units. May be obsolete. An identifier for an atom. Of the form prefix:suffix where prefix and suffix are purely alphanumeric (with _ and -) and prefix is optional. This is similar to XML IDs (and we promote this as good practice for atomIDs. Other punctuation and whitespace is forbidden, so IDs from (say) PDB files are not satisfactory. The prefix is intended to form a pseudo-namespace so that atom IDs in different molecules may have identical suffixes. It is also useful if the prefix is the ID for the molecule (though this clearly has its limitation). Atom IDs should not be typed as XML IDs since they may not validate. 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. A reference to two distinct existing atoms in order. A reference to three distinct existing atoms in order. A reference to four distinct existing atoms in order. A reference to an existing atom. An array of references to bonds. The references cannot (yet) cannot be schema- or schematron-validated. Instances of this type will be used in array-style representation of electron counts, etc. It can also be used for arrays of bondIDTypes such as in complex stereochemistry, geometrical definitions, bond groupings, etc. A reference to an existing bond. A reference to a bond may be made by atoms (e.g. for multicentre or pi-bonds), electrons (for annotating reactions or describing electronic properties) or possibly other bonds (no examples yet). The semantics are relatively flexible. A box in 3-space. Defined by 6 real numbers (x1 y1 z1 x2 y2 z2). By default these are Cartesian coordinates (with units specified elsewhere - responsibility of schema creator.) If there is a means of specifying oblique axes (e.g. crystallographic cell) the box may be a parallelipiped. The components are grouped in threes ans separated by a semicolon to avoid problems of guessing the convention. enumerated type of cellParameter The chirality of a system or molecule. This is being actively investigated by a IUPAC committee (2002) so the convention is likely to change. No formal default. A pair of floats representing a complex number. This example is schema-invalid as it has three floats An x/y coordinate pair. An x/y coordinate pair consisting of two real numbers, separated by whitespace or a comma. In arrays and matrices, it may be useful to set a separate delimiter An x/y/z coordinate triple. An x/y/z coordinate triple consisting of three real numbers, separated by whitespace or commas. In arrays and matrices, it may be useful to set a separate delimiter. An array of coordinateComponents for a single coordinate. An array of coordinateComponents for a single coordinate where these all refer to an X-coordinate (NOT x,y,z).Instances of this type will be used in array-style representation of 2-D or 3-D coordinates. Currently no machine validation. Currently not used in STMML, but re-used by CML (see example). Array of counts. Normally, but not always, integers. can be used with a number of elements 2005-11-01: PMR the combination of dataType and list does not work with JUMBO5.0 - so for the meantime we have removed the restriction A count multiplier for an object. Many elements represent objects which can occur an arbitrary number of times in a scientific context. Examples are action, object or molecules. 2005-10-16. Changed to positiveNumerType. The cyclic nature of a bond. Used for indicating the cyclic nature of a bond. It may or may not agree with the actually connection table (i.e. a user may assert that a bond is a/cyclic). an enumerated type for all dataTypes in STM. dataTypeType represents an enumeration of allowed dataTypes (at present identical with those in XML-Schemas (Part2- datatypes). This means that implementers should be able to use standard XMLSchema-based tools for validation without major implementation problems. It will often be used an an attribute on scalar, array or matrix elements. Note: the attribute xsi:type might be used to enforce the type-checking but I haven't worked this through yet. A single non-whitespace character to separate components in arrays. Some STMML elements (such as array) have content representing concatenated values. The default separator is whitespace (which can be normalised) and this should be used whenever possible. However in some cases the values are empty, or contain whitespace or other problematic punctuation, and a delimiter is required. Note that the content string MUST start and end with the delimiter so there is no ambiguity as to what the components are. Only printable characters from the ASCII character set should be used, and character entities should be avoided. When delimiters are used to separate precise whitespace this should always consist of spaces and not the other allowed whitespace characters (newline, tabs, etc.). If the latter are important it is probably best to redesign the application. At present there is a controlled pattern of characters selected so as not to collide with common usage in XML document The values in the array are "A", "B12", "" (empty string) and "D and E" note the spaces A dictionaryPrefix used to identify a dictionary, units, convention or other metadata. 2005-12-12: PMR. Added for use with dictionary The dictionary prefix must conform to XSD. Allowed values for dimension Types in quantities. These are the 7 types prescribed by the SI system, together with the "dimensionless" type. We intend to be somewhat uncoventional and explore enhanced values of "dimensionless", such as "angle". This may be heretical, but we find the present system impossible to implement in many cases. Used for constructing entries in a dictionary of units An angl. (formally dimensionless, but useful to have units). Orientation of the eigenvector matrix. Specifies whether the rows or columns of the (square) matrix correspond to the eigenvectors. For example, in molecular orbitals the vectors are normally represented as columns, and each column would correspond to a different eigenvalue 2006-01-13: PMR. Created. The columns are the eigenvectors. The columns are the eigenvectors. An array of elementTypes. Instances of this type will be used in array-style representation of atoms. Allowed elementType values. The periodic table (up to element number 118. In addition the following strings are allowed: Du. ("dummy") This does not correspond to a "real" atom and can support a point in space or within a chemical graph. R. ("R-group") This indicates that an atom or group of atoms could be attached at this point. Any isotope of hydrogen. There are no special element symbols for D and T which should use the isotope attribute. A point or object with no chemical semantics. Examples can be centroids, bond-midpoints, orienting "atoms" in small z-matrices. Note "Dummy" has the same semantics but is now deprecated. A point at which an atom or group might be attached. Examples are abbreviated organic functional groups, Markush representations, polymers, unknown atoms, etc. Semantics may be determined by the role attribute on the atom. The basis of an error value. Errors in values can be of several types and this simpleType provides a small controlled vocabulary. Array of error estimate values. An observed or calculated estimate of the error in the value of a numeric quantity. It should be ignored for dataTypes such as URL, date or string. The statistical basis of the errorValueType is not defined - it could be a range, an estimated standard deviation, an observed standard error, etc. This information can be added through _errorBasisType_. An estimate of the error in the value of a quantity. An observed or calculated estimate of the error in the value of a numeric quantity. It should be ignored for dataTypes such as URL, date or string. The statistical basis of the errorValueType is not defined - it could be a range, an estimated standard deviation, an observed standard error, etc. This information can be added through _errorBasisType_. OBSOLETE An array of floats. An array of floats or other real numbers. Not used in STM Schema, but re-used by CML and other languages. Array of formalCharges. Used for electron-bookeeping. This has no relation to its calculated (fractional) charge or oxidation state. The formal charge on an object. Used for electron-bookeeping. This has no relation to its calculated (fractional) charge or oxidation state. Format of a spectrum. The data structure of the spectrum. (Not the format of the data). This describes how the data structure is to be interpreted. one dimensional spectru. Data are represented by two _array_s, one representing the independent variable (e.g. wavelength, mass number) and the other the measured dependent variable (absorption, intensity, etc.). This can normally be plotted directly with the independent variable as the x-axis. The order of the points is not necessarily significant and may be increasing or decreasing. Two dimensional spectru. Data are represented by a single symmetric _matrix_ with both axes identical (i.e. the same independent variable). A typical example is a "2D 1HNMR spectrum". The dependent variable is represented by the matrix elements. This can normally be plotted as a square symmentric about a diagonal. Two dimensional spectrum with different axe. Data are represented by non-square _matrix_ with independent axes. A typical example is a "2D 1H 13C NMR spectrum". The dependent variable is represented by the matrix elements. . A concise representation for a molecular formula. This MUST adhere to a whitespaced syntax so that it is trivially machine-parsable. Each element is followed by its count (which may be decimal), and the string is optionally ended by a formal charge (of form d or -d, i.e. no '+') NO brackets or other nesting is allowed. 2005-08-30: allowed decimal points Domain of an FT spectrum. Indicates whether a spectrum is raw FID or has been transforme. Data are raw, so will normally require transforming. Data have been transformed. This value indicates that an FT experiment and transformation have been performe. This was not known to be an FT experiment. (It may have been, but the author or abstracter omitted to mention it). The head linker in a polymeric repeat unit A polymeric chain may be described by liniing the head of one repeat unit to the tail or head of another. The head attribute indicates the atom id (normally on an atom of elementType="R") which acts as the head 2006-05-20: PMR added Array of hydrogenCounts. The total number of hydrogen atoms bonded to an atom or contained in a molecule, whether explicitly included as atoms or not. It is an error to have hydrogen count less than the explicit hydrogen count. There is no default value and no assumptions about hydrogen Count can be made if it is not given. If hydrogenCount is given on every atom, then the values can be summed to give the total hydrogenCount for the (sub)molecule. Because of this hydrogenCount should not be used where hydrogen atoms bridge 2 or more atoms. The total number of hydrogen atoms bonded to an object. The total number of hydrogen atoms bonded to an atom or contained in a molecule, whether explicitly included as atoms or not. It is an error to have hydrogen count less than the explicit hydrogen count. There is no default value and no assumptions about hydrogen Count can be made if it is not given. If hydrogenCount is given on every atom, then the values can be summed to give the total hydrogenCount for the (sub)molecule. Because of this hydrogenCount should not be used where hydrogen atoms bridge 2 or more atoms. An array of ids or idRefs. See idType. A unique ID for an element. This is not formally of type ID (an XML NAME which must start with a letter and contain only letters, digits and .-_:). It is recommended that IDs start with a letter, and contain no punctuation or whitespace. The function in XSLT will generate semantically void unique IDs. It is difficult to ensure uniqueness when documents are merged. We suggest namespacing IDs, perhaps using the containing elements as the base. Thus mol3:a1 could be a useful unique ID. However this is still experimental. Inheritance mechanism. A reference to an existing element can be used to supplement values such as coordinates. The inheritance attribute determines whether the values are supplemented, overwritten or deleted. In the example: <molecule id="m1" view="initial"> <atomArray> <atom id="a1" x3="0.1"/> </atomArray> </molecule> <!-- this adds more information --> <molecule ref="m1" view="initial" inherit="supplement"> <atomArray> <atom id="a1" hydrogenCount="1"/> </atomArray> </molecule> <!-- this will overwrite the previous values --> <molecule ref="m1" inherit="overwrite" view="final" id="m2"> <atomArray> <atom id="a1" x3="0.1"/> </atomArray> </molecule> <!-- this will delete the previous values --> <molecule ref="m1" inherit="delete" view="restart"> <atomArray> <atom id="a1" hydrogenCount=""/> </atomArray> </molecule> The first molecule/@ref adds complementary information, the second changes the values. Software is allowed to generate two independent copies of the molecule and reference them by different IDs ( m1 and m2). This mechanism is necessary to manage the implied inheritance of partial information during minimisations and dynamics. It requires careful software implementation. Values from this element will be merged. The merging is element-specific with the intention that information from the current element will not conflict with the existing information. It is an error if there is a conflict. Values from this element will replace existing information. The merging is element-specific with the intention that information from the current element will replace the existing information. Components of this element will de deleted if they exist. An array of integers. An array of integers; for re-use by other schemas. Not machine-validatable. The numeric representation of an isotope. In core CML this represents a single number; either the combined proton/neutron count or a more accurate estimate of the nuclear mass. This is admittedly fuzzy, and requires a more complex object (which can manage conventions, lists of isotopic masses, etc.) See isotope. The default is "natural abundance" - whatever that can be interpreted as. Delta values (i.e. deviations from the most abundant istopic mass) are never allowed. A fractional representation of the spin of the nucleus. Allowed lattice types. lattice with A centering. A lattice which uses the translation operator {0, 0.5, 0.5}. User-defined lattice-type. This definition must be by reference to a namespaced dictionary entry. An unbounded line in 3-space. Defined by 6 real numbers, conventionally an arbitrary point on the line and a vector3. There is no significance to the point (i.e. it is not the "end of the line") and there are an infinite number of ways of representing the line. DANGER. Line3 now uses the point3 and vector3 attributes and the line3Type may be OBSOLETED. The type of the link. A container for locators. A link to an element. A labelled link. symbolic represention of l amd m. takes avlues of s, p, px, dxy, dx2y2, f, etc. A 4x4 transformation matrix This is the base for extending the transform3 element. Allowed matrix types. Many are square matrices. By default all elements must be included. For symmetric, antisymmetric and diagonal matrices some compression is possible by not reporting the identical or forced zero elements. These have their own subtypes, usually with UT or LT appended. Use these with caution as there is chance of confusion and you cannot rely on standard software to read these. The matrix type fixes the order and semantics of the elements in the XML element but does not mandate any local syntax. Thus an application may insert newline characters after each row or use a <row> element. Rectangular with no semantic constraints and ordered rowwise (i.e. the column index runs fastest). 1 2 3 4 0 3 5 6 Square with no semantic constraints. 1 2 78 3 4 -1 -34 2 7 Square symmetric with all elements explicit. 1 2 3 2 7 1 3 1 9 Square symmetric with the diagonal and lower triangle explicit and the upper triangle omitted. Rows are of length 1, 2, 3... 1 2 7 3 1 9 is equivalent to 1 2 3 2 7 1 3 1 9 Square symmetric with the diagonal and upper triangle explicit. Rows are of length n, n-1, ... 2, 1 1 7 9 2 -1 34 is equivalent to 1 7 9 7 2 -1 9 -1 34 Square antisymmetric with all elements explicit. The diagonal is necessarily zero. 0 -2 3 2 0 1 -3 -1 0 Square symmetric with the lower triangle explicit and diagonal and upper triangle omitted. Rows are of length 1, 2,... n-1. -7 -9 1 is equivalent to 0 7 9 -7 0 -1 -9 1 0 Square symmetric with the upper triangle explicit and diagonal and lower triangle omitted. Rows are of length n-1, n-2,... 2,1. 7 9 -1 is equivalent to 0 7 9 -7 0 -1 -9 1 0 Symmetric. Elements are zero except on the diagonal. No compressed representation available (use array element). 1 0 0 0 3 0 0 0 4 Square. Elements are zero below the diagonal 1 2 3 4 0 3 5 6 0 0 4 8 0 0 0 2 Square. Elements below the diagonal are zero and omitted, and rows are of length n, n-1, ... , 2, 1. 1 2 3 4 3 5 6 4 8 2 is equivalent to 1 2 3 4 0 3 5 6 0 0 4 8 0 0 0 2 Square. Elements are zero above the diagonal 1 0 0 7 3 0 9 2 4 Square. Elements above the diagonal are zero and omitted, and rows are of length 1, 2, ...n. 1 3 7 9 2 3 is equivalent to 1 0 0 3 7 0 9 2 3 Square. Diagonal elements are 1 and off-diagonal are zero. 1 0 0 0 1 0 0 0 1 Square. When multiplied by its transpose gives the unit matrix. 0 -1 0 1 0 0 0 0 1 Square. Each row corresponds to an eigenvector of a square matrix. Elements are real. The length of the eigenvectors is undefined, i.e. they are not required to be normalised to 1. 0 -1 0 1 0 0 0 0 1 The rotation is defined by the matrix premultiplyin a column vector (x, y) . 0 -1 1 0 produces (-y, x), i.e. a rotation of -90 degrees. A third column defining the translation is added to a rotation22. 0 -1 22 1 0 33 produces (-y + 22, x + 33), i.e. a rotation of -90 degrees followed by a translation of (22, 33). User-defined matrix-type. This definition must be by reference to a namespaced dictionary entry. The maximum INCLUSIVE value of a quantity. The maximum INCLUSIVE value of a sortable quantity such as numeric, date or string. It should be ignored for dataTypes such as URL. The use of min and max attributes can be used to give a range for the quantity. The statistical basis of this range is not defined. The value of max is usually an observed quantity (or calculated from observations). To restrict a value, the maxExclusive type in a dictionary should be used. The type of the maximum is the same as the quantity to which it refers - numeric, date and string are currently allowed Type of spectral measurement. The nature of the measured data. This is not an exhaustive list and should only be used if it affects the storage or immediate processing. Data are transmittance, so "peaks" are usually troughs. Data are absorbanc. so "peaks" are normally peaks. The name of the metadata. Metadata consists of name-value pairs (value is in the "content" attribute). The names are from a semi-restricted vocabulary, mainly Dublin Core. The content is unrestricted. The order of metadata has no implied semantics at present. Users can create their own metadata names using the namespaced prefix syntax (e.g. foo:institution). Ideally these names should be defined in an STMML dictionary. 2003-03-05: Added UNION to manage non-controlled name. The extent or scope of the content of the resource. Coverage will typically include spatial location (a place name or geographic coordinates), temporal period (a period label, date, or date range) or jurisdiction (such as a named administrative entity). Recommended best practice is to select a value from a controlled vocabulary (for example, the Thesaurus of Geographic Names [TGN]) and that, where appropriate, named places or time periods be used in preference to numeric identifiers such as sets of coordinates or date ranges. An account of the content of the resource. Description may include but is not limited to: an abstract, table of contents, reference to a graphical representation of content or a free-text account of the content. An unambiguous reference to the resource within a given context. Recommended best practice is to identify the resource by means of a string or number conforming to a formal identification system. Example formal identification systems include the Uniform Resource Identifier (URI) (including the Uniform Resource Locator (URL)), the Digital Object Identifier (DOI) and the International Standard Book Number (ISBN). The physical or digital manifestation of the resource. Typically, Format may include the media-type or dimensions of the resource. Format may be used to determine the software, hardware or other equipment needed to display or operate the resource. Examples of dimensions include size and duration. Recommended best practice is to select a value from a controlled vocabulary (for example, the list of Internet Media Types [MIME] defining computer media formats). A reference to a related resource. Recommended best practice is to reference the resource by means of a string or number conforming to a formal identification system. Information about rights held in and over the resource. Typically, a Rights element will contain a rights management statement for the resource, or reference a service providing such information. Rights information often encompasses Intellectual Property Rights (IPR), Copyright, and various Property Rights. If the Rights element is absent, no assumptions can be made about the status of these and other rights with respect to the resource. The topic of the content of the resource. Typically, a Subject will be expressed as keywords, key phrases or classification codes that describe a topic of the resource. Recommended best practice is to select a value from a controlled vocabulary or formal classification scheme. A name given to the resource. Typically, a Title will be a name by which the resource is formally known. The nature or genre of the content of the resource. Type includes terms describing general categories, functions, genres, or aggregation levels for content. Recommended best practice is to select a value from a controlled vocabulary (for example, the working draft list of Dublin Core Types [DCT1]). To describe the physical or digital manifestation of the resource, use the FORMAT element. An entity responsible for making contributions to the content of the resource. Examples of a Contributor include a person, an organisation, or a service. Typically, the name of a Contributor should be used to indicate the entity. An entity primarily responsible for making the content of the resource. Examples of a Creator include a person, an organisation, or a service. Typically, the name of a Creator should be used to indicate the entity. An entity responsible for making the resource available. Examples of a Publisher include a person, an organisation, or a service. Typically, the name of a Publisher should be used to indicate the entity. A Reference to a resource from which the present resource is derived. The present resource may be derived from the Source resource in whole or in part. Recommended best practice is to reference the resource by means of a string or number conforming to a formal identification system. A language of the intellectual content of the resource. Recommended best practice for the values of the Language element is defined by RFC 1766 [RFC1766] which includes a two-letter Language Code (taken from the ISO 639 standard [ISO639]), followed optionally, by a two-letter Country Code (taken from the ISO 3166 standard [ISO3166]). For example, 'en' for English, 'fr' for French, or 'en-uk' for English used in the United Kingdom. A date associated with an event in the life cycle of the resource. Typically, Date will be associated with the creation or availability of the resource. Recommended best practice for encoding the date value is defined in a profile of ISO 8601 [W3CDTF] and follows the YYYY-MM-DD format. Entry contains information relating to chemical safety. Typically the content will be a reference to a handbook, MSDS, threshhold or other human-readable strin. Part or whole of the information was computer-generated. Typically the content will be the name of a method or a progra. 3D structure included. details include. The minimum INCLUSIVE value of a quantity. The minimum INCLUSIVE value of a sortable quantity such as numeric, date or string. It should be ignored for dataTypes such as URL. The use of min and min attributes can be used to give a range for the quantity. The statistical basis of this range is not defined. The value of min is usually an observed quantity (or calculated from observations). To restrict a value, the minExclusive type in a dictionary should be used. The type of the minimum is the same as the quantity to which it refers - numeric, date and string are currently allowed An identifier for an molecule. Of the form prefix:suffix where prefix and suffix are purely alphanumeric (with _ and -) and prefix is optional. This is similar to XML IDs (and we promote this as good practice for moleculeIDs. Other punctuation and whitespace is forbidden, so IDs from (say) PDB files are not satisfactory. The prefix is intended to form a pseudo-namespace so that molecule IDs in different molecules may have identical suffixes. It is also useful if the prefix is the ID for the molecule (though this clearly has its limitation). molecule IDs should not be typed as XML IDs since they may not validate. 2006-11-24: PMR created. An array of moleculeRefs. Typical applications are the annotation of peaks in chromatograms and mapping reactions. The context of the id resolution is the childOrSibling concept. A reference to two distinct existing molecules in order. At present used for joining molecules or fragments(with join). 2006-11-24: PMR created A reference to an existing molecule. An array of namespaceURIs with required protocol. used to identify dictionaries, units, conventions or other metadata. 2005-12-17: PMR. Added for use with unitList An XML QName with required prefix. A string referencing a dictionary, units, convention or other metadata. The purpose is to allow authors to extend the vocabulary through their own namespaces without altering the schema. The prefix is mandatory. This convention is only used within CML and related languages; it is NOT a generic URI. The namespace prefix must start with an alpha character and can only contain alphanumeric and '_'. The suffix can have characters from the XML ID specification (alphanumeric, '_', '.' and '-' A namespaceURI with required protocol. used to identify a dictionary, units, convention or other metadata. Not yet confirmant with XSD 2005-12-10: PMR. Added for use with dictionary The namespace prefix must start with a protocol. The number of non-hydrogen atoms attached to an atom. Obsolete in core CML. Only useful in CML queries. A non-signed angle. Re-used by _angle_. Note that we also provide positiveAngleType (e.g. for cell angles) and torsionAngleType for _torsion_. A nonNegative number. Note that we also provide positiveNumber to avoid inclusive zero. The maximum number is 1.0E+999 since 'unbounded' is more difficult to implement. This is greater than Eddington's estimate of the number of particles in the universe so it should work for most people. Array of atomic occupancies. Primarily for crystallography. Values outside 0-1 are not allowed. A floating point number between 0 and 1 inclusive Originally for crystallographic occupancy but re-usable for fractional yield, etc. An array of bond orders. See order. Bond order. This is purely conventional and used for bond/electron counting. There is no default value. The emptyString attribute can be used to indicate a bond of unknown or unspecified type. The interpretation of this is outside the scope of CML-based algorithms. It may be accompanied by a convention attribute on the bond which links to a dictionary. Example: <bond convention="ccdc:9" atomRefs2="a1 a2"/> could represent a delocalised bond in the CCDC convention. Hydrogen bond. Carries no semantics but will normally be between a hydrogen atom and an element with lone pairs. Partial bond. Can be used for a partial bond in a transition state, intermolecular interaction, etc. There is no numeric value associated and the bond order could be anywhere between 0 and single. Single bond. synonymous with "1. Single bond. Intermediate between 1 and . Could be used for a transition state or a delocalised system. Double bond. Double bond. Intermediate between 2 and . Could be used for a transition state or a delocalised system. Triple bond. Triple bond. Aromatic bond. Multiplicity of a peak. Uses a semi-controlled vocabulary. A single maximum within the peak rang. Two maxima (not necessarily equal) within the peak rang. Three maxima (not necessarily equal) within the peak rang. Four maxima (not necessarily equal) within the peak rang. Five maxima (not necessarily equal) within the peak rang. Six maxima (not necessarily equal) within the peak rang. Several maxima (not necessarily equal) within the peak rang. User contributed vocabulary of type foo:ba. Shape of a peak. Semi-controlled vocabulary such as broad or sharp. A sharp peak. A broad peak. A brodening of a peak suggesting the presence of a smaller incompletely resolved component. User contributed vocabulary of type foo:bar. type of a peakStructure. Semi-controlled vocabulary such as coupling or splitting. A coupling such as in NMR. A splitting such as in NMR. User contributed vocabulary. The width of a peak. At present we allow a peakWidth to be positive or exactly zero (to signal that the peak should not be integrated). An unbounded plane in 3-space. Defined by 4 real numbers, conventionally a vector3 normal to the plane and a signed scalar representing the distance to the origin. The vector must not be of zero length (and need not be normalized. The first three numbers are the vector, followed by the distance A point in 3-space. The 3 components can have any signed value. A non-signed angle such as a cell angle. Re-used by _crystal_. Note that we also provide nonNegativeAngleType (e.g. for bond angles). A positive number. Note that we also provide nonNegativeNumber with inclusive zero. The maximum number is (quite large) since 'unbounded' is more difficult to implement. The format of the reaction. This is provided for machine-understanding of the format of the reaction steps and components. Semantics are semi-controlled. The commonest representation with reactantList and productList. A list of molecules representing snap shots on a reaction pathway. The role of the reaction within a reactionList. Semantics are semi-controlled. On reactionList signifies that the children are the complete description of the reaction. The overall reaction in a multi-step reaction. Normally this would be the first reaction in a reactionList and the individual steps are held in a following sibling reactionList. The rate-determining step in a multi-step reaction. This implies also that the reaction has a role of step. A step in a multi-step reaction. This reaction will normally be a child of reactionList. a reactionList containing steps Examples could be "myDict:step1", "foo:chainPropagation", etc. The sequence of steps in a reactionStepList. By default the reactions in a reactionStepList are assumed to take place in sequence (e.g. one or more products of reaction n are used in reaction n+1 or later. However there are cases where it is known that reactions take place in parallel (e.g. if there is no overlap of molecular identities). Alternatively there are points at which there are two or more competing reactions which may depend on conditions or concentrations. A small semi-controlled vocabulary is suggested. The semantic of these are not fully explored, but we suggest that consecutive and simultaneous should be the first to be supported The order of the steps is unknown. The reaction proceeds through the steps in the order given. The reaction may proceed through either (or possibly both) of the contained reactions or reactionScheme, but it may not be known which. The two or more independent reaction/List children proceed independently. The semantic type of the reaction. This is provided for machine-understanding of the topology or logic of the reaction steps and components (i.e. not for a general classification for which label is more appropriate.) Semantics are semi-controlled. Some terms are appropriate to multistep reactions, and can be used with or without explicit steps. A reaction in which one or more reactive reaction intermediates (frequently radicals) are continuously regenerated, usually through a repetitive cycle of elementary steps (the 'propagation step') (IUPAC GoldBook). A reaction or process generating free radicals (or some other reactive reaction intermediates) which then induce a chain reaction. For example, in the chlorination of alkanes by a radical mechanism the initiation step is the dissociation of molecular chlorine. IUPAC Compendium of Chemical Terminology 2nd Edition (1997). The steps in a chain reaction in which reactive intermediates are destroyed or rendered inactive, thus ending the chain. IUPAC Compendium of Chemical Terminology 2nd Edition (1997) . A reaction which can proceed in the forward direction as readily as in the reverse direction (IUPAC GoldBook). A reference to an existing object. A reference to an existing element in the document. The target of the ref attribute must exist. The test for validity will normally occur in the element's _appinfo_. Any DOM Node created from this element will normally be a reference to another Node, so that if the target node is modified a the dereferenced content is modified. At present there are no deep copy semantics hardcoded into the schema. The semantic of reference are normally identical to an idType (e.g. "a123b"). Howevere there are some cases where compound references are required, such as "a123b:pq456". It is likely that this will be superseded at by RDF or Xpointer, but as long as we have non-uniqueIds this is a problem Type of relatedEntry. Type represents a the type of relationship in a relatedEntry element. instruction to create repeat of the object. The attribute contains an index, its start value (normally 1) and its end value as in "i 3 10" which would make 8 repeat of the object. In selected attribute values the string _i_ acts as a macro and would be replaced by the value of i. EXPERIMENTAL. It can also have variables as the values. 2006-05-20: PMR added. The sequence of steps in a reactionList. By default the reactions in a reactionStepList are assumed to take place in sequence (e.g. one or more products of reaction n are used in reaction n+1 or later. However there are cases where it is known that reactions take place in parallel (e.g. if there is no overlap of molecular identities). Alternatively there are points at which there are two or more competing reactions which may depend on conditions or concentrations. A small semi-controlled vocabulary is suggested. The order of the steps is unknow. The reaction proceeds through the steps in the order give. The reaction may proceed through either of the contained reactions or reactionScheme. The two or more independent reaction/List children proceed independently. This can be extended to synthetic chemistry where two parts of the synthesis are conducted in parallel. Allowed shapes of arrayList. Rectangular, triangular or irregular. Rectangular. Triangular decreasing in size from ncols to 1. Triangular increasing in size from 1 to ncols. Irregular shape. User-defined arrayList-type. This definition must be by reference to a namespaced dictionary entry. The size of an array. The size of an array. Redundant, but serves as a check for processing software (useful if delimiters are used). Signifies real or reciprocal space. Likely to be used on types such as lattice, plane, point. A synonym for reciprocal. A synonym for reciprocal. User-defined space-type. No obvious possibilities, but who know. The type of the spectrum. An infrared spectrum. The measurement should denote transmittance or absorbanc. A "simple" mass spectrum. This excludes experiments such as GC/MS, MS/MS, etc. though these could be constructed out of individual spectra with some care. The spectrum may be continuous ( data or a peakList). An NMR spectrum. This can include any experiment which creates a "1D" or "2D" data array. The symmetry of the spectrum can be specified but the details of the NMR experiment (COSY, NOESY, etc.) are not part of CMLSpect. They can be described though the normal dictRef mechanism. A spectrum somewhere in the UV VIS region of the spectrum. The measurement should denote transmittance or absorbance. A sphere in 3-space. Defined by 4 real numbers, conventionally a point3 at the centre of the sphere and a nonNegative scalar for the radius. State of a substance or property. The state(s) of matter appropriate to a substance or property. It follows a partially controlled vocabulary. It can be extended through namespace codes to dictionaries. An aqueous solutio. Gas or vapor. The default state for computation on isolated molecule. A glassy stat. Normally pure liquid (use solution where appropriate. The nematic phas. The smectic phas. A soli. A solid solutio. A (liquid) solutio. Bond stereochemistry as a string. This is purely conventional. There is no default value. The emptyString attribute can be used to indicate a bond of unknown or unspecified type. The interpretation of this is outside the scope of CML-based algorithms. It may be accompanied by a convention attribute which links to a dictionary. A cis bond. A trans bond. A wedge bond. A hatch bond. empty or missing. An array of strings, separated by whitespace. An array of strings, separated by whitespace. If the strings have embedded whitespace or may be empty (zero-length), a non-whitespace single-character delimiter must be used. At present no machine validation Type of the substanceList. Extension is allowed through the "other" value. Allowed types of table. rowBased, arrayBased, contentBased. 2006-11-03: formlized 3 table types rowBased. Based on child arrayList containing arrays or lists child tableContent User-defined table-type. This definition must be by reference to a namespaced dictionary entry. The tail linker in a polymeric repeat unit A polymeric chain may be described by liniing the tail of one repeat unit to the head or tail of another. The tail attribute indicates the atom id (normally on an atom of elementType="R") which acts as the tail 2006-05-20: PMR added The type of a torsion angle. Type of unitList. Required to differentiate between the two types of unitList (units and unitTypes) child elements are unit child elements are unitType Scientific units. These will be linked to dictionaries of units with conversion information, using namespaced references (e.g. si:m). Distinguish carefully from _unitType_ which is an element describing a type of a unit in a _unitList_. A vector in 3-space. No constraints on magnitude (i.e. could be zero. Version of a document or code. Forms include 1, 0.9, 1.1.3, 1.2alpha, etc. The name of an XMLElement. (Distinguish from a chemical element as in elementTypeType). Currently used for assigning XMLElement types to references (e.g. to='a1' toType='atom'). Semantics are not controlled and in principle elements outside the CML tagSet could be used. Implementers cannot assume that namespace prefixes can be resolved and default usage is probably the local name. cmlxom-cmlxom-4.11/src/main/resources/org/xmlcml/molutil/000077500000000000000000000000001477224461000235375ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/main/resources/org/xmlcml/molutil/elementdata.xml000077500000000000000000004247211477224461000265610ustar00rootroot00000000000000 0.000 0.000 0.000 0 0.000 0.00 0.000 0.000 0.000 0 0.000 0.00 1 3.016049 1s1 1 2.01355 1s1 0.230 0.330 1.200 1 1.00794 2.10 1.00794 1s1 25 53 37 120 2.20 0.930 0.700 1.400 0 4.002602 0.00 4.002602 1s2 31 32 140 0.680 1.230 1.820 1 6.941 0.98 6.941 [He].2s1 145 167 134 182 0.98 0.350 0.900 1.700 2 9.012182 1.57 9.012182 [He].2s2 105 112 90 1.57 0.830 0.820 2.080 3 10.811 2.04 10.811 [He].2s2.2p1 85 87 82 2.04 0.680 0.770 1.950 4 12.0107 2.55 12.0107 [He].2s2.2p2 70 67 77 170 2.55 0.680 0.700 1.850 4 14.0067 3.04 14.0067 [He].2s2.2p3 65 56 75 155 3.04 0.680 0.660 1.700 2 15.9994 3.44 15.9994 [He].2s2.2p4 60 48 73 152 3.44 0.640 0.611 1.730 1 18.9984032 3.98 18.9984032 [He].2s2.2p5 50 42 71 147 3.98 1.120 0.700 1.540 0 20.1797 0.00 20.1797 [He].2s2.2p6 38 69 154 0.970 1.540 2.270 1 22.989770 0.93 22.989770 [Ne].3s1 180 190 154 227 0.93 1.100 1.360 1.730 2 24.3050 1.31 24.3050 [Ne].3s2 150 145 130 173 1.31 1.350 1.180 2.050 6 26.981538 1.61 26.981538 [Ne].3s2.3p1 125 118 118 1.61 1.200 0.937 2.100 6 28.0855 1.90 28.0855 [Ne].3s2.3p2 110 111 111 210 1.90 1.100 0.890 2.080 5 30.973761 2.19 30.973761 [Ne].3s2.3p3 100 98 106 180 2.19 1.020 1.040 2.000 6 32.065 2.58 32.065 [Ne].3s2.3p4 100 88 102 180 2.58 0.990 0.997 1.970 1 35.453 3.16 35.453 [Ne].3s2.3p5 100 79 99 175 3.16 1.570 1.740 1.880 0 39.948 0.00 39.948 [Ne].3s2.3p6 71 97 188 1.330 2.030 2.750 1 39.0983 0.82 39.0983 [Ar].4s1 220 243 196 275 0.82 0.990 1.740 1.973 2 40.078 1.00 40.078 [Ar].4s2 180 194 174 1.00 1.440 1.440 1.700 6 44.955910 1.36 44.955910 [Ar].3d1.4s2 160 184 144 1.36 1.470 1.320 1.700 6 47.867 1.54 47.867 [Ar].3d2.4s2 140 176 136 1.54 1.330 1.220 1.700 6 50.9415 1.63 50.9415 [Ar].3d3.4s2 135 171 125 1.63 1.350 1.180 1.700 6 51.9961 1.66 51.9961 [Ar].3d5.4s1 140 166 127 1.66 1.350 1.170 1.700 8 54.938049 1.55 54.938049 [Ar].3d5.4s2 140 161 139 1.55 1.340 1.170 1.700 6 55.845 1.83 55.845 [Ar].3d6.4s2 140 156 125 1.83 1.330 1.160 1.700 6 58.933200 1.88 58.933200 [Ar].3d7.4s2 135 152 126 1.88 1.500 1.150 1.630 6 58.6934 1.91 58.6934 [Ar].3d8.4s2 135 149 121 163 1.91 1.520 1.170 1.400 6 63.546 1.90 63.546 [Ar].3d10.4s1 135 145 138 140 1.90 1.450 1.250 1.390 6 65.409 1.65 65.409 [Ar].3d10.4s2 135 142 131 139 1.65 1.220 1.260 1.870 3 69.723 1.81 69.723 [Ar].3d10.4s2.4p1 130 136 126 187 1.81 1.170 1.188 1.700 4 72.64 2.01 72.64 [Ar].3d10.4s2.4p2 125 125 122 2.01 1.210 1.200 1.850 3 74.92160 2.18 74.92160 [Ar].3d10.4s2.4p3 115 114 119 185 2.18 1.220 1.170 1.900 2 78.96 2.55 78.96 [Ar].3d10.4s2.4p4 115 103 116 190 2.55 1.210 1.167 2.100 1 79.904 2.96 79.904 [Ar].3d10.4s2.4p5 115 94 114 185 2.96 1.910 1.910 2.020 0 83.798 0.00 83.798 [Ar].3d10.4s2.4p6 88 110 202 3.00 1.470 2.160 1.700 1 85.4678 0.82 85.4678 [Kr].5s1 235 265 211 0.82 1.120 1.910 1.700 2 87.62 0.95 87.62 [Kr].5s2 200 219 192 0.95 1.780 1.620 1.700 6 88.90585 1.22 88.90585 [Kr].4d1.5s2 180 212 162 1.22 1.560 1.450 1.700 6 91.224 1.33 91.224 [Kr].4d2.5s2 155 206 148 1.33 1.480 1.340 1.700 6 92.90638 1.6 92.90638 [Kr].4d4.5s1 145 198 137 1.6 1.470 1.300 1.700 6 95.94 2.16 95.94 [Kr].4d5.5s1 145 190 145 2.16 1.350 1.270 1.700 6 98 1.9 98 [Kr].4d6.5s1 135 183 156 1.9 1.400 1.250 1.700 6 101.07 2.2 101.07 [Kr].4d75s1 130 178 126 2.2 1.450 1.250 1.700 6 102.90550 2.28 102.90550 [Kr].4d85s1 135 173 135 2.28 1.500 1.280 1.630 6 106.42 2.20 106.42 [Kr].4d10 140 169 131 163 2.20 1.590 1.340 1.720 6 107.8682 1.93 107.8682 [Kr].4d10.5s1 160 165 153 172 1.93 1.690 1.480 1.580 6 112.411 1.69 112.411 [Kr].4d10.5s2 155 161 148 158 1.69 1.630 1.440 1.930 3 114.818 1.78 114.818 [Kr].4d10.5s2.5p1 155 156 144 193 1.78 1.460 1.385 2.170 4 118.710 1.96 118.710 [Kr].4d10.5s2.5p2 145 145 141 217 1.96 1.460 1.400 2.200 3 121.760 2.05 121.760 [Kr].4d10.5s2.5p3 145 133 138 2.05 1.470 1.378 2.060 2 127.60 2.1 127.60 [Kr].4d10.5s2.5p4 140 123 135 206 2.1 1.400 1.387 2.150 1 126.90447 2.66 126.90447 [Kr].4d10.5s2.5p5 140 115 133 198 2.66 1.980 1.980 2.160 0 131.293 2.6 131.293 [Kr].4d10.5s2.5p6 108 130 216 2.6 1.670 2.350 1.700 1 132.90545 0.79 132.90545 [Xe].6s1 260 298 225 0.79 1.340 1.980 1.700 2 137.327 0.89 137.327 [Xe].6s2 215 253 198 0.89 1.870 1.690 1.700 12 138.9055 1.10 138.9055 138.9055 [Xe].5d1.6s2 195 169 1.10 1.830 1.830 1.700 6 140.116 1.12 140.116 140.116 [Xe].4f1.5d1.6s2 185 1.12 1.820 1.820 1.700 6 140.90765 1.13 140.90765 140.90765 [Xe].4f3.6s2 185 247 1.13 1.810 1.810 1.700 6 144.24 1.14 144.24 144.24 [Xe].4f4.6s2 185 206 1.14 1.800 1.800 1.700 6 145 1.13 145 145 [Xe].4f5.6s2 185 205 1.800 1.800 1.700 6 150.36 1.17 150.36 150.36 [Xe].4f6.6s2 185 238 1.17 1.990 1.990 1.700 6 151.964 1.2 151.964 151.964 [Xe].4f7.6s2 185 231 1.790 1.790 1.700 6 157.25 1.20 157.25 157.25 [Xe].4f7.5d1.6s2 180 233 1.20 1.760 1.760 1.700 6 158.92534 1.1 158.92534 158.92534 [Xe].4f9.6s2 175 225 1.750 1.750 1.700 6 162.500 1.22 162.500 162.500 [Xe].4f10.6s2 175 228 1.22 1.740 1.740 1.700 6 164.93032 1.23 164.93032 164.93032 [Xe].4f11.6s2 175 226 1.23 1.730 1.730 1.700 6 167.259 1.24 167.259 167.259 [Xe].4f12.6s2 175 226 1.24 1.720 1.720 1.700 6 168.93421 1.25 168.93421 168.93421 [Xe].4f13.6s2 175 222 1.25 1.940 1.940 1.700 6 173.04 1.1 173.04 173.04 [Xe].4f14.6s2 175 222 1.720 1.720 1.700 6 174.967 1.27 174.967 [Xe].4f14.5d1.6s2 175 217 160 1.27 1.570 1.440 1.700 6 178.49 1.3 178.49 [Xe].4f14.5d2.6s2 155 208 150 1.3 1.430 1.340 1.700 6 180.9479 1.5 180.9479 [Xe].4f14.5d3.6s2 145 200 138 1.5 1.370 1.300 1.700 6 183.84 2.36 183.84 [Xe].4f14.5d4.6s2 135 193 146 2.36 1.350 1.280 1.700 6 186.207 1.9 186.207 [Xe].4f14.5d5.6s2 135 188 159 1.9 1.370 1.260 1.700 6 190.23 2.2 190.23 [Xe].4f14.5d6.6s2 130 185 128 2.2 1.320 1.270 1.700 6 192.217 2.20 192.217 [Xe].4f14.5d7.6s2 135 180 137 2.20 1.500 1.300 1.720 6 195.078 2.28 195.078 [Xe].4f14.5d9.6s1 135 177 128 175 2.28 1.500 1.340 1.660 6 196.96655 2.54 196.96655 [Xe].4f14.5d10.6s1 135 174 144 166 2.54 1.700 1.490 1.550 6 200.59 2.00 200.59 [Xe].4f14.5d10.6s2 150 171 149 155 2.00 1.550 1.480 1.960 3 204.3833 2.04 204.3833 [Xe].4f14.5d10.6s2.6p1 190 156 148 196 1.62 1.540 1.480 2.020 4 207.2 2.33 207.2 [Xe].4f14.5d10.6s2.6p2 180 154 147 202 2.33 1.540 1.450 1.700 3 208.98038 2.02 208.98038 [Xe].4f14.5d10.6s2.6p3 160 143 146 2.02 1.680 1.460 1.700 2 209 2.0 209 [Xe].4f14.5d10.6s2.6p4 190 135 2.0 1.700 1.450 1.700 1 210 2.2 210 [Xe].4f14.5d10.6s2.6p5 127 2.2 2.400 2.400 1.700 0 222 0.0 222 [Xe].4f14.5d10.6s2.6p6 120 145 2.000 2.000 1.700 1 223 0.7 223 [Rn].7s1 0.7 1.900 1.900 1.700 2 226 0.89 226 [Rn].7s2 215 0.9 1.880 1.880 1.700 6 227 1.1 227 227 [Rn].6d1.7s2 195 1.1 1.790 1.790 1.700 6 232.0381 1.3 232.0381 232.0381 [Rn].6d2.7s2 180 1.3 1.610 1.610 1.700 6 231.03588 1.5 231.03588 231.03588 [Rn].5f2.6d1.7s2 180 1.5 1.580 1.580 1.860 6 238.02891 1.38 238.02891 238.02891 [Rn].5f3.6d1.7s2 175 186 1.38 1.550 1.550 1.700 6 237 1.36 237 237 [Rn].5f4.6d1.7s2 175 1.36 1.530 1.530 1.700 6 244 1.28 244 244 [Rn].5f6.7s2 175 1.28 1.510 1.070 1.700 6 243 1.3 243 243 [Rn].5f7.7s2 175 1.3 1.500 0.000 1.700 6 247 1.3 247 247 [Rn].5f7.6d1.7s2 1.3 1.500 0.000 1.700 6 247 1.3 247 247 [Rn].5f9.7s2 1.3 1.500 0.000 1.700 6 251 1.3 251 251 [Rn].5f10.7s2 1.3 1.500 0.000 1.700 6 252 1.3 252 252 [Rn].5f11.7s2 1.3 1.500 0.000 1.700 6 257 1.3 257 257 [Rn].5f12.7s2 1.3 1.500 0.000 1.700 6 258 1.3 258 258 [Rn].5f13.7s2 1.3 1.500 0.000 1.700 6 259 1.3 259 259 [Rn].5f14.7s2 1.3 1.500 0.000 1.700 6 262 1.3 262 [Rn].5f14.7s2.7p1 1.600 0.000 1.700 6 261 0.0 261 [Rn].5f14.6d2.7s2 1.600 0.000 1.700 6 262 0.0 262 [Rn].5f14.6d3.7s2 1.600 0.000 1.700 6 263 0.0 266 [Rn].5f14.6d4.7s2 1.600 0.000 1.700 6 264 0.0 264 [Rn].5f14.6d5.7s2 1.600 0.000 1.700 6 265 0.0 269 [Rn].5f14.6d6.7s2 1.600 0.000 1.700 6 268 0.0 268 [Rn].5f14.6d7.7s2 271 [Rn].5f14.6d9.7s1 272 [Rn].5f14.6d10.7s1 285 [Rn].5f14.6d10.7s2 284 [Rn].5f14.6d10.7s2.7p1 289 [Rn].5f14.6d10.7s2.7p2 288 [Rn].5f14.6d10.7s2.7p3 292 [Rn].5f14.6d10.7s2.7p4 cmlxom-cmlxom-4.11/src/test/000077500000000000000000000000001477224461000160105ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/java/000077500000000000000000000000001477224461000167315ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/java/org/000077500000000000000000000000001477224461000175205ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/000077500000000000000000000000001477224461000210145ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/000077500000000000000000000000001477224461000215675ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/attribute/000077500000000000000000000000001477224461000235725ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/attribute/CountExpressionAttributeAdapterTest.java000077500000000000000000000063521477224461000336430ustar00rootroot00000000000000/** * 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.attribute; import nu.xom.Attribute; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLFragment; import org.xmlcml.cml.element.CMLJoin; public class CountExpressionAttributeAdapterTest { @Test public void testSetCMLValue() { String s = ""; CMLJoin join = (CMLJoin) CMLXOMTestUtils.parseValidString(s); Attribute att = join.getAttribute("countExpression"); CountExpressionAttributeAdapter ceaa = new CountExpressionAttributeAdapter(att); ceaa.setCMLValue("*(5)"); int ii = ceaa.calculateCountExpression(); Assert.assertEquals("calculated value", 5, ii); } @Test public void testCalculateCountExpression() { String s = ""; CMLJoin join = (CMLJoin) CMLXOMTestUtils.parseValidString(s); Attribute att = join.getAttribute("countExpression"); CountExpressionAttributeAdapter ceaa = new CountExpressionAttributeAdapter(att); ceaa = new CountExpressionAttributeAdapter(att); int ii = ceaa.calculateCountExpression(); Assert.assertTrue("calculated value", ii < 6 && ii > 2); } @Test public void testUsageOnFragment() { String s = ""; CMLFragment fragment = (CMLFragment) CMLXOMTestUtils.parseValidString(s); Attribute att = fragment.getAttribute("countExpression"); CountExpressionAttributeAdapter ceaa = new CountExpressionAttributeAdapter(att); ceaa.setCMLValue("*(5)"); int ii = ceaa.calculateCountExpression(); Assert.assertEquals("calculated value", 5, ii); } @Test public void testGetRange() { String s = ""; CMLJoin join = (CMLJoin) CMLXOMTestUtils.parseValidString(s); Attribute att = join.getAttribute("countExpression"); CountExpressionAttributeAdapter ceaa = new CountExpressionAttributeAdapter(att); int [] range = ceaa.getRange(); Assert.assertEquals(2, range.length); Assert.assertEquals(4, range[0]); Assert.assertEquals(8, range[1]); String s2 = ""; CMLJoin join2 = (CMLJoin) CMLXOMTestUtils.parseValidString(s2); Attribute att2 = join2.getAttribute("countExpression"); CountExpressionAttributeAdapter ceaa2 = new CountExpressionAttributeAdapter(att2); range = ceaa2.getRange(); Assert.assertNull(range); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/attribute/DelimiterAttributeTest.java000077500000000000000000000314361477224461000311110ustar00rootroot00000000000000/** * 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.attribute; import nu.xom.Attribute; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.euclid.EC; import org.xmlcml.euclid.test.StringTestBase; /** * test * * @author pm286 * */ public class DelimiterAttributeTest { /** * set up * * @throws Exception */ @Before public void setUp() throws Exception { } /** dewisott */ @Test public final void testSetCMLValue() { DelimiterAttribute delimiterAttribute = new DelimiterAttribute(); delimiterAttribute.setCMLValue(EC.S_SLASH); Assert.assertEquals("simple delim ", EC.S_SLASH, delimiterAttribute .getConcat()); } /** dewisott */ @Test public final void testDelimiterAttribute() { DelimiterAttribute delimiterAttribute = new DelimiterAttribute(); Assert.assertNull("simple concat ", delimiterAttribute.getConcat()); Assert.assertNotNull("simple delim ", delimiterAttribute.getCMLValue()); Assert.assertEquals("simple delim ", EC.S_EMPTY, delimiterAttribute .getCMLValue()); Assert.assertNull("simple splitter ", delimiterAttribute.getSplitter()); } /** dewisott */ @Test public final void testDelimiterAttributeString() { DelimiterAttribute delimiterAttribute = new DelimiterAttribute(EC.S_SLASH); Assert.assertEquals("concat ", EC.S_SLASH, delimiterAttribute.getConcat()); Assert .assertEquals("delim ", EC.S_SLASH, delimiterAttribute .getCMLValue()); Assert.assertEquals("splitter ", EC.S_SLASH, delimiterAttribute .getSplitter()); delimiterAttribute = new DelimiterAttribute(EC.S_EMPTY); Assert.assertEquals("concat ", EC.S_SPACE, delimiterAttribute.getConcat()); Assert .assertEquals("delim ", EC.S_EMPTY, delimiterAttribute .getCMLValue()); Assert.assertEquals("splitter ", EC.S_WHITEREGEX, delimiterAttribute .getSplitter()); delimiterAttribute = new DelimiterAttribute(EC.S_SPACE); Assert.assertEquals("concat ", EC.S_SPACE, delimiterAttribute.getConcat()); Assert .assertEquals("delim ", EC.S_EMPTY, delimiterAttribute .getCMLValue()); Assert.assertEquals("splitter ", EC.S_WHITEREGEX, delimiterAttribute .getSplitter()); delimiterAttribute = new DelimiterAttribute(EC.S_SPACE + EC.S_NL + EC.S_TAB); Assert.assertEquals("concat ", EC.S_SPACE, delimiterAttribute.getConcat()); Assert .assertEquals("delim ", EC.S_EMPTY, delimiterAttribute .getCMLValue()); Assert.assertEquals("splitter ", EC.S_WHITEREGEX, delimiterAttribute .getSplitter()); delimiterAttribute = new DelimiterAttribute(EC.S_PIPE); Assert.assertEquals("concat ", EC.S_PIPE, delimiterAttribute.getConcat()); Assert.assertEquals("delim ", EC.S_PIPE, delimiterAttribute.getCMLValue()); Assert.assertEquals("splitter ", "\\|", delimiterAttribute .getSplitter()); } /** */ @Test public final void testDelimiterAttributeAttribute() { Attribute att = new Attribute(DelimiterAttribute.NAME, EC.S_SLASH); DelimiterAttribute delimiterAttribute = new DelimiterAttribute(att); Assert.assertEquals("concat ", EC.S_SLASH, delimiterAttribute.getConcat()); Assert .assertEquals("delim ", EC.S_SLASH, delimiterAttribute .getCMLValue()); Assert.assertEquals("splitter ", EC.S_SLASH, delimiterAttribute .getSplitter()); att = new Attribute(DelimiterAttribute.NAME, EC.S_EMPTY); delimiterAttribute = new DelimiterAttribute(att); Assert.assertEquals("concat ", EC.S_SPACE, delimiterAttribute.getConcat()); Assert .assertEquals("delim ", EC.S_EMPTY, delimiterAttribute .getCMLValue()); Assert.assertEquals("splitter ", EC.S_WHITEREGEX, delimiterAttribute .getSplitter()); } /** */ @Test public final void testGetSplitContent() { DelimiterAttribute delimiterAttribute = new DelimiterAttribute(EC.S_SLASH); Assert.assertEquals("concat ", EC.S_SLASH, delimiterAttribute.getConcat()); Assert .assertEquals("delim ", EC.S_SLASH, delimiterAttribute .getCMLValue()); Assert.assertEquals("splitter ", EC.S_SLASH, delimiterAttribute .getSplitter()); String content = "/1/2/3/4/5/"; String[] ss = delimiterAttribute.getSplitContent(content); String[] sss = new String[] { "1", "2", "3", "4", "5" }; StringTestBase.assertEquals("split ", sss, ss); content = "1/2/3/4/5/"; ss = delimiterAttribute.getSplitContent(content); StringTestBase.assertEquals("split ", sss, ss); content = "1/2/3/4/5"; ss = delimiterAttribute.getSplitContent(content); StringTestBase.assertEquals("split ", sss, ss); content = "/1/2/3/4/5"; ss = delimiterAttribute.getSplitContent(content); StringTestBase.assertEquals("split ", sss, ss); content = "/1/2/3/4//5"; sss = new String[] { "1", "2", "3", "4", "", "5" }; ss = delimiterAttribute.getSplitContent(content); StringTestBase.assertEquals("split ", sss, ss); content = "//1/2/3/4//5"; sss = new String[] { "", "1", "2", "3", "4", "", "5" }; ss = delimiterAttribute.getSplitContent(content); StringTestBase.assertEquals("split ", sss, ss); delimiterAttribute = new DelimiterAttribute(EC.S_SPACE); Assert.assertEquals("concat ", EC.S_SPACE, delimiterAttribute.getConcat()); Assert .assertEquals("delim ", EC.S_EMPTY, delimiterAttribute .getCMLValue()); Assert.assertEquals("splitter ", EC.S_WHITEREGEX, delimiterAttribute .getSplitter()); content = "1 2 3 4 5"; sss = new String[] { "1", "2", "3", "4", "5" }; ss = delimiterAttribute.getSplitContent(content); StringTestBase.assertEquals("split ", sss, ss); content = " 1 2 3\n 4 \t 5 "; sss = new String[] { "1", "2", "3", "4", "5" }; ss = delimiterAttribute.getSplitContent(content); StringTestBase.assertEquals("split ", sss, ss); } /** */ @Test public final void testCheckDelimiter() { DelimiterAttribute delimiterAttribute = new DelimiterAttribute(EC.S_SLASH); Assert.assertEquals("concat ", EC.S_SLASH, delimiterAttribute.getConcat()); Assert .assertEquals("delim ", EC.S_SLASH, delimiterAttribute .getCMLValue()); Assert.assertEquals("splitter ", EC.S_SLASH, delimiterAttribute .getSplitter()); String s = "123"; try { delimiterAttribute.checkDelimiter(s); } catch (RuntimeException e) { Assert.fail("Should not throw " + e); } s = "1/23"; try { delimiterAttribute.checkDelimiter(s); Assert.fail("Should throw exception"); } catch (RuntimeException e) { Assert.assertEquals("Should throw ", "cannot delimit {1/23} with {/}", e.getMessage()); } delimiterAttribute = new DelimiterAttribute(EC.S_SPACE); Assert.assertEquals("concat ", EC.S_SPACE, delimiterAttribute.getConcat()); Assert .assertEquals("delim ", EC.S_EMPTY, delimiterAttribute .getCMLValue()); Assert.assertEquals("splitter ", EC.S_WHITEREGEX, delimiterAttribute .getSplitter()); s = "123"; try { delimiterAttribute.checkDelimiter(s); } catch (RuntimeException e) { Assert.fail("Should not throw " + e); } s = ""; try { delimiterAttribute.checkDelimiter(s); } catch (RuntimeException e) { Assert.fail("Should not throw " + e); } s = " 123 "; try { delimiterAttribute.checkDelimiter(s); Assert.fail("Should throw exception"); } catch (RuntimeException e) { Assert.assertEquals("Should throw ", "cannot delimit { 123 } with { }", e.getMessage()); } s = "1 23"; try { delimiterAttribute.checkDelimiter(s); Assert.fail("Should throw exception"); } catch (RuntimeException e) { Assert.assertEquals("Should throw ", "cannot delimit {1 23} with { }", e.getMessage()); } } /** */ @Test public final void testGetDelimitedXMLContentString() { DelimiterAttribute delimiterAttribute = new DelimiterAttribute(EC.S_SLASH); Assert.assertEquals("concat ", EC.S_SLASH, delimiterAttribute.getConcat()); Assert .assertEquals("delim ", EC.S_SLASH, delimiterAttribute .getCMLValue()); Assert.assertEquals("splitter ", EC.S_SLASH, delimiterAttribute .getSplitter()); String s = "1/2/3/"; s = delimiterAttribute.getDelimitedXMLContent(s); Assert.assertEquals("delimit content ", "/1/2/3/", s); s = ""; s = delimiterAttribute.getDelimitedXMLContent(s); Assert.assertEquals("delimit content ", EC.S_EMPTY, s); s = "/1/2/3/"; s = delimiterAttribute.getDelimitedXMLContent(s); Assert.assertEquals("delimit content ", "/1/2/3/", s); s = "//"; s = delimiterAttribute.getDelimitedXMLContent(s); Assert.assertEquals("delimit content ", "//", s); s = "/"; s = delimiterAttribute.getDelimitedXMLContent(s); Assert.assertEquals("delimit content ", "/", s); s = " "; s = delimiterAttribute.getDelimitedXMLContent(s); Assert.assertEquals("delimit content ", "/ /", s); } /** */ @Test public final void testAppendXMLContent() { DelimiterAttribute delimiterAttribute = new DelimiterAttribute(EC.S_SLASH); Assert.assertEquals("concat ", EC.S_SLASH, delimiterAttribute.getConcat()); Assert .assertEquals("delim ", EC.S_SLASH, delimiterAttribute .getCMLValue()); Assert.assertEquals("splitter ", EC.S_SLASH, delimiterAttribute .getSplitter()); String s = "1/2/3/"; s = delimiterAttribute.appendXMLContent(s, "x"); Assert.assertEquals("append content ", "/1/2/3/x/", s); s = ""; s = delimiterAttribute.appendXMLContent(s, "x"); Assert.assertEquals("append content ", "/x/", s); s = "/1/2/3//"; s = delimiterAttribute.appendXMLContent(s, "x"); Assert.assertEquals("append content ", "/1/2/3//x/", s); } /** */ @Test public final void testGetDelimitedXMLContentStringArray() { DelimiterAttribute delimiterAttribute = new DelimiterAttribute(EC.S_SLASH); Assert.assertEquals("concat ", EC.S_SLASH, delimiterAttribute.getConcat()); Assert .assertEquals("delim ", EC.S_SLASH, delimiterAttribute .getCMLValue()); Assert.assertEquals("splitter ", EC.S_SLASH, delimiterAttribute .getSplitter()); String[] ss = new String[] { "a", "b", "c" }; String s = delimiterAttribute.getDelimitedXMLContent(ss); Assert.assertEquals("append content ", "/a/b/c/", s); ss = new String[] { "a ", "", "b", "c" }; s = delimiterAttribute.getDelimitedXMLContent(ss); Assert.assertEquals("append content ", "/a //b/c/", s); delimiterAttribute = new DelimiterAttribute(EC.S_PIPE); Assert.assertEquals("concat ", EC.S_PIPE, delimiterAttribute.getConcat()); Assert.assertEquals("delim ", EC.S_PIPE, delimiterAttribute.getCMLValue()); Assert.assertEquals("splitter ", EC.S_BACKSLASH + EC.S_PIPE, delimiterAttribute.getSplitter()); ss = new String[] { "O1", "O2" }; s = delimiterAttribute.getDelimitedXMLContent(ss); Assert.assertEquals("append content ", "|O1|O2|", s); } /** */ @Test public final void testGetDelimitedXMLContentDoubleArray() { DelimiterAttribute delimiterAttribute = new DelimiterAttribute(EC.S_SLASH); Assert.assertEquals("concat ", EC.S_SLASH, delimiterAttribute.getConcat()); Assert .assertEquals("delim ", EC.S_SLASH, delimiterAttribute .getCMLValue()); Assert.assertEquals("splitter ", EC.S_SLASH, delimiterAttribute .getSplitter()); double[] dd = new double[] { 1.1, 2.2, 3.3 }; String s = delimiterAttribute.getDelimitedXMLContent(dd); Assert.assertEquals("append content ", "/1.1/2.2/3.3/", s); } /** */ @Test public final void testGetDelimitedXMLContentIntArray() { DelimiterAttribute delimiterAttribute = new DelimiterAttribute(EC.S_SLASH); Assert.assertEquals("concat ", EC.S_SLASH, delimiterAttribute.getConcat()); Assert .assertEquals("delim ", EC.S_SLASH, delimiterAttribute .getCMLValue()); Assert.assertEquals("splitter ", EC.S_SLASH, delimiterAttribute .getSplitter()); int[] dd = new int[] { 1, 2, 3 }; String s = delimiterAttribute.getDelimitedXMLContent(dd); Assert.assertEquals("append content ", "/1/2/3/", s); } @Test public final void testAttributeAccess(){ DelimiterAttribute delim = new DelimiterAttribute(); delim.setValue("|"); String a=(String)delim.getCMLValue(); Assert.assertEquals("|", a); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/attribute/DictRefAttributeTest.java000077500000000000000000000030511477224461000305030ustar00rootroot00000000000000/** * 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.attribute; import junit.framework.Assert; import nu.xom.Attribute; import nu.xom.Element; import org.junit.Test; public class DictRefAttributeTest { @Test public void testGetDictRefLocalValue() { Element element = new Element("e"); element.addAttribute(new Attribute(DictRefAttribute.NAME, "a:b")); String dictRef = DictRefAttribute.getLocalValue(element); Assert.assertEquals("a:b", "b", dictRef); } @Test public void testGetDictRefLocalValue1() { Element element = new Element("e"); String dictRef = DictRefAttribute.getLocalValue(element); Assert.assertNull(dictRef); } @Test public void testGetDictRefLocalValue2() { Element element = new Element("e"); element.addAttribute(new Attribute(DictRefAttribute.NAME, "b")); String dictRef = DictRefAttribute.getLocalValue(element); Assert.assertEquals("b", "b", dictRef); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/attribute/UnitTypeAttributeTest.java000077500000000000000000000030601477224461000307440ustar00rootroot00000000000000/** * 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.attribute; import junit.framework.Assert; import org.junit.Test; import org.xmlcml.cml.element.CMLEntry; public class UnitTypeAttributeTest { @Test public void testConstructer(){ UnitTypeAttribute att = new UnitTypeAttribute(); Assert.assertNotNull(att); } @Test public void testValueConstructer(){ UnitTypeAttribute att = new UnitTypeAttribute("test:Test"); Assert.assertEquals("test:Test", att.getValue()); } @Test public void testAddToEntry(){ CMLEntry entry = new CMLEntry(); entry.setUnitType("test:Test"); Assert.assertEquals("test:Test", entry.getUnitType()); } @Test public void testValueChange(){ CMLEntry entry = new CMLEntry(); entry.setUnitType("test:Test1"); entry.setUnitType("test:Test2"); Assert.assertEquals("test:Test2", entry.getUnitType()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/base/000077500000000000000000000000001477224461000225015ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/base/AttributeTest.java000077500000000000000000000166051477224461000261620ustar00rootroot00000000000000/** * 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.junit.Assert; import org.junit.Before; import org.junit.Test; /** * test for attribute. * * @author pmr * */ public class AttributeTest { CMLAttribute att1; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { att1 = new CMLAttribute("name", "value"); } /** * Test method for 'org.xmlcml.cml.base.CMLAttribute.CMLAttribute(String)' */ @Test public void testCMLAttributeString() { CMLAttribute string = new CMLAttribute("string"); Assert.assertEquals("string att", "string", string.getLocalName()); Assert.assertEquals("string att", "string", string.getQualifiedName()); Assert.assertEquals("string att", "string", string.getLocalName()); Assert.assertEquals("string att", CMLConstants.S_EMPTY, string.getValue()); Assert.assertEquals("string att", CMLConstants.S_EMPTY, string.getCMLValue()); Assert.assertEquals("string att", CMLConstants.S_EMPTY, string.getNamespaceURI()); Assert.assertEquals("string att", "String", string.getJavaType()); // Assert.assertEquals("string att", "setCMLValue", string // .getJavaSetMethod()); // Assert.assertEquals("string att", "getCMLValue", string // .getJavaGetMethod()); // Assert.assertEquals("string att", "CMLAttribute", string // .getJavaShortClassName()); Assert.assertNull("string att", string.getSchemaType()); Assert.assertNull("string att", string.getSummary()); Assert.assertNull("string att", string.getDescription()); } /** * Test method for 'org.xmlcml.cml.base.CMLAttribute.CMLAttribute(String, * String)' */ @Test public void testCMLAttributeStringString() { CMLAttribute string = new CMLAttribute("string", "a1"); Assert.assertEquals("string att", "string", string.getLocalName()); Assert.assertEquals("string att", "string", string.getQualifiedName()); Assert.assertEquals("string att", "string", string.getLocalName()); Assert.assertEquals("string att", "a1", string.getValue()); Assert.assertEquals("string att", "a1", string.getCMLValue()); Assert.assertEquals("string att", CMLConstants.S_EMPTY, string.getNamespaceURI()); Assert.assertEquals("string att", "String", string.getJavaType()); // Assert.assertEquals("string att", "setCMLValue", string // .getJavaSetMethod()); // Assert.assertEquals("string att", "getCMLValue", string // .getJavaGetMethod()); Assert.assertEquals("string att", "CMLAttribute", string .getJavaShortClassName()); Assert.assertNull("string att", string.getSchemaType()); Assert.assertNull("string att", string.getSummary()); Assert.assertNull("string att", string.getDescription()); } /** * Test method for * 'org.xmlcml.cml.base.CMLAttribute.CMLAttribute(CMLAttribute)' */ @Test public void testCMLAttributeCMLAttribute() { CMLAttribute att = new CMLAttribute(att1); Assert.assertNotNull("att copy", att); Assert.assertEquals("att copy", 0, att1.compareTo(att)); } /** * Test method for 'org.xmlcml.cml.base.CMLAttribute.copy()' */ @Test public void testCopy() { CMLAttribute att = (CMLAttribute) att1.copy(); Assert.assertNotNull("att copy", att); Assert.assertEquals("att copy", 0, att1.compareTo(att)); } /** * Test method for 'org.xmlcml.cml.base.CMLAttribute.compareTo(Attribute)' */ @Test public void testCompareTo() { CMLAttribute att = new CMLAttribute(att1); Assert.assertEquals("compare", "name", att.getLocalName()); Assert.assertEquals("compare", "value", att.getValue()); Assert.assertEquals("compare", 0, att.compareTo(att1)); } /** * Test method for 'org.xmlcml.cml.base.CMLAttribute.setSchemaType(String)' */ @Test public void testGetSetSchemaType() { // test CMLType CMLType st = new CMLType(); String namex = "formalChargeType"; st.setName(namex); st.setBase("xsd:integer"); st.setId("st.formalChargeType"); st.setSummary("The formal charge on an object."); st .setDescription("Used for electron-bookeeping. This has no relation to its calculated (fractional) charge or oxidation state."); Assert.assertNull("schema type", att1.getSchemaType()); att1.setSchemaType(st); CMLType fc = att1.getSchemaType(); Assert.assertNotNull("schema type fc", fc); Assert.assertEquals("schema type fc", "formalChargeType", fc.getName()); Assert.assertEquals("schema type fc", CC.XSD_INTEGER, fc.getBase()); } /** * Test method for 'org.xmlcml.cml.base.CMLAttribute.getCMLValue()' */ @Test public void testGetCMLValue() { } /** * Test method for 'org.xmlcml.cml.base.CMLAttribute.setCMLValue(String)' */ @Test public void testSetCMLValue() { } /** * Test method for * 'org.xmlcml.cml.base.CMLAttribute.createSubclassedAttribute(Attribute, * String)' */ @Test public void testCreateSubclassedAttribute() { // this is used in copy... } /** * Test method for 'org.xmlcml.cml.base.CMLAttribute.getSummary()' */ @Test public void testGetSetDocumentation() { Assert.assertNull("doc", att1.getSummary()); Assert.assertNull("doc", att1.getDescription()); att1.setSummary("the x2 coordinate"); att1 .setDescription("x2 is the 2D coordinate in arbitrary units.\n it should always be accompanied by y2"); // note added period Assert.assertEquals("doc", "the x2 coordinate" + CMLConstants.S_PERIOD, att1 .getSummary()); Assert .assertEquals( "doc", "x2 is the 2D coordinate in arbitrary units.\n it should always be accompanied by y2", att1.getDescription()); att1.setSummary("the y2 coordinate."); att1 .setDescription("y2 is the 2D coordinate in arbitrary units.\n it should always be accompanied by x2"); // note added period Assert.assertEquals("doc", "the y2 coordinate.", att1.getSummary()); Assert .assertEquals( "doc", "y2 is the 2D coordinate in arbitrary units.\n it should always be accompanied by x2", att1.getDescription()); } /** * Test method for 'nu.xom.Attribute.getNamespacePrefix()' */ @Test public void testGetSetNamespace() { Assert.assertEquals("namespace", CMLConstants.S_EMPTY, att1.getNamespacePrefix()); att1.setNamespace("xyz", "http://foo"); Assert.assertEquals("namespace", "xyz", att1.getNamespacePrefix()); Assert.assertEquals("namespace", "http://foo", att1.getNamespaceURI()); att1.setNamespace("xyz", "http://bar"); Assert.assertEquals("namespace", "xyz", att1.getNamespacePrefix()); Assert.assertEquals("namespace", "http://bar", att1.getNamespaceURI()); att1.setNamespace("abc", "http://bar"); Assert.assertEquals("namespace", "abc", att1.getNamespacePrefix()); Assert.assertEquals("namespace", "http://bar", att1.getNamespaceURI()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/base/BaseTestTest.java000077500000000000000000000025631477224461000257270ustar00rootroot00000000000000/** * 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.Element; import org.junit.Assert; import org.junit.Test; public class BaseTestTest { @Test public void testAssertEqualsIncludingFloat() { String s1 = "3.45"; String s2 = "3.452"; Element e1 =CMLXOMTestUtils.parseValidString(s1); Element e2 =CMLXOMTestUtils.parseValidString(s2); CMLXOMTestUtils.assertNotEqualsCanonically("ok", e1, e2); CMLXOMTestUtils.assertEqualsIncludingFloat("ok", e1, e2, true, 0.01); try { CMLXOMTestUtils.assertEqualsIncludingFloat("ok", e1, e2, true, 0.001, false); Assert.fail("should throw non-equality"); } catch (Throwable t) { } } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/base/CMLSchemaValidatorTest.java000077500000000000000000000034051477224461000276130ustar00rootroot00000000000000/** * 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.StringReader; import org.junit.Assert; import org.junit.Test; /** * @author pm286 * */ public class CMLSchemaValidatorTest { // /** // * // * @throws IOException // */ // @Test // @ I gnore // this is a mess anyway // public void testCMLSchemaValidatorSuccess() throws IOException { // String cml = ""; // try { // CMLSchemaValidator.getInstance().validateCML(new StringReader(cml)); // } catch (CMLException e) { // Assert.fail("failed to validate"+e); // } // } /** * @exception IOException */ @Test public void testCMLSchemaValidatorFailure() throws IOException { String cml = ""; try { CMLSchemaValidator.getInstance().validateCML(new StringReader(cml)); Assert.fail("failed to validate"); } catch (Exception e) { // PASS } } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/base/CMLUtilTest.java000077500000000000000000000555461477224461000254770ustar00rootroot00000000000000/** * 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.File; import java.io.IOException; import java.io.StringReader; import java.text.ParseException; import java.util.List; import nu.xom.Attribute; import nu.xom.Builder; import nu.xom.Document; import nu.xom.Element; import nu.xom.Elements; import nu.xom.Node; import nu.xom.Text; import nu.xom.XPathContext; import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.element.CMLCml; import org.xmlcml.euclid.EC; import org.xmlcml.euclid.Util; /** * test CMLUtil. * * @author pm286 * */ public class CMLUtilTest { private static Logger LOG = Logger.getLogger(CMLUtilTest.class); static { LOG.setLevel(Level.DEBUG); } /** * Test method for 'org.xmlcml.cml.base.CMLUtil.checkPrefixedName(String)' */ @Test public final void testCheckPrefixedName() { CMLUtil.checkPrefixedName("foo:name"); try { CMLUtil.checkPrefixedName("name"); Assert.fail("unprefixed name"); } catch (Exception e) { Assert.assertEquals("unprefixed", "Unprefixed name (name)", e.getMessage()); } } /** * Test method for 'org.xmlcml.cml.base.CMLUtil.getXMLResource(String)' */ @Test public final void testGetXMLResource() { String filename = CMLXOMTestUtils.BASE_RESOURCE +CMLConstants.U_S + "cml0.xml"; Document doc = null; try { doc = CMLUtil.getXMLResource(filename); } catch (Exception e) { Assert.fail("BUG "+e); } Assert.assertNotNull("doc not null", doc); } /** * Test method for * {@link org.xmlcml.cml.base.CMLUtil#getChildNodes(nu.xom.Element)}. */ @Test public final void testGetChildNodes() { String s = "abcdefghijkl"; Element root = CMLUtil.parseXML(s); List childNodes = CMLUtil.getChildNodes(root); Assert.assertEquals("count", 5, childNodes.size()); Assert.assertEquals("class", Text.class, childNodes.get(0).getClass()); Assert.assertEquals("value", "abc", childNodes.get(0).getValue()); Assert.assertEquals("class", Element.class, childNodes.get(1).getClass()); Assert.assertEquals("class", "bar", ((Element) childNodes.get(1)) .getLocalName()); Assert.assertEquals("value", "", childNodes.get(1).getValue()); Assert.assertEquals("class", Text.class, childNodes.get(2).getClass()); Assert.assertEquals("value", "def", childNodes.get(2).getValue()); Assert.assertEquals("class", Element.class, childNodes.get(3).getClass()); Assert.assertEquals("class", "bar1", ((Element) childNodes.get(3)) .getLocalName()); Assert.assertEquals("value", "ghi", childNodes.get(3).getValue()); Assert.assertEquals("class", Text.class, childNodes.get(4).getClass()); Assert.assertEquals("value", "jkl", childNodes.get(4).getValue()); } /** * Test method for {@link org.xmlcml.cml.base.CMLUtil#parseXML(String)}. */ @Test public final void testparseXMLString() { String s = "abcdefghijkl"; Element root = CMLUtil.parseXML(s); Element root1 = new Element("foo"); root1.appendChild(new Text("abc")); Element bar = new Element("bar"); root1.appendChild(bar); root1.appendChild(new Text("def")); Element bar1 = new Element("bar1"); bar1.appendChild(new Text("ghi")); root1.appendChild(bar1); root1.appendChild(new Text("jkl")); CMLXOMTestUtils.assertEqualsCanonically("parseXML", root1, root); // parseXML does not generate CML s = ""; root = CMLUtil.parseXML(s); Assert.assertEquals("class", Element.class, root.getClass()); } /** * Test method for {@link org.xmlcml.cml.base.CMLUtil#parseCML(String)}. */ @Test public final void testParseCMLString() { String s = ""; CMLElement root = CMLUtil.parseCML(s); Assert.assertEquals("class", CMLCml.class, root.getClass()); // if applied to non-CML, throws exception s = "abcdefghijkl"; try { root = CMLUtil.parseCML(s); Assert.fail("should throw ClassCastException"); } catch (RuntimeException cce) { } } /** * Test method for * {@link org.xmlcml.cml.base.CMLUtil#getQueryNodes(nu.xom.Node, java.lang.String, nu.xom.XPathContext)} * . */ @Test public final void testGetQueryNodesNodeStringXPathContext() { XPathContext XPC = new XPathContext("boo", "http://boo"); String s = "abcxyzdefghijkl"; Element root = CMLUtil.parseXML(s); List nodeList = CMLUtil.getQueryNodes(root, "/foo"); Assert.assertEquals("nodes", 1, nodeList.size()); nodeList = CMLUtil.getQueryNodes(root, "//bar"); Assert.assertEquals("nodes", 1, nodeList.size()); Assert.assertEquals("nodes", "ghi", nodeList.get(0).getValue()); nodeList = CMLUtil.getQueryNodes(root, "//boo:bar", XPC); Assert.assertEquals("nodes", 1, nodeList.size()); Assert.assertEquals("nodes", "xyz", nodeList.get(0).getValue()); } /** * Test method for * {@link org.xmlcml.cml.base.CMLUtil#getQueryNodes(nu.xom.Node, java.lang.String)} * . */ @Test public final void testGetQueryNodesNodeString() { String s = "abcdefghijkl"; Element root = CMLUtil.parseXML(s); List nodeList = CMLUtil.getQueryNodes(root, ".//text()"); Assert.assertEquals("nodes", 4, nodeList.size()); nodeList = CMLUtil.getQueryNodes(root, "/*/text()"); Assert.assertEquals("nodes", 3, nodeList.size()); nodeList = CMLUtil.getQueryNodes(root, "/text()"); Assert.assertEquals("nodes", 0, nodeList.size()); nodeList = CMLUtil.getQueryNodes(root, "/foo"); Assert.assertEquals("nodes", 1, nodeList.size()); nodeList = CMLUtil.getQueryNodes(root, "/foo/*"); Assert.assertEquals("nodes", 2, nodeList.size()); } /** * Test method for * {@link org.xmlcml.cml.base.CMLUtil#getFollowingSibling(nu.xom.Node)}. */ @Test public final void testGetFollowingSibling() { String s = "abcdefghijkl"; Element root = CMLUtil.parseXML(s); List nodeList = CMLUtil.getChildNodes(root); Node text = nodeList.get(0); Node sibNode = CMLUtil.getFollowingSibling(text); Assert.assertEquals("fsib", "bar", ((Element) sibNode).getLocalName()); Node bar1 = nodeList.get(3); Assert.assertEquals("fsib", "bar1", ((Element) bar1).getLocalName()); sibNode = CMLUtil.getFollowingSibling(bar1); Assert.assertEquals("fsib", "jkl", sibNode.getValue()); text = nodeList.get(4); sibNode = CMLUtil.getFollowingSibling(text); Assert.assertNull("fsib", sibNode); } /** * Test method for * {@link org.xmlcml.cml.base.CMLUtil#getPrecedingSibling(nu.xom.Node)}. */ @Test public final void testGetPrecedingSibling() { String s = "abcdefghijkl"; Element root = CMLUtil.parseXML(s); List nodeList = CMLUtil.getChildNodes(root); Node text = nodeList.get(0); Node sibNode = CMLUtil.getPrecedingSibling(text); Assert.assertNull("fsib", sibNode); Node bar1 = nodeList.get(3); Assert.assertEquals("fsib", "bar1", ((Element) bar1).getLocalName()); sibNode = CMLUtil.getPrecedingSibling(bar1); Assert.assertEquals("fsib", "def", sibNode.getValue()); text = nodeList.get(4); sibNode = CMLUtil.getFollowingSibling(text); Assert.assertEquals("fsib", "bar1", ((Element) bar1).getLocalName()); } /** * Test method for * {@link org.xmlcml.cml.base.CMLUtil#getLastTextDescendant(nu.xom.Node)}. */ @Test public final void testGetLastTextDescendant() { String s = "abcdefghijkl"; Element root = CMLUtil.parseXML(s); Text text = CMLUtil.getLastTextDescendant(root); Assert.assertNotNull("text", text); Assert.assertEquals("text", "jkl", text.getValue()); s = ""; root = CMLUtil.parseXML(s); text = CMLUtil.getLastTextDescendant(root); Assert.assertNull("text", text); } /** * Test method for * {@link org.xmlcml.cml.base.CMLUtil#getFirstTextDescendant(nu.xom.Node)}. */ @Test public final void testGetFirstTextDescendant() { String s = "abcdefghijkl"; Element root = CMLUtil.parseXML(s); Text text = CMLUtil.getFirstTextDescendant(root); Assert.assertNotNull("text", text); Assert.assertEquals("text", "abc", text.getValue()); s = ""; root = CMLUtil.parseXML(s); text = CMLUtil.getFirstTextDescendant(root); Assert.assertNull("text", text); } /** * Test method for * {@link org.xmlcml.cml.base.CMLUtil#transferChildren(nu.xom.Element, nu.xom.Element)} * . */ @Test public final void testTransferChildren() { String s = "" + "abcdefghijklandzzz"; Element root = CMLUtil.parseXML(s); Element foo = (Element) root.getChild(0); Element plugh = (Element) root.getChild(2); CMLUtil.transferChildren(plugh, foo); Element newRoot = CMLUtil.parseXML("" + "abcdefghijklzzz" + "and"); CMLXOMTestUtils.assertEqualsCanonically("new root", root, newRoot); } /** * Test method for */ @Test public final void testOutput() { // no simple test } /** * Test method for 'org.xmlcml.cml.base.CMLUtil.toArray(Elements, Object[])' */ @Test public final void testToArray() { String s = "abcdefghijkl"; Element root = CMLUtil.parseXML(s); Elements elements = root.getChildElements(); CMLUtil.toArray(elements, new Element[] {}); } /** * test get prefixes. */ @Test public void testGetPrefixes() { Element fragment = new Element("fragment", CMLConstants.CML_NS); Element fragment1 = new Element("fragment"); fragment.appendChild(fragment1); fragment1.addAttribute(new Attribute("ref", "g:mol")); fragment1 = new Element("fragment"); fragment.appendChild(fragment1); fragment1.addAttribute(new Attribute("ref", "k:mol")); fragment1 = new Element("fragment"); fragment.appendChild(fragment1); fragment1.addAttribute(new Attribute("dictRef", "k:x")); fragment1 = new Element("fragment"); fragment.appendChild(fragment1); fragment1.addAttribute(new Attribute("ref", "k:xxx")); fragment1 = new Element("fragment"); fragment.appendChild(fragment1); fragment1.addAttribute(new Attribute("dictRef", "q:xxx")); fragment1 = new Element("fragment"); fragment.appendChild(fragment1); fragment1.addAttribute(new Attribute("ref", "xxx")); List prefixList = CMLUtil.getPrefixes(fragment, "ref"); Assert.assertEquals("set", 3, prefixList.size()); Assert.assertTrue("set", prefixList.contains(EC.S_EMPTY)); Assert.assertTrue("set", prefixList.contains("g")); Assert.assertTrue("set", prefixList.contains("k")); Assert.assertFalse("set", prefixList.contains("q")); prefixList = CMLUtil.getPrefixes(fragment, "dictRef"); Assert.assertEquals("set", 2, prefixList.size()); Assert.assertFalse("set", prefixList.contains(EC.S_EMPTY)); Assert.assertFalse("set", prefixList.contains("g")); Assert.assertTrue("set", prefixList.contains("k")); Assert.assertTrue("set", prefixList.contains("q")); } @Test public void checkDoubleParsing() throws ParseException { Assert.assertEquals(1.0, (Util.parseFlexibleDouble("1.0")), 0.0001); Assert.assertEquals(Double.NaN, (Util.parseFlexibleDouble("NaN")), 0.0001); Assert.assertEquals(Double.POSITIVE_INFINITY, (Util.parseFlexibleDouble("INF")), 0.0001); Assert.assertEquals(Double.NEGATIVE_INFINITY, (Util.parseFlexibleDouble("-INF")), 0.0001); Assert.assertEquals(-0.001, (Util.parseFlexibleDouble("-0.001")), 0.0001); Assert.assertEquals(-0.1, (Util.parseFlexibleDouble("-000.1")), 0.0001); Assert.assertEquals(1000.0, (Util.parseFlexibleDouble("1.0E3")), 0.0001); Assert.assertEquals(1000.0, (Util.parseFlexibleDouble("1.0e3")), 0.0001); Assert.assertEquals(10000.0, (Util.parseFlexibleDouble("10.0E3")), 0.0001); Assert.assertEquals(1000.0, (Util.parseFlexibleDouble("1.0E+3")), 0.0001); Assert.assertEquals(0.001, (Util.parseFlexibleDouble("1.0E-3")), 0.0001); Assert.assertEquals(1000.0, (Util.parseFlexibleDouble("1.0E+03")), 0.0001); try { @SuppressWarnings("unused") double parseFlexibleDouble = (Util.parseFlexibleDouble("1.0e3foobar")); Assert.fail("Parsing 1.0e3foobar should have resulted in a ParseException being raised"); } catch (ParseException e) { // OK // e.printStackTrace(); // assertTrue(true); } } @Test public void testEqualsCanonicallyStringElementBoolean() { String xml1S = ""; Element xml1 = null; try { xml1 = new Builder().build(new StringReader(xml1S)).getRootElement(); } catch (Exception e) { throw new RuntimeException("parse fail", e); } String message = null; String refString = xml1S; // equality message = CMLUtil.equalsCanonically(refString, xml1, true); LOG.trace(refString); // element name different refString = ""; message = CMLUtil.equalsCanonically(refString, xml1, true); Assert.assertNotNull("message should be thrown", message); Assert.assertEquals("element name", "element names differ at /*[local-name()='Atom']/: Atom != atom", message); LOG.trace(refString); // element namespaces are the same refString = ""; message = CMLUtil.equalsCanonically(refString, xml1, true); Assert.assertNull("message should not be thrown", message); LOG.trace(refString); // element namespaces differ refString = ""; message = CMLUtil.equalsCanonically(refString, xml1, true); Assert.assertNotNull("message should be thrown", message); LOG.trace(refString); // attribute value different refString = ""; message = CMLUtil.equalsCanonically(refString, xml1, true); Assert.assertNotNull("message should be thrown", message); Assert.assertEquals("attribute value", "normalized attribute values for (/*[local-name()='atom']/@id) a2 != a1", message); LOG.trace(refString); // attribute name different refString = ""; message = CMLUtil.equalsCanonically(refString, xml1, true); Assert.assertNotNull("message should be thrown", message); Assert.assertEquals("attribute value", "no attribute in test (/*[local-name()='atom']/) for idx", message); LOG.trace(refString); // attribute namespace different refString = ""; message = CMLUtil.equalsCanonically(refString, xml1, true); Assert.assertNotNull("message should be thrown", message); LOG.trace(refString); // attribute count different refString = ""; message = CMLUtil.equalsCanonically(refString, xml1, true); Assert.assertNotNull("message should be thrown", message); Assert.assertEquals("attribute value", "unequal attribute count at /*[local-name()='atom']/ (2 != 1)", message); LOG.trace(refString); // content differs refString = " "; message = CMLUtil.equalsCanonically(refString, xml1, false); Assert.assertNotNull("message should be thrown", message); Assert.assertEquals("element content", "unequal child node count at /*[local-name()='atom']/ (1 != 0)", message); LOG.trace(refString); // content differs only in whitespace refString = " "; message = CMLUtil.equalsCanonically(refString, xml1, true); Assert.assertNull("message should not be thrown", message); LOG.trace(refString); // content differs refString = ""; message = CMLUtil.equalsCanonically(refString, xml1, false); Assert.assertNotNull("message should be thrown", message); Assert.assertEquals("element content", "unequal child node count at /*[local-name()='atom']/ (1 != 0)", message); LOG.trace("Q"); LOG.trace(refString); // equal child content xml1S = ""; try { xml1 = new Builder().build(new StringReader(xml1S)).getRootElement(); } catch (Exception e) { throw new RuntimeException("parse fail", e); } refString = xml1S; message = CMLUtil.equalsCanonically(refString, xml1, false); Assert.assertNull("message should not be thrown", message); LOG.trace(refString); // equal child content but whitespace refString = "\n" + " \n" + ""; message = CMLUtil.equalsCanonically(refString, xml1, false); Assert.assertNotNull("message should be thrown", message); Assert.assertEquals("element content", "unequal child node count at /*[local-name()='atom']/ (3 != 1)", message); LOG.trace(refString); // equal child content and ignore whitespace refString = "\n" + " \n" + ""; message = CMLUtil.equalsCanonically(refString, xml1, true); Assert.assertNull("message should not be thrown", message); LOG.trace("Z"); LOG.trace(refString); // check child attributes refString = "\n" + " \n" + ""; message = CMLUtil.equalsCanonically(refString, xml1, true); Assert.assertNotNull("message should be thrown", message); Assert.assertEquals("element content", "no attribute in test (/*[local-name()='atom']/node()[position()=1]) for idap", message); LOG.trace(refString); } @Test public void stripTrailingWhitespaceinTexts() { Element element = CMLUtil.parseXML(" bar "); CMLUtil.stripTrailingWhitespaceinTexts(element); Assert.assertEquals("stripWS", " bar", element.toXML()); } @Test public void stripTrailingWhitespaceinTexts2() { Element element = CMLUtil.parseXML(" bar"); CMLUtil.stripTrailingWhitespaceinTexts(element); Assert.assertEquals("stripWS", " bar", element.toXML()); } @Test public void stripTrailingWhitespaceinTexts3() { Element element = CMLUtil.parseXML(" bar \n\t"); CMLUtil.stripTrailingWhitespaceinTexts(element); Assert.assertEquals("stripWS", " bar", element.toXML()); } @Test public void stripTrailingWhitespaceinTexts4() { Element element = CMLUtil.parseXML(" bar \n\t \n a\n"); CMLUtil.stripTrailingWhitespaceinTexts(element); Assert.assertEquals("stripWS", " bar a", element.toXML()); } @Test public void removeNonCMLAttributes() { String cmlString = ""; CMLElement element = CMLUtil.parseCML(cmlString); CMLUtil.removeNonCMLAttributes(element); String refString = ""; String message = CMLUtil.equalsCanonically(refString, element, true); Assert.assertNull("remove noncml", message); } @Test public void removeNonCMLAttributes1() { String cmlString = "" + " " + ""; CMLElement element = CMLUtil.parseCML(cmlString); CMLUtil.removeNonCMLAttributes(element); String refString = "" + " " + ""; String message = CMLUtil.equalsCanonically(refString, element, true); Assert.assertNull("remove noncml", message); } @Test public void removeNonCMLAttributes2() { String cmlString = ""; CMLElement element = CMLUtil.parseCML(cmlString); CMLUtil.removeNonCMLAttributes(element); String refString = ""; String message = CMLUtil.equalsCanonically(refString, element, true); Assert.assertNull("remove noncml", message); } @Test public void testParseQuietlyToDocument() { File file = new File("src/test/resources/org/xmlcml/cml/base/cml0.xml"); Document doc = CMLUtil.parseQuietlyToDocument(file); Assert.assertNotNull(doc); } @Test public void testDetach() { File file = new File("src/test/resources/org/xmlcml/cml/base/cml0.xml"); Document doc = CMLUtil.parseQuietlyToDocument(file); Element element = doc.getRootElement(); CMLUtil.detach(element); Assert.assertNotNull(element); Assert.assertNull(element.getParent()); } @Test public void testDetach1() { File file = new File("src/test/resources/org/xmlcml/cml/base/cml0.xml"); Document doc = CMLUtil.parseQuietlyToDocument(file); Element element = doc.getRootElement().getChildElements().get(0); CMLUtil.detach(element); Assert.assertNotNull(element); Assert.assertNull(element.getParent()); } @Test public void testDebug() { Element element = new Element("zzz"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { CMLUtil.debug(element, baos, 1); } catch (IOException e) { Assert.fail("fail "+e); } Assert.assertTrue(baos.toByteArray().length > 0); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/base/CMLXOMTestUtils.java000077500000000000000000000244761477224461000262440ustar00rootroot00000000000000/** * 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.File; import java.io.IOException; import java.io.StringWriter; import java.net.URL; import junit.framework.AssertionFailedError; import junit.framework.ComparisonFailure; import nu.xom.Attribute; import nu.xom.Comment; import nu.xom.Element; import nu.xom.Node; import nu.xom.ProcessingInstruction; import nu.xom.Text; import nu.xom.tests.XOMTestCase; import org.apache.log4j.Logger; import org.junit.Assert; import org.xmlcml.euclid.Util; /** * *

* superclass for manage common methods for unit tests *

* * @author Peter Murray-Rust * @version 5.0 * */ public final class CMLXOMTestUtils { /** logger */ public final static Logger logger = Logger.getLogger(CMLXOMTestUtils.class .getName()); /** root of tests. */ public final static String BASE_RESOURCE = "org/xmlcml/cml/base"; /** * tests 2 XML objects for equality using canonical XML. * * @param message * @param refNode * first node * @param testNode * second node */ public static void assertEqualsCanonically(String message, Node refNode, Node testNode) { try { XOMTestCase.assertEquals(message, refNode, testNode); } catch (ComparisonFailure e) { reportXMLDiff(message, e.getMessage(), refNode, testNode); } catch (AssertionFailedError e) { reportXMLDiff(message, e.getMessage(), refNode, testNode); } } /** * compares two XML nodes and checks float near-equivalence (can also be * used for documents without floats) uses .assertEqualsCanonically and only * uses PMR code if fails * * @param message * @param refNode * @param testNode * @param eps */ public static void assertEqualsIncludingFloat(String message, Node refNode, Node testNode, boolean stripWhite, double eps) { assertEqualsIncludingFloat(message, refNode, testNode, stripWhite, eps, true); } /** * compares two XML nodes and checks float near-equivalence (can also be * used for documents without floats) uses .assertEqualsCanonically and only * uses PMR code if fails * * @param message * @param refNode * @param testNode * @param eps */ public static void assertEqualsIncludingFloat(String message, Node refNode, Node testNode, boolean stripWhite, double eps, boolean report) { if (stripWhite && refNode instanceof Element && testNode instanceof Element) { refNode = stripWhite((Element) refNode); testNode = stripWhite((Element) testNode); } try { assertEqualsIncludingFloat(message, refNode, testNode, eps); } catch (RuntimeException e) { if (report) { reportXMLDiffInFull(message, e.getMessage(), refNode, testNode); } } } private static void assertEqualsIncludingFloat(String message, Node refNode, Node testNode, double eps) { try { Assert.assertEquals(message + ": classes", testNode.getClass(), refNode.getClass()); if (refNode instanceof Text) { testStringDoubleEquality(message, refNode.getValue(), testNode .getValue(), eps); } else if (refNode instanceof Comment) { Assert.assertEquals(message + " pi", (Comment) refNode, (Comment) testNode); } else if (refNode instanceof ProcessingInstruction) { Assert.assertEquals(message + " pi", (ProcessingInstruction) refNode, (ProcessingInstruction) testNode); } else if (refNode instanceof Element) { int refNodeChildCount = refNode.getChildCount(); int testNodeChildCount = testNode.getChildCount(); Assert.assertEquals("number of children", testNodeChildCount, refNodeChildCount); for (int i = 0; i < refNodeChildCount; i++) { assertEqualsIncludingFloat(message, refNode.getChild(i), testNode.getChild(i), eps); } Element refElem = (Element) refNode; Element testElem = (Element) testNode; Assert.assertEquals(message + " namespace", refElem .getNamespaceURI(), testElem.getNamespaceURI()); Assert.assertEquals(message + " attributes on " + refElem.getClass(), refElem.getAttributeCount(), testElem.getAttributeCount()); for (int i = 0; i < refElem.getAttributeCount(); i++) { Attribute refAtt = refElem.getAttribute(i); String attName = refAtt.getLocalName(); String attNamespace = refAtt.getNamespaceURI(); Attribute testAtt = testElem.getAttribute(attName, attNamespace); if (testAtt == null) { Assert.fail(message + " attribute on ref not on test: " + attName); } testStringDoubleEquality(message, refAtt.getValue(), testAtt.getValue(), eps); } } else { Assert.fail(message + "cannot deal with XMLNode: " + refNode.getClass()); } } catch (Throwable t) { throw new RuntimeException("" + t); } } private static void testStringDoubleEquality(String message, String refValue, String testValue, double eps) { Error ee = null; try { try { double testVal = Double.valueOf(testValue).doubleValue(); double refVal = Double.valueOf(refValue).doubleValue(); Assert .assertEquals(message + " doubles ", refVal, testVal, eps); } catch (NumberFormatException e) { Assert.assertEquals(message + " String ", refValue, testValue); } } catch (ComparisonFailure e) { ee = e; } catch (AssertionError e) { ee = e; } if (ee != null) { throw new RuntimeException("" + ee); } } /** * tests 2 XML objects for equality using canonical XML. * * @param message * @param refNode * first node * @param testNode * second node * @param stripWhite * if true remove w/s nodes */ public static void assertEqualsCanonically(String message, Element refNode, Element testNode, boolean stripWhite) { assertEqualsCanonically(message, refNode, testNode, stripWhite, true); } /** * tests 2 XML objects for equality using canonical XML. * * @param message * @param refNode * first node * @param testNode * second node * @param stripWhite * if true remove w/s nodes */ private static void assertEqualsCanonically(String message, Element refNode, Element testNode, boolean stripWhite, boolean reportError) throws Error { if (stripWhite) { refNode = stripWhite(refNode); testNode = stripWhite(testNode); } Error ee = null; try { XOMTestCase.assertEquals(message, refNode, testNode); } catch (ComparisonFailure e) { ee = e; } catch (AssertionFailedError e) { ee = e; } if (ee != null) { if (reportError) { reportXMLDiffInFull(message, ee.getMessage(), refNode, testNode); } else { throw (ee); } } } private static Element stripWhite(Element refNode) { refNode = new Element(refNode); CMLUtil.removeWhitespaceNodes(refNode); return refNode; } static protected void reportXMLDiff(String message, String errorMessage, Node refNode, Node testNode) { Assert.fail(message + " ~ " + errorMessage); } static protected void reportXMLDiffInFull(String message, String errorMessage, Node refNode, Node testNode) { try { System.err.println("==========XMLDIFF reference========="); CMLUtil.debug((Element) refNode, System.err, 2); System.err.println("------------test---------------------"); CMLUtil.debug((Element) testNode, System.err, 2); System.err.println("==============" + message + "==================="); } catch (Exception e) { throw new RuntimeException(e); } Assert.fail(message + " ~ " + errorMessage); } /** * tests 2 XML objects for non-equality using canonical XML. * * @param message * @param node1 * first node * @param node2 * second node */ public static void assertNotEqualsCanonically(String message, Node node1, Node node2) { try { XOMTestCase.assertEquals(message, node1, node2); String s1 = CMLUtil.getCanonicalString(node1); String s2 = CMLUtil.getCanonicalString(node2); Assert.fail(message + "nodes should be different " + s1 + " != " + s2); } catch (ComparisonFailure e) { } catch (AssertionFailedError e) { } } /** * test the writeHTML method of element. * * @param element * to test * @param expected * HTML string */ public static void assertWriteHTML(CMLElement element, String expected) { StringWriter sw = new StringWriter(); try { element.writeHTML(sw); sw.close(); } catch (IOException e) { Assert.fail("should not throw " + e); } String s = sw.toString(); Assert.assertEquals("HTML output ", expected, s); } /** * convenience method to parse test string. * * @param s * xml string (assumed valid) * @return root element */ public static Element parseValidString(String s) { Element element = null; if (s == null) { throw new RuntimeException("NULL VALID JAVA_STRING"); } try { element = new CMLBuilder().parseString(s); } catch (Exception e) { e.printStackTrace(); System.err.println("ERROR " + e + e.getMessage() + "..." + s.substring(0, Math.min(100, s.length()))); Util.BUG(e); } return element; } /** * convenience method to parse test file. uses resource * * @param filename * relative to classpath * @return root element */ public static Element parseValidFile(String filename) { Element root = null; try { URL url = Util.getResource(filename); root = new CMLBuilder().build(new File(url.toURI())) .getRootElement(); } catch (Exception e) { e.printStackTrace(); } return root; } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/base/DoubleArrayAttributeTest.java000077500000000000000000000077431477224461000303170ustar00rootroot00000000000000/** * 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.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.euclid.EC; import org.xmlcml.euclid.test.DoubleTestBase; /** * tests for doubleAttribute. * * @author pmr * */ public class DoubleArrayAttributeTest { DoubleArraySTAttribute daa1; DoubleArraySTAttribute daa2; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { daa1 = new DoubleArraySTAttribute(new CMLAttribute("foo"), " 1.2 3.4 "); } /** * Test method for * 'org.xmlcml.cml.base.DoubleArraySTAttribute.getCMLValue()' */ @Test public void testGetCMLValue() { // Assert.assertEquals("get CMLValue", "1.2 3.4", daa1.getCMLValue()); Assert.assertNull("get CMLValue", daa1.getCMLValue()); } /** * Test method for * 'org.xmlcml.cml.base.DoubleArraySTAttribute.setCMLValue(String)' */ @Test public void testSetCMLValueString() { daa1.setCMLValue("3.4 5.6"); double[] dd = (double[]) daa1.getCMLValue(); DoubleTestBase.assertEquals("get CMLValue", new double[] { 3.4, 5.6 }, dd, EC.EPS); } /** * Test method for'org.xmlcml.cml.base.DoubleArraySTAttribute.DoubleArrayAttribute(DoubleArraySTAttribu * t e ) ' */ @Test public void testDoubleArrayAttributeDoubleArrayAttribute() { daa1.setCMLValue("3.4 5.6"); daa2 = new DoubleArraySTAttribute(daa1); double[] dd = (double[]) daa2.getCMLValue(); DoubleTestBase.assertEquals("get CMLValue", new double[] { 3.4, 5.6 }, dd, EC.EPS); } /** * Test method for * 'org.xmlcml.cml.base.DoubleArraySTAttribute.setCMLValue(double[])' */ @Test public void testSetCMLValueDoubleArray() { daa1.setCMLValue(new double[] { 5.6, 7.8 }); Assert.assertEquals("get Value", "5.6 7.8", daa1.getValue()); } /** * Test method for * 'org.xmlcml.cml.base.DoubleArraySTAttribute.checkValue(double[])' */ @Test public void testCheckValue() { daa1.checkValue(new double[] { 5.6, 7.8 }); Assert.assertEquals("get Value", "1.2 3.4", daa1.getValue()); } /** * Test method for 'org.xmlcml.cml.base.DoubleArraySTAttribute.split(String, * String)' */ @Test public void testSplit() { double[] dd = DoubleArraySTAttribute.split("1.2 3.4 5.6", CMLConstants.S_SPACE); Assert.assertEquals("split", 3, dd.length); DoubleTestBase.assertEquals("split", new double[] { 1.2, 3.4, 5.6 }, dd, EC.EPS); dd = DoubleArraySTAttribute.split("1.7 3.4 5.6", null); Assert.assertEquals("split", 3, dd.length); DoubleTestBase.assertEquals("split", new double[] { 1.7, 3.4, 5.6 }, dd, EC.EPS); } @Test public void testNaNSplit() { double[] dd = DoubleArraySTAttribute.split("NaN INF -INF 2.1", CMLConstants.S_SPACE); Assert.assertTrue(Double.isNaN(dd[0])); Assert.assertEquals(Double.POSITIVE_INFINITY, dd[1], 0.0001); Assert.assertEquals(Double.NEGATIVE_INFINITY, dd[2], 0.0001); Assert.assertEquals(2.1, dd[3],EC.EPS); Assert.assertEquals(4, dd.length); } /** * Test method for * 'org.xmlcml.cml.base.DoubleArraySTAttribute.getDoubleArray()' */ @Test public void testGetDoubleArray() { daa1.setCMLValue(new double[] { 5.6, 7.8 }); DoubleTestBase.assertEquals("get Value", new double[] { 5.6, 7.8 }, daa1.getDoubleArray(), EC.EPS); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/base/DoubleAttributeTest.java000077500000000000000000000056101477224461000273070ustar00rootroot00000000000000/** * 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.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.euclid.EC; /** * tests for doubleAttribute. * * @author pmr * */ public class DoubleAttributeTest { DoubleSTAttribute daa1; DoubleSTAttribute daa2; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { daa1 = new DoubleSTAttribute(new CMLAttribute("foo"), " 1.2 "); } /** * Test method for 'org.xmlcml.cml.base.DoubleSTAttribute.getCMLValue()' */ @Test public void testGetCMLValue() { Assert.assertEquals("get CMLValue", "1.2", (String) daa1.getCMLValue()); // Assert.assertNull("get CMLValue", daa1.getCMLValue()); } /** * Test method for * 'org.xmlcml.cml.base.DoubleSTAttribute.setCMLValue(String)' */ @Test public void testSetCMLValueString() { daa1.setCMLValue("3.4"); String dd = (String) daa1.getCMLValue(); Assert.assertEquals("get CMLValue", "3.4", dd); } /** * Test method for * 'org.xmlcml.cml.base.DoubleSTAttribute.DoubleAttribute(DoubleSTAttribute) * ' */ @Test public void testDoubleAttributeDoubleAttribute() { daa1.setCMLValue("3.4"); daa2 = new DoubleSTAttribute(daa1); String dd = (String) daa2.getCMLValue(); Assert.assertEquals("get CMLValue", "3.4", dd); } /** * Test method for * 'org.xmlcml.cml.base.DoubleSTAttribute.setCMLValue(double[])' */ @Test public void testSetCMLValueDouble() { daa1.setCMLValue(5.6); Assert.assertEquals("get Value", "5.6", daa1.getValue()); } @Test public void testSetCMLValueToSpecialValue() { daa1.setCMLValue("NaN"); Assert.assertEquals("NaN", daa1.getValue()); Assert.assertEquals(Double.NaN, daa1.getDouble(), 0.0001); } /** * Test method for * 'org.xmlcml.cml.base.DoubleSTAttribute.checkValue(double[])' */ @Test public void testCheckValue() { daa1.checkValue(5.6); Assert.assertEquals("get Value", "1.2", daa1.getValue()); } /** * Test method for 'org.xmlcml.cml.base.DoubleSTAttribute.getDouble()' */ @Test public void testGetDouble() { daa1.setCMLValue(7.8); Assert.assertEquals("get Value", 7.8, daa1.getDouble(), EC.EPS); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/base/ElementTest.java000077500000000000000000000234231477224461000256040ustar00rootroot00000000000000/** * 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.StringReader; import nu.xom.Builder; import nu.xom.Document; import nu.xom.Element; import nu.xom.ParsingException; import nu.xom.ValidityException; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; import org.xmlcml.euclid.Util; /** * fundamental parsing (not necessarily involved derived classses. * * @author pmr * */ public class ElementTest { final static String noSchema = "noSchema.xml"; final static String cml0 = "cml0.xml"; /** * parse withoout validation. * * @exception Exception * problem * */ @Test public void testParseNoValidate0() throws Exception { xomNoValidate(cml0); xomNoValidate(noSchema); } private void xomNoValidate(String file) throws IOException, ValidityException, ParsingException { Document doc = null; // Util.println(" === xom Parse, no validation: " + file + " ===="); InputStream in = null; in = Util.getInputStreamFromResource(CMLXOMTestUtils.BASE_RESOURCE +CMLConstants.U_S + file); doc = new Builder().build(in); Assert.assertNotNull("document ", doc); } /** * parse without schema. */ @Test public void testParseXomNoSchema1() { InputStream in = null; Document doc = null; try { in = Util.getInputStreamFromResource(CMLXOMTestUtils.BASE_RESOURCE +CMLConstants.U_S + noSchema); doc = new Builder().build(in); Assert.assertNotNull("document", doc); } catch (Exception e) { Assert.fail("BUG"+e); } } /** * test namespace scope. This is a know difficulty and this explores the XOM * approach. * */ @Test public void testNamespaceScope() { String s = ""; Document doc = null; try { doc = new Builder().build(new StringReader(s)); } catch (Exception e) { } Element a = doc.getRootElement(); Element b = a.getFirstChildElement("b"); int nsCount = b.getNamespaceDeclarationCount(); for (int i = 0; i < nsCount; i++) { // Util.output("NSPREFIX"+i+" // ["+b.getNamespacePrefix(i)+S_RSQUARE); // Util.output("NSURI"+i+" // ["+b.getNamespaceURI(b.getNamespacePrefix(i))+S_RSQUARE); } // Util.output("NS: "+b.getNamespaceURI("ns")); } /** * test removeWhitespaceNodes(Element element). */ @Test public void testRemoveWhitespaceNodesElement() { String element0S = "" + "" + " " + "
" + "
" + "
" + ""; Element element0 = CMLXOMTestUtils.parseValidString(element0S); String element1S = "
"; Element element1 = CMLXOMTestUtils.parseValidString(element1S); CMLXOMTestUtils.assertNotEqualsCanonically("before whitespace", element0, element1); CMLUtil.removeWhitespaceNodes(element0); CMLXOMTestUtils.assertEqualsCanonically("before whitespace ", element0, element1); } /** * construct element */ @Test public void testNewCMLElement() { CMLElement element = new CMLElement(); Assert.assertTrue(element instanceof CMLElement); } /** * construct with correct name but not subclassed class * to be avoided */ @Test public void testNewCMLElementName() { CMLElement element = new CMLElement("atom"); Assert.assertTrue(element instanceof CMLElement); Assert.assertEquals("org.xmlcml.cml.base.CMLElement", element.getClass().getName()); } /** * construct element */ @Test public void testNewCMLElementParse() { String cmlString = "" + "" + ""; CMLElement element = CMLUtil.parseCML(cmlString); Assert.assertTrue(element instanceof CMLElement); } /** * construct element */ @Test public void testNewCMLElementRef() { String cmlString = "" + "" + "" + "" + "" + ""; CMLElement top = CMLUtil.parseCML(cmlString); Assert.assertTrue(top instanceof org.xmlcml.cml.element.CMLCml); CMLElement element = (CMLElement) top.getChildElements().get(0); Assert.assertTrue(element instanceof CMLElement); CMLElement atom = (CMLElement) top.getChildElements().get(1); Assert.assertTrue(atom instanceof org.xmlcml.cml.element.CMLAtom); CMLElement element1 = element.dereferenceRef(); Assert.assertNotNull(element1); Assert.assertTrue(element1 instanceof org.xmlcml.cml.element.CMLAtom); // XML should be unchanged but isn't yet // Assert.assertEquals("xml", cmlString, top.toXML()); } /** */ /** * construct element */ @Test public void testNewCMLElementRefCopy() { String cmlString = "" + "" + "" + "" + "" + ""; CMLElement top = CMLUtil.parseCML(cmlString); CMLElement element = (CMLElement) top.getChildElements().get(0); CMLElement element1 = element.dereferenceRefCopyReplace(); Assert.assertNotNull(element1); Assert.assertTrue(element1 instanceof org.xmlcml.cml.element.CMLAtom); CMLElement element2 = (CMLElement) top.getChildElements().get(0); Assert.assertTrue(top.getChildElements().get(0) instanceof org.xmlcml.cml.element.CMLAtom); } /** * construct element */ @Test public void testNewCMLElementRefsCopy() { String cmlString = "" + "" + "" + "" + "" + "" + "" + "" + ""; CMLElement top = CMLUtil.parseCML(cmlString); top.dereferenceRefsCopyReplace(); } /** * dereference URL */ @Test @Ignore // fails - creates invalid URL public void testNewCMLElementRefsCopyURL() { String cmlString = "" + "" + "" + "" + ""; CMLElement top = CMLUtil.parseCML(cmlString); top.dereferenceRefsCopyReplace(); Assert.assertEquals("nodes", 361, top.query("//cml:scalar", CMLConstants.CML_XPATH).size()); } /** * dereference File - element is an untyped pointer */ @Test public void testNewCMLElementRefsCopyFile() { String cmlString = "" + "" + "" + "" + ""; CMLElement top = CMLUtil.parseCML(cmlString); top.dereferenceRefsCopyReplace(); Assert.assertEquals("nodes", 9, top.query("//cml:metadata", CMLConstants.CML_XPATH).size()); } /** * dereference File - cml is an untyped pointer */ @Test public void testNewCMLElementRefsCopyFileTyped() { String cmlString = "" + "" + "" + "" + ""; CMLElement top = CMLUtil.parseCML(cmlString); top.dereferenceRefsCopyReplace(); Assert.assertEquals("nodes", 9, top.query("//cml:metadata", CMLConstants.CML_XPATH).size()); } /** * dereference File - cml is an untyped pointer */ @Test public void testNewCMLElementRefsCopyFileBadlyTyped() { String cmlString = "" + "" + "" + "" + ""; CMLElement top = CMLUtil.parseCML(cmlString); top.dereferenceRefsCopyReplace(); Assert.assertEquals("nodes", 0, top.query("//cml:metadata", CMLConstants.CML_XPATH).size()); } @Test public void testDereferenceMoleculeBonds() { String ccS = "" + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""; CMLElement cml = CMLUtil.parseCML(ccS); cml.dereferenceRefsCopyReplace(); Assert.assertEquals("xxx", 2, cml.query("//cml:bond", CMLConstants.CML_XPATH).size()); // cml.debug("mol"); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/base/IntArrayAttributeTest.java000077500000000000000000000070651477224461000276340ustar00rootroot00000000000000/** * 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.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.euclid.Int; /** * tests for intAttribute. * * @author pmr * */ public class IntArrayAttributeTest { IntArraySTAttribute daa1; IntArraySTAttribute daa2; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { daa1 = new IntArraySTAttribute(new CMLAttribute("foo"), " 1 3 "); } /** * Test method for 'org.xmlcml.cml.base.IntArraySTAttribute.getCMLValue()' */ @Test public void testGetCMLValue() { // Assert.assertEquals("get CMLValue", "1 3", daa1.getCMLValue()); Assert.assertNull("get CMLValue", daa1.getCMLValue()); } /** * Test method for * 'org.xmlcml.cml.base.IntArraySTAttribute.setCMLValue(String)' */ @Test public void testSetCMLValueString() { daa1.setCMLValue("3 5"); int[] dd = (int[]) daa1.getCMLValue(); String s = Int.testEquals((new int[] { 3, 5 }), dd); if (s != null) { Assert.fail("get CMLValue" + "; " + s); } } /** * Test method for * 'org.xmlcml.cml.base.IntArraySTAttribute.IntArrayAttribute(IntArraySTAttribut * e ) ' */ @Test public void testIntArrayAttributeIntArrayAttribute() { daa1.setCMLValue("3 5"); daa2 = new IntArraySTAttribute(daa1); int[] dd = (int[]) daa2.getCMLValue(); String s = Int.testEquals((new int[] { 3, 5 }), dd); if (s != null) { Assert.fail("get CMLValue" + "; " + s); } } /** * Test method for * 'org.xmlcml.cml.base.IntArraySTAttribute.setCMLValue(int[])' */ @Test public void testSetCMLValueIntArray() { daa1.setCMLValue(new int[] { 5, 7 }); Assert.assertEquals("get Value", "5 7", daa1.getValue()); } /** * Test method for * 'org.xmlcml.cml.base.IntArraySTAttribute.checkValue(int[])' */ @Test public void testCheckValue() { daa1.checkValue(new int[] { 5, 7 }); Assert.assertEquals("get Value", "1 3", daa1.getValue()); } /** * Test method for 'org.xmlcml.cml.base.IntArraySTAttribute.split(String, * String)' */ @Test public void testSplit() { int[] dd = IntArraySTAttribute.split("1 3 5", CMLConstants.S_SPACE); Assert.assertEquals("split", 3, dd.length); String s = Int.testEquals((new int[] { 1, 3, 5 }), dd); if (s != null) { Assert.fail("split" + "; " + s); } dd = IntArraySTAttribute.split("7 3 5", null); Assert.assertEquals("split", 3, dd.length); s = Int.testEquals((new int[] { 7, 3, 5 }), dd); if (s != null) { Assert.fail("split" + "; " + s); } } /** * Test method for 'org.xmlcml.cml.base.IntArraySTAttribute.getIntArray()' */ @Test public void testGetIntArray() { daa1.setCMLValue(new int[] { 5, 7 }); String s = Int.testEquals((new int[] { 5, 7 }), daa1 .getIntArray()); if (s != null) { Assert.fail("get Value" + "; " + s); } } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/base/IntAttributeTest.java000077500000000000000000000050601477224461000266260ustar00rootroot00000000000000/** * 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.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.euclid.EC; /** * tests for intAttribute. * * @author pmr * */ public class IntAttributeTest { IntSTAttribute daa1; IntSTAttribute daa2; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { daa1 = new IntSTAttribute(new CMLAttribute("foo"), " 1 "); } /** * Test method for 'org.xmlcml.cml.base.IntSTAttribute.getCMLValue()' */ @Test public void testGetCMLValue() { Assert.assertEquals("get CMLValue", 1, daa1.getCMLValue()); // Assert.assertNull("get CMLValue", daa1.getCMLValue()); } /** * Test method for 'org.xmlcml.cml.base.IntSTAttribute.setCMLValue(String)' */ @Test public void testSetCMLValueString() { daa1.setCMLValue("3"); Integer dd = (Integer) daa1.getCMLValue(); Assert.assertEquals("get CMLValue", 3, dd.intValue(), EC.EPS); } /** * Test method for * 'org.xmlcml.cml.base.IntSTAttribute.IntAttribute(IntSTAttribute)' */ @Test public void testIntAttributeIntAttribute() { daa1.setCMLValue("3"); daa2 = new IntSTAttribute(daa1); Integer dd = (Integer) daa2.getCMLValue(); Assert.assertEquals("get CMLValue", 3, dd.intValue(), EC.EPS); } /** * Test method for * 'org.xmlcml.cml.base.IntSTAttribute.setCMLValue(double[])' */ @Test public void testSetCMLValueInt() { daa1.setCMLValue(5); Assert.assertEquals("get Value", "5", daa1.getValue()); } /** * Test method for 'org.xmlcml.cml.base.IntSTAttribute.checkValue(double[])' */ @Test public void testCheckValue() { daa1.checkValue(5); } /** * Test method for 'org.xmlcml.cml.base.IntSTAttribute.getInt()' */ @Test public void testGetInt() { daa1.setCMLValue(7); Assert.assertEquals("get Value", 7, daa1.getInt()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/base/StringArrayAttributeTest.java000077500000000000000000000071071477224461000303450ustar00rootroot00000000000000/** * 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.junit.Assert; import org.junit.Before; import org.junit.Test; /** * test for stringArrayAttribute. * * @author pmr * */ public class StringArrayAttributeTest { StringArraySTAttribute daa1; StringArraySTAttribute daa2; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { daa1 = new StringArraySTAttribute(new CMLAttribute("foo"), "abc def"); } @Test public void testArrayFromString(){ StringArraySTAttribute test = new StringArraySTAttribute("Test"); String[] array=test.arrayFromString("test foo bar"); Assert.assertEquals(3, array.length); Assert.assertEquals("bar", array[2]); } @Test public void testStringFromArray(){ StringArraySTAttribute test = new StringArraySTAttribute("Test"); String[] array=test.arrayFromString("test foo bar"); Assert.assertEquals("test foo bar",test.stringFromArray(array)); } /** * Test method for * 'org.xmlcml.cml.base.StringArraySTAttribute.getCMLValue()' */ @Test public void testGetCMLValue() { Assert.assertNotNull("get CMLValue", daa1.getCMLValue()); String[] dd = (String[]) daa1.getCMLValue(); Assert.assertEquals("get CMLValue", new String[] { "abc", "def" }, dd); } /** * Test method for * 'org.xmlcml.cml.base.StringArraySTAttribute.setCMLValue(String)' */ @Test public void testSetCMLValueString() { daa1.setCMLValue("1 2 3 4"); String[] dd = (String[]) daa1.getCMLValue(); Assert.assertEquals("get CMLValue", new String[] { "1", "2","3","4" }, dd); daa1.setCMLValue(new String[]{"foo","bar"}); Assert.assertEquals(new String[]{"foo","bar"}, (String[])daa1.getCMLValue()); } /** * Test method for'org.xmlcml.cml.base.StringArraySTAttribute.StringArrayAttribute(StringArraySTAttribute * ) ' */ @Test public void testStringArrayAttributeStringArrayAttribute() { daa1.setCMLValue("3 5"); daa2 = new StringArraySTAttribute(daa1); String[] dd = (String[]) daa2.getCMLValue(); Assert.assertEquals("get CMLValue", new String[] { "3", "5" }, dd); } /** * Test method for * 'org.xmlcml.cml.base.StringArraySTAttribute.setCMLValue(String[])' */ @Test public void testSetCMLValueStringArray() { daa1.setCMLValue(new String[] { "5", "7" }); Assert.assertEquals("get Value", "5 7", daa1.getValue()); } /** * Test method for * 'org.xmlcml.cml.base.StringArraySTAttribute.checkValue(String[])' */ @Test public void testCheckValue() { daa1.checkValue(new String[] { "5", "7" }); Assert.assertEquals("get Value", "abc def", daa1.getValue()); } /** * Test method for * 'org.xmlcml.cml.base.StringArraySTAttribute.getStringArray()' */ @Test public void testGetStringArray() { daa1.setCMLValue(new String[] { "6", "8" }); Assert.assertEquals("get Value", new String[] { "6", "8" }, daa1 .getStringArray()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/base/StringAttributeTest.java000077500000000000000000000052131477224461000273420ustar00rootroot00000000000000/** * 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.junit.Assert; import org.junit.Before; import org.junit.Test; /** * tests for stringAttribute. * * @author pmr * */ public class StringAttributeTest { StringSTAttribute daa1; StringSTAttribute daa2; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { daa1 = new StringSTAttribute(new CMLAttribute("foo"), "abc"); } /** * Test method for 'org.xmlcml.cml.base.StringSTAttribute.getCMLValue()' */ @Test public void testGetCMLValue() { Assert.assertEquals("get CMLValue", "abc", (String) daa1.getCMLValue()); // Assert.assertNull("get CMLValue", daa1.getCMLValue()); } /** * Test method for * 'org.xmlcml.cml.base.StringSTAttribute.setCMLValue(String)' */ @Test public void testSetCMLValueStringX() { daa1.setCMLValue("abc"); String dd = (String) daa1.getCMLValue(); Assert.assertEquals("get CMLValue", "abc", dd); } /** * Test method for * 'org.xmlcml.cml.base.StringSTAttribute.StringAttribute(StringSTAttribute) * ' */ @Test public void testStringAttributeStringAttribute() { daa1.setCMLValue("3"); daa2 = new StringSTAttribute(daa1); String dd = (String) daa2.getCMLValue(); Assert.assertEquals("get CMLValue", "3", dd); } /** * Test method for * 'org.xmlcml.cml.base.StringSTAttribute.setCMLValue(String[])' */ @Test public void testSetCMLValueString() { daa1.setCMLValue("5"); Assert.assertEquals("get Value", "5", daa1.getValue()); } /** * Test method for * 'org.xmlcml.cml.base.StringSTAttribute.checkValue(String[])' */ @Test public void testCheckValue() { daa1.checkValue("5"); Assert.assertEquals("get Value", "abc", daa1.getValue()); } /** * Test method for 'org.xmlcml.cml.base.StringSTAttribute.getString()' */ @Test public void testGetString() { daa1.setCMLValue("6"); Assert.assertEquals("get Value", "6", daa1.getString()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/000077500000000000000000000000001477224461000232205ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/lite/000077500000000000000000000000001477224461000241555ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/lite/CMLArrayTest.java000077500000000000000000001301511477224461000272760ustar00rootroot00000000000000/** * 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.lite; import nu.xom.Element; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.attribute.DelimiterAttribute; import org.xmlcml.cml.attribute.DelimiterAttribute.Action; import org.xmlcml.cml.base.CC; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLUtil; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLArray; import org.xmlcml.cml.element.CMLScalar; import org.xmlcml.euclid.EC; import org.xmlcml.euclid.Int; import org.xmlcml.euclid.test.DoubleTestBase; import org.xmlcml.euclid.test.StringTestBase; /** * test Array * * @author pmr * */ public class CMLArrayTest { final static double EPS = 0.0000000001; int[] i0 = { 1, 2, 3, 4, 5 }; int[] i1 = { 10, 20, 30, 40, 50 }; double[] d0 = { 1., 2., 3., 4., 5. }; double[] d1 = { 10., 20., 30., 40., 50. }; String[] s0 = { "a", "b", "c", "d", "e" }; String[] s1 = { "vector", "w", "x", "y", "z" }; String slashDelim = EC.S_SLASH; CMLArray xomS; CMLArray xomI0; CMLArray xomI1; CMLArray xomD0; CMLArray xomD1; CMLArray xomS0; CMLArray xomS1; String xmlSS = ""; CMLArray xmlS; CMLArray xmlI0; CMLArray xmlI1; CMLArray xmlD0; CMLArray xmlD1; CMLArray xmlS0; CMLArray xmlS1; String unitsS = "" + "180 90 45 0" + "100 50 0 -25" + "100 50 0 -50" + ""; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { try { xomS = new CMLArray(); xmlS = (CMLArray)CMLXOMTestUtils.parseValidString(xmlSS); xomD0 = new CMLArray(d0); xomI0 = new CMLArray(i0); xomS0 = new CMLArray(s0); xomD1 = new CMLArray(d1, slashDelim); xomI1 = new CMLArray(i1, slashDelim); xomS1 = new CMLArray(s1, slashDelim); // note these are String arrays String xmlS0S = "1 2 3 4 5"; String xmlS1S = "/100/200/300/400/500/"; // while these are ints String xmlI0S = "1 2 3 4 5"; String xmlI1S = "/10/20/30/40/50/"; String xmlD0S = "1. 2. 3. 4. 5."; String xmlD1S = "/10./20./30./40./50./"; xmlS0 = (CMLArray)CMLXOMTestUtils.parseValidString(xmlS0S); xmlS1 = (CMLArray)CMLXOMTestUtils.parseValidString(xmlS1S); xmlI0 = (CMLArray)CMLXOMTestUtils.parseValidString(xmlI0S); xmlI1 = (CMLArray)CMLXOMTestUtils.parseValidString(xmlI1S); xmlD0 = (CMLArray)CMLXOMTestUtils.parseValidString(xmlD0S); xmlD1 = (CMLArray)CMLXOMTestUtils.parseValidString(xmlD1S); } catch (Exception e) { e.printStackTrace(); throw e; } } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLArray test, CMLArray expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + EC.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + EC.S_RBRAK, expected); if ((test.getDataType() == null || test.getDataType() .equals(CC.XSD_STRING)) && (expected.getDataType() == null || expected.getDataType() .equals(CC.XSD_STRING))) { StringTestBase.assertEquals(msg, test.getStrings(), expected .getStrings()); } else if (test.getDataType().equals(CC.XSD_DOUBLE) && expected.getDataType().equals(CC.XSD_DOUBLE)) { DoubleTestBase.assertEquals(msg, test.getDoubles(), expected .getDoubles(), EPS); } else if (test.getDataType().equals(CC.XSD_INTEGER) && expected.getDataType().equals(CC.XSD_INTEGER)) { String s = Int.testEquals(test.getInts(), expected.getInts()); if (s != null) { Assert.fail(msg + "; " + s); } } else { Assert.fail("inconsistent dataTypes" + test.getDataType() + " / " + expected.getDataType()); } } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, CMLArray expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + EC.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + EC.S_RBRAK, expected); if (!expected.getDataType().equals(CC.XSD_DOUBLE)) { Assert.fail("expected should be double"); } DoubleTestBase.assertEquals(msg, test, expected.getDoubles(), EPS); } /** * equality test. true if both args not null and equal * * @param msg * message * @param test * @param expected */ public static void assertEquals(String msg, int[] test, CMLArray expected) { Assert.assertNotNull("test should not be null (" + msg + EC.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + EC.S_RBRAK, expected); if (!expected.getDataType().equals(CC.XSD_INTEGER)) { Assert.fail("expected should be int"); } String s = Int.testEquals(test, expected.getInts()); if (s != null) { Assert.fail(msg + "; " + s); } } /** * equality test. true if both args not null and equal * * @param msg * message * @param test * @param expected */ public static void assertEquals(String msg, String[] test, CMLArray expected) { Assert.assertNotNull("test should not be null (" + msg + EC.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + EC.S_RBRAK, expected); if (expected.getDataType() != null && !expected.getDataType().equals(CC.XSD_STRING)) { Assert.fail("expected should be String"); } StringTestBase.assertEquals(msg, test, expected.getStrings()); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.finishMakingElement()' * * @exception Exception */ @Test public void testCatchErrors() throws Exception { CMLArray a = null; try { String xmlBad1 = "/a/b/"; a = (CMLArray) new CMLBuilder().parseString(xmlBad1); Assert.fail("bad 1 should not parse; type was wrong"); } catch (RuntimeException e) { Assert.assertTrue(true); } try { String xmlBad2 = "a b c"; a = (CMLArray) new CMLBuilder().parseString(xmlBad2); Assert.fail("bad 2 should not parse - inconsistent size"); } catch (RuntimeException e) { Assert.assertTrue(true); } try { String xmlBad3 = "1 2 c"; a = (CMLArray) new CMLBuilder().parseString(xmlBad3); Assert.fail("bad 3 should not parse"); } catch (RuntimeException e) { Assert.assertTrue(true); } try { String xmlBad4 = "1 2 c"; a = (CMLArray) new CMLBuilder().parseString(xmlBad4); Assert.fail("bad 4 should not parse"); } catch (RuntimeException e) { Assert.assertTrue(true); } try { String xmlBad5 = "a b c d"; a = (CMLArray) new CMLBuilder().parseString(xmlBad5); Assert.assertEquals("whitespace delimiter", EC.S_EMPTY, a .getDelimiter()); Assert.assertEquals("token length", 4, a.getStrings().length); Assert.assertEquals("token 0", "c", a.getStrings()[2]); } catch (RuntimeException e) { Assert.assertTrue(true); } try { String xmlBad6 = "a b c"; a = (CMLArray) new CMLBuilder().parseString(xmlBad6); Assert.fail("bad 6 should not parse - inconsistent size"); } catch (RuntimeException e) { Assert.assertTrue(true); } } /** * Test method for 'org.xmlcml.cml.element.CMLArray.getDataType()' */ @Test public void testGetDataType() { Assert.assertEquals("dataType", CC.XSD_STRING, xomS.getDataType()); Assert.assertEquals("dataType", CC.XSD_STRING, xomS0.getDataType()); Assert.assertEquals("dataType", CC.XSD_INTEGER, xomI0.getDataType()); Assert.assertEquals("dataType", CC.XSD_DOUBLE, xomD0.getDataType()); Assert.assertEquals("dataType", CC.XSD_STRING, xmlS.getDataType()); Assert.assertEquals("dataType", CC.XSD_STRING, xmlS0.getDataType()); Assert.assertEquals("dataType", CC.XSD_STRING, xmlS1.getDataType()); Assert.assertEquals("dataType", CC.XSD_INTEGER, xmlI0.getDataType()); Assert.assertEquals("dataType", CC.XSD_INTEGER, xmlI1.getDataType()); Assert.assertEquals("dataType", CC.XSD_DOUBLE, xmlD0.getDataType()); Assert.assertEquals("dataType", CC.XSD_DOUBLE, xmlD1.getDataType()); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.setDataType(String)' */ @Test public void testSetDataType() { try { xomS.setDataType(CC.XSD_DOUBLE); } catch (RuntimeException e) { Assert.fail("should not throw CMLRuntime"); } Assert.assertEquals("set data type", CC.XSD_DOUBLE, xomS.getDataType()); try { xomS.setDataType(CC.XSD_DOUBLE); Assert.fail("should throw CMLRuntime"); } catch (RuntimeException e) { Assert.assertEquals("ok", "ok"); } try { xomS0.setDataType(CC.XSD_DOUBLE); Assert.fail("should throw CMLRuntime"); } catch (RuntimeException e) { Assert.assertEquals("ok", "ok"); } try { xomD0.setDataType(CC.XSD_DOUBLE); Assert.fail("should throw CMLRuntime"); } catch (RuntimeException e) { Assert.assertEquals("ok", "ok"); } try { xomI0.setDataType(CC.XSD_DOUBLE); Assert.fail("should throw CMLRuntime"); } catch (RuntimeException e) { Assert.assertEquals("ok", "ok"); } } /** * Test method for 'org.xmlcml.cml.element.CMLArray.getDelimiter()' */ @Test public void testGetDelimiterSplitterConcat() { CMLArray arrayS = new CMLArray(); DelimiterAttribute delimiterAttribute = (DelimiterAttribute) arrayS .getDelimiterAttribute(); // delimiter attribute is now null by default Assert.assertNull("default", delimiterAttribute); // Assert.assertEquals("default", EC.S_EMPTY, delimiterAttribute.getValue()); // Assert.assertEquals("default", EC.S_WHITEREGEX, delimiterAttribute // .getSplitter()); // Assert.assertEquals("default", EC.S_SPACE, delimiterAttribute.getConcat()); // // Assert.assertEquals("default", EC.S_EMPTY, arrayS.getDelimiter()); arrayS.setDelimiter(EC.S_COMMA); delimiterAttribute = (DelimiterAttribute) arrayS .getDelimiterAttribute(); Assert.assertNotNull("default", delimiterAttribute); Assert.assertEquals("default", EC.S_COMMA, delimiterAttribute.getValue()); Assert.assertEquals("default", EC.S_COMMA, delimiterAttribute .getSplitter()); Assert.assertEquals("default", EC.S_COMMA, delimiterAttribute.getConcat()); Assert.assertEquals("default", EC.S_COMMA, arrayS.getDelimiter()); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.getSize()' */ @Test public void testGetSize() { Assert.assertEquals("size", 0, xomS.getSize()); Assert.assertEquals("size", 5, xomS0.getSize()); Assert.assertEquals("double", 5, xomD0.getSize()); Assert.assertEquals("int", 5, xomI0.getSize()); Assert.assertEquals("size", 5, xomS1.getSize()); Assert.assertEquals("double", 5, xomD1.getSize()); Assert.assertEquals("int", 5, xomI1.getSize()); Assert.assertEquals("size", 0, xmlS.getSize()); Assert.assertEquals("size", 5, xmlS0.getSize()); Assert.assertEquals("double", 5, xmlD0.getSize()); Assert.assertEquals("int", 5, xmlI0.getSize()); Assert.assertEquals("size", 5, xmlS1.getSize()); Assert.assertEquals("double", 5, xmlD1.getSize()); Assert.assertEquals("int", 5, xmlI1.getSize()); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.CMLArray()' */ @Test public void testCMLArray() { CMLArray array0 = new CMLArray(); Assert.assertEquals("size", 0, array0.getSize()); Assert.assertEquals("delimiter", EC.S_EMPTY, array0.getDelimiter()); Assert.assertEquals("dataType", CC.XSD_STRING, array0.getDataType()); Assert.assertEquals("size", 0, xomS.getSize()); Assert.assertEquals("delimiter", EC.S_EMPTY, xomS.getDelimiter()); Assert.assertEquals("dataType", CC.XSD_STRING, xomS.getDataType()); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.CMLArray(CMLArray)' */ @Test public void testCMLArrayCMLArray() { CMLArray s2 = new CMLArray(xomS0); Assert.assertNull("delimiter", s2.getDelimiterAttribute()); // Assert.assertEquals("delimiter", EC.S_EMPTY, s2.getDelimiter()); Assert.assertEquals("size", 5, s2.getSize()); Assert.assertEquals("dataType", CC.XSD_STRING, s2.getDataType()); String[] ss = s2.getStrings(); Assert.assertEquals("element", "a", ss[0]); Assert.assertEquals("element", "e", ss[4]); s2 = new CMLArray(xomD0); Assert.assertNull("delimiter", s2.getDelimiterAttribute()); // Assert.assertEquals("delimiter", EC.S_EMPTY, s2.getDelimiter()); Assert.assertEquals("size", 5, s2.getSize()); Assert.assertEquals("dataType", CC.XSD_DOUBLE, s2.getDataType()); double[] dd = null; try { dd = s2.getDoubles(); } catch (RuntimeException e) { Assert.fail("should parse doubles OK"); } Assert.assertEquals("element", 1., dd[0], EPS); Assert.assertEquals("element", 5., dd[4], EPS); s2 = new CMLArray(xomI0); Assert.assertNull("delimiter", s2.getDelimiterAttribute()); // Assert.assertEquals("delimiter", EC.S_EMPTY, s2.getDelimiter()); Assert.assertEquals("size", 5, s2.getSize()); Assert.assertEquals("dataType", CC.XSD_INTEGER, s2.getDataType()); int[] ii = null; try { ii = s2.getInts(); } catch (RuntimeException e) { Assert.fail("should parse doubles OK"); } Assert.assertEquals("element", 1, ii[0]); Assert.assertEquals("element", 5, ii[4]); s2 = new CMLArray(xmlI0); Assert.assertNull("delimiter", s2.getDelimiterAttribute()); // Assert.assertEquals("delimiter", EC.S_EMPTY, s2.getDelimiter()); Assert.assertEquals("size", 5, s2.getSize()); Assert.assertEquals("dataType", CC.XSD_INTEGER, s2.getDataType()); ii = null; try { ii = s2.getInts(); } catch (RuntimeException e) { Assert.fail("should parse doubles OK"); } Assert.assertEquals("element", 1, ii[0]); Assert.assertEquals("element", 5, ii[4]); s2 = new CMLArray(xmlD1); Assert.assertNotNull("delimiter", s2.getDelimiterAttribute()); Assert.assertEquals("delimiter", EC.S_SLASH, s2.getDelimiter()); Assert.assertEquals("size", 5, s2.getSize()); Assert.assertEquals("dataType", CC.XSD_DOUBLE, s2.getDataType()); dd = null; try { dd = s2.getDoubles(); } catch (RuntimeException e) { Assert.fail("should parse doubles OK"); } Assert.assertEquals("element", 10., dd[0], EPS); Assert.assertEquals("element", 50., dd[4], EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.CMLArray(String[])' */ @Test public void testCMLArrayStringArray() { CMLArray arrayS = new CMLArray(new String[] { "a", "b", "c" }); Assert.assertEquals("data type", CC.XSD_STRING, arrayS.getDataType()); Assert.assertEquals("size", 3, arrayS.getSize()); Assert.assertEquals("content", "a b c", arrayS.getXMLContent()); Assert.assertEquals("delimiter", EC.S_EMPTY, arrayS.getDelimiter()); Assert.assertEquals("delimiter", EC.S_EMPTY, xomS0.getDelimiter()); String[] ss = xomS0.getStrings(); Assert.assertEquals("length", 5, ss.length); Assert.assertEquals("array0", "a", ss[0]); Assert.assertEquals("array4", "e", ss[4]); Assert.assertEquals("data type", CC.XSD_STRING, xomS0.getDataType()); Assert.assertEquals("size", 5, xomS0.getSize()); Assert.assertEquals("content", "a b c d e", xomS0.getXMLContent()); Assert.assertEquals("delimiter", EC.S_EMPTY, xomS0.getDelimiter()); ss = xomS0.getStrings(); Assert.assertEquals("length", 5, ss.length); Assert.assertEquals("array0", "a", ss[0]); Assert.assertEquals("array4", "e", ss[4]); } /** * test ensureDelimiter */ @Test public void testEnsureDelimiterAttribute() { CMLArray array = new CMLArray(); array.ensureDelimiterAttribute(Action.PRESERVE); DelimiterAttribute delimiterAttribute = (DelimiterAttribute) array .getDelimiterAttribute(); Assert.assertNotNull("delimiter", delimiterAttribute); Assert.assertEquals("delimiter", EC.S_SPACE, delimiterAttribute .getConcat()); Assert.assertEquals("delimiter", EC.S_WHITEREGEX, delimiterAttribute .getSplitter()); Assert .assertEquals("delimiter", EC.S_EMPTY, delimiterAttribute .getValue()); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.CMLArray(String[], * String)' */ @Test public void testCMLArrayStringArrayString() { Assert.assertEquals("data type", CC.XSD_STRING, xomS1.getDataType()); Assert.assertEquals("size", 5, xomS1.getSize()); Assert.assertEquals("content", "/vector/w/x/y/z/", xomS1 .getXMLContent()); Assert.assertEquals("delimiter", EC.S_SLASH, xomS1.getDelimiter()); Assert.assertNotNull("delimiter", xomS1.getDelimiterAttribute()); String[] ss = xomS1.getStrings(); Assert.assertEquals("length", 5, ss.length); Assert.assertEquals("array0", "vector", ss[0]); Assert.assertEquals("array4", "z", ss[4]); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.CMLArray(double[])' */ @Test public void testCMLArrayDoubleArray() { double[] dd = new double[] { 10.0, 20.0, 30.0, 40.0, 50.0 }; CMLArray arrayD = new CMLArray(dd); Assert.assertEquals("data type", CC.XSD_DOUBLE, arrayD.getDataType()); Assert.assertEquals("size", 5, arrayD.getSize()); Assert.assertEquals("content", "10.0 20.0 30.0 40.0 50.0", arrayD .getXMLContent()); Assert.assertEquals("delimiter", EC.S_EMPTY, arrayD.getDelimiter()); Assert.assertEquals("data type", CC.XSD_DOUBLE, xomD0.getDataType()); Assert.assertEquals("size", 5, xomD0.getSize()); Assert.assertEquals("content", "1.0 2.0 3.0 4.0 5.0", xomD0 .getXMLContent()); Assert.assertEquals("delimiter", EC.S_EMPTY, xomD0.getDelimiter()); double[] ss = null; try { ss = xomD0.getDoubles(); } catch (RuntimeException e) { Assert.fail("doubles should parse OK"); } Assert.assertEquals("length", 5, ss.length); Assert.assertEquals("array0", 1.0, ss[0], EPS); Assert.assertEquals("array4", 5.0, ss[4], EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.CMLArray(double[], * Strinig)' */ @Test public void testCMLArrayDoubleArrayString() { double[] dd = new double[] { 10.0, 20.0, 30.0, 40.0, 50.0 }; CMLArray arrayD = new CMLArray(dd, EC.S_SLASH); // DelimiterAttribute delimiterAttribute = (DelimiterAttribute) // arrayD.getDelimiterAttribute(); Assert.assertEquals("data type", CC.XSD_DOUBLE, arrayD.getDataType()); Assert.assertEquals("size", 5, arrayD.getSize()); Assert.assertEquals("content", "/10.0/20.0/30.0/40.0/50.0/", arrayD .getXMLContent()); Assert.assertEquals("delimiter", EC.S_SLASH, arrayD.getDelimiter()); Assert.assertNotNull("delimiter", arrayD.getDelimiterAttribute()); double[] ss = null; try { ss = xomD1.getDoubles(); } catch (RuntimeException e) { Assert.fail("doubles should parse OK"); } Assert.assertEquals("length", 5, ss.length); Assert.assertEquals("array0", 10.0, ss[0], EPS); Assert.assertEquals("array4", 50.0, ss[4], EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.CMLArray(int[])' */ @Test public void testCMLArrayIntArray() { Assert.assertEquals("data type", CC.XSD_INTEGER, xomI0.getDataType()); Assert.assertEquals("size", 5, xomI0.getSize()); Assert.assertEquals("content", "1 2 3 4 5", xomI0.getXMLContent()); Assert.assertEquals("delimiter", EC.S_EMPTY, xomI0.getDelimiter()); int[] ss = null; try { ss = xomI0.getInts(); } catch (RuntimeException e) { Assert.fail("ints should parse OK"); } Assert.assertEquals("length", 5, ss.length); Assert.assertEquals("array0", 1, ss[0]); Assert.assertEquals("array4", 5, ss[4]); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.CMLArray(int[], String)' */ @Test public void testCMLArrayIntArrayString() { Assert.assertEquals("data type", CC.XSD_INTEGER, xomI1.getDataType()); Assert.assertEquals("size", 5, xomI1.getSize()); Assert.assertEquals("content", "/10/20/30/40/50/", xomI1 .getXMLContent()); Assert.assertEquals("delimiter", EC.S_SLASH, xomI1.getDelimiter()); Assert.assertNotNull("delimiter", xomI1.getDelimiterAttribute()); int[] ss = null; try { ss = xomI0.getInts(); } catch (RuntimeException e) { Assert.fail("ints should parse OK"); } Assert.assertEquals("length", 5, ss.length); Assert.assertEquals("array0", 1, ss[0]); Assert.assertEquals("array4", 5, ss[4]); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.getStrings()' */ @Test public void testGetStrings() { String[] ss = xomS.getStrings(); Assert.assertNotNull("empty content", ss); Assert.assertEquals("empty content", 0, ss.length); ss = xomS0.getStrings(); Assert.assertNotNull("content", ss); Assert.assertEquals("content", 5, ss.length); Assert.assertEquals("array0", "a", ss[0]); Assert.assertEquals("array4", "e", ss[4]); ss = xomS1.getStrings(); Assert.assertNotNull("content", ss); Assert.assertEquals("content", 5, ss.length); Assert.assertEquals("array0", "vector", ss[0]); Assert.assertEquals("array4", "z", ss[4]); ss = xomD0.getStrings(); Assert.assertNull("content", ss); ss = xomD1.getStrings(); Assert.assertNull("content", ss); ss = xomI0.getStrings(); Assert.assertNull("content", ss); ss = xomI1.getStrings(); Assert.assertNull("content", ss); ss = xmlS.getStrings(); Assert.assertNotNull("empty content", ss); Assert.assertEquals("empty content", 0, ss.length); ss = xmlS0.getStrings(); Assert.assertNotNull("content", ss); Assert.assertEquals("content", 5, ss.length); Assert.assertEquals("array0", "1", ss[0]); Assert.assertEquals("array4", "5", ss[4]); ss = xmlS1.getStrings(); Assert.assertNotNull("content", ss); Assert.assertEquals("content", 5, ss.length); Assert.assertEquals("array0", "100", ss[0]); Assert.assertEquals("array4", "500", ss[4]); ss = xmlD0.getStrings(); Assert.assertNull("content", ss); ss = xmlD1.getStrings(); Assert.assertNull("content", ss); ss = xmlI0.getStrings(); Assert.assertNull("content", ss); ss = xmlI1.getStrings(); Assert.assertNull("content", ss); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.getDoubles()' */ @Test public void testGetDoubles() { try { double[] ss = xomS.getDoubles(); Assert.assertNull("empty content", ss); ss = xomD0.getDoubles(); Assert.assertNotNull("content", ss); Assert.assertEquals("content", 5, ss.length); Assert.assertEquals("array0", 1.0, ss[0], EPS); Assert.assertEquals("array4", 5.0, ss[4], EPS); ss = xomD1.getDoubles(); Assert.assertNotNull("content", ss); Assert.assertEquals("content", 5, ss.length); Assert.assertEquals("array0", 10., ss[0], EPS); Assert.assertEquals("array4", 50., ss[4], EPS); ss = xomS0.getDoubles(); Assert.assertNull("content", ss); ss = xomS1.getDoubles(); Assert.assertNull("content", ss); ss = xomI0.getDoubles(); Assert.assertNull("content", ss); ss = xomI1.getDoubles(); Assert.assertNull("content", ss); ss = xmlS.getDoubles(); Assert.assertNull("empty content", ss); ss = xmlD0.getDoubles(); Assert.assertNotNull("content", ss); Assert.assertEquals("content", 5, ss.length); Assert.assertEquals("array0", 1.0, ss[0], EPS); Assert.assertEquals("array4", 5.0, ss[4], EPS); ss = xmlD1.getDoubles(); Assert.assertNotNull("content", ss); Assert.assertEquals("content", 5, ss.length); Assert.assertEquals("array0", 10., ss[0], EPS); Assert.assertEquals("array4", 50., ss[4], EPS); ss = xmlS0.getDoubles(); Assert.assertNull("content", ss); ss = xmlS1.getDoubles(); Assert.assertNull("content", ss); ss = xmlI0.getDoubles(); Assert.assertNull("content", ss); ss = xmlI1.getDoubles(); Assert.assertNull("content", ss); } catch (RuntimeException e) { Assert.fail("should not throw double parsing error"); } } /** * Test method for 'org.xmlcml.cml.element.CMLArray.getInts()' */ @Test public void testGetInts() { try { int[] ss = xomS.getInts(); Assert.assertNull("empty content", ss); ss = xomI0.getInts(); Assert.assertNotNull("content", ss); Assert.assertEquals("content", 5, ss.length); Assert.assertEquals("array0", 1, ss[0]); Assert.assertEquals("array4", 5, ss[4]); ss = xomI1.getInts(); Assert.assertNotNull("content", ss); Assert.assertEquals("content", 5, ss.length); Assert.assertEquals("array0", 10, ss[0], EPS); Assert.assertEquals("array4", 50, ss[4], EPS); ss = xomS0.getInts(); Assert.assertNull("content", ss); ss = xomS1.getInts(); Assert.assertNull("content", ss); ss = xomD0.getInts(); Assert.assertNull("content", ss); ss = xomD1.getInts(); Assert.assertNull("content", ss); ss = xmlS.getInts(); Assert.assertNull("empty content", ss); ss = xmlI0.getInts(); Assert.assertNotNull("content", ss); Assert.assertEquals("content", 5, ss.length); Assert.assertEquals("array0", 1, ss[0]); Assert.assertEquals("array4", 5, ss[4]); ss = xmlI1.getInts(); Assert.assertNotNull("content", ss); Assert.assertEquals("content", 5, ss.length); Assert.assertEquals("array0", 10, ss[0]); Assert.assertEquals("array4", 50, ss[4]); ss = xmlS0.getInts(); Assert.assertNull("content", ss); ss = xmlS1.getInts(); Assert.assertNull("content", ss); ss = xmlD0.getInts(); Assert.assertNull("content", ss); ss = xmlD1.getInts(); Assert.assertNull("content", ss); } catch (RuntimeException e) { Assert.fail("should not throw double parsing error"); } } /** * Test method for 'org.xmlcml.cml.element.CMLArray.setArray(String[])' */ @Test public void testSetArrayStringArray() { Assert.assertEquals("empty", 0, xomS.getStrings().length); try { xomS.setArray(s0); } catch (RuntimeException e) { Assert.fail("should not throw Exception " + e.getMessage()); } Assert.assertEquals("empty", 5, xomS.getStrings().length); try { String[] bad = { "a", "b c", "d" }; xomS.setArray(bad); Assert.fail("should throw Exception as string has whitespace"); } catch (RuntimeException e) { Assert.assertEquals("should throw Exception ", "cannot delimit {b c} with { }", e.getMessage()); } Assert.assertEquals("empty", 5, xomS.getStrings().length); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.setArray(double[])' */ @Test public void testSetArrayDoubleArray() { try { Assert.assertEquals("double", 5, xomD0.getDoubles().length); xomS.setArray(d0); Assert.assertEquals("d", 5, xomS.getDoubles().length); Assert.assertEquals("d", 1.0, xomS.getDoubles()[0], 0.0001); Assert.assertEquals("d", 5.0, xomS.getDoubles()[4], 0.0001); xomS.setArray(d1); Assert.assertEquals("d", 5, xomS.getDoubles().length); Assert.assertEquals("d", 10.0, xomS.getDoubles()[0], 0.0001); Assert.assertEquals("d", 50.0, xomS.getDoubles()[4], 0.0001); } catch (RuntimeException e) { Assert.fail("should not throw parse exception"); } } /** * Test method for 'org.xmlcml.cml.element.CMLArray.setArray(int[])' */ @Test public void testSetArrayIntArray() { try { Assert.assertEquals("int", 5, xomI0.getInts().length); xomS.setArray(i0); Assert.assertEquals("d elim", EC.S_EMPTY, xomS.getDelimiter()); Assert.assertEquals("d type", CC.XSD_INTEGER, xomS.getDataType()); Assert.assertEquals("d type", CC.XSD_INTEGER, xomS.getDataType()); Assert.assertEquals("d XML", "1 2 3 4 5", xomS.getXMLContent()); Assert.assertEquals("d", 5, xomS.getInts().length); Assert.assertEquals("d", 1, xomS.getInts()[0]); Assert.assertEquals("d", 5, xomS.getInts()[4]); Assert.assertNotNull(i1); Assert.assertEquals("i1 ", 5, i1.length); xomS.setArray(i1); Assert.assertNotNull("xomS i1 ", xomS); Assert.assertEquals("d delim", EC.S_EMPTY, xomS.getDelimiter()); Assert.assertEquals("d type", CC.XSD_INTEGER, xomS.getDataType()); Assert .assertEquals("d XML", "10 20 30 40 50", xomS .getXMLContent()); Assert.assertEquals("d", 5, xomS.getInts().length); Assert.assertEquals("d", 10, xomS.getInts()[0]); Assert.assertEquals("d", 50, xomS.getInts()[4]); } catch (RuntimeException e) { Assert.fail("should not throw parse exception"); } } /** * Test method for * 'org.xmlcml.cml.element.CMLArray.checkNumericConformability(CMLArray)' */ @Test public void testCheckNumericConformability() { try { xomD0.checkNumericConformability(xomD1); } catch (Exception e) { Assert.fail("conformability should not throw " + e.getMessage()); } try { xomI0.checkNumericConformability(xomI1); } catch (Exception e) { Assert.fail("conformability should not throw " + e.getMessage()); } try { xomD0.checkNumericConformability(xomS0); Assert.fail("conformability should throw exception"); } catch (Exception e) { } try { xomD0.checkNumericConformability(xomI0); Assert.fail("conformability should throw exception"); } catch (Exception e) { } try { xomI0.checkNumericConformability(xomD0); Assert.fail("conformability should throw exception"); } catch (Exception e) { } try { xomI0.checkNumericConformability(xomS0); Assert.fail("conformability should throw exception"); } catch (Exception e) { } try { xomS0.checkNumericConformability(xomS1); Assert.fail("conformability should throw exception"); } catch (Exception e) { } } /** * Test method for 'org.xmlcml.cml.element.CMLArray.subtract(CMLArray)' */ @Test public void testSubtract() { CMLArray d3 = null; try { d3 = xomD1.subtract(xomD0); } catch (Exception e) { Assert.fail("subtract should not throw " + e.getMessage()); } Assert.assertNotNull("subtract", d3); Assert.assertEquals("subtract", 5, d3.getSize()); try { Assert.assertEquals("subtract", -9., d3.getDoubles()[0], 0.0001); } catch (RuntimeException e) { Assert.fail("subtract should not throw " + e.getMessage()); } d3 = null; try { d3 = xmlD1.subtract(xmlD0); } catch (Exception e) { Assert.fail("subtract should not throw " + e.getMessage()); } Assert.assertNotNull("subtract", d3); Assert.assertEquals("subtract", 5, d3.getSize()); try { Assert.assertEquals("subtract", -9., d3.getDoubles()[0], 0.0001); } catch (RuntimeException e) { Assert.fail("subtract should not throw " + e.getMessage()); } } /** * Test method for 'org.xmlcml.cml.element.CMLArray.plus(CMLArray)' */ @Test public void testPlus() { CMLArray d3 = null; try { d3 = xomD1.plus(xomD0); } catch (Exception e) { Assert.fail("subtract should not throw " + e.getMessage()); } Assert.assertNotNull("plus", d3); Assert.assertEquals("plus", 5, d3.getSize()); try { Assert.assertEquals("plus", 11., d3.getDoubles()[0], 0.0001); } catch (RuntimeException e) { Assert.fail("plus should not throw " + e.getMessage()); } } /** * Test method for 'org.xmlcml.cml.element.CMLArray.append(String)' */ @Test public void testAppendString() { String[] ss = new String[] { "a", "b", "c", "d", "e" }; CMLArray arrayS = new CMLArray(ss); StringTestBase.assertEquals("append", ss, arrayS.getStrings()); Assert.assertEquals("append", "a b c d e", arrayS.getXMLContent()); arrayS.append("f"); Assert.assertEquals("append", "a b c d e f", arrayS.getXMLContent()); arrayS = new CMLArray(ss, EC.S_SLASH); StringTestBase.assertEquals("append", ss, arrayS.getStrings()); Assert.assertEquals("append", "/a/b/c/d/e/", arrayS.getXMLContent()); arrayS.append("f"); Assert.assertEquals("append", "/a/b/c/d/e/f/", arrayS.getXMLContent()); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.append(double)' */ @Test public void testAppendDouble() { xomD0.append(6.); Assert.assertEquals("append", "1.0 2.0 3.0 4.0 5.0 6.0", xomD0 .getXMLContent()); Assert.assertEquals("append", 6, xomD0.getSize()); try { xomD0.append("f"); Assert.fail("append should not throw "); } catch (RuntimeException e) { Assert.assertEquals("cannot add string to double", "Cannot add string (f) to array of: xsd:double", e .getMessage()); } } /** * Test method for 'org.xmlcml.cml.element.CMLArray.append(int)' */ @Test public void testAppendInt() { xomI0.append(6); Assert.assertEquals("append", "1 2 3 4 5 6", xomI0.getXMLContent()); Assert.assertEquals("append", 6, xomI0.getSize()); try { xomI0.append("f"); Assert.fail("append should not throw "); } catch (RuntimeException e) { Assert.assertEquals("cannot add string to int", "Cannot add string (f) to array of: xsd:integer", e .getMessage()); } } /** * Test method for 'org.xmlcml.cml.element.CMLArray.copy()' */ @Test public void testCopy() { CMLArray array = new CMLArray(new double[] { 1., 2. }); CMLArray array1 = (CMLArray) array.copy(); Assert.assertEquals("copy", CC.XSD_DOUBLE, array1.getDataType()); CMLArrayTest.assertEquals("copy", new double[] { 1., 2. }, array1, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.setDelimiter(String)' */ @Test public void testSetDelimiter() { CMLArray array = new CMLArray(); array.setDataType(CC.XSD_DOUBLE); array.setDelimiter(EC.S_SLASH); DelimiterAttribute da = (DelimiterAttribute) array .getDelimiterAttribute(); Assert.assertNotNull("delimiter", da); array.setXMLContent("1./2."); double[] dd = array.getDoubles(); Assert.assertNotNull("dd null", dd); DoubleTestBase.assertEquals("double delimiter", new double[] { 1., 2. }, dd, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLArray.getStringValues()' */ @Test public void testGetStringValues() { CMLArray array = new CMLArray(new String[] { "a", "b" }); StringTestBase.assertEquals("strings", new String[] { "a", "b" }, (String[]) array.getStringValues().toArray(new String[0])); array = new CMLArray(new int[] { 1, 2 }); StringTestBase.assertEquals("ints", new String[] { "1", "2" }, (String[]) array.getStringValues().toArray(new String[0])); array = new CMLArray(new double[] { 1, 2 }); StringTestBase.assertEquals("ints", new String[] { "1.0", "2.0" }, (String[]) array.getStringValues().toArray(new String[0])); } @Test public void testAppend() { CMLArray array = new CMLArray(new String[] { "a", "b" }); CMLArray array1 = new CMLArray(new String[] { "c", "d", "e" }); array.append(array1); CMLArray arrayRef = new CMLArray(new String[] {"a", "b", "c", "d", "e" }); CMLArrayTest.assertEquals("append", array, arrayRef, 0.000001); } @Test public void testAppendDelimiter() { CMLArray array = new CMLArray(new String[] { "a", "b" }, "|"); CMLArray array1 = new CMLArray(new String[] { "c", "d", "e" }, "|"); array.append(array1); CMLArray arrayRef = new CMLArray(new String[] {"a", "b", "c", "d", "e" }, "|"); CMLArrayTest.assertEquals("append", array, arrayRef, 0.000001); } @Test public void testAppendDoubleArray() { CMLArray array = new CMLArray(new double[] { 1.1, 2.2 }); CMLArray array1 = new CMLArray(new double[] { 3.3, 4.4, 5.5}); array.append(array1); CMLArray arrayRef = new CMLArray(new double[]{1.1, 2.2, 3.3, 4.4, 5.5 }); CMLArrayTest.assertEquals("append", array, arrayRef, 0.000001); } @Test public void testAppendIntArray() { CMLArray array = new CMLArray(new int[] { 1, 2 }); CMLArray array1 = new CMLArray(new int[] { 3, 4, 5}); array.append(array1); CMLArray arrayRef = new CMLArray(new int[]{1, 2, 3, 4, 5 }); CMLArrayTest.assertEquals("append", array, arrayRef, 0.000001); } @Test public void testAppendMixedArray() { CMLArray array = new CMLArray(new String[] { "a", "b" }); CMLArray array1 = new CMLArray(new int[] { 3, 4, 5}); try { array.append(array1); Assert.fail("should throw incompatibility"); } catch (Exception e) { } } @Test /** need to remove this delimiter attribute*/ public void testSerializeWithEmptyDelimiter() { CMLArray array = new CMLArray(new int[] { 1, 2 }); String arrayXML = array.toXML(); String ref="1 2"; Assert.assertEquals("serialize", ref, arrayXML); } @Test /** need to remove this delimiter attribute*/ public void testSerializeWithEmptyDelimiter1() { CMLArray array = new CMLArray(new int[] { 1, 2 }); String arrayXML = array.toXML(); String ref="1 2"; Assert.assertEquals("serialize", ref, arrayXML); } @Test /** need to remove this delimiter attribute*/ public void testSerializeWithEmptyDelimiter2() { CMLArray array = new CMLArray(new int[] { 1, 2 }); Assert.assertNull(array.getDelimiterAttribute()); String arrayXML = array.toXML(); String ref="1 2"; array.append(3); arrayXML = array.toXML(); ref="1 2 3"; Assert.assertEquals("serialize", ref, arrayXML); } @Test public void testGetScalar() { CMLArray array = new CMLArray(new int[] { 1, 2 }); array.setDictRef("foo:bar"); CMLScalar scalar = array.getElementAt(1); String ref="2"; Assert.assertEquals("getElement", ref, scalar.toXML()); } @Test public void testGetScalar1() { CMLArray array = new CMLArray(new int[] { 1, 2 }); array.setDictRef("foo:bar"); CMLScalar scalar = array.getElementAt(-1); Assert.assertNull(scalar); scalar = array.getElementAt(2); Assert.assertNull(scalar); } @Test public final void testChangeDelimiter(){ CMLArray array = new CMLArray(); array.setDelimiter(","); array.setArray(new int[]{2,3,4}); Assert.assertEquals(",2,3,4,", array.getStringContent()); Assert.assertNotNull(array.getDelimiterAttribute()); array.setDelimiter(" "); Assert.assertNull(array.getDelimiterAttribute()); Assert.assertEquals("2 3 4", array.getStringContent()); } @Test (expected=RuntimeException.class) public void testThrowsForNewDelimiterInArray(){ CMLArray array = new CMLArray(); array.setDelimiter(","); array.setArray(new String[]{"foo","bar","cat"}); array.setDelimiter("a"); } @Test public void testSubArray() { CMLArray array = new CMLArray(new String[]{"0", "1", "2", "3", "4", "5"}); CMLArray subArray = array.createSubArray(2,4); Element ref = CMLUtil.parseQuietlyIntoCML( "2 3 4"); CMLXOMTestUtils.assertEqualsCanonically("subArray", ref, subArray); } @Test (expected=RuntimeException.class) public void testSubArray1() { CMLArray array = new CMLArray(new String[]{"0", "1", "2", "3", "4", "5"}); CMLArray subArray = array.createSubArray(-1,4); } @Test (expected=RuntimeException.class) public void testSubArray2() { CMLArray array = new CMLArray(new String[]{"0", "1", "2", "3", "4", "5"}); CMLArray subArray = array.createSubArray(1,6); } @Test (expected=RuntimeException.class) public void testSubArray3() { CMLArray array = new CMLArray(new String[]{"0", "1", "2", "3", "4", "5"}); CMLArray subArray = array.createSubArray(4, 2); } @Test public void testSubArray4() { CMLArray array = new CMLArray(new String[]{"0", "1", "2", "3", "4", "5"}); CMLArray subArray = array.createSubArray(4,4); Element ref = CMLUtil.parseQuietlyIntoCML( "4"); CMLXOMTestUtils.assertEqualsCanonically("subArray", ref, subArray); } @Test public void testSubArray5() { CMLArray array = new CMLArray(new String[]{"0", "1", "2", "3", "4", "5"}); CMLArray subArray = array.createSubArray(0, 5); Element ref = CMLUtil.parseQuietlyIntoCML( "0 1 2 3 4 5"); CMLXOMTestUtils.assertEqualsCanonically("subArray", ref, subArray); } @Test public void testSubArray6() { CMLArray array = new CMLArray(new String[]{"0", "1", "2", "3", "4", "5"}, "|"); CMLArray subArray = array.createSubArray(1,4); Element ref = CMLUtil.parseQuietlyIntoCML( "|1|2|3|4|"); CMLXOMTestUtils.assertEqualsCanonically("subArray", ref, subArray); } @Test public void testSubArray7() { CMLArray array = new CMLArray(new String[]{"0", "1", "2", "3", "4", "5"}); array.setDictRef("foo:bar"); CMLArray subArray = array.createSubArray(1,4); Element ref = CMLUtil.parseQuietlyIntoCML( "1 2 3 4"); CMLXOMTestUtils.assertEqualsCanonically("subArray", ref, subArray); } @Test public void testSubArray8() { CMLArray array = new CMLArray(new int[]{0,1,2,3,4,5}); array.setDictRef("foo:bar"); CMLArray subArray = array.createSubArray(1,4); Element ref = CMLUtil.parseQuietlyIntoCML( "1 2 3 4"); CMLXOMTestUtils.assertEqualsCanonically("subArray", ref, subArray); } @Test public void testSubArray9() { CMLArray array = new CMLArray(new double[]{0,1.1,2.2,3.3,4.4,5.5}); array.setDictRef("foo:bar"); CMLArray subArray = array.createSubArray(1,4); Element ref = CMLUtil.parseQuietlyIntoCML( "1.1 2.2 3.3 4.4"); CMLXOMTestUtils.assertEqualsCanonically("subArray", ref, subArray); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/lite/CMLAtomArrayTest.java000077500000000000000000000300351477224461000301170ustar00rootroot00000000000000/** * 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.lite; import java.util.List; import java.util.Map; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLAtomArray; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.main.MoleculeAtomBondFixture; /** * @author pm286 * */ public class CMLAtomArrayTest { MoleculeAtomBondFixture fixture = new MoleculeAtomBondFixture(); /** * @throws java.lang.Exception */ @Before public synchronized void setUp() throws Exception { fixture.setUp(); } /** * Test method for {@link org.xmlcml.cml.element.CMLAtomArray#detach()} * . */ @Test public final void testDetach() { CMLAtomArray atomArray = fixture.xomMolecule.getAtomArray(); Assert.assertNotNull("get atomarray", atomArray); List atomList = fixture.xomMolecule.getAtoms(); Assert.assertEquals("atom count before detach", 5, atomList.size()); Assert.assertEquals("atom count before detach", 5, atomArray.getAtomElements() .size()); CMLAtom a1 = fixture.xomMolecule.getAtomById("a1"); Assert.assertNotNull("get atom", a1); Assert.assertEquals("get atom", "a1", a1.getId()); atomArray.detach(); Assert.assertEquals("atom count after detach", 5, atomArray.getAtomElements() .size()); atomList = fixture.xomMolecule.getAtoms(); Assert.assertEquals("atom count after detach", 0, atomList.size()); // FIXME System.err.println("NOT YET WORKING - PMR"); a1 = fixture.xomMolecule.getAtomById("a1"); Assert.assertNull("get atom", a1); } /** * Test method for * {@link org.xmlcml.cml.element.CMLAtomArray#CMLAtomArray()}. */ @Test public final void testCMLAtomArray() { CMLAtomArray atomArray = new CMLAtomArray(); CMLAtom atom = new CMLAtom("a1"); // this seems to be allowed atomArray.addAtom(atom); Assert.assertEquals("atom count ", 1, atomArray.getAtomElements().size()); CMLMolecule mol = new CMLMolecule(); List atomList = mol.getAtoms(); Assert.assertEquals("atom count before add", 0, atomList.size()); // not sure whether this should be allowed but it works mol.appendChild(atomArray); atomList = mol.getAtoms(); Assert.assertEquals("atom count after add", 1, atomList.size()); CMLMolecule molx = new CMLMolecule(); molx.addAtomArray(new CMLAtomArray()); atomArray = molx.getAtomArray(); atomArray.setAtomID(new String[] { "a1", "a2", "a3" }); Assert.assertEquals("atom count ", 3, atomArray.getAtomElements().size()); atomArray.setX2(new double[] { 10, 20, 30 }); Assert.assertEquals("atom 1 x2", 20.0, atomArray.getAtomElements().get(1) .getX2(), 0.00001); atomArray.setY2(new double[] { 40, 50, 60 }); Assert.assertEquals("atom 2 y2", 60.0, atomArray.getAtomElements().get(2) .getY2(), 0.00001); atomArray.setX3(new double[] { 1.1, 1.2, 1.3 }); Assert.assertEquals("atom 0 x3", 1.1, atomArray.getAtomElements().get(0) .getX3(), 0.00001); atomArray.setY3(new double[] { 1.4, 1.5, 1.6 }); Assert.assertEquals("atom 1 y3", 1.5, atomArray.getAtomElements().get(1) .getY3(), 0.00001); atomArray.setZ3(new double[] { 1.7, 1.8, 1.9 }); Assert.assertEquals("atom 1 z3", 1.9, atomArray.getAtomElements().get(2) .getZ3(), 0.00001); atomArray.setXFract(new double[] { 0.1, 0.2, 0.3 }); Assert.assertEquals("atom 1 xFract", 0.1, atomArray.getAtomElements().get(0) .getXFract(), 0.00001); atomArray.setYFract(new double[] { 0.4, 0.5, 0.6 }); Assert.assertEquals("atom 1 yFract", 0.5, atomArray.getAtomElements().get(1) .getYFract(), 0.00001); atomArray.setZFract(new double[] { 0.7, 0.8, 0.9 }); Assert.assertEquals("atom 1 zFract", 0.9, atomArray.getAtomElements().get(2) .getZFract(), 0.00001); atomArray.setHydrogenCount(new String[] { "1", "2", "3" }); Assert.assertEquals("atom 1 hcount", 2, atomArray.getAtomElements().get(1) .getHydrogenCount()); atomArray.setOccupancy(new String[] { "0.11", "0.22", "0.33" }); Assert.assertEquals("atom 1 occ", .22, atomArray.getAtomElements().get(1) .getOccupancy(), 0.0001); try { atomArray.setOccupancy(new String[] { "0.11", "0.22" }); } catch (RuntimeException e) { Assert.assertEquals("reported error ", "inconsistent atom count (3) and occupancy (2)", e .getMessage()); } } /** * Test method for * {@link org.xmlcml.cml.element.CMLAtomArray#appendChild(org.xmlcml.cml.element.CMLAtom)} * . */ @Test public final void testAppendChildCMLAtom() { CMLAtomArray atomArray = new CMLAtomArray(); CMLAtom atom = new CMLAtom("a1"); // this seems to be allowed atomArray.appendChild(atom); Assert.assertEquals("atom count ", 1, atomArray.getAtomElements().size()); } /** * Test method for {@link org.xmlcml.cml.element.CMLAtomArray#size()}. */ @Test public final void testSize() { CMLAtomArray atomArray = new CMLAtomArray(); Assert.assertEquals("atom count ", 0, atomArray.size()); CMLAtom atom = new CMLAtom("a1"); // this seems to be allowed atomArray.appendChild(atom); Assert.assertEquals("atom count ", 1, atomArray.size()); atomArray.removeChild(atom); Assert.assertEquals("atom count ", 0, atomArray.size()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLAtomArray#addAtom(org.xmlcml.cml.element.CMLAtom)} * . */ @Test public final void testAddAtomCMLAtom() { CMLAtomArray atomArray = new CMLAtomArray(); Assert.assertEquals("atom count ", 0, atomArray.size()); CMLAtom atom = new CMLAtom("a1"); // this seems to be allowed atomArray.addAtom(atom); } /** * Test method for * {@link org.xmlcml.cml.element.CMLAtomArray#insertAtom(org.xmlcml.cml.element.CMLAtom, int)} * . */ @Test public final void testInsertAtom() { CMLAtomArray atomArray = new CMLAtomArray(); Assert.assertEquals("atom count ", 0, atomArray.size()); CMLAtom atom = new CMLAtom("a1"); atomArray.addAtom(atom); atom = new CMLAtom("a2"); atomArray.addAtom(atom); atom = new CMLAtom("a3"); atomArray.addAtom(atom); Assert.assertEquals("atom 2", "a2", atomArray.getAtomElements().get(1).getId()); atom = new CMLAtom("a2a"); atomArray.insertAtom(atom, 1); Assert.assertEquals("atom 2", "a2a", atomArray.getAtomElements().get(1) .getId()); Assert.assertEquals("atom 2", "a2", atomArray.getAtomElements().get(2).getId()); atom = new CMLAtom("a1a"); atomArray.insertAtom(atom, 0); Assert.assertEquals("atom 2", "a1a", atomArray.getAtomElements().get(0) .getId()); Assert.assertEquals("atom 2", "a1", atomArray.getAtomElements().get(1).getId()); Assert.assertEquals("atom count ", 5, atomArray.size()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLAtomArray#removeChild(org.xmlcml.cml.element.CMLAtom)} * . */ @Test public final void testRemoveChildCMLAtom() { CMLAtomArray atomArray = new CMLAtomArray(); Assert.assertEquals("atom count ", 0, atomArray.size()); CMLAtom atom = new CMLAtom("a1"); atomArray.addAtom(atom); atom = new CMLAtom("a2"); atomArray.addAtom(atom); CMLAtom atom2 = atom; atom = new CMLAtom("a3"); atomArray.addAtom(atom); Assert.assertEquals("atom 2", "a2", atomArray.getAtomElements().get(1).getId()); Assert.assertEquals("atom count ", 3, atomArray.size()); CMLAtom atomR = atomArray.removeChild(atom2); Assert.assertEquals("removed atom", atom2, atomR); Assert.assertEquals("atom count ", 2, atomArray.size()); Assert.assertEquals("atom 2", "a3", atomArray.getAtomElements().get(1).getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLAtomArray#removeAtom(org.xmlcml.cml.element.CMLAtom)} * . */ @Test public final void testRemoveAtom() { CMLAtomArray atomArray = new CMLAtomArray(); Assert.assertEquals("atom count ", 0, atomArray.size()); CMLAtom atom = new CMLAtom("a1"); atomArray.addAtom(atom); atom = new CMLAtom("a2"); atomArray.addAtom(atom); CMLAtom atom2 = atom; atom = new CMLAtom("a3"); atomArray.addAtom(atom); Assert.assertEquals("atom 2", "a2", atomArray.getAtomElements().get(1).getId()); Assert.assertEquals("atom count ", 3, atomArray.size()); CMLAtom atomR = atomArray.removeAtom(atom2); Assert.assertEquals("removed atom", atom2, atomR); Assert.assertEquals("atom count ", 2, atomArray.size()); Assert.assertEquals("atom 2", "a3", atomArray.getAtomElements().get(1).getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLAtomArray#getMolecule()}. */ @Test public final void testGetMolecule() { CMLAtomArray atomArray = new CMLAtomArray(); Assert.assertEquals("atom count ", 0, atomArray.size()); CMLAtom atom = new CMLAtom("a1"); atomArray.addAtom(atom); Assert.assertNull("no molecule", atom.getMolecule()); CMLMolecule mol = CMLMolecule.createMoleculeWithId("m1"); mol.addAtomArray(atomArray); CMLMolecule mol1 = atom.getMolecule(); Assert.assertNotNull("molecule", mol1); Assert.assertEquals("mol id", "m1", mol1.getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLAtomArray#getAtomMap()}. */ @Test public final void testGetAtomMap() { CMLAtomArray atomArray = new CMLAtomArray(); Assert.assertEquals("atom count ", 0, atomArray.size()); CMLAtom atom1 = new CMLAtom("a1"); atomArray.addAtom(atom1); CMLAtom atom2 = new CMLAtom("a2"); atomArray.addAtom(atom2); CMLAtom atom3 = new CMLAtom("a3"); atomArray.addAtom(atom3); Map map = atomArray.getAtomMap(); CMLAtom atomx = map.get("a1"); Assert.assertNotNull("atom 1", atomx); Assert.assertEquals("atom 1", "a1", atomx.getId()); atomx = map.get("a4"); Assert.assertNull("atom 4", atomx); CMLAtom atom4 = new CMLAtom("a4"); atomArray.addAtom(atom4); atomx = map.get("a4"); Assert.assertNotNull("atom 4", atomx); Assert.assertEquals("atom 4", "a4", atomx.getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLAtomArray#getAtoms()}. */ @Test public final void testGetAtoms() { CMLAtomArray atomArray = new CMLAtomArray(); Assert.assertEquals("atom count ", 0, atomArray.size()); CMLAtom atom1 = new CMLAtom("a1"); atomArray.addAtom(atom1); CMLAtom atom2 = new CMLAtom("a2"); atomArray.addAtom(atom2); CMLAtom atom3 = new CMLAtom("a3"); atomArray.addAtom(atom3); List atomList = atomArray.getAtoms(); Assert.assertEquals("atoms", 3, atomList.size()); Assert.assertEquals("atom 3", "a3", atomList.get(2).getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLAtomArray#getAtomById(java.lang.String)} * . */ @Test public final void testGetAtomById() { CMLAtomArray atomArray = new CMLAtomArray(); Assert.assertEquals("atom count ", 0, atomArray.size()); CMLAtom atom1 = new CMLAtom("a1"); atomArray.addAtom(atom1); CMLAtom atom2 = new CMLAtom("a2"); atomArray.addAtom(atom2); CMLAtom atom3 = new CMLAtom("a3"); atomArray.addAtom(atom3); CMLAtom atomx = atomArray.getAtomById("a2"); Assert.assertEquals("atom 2", "a2", atomx.getId()); atomx = atomArray.getAtomById("a4"); Assert.assertNull("atom 4", atomx); CMLAtom atom4 = new CMLAtom("a4"); atomArray.addAtom(atom4); atomx = atomArray.getAtomById("a4"); Assert.assertNotNull("atom 4", atomx); Assert.assertEquals("atom 4", "a4", atomx.getId()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/lite/CMLAtomParityTest.java000077500000000000000000000103351477224461000303120ustar00rootroot00000000000000/** * 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.lite; import java.util.List; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLAtomArray; import org.xmlcml.cml.element.CMLAtomParity; import org.xmlcml.cml.element.CMLMolecule; /** * tests CMLAtomParity. * * @author pm286 * */ public class CMLAtomParityTest { String s = "" + "" + " " + " " + " 1" + " " + " " + " " + " " + " " + " " + "" + ""; CMLAtomParity parity = null; CMLMolecule molecule = null; CMLAtomArray atomArray = null; CMLAtom atom = null; CMLAtom[] ligands = null; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { molecule = (CMLMolecule)CMLXOMTestUtils.parseValidString(s); List atoms = molecule.getAtoms(); atom = atoms.get(0); parity = atom.getAtomParityElements().get(0); ligands = new CMLAtom[4]; for (int i = 0; i < 4; i++) { ligands[i] = atoms.get(i + 1); } } /** * Test method for 'org.xmlcml.cml.element.CMLAtomParity.copy()' */ @Test public void testCopy() { CMLAtomParity parity1 = (CMLAtomParity) parity.copy(); Assert.assertEquals("copy", new String[] { "a2", "a3", "a4", "a5" }, parity1.getAtomRefs4()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomParity.setAtomRefs4(CMLAtom[])' */ @Test public void testSetAtomRefs4CMLAtomArray() { parity.removeAttribute("atomRefs4"); Assert.assertNull("no parity atoms", parity.getAtomRefs4Attribute()); parity.setAtomRefs4(ligands); Assert.assertEquals("parity atoms", new String[] { "a2", "a3", "a4", "a5" }, parity.getAtomRefs4()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomParity.rearrangeAtomRefs4(String[])' */ @Test public void testRearrangeAtomRefs4() { Assert.assertTrue("parity positive", parity.getXMLContent() > 0.1); parity.rearrangeAtomRefs4(new String[] { "a3", "a2", "a4", "a5" }); Assert.assertTrue("parity negative", parity.getXMLContent() < 0.1); parity.rearrangeAtomRefs4(new String[] { "a3", "a4", "a5", "a2" }); Assert.assertTrue("parity negative", parity.getXMLContent() < 0.1); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomParity.getIntegerValue()' */ @Test public void testGetIntegerValue() { Assert.assertEquals("parity positive", 1, parity.getIntegerValue()); parity.rearrangeAtomRefs4(new String[] { "a3", "a2", "a4", "a5" }); Assert.assertEquals("parity negative", -1, parity.getIntegerValue()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomParity.getAtomRefs4(CMLMolecule)' */ @Test public void testGetAtomRefs4CMLMolecule() { CMLAtom[] atoms = parity.getAtomRefs4(molecule); Assert.assertEquals("get atoms", 4, atoms.length); Assert.assertEquals("get atom", "a2", atoms[0].getId()); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomParity.isZero()' */ @Test public void testIsZero() { Assert.assertFalse("non-zero parity", parity.isZero()); parity.setXMLContent(0.0); Assert.assertTrue("zero parity", parity.isZero()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/lite/CMLAtomTest.java000077500000000000000000001113741477224461000271260ustar00rootroot00000000000000/** * 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.lite; import static org.xmlcml.euclid.EuclidConstants.S_RBRAK; import nu.xom.Node; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.attribute.IdAttribute; import org.xmlcml.cml.base.CMLAttribute; import org.xmlcml.cml.base.CMLElement.CoordinateType; import org.xmlcml.cml.base.CMLElement.FormalChargeControl; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLBond; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.main.MoleculeAtomBondFixture; import org.xmlcml.euclid.Angle; import org.xmlcml.euclid.EC; import org.xmlcml.euclid.EuclidConstants; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Real2; import org.xmlcml.euclid.Transform2; import org.xmlcml.euclid.Transform3; import org.xmlcml.euclid.Vector3; import org.xmlcml.euclid.test.DoubleTestBase; import org.xmlcml.molutil.ChemicalElement; import org.xmlcml.molutil.ChemicalElement.AS; /** * test CMLAtom. * * @author pmr * */ public class CMLAtomTest { MoleculeAtomBondFixture fixture; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { fixture = new MoleculeAtomBondFixture(); /* * -- String chiralMol = "\r\n"+ * \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n * \r\n \r\n \r\n \r\n \r\n \r\n * \r\n \r\n H\r\n * \r\n \r\n \r\n * H\r\n \r\n \r\n \r\n \r\n\r\n"; * * try { Document chrialDoc = builder.build(new * StringReader(chiralMol)); chrialMolecule = (CMLMolecule) * chrialDoc.getRootElement(); } catch (IOException e) { * Assert.fail("Should not throw IOException"); } catch * (ParsingException e) { e.printStackTrace(); * Assert.fail("Should not throw ParsingException"); } * * String simpleExplicitChiralMolS = * "\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n W\r\n \r\n \r\n \r\n \r\n\r\n" * ; String simpleExplicitChiralMolR = * "\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n H\r\n \r\n \r\n \r\n \r\n\r\n" * ; * * try { Document chrialDoc = builder.build(new * StringReader(simpleExplicitChiralMolS)); * simpleExplicitChiralMoleculeS = (CMLMolecule) * chrialDoc.getRootElement(); } catch (IOException e) { * Assert.fail("Should not throw IOException"); } catch * (ParsingException e) { e.printStackTrace(); * Assert.fail("Should not throw ParsingException"); } * * try { Document chrialDoc = builder.build(new * StringReader(simpleExplicitChiralMolR)); * simpleExplicitChiralMoleculeR = (CMLMolecule) * chrialDoc.getRootElement(); } catch (IOException e) { * Assert.fail("Should not throw IOException"); } catch * (ParsingException e) { e.printStackTrace(); * Assert.fail("Should not throw ParsingException"); } -- */ } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.copy()' */ @Test public void testCopy() { Node copy = fixture.xmlAtom[0].copy(); // XML-BASIC Assert.assertEquals("class should be CMLAtom: ", copy.getClass(), CMLAtom.class); CMLAtom copyAtom = (CMLAtom) copy; // XML-BASIC Assert.assertEquals("atom is identical", copyAtom .compareTo(fixture.xmlAtom[0]), 0); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.CMLAtom()' */ @Test public void testCMLAtom() { CMLAtom atom = new CMLAtom(); // XML-BASIC Assert.assertNotNull("constructor ", atom); Assert.assertNull("no id attribute", atom.getIdAttribute()); Assert.assertEquals("no children", atom.getChildCount(), 0); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.CMLAtom(CMLAtom)' */ @Test public void testCMLAtomCMLAtom() { // copy constructor // XML-BASIC CMLAtom xatom = fixture.xomAtom[0]; CMLAtom atom = new CMLAtom(xatom); Assert.assertNotNull("constructor ", atom); CMLAttribute idAtt = atom.getIdAttribute(); // XML-BASIC Assert.assertTrue("id class is subclass of CMLAttribute", CMLAttribute.class.isAssignableFrom(idAtt.getClass())); // XML-BASIC Assert.assertEquals("id class is StringSTAttribute", IdAttribute.class, idAtt.getClass()); // XML-BASIC Assert.assertEquals("id value", atom.getId(), xatom.getId()); // XML-BASIC Assert.assertEquals("atom is identical", 0, atom.compareTo(xatom)); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.getMolecule()' */ @Test public void testGetMolecule() { // xml CMLMolecule molecule = fixture.xmlAtom[0].getMolecule(); // XML-BASIC Assert.assertNotNull("molecule should not be null", molecule); // XML-BASIC Assert.assertEquals("get molecule", fixture.xmlMolecule, molecule); // dom molecule = fixture.xomAtom[0].getMolecule(); // XML-BASIC Assert.assertNotNull("molecule should not be null", molecule); // XML-BASIC Assert.assertEquals("get molecule", fixture.xomMolecule, molecule); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.getValenceElectrons()' */ @Test public void testGetValenceElectrons() { String el = fixture.xmlAtom[0].getElementType(); // XML-BASIC Assert.assertEquals("element type", AS.N.value, el); // DSL int ve = fixture.xmlAtom[0].getValenceElectrons(); Assert.assertEquals("valence electrons", 5, ve); el = fixture.xmlAtom[1].getElementType(); // XML-BASIC Assert.assertEquals("element type", AS.C.value, el); ve = fixture.xmlAtom[1].getValenceElectrons(); // DSL Assert.assertEquals("valence electrons", 4, ve); el = fixture.xmlAtom[2].getElementType(); // XML-BASIC Assert.assertEquals("element type", AS.S.value, el); ve = fixture.xmlAtom[2].getValenceElectrons(); // DSL Assert.assertEquals("valence electrons", 6, ve); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.getXY2()' */ @Test public void testGetXY2() { // xml Real2 xy2 = fixture.xmlAtom[1].getXY2(); // CML Assert.assertNotNull("xy2 is not null", xy2); // CML Assert.assertEquals("x coord", xy2.getX(), 1.0, EC.EPS); // CML Assert.assertEquals("y coord", xy2.getY(), 1.0, EC.EPS); // xom xy2 = fixture.xmlAtom[0].getXY2(); // CML Assert.assertNotNull("xy2 is not null", xy2); // CML Assert.assertEquals("x coord", xy2.getX(), .0, EC.EPS); // CML Assert.assertEquals("y coord", xy2.getY(), .0, EC.EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.setXY2(Real2)' */ @Test public void testSetXY2() { Real2 r2 = new Real2(7., 3.); // // CML fixture.xmlAtom[1].setXY2(r2); Assert.assertEquals("x2 coord", 7., fixture.xmlAtom[1].getX2(), EC.EPS); Assert.assertEquals("y2 coord", 3., fixture.xmlAtom[1].getY2(), EC.EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.getXYZ3()' */ @Test public void testGetXYZ3() { // CML Point3 p3 = fixture.xmlAtom[1].getXYZ3(); double[] test = new double[] { 1., 1., 1., }; Assert.assertNotNull("test should not be null (" + "3D coord" + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + "3D coord" + S_RBRAK, p3); DoubleTestBase.assertEquals("3D coord", test, p3.getArray(), EC.EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.setXYZ3(Point3)' */ @Test public void testSetXYZ3() { // CML Point3 p3 = new Point3(7., 3., 5.); fixture.xmlAtom[1].setXYZ3(p3); Point3 p3a = fixture.xmlAtom[1].getXYZ3(); double[] test = new double[] { 7., 3., 5., }; Assert.assertNotNull("test should not be null (" + "set 3D coord" + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + "set 3D coord" + S_RBRAK, p3a); DoubleTestBase.assertEquals("set 3D coord", test, p3a.getArray(), EC.EPS); Assert.assertEquals("x3 coord", 7., fixture.xmlAtom[1].getX3(), EC.EPS); Assert.assertEquals("y3 coord", 3., fixture.xmlAtom[1].getY3(), EC.EPS); Assert.assertEquals("z3 coord", 5., fixture.xmlAtom[1].getZ3(), EC.EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.unsetXY2()' */ @Test public void testUnsetXY2() { // CML CMLAtom atom = new CMLAtom(); atom.setXYZ3(new Point3(1.1, 2.2, 3.3)); Assert.assertFalse("has not xy2", atom .hasCoordinates(CoordinateType.TWOD)); Assert.assertTrue("has xyz3", atom .hasCoordinates(CoordinateType.CARTESIAN)); // CML atom.unsetXYZ3(); Assert.assertFalse("has not xy2", atom .hasCoordinates(CoordinateType.TWOD)); Assert.assertFalse("has not xyz3", atom .hasCoordinates(CoordinateType.CARTESIAN)); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.unsetXYZFract()' */ @Test public void testUnsetXYZFract() { // CML CMLAtom atom = new CMLAtom(); atom.setXYZFract(new Point3(0.1, 0.2, 0.3)); Assert.assertFalse("has not xy2", atom .hasCoordinates(CoordinateType.TWOD)); Assert.assertTrue("has xyzFract", atom .hasCoordinates(CoordinateType.FRACTIONAL)); atom.unsetXYZFract(); Assert.assertFalse("has not xy2", atom .hasCoordinates(CoordinateType.TWOD)); Assert.assertFalse("has not xyzFract", atom .hasCoordinates(CoordinateType.FRACTIONAL)); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.unsetXYZ2()' */ @Test public void testUnsetXYZ3() { // CML CMLAtom atom = new CMLAtom(); atom.setXY2(new Real2(1.1, 2.2)); Assert.assertTrue("has xy2", atom.hasCoordinates(CoordinateType.TWOD)); Assert.assertFalse("has not xyz3", atom .hasCoordinates(CoordinateType.CARTESIAN)); atom.unsetXY2(); Assert.assertFalse("has not xy2", atom .hasCoordinates(CoordinateType.TWOD)); Assert.assertFalse("has not xyz3", atom .hasCoordinates(CoordinateType.CARTESIAN)); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.getFractCoord()' */ @Test public void testGetFractCoord() { // CML Point3 p3 = fixture.xmlAtom[0].getFractCoord(); Assert.assertNotNull("non null fract coord", p3); double[] test = new double[] { 0.1, 0.2, 0.3, }; Assert.assertNotNull("test should not be null (" + "3D coord" + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + "3D coord" + S_RBRAK, p3); DoubleTestBase.assertEquals("3D coord", test, p3.getArray(), EC.EPS); p3 = fixture.xmlAtom[1].getFractCoord(); Assert.assertNull("null fract coord", p3); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.getChemicalElement()' */ @Test public void testGetChemicalElement() { // DSL ChemicalElement el = fixture.xmlAtom[0].getChemicalElement(); Assert.assertEquals("element", el, ChemicalElement .getChemicalElement(AS.N.value)); el = fixture.xmlAtom[1].getChemicalElement(); Assert.assertEquals("element", el, ChemicalElement .getChemicalElement(AS.C.value)); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.getAtomicNumber()' */ @Test public void testGetAtomicNumber() { // DSL int atNum = fixture.xmlAtom[0].getAtomicNumber(); Assert.assertEquals("atomic number", atNum, 7); atNum = fixture.xmlAtom[1].getAtomicNumber(); Assert.assertEquals("atomic number", atNum, 6); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.compareTo(CMLAtom)' */ @Test public void testCompareToCMLAtom() { // XML-BASIC-TEST?? int comp = fixture.xmlAtom[0].compareTo(fixture.xmlAtom[0]); Assert.assertEquals("same atom comparison", comp, 0); comp = fixture.xmlAtom[0].compareTo(fixture.xmlAtom[1]); Assert.assertFalse("different atom comparison", comp == 0); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtom.get3DCrossProduct(CMLAtom, CMLAtom)' */ @Test public void testGet3DCrossProduct() { // DSL Vector3 cross3d = fixture.xmlAtom[0].get3DCrossProduct( fixture.xmlAtom[1], fixture.xmlAtom[2]); double[] test = new double[] { 0., 2., -2. }; Assert.assertNotNull("test should not be null (" + "cross3d" + EuclidConstants.S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("expected should not be null (" + "cross3d" + EuclidConstants.S_RBRAK, cross3d); DoubleTestBase.assertEquals("cross3d", test, cross3d.getArray(), EC.EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtom.get2DCrossProduct(CMLAtom, CMLAtom)' */ @Test public void testGet2DCrossProduct() { // DSL Vector3 cross2d = fixture.xmlAtom[0].get2DCrossProduct( fixture.xmlAtom[1], fixture.xmlAtom[2]); double[] test = new double[] { 0., 0., -2. }; Assert.assertNotNull("test should not be null (" + "cross2d" + EuclidConstants.S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("expected should not be null (" + "cross2d" + EuclidConstants.S_RBRAK, cross2d); DoubleTestBase.assertEquals("cross2d", test, cross2d.getArray(), EC.EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.get2DPoint3()' */ @Test public void testGet2DPoint3() { // DSL Point3 point3 = fixture.xmlAtom[1].get2DPoint3(); double[] test = new double[] { 1., 1., 0. }; Assert.assertNotNull("test should not be null (" + "point23" + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + "point23" + S_RBRAK, point3); DoubleTestBase.assertEquals("point23", test, point3.getArray(), EC.EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.getVector3(CMLAtom)' */ @Test public void testGetVector3() { // DSL Vector3 v3 = fixture.xmlAtom[0].getVector3(fixture.xmlAtom[1]); double[] test = new double[] { 1., 1., 1. }; Assert.assertNotNull("test should not be null (" + "atom0 atom1" + EuclidConstants.S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("expected should not be null (" + "atom0 atom1" + EuclidConstants.S_RBRAK, v3); DoubleTestBase.assertEquals("atom0 atom1", test, v3.getArray(), EC.EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.getMoleculeAncestor()' */ @Test public void testGetMoleculeAncestor() { // DSL CMLMolecule molecule = CMLMolecule .getMoleculeAncestor(fixture.xmlAtom[0]); Assert.assertSame("molecule ancestor", fixture.xmlMolecule, molecule); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.setAtomId(String)' */ @Test public void testResetAtomId() { // CML CMLAtom atom = fixture.xmlAtom[0]; String id = atom.getId(); Assert.assertEquals("atom id ", "a1", id); atom.resetId("newId"); id = atom.getId(); Assert.assertEquals("atom id ", "newId", id); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.increaseXY2(double, * double)' */ @Test public void testIncreaseXY2() { // DSL CMLAtom atom = fixture.xmlAtom[2]; Real2 xy2 = atom.getXY2(); Assert.assertNotNull("xy2 ", xy2); Assert.assertEquals("xy2.x before ", 1.0, xy2.getX(), EC.EPS); Assert.assertEquals("xy2.y before ", -1.0, xy2.getY(), EC.EPS); atom.setXY2(new Real2(1.2, 3.4)); xy2 = atom.getXY2(); Assert.assertNotNull("xy2 not null", xy2); Assert.assertEquals("xy2.x after ", 1.2, xy2.getX(), EC.EPS); Assert.assertEquals("xy2.y after ", 3.4, xy2.getY(), EC.EPS); atom.increaseXY2(2., 3.); xy2 = atom.getXY2(); Assert.assertNotNull("xy2 not null", xy2); Assert.assertEquals("xy2.x after translate", 3.2, xy2.getX(), EC.EPS); Assert.assertEquals("xy2.y after translate", 6.4, xy2.getY(), EC.EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.transform(Transform2)' */ @Test public void testTransformTransform2() { // DSL CMLAtom atom = fixture.xmlAtom[2]; atom.setXY2(new Real2(1., 2.)); Transform2 t2 = new Transform2(new Angle(Math.PI / 2.)); atom.transform(t2); Real2 xy2 = atom.getXY2(); Assert.assertNotNull("xy2 not null", xy2); Assert.assertEquals("xy2.x after ", 2., xy2.getX(), EC.EPS); Assert.assertEquals("xy2.y after ", -1., xy2.getY(), EC.EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.increaseXYZ3(double, * double, double)' */ @Test public void testIncreaseXYZ3() { // DSL CMLAtom atom = fixture.xmlAtom[2]; Point3 p3 = atom.getXYZ3(); Assert.assertNotNull("p3 ", p3); double[] test = new double[] { 1.0, -1., -1. }; Assert.assertNotNull("test should not be null (" + "p3 before " + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + "p3 before " + S_RBRAK, p3); DoubleTestBase.assertEquals("p3 before ", test, p3.getArray(), EC.EPS); atom.setXYZ3(new Point3(1.2, 3.4, 5.6)); p3 = atom.getXYZ3(); Assert.assertNotNull("p3 not null", p3); double[] test1 = new double[] { 1.2, 3.4, 5.6 }; Assert.assertNotNull("test should not be null (" + "p3 after " + S_RBRAK, test1); Assert.assertEquals("must be of length 3", 3, test1.length); Assert.assertNotNull("ref should not be null (" + "p3 after " + S_RBRAK, p3); DoubleTestBase.assertEquals("p3 after ", test1, p3.getArray(), EC.EPS); atom.increaseXYZ3(2., 3., 4.); p3 = atom.getXYZ3(); Assert.assertNotNull("p3 not null", p3); double[] test2 = new double[] { 3.2, 6.4, 9.6 }; Assert.assertNotNull("test should not be null (" + "p3 after translate" + S_RBRAK, test2); Assert.assertEquals("must be of length 3", 3, test2.length); Assert.assertNotNull("ref should not be null (" + "p3 after translate" + S_RBRAK, p3); DoubleTestBase.assertEquals("p3 after translate", test2, p3.getArray(), EC.EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.increaseXYZFract(double, * double, double)' */ @Test public void testIncreaseXYZFract() { // DSL CMLAtom atom = fixture.xmlAtom[2]; Point3 p3 = atom.getXYZFract(); Assert.assertNull("p3 ", p3); atom.setXYZFract(new Point3(.12, .34, .56)); p3 = atom.getXYZFract(); Assert.assertNotNull("p3 not null", p3); double[] test = new double[] { .12, .34, .56 }; Assert.assertNotNull("test should not be null (" + "p3 after " + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + "p3 after " + S_RBRAK, p3); DoubleTestBase.assertEquals("p3 after ", test, p3.getArray(), EC.EPS); atom.increaseXYZFract(.2, .3, .4); p3 = atom.getXYZFract(); Assert.assertNotNull("p3 not null", p3); double[] test1 = new double[] { .32, .64, .96 }; Assert.assertNotNull("test should not be null (" + "p3 after translate" + S_RBRAK, test1); Assert.assertEquals("must be of length 3", 3, test1.length); Assert.assertNotNull("ref should not be null (" + "p3 after translate" + S_RBRAK, p3); DoubleTestBase.assertEquals("p3 after translate", test1, p3.getArray(), EC.EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.getHydrogenCount()' */ @Test public final void testGetHydrogenCount() { CMLAtom atom = new CMLAtom(); // XML-BASIC int nh = atom.getHydrogenCount(); Assert.assertEquals("empty atom", 0, nh); atom.setHydrogenCount(3); nh = atom.getHydrogenCount(); Assert.assertEquals("atom with H", 3, nh); // CML CMLMolecule molecule = new CMLMolecule(); CMLAtom atom1 = new CMLAtom("a1", ChemicalElement .getChemicalElement(AS.O.value)); molecule.addAtom(atom1); CMLAtom atom2 = new CMLAtom("a1_h1", ChemicalElement .getChemicalElement(AS.H.value)); molecule.addAtom(atom2); molecule.addBond(new CMLBond(atom1, atom2)); CMLAtom atom3 = new CMLAtom("a1_h2", ChemicalElement .getChemicalElement(AS.H.value)); molecule.addAtom(atom3); molecule.addBond(new CMLBond(atom1, atom3)); nh = atom1.getHydrogenCount(); Assert.assertEquals("h2o", 2, nh); } @Test public void testGetHydrogenCountMixedHydrogens() { CMLMolecule molecule = new CMLMolecule(); CMLAtom atom1 = new CMLAtom("a1", ChemicalElement .getChemicalElement(AS.C.value)); molecule.addAtom(atom1); atom1.setHydrogenCount(4); Assert.assertEquals(4, atom1.getHydrogenCount()); CMLAtom atom2 = new CMLAtom("a1_h1", ChemicalElement .getChemicalElement(AS.H.value)); molecule.addAtom(atom2); molecule.addBond(new CMLBond(atom1, atom2)); Assert.assertEquals(4, atom1.getHydrogenCount()); CMLAtom atom3 = new CMLAtom("a1_h2", ChemicalElement .getChemicalElement(AS.H.value)); molecule.addAtom(atom3); molecule.addBond(new CMLBond(atom1, atom3)); Assert.assertEquals(4, atom1.getHydrogenCount()); CMLAtom atom4 = new CMLAtom("a1_h3", ChemicalElement .getChemicalElement(AS.H.value)); molecule.addAtom(atom4); molecule.addBond(new CMLBond(atom1, atom4)); Assert.assertEquals(4, atom1.getHydrogenCount()); CMLAtom atom5 = new CMLAtom("a1_h4", ChemicalElement .getChemicalElement(AS.H.value)); molecule.addAtom(atom5); molecule.addBond(new CMLBond(atom1, atom5)); Assert.assertEquals(4, atom1.getHydrogenCount()); atom1.setHydrogenCount(2); //hydrogenCount is overridden by additional explicit hydrogens Assert.assertEquals(4, atom1.getHydrogenCount()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtom.getPoint3(CoordinateType)' also tests set */ @Test public final void testGetPoint3() { // CML Point3 p = fixture.xomAtom[0].getPoint3(CoordinateType.CARTESIAN); double[] test = new double[] { 0.0, 1.0, 2.0 }; Assert.assertNotNull("test should not be null (" + "getPoint3" + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + "getPoint3" + S_RBRAK, p); DoubleTestBase.assertEquals("getPoint3", test, p.getArray(), EC.EPS); // test set fixture.xomAtom[0].setPoint3(new Point3(1.1, 1.2, 1.3), CoordinateType.CARTESIAN); p = fixture.xomAtom[0].getPoint3(CoordinateType.CARTESIAN); double[] test1 = new double[] { 1.1, 1.2, 1.3 }; Assert.assertNotNull("test should not be null (" + "getPoint3" + S_RBRAK, test1); Assert.assertEquals("must be of length 3", 3, test1.length); Assert.assertNotNull("ref should not be null (" + "getPoint3" + S_RBRAK, p); DoubleTestBase.assertEquals("getPoint3", test1, p.getArray(), EC.EPS); // fractional originally missing p = fixture.xomAtom[0].getPoint3(CoordinateType.FRACTIONAL); Assert.assertNull("get fract", p); // set it fixture.xomAtom[0].setPoint3(new Point3(0.1, 0.2, 0.3), CoordinateType.FRACTIONAL); p = fixture.xomAtom[0].getPoint3(CoordinateType.FRACTIONAL); Assert.assertNotNull("get fract", p); double[] test2 = new double[] { 0.1, 0.2, 0.3 }; Assert.assertNotNull("test should not be null (" + "getPoint3" + S_RBRAK, test2); Assert.assertEquals("must be of length 3", 3, test2.length); Assert.assertNotNull("ref should not be null (" + "getPoint3" + S_RBRAK, p); DoubleTestBase.assertEquals("getPoint3", test2, p.getArray(), EC.EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.transform(Transform3)' */ @Test public final void testTransformXYZTransform3() { // DSL Transform3 t = new Transform3("y, -x, y+z"); fixture.xomAtom[0].setPoint3(new Point3(1.1, 1.2, 1.3), CoordinateType.CARTESIAN); Point3 p = fixture.xomAtom[0].getPoint3(CoordinateType.CARTESIAN); double[] test = new double[] { 1.1, 1.2, 1.3 }; Assert.assertNotNull("test should not be null (" + "getPoint3" + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + "getPoint3" + S_RBRAK, p); DoubleTestBase.assertEquals("getPoint3", test, p.getArray(), EC.EPS); fixture.xomAtom[0].transformCartesians(t); p = fixture.xomAtom[0].getPoint3(CoordinateType.CARTESIAN); double[] test1 = new double[] { 1.2, -1.1, 2.5 }; Assert.assertNotNull("test should not be null (" + "getPoint3" + S_RBRAK, test1); Assert.assertEquals("must be of length 3", 3, test1.length); Assert.assertNotNull("ref should not be null (" + "getPoint3" + S_RBRAK, p); DoubleTestBase.assertEquals("getPoint3", test1, p.getArray(), EC.EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.getXYZFract()' */ @Test public final void testGetSetXYZFract() { // DSL // fractional originally missing Point3 p = fixture.xomAtom[0].getPoint3(CoordinateType.FRACTIONAL); Assert.assertNull("get fract", p); // set it fixture.xomAtom[0].setXYZFract(new Point3(0.1, 0.2, 0.3)); p = fixture.xomAtom[0].getXYZFract(); Assert.assertNotNull("get fract", p); double[] test = new double[] { 0.1, 0.2, 0.3 }; Assert.assertNotNull("test should not be null (" + "getPoint3" + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + "getPoint3" + S_RBRAK, p); DoubleTestBase.assertEquals("getPoint3", test, p.getArray(), EC.EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtom.transformFractionalCoordinates(Transform3 * ) ' */ @Test public final void testTransformFractionalCoordinatesTransform3() { // DSL Transform3 t = new Transform3("y, 1/2-x, y+z"); fixture.xomAtom[0].setPoint3(new Point3(0.1, 0.2, 0.3), CoordinateType.FRACTIONAL); Point3 p = fixture.xomAtom[0].getPoint3(CoordinateType.FRACTIONAL); double[] test = new double[] { 0.1, 0.2, 0.3 }; Assert.assertNotNull("test should not be null (" + "getPoint3" + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + "getPoint3" + S_RBRAK, p); DoubleTestBase.assertEquals("getPoint3", test, p.getArray(), EC.EPS); fixture.xomAtom[0].transformFractionals(t); p = fixture.xomAtom[0].getPoint3(CoordinateType.FRACTIONAL); double[] test1 = new double[] { 0.2, 0.4, 0.5 }; Assert.assertNotNull("test should not be null (" + "getPoint3" + S_RBRAK, test1); Assert.assertEquals("must be of length 3", 3, test1.length); Assert.assertNotNull("ref should not be null (" + "getPoint3" + S_RBRAK, p); DoubleTestBase.assertEquals("getPoint3", test1, p.getArray(), EC.EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtom.getFormalCharge(FormalChargeControl)' */ @Test public final void testGetFormalChargeFormalChargeControl() { // DSL // charge is not set on this atom, so NO_DEFAULT throws error int fc = fixture.xomAtom[0] .getFormalCharge(FormalChargeControl.DEFAULT); Assert.assertEquals("formal charge", 0, fc); String err = "BUG: (unset attribute: formalCharge)should never throw"; try { fc = fixture.xomAtom[0] .getFormalCharge(FormalChargeControl.NO_DEFAULT); } catch (RuntimeException e) { Assert.assertEquals("no default", err, e.getMessage()); } // charge is set on this atom, so no default fc = fixture.xmlAtom[0].getFormalCharge(FormalChargeControl.DEFAULT); Assert.assertEquals("formal charge", 1, fc); err = "org.xmlcml.cml.base.CMLRuntime: unset attribute: formalCharge"; fc = fixture.xmlAtom[0].getFormalCharge(FormalChargeControl.NO_DEFAULT); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.getElemNumb(String)' */ @Test public final void testCommonElementSerialNumber() { // DSL int en = CMLAtom.getCommonElementSerialNumber(AS.Si.value); Assert.assertEquals("common serial", 5, en); en = CMLAtom.getCommonElementSerialNumber("Pt"); Assert.assertEquals("common serial", -1, en); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.getDistanceTo(CMLAtom)' */ @Test public final void testGetDistanceTo() { // DSL double d = fixture.xomAtom[0].getDistanceTo(fixture.xomAtom[1]); Assert.assertEquals("distance", Math.sqrt(3.), d, EC.EPS); d = fixture.xomAtom[0].getDistanceTo(fixture.xomAtom[0]); Assert.assertEquals("distance", 0.0, d, EC.EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.getDistanceTo(CMLAtom)' */ @Test public final void testIsWithinRadiusSum() { // DSL CMLAtom atom0 = new CMLAtom("a0"); atom0.setElementType(AS.C.value); CMLAtom atom1 = new CMLAtom("a1"); atom1.setElementType(AS.O.value); boolean b = atom0.isWithinRadiusSum(atom1, ChemicalElement.RadiusType.VDW); Assert.assertFalse("sum", b); atom0.setPoint3(new Point3(0., 0., 0.), CoordinateType.CARTESIAN); atom1.setPoint3(new Point3(2., 0., 0.), CoordinateType.CARTESIAN); b = atom0.isWithinRadiusSum(atom1, ChemicalElement.RadiusType.VDW); Assert.assertTrue("sum", b); atom1.setPoint3(new Point3(4., 0., 0.), CoordinateType.CARTESIAN); b = atom0.isWithinRadiusSum(atom1, ChemicalElement.RadiusType.VDW); Assert.assertFalse("sum", b); } /** * Test method for 'org.xmlcml.cml.element.CMLAtom.roundCoords(double)' */ @Test public final void testRoundCoords() { // DSL CMLAtom atom = new CMLAtom(); atom.setPoint3(new Point3(0.1009, 0.2021, -0.3011), CoordinateType.FRACTIONAL); Point3 p = atom.getPoint3(CoordinateType.FRACTIONAL); double[] test = new double[] { 0.1009, 0.2021, -0.3011 }; Assert.assertNotNull("test should not be null (" + "getPoint3" + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + "getPoint3" + S_RBRAK, p); DoubleTestBase.assertEquals("getPoint3", test, p.getArray(), EC.EPS); atom .setPoint3(new Point3(1.001, 2.22, -3.13), CoordinateType.CARTESIAN); p = atom.getPoint3(CoordinateType.CARTESIAN); double[] test1 = new double[] { 1.001, 2.22, -3.13 }; Assert.assertNotNull("test should not be null (" + "getPoint3" + S_RBRAK, test1); Assert.assertEquals("must be of length 3", 3, test1.length); Assert.assertNotNull("ref should not be null (" + "getPoint3" + S_RBRAK, p); DoubleTestBase.assertEquals("getPoint3", test1, p.getArray(), EC.EPS); double epsilon = 0.001; atom.roundCoords(epsilon, CoordinateType.FRACTIONAL); p = atom.getPoint3(CoordinateType.FRACTIONAL); double[] test2 = new double[] { 0.100, 0.202, -0.301 }; Assert.assertNotNull("test should not be null (" + "getPoint3" + S_RBRAK, test2); Assert.assertEquals("must be of length 3", 3, test2.length); Assert.assertNotNull("ref should not be null (" + "getPoint3" + S_RBRAK, p); DoubleTestBase.assertEquals("getPoint3", test2, p.getArray(), EC.EPS); p = atom.getPoint3(CoordinateType.CARTESIAN); double[] test3 = new double[] { 1.001, 2.22, -3.13 }; Assert.assertNotNull("test should not be null (" + "getPoint3" + S_RBRAK, test3); Assert.assertEquals("must be of length 3", 3, test3.length); Assert.assertNotNull("ref should not be null (" + "getPoint3" + S_RBRAK, p); DoubleTestBase.assertEquals("getPoint3", test3, p.getArray(), EC.EPS); epsilon = 0.1; atom.roundCoords(epsilon, CoordinateType.CARTESIAN); p = atom.getPoint3(CoordinateType.CARTESIAN); double[] test4 = new double[] { 1.0, 2.2, -3.1 }; Assert.assertNotNull("test should not be null (" + "getPoint3" + S_RBRAK, test4); Assert.assertEquals("must be of length 3", 3, test4.length); Assert.assertNotNull("ref should not be null (" + "getPoint3" + S_RBRAK, p); DoubleTestBase.assertEquals("getPoint3", test4, p.getArray(), EC.EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtom.hasCoordinates(CoordinateType)' */ @Test public final void testHasCoordinates() { // DSL CMLAtom atom = new CMLAtom(); Assert.assertFalse(atom.hasCoordinates(CoordinateType.CARTESIAN)); Assert.assertFalse(atom.hasCoordinates(CoordinateType.FRACTIONAL)); Assert.assertFalse(atom.hasCoordinates(CoordinateType.TWOD)); atom.setPoint3(new Point3(0.1009, 0.2021, -0.3011), CoordinateType.FRACTIONAL); Assert.assertFalse(atom.hasCoordinates(CoordinateType.CARTESIAN)); Assert.assertTrue(atom.hasCoordinates(CoordinateType.FRACTIONAL)); Assert.assertFalse(atom.hasCoordinates(CoordinateType.TWOD)); atom.setPoint3(new Point3(1.1009, 1.2021, -3.3011), CoordinateType.CARTESIAN); Assert.assertTrue(atom.hasCoordinates(CoordinateType.CARTESIAN)); Assert.assertTrue(atom.hasCoordinates(CoordinateType.FRACTIONAL)); Assert.assertFalse(atom.hasCoordinates(CoordinateType.TWOD)); atom.setXY2(new Real2(11, 22)); Assert.assertTrue(atom.hasCoordinates(CoordinateType.CARTESIAN)); Assert.assertTrue(atom.hasCoordinates(CoordinateType.FRACTIONAL)); Assert.assertTrue(atom.hasCoordinates(CoordinateType.TWOD)); atom.removeAttribute("x2"); atom.removeAttribute("y2"); Assert.assertTrue("remove x2y2", atom .hasCoordinates(CoordinateType.CARTESIAN)); Assert.assertTrue("remove x2y2", atom .hasCoordinates(CoordinateType.FRACTIONAL)); Assert.assertFalse("remove x2y2", atom .hasCoordinates(CoordinateType.TWOD)); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtom.compareByAtomicNumber(CMLAtom)' */ @Test public final void testCompareByAtomicNumber() { // DSL CMLAtom atom1 = new CMLAtom(); atom1.setElementType(AS.C.value); CMLAtom atom2 = new CMLAtom(); atom2.setElementType(AS.N.value); Assert.assertEquals("compare", -1, atom1.compareByAtomicNumber(atom2)); Assert.assertEquals("compare", 1, atom2.compareByAtomicNumber(atom1)); Assert.assertEquals("compare", 0, atom2.compareByAtomicNumber(atom2)); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/lite/CMLBondArrayTest.java000077500000000000000000000232201477224461000300770ustar00rootroot00000000000000/** * 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.lite; import java.util.List; import java.util.Map; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLBond; import org.xmlcml.cml.element.CMLBondArray; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.main.MoleculeAtomBondFixture; /** * @author pm286 * */ public class CMLBondArrayTest { MoleculeAtomBondFixture fixture = new MoleculeAtomBondFixture(); CMLMolecule moleculex; CMLBondArray bondArrayx; CMLAtom atom0x; CMLAtom atom1x; CMLAtom atom2x; CMLBond bond01x; CMLBond bond12x; /** * @throws java.lang.Exception */ @Before public synchronized void setUp() throws Exception { makeMola(); } void makeMola() { moleculex = CMLMolecule.createMoleculeWithId("m1"); atom0x = new CMLAtom("a0"); moleculex.addAtom(atom0x); atom1x = new CMLAtom("a1"); moleculex.addAtom(atom1x); bond01x = new CMLBond("b01", atom0x, atom1x); moleculex.appendChild(bond01x); bondArrayx = moleculex.getBondArray(); atom2x = new CMLAtom("a2"); moleculex.addAtom(atom2x); bond12x = new CMLBond("b12", atom1x, atom2x); bondArrayx.addBond(bond12x); } /** * Test method for {@link org.xmlcml.cml.element.CMLBondArray#detach()} * . */ @Test public final void testDetach() { CMLMolecule xomMolecule = fixture.xomMolecule; CMLBondArray bondArray = xomMolecule.getBondArray(); Assert.assertNotNull("get bondarray", bondArray); List bondList = xomMolecule.getBonds(); Assert.assertEquals("bond count before detach", 5, bondList.size()); Assert.assertEquals("bond count before detach", 5, bondArray.getBondElements() .size()); CMLBond b1 = xomMolecule.getBondById("b1"); Assert.assertNotNull("get bond", b1); Assert.assertEquals("get bond", "b1", b1.getId()); bondArray.detach(); Assert.assertEquals("bond count after detach", 5, bondArray.getBondElements() .size()); bondList = xomMolecule.getBonds(); Assert.assertEquals("bond count after detach", 0, bondList.size()); b1 = xomMolecule.getBondById("b1"); Assert.assertNull("get bond", b1); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBondArray#CMLBondArray()}. */ @Test public final void testCMLBondArray() { CMLBondArray bondArray = new CMLBondArray(); Assert.assertNotNull("get bondarray", bondArray); CMLMolecule xMolecule = CMLMolecule.createMoleculeWithId("m1"); CMLAtom atom0 = new CMLAtom("a0"); xMolecule.addAtom(atom0); CMLAtom atom1 = new CMLAtom("a1"); xMolecule.addAtom(atom1); CMLAtom atom2 = new CMLAtom("a2"); xMolecule.addAtom(atom2); List bondList = bondArray.getBonds(); Assert.assertEquals("bond count ", 0, bondList.size()); CMLBond bond01 = new CMLBond("b01", atom0, atom1); // adding bond will fail, as no parent molecule try { bondArray.addBond(bond01); Assert.fail("cannot add bonds unless they belong to molecule"); } catch (RuntimeException e) { Assert.assertEquals("expected fail", "bondArray parent must be molecule", e.getMessage()); } xMolecule.addBondArray(bondArray); bondArray.addBond(bond01); CMLBond bond12 = new CMLBond("b12", atom1, atom2); bondArray.addBond(bond12); Assert.assertEquals("bond count ", 2, bondArray.size()); CMLBond bx = xMolecule.getBondById("b12"); Assert.assertNotNull("get bond not null", bx); Assert.assertEquals("get bond", "b12", bx.getId()); bondArray.detach(); Assert.assertEquals("bond count after detach", 2, bondArray.getBondElements() .size()); bondList = xMolecule.getBonds(); Assert.assertEquals("bond count after detach", 0, bondList.size()); bx = xMolecule.getBondById("b1"); Assert.assertNull("get bond", bx); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBondArray#appendChild(org.xmlcml.cml.element.CMLBond)} * . */ @Test public final void testAppendChildCMLBond() { CMLMolecule molecule = CMLMolecule.createMoleculeWithId("m1"); CMLBondArray bondArray = new CMLBondArray(); Assert.assertNotNull("get bondarray", bondArray); Assert.assertNull("mol bondarray", molecule.getBondArray()); CMLAtom atom0 = new CMLAtom("a0"); molecule.addAtom(atom0); CMLAtom atom1 = new CMLAtom("a1"); molecule.addAtom(atom1); CMLBond bond01 = new CMLBond("b01", atom0, atom1); molecule.appendChild(bond01); CMLBond bondx = molecule.getBonds().get(0); Assert.assertNotNull("bond01", bondx); // test size // bondArray not yet added Assert.assertEquals("size", 0, bondArray.size()); bondArray = molecule.getBondArray(); Assert.assertEquals("size", 1, bondArray.size()); CMLAtom atom2 = new CMLAtom("a2"); molecule.addAtom(atom2); CMLBond bond12 = new CMLBond("b12", atom1, atom2); bondArray.addBond(bond12); Assert.assertEquals("size", 2, bondArray.size()); } /** test insertBond(). */ @Test public final void testInsertBond() { makeMola(); // test insertBond CMLAtom atom3x = new CMLAtom("a3"); moleculex.addAtom(atom3x); CMLBond bond34x = new CMLBond("b23", atom2x, atom3x); bondArrayx.insertBond(bond34x, 1); Assert.assertEquals("size", 3, bondArrayx.size()); CMLBond bondx = moleculex.getBonds().get(1); Assert.assertEquals("insertBond ", "b23", bondx.getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBondArray#indexBonds()}. */ @Test public final void testIndexBonds() { makeMola(); // not easy to test this as it is kept uptodate // just make sure there is no error bondArrayx.indexBonds(); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBondArray#removeChild(CMLBond)}. */ @Test public final void testRemoveChild() { makeMola(); Assert.assertEquals("size", 2, bondArrayx.size()); bondArrayx.removeChild(bond01x); Assert.assertEquals("size", 1, bondArrayx.size()); CMLBond bondx = moleculex.getBonds().get(0); Assert.assertEquals("removeChild ", "b12", bondx.getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBondArray#removeBond(CMLBond)}. */ @Test public final void testRemoveBond() { makeMola(); bondArrayx.removeBond(bondArrayx.getBonds().get(0)); Assert.assertEquals("size", 1, bondArrayx.size()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBondArray#getBondMap()}. */ @Test public final void testGetBondMap() { makeMola(); Map bondMap = bondArrayx.getBondMap(); Assert.assertEquals("map size", 2, bondMap.size()); Assert.assertNull("id 99", bondMap.get("foo")); Assert.assertEquals("id 12", "b12", bondMap.get(CMLBond.atomHash(bond12x)) .getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBondArray#getBondIdMap()}. */ @Test public final void testGetBondIdMap() { makeMola(); Map bondIdMap = bondArrayx.getBondIdMap(); Assert.assertEquals("map size", 2, bondIdMap.size()); Assert.assertNull("id 99", bondIdMap.get("foo")); Assert.assertEquals("id 12", "b12", bondIdMap.get("b12").getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBondArray#getBonds()}. */ @Test public final void testGetBonds() { makeMola(); List bondList = bondArrayx.getBonds(); Assert.assertEquals("map size", 2, bondList.size()); Assert.assertEquals("id 01", "b01", bondList.get(0).getId()); Assert.assertEquals("id 12", "b12", bondList.get(1).getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBondArray#getBondByHash(java.lang.String)} * . */ @Test public final void testGetBondByHash() { makeMola(); CMLBond bondx = bondArrayx.getBondByHash(CMLBond.atomHash("a1", "a2")); Assert.assertEquals("id 12", "b12", bondx.getId()); bondx = bondArrayx.getBondByHash(CMLBond.atomHash("a2", "a1")); Assert.assertEquals("id 12", "b12", bondx.getId()); bondx = bondArrayx.getBondByHash(CMLBond.atomHash("a2", "a0")); Assert.assertNull("id 02", bondx); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBondArray#getBondByAtomRefs2(java.lang.String[])} * . */ @Test public final void testGetBondByAtomRefs2() { makeMola(); CMLBond bondx = bondArrayx .getBondByAtomRefs2(new String[] { "a1", "a2" }); Assert.assertEquals("id 12", "b12", bondx.getId()); bondx = bondArrayx.getBondByAtomRefs2(new String[] { "a2", "a1" }); Assert.assertEquals("id 12", "b12", bondx.getId()); bondx = bondArrayx.getBondByAtomRefs2(new String[] { "a2", "a0" }); Assert.assertNull("id 02", bondx); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBondArray#getBondById(java.lang.String)} * . */ @Test public final void testGetBondById() { makeMola(); CMLBond bondx = bondArrayx.getBondById("b12"); Assert.assertEquals("id 12", "b12", bondx.getId()); bondx = bondArrayx.getBondById("b99"); Assert.assertNull("id 02", bondx); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/lite/CMLBondStereoTest.java000077500000000000000000000047331477224461000302720ustar00rootroot00000000000000/** * 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.lite; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLBond; import org.xmlcml.cml.element.CMLBondStereo; import org.xmlcml.cml.element.CMLMolecule; /** * test bondStereo. * * @author pm286 * */ public class CMLBondStereoTest { /** * Test method for * 'org.xmlcml.cml.element.CMLBondStereo.matchParity(CMLBondStereo, * CMLMolecule)' */ @Test public void testMatchParity() { String s = "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " C" + " " + " " + " " + ""; CMLMolecule mol = (CMLMolecule) CMLXOMTestUtils.parseValidString(s); CMLBond b2 = mol.getBondByAtomIds("a2", "a3"); CMLBondStereo bs = b2.getBondStereo(); CMLBondStereo bs1 = new CMLBondStereo(); bs1.setAtomRefs4("a1 a2 a3 a4"); bs1.setXMLContent("C"); Assert.assertEquals("bs parity", 1, bs.matchParity(bs1)); // swap atom order bs1.setAtomRefs4("a4 a3 a2 a1"); Assert.assertEquals("bs parity", 1, bs.matchParity(bs1)); // swap sterochemistry bs1.setXMLContent("T"); Assert.assertEquals("bs parity", -1, bs.matchParity(bs1)); // garble order bs1.setAtomRefs4("a4 a2 a3 a1"); Assert.assertEquals("bs parity", 0, bs.matchParity(bs1)); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/lite/CMLBondTest.java000077500000000000000000000465171477224461000271160ustar00rootroot00000000000000/** * 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.lite; import java.util.List; import nu.xom.Node; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.attribute.IdAttribute; import org.xmlcml.cml.base.CMLAttribute; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.base.StringSTAttribute; import org.xmlcml.cml.base.CMLElement.CoordinateType; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLBond; import org.xmlcml.cml.element.CMLBondStereo; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.main.MoleculeAtomBondFixture; import org.xmlcml.euclid.Point3; import org.xmlcml.molutil.ChemicalElement.AS; /** * test CMLBond. * * @author pmr * */ public class CMLBondTest { MoleculeAtomBondFixture fixture = new MoleculeAtomBondFixture(); /** * Test method for 'org.xmlcml.cml.element.CMLBond.copy()' */ @Test public void testCopy() { Node copy = ((CMLBond) fixture.xmlBonds.get(0)).copy(); Assert.assertEquals("class should be CMLBond: ", copy.getClass(), CMLBond.class); CMLBond copyBond = (CMLBond) copy; Assert.assertEquals("bond is identical", copyBond .compareTo(((CMLBond) fixture.xmlBonds.get(0))), 0); } /** * Test method for 'org.xmlcml.cml.element.CMLBond.getOrder()' */ @Test public void testGetOrder() { String order = ((CMLBond) fixture.xmlBonds.get(0)).getOrder(); Assert.assertEquals("bond order", CMLBond.SINGLE_S, order); // note change of "S" // this fails until we have sorted the filling of bonds try { order = ((CMLBond) fixture.xmlBonds.get(1)).getOrder(); Assert.assertEquals("bond order", CMLBond.SINGLE_S, order); } catch (Exception e) { Assert.fail("should not throw exception " + e); } } /** * Test method for 'org.xmlcml.cml.element.CMLBond.CMLBond()' */ @Test public void testCMLBond() { CMLBond bond = new CMLBond(); Assert.assertNotNull("constructor ", bond); Assert.assertNull("no atomRefs2 attribute", bond .getAtomRefs2Attribute()); Assert.assertEquals("no children", bond.getChildCount(), 0); } /** * Test method for 'org.xmlcml.cml.element.CMLBond.CMLBond(CMLBond)' */ @Test public void testCMLBondCMLBond() { // copy constructor CMLBond xbond = fixture.xomBond[0]; CMLBond bond = new CMLBond(xbond); Assert.assertNotNull("constructor ", bond); CMLAttribute orderAtt = bond.getOrderAttribute(); Assert.assertTrue("order class is subclass of CMLAttribute", CMLAttribute.class.isAssignableFrom(orderAtt.getClass())); Assert.assertEquals("order class is StringSTAttribute", orderAtt .getClass(), StringSTAttribute.class); Assert.assertEquals("order value", bond.getOrder(), xbond.getOrder()); Assert.assertEquals("bond is identical", 0, bond.compareTo(xbond)); } /** * Test method for 'org.xmlcml.cml.element.CMLBond.getMolecule()' */ @Test public void testGetMolecule() { // xml CMLMolecule molecule = ((CMLBond) fixture.xmlBonds.get(0)) .getMolecule(); Assert.assertNotNull("molecule should not be null", molecule); Assert.assertEquals("get molecule", fixture.xmlMolecule, molecule); // dom molecule = fixture.xomBond[0].getMolecule(); Assert.assertNotNull("molecule should not be null", molecule); Assert.assertEquals("get molecule", fixture.xomMolecule, molecule); } /** * Test method for 'org.xmlcml.cml.element.CMLBond.getAtoms()' */ @Test public void testGetAtoms() { List atoms = fixture.xmlBonds.get(0).getAtoms(); Assert.assertEquals("atoms ", 2, atoms.size()); Assert.assertEquals("atom 1 id ", "a1", atoms.get(0).getId()); Assert.assertEquals("atom 2 id ", "a2", atoms.get(1).getId()); } /** * Test method for 'org.xmlcml.cml.element.CMLBond.appendToId(String, * boolean)' */ @Test public void testAppendToId() { List xmlBonds = fixture.xmlBonds; xmlBonds.get(0).resetId("B"); xmlBonds.get(0).appendToId("foo", true); Assert.assertEquals("new id ", "Bfoo", xmlBonds.get(0).getId()); } /** * Test method for 'org.xmlcml.cml.element.CMLBond.atomHash(String, String)' */ @Test public void testAtomHashStringString() { String hash = CMLBond.atomHash("a1", "a2"); Assert.assertEquals("bond hash", "a2" + CMLBond.HASH_SYMB + "a1", hash); hash = CMLBond.atomHash("a2", "a1"); Assert.assertEquals("bond hash", "a2" + CMLBond.HASH_SYMB + "a1", hash); } /** * Test method for 'org.xmlcml.cml.element.CMLBond.atomHash(CMLAtom, * CMLAtom)' */ @Test public void testAtomHashCMLAtomCMLAtom() { CMLAtom[] xmlAtom = fixture.xmlAtom; String hash = CMLBond.atomHash(xmlAtom[0], xmlAtom[1]); Assert.assertEquals("bond hash", "a2" + CMLBond.HASH_SYMB + "a1", hash); hash = CMLBond.atomHash(xmlAtom[1], xmlAtom[0]); Assert.assertEquals("bond hash", "a2" + CMLBond.HASH_SYMB + "a1", hash); fixture.makeMol5a(); CMLAtom atom1 = fixture.mol5a.getAtomById("a1"); Assert.assertNotNull("atom1 should not be null", atom1); CMLAtom atom3 = fixture.mol5a.getAtomById("a3"); Assert.assertNotNull("atom3 should not be null", atom3); hash = CMLBond.atomHash(atom1, atom3); Assert.assertEquals("bond hash", "a3" + CMLBond.HASH_SYMB + "a1", hash); } /** * Test method for 'org.xmlcml.cml.element.CMLBond.atomHash(CMLBond)' */ @Test public void testAtomHashCMLBond() { String hash = CMLBond.atomHash(((CMLBond) fixture.xmlBonds.get(0))); Assert.assertEquals("bond hash", "a2" + CMLBond.HASH_SYMB + "a1", hash); fixture.makeMol5a(); CMLMolecule mol5a = fixture.mol5a; CMLAtom atom1 = mol5a.getAtomById("a1"); Assert.assertNotNull("atom1 should not be null", atom1); CMLAtom atom4 = mol5a.getAtomById("a4"); Assert.assertNotNull("atom4 should not be null", atom4); hash = CMLBond.atomHash(atom1, atom4); Assert.assertEquals("bond hash", "a4" + CMLBond.HASH_SYMB + "a1", hash); CMLBond bond = mol5a.getBonds().get(1); hash = CMLBond.atomHash(bond); Assert.assertEquals("bond hash..", "a4" + CMLBond.HASH_SYMB + "a1", hash); } /** * Test method for 'org.xmlcml.cml.element.CMLBond.CMLBond(CMLAtom, * CMLAtom)' */ @Test public void testCMLBondCMLAtomCMLAtom() { CMLBond bond = new CMLBond(fixture.xmlAtoms.get(1), fixture.xmlAtoms .get(2)); bond.setId("b12"); fixture.xmlMolecule.addBond(bond); } /** * Test method for 'org.xmlcml.cml.element.CMLBond.atomHash()' */ @Test public void testAtomHash() { CMLBond bond = fixture.xmlMolecule.getBonds().get(0); String s = bond.atomHash(); Assert.assertEquals("hash", "a2" + CMLBond.HASH_SYMB + "a1", s); } /** * Test method for 'org.xmlcml.cml.element.CMLBond.getBondStereo()' */ @Test public void testGetSetBondStereo() { CMLBond bond = new CMLBond(); Assert.assertNull("no bond stereo", bond.getBondStereo()); CMLBondStereo bondStereo = new CMLBondStereo(); bond.setBondStereo(bondStereo); Assert.assertNotNull("bond stereo", bond.getBondStereo()); bond.setBondStereo(bondStereo); Assert.assertNotNull("bond stereo", bond.getBondStereo()); Assert.assertEquals("only one child", 1, bond.getBondStereoElements() .size()); } /** * Test method for 'org.xmlcml.cml.element.CMLBond.clearBondStereo()' */ @Test public void testClearBondStereo() { CMLBond bond = new CMLBond(); bond.clearBondStereo(); Assert.assertNull("no bond stereo", bond.getBondStereo()); CMLBondStereo bondStereo = new CMLBondStereo(); bond.setBondStereo(bondStereo); Assert.assertNotNull("bond stereo", bond.getBondStereo()); bond.clearBondStereo(); Assert.assertNull("cleared bond stereo", bond.getBondStereo()); } /** * Test method for * 'org.xmlcml.cml.element.CMLBond.areWithinBondingDistance(CMLAtom, * CMLAtom, double, double)' */ @Test public void testAreWithinBondingDistanceCMLAtomCMLAtomDoubleDouble() { CMLAtom atom1 = new CMLAtom(); atom1.setPoint3(new Point3(0.0, 0.0, 0.0), CoordinateType.CARTESIAN); atom1.setElementType(AS.C.value); CMLAtom atom2 = new CMLAtom(); atom2.setPoint3(new Point3(0.85, 0.85, 0.85), CoordinateType.CARTESIAN); atom2.setElementType(AS.C.value); Assert.assertTrue("bonded", CMLBond.areWithinBondingDistance(atom1, atom2)); // FIXME the latest change in bonding tolerance breaks this // ChemicalElement.setBondingRadiusTolerance(0.01); // Assert.assertFalse("bonded", CMLBond.areWithinBondingDistance(atom1, // atom2)); } /** * Test method for * 'org.xmlcml.cml.element.CMLBond.areWithinBondingDistance(CMLAtom, * CMLAtom)' */ @Test public void testAreWithinBondingDistanceCMLAtomCMLAtom() { CMLAtom atom1 = new CMLAtom(); atom1.setPoint3(new Point3(0.0, 0.0, 0.0), CoordinateType.CARTESIAN); atom1.setElementType("Pt"); CMLAtom atom2 = new CMLAtom(); atom2.setPoint3(new Point3(1.3, 1.3, 1.3), CoordinateType.CARTESIAN); atom2.setElementType("Pt"); Assert.assertTrue("bonded", CMLBond.areWithinBondingDistance(atom1, atom2)); } /** * Test method for 'org.xmlcml.cml.element.CMLBond.incrementOrder(int)' */ @Test public void testIncrementOrder() { CMLBond bond = new CMLBond(); Assert.assertNull("order null", bond.getOrder()); // note this forms a double bond bond.incrementOrder(1); Assert.assertEquals("order", CMLBond.DOUBLE_D, bond.getOrder()); bond.incrementOrder(1); Assert.assertEquals("order", CMLBond.TRIPLE_T, bond.getOrder()); try { bond.incrementOrder(1); } catch (RuntimeException e) { Assert.assertEquals("cannot increment bond order 3", RuntimeException.class.getName() + ": Cannot increment bond order 3", "" + e); } Assert.assertEquals("order", CMLBond.UNKNOWN_ORDER, bond.getOrder()); bond.setOrder(CMLBond.TRIPLE_T); Assert.assertEquals("order", CMLBond.TRIPLE_T, bond.getOrder()); bond.incrementOrder(-1); Assert.assertEquals("order", CMLBond.DOUBLE_D, bond.getOrder()); bond.incrementOrder(-1); Assert.assertEquals("order", CMLBond.SINGLE_S, bond.getOrder()); try { bond.incrementOrder(-1); } catch (RuntimeException e) { Assert.assertEquals("cannot decrement single", RuntimeException.class.getName() + ": Cannot decrement bond order "+CMLBond.SINGLE_S, "" + e); } Assert.assertEquals("order", CMLBond.SINGLE_S, bond.getOrder()); } /** * Test method for 'org.xmlcml.cml.element.CMLBond.getBondLength()' */ @Test public void testGetBondLength() { Assert.assertEquals("calculated length", Math.sqrt(3.), ((CMLBond) fixture.xmlBonds.get(0)) .getBondLength(CoordinateType.CARTESIAN), 0.00001); } private CMLBond getBond5a(int i) { fixture.makeMol5a(); return fixture.mol5a.getBonds().get(i); } /** * Test method for {@link org.xmlcml.cml.element.CMLBond#detach()}. */ @Test public final void testDetach() { CMLBond bond = getBond5a(0); bond.detach(); Assert.assertEquals("count", 3, fixture.mol5a.getBondCount()); Assert.assertEquals("count", 5, fixture.mol5a.getAtomCount()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBond#setId(java.lang.String)}. */ @Test public final void testSetId() { CMLBond bond = getBond5a(0); try { bond.setId("FOO"); } catch (RuntimeException e) { Assert.assertEquals("should throw", "Cannot reindex id", e .getMessage()); } bond.removeAttribute(IdAttribute.NAME); try { bond.setId("FOO"); } catch (RuntimeException e) { Assert.fail("bug"); } Assert.assertEquals("getid", "FOO", bond.getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBond#CMLBond(java.lang.String, org.xmlcml.cml.element.CMLAtom, org.xmlcml.cml.element.CMLAtom)} * . */ @Test public final void testCMLBondStringCMLAtomCMLAtom() { fixture.makeMol5a(); CMLMolecule mol5a = fixture.mol5a; CMLAtom a2 = mol5a.getAtom(1); CMLAtom a5 = mol5a.getAtom(4); CMLBond bond = new CMLBond("FOO", a2, a5); mol5a.addBond(bond); Assert.assertEquals("count", 5, mol5a.getBondCount()); bond = mol5a.getBonds().get(4); Assert.assertEquals("getid", "FOO", bond.getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBond#getAtomId(int)}. */ @Test public final void testGetAtomId() { CMLBond bond = getBond5a(0); Assert.assertEquals("getid", "a1", bond.getAtomId(0)); Assert.assertEquals("getid", "a2", bond.getAtomId(1)); } /** * Test method for {@link org.xmlcml.cml.element.CMLBond#getAtom(int)}. */ @Test public final void testGetAtom() { CMLBond bond = getBond5a(0); Assert.assertEquals("getid", "a1", bond.getAtom(0).getId()); Assert.assertEquals("getid", "a2", bond.getAtom(1).getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBond#getOtherAtomId(java.lang.String)} * . */ @Test public final void testGetOtherAtomId() { CMLBond bond = getBond5a(0); Assert.assertEquals("getid", "a2", bond.getOtherAtomId("a1")); Assert.assertEquals("getid", "a1", bond.getOtherAtomId("a2")); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBond#getOtherAtom(org.xmlcml.cml.element.CMLAtom)} * . */ @Test public final void testGetOtherAtom() { CMLBond bond = getBond5a(0); CMLAtom atom = fixture.mol5a.getAtom(0); Assert.assertEquals("getid", "a2", bond.getOtherAtom(atom).getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBond#atomHash(java.lang.String[])}. */ @Test public final void testAtomHashStringArray() { Assert.assertEquals("gethash", "Y" + CMLBond.HASH_SYMB + "X", CMLBond .atomHash(new String[] { "X", "Y" })); Assert.assertEquals("gethash", "Y" + CMLBond.HASH_SYMB + "X", CMLBond .atomHash(new String[] { "Y", "X" })); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBond#setCyclic(java.lang.String)}. */ @Test public final void testSetCyclic() { CMLBond bond = getBond5a(0); Assert.assertNull("cyclic", bond.getCyclic()); bond.setCyclic(CMLBond.ACYCLIC); Assert.assertEquals("acyclic", CMLBond.ACYCLIC, bond.getCyclic()); bond.setCyclic(CMLBond.CYCLIC); Assert.assertEquals("cyclic", CMLBond.CYCLIC, bond.getCyclic()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBond#getBondStereo()}. */ @Test public final void testGetBondStereo() { CMLBond bond = getBond5a(0); CMLBondStereo bs = bond.getBondStereo(); Assert.assertNull(bs); String s = "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " C" + " " + " " + " " + ""; CMLMolecule mol = (CMLMolecule)CMLXOMTestUtils.parseValidString(s); CMLBond b2 = mol.getBondByAtomIds("a2", "a3"); bs = b2.getBondStereo(); CMLXOMTestUtils.assertEqualsCanonically( "bs", (CMLBondStereo)CMLXOMTestUtils.parseValidString("C"), bs, true); bs = new CMLBondStereo(); bs.setAtomRefs4("a1 a2 a3 a4"); bs.setXMLContent(CMLBond.TRANS); try { b2.addBondStereo(bs); } catch (RuntimeException e) { Assert.fail("nothing wrong"); } } /** * Test method for * {@link org.xmlcml.cml.element.CMLBond#setBondStereo(org.xmlcml.cml.element.CMLBondStereo)} * . */ @Test public final void testSetBondStereo() { String s = "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""; CMLMolecule mol = (CMLMolecule)CMLXOMTestUtils.parseValidString(s); CMLBond b2 = mol.getBondByAtomIds("a2", "a3"); CMLBondStereo bs = new CMLBondStereo(); bs.setAtomRefs4("a1 a2 a3 a4"); bs.setXMLContent(CMLBond.CIS); CMLXOMTestUtils.assertEqualsCanonically( "bs", (CMLBondStereo)CMLXOMTestUtils.parseValidString("C"), bs, true); try { b2.setBondStereo(bs); } catch (RuntimeException e) { Assert.fail("nothing wrong"); } bs = new CMLBondStereo(); bs.setAtomRefs4("a1 a2 a3 a4"); bs.setXMLContent(CMLBond.TRANS); try { b2.setBondStereo(bs); } catch (RuntimeException e) { Assert.fail("nothing wrong"); } } /** * Test method for * {@link org.xmlcml.cml.element.CMLBond#createId(org.xmlcml.cml.element.CMLAtom, org.xmlcml.cml.element.CMLAtom)} * . */ @Test public final void testCreateIdCMLAtomCMLAtom() { fixture.makeMol5a(); CMLAtom a1 = fixture.mol5a.getAtom(0); CMLAtom a2 = fixture.mol5a.getAtom(2); Assert.assertEquals("bond?", "a1-a3", CMLBond.createId(a1, a2)); } /** * Test method for {@link org.xmlcml.cml.element.CMLBond#createId()}. */ @Test public final void testCreateId() { fixture.makeMol5a(); CMLBond bond = fixture.mol5a.getBonds().get(0); Assert.assertEquals("bond?", "a1-a2", bond.createId()); } /** * Test method for {@link org.xmlcml.cml.element.CMLBond#getString()}. */ @Test public final void testGetString() { fixture.makeMol5a(); CMLBond bond = fixture.mol5a.getBonds().get(0); Assert.assertEquals("bond?", "a2__a1", bond.getString()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLBond#generateAndSetId()}. */ @Test public final void testGenerateAndSetId() { fixture.makeMol5a(); CMLBond bond = fixture.mol5a.getBonds().get(0); bond.removeAttribute(IdAttribute.NAME); bond.generateAndSetId(); Assert.assertEquals("bond?", "a2__a1", bond.getString()); } /** * Test method for * 'org.xmlcml.cml.tools.MoleculeTool.calculateBondLength(CMLBond, * CoordinateType)' */ @Test public void testCalculateBondLength() { fixture.makeMol5a(); CMLBond bond = fixture.mol5a.getBonds().get(0); double d = bond.calculateBondLength(CoordinateType.CARTESIAN); Assert.assertEquals("length", 1.3, d, 0.0000001); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/lite/CMLFormulaTest.java000077500000000000000000001437331477224461000276370ustar00rootroot00000000000000/** * 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.lite; import static org.xmlcml.euclid.EuclidConstants.EPS; import static org.xmlcml.euclid.test.EuclidTestBase.getAssertFormat; import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import nu.xom.Document; import nu.xom.Element; import nu.xom.Node; import nu.xom.ParsingException; import org.apache.log4j.Logger; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLAttribute; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.base.CMLSerializer; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.base.DoubleSTAttribute; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLAtomArray; import org.xmlcml.cml.element.CMLBond; import org.xmlcml.cml.element.CMLFormula; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.CMLFormula.Sort; import org.xmlcml.cml.element.CMLFormula.Type; import org.xmlcml.cml.element.main.MoleculeAtomBondFixture; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.test.DoubleTestBase; import org.xmlcml.euclid.test.StringTestBase; import org.xmlcml.molutil.ChemicalElement; import org.xmlcml.molutil.ChemicalElement.AS; /** * test CMLFormula. * * @author pmr * */ public class CMLFormulaTest { MoleculeAtomBondFixture fixture = new MoleculeAtomBondFixture(); private static Logger LOG = Logger.getLogger(CMLFormulaTest.class); // built in xom; CMLFormula xomForm1 = null; CMLFormula xomForm2 = null; CMLFormula xomForm3 = null; CMLFormula xomForm3a = null; CMLFormula xomForm3b = null; // read into xom; String xmlForm1S = "" + CMLConstants.S_EMPTY; Document xmlForm1Doc = null; CMLFormula xmlForm1 = null; static int count = 0; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { if (count++ > 0) { // throw new RuntimeException("SKIP"); } // build from scratch xomForm1 = new CMLFormula(); xomForm1.add(AS.H.value, 1.0); xomForm1.add(AS.O.value, 3.0); xomForm1.add(AS.N.value, 1.0); xomForm1.setCount(2.0); xomForm1.setId("xomForm1"); // build from concise xomForm2 = new CMLFormula(); xomForm2.setConcise("H 1 N 1 O 3"); xomForm2.setId("xomForm2"); // read reference moelcule try { xmlForm1Doc = new CMLBuilder().build(new StringReader(xmlForm1S)); } catch (IOException e) { Assert.fail("Should not throw IOException"); } catch (ParsingException e) { e.printStackTrace(); LOG.error("Parse exception " + e.getMessage()); Assert.fail("Should not throw ParsingException" + e.getCause()); } xmlForm1 = (CMLFormula) xmlForm1Doc.getRootElement(); // BUG the copy constructor adds spurious children! xomForm3 = new CMLFormula(); xomForm3a = new CMLFormula(); xomForm3a.setId("xomForm3a"); String expectS = "" + (char) 13 + (char) 10 + ""; Element expectElem =CMLXOMTestUtils.parseValidString(expectS); CMLXOMTestUtils.assertEqualsCanonically("formula setup", expectElem, xomForm3a); xomForm3a.setConcise("H 2 S 1 O 4"); expectS = "" + (char) 13 + (char) 10 + "" + "" + ""; expectElem =CMLXOMTestUtils.parseValidString(expectS); CMLXOMTestUtils.assertEqualsCanonically("formula setup", expectElem, xomForm3a); Assert.assertEquals("xom3a child", 1, xomForm3a.getChildCount()); CMLFormula xomForm3aCopy = new CMLFormula(xomForm3a); // xomForm3aCopy.debug("FORM"); Assert.assertEquals("xom3a children", 1, xomForm3aCopy.getAtomArrayElements() .size()); // should be expectS = "" + (char) 13 + (char) 10 + "" + "" + ""; // but is expectS = "" + (char) 13 + (char) 10 + "" + "" + ""; expectElem =CMLXOMTestUtils.parseValidString(expectS); CMLXOMTestUtils.assertEqualsCanonically("formula setup", expectElem, xomForm3aCopy); xomForm3.appendChild(xomForm3a); xomForm3b = new CMLFormula(); xomForm3b.setConcise("Na 1 H 1 C 1 O 3"); xomForm3.appendChild(xomForm3b); } /** * asserts equality of double arrays. * * checks for non-null, then equality of length, then individual elements * * @param message * @param formula1 * expected formula * @param formula2 * actual formula * @param eps * tolerance for agreement */ public static void assertEqualsConcise(String message, CMLFormula formula1, CMLFormula formula2, double eps) { if (formula1 == null) { Assert.fail(getAssertFormat(message, "formula", "null")); } if (formula2 == null) { Assert.fail(getAssertFormat(message, "formula", "null")); } Assert.assertEquals("equal concise", true, formula1.equals(formula2, eps)); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.copy()' */ @Test public void testCopy() { Node copy = xmlForm1.copy(); Assert.assertEquals("class should be CMLform: ", copy.getClass(), CMLFormula.class); CMLFormula copyForm = (CMLFormula) copy; Assert.assertEquals("formula is identical", copyForm.compareTo(xmlForm1), 0); } /** * test prohibition of formulaArray child. * */ @Test public void testNoAtomArray() { // read into xom; String xmlForm1S = "" + " " + " " + " " + "
" + CMLConstants.S_EMPTY; try { new CMLBuilder().build(new StringReader(xmlForm1S)); Assert.fail("Should throw ParsingException due to forbidden atomArray child"); } catch (IOException e) { Assert.fail("Should not throw IOException"); } catch (ParsingException e) { Assert.assertEquals("ok", "ok"); } } /* public */void /* test */Serialize() { /* * -- cannot really test this as order of output may vary CMLSerializer * serializer; String s; String expect; * * serializer = new CMLSerializer(); s = * serializer.getXML(xomForm1).trim(); expect = * ""+(char)13+(char)10+ "" + * "" + * ""; Assert.assertEquals("xom1 serializer2", expect, s); * xomForm1.add(AS.H.value, 7.0); * * serializer = new CMLSerializer(); s = * serializer.getXML(xomForm1).trim(); expect = * ""+(char)13+(char)10+ "" + * "" + * ""; expect = * ""+(char)13+(char)10+ "" + * "" + * "" + * ""; Assert.assertEquals("xom1 serializer2", expect, s); * * serializer = new CMLSerializer(); s = * serializer.getXML(xomForm3).trim(); expect = * ""+(char)13+(char)10+ "" + "" + * "" + "" * + ""; expect = * ""+(char)13+(char)10+ "" + "" + * "" + * "" + "" * + "" + * "" + * "" + * "" + ""; Assert.assertEquals("xom1 serializer2", expect, * s); -- */ } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.getCount()' */ @Test public void testGetCount() { double count = xomForm1.getCount(); Assert.assertEquals("xomForm1 count", 2.0, count, 0.00001); count = xmlForm1.getCount(); Assert.assertEquals("xmlForm1 count", 1.0, count, 0.00001); } /** * */ @Test public void testAddHydrogensIfExplicitAndPresent() { CMLMolecule molecule; CMLAtom atom; CMLBond bond; CMLAtom hatom; CMLFormula formula; molecule = new CMLMolecule(); atom = new CMLAtom(); atom.setId("a1"); molecule.addAtom(atom); atom.setHydrogenCount(4); atom.setElementType("C"); for (int i = 0; i < 4; i++) { hatom = new CMLAtom(); hatom.setId("h" + (i + 1)); hatom.setElementType("H"); molecule.addAtom(hatom); bond = new CMLBond(atom, hatom); molecule.addBond(bond); } formula = new CMLFormula(molecule); Assert.assertEquals("methane - explicit and count", "C 1 H 4", formula .getConcise()); // test with only hydrogen count molecule = new CMLMolecule(); atom = new CMLAtom(); atom.setId("a1"); molecule.addAtom(atom); atom.setHydrogenCount(4); atom.setElementType("C"); formula = new CMLFormula(molecule); Assert.assertEquals("methane - count", "C 1 H 4", formula.getConcise()); // some explicit H molecule = new CMLMolecule(); atom = new CMLAtom(); atom.setId("a1"); molecule.addAtom(atom); atom.setElementType("C"); atom.setHydrogenCount(4); for (int i = 0; i < 2; i++) { hatom = new CMLAtom(); hatom.setId("h" + (i + 1)); hatom.setElementType("H"); molecule.addAtom(hatom); bond = new CMLBond(atom, hatom); molecule.addBond(bond); } formula = new CMLFormula(molecule); Assert.assertEquals("methane - 2 explicit + count - carbon first", "C 1 H 4", formula.getConcise()); // methanol molecule = new CMLMolecule(); atom = new CMLAtom(); atom.setId("a1"); molecule.addAtom(atom); atom.setElementType("O"); CMLAtom atom2 = new CMLAtom(); atom2.setId("h1"); molecule.addAtom(atom2); atom2.setElementType("H"); bond = new CMLBond(atom, atom2); molecule.addBond(bond); atom2 = new CMLAtom(); atom2.setId("a2"); molecule.addAtom(atom2); atom2.setElementType("C"); atom2.setHydrogenCount(3); bond = new CMLBond(atom, atom2); molecule.addBond(bond); formula = new CMLFormula(molecule); Assert.assertEquals("methanol - oxygen first - ", "C 1 H 4 O 1", formula .getConcise()); molecule = new CMLMolecule(); for (int i = 0; i < 2; i++) { hatom = new CMLAtom(); hatom.setId("h" + (i + 1)); hatom.setElementType("H"); molecule.addAtom(hatom); } atom = new CMLAtom(); atom.setId("a1"); molecule.addAtom(atom); atom.setElementType("C"); atom.setHydrogenCount(4); for (int i = 0; i < 2; i++) { hatom = molecule.getAtomById("h" + (i + 1)); bond = new CMLBond(atom, hatom); molecule.addBond(bond); } formula = new CMLFormula(molecule); Assert.assertEquals("methane - 2 explicit + count - hydrogens first - ", "C 1 H 4", formula.getConcise()); // no hydrogen count molecule = new CMLMolecule(); atom = new CMLAtom(); atom.setId("a1"); molecule.addAtom(atom); atom.setElementType("C"); for (int i = 0; i < 4; i++) { hatom = new CMLAtom(); hatom.setId("h" + (i + 1)); hatom.setElementType("H"); molecule.addAtom(hatom); bond = new CMLBond(atom, hatom); molecule.addBond(bond); } formula = new CMLFormula(molecule); Assert.assertEquals("methane - explicit", "C 1 H 4", formula.getConcise()); // inconsistent molecule = new CMLMolecule(); atom = new CMLAtom(); atom.setId("a1"); molecule.addAtom(atom); atom.setElementType("C"); atom.setHydrogenCount(2); for (int i = 0; i < 4; i++) { hatom = new CMLAtom(); hatom.setId("h" + (i + 1)); hatom.setElementType("H"); molecule.addAtom(hatom); bond = new CMLBond(atom, hatom); molecule.addBond(bond); } formula = new CMLFormula(molecule); // formula.debug("BAD"); Assert.assertEquals("methane - all H explicit but count = 2", "C 1 H 4", formula.getConcise()); // methanol molecule = new CMLMolecule(); atom2 = new CMLAtom(); atom2.setId("a2"); molecule.addAtom(atom2); atom2.setElementType("C"); for (int i = 0; i < 3; i++) { hatom = new CMLAtom(); hatom.setId("h" + (i + 2)); hatom.setElementType("H"); molecule.addAtom(hatom); bond = new CMLBond(atom2, hatom); molecule.addBond(bond); } atom = new CMLAtom(); atom.setId("a1"); molecule.addAtom(atom); atom.setElementType("O"); bond = new CMLBond(atom, atom2); molecule.addBond(bond); atom2 = new CMLAtom(); atom2.setId("h1"); molecule.addAtom(atom2); atom2.setElementType("H"); bond = new CMLBond(atom, atom2); molecule.addBond(bond); formula = new CMLFormula(molecule); Assert.assertEquals("methanol - carbon first, explicit Hs- ", "C 1 H 4 O 1", formula.getConcise()); // hydrogen molecule molecule = new CMLMolecule(); atom = new CMLAtom(); atom.setId("h1"); molecule.addAtom(atom); atom.setElementType("H"); atom2 = new CMLAtom(); atom2.setId("h2"); molecule.addAtom(atom2); atom2.setElementType("H"); bond = new CMLBond(atom, atom2); molecule.addBond(bond); formula = new CMLFormula(molecule); Assert.assertEquals("hydrogen molecule - ", "H 2", formula.getConcise()); // hydrogen chloride molecule = new CMLMolecule(); atom = new CMLAtom(); atom.setId("h1"); molecule.addAtom(atom); atom.setElementType("H"); atom.setFormalCharge(1); atom2 = new CMLAtom(); atom2.setId("h2"); molecule.addAtom(atom2); atom2.setElementType("Cl"); atom2.setFormalCharge(-1); formula = new CMLFormula(molecule); Assert.assertEquals("hydrogen chloride - ", "H 1 Cl 1", formula.getConcise()); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.setCount(double)' */ @Test public void testSetCount() { double cc = xmlForm1.getCount(); Assert.assertEquals("count", 1.0, cc, 0.0000001); xmlForm1.setCount(1.5); cc = xmlForm1.getCount(); Assert.assertEquals("count", 1.5, cc, 0.0001); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.getFormalCharge()' */ @Test public void testGetFormalCharge() { int fc = xmlForm1.getFormalCharge(); Assert.assertEquals("formal charge", -1, fc); xmlForm1.setFormalCharge(2); fc = xmlForm1.getFormalCharge(); Assert.assertEquals("formal charge", 2, fc); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.setFormalCharge(int)' */ @Test public void testSetFormalCharge() { int fc = xmlForm1.getFormalCharge(); Assert.assertEquals("formal charge", -1, fc); xmlForm1.setFormalCharge(-3); fc = xmlForm1.getFormalCharge(); Assert.assertEquals("formal charge", -3, fc); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.CMLFormula()' */ @Test public void testCMLFormula() { CMLFormula formula = new CMLFormula(); Assert.assertNotNull("constructor ", formula); Assert.assertNull("no id attribute", formula.getIdAttribute()); Assert.assertEquals("no children", formula.getChildCount(), 0); } /** * Test method for * 'org.xmlcml.cml.element.CMLFormula.CMLFormula(CMLFormula)' */ @Test public void testCMLFormulaCMLFormula() { // copy constructor CMLFormula xformula = xomForm1; CMLAttribute countAtt = xomForm1.getCountAttribute(); Assert.assertNotNull("count attribute", countAtt); Assert.assertTrue("count class is subclass of CMLAttribute", CMLAttribute.class.isAssignableFrom(countAtt.getClass())); CMLFormula formula = new CMLFormula(xformula); Assert.assertNotNull("constructor ", formula); countAtt = formula.getCountAttribute(); Assert.assertNotNull("copied count attribute", countAtt); Assert.assertTrue("count class is subclass of CMLAttribute", CMLAttribute.class.isAssignableFrom(countAtt.getClass())); Assert.assertEquals("count class is DoubleSTAttribute", countAtt.getClass(), DoubleSTAttribute.class); Assert.assertEquals("count value", formula.getCount(), xformula.getCount(), 0.0001); CMLFormula copyForm = new CMLFormula(xmlForm1); CMLXOMTestUtils.assertEqualsCanonically("compare Formula", copyForm, xmlForm1); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.createFormula(String)' */ @Test public void testCreateFormulaString() { String s; CMLFormula form = null; s = "H 2 O 4 S 1"; try { form = CMLFormula.createFormula(s); } catch (RuntimeException e) { Assert.fail("parsing shouldn't fail for: " + s + " because:" + e); } Assert.assertEquals("formula string", "H 2 O 4 S 1", form.getConcise()); s = "H2O4S"; form = CMLFormula.createFormula(s); Assert.assertEquals("formula string", "H 2 O 4 S 1", form.getConcise()); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.createFormula(String, * String)' */ @Test public void testCreateFormulaStringConvention() { // CMLFormula.createFormula("C 2 H 4", Formula.Convention.) CMLFormula form = null; try { form = CMLFormula.createFormula("C2H4", CMLFormula.Type.NOPUNCTUATION); } catch (RuntimeException e) { e.printStackTrace(); throw new EuclidRuntimeException("should never throw " + e); } // Assert.assertEquals("createFormula", "C 2 H 4", form.getConcise()); try { form = CMLFormula.createFormula("C 2 H 4", CMLFormula.Type.ELEMENT_WHITESPACE_COUNT); } catch (RuntimeException e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertEquals("createFormula", "C 2 H 4", form.getConcise()); try { form = CMLFormula.createFormula("C2 H4", CMLFormula.Type.ELEMENT_COUNT_WHITESPACE); } catch (RuntimeException e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertEquals("createFormula", "C 2 H 4", form.getConcise()); Assert.assertEquals("createFormula", 1.0, form.getCount(), EPS); try { form = CMLFormula.createFormula("2(C2 H4)", CMLFormula.Type.MULTIPLIED_ELEMENT_COUNT_WHITESPACE); } catch (RuntimeException e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertEquals("createFormula", "C 2 H 4", form.getConcise()); Assert.assertEquals("createFormula", 2.0, form.getCount(), EPS); /* * -- try { form = CMLFormula.createFormula("3(C 2 H 4) 2(H 2 O 1)", * CMLFormula.Type.NESTEDBRACKETS); } catch (CMLRuntime e) { * neverThrow(e); } catch (RuntimeException e) { neverThrow(e); } * Assert.assertEquals("createFormula", "C 2 H 4", form.getConcise()); * Assert.assertEquals("createFormula", 2.0, form.getCount(), EPS); -- */ } /** * Test method for * 'org.xmlcml.cml.element.CMLFormula.createFromString(String, String)' */ @Test public void testCreateFromString() { String moiety = "C2 H6 N +, H1 S2 O4 -"; CMLFormula[] f = new CMLFormula[2]; try { f[0] = CMLFormula.createFormula("NC2H6"); } catch (RuntimeException e) { Assert.fail("should not throw " + e); } f[0].setFormalCharge(1); try { f[1] = CMLFormula.createFormula("S2O4H"); } catch (RuntimeException e) { Assert.fail("should not throw " + e); } f[1].setFormalCharge(-1); CMLFormula fMoiety = null; try { fMoiety = CMLFormula.createFormula(moiety, Type.MOIETY); } catch (RuntimeException e) { e.printStackTrace(); Assert.fail("should not throw " + e); } Assert.assertEquals("moiety count", 2, fMoiety.getChildCount()); for (int i = 0; i < 2; i++) { CMLFormula mf = (CMLFormula) fMoiety.getChild(i); Assert.assertTrue("moiety " + i, f[i].equals(mf, 0.0001)); } } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.add(String, double)' */ @Test public void testAdd() { // FIXME - sorting String[] elements = xomForm1.getElementTypes(); StringTestBase.assertEquals("start xomForm1", new String[] { AS.H.value, AS.O.value, AS.N.value }, elements); double[] counts = xomForm1.getCounts(); DoubleTestBase.assertEquals("start xomForm1", new double[] { 1.0, 3.0, 1.0 }, counts, 0.000001); xomForm1.add(AS.S.value, 2.0); elements = xomForm1.getElementTypes(); StringTestBase.assertEquals("add1 xomForm1", new String[] { AS.H.value, AS.O.value, AS.N.value, AS.S.value }, elements); counts = xomForm1.getCounts(); DoubleTestBase.assertEquals("add1 xomForm1", new double[] { 1.0, 3.0, 1.0, 2.0 }, counts, 0.000001); xomForm1.add(AS.H.value, 2.0); elements = xomForm1.getElementTypes(); StringTestBase.assertEquals("add1 xomForm1", new String[] { AS.H.value, AS.O.value, AS.N.value, AS.S.value }, elements); counts = xomForm1.getCounts(); DoubleTestBase.assertEquals("add1 xomForm1", new double[] { 3.0, 3.0, 1.0, 2.0 }, counts, 0.000001); xomForm1.setFormalCharge(-1); String concise = xomForm1.getConcise(); Assert.assertEquals("xom in sync", "H 3 N 1 O 3 S 2 -1", concise); int fc = xomForm1.getFormalCharge(); Assert.assertEquals("formal charge from concise", -1, fc); xomForm1.setFormalCharge(1); concise = xomForm1.getConcise(); Assert.assertEquals("xom in sync", "H 3 N 1 O 3 S 2 1", concise); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.getElementTypes()' */ @Test public void testGetElementTypes() { String[] el = xomForm1.getElementTypes(); StringTestBase.assertEquals("element types", new String[] { AS.H.value, AS.O.value, AS.N.value }, el); el = xmlForm1.getElementTypes(); StringTestBase.assertEquals("element types", new String[] { AS.C.value, AS.H.value, AS.Br.value, AS.O.value }, el); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.getElementCounts()' */ @Test public void testGetElementCounts() { // TODO check provenance od xomForm1 double[] c = xomForm1.getCounts(); DoubleTestBase.assertEquals("element counts", new double[] { 1., 3., 1. }, c, 0.00001); String concise = xmlForm1.getConcise(); // Assert.assertEquals("concise", "C 2 H 2 Br 1 O 2 -1", concise); Assert.assertEquals("concise", "C 2 H 2 Br 1 O 2", concise); c = xmlForm1.getCounts(); DoubleTestBase.assertEquals("element counts", new double[] { 2., 2., 1., 2. }, c, 0.00001); } /** * Test method for * 'org.xmlcml.cml.element.CMLFormula.addFormula(CMLFormula)' */ @Test public void testAddFormulaCMLFormula() { CMLSerializer serializer = new CMLSerializer(); String s = serializer.getXML(xomForm3a).trim(); String expect = "" + (char) 13 + (char) 10 + "" + "" + ""; Assert.assertEquals("xom3a serializer", expect, s); Assert.assertEquals("child count", 1, xomForm3a.getChildCount()); Assert.assertEquals("child count", 1, xomForm3b.getChildCount()); Assert.assertEquals("concise", "H 2 O 4 S 1", xomForm3a.getConcise()); Assert.assertEquals("concise", "C 1 H 1 Na 1 O 3", xomForm3b.getConcise()); serializer = new CMLSerializer(); s = serializer.getXML(xomForm3a).trim(); expect = "" + (char) 13 + (char) 10 + "" + "" + ""; Assert.assertEquals("xom3a serializer", expect, s); // now add the formula xomForm3a.addFormula(xomForm3b); Assert.assertEquals("child count", 2, xomForm3a.getChildCount()); CMLElements childFormula = xomForm3a.getFormulaElements(); Assert.assertEquals("formula child count", 2, childFormula.size()); Assert.assertEquals("formula 0 concise", "H 2 O 4 S 1", childFormula.get(0) .getConcise()); Assert.assertEquals("formula 1 concise", "C 1 H 1 Na 1 O 3", childFormula.get( 1).getConcise()); serializer = new CMLSerializer(); s = serializer.getXML(xomForm3a).trim(); expect = "" + (char) 13 + (char) 10 + "" + "" + "" + "" + "" + "" + "" + ""; Assert.assertEquals("xom3a serializer", expect, s); // appended formula should be unaltered Assert.assertEquals("child count", 1, xomForm3b.getChildCount()); Assert.assertEquals("concise", "C 1 H 1 Na 1 O 3", xomForm3b.getConcise()); Assert.assertNull("concise", xomForm3a.getConcise()); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.getAggregateFormula()' */ @Test public void testGetAggregateFormula() { CMLFormula f = xmlForm1.getAggregateFormula(); Assert.assertEquals("aggregate formula count", 1.0, f.getCount(), 0.0001); Assert.assertEquals("form3 children", 2, xomForm3.getChildCount()); f = xomForm3.getAggregateFormula(); } /** * Test method for * 'org.xmlcml.cml.element.CMLFormula.aggregateFormula(CMLFormula)' */ @Test public void testAggregateFormula() { CMLFormula formula1 = null; try { formula1 = CMLFormula.createFormula("H 1 S 1 O 3", CMLFormula.Type.ELEMENT_WHITESPACE_COUNT); } catch (RuntimeException e) { Assert.fail("should not throw " + e); } formula1.setCount(3); formula1.setFormalCharge(-1); Assert.assertEquals("formula1 concise ", "H 1 O 3 S 1 -1", formula1 .getConcise()); Assert.assertEquals("formula1 charge ", -1, formula1.getFormalCharge()); Assert.assertEquals("formula1 count ", 3, formula1.getCount(), EPS); CMLFormula formula2 = null; try { formula2 = CMLFormula.createFormula("Mg 1 O 6 H 12", CMLFormula.Type.ELEMENT_WHITESPACE_COUNT); } catch (RuntimeException e) { Assert.fail("should not throw " + e); } formula2.setFormalCharge(2); Assert.assertEquals("formula2 concise ", "H 12 Mg 1 O 6 2", formula2 .getConcise()); Assert.assertEquals("formula2 charge ", 2, formula2.getFormalCharge()); Assert.assertEquals("formula2 count ", 1, formula2.getCount(), EPS); CMLFormula formula3 = formula1.createAggregatedFormula(formula2); Assert.assertEquals("formula3 concise ", "H 15 Mg 1 O 15 S 3 -1", formula3 .getConcise()); Assert.assertEquals("formula3 charge ", -1, formula3.getFormalCharge()); Assert.assertEquals("formula3 count ", 1, formula3.getCount(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.divideBy(CMLFormula)' */ @Test public void testDivideBy() { CMLFormula fTop = null; try { fTop = CMLFormula.createFormula("NC2H6"); } catch (RuntimeException e) { e.printStackTrace(); Assert.fail("should not throw " + e); } fTop.setFormalCharge(1); CMLFormula fBot = null; try { fBot = CMLFormula.createFormula("N2C4H12"); } catch (RuntimeException e) { Assert.fail("should not throw " + e); } fBot.setFormalCharge(2); double d = fTop.divideBy(fBot, 0.0001); Assert.assertEquals("divide top by bottom", 0.5, d, 0.0001); d = fBot.divideBy(fTop, 0.0001); Assert.assertEquals("divide top by bottom", 2.0, d, 0.0001); try { fBot = CMLFormula.createFormula("N2C4.1H12"); } catch (RuntimeException e) { Assert.fail("should not throw " + e); } d = fBot.divideBy(fTop, 0.0001); Assert.assertTrue("cannot divide top by bottom", Double.isNaN(d)); try { fTop = CMLFormula.createFormula("Al10.0O20.Si1.0000Sr3."); } catch (RuntimeException e) { Assert.fail("should not throw " + e); } try { fBot = CMLFormula.createFormula("Al2.5O5.Si0.25Sr0.75"); } catch (RuntimeException e) { Assert.fail("should not throw " + e); } d = fBot.divideBy(fTop, 0.0001); Assert.assertEquals("divide top by bottom", 0.25, d, 0.0001); } /** * Test method for * 'org.xmlcml.cml.element.CMLFormula.getCalculatedMolecularMass()' */ @Test public void testGetCalculatedMolecularMass() { double m = xomForm1.getCalculatedMolecularMass(); Assert.assertEquals("xomForm1 mw", 126.02568, m, 0.00001); } /** * Get formatted formula. @ param convention * *
	 *      NOPUNCTUATION			"C2H4Cl2" (default)
	 *      ELEMENT_COUNT_WHITESPACE	"C2 H4 Cl2"
	 *      ELEMENT_WHITESPACE_COUNT	"C 2 H 4 Cl 2"
	 *      NESTEDBRACKETS			"(Na2)(SO4).10(H2O)"
	 * 
* * @ param sort * *
	 *      ALPHABETIC_ELEMENTS		"Br C Cl H"
	 *      CHFIRST			=	"C H Br Cl"; (default)
	 * 
* * @ param omitCount1 omit elements count if 1 (default false) @ return * String the formatted formula */ /** * Test method for * 'org.xmlcml.cml.element.CMLFormula.getFormattedString(String, String, * boolean)' * */ @Test public void testGetFormattedStringStringStringBoolean() { String s = xmlForm1.getFormattedString(Type.NOPUNCTUATION, Sort.CHFIRST, true); Assert.assertEquals("no punct, chfirst, omit1", "C2H2BrO2-", s); s = xmlForm1 .getFormattedString(Type.NOPUNCTUATION, Sort.CHFIRST, false); Assert.assertEquals("no punct, chfirst, omit1", "C2H2Br1O2-", s); s = xmlForm1.getFormattedString(Type.ELEMENT_COUNT_WHITESPACE, Sort.CHFIRST, true); Assert.assertEquals("no punct, chfirst, omit1", "C2 H2 Br O2 -", s); s = xmlForm1.getFormattedString(Type.ELEMENT_COUNT_WHITESPACE, Sort.CHFIRST, false); Assert.assertEquals("no punct, chfirst, omit1", "C2 H2 Br1 O2 -", s); s = xmlForm1.getFormattedString(Type.ELEMENT_WHITESPACE_COUNT, Sort.CHFIRST, true); Assert.assertEquals("no punct, chfirst, omit1", "C 2 H 2 Br O 2 -", s); s = xmlForm1.getFormattedString(Type.ELEMENT_WHITESPACE_COUNT, Sort.CHFIRST, false); Assert.assertEquals("no punct, chfirst, omit1", "C 2 H 2 Br 1 O 2 -", s); s = xmlForm1.getFormattedString(Type.NOPUNCTUATION, Sort.ALPHABETIC_ELEMENTS, true); Assert.assertEquals("no punct, ALPHABETIC_ELEMENTS, omit1", "BrC2H2O2-", s); s = xmlForm1.getFormattedString(Type.NOPUNCTUATION, Sort.ALPHABETIC_ELEMENTS, false); Assert.assertEquals("no punct, ALPHABETIC_ELEMENTS, omit1", "Br1C2H2O2-", s); s = xmlForm1.getFormattedString(Type.ELEMENT_COUNT_WHITESPACE, Sort.ALPHABETIC_ELEMENTS, true); Assert.assertEquals("no punct, ALPHABETIC_ELEMENTS, omit1", "Br C2 H2 O2 -", s); s = xmlForm1.getFormattedString(Type.ELEMENT_COUNT_WHITESPACE, Sort.ALPHABETIC_ELEMENTS, false); Assert.assertEquals("no punct, ALPHABETIC_ELEMENTS, omit1", "Br1 C2 H2 O2 -", s); s = xmlForm1.getFormattedString(Type.ELEMENT_WHITESPACE_COUNT, Sort.ALPHABETIC_ELEMENTS, true); Assert.assertEquals("no punct, ALPHABETIC_ELEMENTS, omit1", "Br C 2 H 2 O 2 -", s); s = xmlForm1.getFormattedString(Type.ELEMENT_WHITESPACE_COUNT, Sort.ALPHABETIC_ELEMENTS, false); Assert.assertEquals("no punct, ALPHABETIC_ELEMENTS, omit1", "Br 1 C 2 H 2 O 2 -", s); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.getFormattedString()' */ @Test public void testGetFormattedString() { String s = xomForm1.getFormattedString(); Assert.assertEquals("xomForm1 string", "HNO3", s); s = xomForm2.getFormattedString(); Assert.assertEquals("xomForm2 string", "HNO3", s); s = xomForm3.getFormattedString(); Assert.assertEquals("xomForm3 string", "H3O7SCNa", s); s = xmlForm1.getFormattedString(); Assert.assertEquals("xmlForm1 string", "C2H2BrO2-", s); } /** * Test method for * 'org.xmlcml.cml.element.CMLFormula.getCalculatedMass(List, RealArray)' */ @Test public void testGetCalculatedMass() { CMLFormula f1 = null; try { f1 = CMLFormula.createFormula("C 2 H 3 Cl 1"); } catch (RuntimeException e) { Assert.fail("should not throw " + e); } double d = f1.getCalculatedMolecularMass(); Assert.assertEquals("Calculated mass ", 62.49822, d, 0.00000001); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.equalsFormula(Object)' */ @Test public void testEqualsFormula() { CMLFormula f1 = null; try { f1 = CMLFormula.createFormula("C 2 H 3 Cl 1"); } catch (RuntimeException e) { Assert.fail("should not throw " + e); } CMLFormula f2 = null; try { f2 = CMLFormula.createFormula("C 2 H 3 Cl 1"); } catch (RuntimeException e) { Assert.fail("should not throw " + e); } boolean ff = f1.equals(f2, 0.0001); Assert.assertTrue("equal formulae", ff); } /** * Test method for * 'org.xmlcml.cml.element.CMLFormula.getDifference(CMLFormula)' */ @Test public void testGetDifference() { CMLFormula formula1 = null; try { formula1 = CMLFormula.createFormula("H 1 S 1 O 3", CMLFormula.Type.ELEMENT_WHITESPACE_COUNT); } catch (RuntimeException e) { Assert.fail("should not throw " + e); } formula1.setCount(3); formula1.setFormalCharge(-1); Assert.assertEquals("formula1 concise ", "H 1 O 3 S 1 -1", formula1 .getConcise()); Assert.assertEquals("formula1 charge ", -1, formula1.getFormalCharge()); Assert.assertEquals("formula1 count ", 3, formula1.getCount(), EPS); CMLFormula formula2 = null; try { formula2 = CMLFormula.createFormula("Mg 1 O 6 H 12", CMLFormula.Type.ELEMENT_WHITESPACE_COUNT); } catch (RuntimeException e) { Assert.fail("should not throw " + e); } formula2.setFormalCharge(2); Assert.assertEquals("formula2 concise ", "H 12 Mg 1 O 6 2", formula2 .getConcise()); Assert.assertEquals("formula2 charge ", 2, formula2.getFormalCharge()); Assert.assertEquals("formula2 count ", 1, formula2.getCount(), EPS); CMLFormula formulaDiff = formula1.getDifference(formula2); CMLFormula expectedDiff = CMLFormula.createFormula( "H -9.0 Mg -1.0 O 3.0 S 3.0 -5", true); assertEqualsConcise("difference ", expectedDiff, formulaDiff, 0.00001); } /** * Test method for * 'org.xmlcml.cml.element.CMLFormula.equalsAggregate(CMLFormula)' * * @exception Exception */ @Test public void testEqualsAggregate() throws Exception { CMLFormula form1 = (CMLFormula)CMLXOMTestUtils.parseValidString(""); CMLFormula form2 = (CMLFormula)CMLXOMTestUtils.parseValidString(""); boolean equals = form1.equalsAggregate(form1); Assert.assertTrue("equality", equals); equals = form1.equalsAggregate(form2); Assert.assertFalse("equality", equals); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.toFormulaString()' */ @Test public void testToFormulaString() { CMLFormula f1 = null; try { f1 = CMLFormula.createFormula("C 2 H 3 Cl 1"); } catch (RuntimeException e) { Assert.fail("should not throw " + e); } String formulaString = f1.toFormulaString(); Assert.assertEquals("formula string", "count: 1.0; charge: 0: C(2.0)H(3.0)Cl", formulaString); } /** test */ @Test public void testMultiplyBy() { CMLFormula f1 = null; try { f1 = CMLFormula.createFormula("C 1 H 1.5 Cl 0.5"); } catch (RuntimeException e) { Assert.fail("should not throw " + e); } f1.multiplyBy(2.0); String f1S = f1.getConcise(); Assert.assertEquals("multiplied formula ", "C 2 H 3 Cl 1", f1S); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.writeHTML(Writer)' * * @exception Exception */ @Test public void testWriteHTML() throws Exception { StringWriter w = new StringWriter(); xomForm1.writeHTML(w); String html = w.toString(); w.close(); Assert.assertEquals("html", "HO3N", html); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.setConcise(String)' */ @Test public void testSetConcise() { Assert.assertEquals("concise", "H 1 O 3 N 1", xomForm1.getConcise()); try { xomForm1.setConcise("H 2 O 1"); Assert.fail("should throw 'Cannot reset concise if atomArray is present'"); } catch (RuntimeException e) { Assert.assertEquals("cannot reset concise", "Cannot reset concise if atomArray is present", e .getMessage()); } Assert.assertEquals("concise", "H 1 O 3 N 1", xomForm1.getConcise()); CMLFormula form = new CMLFormula(); form.setConcise("H 1 O 3 N 1"); Assert.assertEquals("concise", "H 1 N 1 O 3", form.getConcise()); try { form.setConcise("H 2 O 1"); Assert.fail("should throw 'Cannot reset concise if atomArray is present'"); } catch (RuntimeException e) { Assert.assertEquals("cannot reset concise", "Cannot reset concise if atomArray is present", e .getMessage()); } Assert.assertEquals("concise", "H 1 N 1 O 3", form.getConcise()); } /** * Test method for * 'org.xmlcml.cml.element.CMLFormula.CMLFormula(CMLMolecule)' */ @Test public void testCMLFormulaCMLMolecule() { CMLFormula form = new CMLFormula(fixture.xmlMolecule); Assert.assertEquals("concise", "C 1 H 3 F 1 N 1 O 1 S 1", form.getConcise()); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.normalize()' * * @exception Exception */ @Test public void testNormalize() throws Exception { CMLFormula form1 = (CMLFormula)CMLXOMTestUtils.parseValidString(""); form1.normalize(); Assert.assertEquals("concise", "C 2 H 4", form1.getConcise()); } /** * Test method for * 'org.xmlcml.cml.element.CMLFormula.generateConcise(CMLAtomArray, int)' * * @exception Exception */ @Test public void testGenerateConcise() throws Exception { CMLAtomArray atomArray = new CMLAtomArray(); // atomArray.setElementType(new String[]{AS.C.value, AS.H.value, // AS.O.value}); // atomArray.setCount(new double[]{1, 4, 2}); atomArray.setElementTypeAndCount(new String[] { AS.C.value, AS.H.value, AS.O.value }, new double[] { 1, 4, 2 }); String concise = atomArray.generateConcise(-2); Assert.assertEquals("concise", "C 1 H 4 O 2 -2", concise); } /** * Test method for * 'org.xmlcml.cml.element.CMLFormula.removeChargeFromConcise(String)' * * @exception Exception */ @Test public void testRemoveChargeFromConcise() throws Exception { String concise = CMLFormula.removeChargeFromConcise("C 2 H 4 O 2 -2"); Assert.assertEquals("concise", "C 2 H 4 O 2", concise); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.getConciseNoCharge()' * * @exception Exception */ @Test public void testGetConciseNoCharge() throws Exception { CMLFormula form1 = (CMLFormula)CMLXOMTestUtils.parseValidString(""); Assert.assertEquals("concise", "C 2 H 4 O 2", form1.getConciseNoCharge()); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.createFormula(String, * Type)' * * @exception Exception */ @Test public void testCreateFormulaStringType() throws Exception { CMLFormula form = CMLFormula.createFormula("C 2 H 4 O 2"); Assert.assertEquals("concise", "C 2 H 4 O 2", form.getConcise()); form = CMLFormula.createFormula("C 2 H 4 O 2 -1"); Assert.assertEquals("concise", "C 2 H 4 O 2 -1", form.getConcise()); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.getCounts()' * * @exception Exception */ @Test public void testGetCounts() throws Exception { CMLFormula form = CMLFormula.createFormula("C 2 H 4 O 2"); DoubleTestBase.assertEquals("concise", new double[] { 2, 4, 2 }, form .getCounts(), EPS); form = CMLFormula.createFormula("C 2 H 4 O 2 -1"); DoubleTestBase.assertEquals("concise", new double[] { 2, 4, 2 }, form .getCounts(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.getTotalAtomCount()' * * @exception Exception */ @Test public void testGetTotalAtomCount() throws Exception{ CMLFormula form1 = CMLFormula.createFormula("C2H10"); Assert.assertEquals(form1.getTotalAtomCount(), 12.0, 0.0001); CMLFormula form2 = CMLFormula.createFormula("C2H10"); CMLFormula diff = form1.getDifference((form2)); Assert.assertEquals(0.0, diff.getTotalAtomCount(), 0.0001); } /** * Test method for * 'org.xmlcml.cml.element.CMLFormula.createAggregatedFormula(CMLFormula)' * * @exception Exception */ @Test public void testCreateAggregatedFormula() throws Exception { CMLFormula form1 = (CMLFormula)CMLXOMTestUtils.parseValidString(""); CMLFormula form2 = (CMLFormula)CMLXOMTestUtils.parseValidString(""); CMLFormula form3 = form1.createAggregatedFormula(form2); Assert.assertEquals("concise", "C 5 H 7 Cl 3 O 2 -1", form3.getConcise()); CMLFormula form4 = (CMLFormula)CMLXOMTestUtils.parseValidString(""); form3 = form1.createAggregatedFormula(form4); Assert.assertEquals("concise", "C 8 H 10 Cl 6 O 2 -4", form3.getConcise()); } /** * Test method for * 'org.xmlcml.cml.element.CMLFormula.getFormattedString(Type, Sort, * boolean)' * * @exception Exception */ @Test public void testGetFormattedStringTypeSortBoolean() throws Exception { CMLFormula form1 = (CMLFormula)CMLXOMTestUtils.parseValidString(""); boolean omit1 = true; Sort sort = Sort.ALPHABETIC_ELEMENTS; String formS = form1.getFormattedString(Type.ELEMENT_COUNT_WHITESPACE, sort, omit1); Assert.assertEquals("formatted", "Br C H4 O2 --", formS); omit1 = false; formS = form1.getFormattedString(Type.ELEMENT_COUNT_WHITESPACE, sort, omit1); Assert.assertEquals("formatted", "Br1 C1 H4 O2 --", formS); sort = Sort.CHFIRST; omit1 = false; formS = form1.getFormattedString(Type.ELEMENT_COUNT_WHITESPACE, sort, omit1); Assert.assertEquals("formatted", "C1 H4 Br1 O2 --", formS); omit1 = true; formS = form1.getFormattedString(Type.ELEMENT_COUNT_WHITESPACE, sort, omit1); Assert.assertEquals("formatted", "C H4 Br O2 --", formS); } /** * Test method for * 'org.xmlcml.cml.element.CMLFormula.getFormalChargeString()' * * @exception Exception */ @Test public void testGetFormalChargeString() throws Exception { CMLFormula form1 = (CMLFormula)CMLXOMTestUtils.parseValidString(""); String formS = form1.getFormalChargeString(); Assert.assertEquals("formatted", "--", formS); } /** * Test method for 'org.xmlcml.cml.element.CMLFormula.equals(CMLFormula, * double)' * * @exception Exception */ @Test public void testEqualsCMLFormulaDouble() throws Exception { CMLFormula form1 = (CMLFormula)CMLXOMTestUtils.parseValidString(""); CMLFormula form2 = (CMLFormula)CMLXOMTestUtils.parseValidString(""); Assert.assertFalse("equals", form1.equals(form2, 0.001)); Assert.assertTrue("equals", form1.equals(form2, 0.011)); } /** * Test method for * 'org.xmlcml.cml.element.CMLFormula.equalsConcise(CMLFormula, double)' * * @exception Exception */ @Test public void testEqualsConcise() throws Exception { CMLFormula form1 = (CMLFormula)CMLXOMTestUtils.parseValidString(""); CMLFormula form2 = (CMLFormula)CMLXOMTestUtils.parseValidString(""); Assert.assertTrue("equals", form1.equals(form1)); Assert.assertFalse("equals", form1.equals(form2)); } /** * checks that finishMakingElement does not throw exception */ @Test public void testReadFormula() { String s = ""+ ""+ ""+ " "+ " "+ ""; try { new CMLBuilder().build(new StringReader(s)); } catch (Exception e) { e.printStackTrace(); Assert.fail("Should not fail parse"+e.getMessage()); } } @Test public void testNullCreateFromMoleculeFactory(){ CMLMolecule mol = null; CMLFormula form = CMLFormula.createFormula(mol); Assert.assertNull(form); } @Test public void testEmptyCreateFromMoleculeFactory(){ CMLMolecule mol = new CMLMolecule(); CMLFormula form = CMLFormula.createFormula(mol); Assert.assertNotNull(form); Assert.assertEquals(0.0, form.getTotalAtomCount(), 0.0001); } @Test public void testCreateFromMoleculeFactory(){ CMLMolecule mol = new CMLMolecule(); mol.addAtom(new CMLAtom("a1", ChemicalElement.AS.C)); CMLFormula form = CMLFormula.createFormula(mol); Assert.assertNotNull(form); Assert.assertEquals(1.0, form.getTotalAtomCount(), 0.0001); } @Test public void test2LetterElements() { CMLFormula formula = CMLFormula.createFormula("H 6 O 2 Cl 2 R 4"); String formulaS = formula.getConcise(); Assert.assertEquals("2LetterTest", "H 6 Cl 2 O 2 R 4", formulaS); } @Test public void test2LetterElements1() { CMLFormula formula = CMLFormula.createFormula("H 6 Xe 1 O 2 Cl 2 R 4 B 3 Sn 4"); String formulaS = formula.getConcise(); Assert.assertEquals("2LetterTest", "H 6 B 3 Cl 2 O 2 R 4 Sn 4 Xe 1", formulaS); } @Test public void testConciseCharge() { CMLFormula formula = new CMLFormula(); formula.setConcise("H 4 O 2 C 3 -1"); // formula.debug(); String expectedFormulaS = "" + "" + ""; CMLXOMTestUtils.assertEqualsCanonically("concise", CMLXOMTestUtils.parseValidString(expectedFormulaS), formula, true); String formulaS = formula.getConcise(); Assert.assertEquals("negative", "C 3 H 4 O 2 -1", formulaS); } @Test public void testNegativeElements() { CMLFormula formula = new CMLFormula(); formula.setConcise("H 4 O -2 C 3"); Assert.assertFalse("negative", formula.isAllowNegativeCounts()); String formulaS = formula.getConcise(); Assert.assertEquals("negative", "C 3 H 4 O -2", formulaS); } @Test public void testNegativeElements1() { CMLFormula formula = new CMLFormula(); formula.setConcise("H 4 O -2 C 3 -3"); // formula.debug(); String formulaS = formula.getConcise(); Assert.assertEquals("negative", "C 3 H 4 O -2 -3", formulaS); } @Test public void testCreateConcise() { CMLFormula formula = CMLFormula.createFormula("H 4 O 2 C 3", Type.CONCISE); String formulaS = formula.getConcise(); Assert.assertEquals("Concise", "C 3 H 4 O 2", formulaS); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/lite/CMLMoleculeTest.java000077500000000000000000001405631477224461000277750ustar00rootroot00000000000000/** * 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.lite; import static org.xmlcml.euclid.EuclidConstants.EPS; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Map; import nu.xom.Element; import nu.xom.Elements; import nu.xom.Node; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.attribute.IdAttribute; import org.xmlcml.cml.base.CMLAttribute; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.base.CMLUtil; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.base.CMLElement.CoordinateType; import org.xmlcml.cml.base.CMLElement.FormalChargeControl; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLAtomArray; import org.xmlcml.cml.element.CMLBond; import org.xmlcml.cml.element.CMLBondArray; import org.xmlcml.cml.element.CMLCml; import org.xmlcml.cml.element.CMLFormula; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.CMLName; import org.xmlcml.cml.element.main.MoleculeAtomBondFixture; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.Real2; import org.xmlcml.euclid.Real2Vector; import org.xmlcml.molutil.ChemicalElement; import org.xmlcml.molutil.ChemicalElement.AS; /** * test CMLMolecule. * * @author pmr * */ public class CMLMoleculeTest { MoleculeAtomBondFixture fixture = new MoleculeAtomBondFixture(); /** * compare two molecules. ignore whitespace nodes in either. * * @param mol * to compare * @param filename * containing molecule as root element */ public static void assertEqualsCanonically(CMLMolecule mol, String filename) { CMLMolecule mol1 = null; try { mol1 = (CMLMolecule) new CMLBuilder().build(new File(filename)) .getRootElement(); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } assertEqualsCanonically(mol, mol1); } /** * compare two molecules. ignore whitespace nodes in either. * * @param mol * to compare * @param fixture * .mol1 other molecule */ public static void assertEqualsCanonically(CMLMolecule mol, CMLMolecule mol1) { mol = new CMLMolecule(mol); CMLUtil.removeWhitespaceNodes(mol); mol1 = new CMLMolecule(mol1); CMLUtil.removeWhitespaceNodes(mol1); String molS = mol.getCanonicalString(); String mol1S = mol1.getCanonicalString(); Assert.assertEquals("MOLECUL equality: ", molS, mol1S); CMLXOMTestUtils.assertEqualsCanonically("molecule equality", mol, mol1); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.addAtom(CMLAtom)' */ @Test public void testAddAtom() { fixture.makeMol1(); Assert.assertEquals("addAtom", 3, fixture.mol1.getAtomCount()); CMLAtom atom = new CMLAtom("a99"); fixture.mol1.addAtom(atom); Assert.assertEquals("addAtom", 4, fixture.mol1.getAtomCount()); Assert.assertEquals("addAtom", "a99", fixture.mol1.getAtom(3).getId()); } /** * Test method for * 'org.xmlcml.cml.element.CMLMolecule.appendMolecule(CMLMolecule)' */ @Test public void testAppendMolecule() { fixture.makeMol1(); fixture.makeMol2(); CMLMolecule emptyMolecule = new CMLMolecule(); Assert.assertNotNull("empty molecule", emptyMolecule); emptyMolecule.setId("m0"); emptyMolecule.appendMolecule(fixture.mol1); Assert.assertEquals("molecule children", 2, emptyMolecule .getMoleculeCount()); emptyMolecule.appendMolecule(fixture.mol2); Assert.assertEquals("molecule children", 3, emptyMolecule .getMoleculeCount()); Assert.assertEquals("top id", "m0", emptyMolecule.getId()); CMLElements molecules = emptyMolecule .getMoleculeElements(); CMLMolecule mol0a = molecules.get(0); Assert.assertEquals("id ", "m0", mol0a.getId()); List atoms0 = mol0a.getAtoms(); Assert.assertEquals("atoms ", 0, atoms0.size()); CMLMolecule mol1a = molecules.get(1); Assert.assertEquals("id ", "m1", mol1a.getId()); List atoms1 = mol1a.getAtoms(); Assert.assertEquals("atoms ", 3, atoms1.size()); Assert.assertEquals("atom id ", "a1", atoms1.get(0).getId()); CMLMolecule mol2a = molecules.get(2); Assert.assertEquals("id ", "m2", mol2a.getId()); List atoms2 = mol2a.getAtoms(); Assert.assertEquals("atoms ", 3, atoms2.size()); Assert.assertEquals("atom id ", "a11", atoms2.get(0).getId()); // --- Assert.assertEquals("molecule children", 0, fixture.mol1 .getMoleculeCount()); fixture.mol1.appendMolecule(fixture.mol2); Assert.assertEquals("molecule children", 2, fixture.mol1 .getMoleculeCount()); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.CMLMolecule()' */ @Test public void testCMLMolecule() { CMLMolecule molecule = new CMLMolecule(); Assert.assertNotNull("constructor ", molecule); Assert.assertNull("no id attribute", molecule.getIdAttribute()); Assert.assertEquals("no children", molecule.getChildCount(), 0); } /** * Test method for * 'org.xmlcml.cml.element.CMLMolecule.CMLMolecule(CMLMolecule)' */ @Test public void testCMLMoleculeCMLMolecule() { // copy constructor CMLMolecule molecule = new CMLMolecule(fixture.xmlMolecule); Assert.assertNotNull("constructor ", molecule); CMLAttribute idAtt = molecule.getIdAttribute(); Assert.assertTrue("id class is subclass of CMLAttribute", CMLAttribute.class.isAssignableFrom(idAtt.getClass())); Assert.assertEquals("id class is StringSTAttribute", IdAttribute.class, idAtt.getClass()); Assert.assertEquals("id value", molecule.getId(), fixture.xmlMolecule .getId()); Assert.assertEquals("Molecule is identical", molecule .compareTo(fixture.xmlMolecule), 0); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.copy()' */ @Test public void testCopy() { Node copy = fixture.xmlMolecule.copy(); Assert.assertEquals("class should be CMLMolecule: ", copy.getClass(), CMLMolecule.class); CMLMolecule copyMolecule = (CMLMolecule) copy; Assert.assertEquals("Molecule is identical", copyMolecule .compareTo(fixture.xmlMolecule), 0); } /** * test building from XML* Test method for * 'org.xmlcml.cml.element.CMLMolecule.createAndAddAtom(String)' */ @Test public void testCreateAndAddAtomString() { // build molecule CMLMolecule molecule = new CMLMolecule(); // add atom - fragile CMLAtom atom = new CMLAtom(); atom.setId("a1"); molecule.getOrCreateAtomArray().appendChild(atom); Assert.assertNotNull("create and add atom", atom); Assert.assertNotNull("created id", atom.getId()); Assert.assertEquals("created id", atom.getId(), "a1"); CMLAtomArray atomArray = (CMLAtomArray) molecule.getAtomArrayElements() .get(0); Assert.assertNotNull("added atomArray", atomArray); Assert.assertEquals("added atom", atomArray.getAtomElements().get(0), atom); // add another of same id, should fail atom = molecule.getAtomById("a1"); Assert.assertNotNull("atom should not be null", atom); atom = new CMLAtom(); atom.setId("z1"); fixture.xomMolecule.getOrCreateAtomArray().appendChild(atom); List atoms = fixture.xomMolecule.getAtoms(); Assert.assertEquals("atom count", 6, atoms.size()); Assert.assertEquals("atom id", "a1", ((CMLAtom) atoms.get(0)).getId()); Assert.assertEquals("atom id", "z1", ((CMLAtom) atoms.get(5)).getId()); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.getBond(CMLAtom, * CMLAtom)' */ @Test public void testGetBondCMLAtomCMLAtom() { fixture.makeMol5a(); CMLMolecule mol5a = fixture.mol5a; Assert.assertEquals("get bond", 4, mol5a.getBondCount()); CMLAtom atom1 = mol5a.getAtomById("a1"); Assert.assertNotNull("get bond", atom1); CMLAtom atom3 = mol5a.getAtomById("a3"); Assert.assertNotNull("get bond", atom3); CMLAtom atom4 = mol5a.getAtomById("a4"); Assert.assertNotNull("get bond", atom4); CMLBond bond = mol5a.getBond(atom1, atom3); Assert.assertNull("bond should be be null", bond); bond = mol5a.getBond(atom1, atom4); Assert.assertNotNull("bond should not be null", bond); Assert.assertEquals("bond atoms", new String[] { "a1", "a4" }, bond .getAtomRefs2()); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.getBondCount()' */ @Test public void testGetBondCount() { fixture.makeMol5a(); Assert.assertEquals("get bond count", 4, fixture.mol5a.getBondCount()); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.getBonds()' */ @Test public void testGetBonds() { List bonds = fixture.xmlMolecule.getBonds(); Assert.assertNotNull("bonds not null", bonds); Assert.assertEquals("number of bonds", fixture.xmlNbonds, bonds.size()); } /** * Test method for * 'org.xmlcml.cml.element.CMLMolecule.getCalculatedFormalCharge()' */ @Test public void testGetCalculatedFormalCharge() { fixture.makeMol1(); int fc = Integer.MIN_VALUE; try { fc = fixture.mol1 .getCalculatedFormalCharge(FormalChargeControl.NO_DEFAULT); } catch (RuntimeException e) { Assert.assertEquals("formal charge ", "BUG: (unset attribute: formalCharge)should never throw", e .getMessage()); } fc = Integer.MIN_VALUE; Assert.assertEquals("formal charge", Integer.MIN_VALUE, fc); fixture.makeMol5(); try { fc = fixture.mol5 .getCalculatedFormalCharge(FormalChargeControl.DEFAULT); } catch (RuntimeException e) { Assert.fail("formal charge should not throw " + e); } Assert.assertEquals("formal charge", -1, fc); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.getCentroid2D()' */ @Test public void testGetCentroid2D() { fixture.makeMol1(); Real2 centroid = fixture.mol1.calculateCentroid2D(); Assert.assertNull("centroid 1", centroid); fixture.makeMol7(); centroid = fixture.mol7.calculateCentroid2D(); Assert.assertNotNull("centroid 7", centroid); Assert.assertEquals("centroid x", 0.4, centroid.getX(), .0001); Assert.assertEquals("centroid y", 1.1666, centroid.getY(), .0001); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.getMoleculeCount()' */ @Test public void testGetMoleculeCount() { fixture.makeMol1(); Assert.assertEquals("molecule count", 0, fixture.mol1 .getMoleculeCount()); fixture.makeMol8(); Assert.assertEquals("molecule count", 2, fixture.mol8 .getMoleculeCount()); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.getMolecules()' */ @Test public void testGetMolecules() { CMLElements molecules = fixture.xmlMolecule .getMoleculeElements(); Assert.assertNotNull("empty child molecules not null", molecules); Assert.assertEquals("child molecule count", 0, molecules.size()); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.getVector2D()' */ @Test public void testGetVector2D() { fixture.makeMol1(); Real2Vector vector = fixture.mol1.getCoordinates2D(); Assert.assertNotNull("get vector2d", vector); Assert.assertEquals("get vector2d", 0, vector.size()); fixture.makeMol7(); vector = fixture.mol7.getCoordinates2D(); Assert.assertNotNull("get vector2d", vector); Assert.assertEquals("get vector2d", 3, vector.size()); Real2 p = vector.getReal2(2); Assert.assertEquals("vector x", 1.2, p.getX(), EPS); Assert.assertEquals("vector y", 2.2, p.getY(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.hasCoords()' */ @Test public void testHasCoords() { fixture.makeMol1(); Assert.assertTrue("has 3d coords", fixture.mol1 .hasCoordinates(CoordinateType.CARTESIAN)); Assert.assertFalse("has 2d coords", fixture.mol1 .hasCoordinates(CoordinateType.TWOD)); fixture.makeMol7(); Assert.assertTrue("has 3d coords", fixture.mol1 .hasCoordinates(CoordinateType.CARTESIAN)); Assert.assertFalse("has 2d coords", fixture.mol1 .hasCoordinates(CoordinateType.TWOD)); } /** * Test method for * 'org.xmlcml.cml.element.CMLMolecule.multiply2DCoordsBy(double)' */ @Test public void testMultiply2DCoordsBy() { fixture.makeMol7(); CMLMolecule mol7 = fixture.mol7; mol7.multiply2DCoordsBy(10.); Assert.assertEquals("scaled atom x", 0.0, mol7.getAtom(0).getX2(), EPS); Assert.assertEquals("scaled atom x", 0.0, mol7.getAtom(0).getY2(), EPS); Assert .assertEquals("scaled atom x", 12.0, mol7.getAtom(2).getX2(), EPS); Assert .assertEquals("scaled atom x", 22.0, mol7.getAtom(2).getY2(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.renameAtomIDs(List, * List)' */ @Test public void testRenameAtomIDs() { List oldList = new ArrayList(); oldList.add("a1"); oldList.add("a2"); oldList.add("a3"); List newList = new ArrayList(); newList.add("a01"); newList.add("a02"); newList.add("a03"); List badList = new ArrayList(); badList.add("a01"); badList.add("a02"); fixture.makeMol1(); fixture.mol1.renameAtomIDs(oldList, newList); Assert.assertEquals("renamed id", "a01", fixture.mol1.getAtom(0) .getId()); Assert.assertEquals("renamed id", "a02", fixture.mol1.getAtom(1) .getId()); Assert.assertEquals("renamed id", "a03", fixture.mol1.getAtom(2) .getId()); fixture.mol1.renameAtomIDs(newList, oldList); Assert .assertEquals("renamed id", "a1", fixture.mol1.getAtom(0) .getId()); Assert .assertEquals("renamed id", "a2", fixture.mol1.getAtom(1) .getId()); Assert .assertEquals("renamed id", "a3", fixture.mol1.getAtom(2) .getId()); try { fixture.mol1.renameAtomIDs(oldList, badList); Assert.fail("rename should throw exeception"); } catch (Exception e) { Assert.assertEquals("rename IDs should throw", "Lists (3/2) must be same length as atomCount (3)", e .getMessage()); } } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.translate2D(Real2)' */ @Test public void testTranslate2D() { fixture.makeMol7(); CMLMolecule mol7 = fixture.mol7; Real2 p = mol7.getAtom(0).getXY2(); Assert.assertEquals("original point", 0.0, p.getX(), EPS); Assert.assertEquals("original point", 0.0, p.getY(), EPS); p = mol7.getAtom(2).getXY2(); Assert.assertEquals("original point", 1.2, p.getX(), EPS); Assert.assertEquals("original point", 2.2, p.getY(), EPS); mol7.translate2D(new Real2(0.000111, 0.999999)); p = mol7.getAtom(0).getXY2(); Assert.assertEquals("moved point", 0.000111, p.getX(), EPS); Assert.assertEquals("moved point", 0.999999, p.getY(), EPS); p = mol7.getAtom(2).getXY2(); Assert.assertEquals("moved point", 1.200111, p.getX(), EPS); Assert.assertEquals("moved point", 3.199999, p.getY(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.unlabelAllAtoms()' */ @Test public void testUnlabelAllAtoms() { fixture.makeMol5(); CMLMolecule mol5 = fixture.mol5; Assert.assertNotNull("label C1", mol5.getAtomByLabel("C1")); Assert.assertNull("label C2", mol5.getAtomByLabel("C2")); Assert.assertNotNull("label H1a", mol5.getAtomByLabel("H1a")); mol5.unlabelAllAtoms(); Assert.assertNull("label C1", mol5.getAtomByLabel("C1")); Assert.assertNull("label C2", mol5.getAtomByLabel("C2")); Assert.assertNull("label H1a", mol5.getAtomByLabel("H1a")); } /** * Test method for * 'org.xmlcml.cml.element.CMLMolecule.getMoleculeAncestor(CMLElement)' * * @exception Exception */ @Test public void testGetMoleculeAncestor() throws Exception { CMLCml cml = (CMLCml)CMLXOMTestUtils.parseValidString("" + " " + " foo" + " " + " para" + " " + " " + ""); CMLMolecule mol = (CMLMolecule) cml.getChildElements().get(0); CMLName name = (CMLName) mol.getChildElements().get(0); CMLAtomArray atomArray = (CMLAtomArray) mol.getChildElements().get(1); // Element p = atomArray.getChildElements().get(0); Element e = CMLMolecule.getMoleculeAncestor(atomArray); Assert.assertEquals("equals", e, mol); e = CMLMolecule.getMoleculeAncestor(name); Assert.assertEquals("equals", e, mol); e = CMLMolecule.getMoleculeAncestor(mol); Assert.assertNull("equals", e); e = CMLMolecule.getMoleculeAncestor(cml); Assert.assertNull("equals", e); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.addBond(CMLBond, * boolean)' * * @exception Exception */ @Test public void testAddBond() throws Exception { CMLMolecule molecule = (CMLMolecule)CMLXOMTestUtils.parseValidString("" + " " + " " + " " + " " + " " + ""); List atoms = molecule.getAtoms(); CMLBond bond = new CMLBond(atoms.get(0), atoms.get(1)); bond.setId("b1"); molecule.addBond(bond); bond = new CMLBond(atoms.get(2), atoms.get(1)); bond.setId("b2"); molecule.addBond(bond); bond = new CMLBond(atoms.get(0), atoms.get(1)); bond.setId("b1"); try { molecule.addBond(bond); } catch (RuntimeException e) { Assert.assertEquals("check", "Bond id not unique: b1", e .getMessage()); } } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.appendToIds(String)' */ @Test public void testAppendToIds() { fixture.makeMol1(); CMLAtom atom = fixture.mol1.getAtom(0); String id = atom.getId(); Assert.assertEquals("resetId", "a1", id); atom = fixture.mol1.getAtomById("a1"); Assert.assertNotNull("atom 0 not null", atom); fixture.mol1.appendToIds("X"); id = fixture.mol1.getAtom(0).getId(); Assert.assertEquals("resetId", "a1X", id); atom = fixture.mol1.getAtomById("a1X"); Assert.assertNotNull("atom 0 not null", atom); fixture.makeMol8(); atom = fixture.mol8.getAtom(0); id = atom.getId(); Assert.assertEquals("resetId", "a1", id); fixture.mol8.appendToIds("X"); id = atom.getId(); Assert.assertEquals("resetId", "a1X", id); } /** * Test method for * 'org.xmlcml.cml.element.CMLMolecule.createCartesiansFromFractionals(CMLCr * y s t a l ) ' */ @Test public void testCreateCartesiansFromFractionalsCMLCrystal() { fixture.makeMolCryst(); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.getAtom(int)' */ @Test public void testGetAtom() { fixture.makeMol1(); CMLAtom atom = fixture.mol1.getAtom(0); Assert.assertNotNull("atom 0", atom); Assert.assertEquals("atom 0", "a1", atom.getId()); atom = fixture.mol1.getAtom(3); Assert.assertNull("atom 3", atom); fixture.makeMol8(); atom = fixture.mol8.getAtom(0); Assert.assertNotNull("atom 0 not null", atom); Assert.assertEquals("atom 0", "a1", atom.getId()); atom = fixture.mol8.getAtom(4); Assert.assertNotNull("atom 4 not null", atom); Assert.assertEquals("atom 4", "a2", atom.getId()); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.getAtomById(String)' */ @Test public void testGetAtomById() { fixture.makeMol1(); CMLAtom atom = fixture.mol1.getAtomById("a1"); Assert.assertNotNull("atom 0", atom); Assert.assertEquals("atom 0", "a1", atom.getId()); atom = fixture.mol1.getAtomById("a4"); Assert.assertNull("atom 4", atom); fixture.makeMol8(); atom = fixture.mol8.getAtomById("a1"); Assert.assertNull("atom 0 null", atom); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.getBondById(String)' */ @Test public void testGetBondById() { fixture.makeMol5a(); CMLBond bond = fixture.mol5a.getBondById("a1_a2"); Assert.assertNotNull("not null bond", bond); String id = bond.getId(); Assert.assertEquals("bond", "a1_a2", id); } /** * Test method for * 'org.xmlcml.cml.element.CMLMolecule.getAtomsByIds(String[])' */ @Test public void testGetAtomListByIds() { fixture.makeMol1(); List atomList = fixture.mol1.getAtomListByIds(new String[] { "a1", "a3" }); Assert.assertNotNull("atomList", atomList); Assert.assertEquals("atomList", 2, atomList.size()); Assert.assertEquals("atom", "a1", atomList.get(0).getId()); atomList = fixture.mol1.getAtomsById("a4"); Assert.assertNull("atom 4", atomList); fixture.makeMol8(); atomList = fixture.mol8.getAtomListByIds(new String[] { "a1", "a3" }); Assert.assertNotNull("atomList", atomList); Assert.assertEquals("atomList", 0, atomList.size()); } /** * Test method for * 'org.xmlcml.cml.element.CMLMolecule.getAtomByLabel(String)' */ @Test public void testGetAtomByLabel() { fixture.makeMol5(); CMLAtom atom = fixture.mol5.getAtomByLabel("C1"); Assert.assertNotNull("atom not null", atom); Assert.assertEquals("atom id", "a1", atom.getId()); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.getBond(CMLAtom, * CMLAtom)' */ @Test public void testGetBond() { fixture.makeMol5a(); CMLMolecule mol5a = fixture.mol5a; CMLAtom a1 = mol5a.getAtomById("a1"); CMLAtom a2 = mol5a.getAtomById("a2"); CMLBond b = mol5a.getBond(a1, a2); Assert.assertNotNull("b not null", b); } /** * Test method for * 'org.xmlcml.cml.element.CMLMolecule.calculateCentroid2D()' */ @Test public void testCalculateCentroid2D() { fixture.makeMol7(); Real2 r2 = fixture.mol7.calculateCentroid2D(); Assert.assertEquals("r2", 0.4, r2.getX(), 0.00001); Assert.assertEquals("r2", 3.5 / 3., r2.getY(), 0.00001); fixture.makeMol1(); r2 = fixture.mol1.calculateCentroid2D(); Assert.assertNull("centroid null", r2); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.getDoubleBonds()' */ @Test public void testGetDoubleBonds() { fixture.makeMol5a(); List bonds = fixture.mol5a.getBonds(); Assert.assertNull("bond 1", bonds.get(0).getOrder()); bonds.get(0).setOrder(CMLBond.SINGLE_S); bonds.get(1).setOrder(CMLBond.DOUBLE_D); bonds.get(3).setOrder(CMLBond.DOUBLE_D); Assert.assertEquals("bond 0", CMLBond.SINGLE_S, bonds.get(0).getOrder()); Assert.assertEquals("bond 1", CMLBond.DOUBLE_D, bonds.get(1).getOrder()); Assert.assertNull("bond 2", bonds.get(2).getOrder()); List bondList = fixture.mol5a.getDoubleBonds(); Assert.assertEquals("bonds", 2, bondList.size()); } protected CMLMolecule makeMol1a() { CMLMolecule mol1a = new CMLMolecule(fixture.mol1); mol1a.getAtom(0).resetId("a11"); mol1a.getAtom(1).resetId("a12"); mol1a.getAtom(2).resetId("a13"); return mol1a; } /** * Test method for * 'org.xmlcml.cml.element.CMLMolecule.getDescendantsOrMolecule()' */ @Test public void testGetDescendantsOrMolecule() { fixture.makeMol1(); // get single molecule List molList = fixture.mol1.getDescendantsOrMolecule(); Assert.assertNotNull("mol not null", molList); Assert.assertEquals("mols", 1, molList.size()); fixture.makeMol8(); // gets the 2 children molList = fixture.mol8.getDescendantsOrMolecule(); Assert.assertNotNull("mol not null", molList); Assert.assertEquals("mols", 2, molList.size()); } /** * Test method for 'org.xmlcml.cml.element.CMLMolecule.getCoordinates2D()' */ @Test public void testGetCoordinates2D() { fixture.makeMol7(); Real2Vector r2v = fixture.mol7.getCoordinates2D(); Assert.assertEquals("coord2", 3, r2v.size()); Real2 r2 = r2v.get(2); Assert.assertEquals("r2", 1.2, r2.getX(), 0.00001); Assert.assertEquals("r2", 2.2, r2.getY(), 0.00001); } /** * Test method for * 'org.xmlcml.cml.element.CMLMolecule.hasCoordinates(CoordinateType)' */ @Test public void testHasCoordinates() { fixture.makeMol5a(); Assert.assertTrue("coords", fixture.mol5a .hasCoordinates(CoordinateType.CARTESIAN)); fixture.makeMol7(); Assert.assertFalse("coords", fixture.mol7 .hasCoordinates(CoordinateType.CARTESIAN)); } /** * Test method for * 'org.xmlcml.cml.element.CMLMolecule.isMoleculeContainer()' */ @Test public void testIsMoleculeContainer() { fixture.makeMol1(); Assert.assertFalse("container", fixture.mol1.isMoleculeContainer()); fixture.makeMol8(); Assert.assertTrue("container", fixture.mol8.isMoleculeContainer()); } // /** // * Test method for // * 'org.xmlcml.cml.element.CMLMolecule.mustEqual(CMLElement)' // */ // @Test // public void testMustEqual() { // fixture.mol1.mustEqual(fixture.mol1); // } /** * Test method for * 'org.xmlcml.cml.element.CMLMolecule.setBondOrders(String)' */ @Test public void testSetBondOrders() { fixture.makeMol5a(); List bonds = fixture.mol5a.getBonds(); Assert.assertNull("bond 1", bonds.get(0).getOrder()); bonds.get(0).setOrder(CMLBond.SINGLE_S); bonds.get(1).setOrder(CMLBond.DOUBLE_D); Assert.assertEquals("bond 0", CMLBond.SINGLE_S, bonds.get(0).getOrder()); Assert.assertEquals("bond 1", CMLBond.DOUBLE_D, bonds.get(1).getOrder()); Assert.assertNull("bond 2", bonds.get(2).getOrder()); } /** * Test method for * 'org.xmlcml.cml.element.CMLMolecule.setPreferredBondOrders()' */ @Test public void testSetNormalizedBondOrders() { String s = "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""; CMLMolecule mol = (CMLMolecule)CMLXOMTestUtils.parseValidString(s); List bondList = mol.getBonds(); Assert .assertEquals("bond0", CMLBond.SINGLE_S, bondList.get(0) .getOrder()); Assert .assertEquals("bond1", CMLBond.SINGLE_S, bondList.get(1) .getOrder()); Assert .assertEquals("bond2", CMLBond.DOUBLE_D, bondList.get(2) .getOrder()); mol.setNormalizedBondOrders(); Assert .assertEquals("bond0", CMLBond.SINGLE_S, bondList.get(0) .getOrder()); Assert .assertEquals("bond1", CMLBond.SINGLE_S, bondList.get(1) .getOrder()); Assert .assertEquals("bond2", CMLBond.DOUBLE_D, bondList.get(2) .getOrder()); Assert.assertNull("bond3", bondList.get(3).getOrder()); bondList.get(0).setOrder(CMLBond.SINGLE_S); bondList.get(1).setOrder(CMLBond.SINGLE_S); bondList.get(2).setOrder(CMLBond.DOUBLE_D); Assert .assertEquals("bond0", CMLBond.SINGLE_S, bondList.get(0) .getOrder()); Assert .assertEquals("bond1", CMLBond.SINGLE_S, bondList.get(1) .getOrder()); Assert .assertEquals("bond2", CMLBond.DOUBLE_D, bondList.get(2) .getOrder()); Assert.assertNull("bond3", bondList.get(3).getOrder()); } // /** // * Test method for // * 'org.xmlcml.cml.element.CMLMolecule.transform(CMLSymmetry)' // */ // @Test // public void testTransformCMLSymmetry() { // fixture.mol1.transform(new CMLSymmetry()); // fail("Not yet implemented"); // TODO // } // /** * tests addition and deletion through the tree. should be rerouted * */ @Test public void testAddAndDeleteAtoms() { CMLMolecule molecule = new CMLMolecule(); CMLAtom atom0 = new CMLAtom("a0"); molecule.addAtom(atom0); Assert.assertEquals("addAtom", 1, molecule.getAtomCount()); Assert.assertEquals("addAtom", 0, atom0.getLigandAtoms().size()); Assert.assertEquals("addAtom", 0, atom0.getLigandBonds().size()); CMLAtom atom1 = new CMLAtom("a1"); molecule.appendChild(atom1); Assert.assertEquals("addAtom", 2, molecule.getAtomCount()); Assert.assertEquals("addAtom", 0, atom0.getLigandAtoms().size()); Assert.assertEquals("addAtom", 0, atom0.getLigandBonds().size()); Assert.assertEquals("addAtom", 0, atom1.getLigandAtoms().size()); Assert.assertEquals("addAtom", 0, atom1.getLigandBonds().size()); CMLBond bond0 = new CMLBond(atom0, atom1); molecule.appendChild(bond0); Assert.assertEquals("addBond", 1, molecule.getBondCount()); Assert.assertEquals("addAtom", 1, atom0.getLigandAtoms().size()); Assert.assertEquals("addAtom", 1, atom0.getLigandBonds().size()); Assert.assertEquals("addAtom", 1, atom1.getLigandAtoms().size()); Assert.assertEquals("addAtom", 1, atom1.getLigandBonds().size()); CMLAtom atom2 = new CMLAtom("a2"); molecule.appendChild(atom2); Assert.assertEquals("addAtom", 3, molecule.getAtomCount()); Assert.assertEquals("addAtom", 1, atom0.getLigandAtoms().size()); Assert.assertEquals("addAtom", 1, atom0.getLigandBonds().size()); Assert.assertEquals("addAtom", 1, atom1.getLigandAtoms().size()); Assert.assertEquals("addAtom", 1, atom1.getLigandBonds().size()); Assert.assertEquals("addAtom", 0, atom2.getLigandAtoms().size()); Assert.assertEquals("addAtom", 0, atom2.getLigandBonds().size()); CMLBond bond1 = new CMLBond(atom1, atom2); molecule.appendChild(bond1); Assert.assertEquals("addBond", 2, molecule.getBondCount()); Assert.assertEquals("addAtom", 1, atom0.getLigandAtoms().size()); Assert.assertEquals("addAtom", 1, atom0.getLigandBonds().size()); Assert.assertEquals("addAtom", 2, atom1.getLigandAtoms().size()); Assert.assertEquals("addAtom", 2, atom1.getLigandBonds().size()); Assert.assertEquals("addAtom", 1, atom2.getLigandAtoms().size()); Assert.assertEquals("addAtom", 1, atom2.getLigandBonds().size()); CMLAtom atom3 = new CMLAtom("a3"); molecule.appendChild(atom3); Assert.assertEquals("addAtom", 4, molecule.getAtomCount()); Assert.assertEquals("addAtom", 1, atom0.getLigandAtoms().size()); Assert.assertEquals("addAtom", 1, atom0.getLigandBonds().size()); Assert.assertEquals("addAtom", 2, atom1.getLigandAtoms().size()); Assert.assertEquals("addAtom", 2, atom1.getLigandBonds().size()); Assert.assertEquals("addAtom", 1, atom2.getLigandAtoms().size()); Assert.assertEquals("addAtom", 1, atom2.getLigandBonds().size()); Assert.assertEquals("addAtom", 0, atom3.getLigandAtoms().size()); Assert.assertEquals("addAtom", 0, atom3.getLigandBonds().size()); CMLBond bond2 = new CMLBond(atom1, atom3); molecule.appendChild(bond2); Assert.assertEquals("addBond", 3, molecule.getBondCount()); Assert.assertEquals("addAtom", 1, atom0.getLigandAtoms().size()); Assert.assertEquals("addAtom", 1, atom0.getLigandBonds().size()); Assert.assertEquals("addAtom", 3, atom1.getLigandAtoms().size()); Assert.assertEquals("addAtom", 3, atom1.getLigandBonds().size()); Assert.assertEquals("addAtom", 1, atom2.getLigandAtoms().size()); Assert.assertEquals("addAtom", 1, atom2.getLigandBonds().size()); Assert.assertEquals("addAtom", 1, atom3.getLigandAtoms().size()); Assert.assertEquals("addAtom", 1, atom3.getLigandBonds().size()); molecule.deleteAtom(atom2); Assert.assertEquals("addAtom", 1, atom0.getLigandAtoms().size()); Assert.assertEquals("addAtom", 1, atom0.getLigandBonds().size()); Assert.assertEquals("addAtom", 2, atom1.getLigandAtoms().size()); Assert.assertEquals("addAtom", 2, atom1.getLigandBonds().size()); Assert.assertEquals("addAtom", 0, atom2.getLigandAtoms().size()); Assert.assertEquals("addAtom", 0, atom2.getLigandBonds().size()); Assert.assertEquals("addAtom", 1, atom3.getLigandAtoms().size()); Assert.assertEquals("addAtom", 1, atom3.getLigandBonds().size()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#createMoleculeWithId(java.lang.String)} * . */ @Test public final void testCreateMoleculeWithIdString() { CMLMolecule mol = CMLMolecule.createMoleculeWithId("m1"); Assert.assertEquals("create mol", 0, mol.getAtomCount()); Assert.assertEquals("create mol", 0, mol.getBondCount()); Assert.assertEquals("create mol", "m1", mol.getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#deleteAtom(org.xmlcml.cml.element.CMLAtom)} * . */ @Test public final void testDeleteAtom() { fixture.makeMol1(); Assert.assertEquals("orig", 3, fixture.mol1.getAtomCount()); Assert.assertEquals("orig", 0, fixture.mol1.getBondCount()); CMLAtom a1 = fixture.mol1.getAtomById("a1"); fixture.mol1.deleteAtom(a1); Assert.assertEquals("orig", 2, fixture.mol1.getAtomCount()); a1 = fixture.mol1.getAtomById("a1"); Assert.assertNull("deleted should be null", a1); fixture.makeMol5a(); CMLMolecule mol5a = fixture.mol5a; Assert.assertEquals("orig", 5, mol5a.getAtomCount()); Assert.assertEquals("orig", 4, mol5a.getBondCount()); a1 = mol5a.getAtomById("a1"); CMLAtom a2 = mol5a.getAtomById("a2"); CMLAtom a3 = mol5a.getAtomById("a3"); CMLAtom a4 = mol5a.getAtomById("a4"); CMLBond bond = mol5a.getBond(a1, a2); mol5a.deleteAtom(a1); Assert.assertEquals("orig", 4, mol5a.getAtomCount()); Assert.assertEquals("orig", 1, mol5a.getBondCount()); bond = mol5a.getBond(a1, a2); Assert.assertNull("orig", bond); bond = mol5a.getBond(a1, a4); Assert.assertNull("orig", bond); bond = mol5a.getBond(a2, a3); Assert.assertNotNull("orig", bond); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#removeAtomArray()}. */ @Test public final void testRemoveAtomArray() { fixture.makeMol1(); Assert.assertEquals("orig", 3, fixture.mol1.getAtomCount()); fixture.mol1.removeAtomArray(); Assert.assertEquals("orig", 0, fixture.mol1.getAtomCount()); fixture.makeMol5a(); CMLMolecule mol5a = fixture.mol5a; Assert.assertEquals("orig", 5, mol5a.getAtomCount()); Assert.assertEquals("orig", 4, mol5a.getBondCount()); mol5a.removeAtomArray(); Assert.assertEquals("orig", 0, mol5a.getAtomCount()); Assert.assertEquals("orig", 0, mol5a.getBondCount()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#removeBondArray()}. */ @Test public final void testRemoveBondArray() { fixture.makeMol1(); Assert.assertEquals("orig", 0, fixture.mol1.getBondCount()); fixture.mol1.removeBondArray(); Assert.assertEquals("orig", 0, fixture.mol1.getBondCount()); fixture.makeMol5a(); CMLMolecule mol5a = fixture.mol5a; Assert.assertEquals("orig", 5, mol5a.getAtomCount()); Assert.assertEquals("orig", 4, mol5a.getBondCount()); mol5a.removeBondArray(); Assert.assertEquals("orig", 5, mol5a.getAtomCount()); Assert.assertEquals("orig", 0, mol5a.getBondCount()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#deleteBond(org.xmlcml.cml.element.CMLBond)} * . */ @Test public final void testDeleteBond() { fixture.makeMol5a(); CMLMolecule mol5a = fixture.mol5a; Assert.assertEquals("orig", 5, mol5a.getAtomCount()); Assert.assertEquals("orig", 4, mol5a.getBondCount()); CMLAtom a1 = mol5a.getAtomById("a1"); CMLAtom a2 = mol5a.getAtomById("a2"); CMLBond bond = mol5a.getBond(a1, a2); mol5a.deleteBond(bond); Assert.assertEquals("orig", 5, mol5a.getAtomCount()); Assert.assertEquals("orig", 3, mol5a.getBondCount()); bond = mol5a.getBond(a1, a2); Assert.assertNull("orig", bond); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#deleteMolecule(org.xmlcml.cml.element.CMLMolecule)} * . */ @Test public final void testDeleteMolecule() { fixture.makeMol8(); CMLMolecule mol8 = fixture.mol8; Assert.assertEquals("orig", 2, mol8.getMoleculeCount()); CMLMolecule mol81 = mol8.getMoleculeElements().get(0); // CMLMolecule mol82 = mol8.getMoleculeElements().get(1); mol8.deleteMolecule(mol81); Assert.assertEquals("after", 1, mol8.getMoleculeCount()); mol8.normalizeSingleMoleculeChild(); Assert.assertEquals("after normalization", 0, mol8.getMoleculeCount()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#normalizeSingleMoleculeChild()} * . */ @Test public final void testNormalizeSingleMoleculeChild() { fixture.makeMol1(); Assert.assertEquals("orig", 3, fixture.mol1.getAtomCount()); Assert.assertEquals("orig", 0, fixture.mol1.getMoleculeCount()); Assert.assertEquals("orig", "m1", fixture.mol1.getId()); CMLMolecule top = CMLMolecule.createMoleculeWithId("top"); top.appendChild(fixture.mol1); Assert.assertEquals("after", 3, top.getAtomCount()); Assert.assertEquals("after", 1, top.getMoleculeCount()); Assert.assertEquals("after", "top", top.getId()); top.normalizeSingleMoleculeChild(); Assert.assertEquals("after norm", 3, top.getAtomCount()); Assert.assertEquals("after norm", 0, top.getMoleculeCount()); Assert.assertEquals("after norm", "top", top.getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#appendChild(org.xmlcml.cml.element.CMLMolecule)} * . */ @Test public final void testAppendChildCMLMolecule() { // same as addMolecule } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#removeChild(org.xmlcml.cml.element.CMLMolecule)} * . */ @Test public final void testRemoveChildCMLMolecule() { // same as removeMolecule } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#appendChild(org.xmlcml.cml.element.CMLAtom)} * . */ @Test public final void testAppendChildCMLAtom() { // same as addAtom } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#removeChild(org.xmlcml.cml.element.CMLAtom)} * . */ @Test public final void testRemoveChildCMLAtom() { // same as removeAtom } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#appendChild(org.xmlcml.cml.element.CMLBond)} * . */ @Test public final void testAppendChildCMLBond() { // same as addBond } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#removeChild(org.xmlcml.cml.element.CMLBond)} * . */ @Test public final void testRemoveChildCMLBond() { // same as removeBond } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#getAtomArray()}. */ @Test public final void testGetAtomArray() { fixture.makeMol1(); CMLAtomArray atomArray = fixture.mol1.getAtomArray(); Assert.assertNotNull("atomArray", atomArray); fixture.mol1 = CMLMolecule.createMoleculeWithId("m1"); atomArray = fixture.mol1.getAtomArray(); Assert.assertNull("atomArray", atomArray); CMLAtom atom = new CMLAtom("a1"); fixture.mol1.addAtom(atom); atomArray = fixture.mol1.getAtomArray(); Assert.assertNotNull("atomArray", atomArray); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#getAtomMap()}. */ @Test public final void testGetAtomMap() { fixture.makeMol5a(); Map map = fixture.mol5a.getAtomMap(); Assert.assertEquals("map", 5, map.size()); CMLAtom atom = map.get("a2"); Assert.assertNotNull("atom not null", atom); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#getBondMap()}. */ @Test public final void testGetBondMap() { fixture.makeMol5a(); Map map = fixture.mol5a.getBondMap(); Assert.assertEquals("map", 4, map.size()); // hash is ordered this way CMLBond bond = map.get("a2__a1"); Assert.assertNotNull("bond not null", bond); Assert.assertEquals("bond", new String[] { "a1", "a2" }, bond .getAtomRefs2()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#getBondIdMap()}. */ @Test public final void testGetBondIdMap() { fixture.makeMol5a(); Map bondMap = fixture.mol5a.getBondIdMap(); Assert.assertEquals("map", 4, bondMap.size()); CMLBond bond = bondMap.get("a1_a4"); Assert.assertNotNull("bond not null", bond); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#getAtomsById(java.lang.String)} * . */ @Test public final void testGetAtomsById() { fixture.makeMol1(); List atomList = fixture.mol1.getAtomsById("a1"); Assert.assertNotNull("atomList", atomList); Assert.assertEquals("atomList", 1, atomList.size()); Assert.assertEquals("atom", "a1", atomList.get(0).getId()); atomList = fixture.mol1.getAtomsById("a4"); Assert.assertNull("atom 4", atomList); fixture.makeMol8(); CMLMolecule mol8 = fixture.mol8; atomList = mol8.getAtomsById("a1"); Assert.assertNotNull("atomList", atomList); Assert.assertEquals("atomList", 2, atomList.size()); Assert.assertEquals("atom", "a1", atomList.get(0).getId()); atomList = mol8.getAtomsById("a33"); Assert.assertEquals("atomList", 1, atomList.size()); atomList = mol8.getAtomsById("a4"); Assert.assertNull("atom 4", atomList); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#getAtomCount()}. */ @Test public final void testGetAtomCount() { fixture.makeMol1(); Assert.assertEquals("atom count", 3, fixture.mol1.getAtomCount()); fixture.makeMol8(); Assert.assertEquals("atom count", 6, fixture.mol8.getAtomCount()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#getAtoms()}. */ @Test public final void testGetAtoms() { fixture.makeMol1(); List atomList = fixture.mol1.getAtoms(); Assert.assertEquals("atoms", 3, atomList.size()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#getBondArray()}. */ @Test public final void testGetBondArray() { fixture.makeMol5a(); CMLBondArray bondArray = fixture.mol5a.getBondArray(); Assert.assertNotNull("bondArray", bondArray); fixture.makeMol1(); bondArray = fixture.mol1.getBondArray(); Assert.assertNull("bondArray", bondArray); CMLAtom a1 = fixture.mol1.getAtomById("a1"); CMLAtom a2 = fixture.mol1.getAtomById("a2"); CMLBond bond = new CMLBond(a1, a2); fixture.mol1.addBond(bond); bondArray = fixture.mol1.getBondArray(); Assert.assertNotNull("bondArray", bondArray); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#getOrCreateAtomArray()}. */ @Test public final void testGetOrCreateAtomArray() { fixture.makeMol1(); CMLAtomArray atomArray = fixture.mol1.getOrCreateAtomArray(); Assert.assertNotNull("create atomArray", atomArray); Assert.assertEquals("atomArray", 3, atomArray.getChildCMLElements( CMLAtom.TAG).size()); fixture.mol1 = CMLMolecule.createMoleculeWithId("m1"); Elements atomArrayList = fixture.mol1 .getChildCMLElements(CMLAtomArray.TAG); Assert.assertEquals("missing atomArray", 0, atomArrayList.size()); atomArray = fixture.mol1.getOrCreateAtomArray(); Assert.assertNotNull("create atomArray", atomArray); Assert.assertEquals("atomArray", 0, atomArray.getChildCMLElements( CMLAtom.TAG).size()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLMolecule#getOrCreateBondArray()}. */ @Test public final void testGetOrCreateBondArray() { fixture.makeMol1(); Elements bondArrayList = fixture.mol1 .getChildCMLElements(CMLBondArray.TAG); Assert.assertEquals("missing bondArray", 0, bondArrayList.size()); CMLBondArray bondArray = fixture.mol1.getOrCreateBondArray(); Assert.assertNotNull("create bondArray", bondArray); Assert.assertEquals("bondArray", 0, bondArray.getChildCMLElements( CMLBond.TAG).size()); fixture.mol1 = CMLMolecule.createMoleculeWithId("m1"); bondArray = fixture.mol1.getOrCreateBondArray(); Assert.assertNotNull("create bondArray", bondArray); Assert.assertEquals("bondArray", 0, bondArray.getChildCMLElements( CMLBond.TAG).size()); } /** * Tests getFormulaWithConvention method. * @author nwe23 */ @Test public final void testGetFormulaWithConvention(){ CMLMolecule mol = new CMLMolecule(); String value=mol.getFormulaWithConvention("foo"); Assert.assertEquals(null, value); CMLFormula form = new CMLFormula(); form.setInline("testing"); form.setConvention("foo"); mol.addFormula(form); value=mol.getFormulaWithConvention("foo"); Assert.assertEquals("testing", value); form=new CMLFormula(); form.setConvention("bar"); form.appendChild("test2"); mol.addFormula(form); value=mol.getFormulaWithConvention("bar"); Assert.assertEquals("test2", value); } @Test public void testCalculateHydrogenCountSimple() { CMLMolecule molecule = new CMLMolecule(); CMLAtom carbon1 = new CMLAtom("a1", ChemicalElement .getChemicalElement(AS.C.value)); molecule.addAtom(carbon1); CMLAtom carbon2 = new CMLAtom("a2", ChemicalElement .getChemicalElement(AS.C.value)); molecule.addAtom(carbon2); CMLAtom oxygen = new CMLAtom("a3", ChemicalElement .getChemicalElement(AS.O.value)); molecule.addAtom(oxygen); molecule.addBond(new CMLBond(carbon1, carbon2)); molecule.addBond(new CMLBond(carbon2, oxygen)); oxygen.setHydrogenCount(1); carbon2.setHydrogenCount(2); carbon1.setHydrogenCount(3); Assert.assertEquals(6, molecule.calculateHydrogenCount()); CMLAtom hydrogen1 = new CMLAtom("h1", ChemicalElement .getChemicalElement(AS.H.value)); molecule.addAtom(hydrogen1); molecule.addBond(new CMLBond(carbon1, hydrogen1)); Assert.assertEquals(6, molecule.calculateHydrogenCount()); CMLAtom hydrogen2 = new CMLAtom("h2", ChemicalElement .getChemicalElement(AS.H.value)); molecule.addAtom(hydrogen2); molecule.addBond(new CMLBond(carbon1, hydrogen2)); Assert.assertEquals(6, molecule.calculateHydrogenCount()); CMLAtom hydrogen3 = new CMLAtom("h3", ChemicalElement .getChemicalElement(AS.H.value)); molecule.addAtom(hydrogen3); molecule.addBond(new CMLBond(carbon1, hydrogen3)); Assert.assertEquals(6, molecule.calculateHydrogenCount()); carbon1.setHydrogenCount(1); //additional explicit hydrogens override value of hydrogenCount Assert.assertEquals(6, molecule.calculateHydrogenCount()); } @Test public void testCalculateHydrogenCountWithBridgingHydrogens() { //diborane CMLMolecule molecule = new CMLMolecule(); CMLAtom boron1 = new CMLAtom("a1", ChemicalElement .getChemicalElement(AS.B.value)); molecule.addAtom(boron1); CMLAtom boron2 = new CMLAtom("a2", ChemicalElement .getChemicalElement(AS.B.value)); molecule.addAtom(boron2); CMLAtom hydrogen1 = new CMLAtom("h1", ChemicalElement .getChemicalElement(AS.H.value)); molecule.addAtom(hydrogen1); molecule.addBond(new CMLBond(boron1, hydrogen1)); CMLAtom hydrogen2 = new CMLAtom("h2", ChemicalElement .getChemicalElement(AS.H.value)); molecule.addAtom(hydrogen2); molecule.addBond(new CMLBond(boron1, hydrogen2)); CMLAtom hydrogen3 = new CMLAtom("h3", ChemicalElement .getChemicalElement(AS.H.value)); molecule.addAtom(hydrogen3); molecule.addBond(new CMLBond(boron2, hydrogen3)); CMLAtom hydrogen4 = new CMLAtom("h4", ChemicalElement .getChemicalElement(AS.H.value)); molecule.addAtom(hydrogen4); molecule.addBond(new CMLBond(boron2, hydrogen4)); CMLAtom bridging1 = new CMLAtom("h5", ChemicalElement .getChemicalElement(AS.H.value)); molecule.addAtom(bridging1); molecule.addBond(new CMLBond(boron1, bridging1)); molecule.addBond(new CMLBond(boron2, bridging1)); CMLAtom bridging2 = new CMLAtom("h6", ChemicalElement .getChemicalElement(AS.H.value)); molecule.addAtom(bridging2); molecule.addBond(new CMLBond(boron1, bridging2)); molecule.addBond(new CMLBond(boron2, bridging2)); Assert.assertEquals(6, molecule.calculateHydrogenCount()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/lite/CMLPeakListTest.java000077500000000000000000000157501477224461000277430ustar00rootroot00000000000000/** * 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.lite; import java.util.List; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLMap; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.CMLPeak; import org.xmlcml.cml.element.CMLPeakList; /** * @author pm286 */ public class CMLPeakListTest { CMLPeakList peakList; CMLPeakList peakAndGroupList; String peakAndGroupListS = "" + " " + " " + " " + " " + " " + " " + ""; String moleculeS = "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""; CMLMolecule molecule; CMLPeakList toluenePeakList; CMLMolecule toluene; CMLMap tolueneMap; /** */ @Before public void setup() { if (peakList == null) { peakList = new CMLPeakList(); CMLPeak peak = new CMLPeak(); peak.setXValue(3.0); peak.setYValue(10.0); peak.setId("p1"); peakList.addPeak(peak); peak = new CMLPeak(); peak.setXValue(1.0); peak.setYValue(7.0); peak.setId("p2"); peakList.addPeak(peak); peak = new CMLPeak(); peak.setXValue(2.0); peak.setYValue(5.0); peak.setId("p3"); peakList.addPeak(peak); peak = new CMLPeak(); peak.setXValue(2.0); peak.setYValue(3.0); peak.setId("p4"); peakList.addPeak(peak); } if (peakAndGroupList == null) { peakAndGroupList = (CMLPeakList)CMLXOMTestUtils.parseValidString(peakAndGroupListS); } if (molecule == null) { molecule = (CMLMolecule)CMLXOMTestUtils.parseValidString(moleculeS); } } private void makeToluene() { // deliberately misordered String tolueneS = " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " "; toluene = (CMLMolecule)CMLXOMTestUtils.parseValidString(tolueneS); // delieberately unordered - numbers meaningless String toluenePeakListS = "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""; toluenePeakList = (CMLPeakList)CMLXOMTestUtils.parseValidString(toluenePeakListS); @SuppressWarnings("unused") String tolueneMapS = "" + " " + " " + " " + " " + " " + " " + "" + " " + " " + " " + " " + " " + " " + " " + " " + ""; } /** */ @Test public final void testGetPeaks() { List peaks = peakList.getPeakChildren(); Assert.assertEquals("indexables", "p2", ((CMLPeak) peaks.get(1)) .getId()); } /** */ @Test public void testRemoveAtomsByElementType() { makeToluene(); // CMLAtomSet tolueneAtomSet = toluene.getAtomSet(); // CMLAtomSet tolueneCarbonSet = // tolueneAtomSet.getAtomSetByElementType(AS.C.value); // CMLAtomSet tolueneHydrogenSet = // tolueneAtomSet.getAtomSetByElementType(AS.H.value); // toluenePeakList.addAtomRefs(tolueneMap, true); toluene = null; } /** */ @Test public final void testGetPeakChildren() { List peaks = peakList.getPeakChildren(); Assert.assertEquals("peaks", 4, peaks.size()); peaks = peakAndGroupList.getPeakChildren(); Assert.assertEquals("peaks", 2, peaks.size()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/lite/CMLPeakStructureTest.java000077500000000000000000000325471477224461000310330ustar00rootroot00000000000000/** * 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.lite; import static org.xmlcml.cml.element.main.AbstractTestBase.SIMPLE_RESOURCE; import java.io.IOException; import java.io.InputStream; import java.util.List; import nu.xom.Elements; import nu.xom.ParsingException; import nu.xom.ValidityException; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLCml; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.CMLPeak; import org.xmlcml.cml.element.CMLPeakList; import org.xmlcml.cml.element.CMLPeakStructure; import org.xmlcml.cml.element.CMLSpectrum; import org.xmlcml.euclid.Util; /** * test CMLPeakStructure * * @author pmr * */ public class CMLPeakStructureTest extends PeakSpectrumBase { /** * tests access to peaks and peakStructure. * * * * * @throws IOException * @throws ParsingException * @throws ValidityException * */ @Test public void testGetPeaks1() throws IOException, ValidityException, ParsingException { CMLCml cml = null; InputStream in = Util.getInputStreamFromResource(SIMPLE_RESOURCE +CMLConstants.U_S + peakStructureFile1); cml = (CMLCml) new CMLBuilder().build(in).getRootElement(); in.close(); // cml = (CMLCml) new CMLBuilder().build(new // File(peakStructureFile1Schema)).getRootElement(); Assert.assertNotNull("cml not null: ", cml); Elements elements1 = cml.getChildElements(); Assert.assertEquals("cmlChildren", 2, elements1.size()); Elements elements = cml.getChildCMLElements(CMLSpectrum.TAG); Assert.assertEquals("cmlChild", 1, elements.size()); CMLSpectrum spectrum = (CMLSpectrum) elements.get(0); Assert.assertNotNull("spectrum", spectrum); CMLPeakList peakList = spectrum.getPeakListElements().get(0); Assert.assertNotNull("peakList", peakList); CMLElements peaks = peakList.getPeakElements(); Assert.assertNotNull("peaks", peaks); Assert.assertEquals("peak count", 3, peaks.size()); // check owner spectrum elements CMLSpectrum spectrum1 = CMLSpectrum.getSpectrum(peaks.get(0)); Assert.assertNotNull("spectrum", spectrum1); spectrum1 = CMLSpectrum.getSpectrum(peakList); Assert.assertNotNull("spectrum", spectrum1); CMLMolecule molecule = spectrum.getSiblingMolecule(); Assert.assertNotNull("molecule", molecule); Assert.assertEquals("molecule", "m1", molecule.getId()); } /** * test * * @throws IOException * @throws ParsingException * @throws ValidityException */ @Test public void testGetPeaks2() throws IOException, ValidityException, ParsingException { CMLCml cml = null; InputStream in = Util.getInputStreamFromResource(SIMPLE_RESOURCE +CMLConstants.U_S + peakStructureFile2); cml = (CMLCml) new CMLBuilder().build(in).getRootElement(); Assert.assertNotNull("cml not null: ", cml); Elements elements1 = cml.getChildElements(); Assert.assertEquals("cmlChildren", 2, elements1.size()); Elements elements = cml.getChildCMLElements(CMLSpectrum.TAG); Assert.assertEquals("cmlChild", 1, elements.size()); CMLSpectrum spectrum = (CMLSpectrum) elements.get(0); Assert.assertNotNull("spectrum", spectrum); CMLPeakList peakList = spectrum.getPeakListElements().get(0); Assert.assertNotNull("peakList", peakList); CMLElements peaks = peakList.getPeakElements(); Assert.assertNotNull("peaks", peaks); Assert.assertEquals("peak count", 1, peaks.size()); CMLElements peakStructureAs = peaks.get(0) .getPeakStructureElements(); Assert.assertNotNull("peaks", peakStructureAs); Assert.assertEquals("peakStructure count", 2, peakStructureAs.size()); CMLElements peakStructureAB1s = peakStructureAs .get(0).getPeakStructureElements(); Assert.assertNotNull("grandchild peakStructures not null", peakStructureAB1s); Assert.assertEquals("grandchild peakStructures count", 2, peakStructureAB1s.size()); Assert.assertEquals("grandchild peakStructure 1 id", "ps11", peakStructureAB1s.get(0).getId()); CMLElements peakStructureAB2s = peakStructureAs .get(1).getPeakStructureElements(); Assert.assertNotNull("grandchild peakStructures not null", peakStructureAB2s); Assert.assertEquals("grandchild peakStructures count", 2, peakStructureAB2s.size()); Assert.assertEquals("grandchild peakStructure 1 id", "ps22", peakStructureAB2s.get(1).getId()); // check owner spectrum elements CMLSpectrum spectrum1 = CMLSpectrum.getSpectrum(peaks.get(0)); Assert.assertNotNull("spectrum", spectrum1); spectrum1 = CMLSpectrum.getSpectrum(peakStructureAB1s.get(0)); Assert.assertNotNull("spectrum", spectrum1); spectrum1 = CMLSpectrum.getSpectrum(peakList); Assert.assertNotNull("spectrum", spectrum1); CMLMolecule molecule = spectrum.getSiblingMolecule(); Assert.assertNotNull("molecule", molecule); Assert.assertEquals("molecule", "m1", molecule.getId()); } /** * test * * @throws IOException * @throws ParsingException * @throws ValidityException */ @Test public void testAtomRefs() throws IOException, ValidityException, ParsingException { CMLCml cml = null; CMLSpectrum spectrum = null; CMLMolecule molecule = null; InputStream in = Util.getInputStreamFromResource(SIMPLE_RESOURCE +CMLConstants.U_S + peakStructureFile1); cml = (CMLCml) new CMLBuilder().build(in).getRootElement(); spectrum = (CMLSpectrum) cml.getChildCMLElements(CMLSpectrum.TAG) .get(0); Assert.assertNotNull("spectrum", spectrum); molecule = spectrum.getSiblingMolecule(); Assert.assertNotNull("molecule", molecule); CMLPeakList peakList = spectrum.getPeakListElements().get(0); Assert.assertNotNull("peakList", peakList); CMLElements peaks = peakList.getPeakElements(); /* * -- -- */ CMLPeak peak1 = peaks.get(0); List atoms1 = molecule.getAtomListByIds(peak1.getAtomRefs()); Assert.assertEquals("atoms in peak 1", 1, atoms1.size()); CMLAtom atom1 = atoms1.get(0); Assert.assertEquals("atom peak1", "Ha", atom1.getLabelElements().get(0) .getCMLValue()); CMLElements peakStructures = peak1 .getPeakStructureElements(); Assert.assertEquals("peak structures in peak 1", 1, peakStructures .size()); CMLPeakStructure peakStructure11 = peakStructures.get(0); Assert.assertEquals("peak1 coupling1 type", "coupling", peakStructure11 .getType()); Assert.assertEquals("peak1 coupling1 multiplicity", "nmr:doublet11", peakStructure11.getPeakMultiplicity()); Assert.assertEquals("peak1 coupling1 value", "12", peakStructure11 .getCMLValue()); List atoms11 = molecule.getAtomListByIds(peakStructure11 .getAtomRefs()); Assert.assertEquals("atoms in peak structure 11", 1, atoms11.size()); CMLAtom atomPeak1Coupling1 = atoms11.get(0); Assert.assertEquals("atom peak1 coupling1", "Hb", atomPeak1Coupling1 .getLabelElements().get(0).getCMLValue()); /* * */ CMLPeak peak2 = peaks.get(1); List atoms2 = molecule.getAtomListByIds(peak2.getAtomRefs()); Assert.assertEquals("atoms in peak 2", 1, atoms2.size()); CMLAtom atom2 = atoms2.get(0); Assert.assertEquals("atom peak2", "Hb", atom2.getLabelElements().get(0) .getCMLValue()); CMLElements peakStructures2 = peak2 .getPeakStructureElements(); Assert.assertEquals("peak structures in peak 2", 2, peakStructures2 .size()); CMLPeakStructure peakStructure21 = peakStructures2.get(0); Assert.assertEquals("peak2 coupling1 type", "coupling", peakStructure21 .getType()); Assert.assertEquals("peak2 coupling1 multiplicity", "nmr:doublet11", peakStructure21.getPeakMultiplicity()); Assert.assertEquals("peak2 coupling1 value", "12", peakStructure21 .getCMLValue()); List atoms21 = molecule.getAtomListByIds(peakStructure21 .getAtomRefs()); Assert.assertEquals("atoms in peak structure 21", 1, atoms21.size()); CMLAtom atomPeak2Coupling1 = atoms21.get(0); Assert.assertEquals("atom peak2 coupling1", "Ha", atomPeak2Coupling1 .getLabelElements().get(0).getCMLValue()); CMLPeakStructure peakStructure22 = peakStructures2.get(1); Assert.assertEquals("peak2 coupling2 type", "coupling", peakStructure22 .getType()); Assert.assertEquals("peak2 coupling2 multiplicity", "nmr:triplet121", peakStructure22.getPeakMultiplicity()); Assert.assertEquals("peak2 coupling2 value", "15", peakStructure22 .getCMLValue()); List atoms22 = molecule.getAtomListByIds(peakStructure22 .getAtomRefs()); Assert.assertEquals("atoms in peak structure 22", 2, atoms22.size()); CMLAtom atom1Peak2Coupling2 = atoms22.get(0); Assert.assertEquals("atom1 peak2 coupling2", "Hc1", atom1Peak2Coupling2 .getLabelElements().get(0).getCMLValue()); CMLAtom atom2Peak2Coupling2 = atoms22.get(1); Assert.assertEquals("atom2 peak2 coupling2", "Hc2", atom2Peak2Coupling2 .getLabelElements().get(0).getCMLValue()); /* * */ CMLPeak peak3 = peaks.get(2); List atoms3 = molecule.getAtomListByIds(peak3.getAtomRefs()); Assert.assertEquals("atoms in peak 3", 2, atoms3.size()); CMLAtom atom31 = atoms3.get(0); Assert.assertEquals("atom1 peak3", "Hc1", atom31.getLabelElements() .get(0).getCMLValue()); CMLAtom atom32 = atoms3.get(1); Assert.assertEquals("atom2 peak3", "Hc2", atom32.getLabelElements() .get(0).getCMLValue()); CMLElements peakStructures3 = peak3 .getPeakStructureElements(); Assert.assertEquals("peak structures in peak 3", 1, peakStructures3 .size()); CMLPeakStructure peakStructure31 = peakStructures3.get(0); Assert.assertEquals("peak3 coupling1 type", "coupling", peakStructure31 .getType()); Assert.assertEquals("peak3 coupling1 multiplicity", "nmr:doublet11", peakStructure31.getPeakMultiplicity()); Assert.assertEquals("peak3 coupling1 value", "15", peakStructure31 .getCMLValue()); List atoms31 = molecule.getAtomListByIds(peakStructure31 .getAtomRefs()); Assert.assertEquals("atoms in peak structure 31", 1, atoms31.size()); CMLAtom atomPeak3Coupling1 = atoms31.get(0); Assert.assertEquals("atom peak3 coupling1", "Hb", atomPeak3Coupling1 .getLabelElements().get(0).getCMLValue()); } /** * tests public boolean hasValidNestedPeakStructure() * * @throws IOException * @throws ParsingException * @throws ValidityException */ @Test public void testHasValidNestedPeakStructure() throws IOException, ValidityException, ParsingException { CMLCml cml = null; InputStream in = Util.getInputStreamFromResource(SIMPLE_RESOURCE +CMLConstants.U_S + peakStructureFile2); cml = (CMLCml) new CMLBuilder().build(in).getRootElement(); in.close(); CMLPeak peak1 = CMLSpectrum.getDescendantPeaks(cml).get(0); CMLPeakStructure ps = peak1.getPeakStructureElements().get(0); Assert.assertTrue("has valid nesting ", ps .hasValidNestedPeakStructure()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/lite/CMLPeakTest.java000077500000000000000000000065541477224461000271110ustar00rootroot00000000000000/** * 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.lite; import static org.xmlcml.cml.element.main.AbstractTestBase.SIMPLE_RESOURCE; import java.io.IOException; import java.io.InputStream; import java.util.List; import nu.xom.Elements; import nu.xom.ParsingException; import nu.xom.ValidityException; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.element.CMLCml; import org.xmlcml.cml.element.CMLPeak; import org.xmlcml.cml.element.CMLPeakList; import org.xmlcml.cml.element.CMLSpectrum; import org.xmlcml.euclid.Util; /** * test CMLPeak * * @author pmr * */ public class CMLPeakTest extends PeakSpectrumBase { /** * get peaks. * * @throws IOException * @throws ParsingException * @throws ValidityException */ @Test public void testGetPeaks() throws IOException, ValidityException, ParsingException { CMLCml cml = null; InputStream in = Util.getInputStreamFromResource(SIMPLE_RESOURCE +CMLConstants.U_S + testfile2); cml = (CMLCml) new CMLBuilder().build(in).getRootElement(); in.close(); Assert.assertNotNull("cml should not be null " + testfile2, cml); Elements elements1 = cml.getChildElements(); Assert.assertEquals("cmlChildren", 2, elements1.size()); Elements elements = cml.getChildCMLElements(CMLSpectrum.TAG); Assert.assertEquals("cmlChild", 1, elements.size()); CMLSpectrum spectrum = (CMLSpectrum) elements.get(0); Assert.assertNotNull("spectrum", spectrum); CMLPeakList peakList = spectrum.getPeakListElements().get(0); Assert.assertNotNull("peakList", peakList); CMLElements peaks = peakList.getPeakElements(); Assert.assertNotNull("peaks", peaks); Assert.assertEquals("peak count", 1, peaks.size()); // check owner spectrum elements CMLSpectrum spectrum1 = CMLSpectrum.getSpectrum(peaks.get(0)); Assert.assertNotNull("spectrum", spectrum1); spectrum1 = CMLSpectrum.getSpectrum(peakList); Assert.assertNotNull("spectrum", spectrum1); } /** * tests * * getDescendantPeaks(CMLElement element) * * @throws IOException * @throws ParsingException * @throws ValidityException */ @Test public void testGetDescendantPeaks() throws IOException, ValidityException, ParsingException { CMLCml cml = null; InputStream in = Util.getInputStreamFromResource(SIMPLE_RESOURCE +CMLConstants.U_S + testfile2); cml = (CMLCml) new CMLBuilder().build(in).getRootElement(); in.close(); List peaks = CMLSpectrum.getDescendantPeaks(cml); Assert.assertNotNull("peaks ", peaks); Assert.assertEquals("peak count ", 4, peaks.size()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/lite/CMLPropertyTest.java000077500000000000000000000214461477224461000300520ustar00rootroot00000000000000/** * 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.lite; import static org.xmlcml.cml.base.CMLConstants.XSD_DOUBLE; import static org.xmlcml.cml.base.CMLConstants.XSD_STRING; import static org.xmlcml.euclid.EuclidConstants.EPS; import java.util.List; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.base.CMLConstants.Units; import org.xmlcml.cml.element.CMLCml; import org.xmlcml.cml.element.CMLProperty; import org.xmlcml.cml.element.CMLPropertyList; import org.xmlcml.cml.interfacex.HasDataType; /** * tests property * * @author pm286 * */ public class CMLPropertyTest { CMLProperty prop1; /** * @exception Exception */ @Before public synchronized void setUp() throws Exception { String prop1S = "" + " 12.3" + ""; prop1 = (CMLProperty)CMLXOMTestUtils.parseValidString(prop1S); } /** dewisott */ @Test public final void testGetPropertyList() { String cmlS = "" + "" + " 12.3" + "" + "" + " 45.6" + "" + "" + " 49.6" + "" + ""; CMLCml cml = (CMLCml)CMLXOMTestUtils.parseValidString(cmlS); CMLPropertyList propertyList = CMLProperty.getPropertyList(cml, "foo:bar"); Assert.assertEquals("propertyList", 1, propertyList .getPropertyElements().size()); } /** dewisott */ @Test public final void testGetPropertyCMLElementString() { String cmlS = "" + "" + " 12.3" + "" + "" + " 45.6" + "" + "" + " 49.6" + "" + ""; CMLCml cml = (CMLCml)CMLXOMTestUtils.parseValidString(cmlS); CMLProperty property = CMLProperty.getProperty(cml, "foo:bar"); Assert.assertEquals("property", 12.3, property.getDouble(), EPS); property = CMLProperty.getProperty(cml, "foo:plugh"); Assert.assertNull("property", property); } /** dewisott */ @Test public final void testCanonicalize() { CMLProperty prop2 = new CMLProperty(prop1); prop2.canonicalize(); } /** dewisott */ @Test public final void testGetDouble() { double val = prop1.getDouble(); Assert.assertEquals("double", 12.3, val, EPS); } /** dewisott */ @Test public final void testGetString() { String cmlS = "" + "" + " 12.3" + "" + "" + " penguin" + "" + ""; CMLCml cml = (CMLCml)CMLXOMTestUtils.parseValidString(cmlS); CMLProperty property = CMLProperty.getProperty(cml, "foo:bar"); String val = property.getString(); Assert.assertNull("string", val); property = CMLProperty.getProperty(cml, "foo:plugh"); val = property.getString(); Assert.assertEquals("string", "penguin", val); } /** dewisott */ @Test public final void testGetInt() { String cmlS = "" + "" + " 12.3" + "" + "" + " 12" + "" + ""; CMLCml cml = (CMLCml)CMLXOMTestUtils.parseValidString(cmlS); CMLProperty property = CMLProperty.getProperty(cml, "foo:bar"); int val = property.getInt(); Assert.assertEquals("int", Integer.MIN_VALUE, val); property = CMLProperty.getProperty(cml, "foo:plugh"); val = property.getInt(); Assert.assertEquals("int", 12, val); } /** dewisott */ @Test public final void testGetStringValues() { String cmlS = "" + "" + " penguin bear wombat" + "" + "" + " penguin bear wombat" + "" + ""; CMLCml cml = (CMLCml)CMLXOMTestUtils.parseValidString(cmlS); CMLProperty property = CMLProperty.getProperty(cml, "foo:plugh"); List val = property.getStringValues(); Assert.assertNotNull("strings", val); Assert.assertEquals("strings", 3, val.size()); Assert.assertEquals("strings", "bear", val.get(1)); property = CMLProperty.getProperty(cml, "foo:bar"); Assert.assertNotNull("property not null", property); val = property.getStringValues(); Assert.assertNull("strings", val); } /** dewisott */ @Test public final void testGetInts() { String cmlS = "" + "" + " 1 2 3" + "" + ""; CMLCml cml = (CMLCml)CMLXOMTestUtils.parseValidString(cmlS); CMLProperty property = CMLProperty.getProperty(cml, "foo:plugh"); int[] val = property.getInts(); Assert.assertNotNull("ints", val); Assert.assertEquals("ints", 3, val.length); Assert.assertEquals("ints", 2, val[1]); } /** dewisott */ @Test public final void testGetDoubles() { String cmlS = "" + "" + " 1.1 2.1 3.1" + "" + ""; CMLCml cml = (CMLCml)CMLXOMTestUtils.parseValidString(cmlS); CMLProperty property = CMLProperty.getProperty(cml, "foo:plugh"); double[] val = property.getDoubles(); Assert.assertNotNull("doubles", val); Assert.assertEquals("doubles", 3, val.length); Assert.assertEquals("doubles", 2.1, val[1], 0.0001); } /** dewisott */ @Test public final void testGetChild() { String cmlS = "" + "" + " 1.1 2.1 3.1" + "" + "" + " " + "" + "" + ""; CMLCml cml = (CMLCml)CMLXOMTestUtils.parseValidString(cmlS); CMLProperty property = CMLProperty.getProperty(cml, "foo:plugh"); HasDataType child = property.getChild(); Assert.assertNotNull("child", child); property = CMLProperty.getProperty(cml, "foo:bar"); child = property.getChild(); Assert.assertNull("child", child); } /** dewisott */ @Test public final void testGetDataType() { String cmlS = "" + "" + " 1.1 2.1 3.1" + "" + "" + " " + "" + "" + ""; CMLCml cml = (CMLCml)CMLXOMTestUtils.parseValidString(cmlS); CMLProperty property = CMLProperty.getProperty(cml, "foo:plugh"); String dataType = property.getDataType(); Assert.assertEquals("datatype", XSD_DOUBLE, dataType); property = CMLProperty.getProperty(cml, "foo:bar"); dataType = property.getDataType(); Assert.assertEquals("datatype", XSD_STRING, dataType); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/lite/CMLScalarTest.java000077500000000000000000000756101477224461000274350ustar00rootroot00000000000000/** * 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.lite; import static org.xmlcml.cml.base.CMLConstants.SIUNIT_NS; import static org.xmlcml.cml.base.CMLConstants.UNIT_NS; import static org.xmlcml.cml.base.CMLConstants.U_CELSIUS; import static org.xmlcml.cml.base.CMLConstants.U_DEGREE; import static org.xmlcml.cml.base.CMLConstants.U_KCAL; import static org.xmlcml.euclid.EuclidConstants.EPS; import static org.xmlcml.euclid.EuclidConstants.S_EMPTY; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.StringReader; import nu.xom.Node; import nu.xom.ParsingException; import nu.xom.Text; import nu.xom.ValidityException; import org.joda.time.DateTime; import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.xmlcml.cml.attribute.DictRefAttribute; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLUtil; import org.xmlcml.cml.base.CMLConstants.Units; import org.xmlcml.cml.element.CMLCml; import org.xmlcml.cml.element.CMLScalar; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.JodaDate; /** * tests CMLScalar. * * @author pmr * */ public class CMLScalarTest { protected CMLScalar xomScalarD0 = new CMLScalar(2.1); protected CMLScalar xomScalarI0 = new CMLScalar((int) 2); protected CMLScalar xomScalarS0 = new CMLScalar("two"); protected CMLScalar xomScalarD1 = new CMLScalar(2.3); protected CMLScalar xomScalarI1 = new CMLScalar((int) 3); protected CMLScalar xomScalarS1 = new CMLScalar("three"); protected CMLScalar xmlScalar; protected CMLScalar xmlScalarD0; protected CMLScalar xmlScalarI0; protected CMLScalar xmlScalarS0; protected CMLScalar xmlScalarD1; protected CMLScalar xmlScalarI1; protected CMLScalar xmlScalarS1; CMLBuilder builder = new CMLBuilder(); String xmlS = ""; String xmlD0S = "2.1"; String xmlDNaNOK = "NaN"; String xmlI0S = "2"; String xmlS0S = "two"; String xmlD1S = "2.3"; String xmlI1S = "3"; String xmlS1S = "three"; String xmlBad1 = "three"; String xmlBad2 = "2.1"; String unitsS = S_EMPTY + "" + "180" + "100" + "100" + ""; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { xmlScalar = (CMLScalar) builder.build(new StringReader(xmlS)) .getRootElement(); xmlScalarD0 = (CMLScalar) builder.build(new StringReader(xmlD0S)) .getRootElement(); xmlScalarI0 = (CMLScalar) builder.build(new StringReader(xmlI0S)) .getRootElement(); xmlScalarS0 = (CMLScalar) builder.build(new StringReader(xmlS0S)) .getRootElement(); xmlScalarD1 = (CMLScalar) builder.build(new StringReader(xmlD1S)) .getRootElement(); xmlScalarI1 = (CMLScalar) builder.build(new StringReader(xmlI1S)) .getRootElement(); xmlScalarS1 = (CMLScalar) builder.build(new StringReader(xmlS1S)) .getRootElement(); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar build' */ @Test public void testParse() { try { builder.build(new StringReader(xmlBad1)); Assert.fail("should throw parse exception"); } catch (ValidityException e) { Assert.fail("should be valid"); } catch (ParsingException e) { Assert.assertTrue(true); } catch (IOException e) { Assert.fail("should not throw IO"); } catch (RuntimeException e) { // this catches the bad values } try { builder.build(new StringReader(xmlBad2)); Assert.fail("should throw parse exception"); } catch (ValidityException e) { Assert.fail("should be valid"); } catch (ParsingException e) { Assert.assertEquals("should fail to parse", "bad integer content: 2.1", e.getMessage()); } catch (IOException e) { Assert.fail("should not throw IO"); } catch (RuntimeException e) { // this catches the bad values } } @Test public void testNaNParse() throws ValidityException, ParsingException, IOException { CMLScalar cs = (CMLScalar) builder.build(new StringReader(xmlDNaNOK)) .getRootElement(); Assert.assertEquals(Double.NaN, cs.getDouble(), 0.0001); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.getDataType()' */ @Test public void testGetDataType() { Assert.assertEquals("data type", CMLElement.XSD_STRING, xomScalarS0 .getDataType()); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, xomScalarD0 .getDataType()); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, xomScalarI0 .getDataType()); Assert.assertEquals("data type", CMLElement.XSD_STRING, xmlScalarS0 .getDataType()); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, xmlScalarD0 .getDataType()); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, xmlScalarI0 .getDataType()); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.setDataType(String)' */ @Test public void testSetDataType() { try { xomScalarS0.setDataType(CMLElement.XSD_DOUBLE); Assert.fail("should throw CMLRuntime"); } catch (RuntimeException e) { Assert.assertEquals("cannot set dataType", "Must not reset dataType; use SetValue(...)", e .getMessage()); } } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.CMLScalar()' */ @Test public void testCMLScalar() { CMLScalar copy = new CMLScalar(); Assert.assertNotNull("new CMLScalar", copy); Assert.assertEquals("data type", CMLElement.XSD_STRING, copy .getDataType()); Assert.assertEquals("value", S_EMPTY, copy.getString()); Assert.assertEquals("value", S_EMPTY, copy.getXMLContent()); int nchild = copy.getChildCount(); Assert.assertEquals("should be no text child", 0, nchild); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.CMLScalar(CMLScalar)' */ @Test public void testCMLScalarCMLScalar() { CMLScalar copy = new CMLScalar(xomScalarD0); Assert.assertNotNull("new CMLScalar", copy); Assert.assertEquals("data type", copy.getDataType(), xomScalarD0 .getDataType()); Assert.assertEquals("value", copy.getDouble(), xomScalarD0.getDouble(), EPS); int nchild = copy.getChildCount(); Assert.assertEquals("should be a text child", 1, nchild); Node child = copy.getChild(0); Assert.assertTrue("text node", child instanceof Text); Assert.assertEquals("text value", "2.1", child.getValue()); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.CMLScalar(String)' */ @Test public void testCMLScalarString() { CMLScalar s = new CMLScalar("foo"); Assert.assertNotNull("new CMLScalar", s); Assert .assertEquals("data type", CMLElement.XSD_STRING, s .getDataType()); Assert.assertEquals("value", "foo", s.getString()); int nchild = s.getChildCount(); Assert.assertEquals("should be a text child", 1, nchild); Node child = s.getChild(0); Assert.assertTrue("text node", child instanceof Text); Assert.assertEquals("text value", "foo", child.getValue()); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.CMLScalar(double)' */ @Test public void testCMLScalarDouble() { CMLScalar s = new CMLScalar(3.4); Assert.assertNotNull("new CMLScalar", s); Assert .assertEquals("data type", CMLElement.XSD_DOUBLE, s .getDataType()); Assert.assertEquals("value", 3.4, s.getDouble(), EPS); int nchild = s.getChildCount(); Assert.assertEquals("should be a text child", 1, nchild); Node child = s.getChild(0); Assert.assertTrue("text node", child instanceof Text); Assert.assertEquals("text value", "3.4", child.getValue()); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.CMLScalar(int)' */ @Test public void testCMLScalarInt() { CMLScalar s = new CMLScalar(98); Assert.assertNotNull("new CMLScalar", s); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s .getDataType()); Assert.assertEquals("value", 98, s.getInt()); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.CMLScalar(Date)' */ @Test public void testCMLScalarDate() throws Exception { DateTime today = new DateTime(); DateTime noMillisToday = today.minusMillis(today.getMillisOfSecond()); CMLScalar s = new CMLScalar(today); Assert.assertNotNull("new CMLScalar", s); Assert.assertEquals("data type", CMLElement.XSD_DATE, s.getDataType()); Assert.assertEquals("value", noMillisToday, s.getDate()); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.CMLScalar(Date)' */ @Test public void testCMLScalarDate1() throws Exception { DateTime date = new DateTime(2010, 10, 26, 17, 56, 23, 123); DateTime noMillisToday = date.minusMillis(date.getMillisOfSecond()); CMLScalar s = new CMLScalar(date); Assert.assertNotNull("new CMLScalar", s); Assert.assertEquals("data type", CMLElement.XSD_DATE, s.getDataType()); Assert.assertEquals("value", JodaDate.formatDate(noMillisToday), JodaDate.formatDate(s.getDate())); Assert.assertEquals("value", noMillisToday, s.getDate()); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.getString()' */ @Test public void testGetString() { CMLScalar s = new CMLScalar("foo"); Assert.assertNotNull("new CMLScalar", s); Assert .assertEquals("data type", CMLElement.XSD_STRING, s .getDataType()); Assert.assertEquals("value", "foo", s.getString()); CMLScalar d = new CMLScalar(2.1); Assert .assertEquals("data type", CMLElement.XSD_DOUBLE, d .getDataType()); Assert.assertNull("value", d.getString()); Assert.assertEquals("value", 2.1, d.getDouble(), EPS); Assert.assertNull("double", xmlScalarD0.getString()); Assert.assertNull("integer", xmlScalarI0.getString()); Assert.assertEquals("string", "two", xmlScalarS0.getString()); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.getDouble()' */ @Test public void testGetDouble() { CMLScalar d = new CMLScalar(2.1); Assert .assertEquals("data type", CMLElement.XSD_DOUBLE, d .getDataType()); Assert.assertEquals("value", 2.1, d.getDouble(), EPS); CMLScalar s = new CMLScalar("foo"); Assert.assertNotNull("new CMLScalar", s); Assert .assertEquals("data type", CMLElement.XSD_STRING, s .getDataType()); Assert.assertTrue("value", Double.isNaN(s.getDouble())); Assert.assertEquals("integer", Double.NaN, xmlScalarI0.getDouble(), 0.0001); Assert.assertEquals("string", Double.NaN, xmlScalarS0.getDouble(), 0.0001); Assert.assertEquals("double", 2.1, xmlScalarD0.getDouble(), 0.0001); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.getInt()' */ @Test public void testGetInt() { CMLScalar i = new CMLScalar((int) 2); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, i .getDataType()); Assert.assertEquals("value", 2, i.getInt()); CMLScalar s = new CMLScalar("foo"); Assert.assertNotNull("new CMLScalar", s); Assert .assertEquals("data type", CMLElement.XSD_STRING, s .getDataType()); try { s.getInt(); Assert.fail("should throw CMLRuntime"); } catch (RuntimeException e) { Assert.assertEquals("ok", "ok"); } try { xmlScalarD0.getInt(); Assert.fail("should throw runtime"); } catch (RuntimeException e) { Assert.assertEquals("not integer", "wrong dataType for int xsd:double", e.getMessage()); } try { xmlScalarS0.getInt(); Assert.fail("should throw runtime"); } catch (RuntimeException e) { Assert.assertEquals("not integer", "wrong dataType for int xsd:string", e.getMessage()); } Assert.assertEquals("integer", 2, xmlScalarI0.getInt()); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.setValue(String)' */ @Test public void testSetValueString() { CMLScalar s = new CMLScalar("foo"); Assert.assertNotNull("new CMLScalar", s); Assert .assertEquals("data type", CMLElement.XSD_STRING, s .getDataType()); Assert.assertEquals("value", "foo", s.getString()); int nchild = s.getChildCount(); Assert.assertEquals("should be a text child", 1, nchild); Node child = s.getChild(0); Assert.assertTrue("text node", child instanceof Text); Assert.assertEquals("text value", "foo", child.getValue()); s.setValue("bar"); Assert .assertEquals("data type", CMLElement.XSD_STRING, s .getDataType()); Assert.assertEquals("value", "bar", s.getString()); nchild = s.getChildCount(); Assert.assertEquals("should be a text child", 1, nchild); child = s.getChild(0); Assert.assertTrue("text node", child instanceof Text); Assert.assertEquals("text value", "bar", child.getValue()); s.setValue(1.2); Assert .assertEquals("data type", CMLElement.XSD_DOUBLE, s .getDataType()); Assert.assertEquals("value", 1.2, s.getDouble(), EPS); Assert.assertNull("value", s.getString()); nchild = s.getChildCount(); Assert.assertEquals("should be a text child", 1, nchild); child = s.getChild(0); Assert.assertTrue("text node", child instanceof Text); Assert.assertEquals("text value", "1.2", child.getValue()); s.setValue("plugh"); Assert .assertEquals("data type", CMLElement.XSD_STRING, s .getDataType()); Assert.assertEquals("value", "plugh", s.getString()); nchild = s.getChildCount(); Assert.assertEquals("should be a text child", 1, nchild); child = s.getChild(0); Assert.assertTrue("text node", child instanceof Text); Assert.assertEquals("text value", "plugh", child.getValue()); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.setValue(double)' */ @Test public void testSetValueDouble() { CMLScalar s = new CMLScalar(2.3); Assert.assertNotNull("new CMLScalar", s); Assert .assertEquals("data type", CMLElement.XSD_DOUBLE, s .getDataType()); Assert.assertNull("value", s.getString()); Assert.assertEquals("value", 2.3, s.getDouble(), EPS); s.setValue(4.5); Assert .assertEquals("data type", CMLElement.XSD_DOUBLE, s .getDataType()); Assert.assertEquals("value", 4.5, s.getDouble(), EPS); s.setValue(1.2); s.setValue("plugh"); Assert .assertEquals("data type", CMLElement.XSD_STRING, s .getDataType()); Assert.assertEquals("value", "plugh", s.getString()); Assert.assertTrue("value", Double.isNaN(s.getDouble())); s.setValue(6.2); Assert .assertEquals("data type", CMLElement.XSD_DOUBLE, s .getDataType()); Assert.assertEquals("value", 6.2, s.getDouble(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.setValue(int)' */ @Test public void testSetValueInt() { CMLScalar s = new CMLScalar((int) 2); Assert.assertNotNull("new CMLScalar", s); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s .getDataType()); Assert.assertNull("value", s.getString()); Assert.assertEquals("value", 2, s.getInt()); s.setValue((int) 4); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s .getDataType()); Assert.assertEquals("value", 4, s.getInt()); s.setValue("plugh"); Assert .assertEquals("data type", CMLElement.XSD_STRING, s .getDataType()); Assert.assertEquals("value", "plugh", s.getString()); try { s.getInt(); Assert.fail("should throw CMLRuntime"); } catch (RuntimeException e) { ; } s.setValue(6); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s .getDataType()); Assert.assertEquals("value", 6, s.getInt()); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.subtract(CMLScalar)' */ @Test public void testSubtract() { CMLScalar s1 = new CMLScalar((int) 7); Assert.assertNotNull("new CMLScalar", s1); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s1 .getDataType()); Assert.assertEquals("value", 7, s1.getInt()); CMLScalar s2 = new CMLScalar((int) 4); Assert.assertNotNull("new CMLScalar", s2); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s2 .getDataType()); Assert.assertEquals("value", 4, s2.getInt()); CMLScalar s3 = s1.subtract(s2); Assert.assertNotNull("new CMLScalar", s3); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s3 .getDataType()); Assert.assertEquals("value", 3, s3.getInt()); Assert.assertNotNull("new CMLScalar", s1); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s1 .getDataType()); Assert.assertEquals("value", 7, s1.getInt()); Assert.assertNotNull("new CMLScalar", s2); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s2 .getDataType()); Assert.assertEquals("value", 4, s2.getInt()); CMLScalar s4 = new CMLScalar(3.2); Assert.assertNotNull("new CMLScalar", s4); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s4 .getDataType()); Assert.assertEquals("value", 3.2, s4.getDouble(), 0.0001); try { s3 = s1.subtract(s4); Assert.fail("should throw CMLexception "); } catch (Exception e) { Assert .assertEquals( "throws CMLException ", "Unsuitable dataTypes for numeric operations / xsd:integer/xsd:double", e.getMessage()); } CMLScalar s11 = new CMLScalar(7.5); Assert.assertNotNull("new CMLScalar", s11); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s11 .getDataType()); Assert.assertEquals("value", 7.5, s11.getDouble(), EPS); CMLScalar s12 = new CMLScalar(4.4); Assert.assertNotNull("new CMLScalar", s12); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s12 .getDataType()); Assert.assertEquals("value", 4.4, s12.getDouble(), 0.0001); CMLScalar s13 = s11.subtract(s12); Assert.assertNotNull("old CMLScalar", s11); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s11 .getDataType()); Assert.assertEquals("value", 7.5, s11.getDouble(), EPS); Assert.assertNotNull("new CMLScalar", s12); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s12 .getDataType()); Assert.assertEquals("value", 4.4, s12.getDouble(), EPS); Assert.assertNotNull("new CMLScalar", s13); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s13 .getDataType()); Assert.assertEquals("value", 3.1, s13.getDouble(), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLScalar.subtractEquals(CMLScalar)' */ @Test public void testSubtractEquals() { CMLScalar s1 = new CMLScalar((int) 7); Assert.assertNotNull("new CMLScalar", s1); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s1 .getDataType()); Assert.assertEquals("value", 7, s1.getInt()); CMLScalar s2 = new CMLScalar((int) 4); Assert.assertNotNull("new CMLScalar", s2); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s2 .getDataType()); Assert.assertEquals("value", 4, s2.getInt()); s1.subtractEquals(s2); Assert.assertNotNull("old CMLScalar", s1); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s1 .getDataType()); Assert.assertEquals("value", 3, s1.getInt()); Assert.assertNotNull("new CMLScalar", s2); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s2 .getDataType()); Assert.assertEquals("value", 4, s2.getInt()); CMLScalar s4 = new CMLScalar(3.2); Assert.assertNotNull("new CMLScalar", s4); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s4 .getDataType()); Assert.assertEquals("value", 3.2, s4.getDouble(), 0.0001); try { s1.subtract(s4); Assert.fail("should throw CMLexception "); } catch (Exception e) { Assert .assertEquals( "throws CMLException ", "Unsuitable dataTypes for numeric operations / xsd:integer/xsd:double", e.getMessage()); } CMLScalar s11 = new CMLScalar(7.5); Assert.assertNotNull("new CMLScalar", s11); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s11 .getDataType()); Assert.assertEquals("value", 7.5, s11.getDouble(), EPS); CMLScalar s12 = new CMLScalar(4.4); Assert.assertNotNull("new CMLScalar", s12); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s12 .getDataType()); Assert.assertEquals("value", 4.4, s12.getDouble(), 0.0001); s11.subtractEquals(s12); Assert.assertNotNull("old CMLScalar", s11); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s11 .getDataType()); Assert.assertEquals("value", 3.1, s11.getDouble(), EPS); Assert.assertNotNull("new CMLScalar", s12); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s12 .getDataType()); Assert.assertEquals("value", 4.4, s12.getDouble(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.plus(CMLScalar)' */ @Test public void testPlus() { CMLScalar s1 = new CMLScalar((int) 7); Assert.assertNotNull("new CMLScalar", s1); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s1 .getDataType()); Assert.assertEquals("value", 7, s1.getInt()); CMLScalar s2 = new CMLScalar((int) 4); Assert.assertNotNull("new CMLScalar", s2); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s2 .getDataType()); Assert.assertEquals("value", 4, s2.getInt()); CMLScalar s3 = s1.plus(s2); Assert.assertNotNull("new CMLScalar", s3); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s3 .getDataType()); Assert.assertEquals("value", 11, s3.getInt()); Assert.assertNotNull("new CMLScalar", s1); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s1 .getDataType()); Assert.assertEquals("value", 7, s1.getInt()); Assert.assertNotNull("new CMLScalar", s2); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s2 .getDataType()); Assert.assertEquals("value", 4, s2.getInt()); CMLScalar s4 = new CMLScalar(3.2); Assert.assertNotNull("new CMLScalar", s4); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s4 .getDataType()); Assert.assertEquals("value", 3.2, s4.getDouble(), 0.0001); try { s3 = s1.subtract(s4); Assert.fail("should throw CMLexception "); } catch (Exception e) { Assert .assertEquals( "throws CMLException ", "Unsuitable dataTypes for numeric operations / xsd:integer/xsd:double", e.getMessage()); } CMLScalar s11 = new CMLScalar(7.5); Assert.assertNotNull("new CMLScalar", s11); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s11 .getDataType()); Assert.assertEquals("value", 7.5, s11.getDouble(), EPS); CMLScalar s12 = new CMLScalar(4.4); Assert.assertNotNull("new CMLScalar", s12); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s12 .getDataType()); Assert.assertEquals("value", 4.4, s12.getDouble(), 0.0001); CMLScalar s13 = s11.plus(s12); Assert.assertNotNull("old CMLScalar", s11); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s11 .getDataType()); Assert.assertEquals("value", 7.5, s11.getDouble(), EPS); Assert.assertNotNull("new CMLScalar", s12); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s12 .getDataType()); Assert.assertEquals("value", 4.4, s12.getDouble(), EPS); Assert.assertNotNull("new CMLScalar", s13); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s13 .getDataType()); Assert.assertEquals("value", 11.9, s13.getDouble(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.plusEquals(CMLScalar)' */ @Test public void testPlusEquals() { CMLScalar s1 = new CMLScalar((int) 7); Assert.assertNotNull("new CMLScalar", s1); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s1 .getDataType()); Assert.assertEquals("value", 7, s1.getInt()); CMLScalar s2 = new CMLScalar((int) 4); Assert.assertNotNull("new CMLScalar", s2); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s2 .getDataType()); Assert.assertEquals("value", 4, s2.getInt()); s1.plusEquals(s2); Assert.assertNotNull("old CMLScalar", s1); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s1 .getDataType()); Assert.assertEquals("value", 11, s1.getInt()); Assert.assertNotNull("new CMLScalar", s2); Assert.assertEquals("data type", CMLElement.XSD_INTEGER, s2 .getDataType()); Assert.assertEquals("value", 4, s2.getInt()); CMLScalar s4 = new CMLScalar(3.2); Assert.assertNotNull("new CMLScalar", s4); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s4 .getDataType()); Assert.assertEquals("value", 3.2, s4.getDouble(), 0.0001); try { s1.subtract(s4); Assert.fail("should throw CMLexception "); } catch (Exception e) { Assert .assertEquals( "throws CMLException ", "Unsuitable dataTypes for numeric operations / xsd:integer/xsd:double", e.getMessage()); } CMLScalar s11 = new CMLScalar(7.5); Assert.assertNotNull("new CMLScalar", s11); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s11 .getDataType()); Assert.assertEquals("value", 7.5, s11.getDouble(), EPS); CMLScalar s12 = new CMLScalar(4.4); Assert.assertNotNull("new CMLScalar", s12); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s12 .getDataType()); Assert.assertEquals("value", 4.4, s12.getDouble(), 0.0001); s11.plusEquals(s12); Assert.assertNotNull("old CMLScalar", s11); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s11 .getDataType()); Assert.assertEquals("value", 11.9, s11.getDouble(), EPS); Assert.assertNotNull("new CMLScalar", s12); Assert.assertEquals("data type", CMLElement.XSD_DOUBLE, s12 .getDataType()); Assert.assertEquals("value", 4.4, s12.getDouble(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.copy()' */ @Test public void testCopy() { CMLScalar ss = (CMLScalar) xomScalarD0.copy(); Assert.assertEquals("copy", ss.getDouble(), xomScalarD0.getDouble(), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLScalar.getDictRefFromElementOrParent()' */ @Test public void testGetDictRefFromElementOrParent() { CMLCml cml = null; try { cml = (CMLCml) new CMLBuilder().parseString(unitsS); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } CMLScalar scalar = (CMLScalar) cml.getChildCMLElements("scalar").get(0); DictRefAttribute dictRef = scalar.getDictRefFromElementOrParent(); Assert.assertNotNull("dictRef not null", dictRef); Assert.assertEquals("dictRef", "cmlDict:angle", dictRef.getCMLValue()); } // /** // * Test method for // * 'org.xmlcml.cml.element.CMLScalar.getUnit(NamespaceToUnitListMap)' // */ // @Test // public void testGetUnit() { // CMLCml cml = null; // try { // cml = (CMLCml) new CMLBuilder().parseString(unitsS); // } catch (Exception e) { // neverThrow(e); // } // CMLScalar scalar = (CMLScalar) cml.getChildCMLElements("scalar").get(0); // CMLUnit unit = scalar.getUnit(unitsUnitListMap); // Assert.assertNotNull("unit not null", unit); // } /** * Test method for 'org.xmlcml.cml.element.CMLScalar.setUnits(String, * String)' */ @Test public void testSetUnitsStringString() { xmlScalarD0.setUnits("units", "g", UNIT_NS); Assert.assertEquals("set units", Units.GRAM.toString(), xmlScalarD0.getUnits()); Assert.assertEquals("set units", UNIT_NS, xmlScalarD0 .getNamespaceURIForPrefix("units")); } @Test public void testNonNormalizedWhitespace0() { String s = "one two three"; CMLScalar scalar = new CMLScalar(s); Assert.assertEquals("whitespace", "one two three", scalar.getValue()); } @Test public void testNonNormalizedWhitespace00() { String s = "one two three"; CMLScalar scalar = new CMLScalar(s); Assert.assertEquals("whitespace", "one two three", scalar.getValue()); } @Test public void testNonNormalizedWhitespace() { String s = "one\ntwo\nthree"; CMLScalar scalar = new CMLScalar(s); Assert.assertEquals("whitespace", "one\ntwo\nthree", scalar.getValue()); } @Test public void testNonNormalizedWhitespace1() { String s = "one\ntwo\nthree"; CMLScalar scalar = new CMLScalar(s); Assert.assertEquals("whitespace", "one\ntwo\nthree", scalar.toXML()); } @Test public void testNonNormalizedWhitespace2() { String s = "one\ntwo\nthree"; CMLScalar scalar = new CMLScalar(s); CMLScalar scalar1 = new CMLScalar(scalar); Assert.assertEquals("whitespace", "one\ntwo\nthree", scalar1.getValue()); } @Test @Ignore ("the content is correct") public void testNonNormalizedWhitespace3() throws Exception { String s = "one\ntwo\nthree"; CMLScalar scalar = new CMLScalar(s); Assert.assertNotNull(scalar); // this should have correct ws ByteArrayOutputStream baos = new ByteArrayOutputStream(); CMLUtil.debug(scalar, baos, 0); Assert.assertEquals("good whitespace", "\n"+ "one\n"+ "two\n"+ "three\n", baos.toString()); } @Test public void testNonNormalizedWhitespace4() { String s = "one two three"; CMLScalar scalar = new CMLScalar(s); Assert.assertEquals("whitespace", "one two three", scalar .getValue()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/lite/PeakSpectrumBase.java000077500000000000000000000106531477224461000302260ustar00rootroot00000000000000/** * 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.lite; import static org.xmlcml.cml.base.CMLConstants.XML_SUFF; import static org.xmlcml.cml.element.main.AbstractTestBase.SIMPLE_RESOURCE; import java.io.IOException; import java.io.InputStream; import java.net.URL; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.element.CMLCml; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.CMLPeak; import org.xmlcml.cml.element.CMLPeakList; import org.xmlcml.cml.element.CMLPeakStructure; import org.xmlcml.cml.element.CMLSpectrum; import org.xmlcml.euclid.Util; /** * test Peak and Spectrum * * @author pmr * */ public abstract class PeakSpectrumBase { protected String peakStructureFile1 = "peakStructure1" + XML_SUFF; protected String peakStructureFile1NoSchema = "peakStructure1-noSchema" + XML_SUFF; protected String peakStructureFile2 = "peakStructure2" + XML_SUFF; protected String peakStructureFile2Schema = "peakStructure2Schema" + XML_SUFF; protected String testfile = "spectrum"; protected String testfile1 = "spectrum1.xml"; protected String testfile2 = "spectrum2.xml"; protected String testfile3 = "spectrum3.xml"; protected String testfile4 = "spectrum4.xml"; protected String testfile5 = "spectrum5.xml"; protected String testCompoundFile1 = "spectrum_and_structure1.xml"; private URL makeSpectrumInputStreamContainer(int num) throws IOException { return Util.getResource(SIMPLE_RESOURCE +CMLConstants.U_S + "spectrum" + num + XML_SUFF); } protected CMLSpectrum readSpectrum(int num) throws Exception { CMLSpectrum spectrum = null; URL spurl = makeSpectrumInputStreamContainer(num); InputStream in = spurl.openStream(); spectrum = (CMLSpectrum) new CMLBuilder().build(in).getRootElement(); in.close(); return spectrum; } /** test */ @Test public void testDummy1() { ; // else get warning about no tests! } /** * gets the spectrum out of the peakStructure.xml test file * * @return the spectrum */ protected CMLSpectrum getSpectrum() throws Exception { CMLSpectrum spectrum = null; InputStream in = Util.getInputStreamFromResource(SIMPLE_RESOURCE +CMLConstants.U_S + peakStructureFile1); CMLCml cml = (CMLCml) new CMLBuilder().build(in).getRootElement(); spectrum = (CMLSpectrum) cml.getChildCMLElements(CMLSpectrum.TAG) .get(0); return spectrum; } /** * gets peaks from peakStructure.xml example file. * * @return the peaks * @throws Exception */ CMLElements getPeaks() throws Exception { CMLSpectrum spectrum = getSpectrum(); // CMLMolecule molecule = getMolecule(); CMLPeakList peakList = spectrum.getPeakListElements().get(0); CMLElements peaks = peakList.getPeakElements(); return peaks; } /** * gets peak structures from peakStructure.xml example files. * * @param num * only 1 works. gets peaksStructure[1] on Hb. * @return the peakStructures * @throws Exception */ protected CMLElements getPeakStructures(int num) throws Exception { CMLPeak peak = getPeaks().get(num); return peak.getPeakStructureElements(); } /** * gets the molecule out of the peakStructure.xml test file * * @return the spectrum */ protected CMLMolecule getMolecule() throws Exception { CMLMolecule molecule = null; InputStream in = Util.getInputStreamFromResource(SIMPLE_RESOURCE +CMLConstants.U_S + peakStructureFile1); CMLCml cml = (CMLCml) new CMLBuilder().build(in).getRootElement(); in.close(); molecule = (CMLMolecule) cml.getChildCMLElements(CMLMolecule.TAG) .get(0); return molecule; } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/000077500000000000000000000000001477224461000241445ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/AbstractTableBase.java000077500000000000000000000046531477224461000303300ustar00rootroot00000000000000/** * 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.main; import org.xmlcml.cml.base.CMLConstants; /** * test CMLTable. * * @author pmr * */ public class AbstractTableBase { protected final static String tableRowListS = CMLConstants.S_EMPTY + "" + " " + " 1" + " a" + " " + " " + " 2" + " b" + " " + " " + " 3" + " c" + " " + ""; protected final static String tableContentS = CMLConstants.S_EMPTY + "" + "1 a\n" + "2 b\n" + "3 c" + ""; protected final static String tableHeaderS = CMLConstants.S_EMPTY + "" + " " + " " + "" + CMLConstants.S_EMPTY; protected final static String arrayListS = CMLConstants.S_EMPTY + "" + " 1 2 3" + " a b c" + "" + CMLConstants.S_EMPTY; protected final static String COLUMN_TABLE1_XML = "org/xmlcml/cml/element/examples/misc/columnTable1.xml"; protected final static String CONTENT_TABLE1_XML = "org/xmlcml/cml/element/examples/misc/contentTable1.xml"; protected final static String ROW_TABLE1_XML = "org/xmlcml/cml/element/examples/misc/rowTable1.xml"; } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/AbstractTestBase.java000077500000000000000000000071311477224461000302120ustar00rootroot00000000000000/** * 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.main; import java.io.File; import java.io.FileWriter; import java.io.IOException; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.euclid.Util; /** * superclass of all CMLTests. creates CMLBuilder for subclasses. little other * functionality but may be required later for setUp(), etc. * * @author pm286 * */ public final class AbstractTestBase { /** root of tests. */ public final static String TEST_RESOURCE = "org/xmlcml/cml/element"; /** root of examples. */ public final static String EXAMPLES_RESOURCE = TEST_RESOURCE + CMLConstants.S_SLASH + "examples"; /** root of complex examples. */ public final static String COMPLEX_RESOURCE = EXAMPLES_RESOURCE + CMLConstants.S_SLASH + "complex"; /** root of experimental examples. */ public final static String EXPERIMENTAL_RESOURCE = EXAMPLES_RESOURCE + CMLConstants.S_SLASH + "experimental"; /** root of xsd examples. */ public final static String SIMPLE_RESOURCE = EXAMPLES_RESOURCE + CMLConstants.S_SLASH + "xsd"; /** root of dictionary examples. */ public final static String DICT_RESOURCE = EXAMPLES_RESOURCE + CMLConstants.S_SLASH + "dict"; /** root of unit examples. */ public final static String UNIT_RESOURCE = EXAMPLES_RESOURCE + CMLConstants.S_SLASH + "units"; /** root of tool tests. */ public final static String TOOL_TEST_RESOURCE = "org/xmlcml/cml/tools"; /** root of tool test examples. */ public final static String TOOL_EXAMPLES_RESOURCE = TOOL_TEST_RESOURCE + CMLConstants.S_SLASH + "examples"; /** root of tool test molecules. */ public final static String TOOL_MOLECULES_RESOURCE = TOOL_EXAMPLES_RESOURCE + CMLConstants.S_SLASH + "molecules"; /** index in each directory. */ public final static String INDEX = "index.xml"; static String TEST_INDEX = TEST_RESOURCE + CMLConstants.S_SLASH + INDEX; /** final string in dictionary namespaces */ public final static String CML_DICT = "cml"; /** alternative namespace for cml dictionary :-( */ public final static String CML_DICT_DICT = CML_DICT + "Dict"; /** cml comp dictionary */ public final static String CML_COMP_DICT = "cmlComp"; /** * error. * * @param s */ public static void severeError(String s) { Util.println("***** SEVERE ERROR: " + s); } /** * tests writing HTML. * * @param element * @param htmlFile * @throws IOException */ void writeHTML(CMLElement element, String htmlFile) throws IOException { File f = new File(htmlFile); if (!f.exists()) { File dir = f.getParentFile(); if (!dir.exists()) { if (!dir.mkdirs()) { throw new RuntimeException("Problem: cannot create " + dir); } } if (!f.createNewFile()) { throw new RuntimeException("Problem: cannot create " + f); } } FileWriter fw = new FileWriter(f); element.writeHTML(fw); fw.close(); } }cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLAbundanceTest.java000066400000000000000000000312211477224461000300620ustar00rootroot00000000000000/** * Copyright 2023 Sakshi Jain * * 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.main; import static org.junit.Assert.*; import org.junit.Test; import nu.xom.Element; import org.xmlcml.cml.base.CMLAttribute; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.element.CMLAbundance; public class CMLAbundanceTest { @Test public void testCopy() { CMLAbundance cml = new CMLAbundance(); Element cmlCopy = cml.copy(); assertEquals("Class should be CMLAbundance: ", CMLAbundance.class, cmlCopy.getClass()); } @Test public void testMakeElementInContext() { CMLAbundance c = new CMLAbundance(); CMLElement actual = c.makeElementInContext(null); assertEquals("Class should be CMLAbundance: ", CMLAbundance.class, actual.getClass()); } @Test public void testGetTitleAttributeWhenTitleIsSet() { CMLAbundance cml = new CMLAbundance(); cml.setTitle("testTitle"); CMLAttribute expected = new CMLAttribute("title"); expected.setCMLValue("testTitle"); CMLAttribute actual = cml.getTitleAttribute(); assertEquals("LocalName should be 'title': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testTitle': ", expected.getValue(), actual.getValue()); } @Test public void testGetTitleAttributeWhenTitleIsNotSet() { CMLAbundance cml = new CMLAbundance(); CMLAttribute expected = null; CMLAttribute actual = cml.getTitleAttribute(); assertEquals("Title attribute should be null: ", expected, actual); } @Test public void testGetTitleWhenTitleIsSet() { CMLAbundance cml = new CMLAbundance(); cml.setTitle("testTitle"); String expected = "testTitle"; String actual = cml.getTitle(); assertEquals("Title should be 'testTitle': ", expected, actual); } @Test public void testGetTitleWhenTitleIsNotSet() { CMLAbundance cml = new CMLAbundance(); String expected = null; String actual = cml.getTitle(); assertEquals("Title should be null: ", expected, actual); } @Test public void testGetIdAttributeWhenIdIsSet() { CMLAbundance cml = new CMLAbundance(); cml.setId("testId"); CMLAttribute expected = new CMLAttribute("id"); expected.setCMLValue("testId"); CMLAttribute actual = cml.getIdAttribute(); assertEquals("LocalName should be 'id': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testId': ", expected.getValue(), actual.getValue()); } @Test public void testGetIdAttributeWhenIdIsNotSet() { CMLAbundance cml = new CMLAbundance(); CMLAttribute expected = null; CMLAttribute actual = cml.getIdAttribute(); assertEquals("Id attribute should be null: ", expected, actual); } @Test public void testGetIdWhenIdIsSet() { CMLAbundance cml = new CMLAbundance(); cml.setId("testId"); String expected = "testId"; String actual = cml.getId(); assertEquals("Id value should be 'testId': ", expected, actual); } @Test public void testGetIdWhenIdIsNotSet() { CMLAbundance cml = new CMLAbundance(); String expected = null; String actual = cml.getId(); assertEquals("Id value should be null: ", expected, actual); } @Test public void testGetConventionAttributeWhenConventionIsSet() { CMLAbundance cml = new CMLAbundance(); cml.setConvention("testConvention"); CMLAttribute expected = new CMLAttribute("convention"); expected.setCMLValue("testConvention"); CMLAttribute actual = cml.getConventionAttribute(); assertEquals("LocalName should be 'convention': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testConvention': ", expected.getValue(), actual.getValue()); } @Test public void testGetConventionAttributeWhenConventionIsNotSet() { CMLAbundance cml = new CMLAbundance(); CMLAttribute expected = null; CMLAttribute actual = cml.getConventionAttribute(); assertEquals("Convention attribute should be null: ", expected, actual); } @Test public void testGetConventionWhenConventionIsSet() { CMLAbundance cml = new CMLAbundance(); cml.setConvention("testConvention"); String expected = "testConvention"; String actual = cml.getConvention(); assertEquals("Convention value should be 'testConvention': ", expected, actual); } @Test public void testGetConventionWhenConventionIsNotSet() { CMLAbundance cml = new CMLAbundance(); String expected = null; String actual = cml.getConvention(); assertEquals("Convention value should be null: ", expected, actual); } @Test public void testGetDictRefAttributeWhenDictRefIsSet() { CMLAbundance cml = new CMLAbundance(); cml.setDictRef("test:dictRef"); CMLAttribute expected = new CMLAttribute("dictRef"); expected.setCMLValue("test:dictRef"); CMLAttribute actual = cml.getDictRefAttribute(); assertEquals("LocalName should be 'dictRef': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'test:dictRef': ", expected.getValue(), actual.getValue()); } @Test public void testGetDictRefAttributeWhenDictRefIsNotSet() { CMLAbundance cml = new CMLAbundance(); CMLAttribute expected = null; CMLAttribute actual = cml.getDictRefAttribute(); assertEquals("dictRef attribute should be null: ", expected, actual); } @Test public void testGetDictRefWhenDictRefIsSet() { CMLAbundance cml = new CMLAbundance(); cml.setDictRef("test:dictRef"); String expected = "test:dictRef"; String actual = cml.getDictRef(); assertEquals("dictRef value should be 'test:dictRef': ", expected, actual); } @Test public void testGetDictRefWhenDictRefIsNotSet() { CMLAbundance cml = new CMLAbundance(); String expected = null; String actual = cml.getDictRef(); assertEquals("dictRef value should be null: ", expected, actual); } @Test public void testGetMinAttributeWhenMinIsSet() { CMLAbundance cml = new CMLAbundance(); cml.setMin("0"); CMLAttribute expected = new CMLAttribute("min"); expected.setCMLValue("0"); CMLAttribute actual = cml.getMinAttribute(); assertEquals("LocalName should be 'min': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be '0': ", expected.getValue(), actual.getValue()); } @Test public void testGetMinAttributeWhenMinIsNotSet() { CMLAbundance cml = new CMLAbundance(); CMLAttribute expected = null; CMLAttribute actual = cml.getDictRefAttribute(); assertEquals("Min attribute should be null: ", expected, actual); } @Test public void testGetMinWhenMinIsSet() { CMLAbundance cml = new CMLAbundance(); cml.setMin("0"); String expected = "0"; String actual = cml.getMin(); assertEquals("Min value should be '0': ", expected, actual); } @Test public void testGetMinWhenMinIsNotSet() { CMLAbundance cml = new CMLAbundance(); String expected = null; String actual = cml.getMin(); assertEquals("min value value should be null: ", expected, actual); } @Test public void testGetMaxAttributeWhenMaxIsSet() { CMLAbundance cml = new CMLAbundance(); cml.setMax("0"); CMLAttribute expected = new CMLAttribute("max"); expected.setCMLValue("0"); CMLAttribute actual = cml.getMaxAttribute(); assertEquals("LocalName should be 'max': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be '0': ", expected.getValue(), actual.getValue()); } @Test public void testGetMaxAttributeWhenMaxIsNotSet() { CMLAbundance cml = new CMLAbundance(); CMLAttribute expected = null; CMLAttribute actual = cml.getDictRefAttribute(); assertEquals("Max attribute should be null: ", expected, actual); } @Test public void testGetMaxWhenMaxIsSet() { CMLAbundance cml = new CMLAbundance(); cml.setMax("0"); String expected = "0"; String actual = cml.getMax(); assertEquals("Max value should be '0': ", expected, actual); } @Test public void testGetMaxWhenMaxIsNotSet() { CMLAbundance cml = new CMLAbundance(); String expected = null; String actual = cml.getMax(); assertEquals("max value value should be null: ", expected, actual); } @Test public void testGetUnitsAttributeWhenUnitsIsSet() { CMLAbundance cml = new CMLAbundance(); cml.setUnits("units:ang"); CMLAttribute expected = new CMLAttribute("units"); expected.setCMLValue("units:ang"); CMLAttribute actual = cml.getUnitsAttribute(); assertEquals("LocalName should be 'units': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'units:ang': ", expected.getValue(), actual.getValue()); } @Test public void testGetUnitsAttributeWhenUnitsIsNotSet() { CMLAbundance cml = new CMLAbundance(); CMLAttribute expected = null; CMLAttribute actual = cml.getUnitsAttribute(); assertEquals("Units attribute should be null: ", expected, actual); } @Test public void testGetUnitsWhenUnitsIsSet() { CMLAbundance cml = new CMLAbundance(); cml.setUnits("units:ang"); String expected = "units:ang"; String actual = cml.getUnits(); assertEquals("Units value should be 'units:ang': ", expected, actual); } @Test public void testGetUnitsWhenUnitsIsNotSet() { CMLAbundance cml = new CMLAbundance(); String expected = null; String actual = cml.getUnits(); assertEquals("units value value should be null: ", expected, actual); } @Test public void testGetXmlContentWhenXmlContentIsSetAsString() { CMLAbundance cml = new CMLAbundance(); cml.setXMLContent("1"); Double expected = 1d; Double actual = cml.getXMLContent(); assertEquals("XmlContent value should be '1': ", expected, actual); } @Test public void testGetXmlContentWhenXmlContentIsSetAsDouble() { CMLAbundance cml = new CMLAbundance(); cml.setXMLContent(1d); Double expected = 1d; Double actual = cml.getXMLContent(); assertEquals("XmlContent value should be '1': ", expected, actual); } @Test public void testGetXmlContentWhenXmlContentIsNotSet() { CMLAbundance cml = new CMLAbundance(); try { cml.getXMLContent(); } catch (Exception exception) { assertEquals("Should throw null pointer exception: ", java.lang.NullPointerException.class, exception.getClass()); } } @Test public void testSetAttribute() { CMLAbundance cml = new CMLAbundance(); cml.setAttribute("title", "testTitle"); cml.setAttribute("id", "testId"); cml.setAttribute("convention", "testConvention"); cml.setAttribute("dictRef", "test:dictRef"); cml.setAttribute("min", "0"); cml.setAttribute("max", "1"); cml.setAttribute("units", "units:ang"); assertEquals("Title should be 'testTitle': ", "testTitle", cml.getTitle()); assertEquals("Id should be 'testId': ", "testId", cml.getId()); assertEquals("Convention should be 'testConvention': ", "testConvention", cml.getConvention()); assertEquals("DictRef should be 'test:dictRef': ", "test:dictRef", cml.getDictRef()); assertEquals("Min should be '0': ", "0", cml.getMin()); assertEquals("Max should be '1': ", "1", cml.getMax()); assertEquals("Units should be 'units:ang': ", "units:ang", cml.getUnits()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLActionListTest.java000066400000000000000000000522551477224461000302650ustar00rootroot00000000000000/** * Copyright 2023 Sakshi Jain * * 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.main; import nu.xom.Element; import org.junit.Test; import org.xmlcml.cml.base.CMLAttribute; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.element.CMLActionList; import static org.junit.Assert.*; public class CMLActionListTest { @Test public void testCopy() { CMLActionList cml = new CMLActionList(); Element cmlCopy = cml.copy(); assertEquals("Class should be CMLActionList: ", CMLActionList.class, cmlCopy.getClass()); } @Test public void testMakeElementInContext() { CMLActionList cml = new CMLActionList(); CMLElement actual = cml.makeElementInContext(null); assertEquals("Class should be CMLActionList: ", CMLActionList.class, actual.getClass()); } @Test public void testGetTitleAttributeWhenTitleIsSet() { CMLActionList cml = new CMLActionList(); cml.setTitle("testTitle"); CMLAttribute expected = new CMLAttribute("title"); expected.setCMLValue("testTitle"); CMLAttribute actual = cml.getTitleAttribute(); assertEquals("LocalName should be 'title': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testTitle': ", expected.getValue(), actual.getValue()); } @Test public void testGetTitleAttributeWhenTitleIsNotSet() { CMLActionList cml = new CMLActionList(); CMLAttribute expected = null; CMLAttribute actual = cml.getTitleAttribute(); assertEquals("Title attribute should be null: ", expected, actual); } @Test public void testGetTitleWhenTitleIsSet() { CMLActionList cml = new CMLActionList(); cml.setTitle("testTitle"); String expected = "testTitle"; String actual = cml.getTitle(); assertEquals("Title should be 'testTitle': ", expected, actual); } @Test public void testGetTitleWhenTitleIsNotSet() { CMLActionList cml = new CMLActionList(); String expected = null; String actual = cml.getTitle(); assertEquals("Title should be null: ", expected, actual); } @Test public void testGetIdAttributeWhenIdIsSet() { CMLActionList cml = new CMLActionList(); cml.setId("testId"); CMLAttribute expected = new CMLAttribute("id"); expected.setCMLValue("testId"); CMLAttribute actual = cml.getIdAttribute(); assertEquals("LocalName should be 'id': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testId': ", expected.getValue(), actual.getValue()); } @Test public void testGetIdAttributeWhenIdIsNotSet() { CMLActionList cml = new CMLActionList(); CMLAttribute expected = null; CMLAttribute actual = cml.getIdAttribute(); assertEquals("Id attribute should be null: ", expected, actual); } @Test public void testGetIdWhenIdIsSet() { CMLActionList cml = new CMLActionList(); cml.setId("testId"); String expected = "testId"; String actual = cml.getId(); assertEquals("Id value should be 'testId': ", expected, actual); } @Test public void testGetIdWhenIdIsNotSet() { CMLActionList cml = new CMLActionList(); String expected = null; String actual = cml.getId(); assertEquals("Id value should be null: ", expected, actual); } @Test public void testGetConventionAttributeWhenConventionIsSet() { CMLActionList cml = new CMLActionList(); cml.setConvention("testConvention"); CMLAttribute expected = new CMLAttribute("convention"); expected.setCMLValue("testConvention"); CMLAttribute actual = cml.getConventionAttribute(); assertEquals("LocalName should be 'convention': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testConvention': ", expected.getValue(), actual.getValue()); } @Test public void testGetConventionAttributeWhenConventionIsNotSet() { CMLActionList cml = new CMLActionList(); CMLAttribute expected = null; CMLAttribute actual = cml.getConventionAttribute(); assertEquals("Convention attribute should be null: ", expected, actual); } @Test public void testGetConventionWhenConventionIsSet() { CMLActionList cml = new CMLActionList(); cml.setConvention("testConvention"); String expected = "testConvention"; String actual = cml.getConvention(); assertEquals("Convention value should be 'testConvention': ", expected, actual); } @Test public void testGetConventionWhenConventionIsNotSet() { CMLActionList cml = new CMLActionList(); String expected = null; String actual = cml.getConvention(); assertEquals("Convention value should be null: ", expected, actual); } @Test public void testGetDictRefAttributeWhenDictRefIsSet() { CMLActionList cml = new CMLActionList(); cml.setDictRef("test:dictRef"); CMLAttribute expected = new CMLAttribute("dictRef"); expected.setCMLValue("test:dictRef"); CMLAttribute actual = cml.getDictRefAttribute(); assertEquals("LocalName should be 'dictRef': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'test:dictRef': ", expected.getValue(), actual.getValue()); } @Test public void testGetDictRefAttributeWhenDictRefIsNotSet() { CMLActionList cml = new CMLActionList(); CMLAttribute expected = null; CMLAttribute actual = cml.getDictRefAttribute(); assertEquals("dictRef attribute should be null: ", expected, actual); } @Test public void testGetDictRefWhenDictRefIsSet() { CMLActionList cml = new CMLActionList(); cml.setDictRef("test:dictRef"); String expected = "test:dictRef"; String actual = cml.getDictRef(); assertEquals("dictRef value should be 'test:dictRef': ", expected, actual); } @Test public void testGetDictRefWhenDictRefIsNotSet() { CMLActionList cml = new CMLActionList(); String expected = null; String actual = cml.getDictRef(); assertEquals("dictRef value should be null: ", expected, actual); } @Test public void testGetUnitsAttributeWhenUnitsIsSet() { CMLActionList cml = new CMLActionList(); cml.setUnits("units:ang"); CMLAttribute expected = new CMLAttribute("units"); expected.setCMLValue("units:ang"); CMLAttribute actual = cml.getUnitsAttribute(); assertEquals("LocalName should be 'units': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'units:ang': ", expected.getValue(), actual.getValue()); } @Test public void testGetUnitsAttributeWhenUnitsIsNotSet() { CMLActionList cml = new CMLActionList(); CMLAttribute expected = null; CMLAttribute actual = cml.getDictRefAttribute(); assertEquals("Units attribute should be null: ", expected, actual); } @Test public void testGetUnitsWhenUnitsIsSet() { CMLActionList cml = new CMLActionList(); cml.setUnits("units:ang"); String expected = "units:ang"; String actual = cml.getUnits(); assertEquals("Units value should be 'units:ang': ", expected, actual); } @Test public void testGetUnitsWhenUnitsIsNotSet() { CMLActionList cml = new CMLActionList(); String expected = null; String actual = cml.getUnits(); assertEquals("units value value should be null: ", expected, actual); } @Test public void testGetStartAttributeWhenStartIsSet() { CMLActionList cml = new CMLActionList(); cml.setStart("xsd:double"); CMLAttribute expected = new CMLAttribute("start"); expected.setCMLValue("xsd:double"); CMLAttribute actual = cml.getStartAttribute(); assertEquals("LocalName should be 'start': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'xsd:double': ", expected.getValue(), actual.getValue()); } @Test public void testGetStartAttributeWhenStartIsNotSet() { CMLActionList cml = new CMLActionList(); CMLAttribute expected = null; CMLAttribute actual = cml.getStartAttribute(); assertEquals("Start attribute should be null: ", expected, actual); } @Test public void testGetStartWhenStartIsSet() { CMLActionList cml = new CMLActionList(); cml.setStart("xsd:double"); String expected = "xsd:double"; String actual = cml.getStart(); assertEquals("Start value should be 'xsd:double': ", expected, actual); } @Test public void testGetStartWhenStartIsNotSet() { CMLActionList cml = new CMLActionList(); String expected = null; String actual = cml.getStart(); assertEquals("Start value value should be null: ", expected, actual); } @Test public void testGetStartConditionAttributeWhenStartConditionIsSet() { CMLActionList cml = new CMLActionList(); cml.setStartCondition("test"); CMLAttribute expected = new CMLAttribute("startCondition"); expected.setCMLValue("test"); CMLAttribute actual = cml.getStartConditionAttribute(); assertEquals("LocalName should be 'startCondition': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'test': ", expected.getValue(), actual.getValue()); } @Test public void testGetStartConditionAttributeWhenStartConditionIsNotSet() { CMLActionList cml = new CMLActionList(); CMLAttribute expected = null; CMLAttribute actual = cml.getStartConditionAttribute(); assertEquals("Start condition attribute should be null: ", expected, actual); } @Test public void testGetStartConditionWhenStartConditionIsSet() { CMLActionList cml = new CMLActionList(); cml.setStartCondition("test"); String expected = "test"; String actual = cml.getStartCondition(); assertEquals("Start condition value should be 'test': ", expected, actual); } @Test public void testGetStartConditionWhenStartConditionIsNotSet() { CMLActionList cml = new CMLActionList(); String expected = null; String actual = cml.getStartCondition(); assertEquals("Start condition value should be null: ", expected, actual); } @Test public void testGetEndAttributeWhenEndIsSet() { CMLActionList cml = new CMLActionList(); cml.setEnd("xsd:double"); CMLAttribute expected = new CMLAttribute("end"); expected.setCMLValue("xsd:double"); CMLAttribute actual = cml.getEndAttribute(); assertEquals("LocalName should be 'end': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'xsd:double': ", expected.getValue(), actual.getValue()); } @Test public void testGetEndAttributeWhenEndIsNotSet() { CMLActionList cml = new CMLActionList(); CMLAttribute expected = null; CMLAttribute actual = cml.getEndAttribute(); assertEquals("End attribute should be null: ", expected, actual); } @Test public void testGetEndWhenEndIsSet() { CMLActionList cml = new CMLActionList(); cml.setEnd("xsd:double"); String expected = "xsd:double"; String actual = cml.getEnd(); assertEquals("End value should be 'xsd:double': ", expected, actual); } @Test public void testGetEndWhenEndIsNotSet() { CMLActionList cml = new CMLActionList(); String expected = null; String actual = cml.getEnd(); assertEquals("End value value should be null: ", expected, actual); } @Test public void testGetEndConditionAttributeWhenEndConditionIsSet() { CMLActionList cml = new CMLActionList(); cml.setEndCondition("test"); CMLAttribute expected = new CMLAttribute("endCondition"); expected.setCMLValue("test"); CMLAttribute actual = cml.getEndConditionAttribute(); assertEquals("LocalName should be 'endCondition': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'test': ", expected.getValue(), actual.getValue()); } @Test public void testGetEndConditionAttributeWhenEndConditionIsNotSet() { CMLActionList cml = new CMLActionList(); CMLAttribute expected = null; CMLAttribute actual = cml.getEndConditionAttribute(); assertEquals("End condition attribute should be null: ", expected, actual); } @Test public void testGetEndConditionWhenEndConditionIsSet() { CMLActionList cml = new CMLActionList(); cml.setEndCondition("test"); String expected = "test"; String actual = cml.getEndCondition(); assertEquals("End condition value should be 'test': ", expected, actual); } @Test public void testGetEndConditionWhenEndConditionIsNotSet() { CMLActionList cml = new CMLActionList(); String expected = null; String actual = cml.getEndCondition(); assertEquals("End condition value should be null: ", expected, actual); } @Test public void testGetDurationAttributeWhenDurationIsSet() { CMLActionList cml = new CMLActionList(); cml.setDuration("testDuration"); CMLAttribute expected = new CMLAttribute("duration"); expected.setCMLValue("testDuration"); CMLAttribute actual = cml.getDurationAttribute(); assertEquals("LocalName should be 'duration': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testDuration': ", expected.getValue(), actual.getValue()); } @Test public void testGetDurationAttributeWhenDurationIsNotSet() { CMLActionList cml = new CMLActionList(); CMLAttribute expected = null; CMLAttribute actual = cml.getDurationAttribute(); assertEquals("Duration attribute should be null: ", expected, actual); } @Test public void testGetDurationWhenDurationIsSet() { CMLActionList cml = new CMLActionList(); cml.setDuration("testDuration"); String expected = "testDuration"; String actual = cml.getDuration(); assertEquals("Duration value should be 'testDuration': ", expected, actual); } @Test public void testGetDurationWhenDurationIsNotSet() { CMLActionList cml = new CMLActionList(); String expected = null; String actual = cml.getDuration(); assertEquals("Duration value should be null: ", expected, actual); } @Test public void testGetTypeAttributeWhenTypeIsSet() { CMLActionList cml = new CMLActionList(); cml.setType("testType"); CMLAttribute expected = new CMLAttribute("type"); expected.setCMLValue("testType"); CMLAttribute actual = cml.getTypeAttribute(); assertEquals("LocalName should be 'type': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testType': ", expected.getValue(), actual.getValue()); } @Test public void testGetTypeAttributeWhenTypeIsNotSet() { CMLActionList cml = new CMLActionList(); CMLAttribute expected = null; CMLAttribute actual = cml.getTypeAttribute(); assertEquals("Type attribute should be null: ", expected, actual); } @Test public void testGetTypeWhenTypeIsSet() { CMLActionList cml = new CMLActionList(); cml.setType("testType"); String expected = "testType"; String actual = cml.getType(); assertEquals("Type value should be 'testType': ", expected, actual); } @Test public void testGetTypeWhenTypeIsNotSet() { CMLActionList cml = new CMLActionList(); String expected = null; String actual = cml.getType(); assertEquals("Type value should be null: ", expected, actual); } @Test public void testGetOrderAttributeWhenOrderIsSet() { CMLActionList cml = new CMLActionList(); cml.setOrder("parallel"); CMLAttribute expected = new CMLAttribute("order"); expected.setCMLValue("parallel"); CMLAttribute actual = cml.getOrderAttribute(); assertEquals("LocalName should be 'order': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'parallel': ", expected.getValue(), actual.getValue()); } @Test public void testGetOrderAttributeWhenOrderIsNotSet() { CMLActionList cml = new CMLActionList(); CMLAttribute expected = null; CMLAttribute actual = cml.getOrderAttribute(); assertEquals("Order attribute should be null: ", expected, actual); } @Test public void testGetOrderWhenOrderIsSet() { CMLActionList cml = new CMLActionList(); cml.setOrder("parallel"); String expected = "parallel"; String actual = cml.getOrder(); assertEquals("Order value should be 'parallel': ", expected, actual); } @Test public void testGetOrderWhenOrderIsNotSet() { CMLActionList cml = new CMLActionList(); String expected = null; String actual = cml.getOrder(); assertEquals("Order value should be null: ", expected, actual); } @Test public void testGetCountAttributeWhenCountIsSet() { CMLActionList cml = new CMLActionList(); cml.setCount("1.0"); CMLAttribute expected = new CMLAttribute("count"); expected.setCMLValue("1.0"); CMLAttribute actual = cml.getCountAttribute(); assertEquals("LocalName should be 'count': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be '1.0': ", expected.getValue(), actual.getValue()); } @Test public void testGetCountAttributeWhenCountIsNotSet() { CMLActionList cml = new CMLActionList(); CMLAttribute expected = null; CMLAttribute actual = cml.getCountAttribute(); assertEquals("Count attribute should be null: ", expected, actual); } @Test public void testGetCountWhenCountIsSetAsString() { CMLActionList cml = new CMLActionList(); cml.setCount("1.0"); Double expected = 1D; Double actual = cml.getCount(); assertEquals("Count value should be '1': ", expected, actual); } @Test public void testGetCountWhenCountIsSetAsDouble() { CMLActionList cml = new CMLActionList(); cml.setCount(1D); Double expected = 1D; Double actual = cml.getCount(); assertEquals("Count value should be '1': ", expected, actual); } @Test public void testSetAttribute() { CMLActionList cml = new CMLActionList(); cml.setAttribute("title", "testTitle"); cml.setAttribute("id", "testId"); cml.setAttribute("convention", "testConvention"); cml.setAttribute("dictRef", "test:dictRef"); cml.setAttribute("units", "units:ang"); cml.setAttribute("start", "xsd:double"); cml.setAttribute("startCondition", "test"); cml.setAttribute("duration", "testDuration"); cml.setAttribute("end", "xsd:double"); cml.setAttribute("endCondition", "test"); cml.setAttribute("type", "testType"); cml.setAttribute("order", "parallel"); cml.setAttribute("count", "1.0"); assertEquals("Title should be 'testTitle': ", "testTitle", cml.getTitle()); assertEquals("Id should be 'testId': ", "testId", cml.getId()); assertEquals("Convention should be 'testConvention': ", "testConvention", cml.getConvention()); assertEquals("DictRef should be 'test:dictRef': ", "test:dictRef", cml.getDictRef()); assertEquals("Units should be 'units:ang': ", "units:ang", cml.getUnits()); assertEquals("Start value should be 'xsd:double': ", "xsd:double", cml.getStart()); assertEquals("Start condition value should be 'test': ", "test", cml.getStartCondition()); assertEquals("Duration value should be 'testDuration': ", "testDuration", cml.getDuration()); assertEquals("End value should be 'xsd:double': ", "xsd:double", cml.getEnd()); assertEquals("End condition value should be 'test': ", "test", cml.getEndCondition()); assertEquals("Type condition value should be 'testType': ", "testType", cml.getType()); assertEquals("Order condition value should be 'parallel': ", "parallel", cml.getOrder()); assertEquals("Count condition value should be '1.0': ", "1.0", String.valueOf(cml.getCount())); } }cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLActionTest.java000066400000000000000000000541531477224461000274300ustar00rootroot00000000000000/** * Copyright 2023 Sakshi Jain * * 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.main; import nu.xom.Element; import org.junit.Test; import org.xmlcml.cml.base.CMLAttribute; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.element.CMLAction; import static org.junit.Assert.*; public class CMLActionTest { @Test public void testCopy() { CMLAction cml = new CMLAction(); Element cmlCopy = cml.copy(); assertEquals("Class should be CMLAction: ", CMLAction.class, cmlCopy.getClass()); } @Test public void testMakeElementInContext() { CMLAction cml = new CMLAction(); CMLElement actual = cml.makeElementInContext(null); assertEquals("Class should be CMLAction: ", CMLAction.class, actual.getClass()); } @Test public void testGetTitleAttributeWhenTitleIsSet() { CMLAction cml = new CMLAction(); cml.setTitle("testTitle"); CMLAttribute expected = new CMLAttribute("title"); expected.setCMLValue("testTitle"); CMLAttribute actual = cml.getTitleAttribute(); assertEquals("LocalName should be 'title': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testTitle': ", expected.getValue(), actual.getValue()); } @Test public void testGetTitleAttributeWhenTitleIsNotSet() { CMLAction cml = new CMLAction(); CMLAttribute expected = null; CMLAttribute actual = cml.getTitleAttribute(); assertEquals("Title attribute should be null: ", expected, actual); } @Test public void testGetTitleWhenTitleIsSet() { CMLAction cml = new CMLAction(); cml.setTitle("testTitle"); String expected = "testTitle"; String actual = cml.getTitle(); assertEquals("Title should be 'testTitle': ", expected, actual); } @Test public void testGetTitleWhenTitleIsNotSet() { CMLAction cml = new CMLAction(); String expected = null; String actual = cml.getTitle(); assertEquals("Title should be null: ", expected, actual); } @Test public void testGetIdAttributeWhenIdIsSet() { CMLAction cml = new CMLAction(); cml.setId("testId"); CMLAttribute expected = new CMLAttribute("id"); expected.setCMLValue("testId"); CMLAttribute actual = cml.getIdAttribute(); assertEquals("LocalName should be 'id': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testId': ", expected.getValue(), actual.getValue()); } @Test public void testGetIdAttributeWhenIdIsNotSet() { CMLAction cml = new CMLAction(); CMLAttribute expected = null; CMLAttribute actual = cml.getIdAttribute(); assertEquals("Id attribute should be null: ", expected, actual); } @Test public void testGetIdWhenIdIsSet() { CMLAction cml = new CMLAction(); cml.setId("testId"); String expected = "testId"; String actual = cml.getId(); assertEquals("Id value should be 'testId': ", expected, actual); } @Test public void testGetIdWhenIdIsNotSet() { CMLAction cml = new CMLAction(); String expected = null; String actual = cml.getId(); assertEquals("Id value should be null: ", expected, actual); } @Test public void testGetConventionAttributeWhenConventionIsSet() { CMLAction cml = new CMLAction(); cml.setConvention("testConvention"); CMLAttribute expected = new CMLAttribute("convention"); expected.setCMLValue("testConvention"); CMLAttribute actual = cml.getConventionAttribute(); assertEquals("LocalName should be 'convention': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testConvention': ", expected.getValue(), actual.getValue()); } @Test public void testGetConventionAttributeWhenConventionIsNotSet() { CMLAction cml = new CMLAction(); CMLAttribute expected = null; CMLAttribute actual = cml.getConventionAttribute(); assertEquals("Convention attribute should be null: ", expected, actual); } @Test public void testGetConventionWhenConventionIsSet() { CMLAction cml = new CMLAction(); cml.setConvention("testConvention"); String expected = "testConvention"; String actual = cml.getConvention(); assertEquals("Convention value should be 'testConvention': ", expected, actual); } @Test public void testGetConventionWhenConventionIsNotSet() { CMLAction cml = new CMLAction(); String expected = null; String actual = cml.getConvention(); assertEquals("Convention value should be null: ", expected, actual); } @Test public void testGetDictRefAttributeWhenDictRefIsSet() { CMLAction cml = new CMLAction(); cml.setDictRef("test:dictRef"); CMLAttribute expected = new CMLAttribute("dictRef"); expected.setCMLValue("test:dictRef"); CMLAttribute actual = cml.getDictRefAttribute(); assertEquals("LocalName should be 'dictRef': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'test:dictRef': ", expected.getValue(), actual.getValue()); } @Test public void testGetDictRefAttributeWhenDictRefIsNotSet() { CMLAction cml = new CMLAction(); CMLAttribute expected = null; CMLAttribute actual = cml.getDictRefAttribute(); assertEquals("dictRef attribute should be null: ", expected, actual); } @Test public void testGetDictRefWhenDictRefIsSet() { CMLAction cml = new CMLAction(); cml.setDictRef("test:dictRef"); String expected = "test:dictRef"; String actual = cml.getDictRef(); assertEquals("dictRef value should be 'test:dictRef': ", expected, actual); } @Test public void testGetDictRefWhenDictRefIsNotSet() { CMLAction cml = new CMLAction(); String expected = null; String actual = cml.getDictRef(); assertEquals("dictRef value should be null: ", expected, actual); } @Test public void testGetUnitsAttributeWhenUnitsIsSet() { CMLAction cml = new CMLAction(); cml.setUnits("units:ang"); CMLAttribute expected = new CMLAttribute("units"); expected.setCMLValue("units:ang"); CMLAttribute actual = cml.getUnitsAttribute(); assertEquals("LocalName should be 'units': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'units:ang': ", expected.getValue(), actual.getValue()); } @Test public void testGetUnitsAttributeWhenUnitsIsNotSet() { CMLAction cml = new CMLAction(); CMLAttribute expected = null; CMLAttribute actual = cml.getDictRefAttribute(); assertEquals("Units attribute should be null: ", expected, actual); } @Test public void testGetUnitsWhenUnitsIsSet() { CMLAction cml = new CMLAction(); cml.setUnits("units:ang"); String expected = "units:ang"; String actual = cml.getUnits(); assertEquals("Units value should be 'units:ang': ", expected, actual); } @Test public void testGetUnitsWhenUnitsIsNotSet() { CMLAction cml = new CMLAction(); String expected = null; String actual = cml.getUnits(); assertEquals("units value value should be null: ", expected, actual); } @Test public void testGetStartAttributeWhenStartIsSet() { CMLAction cml = new CMLAction(); cml.setStart("xsd:double"); CMLAttribute expected = new CMLAttribute("start"); expected.setCMLValue("xsd:double"); CMLAttribute actual = cml.getStartAttribute(); assertEquals("LocalName should be 'start': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'xsd:double': ", expected.getValue(), actual.getValue()); } @Test public void testGetStartAttributeWhenStartIsNotSet() { CMLAction cml = new CMLAction(); CMLAttribute expected = null; CMLAttribute actual = cml.getStartAttribute(); assertEquals("Start attribute should be null: ", expected, actual); } @Test public void testGetStartWhenStartIsSet() { CMLAction cml = new CMLAction(); cml.setStart("xsd:double"); String expected = "xsd:double"; String actual = cml.getStart(); assertEquals("Start value should be 'xsd:double': ", expected, actual); } @Test public void testGetStartWhenStartIsNotSet() { CMLAction cml = new CMLAction(); String expected = null; String actual = cml.getStart(); assertEquals("Start value value should be null: ", expected, actual); } @Test public void testGetStartConditionAttributeWhenStartConditionIsSet() { CMLAction cml = new CMLAction(); cml.setStartCondition("test"); CMLAttribute expected = new CMLAttribute("startCondition"); expected.setCMLValue("test"); CMLAttribute actual = cml.getStartConditionAttribute(); assertEquals("LocalName should be 'startCondition': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'test': ", expected.getValue(), actual.getValue()); } @Test public void testGetStartConditionAttributeWhenStartConditionIsNotSet() { CMLAction cml = new CMLAction(); CMLAttribute expected = null; CMLAttribute actual = cml.getStartConditionAttribute(); assertEquals("Start condition attribute should be null: ", expected, actual); } @Test public void testGetStartConditionWhenStartConditionIsSet() { CMLAction cml = new CMLAction(); cml.setStartCondition("test"); String expected = "test"; String actual = cml.getStartCondition(); assertEquals("Start condition value should be 'test': ", expected, actual); } @Test public void testGetStartConditionWhenStartConditionIsNotSet() { CMLAction cml = new CMLAction(); String expected = null; String actual = cml.getStartCondition(); assertEquals("Start condition value should be null: ", expected, actual); } @Test public void testGetEndAttributeWhenEndIsSet() { CMLAction cml = new CMLAction(); cml.setEnd("xsd:double"); CMLAttribute expected = new CMLAttribute("end"); expected.setCMLValue("xsd:double"); CMLAttribute actual = cml.getEndAttribute(); assertEquals("LocalName should be 'end': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'xsd:double': ", expected.getValue(), actual.getValue()); } @Test public void testGetEndAttributeWhenEndIsNotSet() { CMLAction cml = new CMLAction(); CMLAttribute expected = null; CMLAttribute actual = cml.getEndAttribute(); assertEquals("End attribute should be null: ", expected, actual); } @Test public void testGetEndWhenEndIsSet() { CMLAction cml = new CMLAction(); cml.setEnd("xsd:double"); String expected = "xsd:double"; String actual = cml.getEnd(); assertEquals("End value should be 'xsd:double': ", expected, actual); } @Test public void testGetEndWhenEndIsNotSet() { CMLAction cml = new CMLAction(); String expected = null; String actual = cml.getEnd(); assertEquals("End value value should be null: ", expected, actual); } @Test public void testGetEndConditionAttributeWhenEndConditionIsSet() { CMLAction cml = new CMLAction(); cml.setEndCondition("test"); CMLAttribute expected = new CMLAttribute("endCondition"); expected.setCMLValue("test"); CMLAttribute actual = cml.getEndConditionAttribute(); assertEquals("LocalName should be 'endCondition': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'test': ", expected.getValue(), actual.getValue()); } @Test public void testGetEndConditionAttributeWhenEndConditionIsNotSet() { CMLAction cml = new CMLAction(); CMLAttribute expected = null; CMLAttribute actual = cml.getEndConditionAttribute(); assertEquals("End condition attribute should be null: ", expected, actual); } @Test public void testGetEndConditionWhenEndConditionIsSet() { CMLAction cml = new CMLAction(); cml.setEndCondition("test"); String expected = "test"; String actual = cml.getEndCondition(); assertEquals("End condition value should be 'test': ", expected, actual); } @Test public void testGetEndConditionWhenEndConditionIsNotSet() { CMLAction cml = new CMLAction(); String expected = null; String actual = cml.getEndCondition(); assertEquals("End condition value should be null: ", expected, actual); } @Test public void testGetDurationAttributeWhenDurationIsSet() { CMLAction cml = new CMLAction(); cml.setDuration("testDuration"); CMLAttribute expected = new CMLAttribute("duration"); expected.setCMLValue("testDuration"); CMLAttribute actual = cml.getDurationAttribute(); assertEquals("LocalName should be 'duration': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testDuration': ", expected.getValue(), actual.getValue()); } @Test public void testGetDurationAttributeWhenDurationIsNotSet() { CMLAction cml = new CMLAction(); CMLAttribute expected = null; CMLAttribute actual = cml.getDurationAttribute(); assertEquals("Duration attribute should be null: ", expected, actual); } @Test public void testGetDurationWhenDurationIsSet() { CMLAction cml = new CMLAction(); cml.setDuration("testDuration"); String expected = "testDuration"; String actual = cml.getDuration(); assertEquals("Duration value should be 'testDuration': ", expected, actual); } @Test public void testGetDurationWhenDurationIsNotSet() { CMLAction cml = new CMLAction(); String expected = null; String actual = cml.getDuration(); assertEquals("Duration value should be null: ", expected, actual); } @Test public void testGetTypeAttributeWhenTypeIsSet() { CMLAction cml = new CMLAction(); cml.setType("testType"); CMLAttribute expected = new CMLAttribute("type"); expected.setCMLValue("testType"); CMLAttribute actual = cml.getTypeAttribute(); assertEquals("LocalName should be 'type': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testType': ", expected.getValue(), actual.getValue()); } @Test public void testGetTypeAttributeWhenTypeIsNotSet() { CMLAction cml = new CMLAction(); CMLAttribute expected = null; CMLAttribute actual = cml.getTypeAttribute(); assertEquals("Type attribute should be null: ", expected, actual); } @Test public void testGetTypeWhenTypeIsSet() { CMLAction cml = new CMLAction(); cml.setType("testType"); String expected = "testType"; String actual = cml.getType(); assertEquals("Type value should be 'testType': ", expected, actual); } @Test public void testGetTypeWhenTypeIsNotSet() { CMLAction cml = new CMLAction(); String expected = null; String actual = cml.getType(); assertEquals("Type value should be null: ", expected, actual); } @Test public void testGetOrderAttributeWhenOrderIsSet() { CMLAction cml = new CMLAction(); cml.setOrder("parallel"); CMLAttribute expected = new CMLAttribute("order"); expected.setCMLValue("parallel"); CMLAttribute actual = cml.getOrderAttribute(); assertEquals("LocalName should be 'order': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'parallel': ", expected.getValue(), actual.getValue()); } @Test public void testGetOrderAttributeWhenOrderIsNotSet() { CMLAction cml = new CMLAction(); CMLAttribute expected = null; CMLAttribute actual = cml.getOrderAttribute(); assertEquals("Order attribute should be null: ", expected, actual); } @Test public void testGetOrderWhenOrderIsSet() { CMLAction cml = new CMLAction(); cml.setOrder("parallel"); String expected = "parallel"; String actual = cml.getOrder(); assertEquals("Order value should be 'parallel': ", expected, actual); } @Test public void testGetOrderWhenOrderIsNotSet() { CMLAction cml = new CMLAction(); String expected = null; String actual = cml.getOrder(); assertEquals("Order value should be null: ", expected, actual); } @Test public void testGetCountAttributeWhenCountIsSet() { CMLAction cml = new CMLAction(); cml.setCount("1.0"); CMLAttribute expected = new CMLAttribute("count"); expected.setCMLValue("1.0"); CMLAttribute actual = cml.getCountAttribute(); assertEquals("LocalName should be 'count': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be '1.0': ", expected.getValue(), actual.getValue()); } @Test public void testGetCountAttributeWhenCountIsNotSet() { CMLAction cml = new CMLAction(); CMLAttribute expected = null; CMLAttribute actual = cml.getCountAttribute(); assertEquals("Count attribute should be null: ", expected, actual); } @Test public void testGetCountWhenCountIsSetAsString() { CMLAction cml = new CMLAction(); cml.setCount("1.0"); Double expected = 1D; Double actual = cml.getCount(); assertEquals("Count value should be '1': ", expected, actual); } @Test public void testGetCountWhenCountIsSetAsDouble() { CMLAction cml = new CMLAction(); cml.setCount(1D); Double expected = 1D; Double actual = cml.getCount(); assertEquals("Count value should be '1': ", expected, actual); } @Test public void testGetRefAttributeWhenRefIsSet() { CMLAction cml = new CMLAction(); cml.setRef("testRef"); CMLAttribute expected = new CMLAttribute("ref"); expected.setCMLValue("testRef"); CMLAttribute actual = cml.getRefAttribute(); assertEquals("LocalName should be 'ref': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testRef': ", expected.getValue(), actual.getValue()); } @Test public void testGetRefAttributeWhenRefIsNotSet() { CMLAction cml = new CMLAction(); CMLAttribute expected = null; CMLAttribute actual = cml.getRefAttribute(); assertEquals("Ref attribute should be null: ", expected, actual); } @Test public void testGetRefWhenRefIsSet() { CMLAction cml = new CMLAction(); cml.setRef("testRef"); String expected = "testRef"; String actual = cml.getRef(); assertEquals("Ref should be 'testRef': ", expected, actual); } @Test public void testGetRefWhenRefIsNotSet() { CMLAction cml = new CMLAction(); String expected = null; String actual = cml.getRef(); assertEquals("Ref should be null: ", expected, actual); } @Test public void testSetAttribute() { CMLAction cml = new CMLAction(); cml.setAttribute("title", "testTitle"); cml.setAttribute("id", "testId"); cml.setAttribute("convention", "testConvention"); cml.setAttribute("dictRef", "test:dictRef"); cml.setAttribute("units", "units:ang"); cml.setAttribute("start", "xsd:double"); cml.setAttribute("startCondition", "test"); cml.setAttribute("duration", "testDuration"); cml.setAttribute("end", "xsd:double"); cml.setAttribute("endCondition", "test"); cml.setAttribute("type", "testType"); cml.setAttribute("order", "parallel"); cml.setAttribute("count", "1.0"); cml.setAttribute("ref", "testRef"); assertEquals("Title should be 'testTitle': ", "testTitle", cml.getTitle()); assertEquals("Id should be 'testId': ", "testId", cml.getId()); assertEquals("Convention should be 'testConvention': ", "testConvention", cml.getConvention()); assertEquals("DictRef should be 'test:dictRef': ", "test:dictRef", cml.getDictRef()); assertEquals("Units should be 'units:ang': ", "units:ang", cml.getUnits()); assertEquals("Start value should be 'xsd:double': ", "xsd:double", cml.getStart()); assertEquals("Start condition value should be 'test': ", "test", cml.getStartCondition()); assertEquals("Duration value should be 'testDuration': ", "testDuration", cml.getDuration()); assertEquals("End value should be 'xsd:double': ", "xsd:double", cml.getEnd()); assertEquals("End condition value should be 'test': ", "test", cml.getEndCondition()); assertEquals("Type condition value should be 'testType': ", "testType", cml.getType()); assertEquals("Order condition value should be 'parallel': ", "parallel", cml.getOrder()); assertEquals("Count condition value should be '1.0': ", "1.0", String.valueOf(cml.getCount())); assertEquals("Ref condition value should be 'testRef': ", "testRef", cml.getRef()); } }cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLAngleTest.java000077500000000000000000000233551477224461000272440ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.euclid.EuclidConstants.EPS; import java.util.ArrayList; import java.util.List; import java.util.Map; import nu.xom.Element; import org.apache.log4j.Logger; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLAngle; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLBond; import org.xmlcml.cml.element.CMLCml; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.test.StringTestBase; /** * tests CMLAngle. * * @author pm286 * */ public class CMLAngleTest { private static Logger LOG = Logger.getLogger(CMLAngleTest.class); String s1 = CMLConstants.S_EMPTY + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "" + CMLConstants.S_EMPTY; CMLAngle angle0; CMLAngle angle1; CMLAngle angle2; CMLMolecule molecule1; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { Element element = null; try { element =CMLXOMTestUtils.parseValidString(s1); } catch (Exception e) { e.printStackTrace(); LOG.error("EXC " + e); throw e; } CMLCml cml = (CMLCml) element; molecule1 = (CMLMolecule) cml.getChildCMLElements("molecule").get(0); angle0 = (CMLAngle) cml.getChildCMLElements("angle").get(0); angle1 = (CMLAngle) cml.getChildCMLElements("angle").get(1); angle2 = (CMLAngle) cml.getChildCMLElements("angle").get(2); } /** * Test method for 'org.xmlcml.cml.element.CMLAngle.copy()' */ @Test public final void testCopy() { CMLAngle angle00 = (CMLAngle) angle0.copy(); StringTestBase.assertEquals("atomRefs3", new String[] { "a1", "a2", "a3" }, angle00.getAtomRefs3()); } /** * Test method for 'org.xmlcml.cml.element.CMLAngle.CMLAngle()' */ @Test public final void testCMLAngle() { CMLAngle angle00 = new CMLAngle(angle0); StringTestBase.assertEquals("atomRefs3", new String[] { "a1", "a2", "a3" }, angle00.getAtomRefs3()); } /** * test getIdList. */ @Test public void testGetIdList() { List idList = angle0.getAtomIds(); Assert.assertNotNull("atom ids should not be null", idList); Assert.assertEquals("atom ids", 3, idList.size()); Assert.assertEquals("atom id 0", "a1", idList.get(0)); Assert.assertEquals("atom id 1", "a2", idList.get(1)); Assert.assertEquals("atom id 2", "a3", idList.get(2)); angle0.removeAttribute("atomRefs3"); idList = angle0.getAtomIds(); Assert.assertNull("atom ids should be null", idList); } /** * Test method for 'org.xmlcml.cml.element.CMLAngle.getAtoms(CMLMolecule)' */ @Test public final void testGetAtoms() { List atomRefs3 = null; try { atomRefs3 = angle0.getAtoms(molecule1); } catch (RuntimeException e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertNotNull("atomRefs3 not null", atomRefs3); String msg = RuntimeException.class.getName() + ": cannot find atom a4"; try { atomRefs3 = angle2.getAtoms(molecule1); Assert.fail("should always throw " + msg); } catch (RuntimeException e) { // OK } } /** * Test method for * 'org.xmlcml.cml.element.CMLAngle.getCalculatedAngle(CMLMolecule)' */ @Test public final void testGetCalculatedAngle() { double angle = angle0.getCalculatedAngle(molecule1); Assert.assertEquals("angle0 ", 90.0, angle, EPS); angle = angle1.getCalculatedAngle(molecule1); Assert.assertEquals("angle1 ", 2.0, Math.tan(angle * Math.PI / 180.), EPS); try { angle = angle2.getCalculatedAngle(molecule1); Assert.fail("Should throw non-existent atom a4"); } catch (RuntimeException e) { // OK } } /** * Test method for 'org.xmlcml.cml.element.CMLAngle.atomHash(String, String, * String)' */ @Test public final void testAtomHash() { String s = "a1" + CMLBond.HASH_SYMB + "a2" + CMLBond.HASH_SYMB + "a3"; Assert .assertEquals("atom hash", s, CMLAngle.atomHash("a1", "a2", "a3")); Assert .assertEquals("atom hash", s, CMLAngle.atomHash("a3", "a2", "a1")); } /** * Test method for * 'org.xmlcml.cml.element.CMLAngle.getIndexedAngles(CMLAngle[])' */ @Test public final void testGetIndexedAngles() { List angles = new ArrayList(); angles.add(angle0); angles.add(angle1); Map map = CMLAngle.getIndexedAngles(angles); Assert.assertEquals("size of map", 2, map.size()); // retrieve by atom ids CMLAngle angle = map.get(CMLAngle.atomHash("a1", "a2", "a3")); Assert.assertNotNull("angle not null", angle); StringTestBase.assertEquals("atomRefs3 ", new String[] { "a1", "a2", "a3" }, angle.getAtomRefs3()); // retrieve in other order angle = map.get(CMLAngle.atomHash("a3", "a2", "a1")); Assert.assertNotNull("angle not null", angle); StringTestBase.assertEquals("atomRefs3 ", new String[] { "a1", "a2", "a3" }, angle.getAtomRefs3()); // non existent angle = map.get(CMLAngle.atomHash("a4", "a2", "a1")); Assert.assertNull("angle null", angle); } /** * Test method for {@link org.xmlcml.cml.element.CMLAngle#getAtomIds()}. */ @Test public final void testGetAtomIds() { List atomIds = angle1.getAtomIds(); Assert.assertEquals("ids ", 3, atomIds.size()); Assert.assertEquals("id0 ", "a2", atomIds.get(0)); Assert.assertEquals("id1 ", "a1", atomIds.get(1)); Assert.assertEquals("id2 ", "a3", atomIds.get(2)); } /** * Test method for * {@link org.xmlcml.cml.element.CMLAngle#getAtoms(org.xmlcml.cml.element.CMLMolecule)} * . */ @Test public final void testGetAtomsCMLMolecule() { List atoms = angle1.getAtoms(molecule1); Assert.assertEquals("ids ", 3, atoms.size()); Assert.assertEquals("id0 ", "a2", atoms.get(0).getId()); Assert.assertEquals("id1 ", "a1", atoms.get(1).getId()); Assert.assertEquals("id2 ", "a3", atoms.get(2).getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLAngle#getAtoms(org.xmlcml.cml.element.CMLAtomSet)} * . */ @Test public final void testGetAtomsCMLAtomSet() { List atoms = angle1.getAtoms(molecule1); Assert.assertEquals("ids ", 3, atoms.size()); Assert.assertEquals("id0 ", "a2", atoms.get(0).getId()); Assert.assertEquals("id1 ", "a1", atoms.get(1).getId()); Assert.assertEquals("id2 ", "a3", atoms.get(2).getId()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLAngle#getCalculatedAngle(org.xmlcml.cml.element.CMLMolecule)} * . */ @Test public final void testGetCalculatedAngleCMLMolecule() { double d = angle0.getCalculatedAngle(molecule1); Assert.assertEquals("ang0 ", 90.0, d, EPS); d = angle1.getCalculatedAngle(molecule1); Assert.assertEquals("ang1 ", 2, Math.tan(d * Math.PI / 180.), EPS); } /** * Test method for * {@link org.xmlcml.cml.element.CMLAngle#getCalculatedAngle(org.xmlcml.cml.element.CMLAtomSet)} * . */ @Test public final void testGetCalculatedAngleCMLAtomSet() { double d = angle0.getCalculatedAngle(molecule1); Assert.assertEquals("ang0 ", 90.0, d, EPS); d = angle1.getCalculatedAngle(molecule1); Assert.assertEquals("ang1 ", 2, Math.tan(d * Math.PI / 180.), EPS); } /** * Test method for * {@link org.xmlcml.cml.element.CMLAngle#atomHash(java.lang.String, java.lang.String, java.lang.String)} * . */ @Test public final void testAtomHashStringStringString() { String s = CMLAngle.atomHash("a20", "a21", "a22"); Assert.assertEquals("hash ", "a20" + CMLBond.HASH_SYMB + "a21" + CMLBond.HASH_SYMB + "a22", s); s = CMLAngle.atomHash("a22", "a21", "a20"); Assert.assertEquals("hash ", "a20" + CMLBond.HASH_SYMB + "a21" + CMLBond.HASH_SYMB + "a22", s); } /** * Test method for * {@link org.xmlcml.cml.element.CMLAngle#getList(org.xmlcml.cml.base.CMLElements)} * . */ @Test public final void testGetList() { // obsolescent method? } /** * Test method for * {@link org.xmlcml.cml.element.CMLAngle#setAtomRefs3(org.xmlcml.cml.element.CMLAtom, org.xmlcml.cml.element.CMLAtom, org.xmlcml.cml.element.CMLAtom)} * . */ @Test public final void testSetAtomRefs3CMLAtomCMLAtomCMLAtom() { CMLAngle angle = new CMLAngle(); List atoms = molecule1.getAtoms(); angle.setAtomRefs3(atoms.get(1), atoms.get(2), atoms.get(0)); StringTestBase.assertEquals("atoms", new String[] { "a2", "a3", "a1" }, angle.getAtomRefs3()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLArgTest.java000077500000000000000000000230151477224461000267200ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.base.CMLXOMTestUtils.assertEqualsCanonically; import static org.xmlcml.cml.element.main.AbstractTestBase.SIMPLE_RESOURCE; import java.io.File; import java.io.InputStream; import java.net.URL; import java.util.List; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLArg; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLBond; import org.xmlcml.cml.element.CMLCml; import org.xmlcml.cml.element.CMLList; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.euclid.Util; import org.xmlcml.euclid.test.StringTestBase; /** * test CMLArg. * * @author pm286 * */ public class CMLArgTest { /** * Test method for 'org.xmlcml.cml.element.CMLArg.CMLArg(String, int)' */ @Test public void testCMLArgStringInt() { CMLArg arg = new CMLArg("foo", 23); Assert.assertEquals("arg int", "foo", arg.getName()); Assert.assertEquals("arg int", 23, arg.getInteger()); } /** * Test method for * 'org.xmlcml.cml.element.CMLArg.substituteNameByValue(CMLElement)' * * @exception Exception */ @Test public void testSubstituteNameByValueCMLElement() throws Exception { String cmlS = "" + "" + " " + " " + " 42" + " " + " " + " " + " " + " " + " " + "" + ""; CMLCml cml = (CMLCml)CMLXOMTestUtils.parseValidString(cmlS); Assert.assertEquals("untouched id", "a_i_", cml.getId()); Assert.assertEquals("child count", 1, cml.getChildElements().size()); CMLMolecule mol = (CMLMolecule) cml .getChildCMLElements(CMLMolecule.TAG).get(0); Assert.assertEquals("mol id", "mol_i_", mol.getId()); List atoms = mol.getAtoms(); Assert.assertEquals("atom count", 2, atoms.size()); Assert.assertEquals("atom id", "m_i__a1", atoms.get(0).getId()); Assert.assertEquals("atom id", "m_i__a2", atoms.get(1).getId()); CMLArg.substituteNameByValue(mol); Assert.assertEquals("untouched id", "a_i_", cml.getId()); Assert.assertEquals("mol id", "mol42", mol.getId()); Assert.assertEquals("atom count", 2, atoms.size()); Assert.assertEquals("atom id", "m42_a1", atoms.get(0).getId()); Assert.assertEquals("atom id", "m42_a2", atoms.get(1).getId()); URL url = Util.getResource(SIMPLE_RESOURCE + File.separator + "arg1.xml"); CMLCml arg1Cml = null; InputStream in = null; try { in = url.openStream(); arg1Cml = (CMLCml) new CMLBuilder().build(in).getRootElement(); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("EXC" + e); } finally { in.close(); } CMLArg.substituteNameByValue(arg1Cml); CMLMolecule arg1Mol = (CMLMolecule) arg1Cml.getChildCMLElements( CMLMolecule.TAG).get(0); /* * -- * -- */ Assert.assertEquals("untouched id", "a_i_", cml.getId()); Assert.assertEquals("mol id", "oh42", arg1Mol.getId()); atoms = arg1Mol.getAtoms(); Assert.assertEquals("atom count", 2, atoms.size()); Assert.assertEquals("atom id", "oh42_a1", atoms.get(0).getId()); Assert.assertEquals("atom id", "oh42_r1", atoms.get(1).getId()); List bonds = arg1Mol.getBonds(); Assert.assertEquals("bond count", 2, atoms.size()); Assert.assertEquals("bond id", "b_oh42_a1_oh42_r1", bonds.get(0) .getId()); StringTestBase.assertEquals("bond atomRefs2", new String[] { "oh42_a1", "oh42_r1" }, bonds.get(0).getAtomRefs2()); } /** * dewisott */ @Test public void testAddArg() { CMLList list = new CMLList(); CMLArg arg = new CMLArg("a1", 1); CMLArg.addArg(list, arg, 0); arg = new CMLArg("a2", 2); CMLArg.addArg(list, arg, 0); String s = "" + "" + "2" + "" + "" + "1" + "" + ""; assertEqualsCanonically("add arg",CMLXOMTestUtils.parseValidString(s), list, true); try { arg = new CMLArg("a1", 2); CMLArg.addArg(list, arg, 0); Assert.fail("should throw duplicate arg"); } catch (RuntimeException e) { } } /** * Test method for 'org.xmlcml.cml.element.CMLArg.eval(List)' * * @exception Exception */ @Test public void testEval() throws Exception { String cmlS = "" + "" + " " + " " + " 42" + " " + " " + " " + " " + " " + " " + " " + " " + " " + "" + ""; CMLCml cml = (CMLCml)CMLXOMTestUtils.parseValidString(cmlS); Assert.assertEquals("untouched id", "a_i_", cml.getId()); Assert.assertEquals("child count", 1, cml.getChildElements().size()); CMLMolecule mol = (CMLMolecule) cml .getChildCMLElements(CMLMolecule.TAG).get(0); Assert.assertEquals("mol id", "mol_i_", mol.getId()); List atoms = mol.getAtoms(); Assert.assertEquals("atom count", 2, atoms.size()); Assert.assertEquals("atom id", "m_j__a1", atoms.get(0).getId()); Assert.assertEquals("atom id", "m_j__a2", atoms.get(1).getId()); // Util.output("----------------------------"); CMLArg.substituteNameByValue(mol); Assert.assertEquals("untouched id", "a_i_", cml.getId()); Assert.assertEquals("mol id", "mol42", mol.getId()); Assert.assertEquals("atom count", 2, atoms.size()); Assert.assertEquals("atom id", "m142_a1", atoms.get(0).getId()); Assert.assertEquals("atom id", "m142_a2", atoms.get(1).getId()); } /** * Test method for 'org.xmlcml.cml.element.CMLArg.getInteger()' */ @Test public void testGetInteger() { CMLArg arg = new CMLArg("foo", 23); Integer i = arg.getInteger(); Assert.assertEquals("int", 23, i.intValue()); } // /** // * Test method for arg and repeat' // * // * @exception Exception // */ // @Test // public void testArgAndRepeat() throws Exception { // CMLCml peo0Cml = null; // try { // peo0Cml = (CMLCml) new CMLBuilder().build( // Util.getInputStreamFromResource(EXPERIMENTAL_RESOURCE // + File.separator + "peo0.xml")).getRootElement(); // } catch (Exception e) { // e.printStackTrace(); // throw new RuntimeException("EXC" + e); // } // Elements peo0Mols = peo0Cml.getChildCMLElements(CMLMolecule.TAG); // CMLMolecule peo0Mol = (CMLMolecule) peo0Mols.get(3); // CMLArg.substituteNameByValue(peo0Mol); // RefAttribute.process(peo0Mol); // // } // /** // * Test method for arg and repeat' // * // * @exception Exception // */ // @Test // public void testArg1() throws Exception { // CMLCml peo1Cml = null; // try { // peo1Cml = (CMLCml) new CMLBuilder().build( // Util.getInputStreamFromResource(EXPERIMENTAL_RESOURCE // + CMLConstants.S_SLASH + "peo1.xml")).getRootElement(); // } catch (Exception e) { // e.printStackTrace(); // throw new RuntimeException("EXC" + e); // } // Elements peo1Mols = peo1Cml.getChildCMLElements(CMLMolecule.TAG); // CMLMolecule peo1Mol = (CMLMolecule) peo1Mols.get(1); // CMLArg.substituteNameByValue(peo1Mol); // RefAttribute.process(peo1Mol); // } // /** // * Test method for arg and repeat' // * // * @exception Exception // */ // @Test // public void testArg2() throws Exception { // Util.sysout("=========start peo2 ============"); // CMLCml peo2Cml = null; // InputStream in = null; // try { // in = Util.getInputStreamFromResource(EXPERIMENTAL_RESOURCE // +CMLConstants.U_S + "peo2.xml"); // peo2Cml = (CMLCml) new CMLBuilder().build(in) // .getRootElement(); // } catch (Exception e) { // e.printStackTrace(); // throw new RuntimeException("EXC" + e); // } // finally { // if (in != null) { // in.close(); // } // } // Elements peo2Mols = peo2Cml.getChildCMLElements(CMLMolecule.TAG); // CMLMolecule peo2Mol = (CMLMolecule) peo2Mols.get(1); // CMLArg.substituteNameByValue(peo2Mol); // RefAttribute.process(peo2Mol); // } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLArrayListTest.java000077500000000000000000000177421477224461000301330ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.base.CMLConstants.XSD_DOUBLE; import static org.xmlcml.cml.base.CMLXOMTestUtils.assertEqualsCanonically; import static org.xmlcml.cml.base.CMLXOMTestUtils.logger; import static org.xmlcml.euclid.EuclidConstants.S_EMPTY; import java.io.File; import java.io.IOException; import java.net.URL; import java.util.List; import nu.xom.ParsingException; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLArray; import org.xmlcml.cml.element.CMLArrayList; import org.xmlcml.cml.element.CMLList; import org.xmlcml.cml.element.CMLScalar; import org.xmlcml.cml.element.CMLTable; import org.xmlcml.cml.element.CMLTableContent; import org.xmlcml.cml.element.CMLTableHeader; import org.xmlcml.cml.element.CMLTableHeaderCell; import org.xmlcml.cml.element.CMLTableRow; import org.xmlcml.cml.element.CMLTableRowList; import org.xmlcml.cml.interfacex.HasArraySize; import org.xmlcml.euclid.Util; /** * @author pm286 * */ public class CMLArrayListTest extends AbstractTableBase { protected CMLTableRowList tableRowList = null; CMLTableRow tableRow = null; protected CMLTableContent tableContent = null; protected CMLTableHeader tableHeader = null; protected CMLArrayList arrayList = null; protected CMLTable columnTable1 = null; protected CMLTable contentTable1 = null; protected CMLTable rowTable1 = null; /** * Test method for * {@link org.xmlcml.cml.element.CMLArrayList#createTableHeader()}. */ @Test public final void testCreateTableHeader() { CMLTableHeader tableHeader1 = arrayList.createTableHeader(); assertEqualsCanonically("table header", tableHeader1, tableHeader, true); } /** * Test method for * {@link org.xmlcml.cml.element.CMLArrayList#createTableHeaderCell(CMLArray)} * . */ @Test public final void testCreateTableHeaderCellNode() { CMLArray array = new CMLArray(); array.setDataType(XSD_DOUBLE); array.setTitle("my title"); array.setDictRef("my:dict"); array.append(1.2); array.append(3.4); CMLTableHeaderCell tableHeaderCell1 = arrayList .createTableHeaderCell(array); Assert.assertNotNull("tableHeader not null", tableHeaderCell1); String ss = ""; CMLTableHeaderCell expected = (CMLTableHeaderCell)CMLXOMTestUtils.parseValidString(ss); assertEqualsCanonically("tableHeaderCell", expected, tableHeaderCell1, true); } /** * Test method for * {@link org.xmlcml.cml.element.CMLArrayList#createTableHeaderCell(org.xmlcml.cml.element.CMLArray)} * . */ @Test public final void testCreateTableHeaderCellCMLArray() { CMLArray array = new CMLArray(); array.setDataType(XSD_DOUBLE); array.setTitle("my title"); array.setDictRef("my:dict"); array.append(1.2); array.append(3.4); CMLTableHeaderCell tableHeaderCell1 = arrayList .createTableHeaderCell(array); Assert.assertNotNull("tableHeader not null", tableHeaderCell1); String ss = ""; CMLTableHeaderCell expected = (CMLTableHeaderCell)CMLXOMTestUtils.parseValidString(ss); assertEqualsCanonically("tableHeaderCell", expected, tableHeaderCell1, true); } /** * Test method for * {@link org.xmlcml.cml.element.CMLArrayList#createTableHeaderCell(org.xmlcml.cml.element.CMLList)} * . */ @Test public final void testCreateTableHeaderCellCMLList() { CMLList list = new CMLList(); list.setTitle("my title"); list.setDictRef("my:dict"); list.appendChild(new CMLScalar(1.2)); list.appendChild(new CMLScalar(3.4)); CMLTableHeaderCell tableHeaderCell1 = arrayList .createTableHeaderCell(list); Assert.assertNotNull("tableHeader not null", tableHeaderCell1); String ss = ""; CMLTableHeaderCell expected = (CMLTableHeaderCell)CMLXOMTestUtils.parseValidString(ss); assertEqualsCanonically("tableHeaderCell", expected, tableHeaderCell1, true); } /** * Test method for {@link org.xmlcml.cml.element.CMLArrayList#getArrays()}. */ @Test public final void testGetListAndArrays() { List arrays = arrayList.getArrays(); Assert.assertEquals("arrays", 2, arrays.size()); } /** * Test method for * {@link org.xmlcml.cml.element.CMLArrayList#createTableContent()}. */ @Test public final void testCreateTableContent() { CMLTableContent tableContent = arrayList.createTableContent(); String ss = "1 a 2 b 3 c"; CMLTableContent expected = (CMLTableContent)CMLXOMTestUtils.parseValidString(ss); assertEqualsCanonically("tableContent", expected, tableContent, true); } /** * Test method for * {@link org.xmlcml.cml.element.CMLArrayList#getCommonDelimiter()}. */ @Test public final void testGetCommonDelimiter() { String delim = arrayList.getCommonDelimiter(); Assert.assertEquals("slashDelim", S_EMPTY, delim); } /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { /* * 3 5 7Sue Fred Sandy *
*/ URL columnUrl1 = null; URL contentUrl1 = null; URL rowUrl1 = null; try { columnUrl1 = Util.getResource(COLUMN_TABLE1_XML); contentUrl1 = Util.getResource(CONTENT_TABLE1_XML); rowUrl1 = Util.getResource(ROW_TABLE1_XML); } catch (Exception e) { // Saw this once, being cautious. ~~~~jd323 e.printStackTrace(); } Assert.assertNotNull(columnUrl1); Assert.assertNotNull(contentUrl1); Assert.assertNotNull(rowUrl1); try { CMLBuilder builder = new CMLBuilder(); columnTable1 = (CMLTable) builder.build( new File(columnUrl1.toURI())).getRootElement(); contentTable1 = (CMLTable) builder.build( new File(contentUrl1.toURI())).getRootElement(); rowTable1 = (CMLTable) builder.build(new File(rowUrl1.toURI())) .getRootElement(); } catch (IOException e) { e.printStackTrace(); Assert.fail("Should not throw IOException"); } catch (ParsingException e) { e.printStackTrace(); logger.error("Parse exception " + e.getMessage()); Assert.fail("Should not throw ParsingException" + e.getCause()); } tableContent = (CMLTableContent)CMLXOMTestUtils.parseValidString(tableContentS); tableHeader = (CMLTableHeader)CMLXOMTestUtils.parseValidString(tableHeaderS); tableRowList = (CMLTableRowList)CMLXOMTestUtils.parseValidString(tableRowListS); tableRow = tableRowList.getTableRowElements().get(1); arrayList = (CMLArrayList)CMLXOMTestUtils.parseValidString(arrayListS); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLAtomSetTest.java000077500000000000000000001422421477224461000275670ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.euclid.EuclidConstants.EPS; import static org.xmlcml.euclid.EuclidConstants.S_RBRAK; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement.CoordinateType; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLAtomSet; import org.xmlcml.cml.element.CMLFormula; import org.xmlcml.cml.element.CMLLink; import org.xmlcml.cml.element.CMLMap; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.CMLTransform3; import org.xmlcml.cml.element.CMLMap.Direction; import org.xmlcml.euclid.Angle; import org.xmlcml.euclid.EC; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Point3Vector; import org.xmlcml.euclid.Real2; import org.xmlcml.euclid.Real2Vector; import org.xmlcml.euclid.RealMatrix; import org.xmlcml.euclid.Transform2; import org.xmlcml.euclid.Vector3; import org.xmlcml.euclid.test.DoubleTestBase; import org.xmlcml.molutil.ChemicalElement.AS; /** * test CMLAtomSet * * @author pmr * */ public class CMLAtomSetTest { MoleculeAtomBondFixture fixture = new MoleculeAtomBondFixture(); CMLAtomSet atomSet1 = null; CMLAtomSet atomSet2 = null; /** * constructor. */ public CMLAtomSetTest() { super(); } /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { atomSet1 = new CMLAtomSet(fixture.xmlMolecule, new String[] { "a1", "a2", "a3" }); atomSet2 = new CMLAtomSet(fixture.xmlMolecule, new String[] { "a2", "a3", "a4", "a5" }); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.CMLAtomSet()' */ @Test public void testCMLAtomSet() { CMLAtomSet xomAtomSet = new CMLAtomSet(); Assert.assertNotNull("atom set creation", xomAtomSet); Assert.assertEquals("atom set size", 0, xomAtomSet.size()); Assert.assertEquals("atom set ", new String[] { CMLConstants.S_EMPTY }, xomAtomSet .getXMLContent()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.CMLAtomSet(CMLAtomSet)' */ @Test public void testCMLAtomSetCMLAtomSet() { CMLAtomSet xomAtomSet0 = new CMLAtomSet(fixture.xomMolecule, new String[] { "a1", "a3" }); CMLAtomSet xomAtomSet = new CMLAtomSet(xomAtomSet0); Assert.assertNotNull("atom set creation", xomAtomSet); Assert.assertEquals("atom set size", 2, xomAtomSet.size()); Assert.assertEquals("atom set ", new String[] { "a1", "a3" }, xomAtomSet.getXMLContent()); CMLAtom atom30 = xomAtomSet0.getAtomById("a3"); CMLAtom atom3 = xomAtomSet.getAtomById("a3"); Assert.assertSame("indexes are copied", atom30, atom3); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.CMLAtomSet(CMLMolecule, String[])' */ @Test public void testCMLAtomSetCMLMoleculeStringArray() { final CMLAtomSet xomAtomSet = new CMLAtomSet(fixture.xomMolecule, new String[] { "a1", "a3" }); Assert.assertNotNull("atom set creation", xomAtomSet); Assert.assertEquals("atom set size", 2, xomAtomSet.size()); Assert.assertEquals("atom set ", new String[] { "a1", "a3" }, xomAtomSet.getXMLContent()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.CMLAtomSet(CMLMolecule)' */ @Test public void testCMLAtomSetCMLMolecule() { final CMLAtomSet xomAtomSet = new CMLAtomSet(fixture.xomMolecule); Assert.assertNotNull("atom set creation", xomAtomSet); Assert.assertEquals("atom set size", 5, xomAtomSet.size()); Assert.assertEquals("atom set ", new String[] { "a1", "a2", "a3", "a4", "a5" }, xomAtomSet.getXMLContent()); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.CMLAtomSet(CMLAtom[])' */ @Test public void testCMLAtomSetCMLAtomArray() { final CMLAtomSet atomSet = new CMLAtomSet(fixture.xomAtom); Assert.assertEquals("atom set size", 5, atomSet.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a2", "a3", "a4", "a5" }, atomSet.getXMLContent()); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.addAtoms(CMLAtom[])' */ @Test @Deprecated public void testAddAtoms() { CMLAtomSet atomSet1 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[0], fixture.xomAtom[2] }); Assert.assertEquals("atom set size", 2, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a3" }, atomSet1.getXMLContent()); atomSet1.addAtoms(new CMLAtom[] { fixture.xomAtom[1], fixture.xomAtom[3] }); Assert.assertEquals("atom set size", 4, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a3", "a2", "a4" }, atomSet1.getXMLContent()); // includes duplicate atom atomSet1.addAtoms(new CMLAtom[] { fixture.xomAtom[3], fixture.xomAtom[4] }); Assert.assertEquals("atom set size", 5, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a3", "a2", "a4", "a5" }, atomSet1.getXMLContent()); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.addAtom(CMLAtom)' */ @Test public void testAddAtom() { CMLAtomSet atomSet1 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[0], fixture.xomAtom[2] }); Assert.assertEquals("atom set size", 2, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a3" }, atomSet1.getXMLContent()); atomSet1.addAtom(fixture.xomAtom[1]); Assert.assertNotNull("atom set molecule", atomSet1.getMolecule()); Assert.assertEquals("atom set molecule", fixture.xomAtom[0] .getMolecule(), atomSet1.getMolecule()); Assert.assertEquals("atom set size", 3, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a3", "a2" }, atomSet1.getXMLContent()); // includes duplicate atom atomSet1.addAtom(fixture.xomAtom[1]); Assert.assertEquals("atom set size", 3, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a3", "a2" }, atomSet1.getXMLContent()); atomSet1.addAtom(fixture.xomAtom[4]); Assert.assertEquals("atom set size", 4, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a3", "a2", "a5" }, atomSet1.getXMLContent()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.addAtomSet(CMLAtomSet)' */ @Test public void testAddAtomSet() { final CMLAtomSet atomSet1 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[0], fixture.xomAtom[2] }); Assert.assertEquals("atom set size", 2, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a3" }, atomSet1.getXMLContent()); CMLAtomSet atomSet2 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[1], fixture.xomAtom[3] }); Assert.assertEquals("atom set size", 2, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a3" }, atomSet1.getXMLContent()); atomSet1.addAtomSet(atomSet2); Assert.assertEquals("atom set size", 4, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a3", "a2", "a4" }, atomSet1.getXMLContent()); // includes duplicate atomSet atomSet1.addAtomSet(atomSet2); Assert.assertEquals("atom set size", 4, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a3", "a2", "a4" }, atomSet1.getXMLContent()); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.getAtoms()' */ @Test public void testGetAtoms() { CMLAtomSet atomSet1 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[0], fixture.xomAtom[2] }); Assert.assertEquals("atom set size", 2, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a3" }, atomSet1.getXMLContent()); List atoms = atomSet1.getAtoms(); Assert.assertEquals("atoms size", 2, atoms.size()); Assert.assertEquals("atom", fixture.xomAtom[0], (CMLAtom) atoms.get(0)); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.size()' */ @Test public void testSize() { CMLAtomSet atomSet1 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[0], fixture.xomAtom[2] }); Assert.assertEquals("atom set size", 2, atomSet1.size()); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.getAtomIDs()' */ @Test public void testGetAtomIDs() { CMLAtomSet atomSet1 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[0], fixture.xomAtom[2] }); Assert.assertEquals("atom ids", new String[] { "a1", "a3" }, atomSet1 .getAtomIDs()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.getAtomSetById(String[])' */ @Test public void testGetAtomSetById() { CMLAtomSet atomSet1 = new CMLAtomSet(fixture.xomAtom); List atoms = new ArrayList(); atoms.add("a2"); atoms.add("a4"); CMLAtomSet atomSet2 = atomSet1.getAtomSetById(atoms); Assert.assertEquals("atom set by id", 2, atomSet2.size()); Assert.assertEquals("atom set by id", fixture.xomAtom[3].getId(), ((CMLAtom) atomSet2.getAtoms().get(1)).getId()); Assert.assertEquals("atom set by id", fixture.xomAtom[3], (CMLAtom) atomSet2.getAtoms().get(1)); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.getAtomSetByElementType(String)' */ @Test public void testGetAtomSetByElementType() { CMLAtomSet atomSet1 = new CMLAtomSet(fixture.xomAtom); CMLAtomSet atomSet2 = atomSet1.getAtomSetByElementType(AS.N.value); Assert.assertEquals("atom set by element", 1, atomSet2.size()); Assert.assertEquals("atom set by element", "a2", ((CMLAtom) atomSet2 .getAtom(0)).getId()); CMLAtomSet atomSet3 = atomSet1.getAtomSetByElementType(AS.B.value); Assert.assertEquals("atom set by element", 1, atomSet3.size()); Assert.assertEquals("atom set by element", "a5", ((CMLAtom) atomSet3 .getAtom(0)).getId()); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.getAtomById(String)' */ @Test public void testGetAtomById() { CMLAtomSet atomSet1 = new CMLAtomSet(fixture.xomAtom); CMLAtom atom = atomSet1.getAtomById("a2"); Assert.assertEquals("atom by id", fixture.xomAtom[1], atom); atom = atomSet1.getAtomById("a5"); Assert.assertEquals("atom by id", fixture.xomAtom[4], atom); atom = atomSet1.getAtomById("a99"); Assert.assertNull("atom by id", atom); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.contains(CMLAtom)' */ @Test public void testContains() { CMLAtomSet atomSet = new CMLAtomSet(fixture.xomAtom); boolean contains = atomSet.contains(fixture.xomAtom[1]); Assert.assertTrue("atom contains", contains); contains = atomSet.contains(fixture.xmlAtom[1]); Assert.assertFalse("atom contains", contains); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.removeAtom(CMLAtom)' */ @Test public void testRemoveAtom() { CMLAtomSet atomSet = new CMLAtomSet(fixture.xomAtom); atomSet.removeAtom(fixture.xomAtom[1]); Assert.assertEquals("atom contains", 4, atomSet.size()); Assert.assertEquals("atom contains", new String[] { "a1", "a3", "a4", "a5" }, atomSet.getAtomIDs()); // delete non-existent try { atomSet.removeAtom(fixture.xomAtom[1]); // Assert.fail("Should throw CMLRuntime"); } catch (RuntimeException e) { Assert.assertEquals("no longer throws exception: atom contains", "atom not in set:a2:a1/a3/a4/a5", e.getMessage()); } atomSet.removeAtom(fixture.xomAtom[3]); Assert.assertEquals("atom contains", 3, atomSet.size()); Assert.assertEquals("atom contains", new String[] { "a1", "a3", "a5" }, atomSet.getAtomIDs()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.removeAtomById(String)' */ @Test public void testRemoveAtomById() { CMLAtomSet atomSet = new CMLAtomSet(fixture.xomAtom); atomSet.removeAtomById("a2"); Assert.assertEquals("atom contains", 4, atomSet.size()); Assert.assertEquals("atom contains", new String[] { "a1", "a3", "a4", "a5" }, atomSet.getAtomIDs()); // delete non-existent; is no-op atomSet.removeAtomById("a10"); Assert.assertEquals("atom contains", 4, atomSet.size()); Assert.assertEquals("atom contains", new String[] { "a1", "a3", "a4", "a5" }, atomSet.getAtomIDs()); atomSet.removeAtomById("a4"); Assert.assertEquals("atom contains", 3, atomSet.size()); Assert.assertEquals("atom contains", new String[] { "a1", "a3", "a5" }, atomSet.getAtomIDs()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.removeAtomSet(CMLAtomSet)' */ @Test public void testRemoveAtomSet() { CMLAtomSet atomSet1 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[0], fixture.xomAtom[2] }); Assert.assertEquals("atom set size", 2, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a3" }, atomSet1.getXMLContent()); CMLAtomSet atomSet2 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[0], fixture.xomAtom[3] }); Assert.assertEquals("atom set size", 2, atomSet2.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a4" }, atomSet2.getXMLContent()); atomSet1.removeAtomSet(atomSet2); Assert.assertEquals("atom set size", 1, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a3" }, atomSet1 .getXMLContent()); // atomSet2 unaltered? Assert.assertEquals("atom set size", 2, atomSet2.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a4" }, atomSet2.getXMLContent()); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.getVector3D()' */ @Test public void testGetVector3D() { CMLAtomSet atomSet = new CMLAtomSet(fixture.xomAtom); Point3 point3 = ((CMLAtom) atomSet.getAtom(1)).getXYZ3(); Assert.assertNotNull("point 3d", point3); double x = ((CMLAtom) atomSet.getAtom(1)).getX3(); Assert.assertEquals("point 3d x", 1.0, x, 0.0001); Assert.assertEquals("point 3d x", 1.0, point3.getArray()[0], 0.0001); double y = ((CMLAtom) atomSet.getAtom(1)).getY3(); Assert.assertEquals("point 3d y", 2.0, y, 0.0001); Assert.assertEquals("point 3d y", 2.0, point3.getArray()[1], 0.0001); double z = ((CMLAtom) atomSet.getAtom(1)).getZ3(); Assert.assertEquals("point 3d z", 3.0, z, 0.0001); Assert.assertEquals("point 3d z", 3.0, point3.getArray()[2], 0.0001); Point3Vector p3 = atomSet.getCoordinates3(CoordinateType.CARTESIAN); Assert.assertNotNull("vector 3d", p3); Assert.assertEquals("vector 3d", 5, p3.size()); point3 = (Point3) p3.get(1); Assert.assertNotNull("vector 3d", point3); Assert.assertEquals("point 3d z", 3.0, point3.getArray()[2], 0.0001); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.translate3D(Vector3)' */ @Test public void testTranslate3D() { CMLAtomSet atomSet = new CMLAtomSet(fixture.xomAtom); Vector3 v3 = new Vector3(10., 20., 30.); atomSet.translate3D(v3); Point3 p = ((CMLAtom) atomSet.getAtom(1)).getXYZ3(); Assert.assertNotNull("vector 3d", p); Assert.assertEquals("point 3d x", 11.0, p.getArray()[0], 0.0001); Assert.assertEquals("point 3d y", 22.0, p.getArray()[1], 0.0001); Assert.assertEquals("point 3d z", 33.0, p.getArray()[2], 0.0001); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.getCentroid3D()' */ @Test public void testGetCentroid3D() { CMLAtomSet atomSet = new CMLAtomSet(fixture.xomAtom); Point3 p3 = atomSet.getCentroid3(CoordinateType.CARTESIAN); Assert.assertNotNull("vector 3d", p3); Assert.assertEquals("point 3d x", 2.0, p3.getArray()[0], 0.0001); Assert.assertEquals("point 3d y", 3.0, p3.getArray()[1], 0.0001); Assert.assertEquals("point 3d z", 4.0, p3.getArray()[2], 0.0001); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.getMolecule()' */ @Test public void testGetMolecule() { CMLAtomSet atomSet = new CMLAtomSet(fixture.xomAtom); CMLMolecule molecule = atomSet.getMolecule(); Assert.assertNotNull("get molecule", molecule); Assert.assertEquals("molecule ", fixture.xomMolecule, molecule); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.transform(Transform2)' */ @Test public void testTransform() { List coords = new CMLAtomSet(fixture.xmlMolecule).getVector2D(); Real2Vector r2v = new Real2Vector(coords); double[] test = new double[] { 0.0, 0.0, 1.0, 1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0 }; Assert.assertNotNull("test should not be null (" + "r2v" + EC.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + "r2v" + EC.S_RBRAK, r2v); Assert.assertEquals("must be of equal length ", test.length, r2v .getXY().getArray().length); DoubleTestBase.assertEquals("r2v", test, r2v.getXY().getArray(), EPS); Transform2 t = new Transform2(new Angle(Math.PI / 2.)); atomSet1.transform(t); coords = new CMLAtomSet(fixture.xmlMolecule).getVector2D(); r2v = new Real2Vector(coords); double[] test1 = new double[] { 0.0, 0.0, 1.0, -1.0, -1.0, -1.0, // notice these are not transformed -1.0, -1.0, -1.0, 1.0 }; Assert.assertNotNull("test should not be null (" + "r2v" + EC.S_RBRAK, test1); Assert.assertNotNull("expected should not be null (" + "r2v" + EC.S_RBRAK, r2v); Assert.assertEquals("must be of equal length ", test1.length, r2v .getXY().getArray().length); DoubleTestBase.assertEquals("r2v", test1, r2v.getXY().getArray(), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.excludeElementTypes(String[])' */ @Test public void testExcludeElementTypes() { CMLAtomSet atomSet = new CMLAtomSet(fixture.xomAtom); Assert.assertEquals("exclude", fixture.xomMolecule, atomSet .getMolecule()); CMLAtomSet atomSet1 = atomSet.excludeElementTypes(new String[] { AS.N.value, AS.S.value }); Assert.assertEquals("exclude", fixture.xomMolecule, atomSet1 .getMolecule()); Assert.assertEquals("excludeElementTypes", 3, atomSet1.size()); Assert.assertEquals("excludeElementTypes", new String[] { "a1", "a3", "a5" }, atomSet1.getAtomIDs()); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.compareTo(CMLAtomSet)' */ @Test public void testCompareToCMLAtomSet() { Assert.assertEquals("compare", 0, atomSet1.compareTo(atomSet1)); Assert.assertEquals("compare", -1, atomSet1.compareTo(atomSet2)); Assert.assertEquals("compare", 1, atomSet2.compareTo(atomSet1)); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.includeElementTypes(String[])' */ @Test public void testIncludeElementTypes() { CMLAtomSet atomSet = new CMLAtomSet(fixture.xomAtom); Assert.assertEquals("exclude", fixture.xomMolecule, atomSet .getMolecule()); CMLAtomSet atomSet1 = atomSet.includeElementTypes(new String[] { AS.N.value, AS.S.value }); Assert.assertEquals("exclude", fixture.xomMolecule, atomSet1 .getMolecule()); Assert.assertEquals("excludeElementTypes", 2, atomSet1.size()); Assert.assertEquals("excludeElementTypes", new String[] { "a2", "a4" }, atomSet1.getAtomIDs()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.getCalculatedFormula(String)' */ @Test public void testGetCalculatedFormula() { CMLAtomSet atomSet = new CMLAtomSet(fixture.xomAtom); CMLFormula formula = null; try { formula = atomSet .getCalculatedFormula(CMLMolecule.HydrogenControl.USE_HYDROGEN_COUNT); Assert.assertEquals("formula", "C 1 H 4 B 1 N 1 O 1 S 1", formula .getConcise()); } catch (RuntimeException e) { Assert.fail("KNOWN BUG WITH FORMULA " + e); } } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.getCalculatedFormalCharge()' */ @Test public void testGetCalculatedFormalCharge() { CMLAtomSet atomSet = new CMLAtomSet(fixture.xomAtom); int ch = atomSet.getCalculatedFormalCharge(); Assert.assertEquals("formula", 0, ch); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.intersection(CMLAtomSet)' */ @Test public void testIntersection() { CMLAtomSet atomSet1 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[0], fixture.xomAtom[1], fixture.xomAtom[2] }); Assert.assertEquals("atom set size", 3, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a2", "a3" }, atomSet1.getXMLContent()); CMLAtomSet atomSet2 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[1], fixture.xomAtom[2], fixture.xomAtom[3] }); Assert.assertEquals("atom set size", 3, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a2", "a3", "a4" }, atomSet2.getXMLContent()); CMLAtomSet atomSet3 = atomSet1.intersection(atomSet2); Assert.assertEquals("atom set size", 2, atomSet3.size()); Assert.assertEquals("atom set value", new String[] { "a2", "a3" }, atomSet3.getXMLContent()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.compliment(CMLAtomSet)' */ @Test public void testComplement() { CMLAtomSet atomSet1 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[0], fixture.xomAtom[1], fixture.xomAtom[2] }); Assert.assertEquals("atom set size", 3, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a2", "a3" }, atomSet1.getXMLContent()); CMLAtomSet atomSet2 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[1], fixture.xomAtom[2], fixture.xomAtom[3] }); Assert.assertEquals("atom set size", 3, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a2", "a3", "a4" }, atomSet2.getXMLContent()); CMLAtomSet atomSet3 = atomSet1.complement(atomSet2); Assert.assertEquals("atom set size", 1, atomSet3.size()); Assert.assertEquals("atom set value", new String[] { "a1" }, atomSet3 .getXMLContent()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.compliment(CMLAtomSet)' */ @Test public void testHasContentEqualTo() { CMLAtomSet atomSet1 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[0], fixture.xomAtom[1], fixture.xomAtom[2] }); CMLAtomSet atomSet2 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[1], fixture.xomAtom[2], fixture.xomAtom[0] }); Assert.assertTrue("atom set equal", atomSet1 .hasContentEqualTo(atomSet2)); atomSet2 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[1], fixture.xomAtom[1] }); Assert.assertFalse("atom set not equal", atomSet1 .hasContentEqualTo(atomSet2)); atomSet2 = null; Assert.assertFalse("atom set not equal", atomSet1 .hasContentEqualTo(atomSet2)); atomSet1 = new CMLAtomSet(); atomSet2 = new CMLAtomSet(); Assert.assertTrue("atom set equal", atomSet1 .hasContentEqualTo(atomSet2)); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.union(CMLAtomSet)' */ @Test public void testUnion() { CMLAtomSet atomSet1 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[0], fixture.xomAtom[1], fixture.xomAtom[2] }); Assert.assertEquals("atom set size", 3, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a2", "a3" }, atomSet1.getXMLContent()); CMLAtomSet atomSet2 = new CMLAtomSet(new CMLAtom[] { fixture.xomAtom[1], fixture.xomAtom[2], fixture.xomAtom[3] }); Assert.assertEquals("atom set size", 3, atomSet1.size()); Assert.assertEquals("atom set value", new String[] { "a2", "a3", "a4" }, atomSet2.getXMLContent()); CMLAtomSet atomSet3 = atomSet1.union(atomSet2); Assert.assertEquals("atom set size", 4, atomSet3.size()); Assert.assertEquals("atom set value", new String[] { "a1", "a2", "a3", "a4" }, atomSet3.getXMLContent()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.symmetricDifference(CMLAtomSet)' */ @Test public void testSymmetricDifference() { CMLAtomSet atomSet = atomSet1.symmetricDifference(atomSet2); Assert.assertEquals("symmetric", new String[] { "a1", "a4", "a5" }, atomSet.getXMLContent()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.intersectionByAtomId(CMLAtomSet)' */ @Test public void testIntersectionByAtomId() { String[] atoms = atomSet1.intersectionByAtomId(atomSet2); Assert.assertEquals("symmetric", new String[] { "a2", "a3" }, atoms); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.complimentByAtomId(CMLAtomSet)' */ @Test public void testComplimentByAtomId() { String[] atoms = atomSet1.complementByAtomId(atomSet2); Assert.assertEquals("compliment", new String[] { "a1" }, atoms); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.unionByAtomId(CMLAtomSet)' */ @Test public void testUnionByAtomId() { String[] atoms = atomSet1.unionByAtomId(atomSet2); Assert.assertEquals("union", new String[] { "a1", "a2", "a3", "a4", "a5" }, atoms); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.symmetricDifferenceByAtomId(CMLAtomSet * ) ' */ @Test public void testSymmetricDifferenceByAtomId() { String[] atoms = atomSet1.symmetricDifferenceByAtomId(atomSet2); Assert.assertEquals("symmetricDifferenceByAtomId", new String[] { "a1", "a4", "a5" }, atoms); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.getVector2D()' */ @Test public void testGetVector2D() { List coords = atomSet1.getVector2D(); Assert.assertEquals("coords", 3, coords.size()); Assert.assertEquals("coords", 0.0, coords.get(0).getX(), EPS); Assert.assertEquals("coords", 0.0, coords.get(0).getY(), EPS); Assert.assertEquals("coords", 1.0, coords.get(1).getX(), EPS); Assert.assertEquals("coords", 1.0, coords.get(1).getY(), EPS); Assert.assertEquals("coords", 1.0, coords.get(2).getX(), EPS); Assert.assertEquals("coords", -1.0, coords.get(2).getY(), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.setVector2D(Real2Vector)' */ @Test public void testSetVector2D() { Real2Vector v = new Real2Vector(new CMLAtomSet(fixture.xmlMolecule) .getVector2D()); double[] test = new double[] { 0.0, 0.0, 1.0, 1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0 }; Assert.assertNotNull("test should not be null (" + "r2v" + EC.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + "r2v" + EC.S_RBRAK, v); Assert.assertEquals("must be of equal length ", test.length, v .getXY().getArray().length); DoubleTestBase.assertEquals("r2v", test, v.getXY().getArray(), EPS); List v1 = new ArrayList(); v1.add(new Real2(4., 5.)); v1.add(new Real2(6., 7.)); v1.add(new Real2(8., 9.)); atomSet1.setVector2D(v1); v = new Real2Vector(new CMLAtomSet(fixture.xmlMolecule).getVector2D()); double[] test1 = new double[] { 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, -1.0, -1.0, -1.0, 1.0 }; Assert.assertNotNull("test should not be null (" + "r2v" + EC.S_RBRAK, test1); Assert.assertNotNull("expected should not be null (" + "r2v" + EC.S_RBRAK, v); Assert.assertEquals("must be of equal length ", test1.length, v .getXY().getArray().length); DoubleTestBase.assertEquals("r2v", test1, v.getXY().getArray(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.translate2D(Real2)' */ @Test public void testTranslate2D() { atomSet1.translate2D(new Real2(10., 20.)); CMLAtomSet atomSet = new CMLAtomSet(fixture.xmlMolecule); List coords = atomSet.getVector2D(); Assert.assertEquals("coords", 5, coords.size()); Assert.assertEquals("coords", 10.0, coords.get(0).getX(), EPS); Assert.assertEquals("coords", 20.0, coords.get(0).getY(), EPS); Assert.assertEquals("coords", 11.0, coords.get(1).getX(), EPS); Assert.assertEquals("coords", 21.0, coords.get(1).getY(), EPS); Assert.assertEquals("coords", 11.0, coords.get(2).getX(), EPS); Assert.assertEquals("coords", 19.0, coords.get(2).getY(), EPS); Assert.assertEquals("coords", -1.0, coords.get(3).getX(), EPS); Assert.assertEquals("coords", -1.0, coords.get(3).getY(), EPS); Assert.assertEquals("coords", -1.0, coords.get(4).getX(), EPS); Assert.assertEquals("coords", 1.0, coords.get(4).getY(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.getCentroid2D()' */ @Test public void testGetCentroid2D() { Real2 centroid = atomSet1.getCentroid2D(); Assert.assertEquals("centroid", 2. / 3., centroid.getX(), 0.0001); Assert.assertEquals("centroid", 0.0, centroid.getY(), 0.0001); CMLAtomSet atomSet = new CMLAtomSet(fixture.xmlMolecule); centroid = atomSet.getCentroid2D(); Assert.assertEquals("centroid", 0.0, centroid.getX(), 0.0001); Assert.assertEquals("centroid", 0.0, centroid.getY(), 0.0001); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.transform(Transform3)' */ @Test public void testTransformTransform3() { CMLAtom atom0 = new CMLAtom(); atom0.setXYZ3(new Point3(1.0, 2.0, 3.0)); atom0.setXYZFract(new Point3(0.1, 0.2, 0.3)); CMLTransform3 tr = new CMLTransform3(new double[] { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 }); CMLAtom atom = new CMLAtom(atom0); atom.transformCartesians(tr.getEuclidTransform3()); double[] test = new double[] { 1, -2, -3 }; Point3 expected = atom .getXYZ3(); Assert.assertNotNull("test should not be null (" + "transform" + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + "transform" + S_RBRAK, expected); DoubleTestBase.assertEquals("transform", test, expected.getArray(), EPS); double[] test1 = new double[] { 0.1, 0.2, 0.3 }; Point3 expected1 = atom.getXYZFract(); // check no corruption Assert.assertNotNull("test should not be null (" + "transform" + S_RBRAK, test1); Assert.assertEquals("must be of length 3", 3, test1.length); Assert.assertNotNull("ref should not be null (" + "transform" + S_RBRAK, expected1); DoubleTestBase.assertEquals("transform", test1, expected1.getArray(), EPS); tr = new CMLTransform3(new double[] { 10, 0, 0, 0, 0, 20, 0, 0, 0, 0, 30, 0, 0, 0, 0, 1 }); atom = new CMLAtom(atom0); atom.transformCartesians(tr.getEuclidTransform3()); double[] test2 = new double[] { 10, 40, 90 }; Point3 expected2 = atom .getXYZ3(); Assert.assertNotNull("test should not be null (" + "transform" + S_RBRAK, test2); Assert.assertEquals("must be of length 3", 3, test2.length); Assert.assertNotNull("ref should not be null (" + "transform" + S_RBRAK, expected2); DoubleTestBase.assertEquals("transform", test2, expected2.getArray(), EPS); tr = new CMLTransform3(new double[] { 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1 }); atom = new CMLAtom(atom0); atom.transformCartesians(tr.getEuclidTransform3()); double[] test3 = new double[] { -3, -1, -2 }; Point3 expected3 = atom .getXYZ3(); Assert.assertNotNull("test should not be null (" + "transform" + S_RBRAK, test3); Assert.assertEquals("must be of length 3", 3, test3.length); Assert.assertNotNull("ref should not be null (" + "transform" + S_RBRAK, expected3); DoubleTestBase.assertEquals("transform", test3, expected3.getArray(), EPS); tr = new CMLTransform3(new double[] { 0, 0, 1, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1 }); atom = new CMLAtom(atom0); atom.transformCartesians(tr.getEuclidTransform3()); double[] test4 = new double[] { 3, -1, -2 }; Point3 expected4 = atom .getXYZ3(); Assert.assertNotNull("test should not be null (" + "transform" + S_RBRAK, test4); Assert.assertEquals("must be of length 3", 3, test4.length); Assert.assertNotNull("ref should not be null (" + "transform" + S_RBRAK, expected4); DoubleTestBase.assertEquals("transform", test4, expected4.getArray(), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.transformFractionalCoordinates(Transfo * r m 3 ) ' */ @Test public void testTransformFractionalCoordinatesTransform3() { CMLAtom atom0 = new CMLAtom(); atom0.setXYZ3(new Point3(1.0, 2.0, 3.0)); atom0.setXYZFract(new Point3(0.1, 0.2, 0.3)); CMLTransform3 tr = new CMLTransform3(new double[] { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 }); CMLAtom atom = new CMLAtom(atom0); atom.transformFractionals(tr.getEuclidTransform3()); double[] test = new double[] { 1, 2, 3 }; Point3 expected = atom .getXYZ3(); // check no corruption Assert.assertNotNull("test should not be null (" + "transform" + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + "transform" + S_RBRAK, expected); DoubleTestBase.assertEquals("transform", test, expected.getArray(), EPS); double[] test1 = new double[] { 0.1, -0.2, -0.3 }; Point3 expected1 = atom.getXYZFract(); Assert.assertNotNull("test should not be null (" + "transform" + S_RBRAK, test1); Assert.assertEquals("must be of length 3", 3, test1.length); Assert.assertNotNull("ref should not be null (" + "transform" + S_RBRAK, expected1); DoubleTestBase.assertEquals("transform", test1, expected1.getArray(), EPS); tr = new CMLTransform3(new double[] { 1, 0, 0, 0.5, 0, -1, 0, 0.5, 0, 0, -1, 0.25, 0, 0, 0, 1 }); atom = new CMLAtom(atom0); atom.transformFractionals(tr.getEuclidTransform3()); double[] test2 = new double[] { 0.6, 0.3, -0.05 }; Point3 expected2 = atom.getXYZFract(); Assert.assertNotNull("test should not be null (" + "transform" + S_RBRAK, test2); Assert.assertEquals("must be of length 3", 3, test2.length); Assert.assertNotNull("ref should not be null (" + "transform" + S_RBRAK, expected2); DoubleTestBase.assertEquals("transform", test2, expected2.getArray(), EPS); tr = new CMLTransform3(new double[] { 1, 1, 0, 0.5, -1, 0, 0, 0.5, 0, 0, 1, 0.25, 0, 0, 0, 1 }); atom = new CMLAtom(atom0); atom.transformFractionals(tr.getEuclidTransform3()); double[] test3 = new double[] { 0.8, 0.4, 0.55 }; Point3 expected3 = atom.getXYZFract(); Assert.assertNotNull("test should not be null (" + "transform" + S_RBRAK, test3); Assert.assertEquals("must be of length 3", 3, test3.length); Assert.assertNotNull("ref should not be null (" + "transform" + S_RBRAK, expected3); DoubleTestBase.assertEquals("transform", test3, expected3.getArray(), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.overlap2DCentroids(CMLAtomSet)' */ @Test public void testOverlap2DCentroids() { CMLMolecule mol1 = new CMLMolecule(fixture.xmlMolecule); CMLAtomSet as1 = new CMLAtomSet(mol1); Real2 delta = atomSet1.overlap2DCentroids(as1); double[] test = new double[] { 2. / 3, 0 }; Assert.assertNotNull("test should not be null (" + "overlap centroid" + S_RBRAK, test); Assert.assertEquals("must be of length 2", 2, test.length); Assert.assertNotNull("ref should not be null (" + "overlap centroid" + S_RBRAK, delta); DoubleTestBase.assertEquals("overlap centroid", test, delta.getXY(), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.getDistanceMatrix(CMLAtomSet)' */ @Test public void testGetDistanceMatrix() { double s2 = Math.sqrt(2.); RealMatrix rm = atomSet1.getDistanceMatrix(atomSet2); double[] test = new double[] { s2, s2, s2, s2, 0.0, 2.0, 2 * s2, 2.0, 2.0, 0.0, 2.0, 2 * s2 }; Assert.assertNotNull("test should not be null (" + "distance matrix" + EC.S_RBRAK, test); Assert.assertNotNull("ref should not be null (" + "distance matrix" + EC.S_RBRAK, rm); Assert.assertEquals("rows should be equal (" + "distance matrix" + EC.S_RBRAK, 3, rm.getRows()); Assert.assertEquals("columns should be equal (" + "distance matrix" + EC.S_RBRAK, 4, rm.getCols()); DoubleTestBase.assertEquals("distance matrix", test, rm.getMatrixAsArray(), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.setChemicalElements(String)' */ @Test public void testSetChemicalElements() { atomSet1.setChemicalElements(AS.P.value); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.labelAtoms(String)' */ @Test public void testLabelAtoms() { // this labels all atoms in atomSet1 in xmlMolecule with child label atomSet1.labelAtoms("atomLabel"); CMLMolecule xmlMolecule = fixture.xmlMolecule; Assert.assertEquals("label", 1, xmlMolecule.getAtomById("a1") .getLabelElements().size()); Assert.assertEquals("label", 1, xmlMolecule.getAtomById("a2") .getLabelElements().size()); Assert.assertEquals("label", 1, xmlMolecule.getAtomById("a3") .getLabelElements().size()); Assert.assertEquals("label", 0, xmlMolecule.getAtomById("a4") .getLabelElements().size()); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.getMap(CMLAtomSet)' */ @Test public void testGetMap() { CMLAtomSet as1 = new CMLAtomSet(fixture.xmlMolecule, new String[] { "a1", "a2", "a3", "a4" }); CMLAtomSet as2 = new CMLAtomSet(fixture.xmlMolecule, new String[] { "a5", "a3", "a2", "a1" }); CMLMap m = as1.getMap(as2); Assert .assertEquals("map", 4, m.getChildCMLElements(CMLLink.TAG) .size()); CMLLink l1 = (CMLLink) m.getChildCMLElement(CMLLink.TAG, 0); Assert.assertEquals("link from", "a1", l1.getFrom()); Assert.assertEquals("link from", "a5", l1.getTo()); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.splitByElements()' */ @Test public void testSplitByElements() { Map map = atomSet2.splitByElements(); Assert.assertEquals("map", 4, map.size()); Assert .assertEquals("map", "a3", map.get(AS.S.value) .getStringContent()); Assert .assertEquals("map", "a4", map.get(AS.O.value) .getStringContent()); Assert .assertEquals("map", "a5", map.get(AS.F.value) .getStringContent()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.CMLAtomSet(List)' */ @Test public final void testCMLAtomSetListOfCMLAtom() { List atomList = new ArrayList(); atomList.add(fixture.xmlMolecule.getAtom(0)); atomList.add(fixture.xmlMolecule.getAtom(1)); CMLAtomSet atomSet = CMLAtomSet.createFromAtoms(atomList); Assert.assertEquals("atom set constructor", new String[] { "a1", "a2" }, atomSet.getXMLContent()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.CMLAtomSet(Set)' */ @Test public final void testCMLAtomSetSetOfCMLAtom() { Set atomSet = new HashSet(); atomSet.add(fixture.xmlMolecule.getAtom(0)); atomSet.add(fixture.xmlMolecule.getAtom(1)); CMLAtomSet atomSet1 = new CMLAtomSet(atomSet); Assert .assertNotNull("atom set constructor", atomSet1 .getAtomById("a1")); Assert.assertNull("atom set constructor", atomSet1.getAtomById("a3")); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.addAtoms(CMLAtom[])' */ @Test @Deprecated public final void testAddAtomsCMLAtomArray() { CMLAtomSet atomSet = new CMLAtomSet(); CMLAtom[] atoms = new CMLAtom[2]; atoms[0] = fixture.xmlMolecule.getAtom(0); atoms[1] = fixture.xmlMolecule.getAtom(1); atomSet.addAtoms(atoms); Assert.assertNotNull("atom set constructor", atomSet.getAtomById("a1")); Assert.assertNull("atom set constructor", atomSet.getAtomById("a3")); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.addAtoms(List)' */ @Test public final void testAddAtomsListOfCMLAtom() { CMLAtomSet atomSet = new CMLAtomSet(); List atomList = new ArrayList(); atomList.add(fixture.xmlMolecule.getAtom(0)); atomList.add(fixture.xmlMolecule.getAtom(1)); atomSet.addAtoms(atomList); Assert.assertNotNull("atom set constructor", atomSet.getAtomById("a1")); Assert.assertNull("atom set constructor", atomSet.getAtomById("a3")); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.getCoordinates3(CoordinateType)' */ @Test public final void testGetCoordinates3() { Point3Vector p3v = atomSet1.getCoordinates3(CoordinateType.CARTESIAN); Assert.assertEquals("point3vector", 3, p3v.size()); double[] test = new double[] { 0.0, 0.0, 0.0 }; Point3 expected = p3v.get(0); Assert.assertNotNull("test should not be null (" + "point3vector" + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + "point3vector" + S_RBRAK, expected); DoubleTestBase.assertEquals("point3vector", test, expected.getArray(), EPS); double[] test1 = new double[] { 1.0, 1.0, 1.0 }; Point3 expected1 = p3v.get(1); Assert.assertNotNull("test should not be null (" + "point3vector" + S_RBRAK, test1); Assert.assertEquals("must be of length 3", 3, test1.length); Assert.assertNotNull("ref should not be null (" + "point3vector" + S_RBRAK, expected1); DoubleTestBase.assertEquals("point3vector", test1, expected1.getArray(), EPS); double[] test2 = new double[] { 1.0, -1.0, -1.0 }; Point3 expected2 = p3v.get(2); Assert.assertNotNull("test should not be null (" + "point3vector" + S_RBRAK, test2); Assert.assertEquals("must be of length 3", 3, test2.length); Assert.assertNotNull("ref should not be null (" + "point3vector" + S_RBRAK, expected2); DoubleTestBase.assertEquals("point3vector", test2, expected2.getArray(), EPS); p3v = atomSet1.getCoordinates3(CoordinateType.FRACTIONAL); Assert.assertNull("point3vector", p3v); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.getCentroid3(CoordinateType)' */ @Test public final void testGetCentroid3() { Point3 cent = atomSet1.getCentroid3(CoordinateType.CARTESIAN); double[] test = new double[] { 2. / 3., 0.0, 0.0 }; Assert.assertNotNull("test should not be null (" + "centroid" + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + "centroid" + S_RBRAK, cent); DoubleTestBase.assertEquals("centroid", test, cent.getArray(), EPS); cent = atomSet1.getCentroid3(CoordinateType.FRACTIONAL); Assert.assertNull("centroid", cent); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.transform(Transform2)' */ @Test public final void testTransformTransform2() { List r2v = atomSet1.getVector2D(); Assert.assertEquals("real2vector", 3, r2v.size()); double[] test = new double[] { 0.0, 0.0 }; Real2 expected = r2v .get(0); Assert.assertNotNull("test should not be null (" + "real2vector" + S_RBRAK, test); Assert.assertEquals("must be of length 2", 2, test.length); Assert.assertNotNull("ref should not be null (" + "real2vector" + S_RBRAK, expected); DoubleTestBase.assertEquals("real2vector", test, expected.getXY(), EPS); double[] test1 = new double[] { 1.0, 1.0 }; Real2 expected1 = r2v .get(1); Assert.assertNotNull("test should not be null (" + "real2vector" + S_RBRAK, test1); Assert.assertEquals("must be of length 2", 2, test1.length); Assert.assertNotNull("ref should not be null (" + "real2vector" + S_RBRAK, expected1); DoubleTestBase.assertEquals("real2vector", test1, expected1.getXY(), EPS); double[] test2 = new double[] { 1.0, -1.0 }; Real2 expected2 = r2v .get(2); Assert.assertNotNull("test should not be null (" + "real2vector" + S_RBRAK, test2); Assert.assertEquals("must be of length 2", 2, test2.length); Assert.assertNotNull("ref should not be null (" + "real2vector" + S_RBRAK, expected2); DoubleTestBase.assertEquals("real2vector", test2, expected2.getXY(), EPS); Angle zrot = new Angle(Math.PI / 2.); Transform2 t = new Transform2(zrot); atomSet1.transform(t); r2v = atomSet1.getVector2D(); Assert.assertEquals("real2vector", 3, r2v.size()); double[] test3 = new double[] { 0.0, 0.0 }; Real2 expected3 = r2v .get(0); Assert.assertNotNull("test should not be null (" + "real2vector" + S_RBRAK, test3); Assert.assertEquals("must be of length 2", 2, test3.length); Assert.assertNotNull("ref should not be null (" + "real2vector" + S_RBRAK, expected3); DoubleTestBase.assertEquals("real2vector", test3, expected3.getXY(), EPS); double[] test4 = new double[] { 1.0, -1.0 }; Real2 expected4 = r2v .get(1); Assert.assertNotNull("test should not be null (" + "real2vector" + S_RBRAK, test4); Assert.assertEquals("must be of length 2", 2, test4.length); Assert.assertNotNull("ref should not be null (" + "real2vector" + S_RBRAK, expected4); DoubleTestBase.assertEquals("real2vector", test4, expected4.getXY(), EPS); double[] test5 = new double[] { -1.0, -1.0 }; Real2 expected5 = r2v .get(2); Assert.assertNotNull("test should not be null (" + "real2vector" + S_RBRAK, test5); Assert.assertEquals("must be of length 2", 2, test5.length); Assert.assertNotNull("ref should not be null (" + "real2vector" + S_RBRAK, expected5); DoubleTestBase.assertEquals("real2vector", test5, expected5.getXY(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.getMappedAtom(CMLMap, * CMLAtom, Direction)' */ @Test public final void testGetMappedAtom() { CMLMap map = new CMLMap(); CMLLink link = new CMLLink(); // from a1 to a3 link.setFrom("a1"); link.setTo("a3"); map.addLink(link); // from a2 to a1 link = new CMLLink(); link.setFrom("a2"); link.setTo("a1"); map.addLink(link); // a1 CMLAtom atom0 = atomSet1.getAtom(0); Assert.assertEquals("check atom", "a1", atom0.getId()); // a2 CMLAtom atom1 = atomSet1.getAtom(1); Assert.assertEquals("check atom", "a2", atom1.getId()); // to a1 Direction toFrom = Direction.TO; CMLAtom atom = atomSet1.getMappedAtom(map, atom0, toFrom); Assert.assertNotNull("mapped atom not null", atom); Assert.assertEquals("linked atom", "a2", atom.getId()); // from a1 toFrom = Direction.FROM; atom = atomSet1.getMappedAtom(map, atom0, toFrom); Assert.assertNotNull("mapped atom not null", atom); Assert.assertEquals("linked atom", "a3", atom.getId()); // to a2 toFrom = Direction.TO; atom = atomSet1.getMappedAtom(map, atom1, toFrom); Assert.assertNull("mapped atom null", atom); // to a2 toFrom = Direction.FROM; atom = atomSet1.getMappedAtom(map, atom1, toFrom); Assert.assertNotNull("mapped atom not null", atom); Assert.assertEquals("linked atom", "a1", atom.getId()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomSet.getMappedAtomSet(CMLMap, CMLAtomSet, * Direction)' */ @Test public final void testGetMappedAtomSet() { CMLMap map = new CMLMap(); CMLLink link = new CMLLink(); // from a1 to a3 link.setFrom("a1"); link.setTo("a3"); map.addLink(link); // from a2 to a1 link = new CMLLink(); link.setFrom("a2"); link.setTo("a1"); map.addLink(link); // to atomSet1 (a1, a2) Direction toFrom = Direction.TO; CMLAtomSet atomSet = atomSet1.getMappedAtomSet(map, atomSet1, toFrom); Assert.assertNotNull("mapped atomSet not null", atomSet); Assert.assertEquals("linked atomSet", new String[] { "a2", "a1" }, atomSet.getXMLContent()); // from atomSet1 (a1, a2) toFrom = Direction.FROM; atomSet = atomSet1.getMappedAtomSet(map, atomSet1, toFrom); Assert.assertNotNull("mapped atomSet not null", atomSet); Assert.assertEquals("linked atomSet", new String[] { "a3", "a1" }, atomSet.getXMLContent()); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.removeAtoms(CMLMap, * CMLAtomSet)' */ @Test public final void testRemoveAtomsCMLMapCMLAtomSet() { CMLMap map = new CMLMap(); CMLLink link = new CMLLink(); // from a1 to a3 link.setFrom("a1"); link.setTo("a3"); map.addLink(link); // from a2 to a1 link = new CMLLink(); link.setFrom("a2"); link.setTo("a1"); map.addLink(link); Assert.assertEquals("before remove", new String[] { "a2", "a3", "a4", "a5" }, atomSet2.getXMLContent()); atomSet2.removeAtoms(map, atomSet1); Assert.assertEquals("after remove", new String[] { "a3", "a4", "a5" }, atomSet2.getXMLContent()); } /** * Test method for 'org.xmlcml.cml.element.CMLAtomSet.removeAtoms(CMLMap, * Direction)' */ @Test public final void testRemoveAtomsCMLMapDirection() { CMLMap map = new CMLMap(); CMLLink link = new CMLLink(); // from a1 to a3 link.setFrom("a1"); link.setTo("a3"); map.addLink(link); // from a2 to a1 link = new CMLLink(); link.setFrom("a2"); link.setTo("a1"); map.addLink(link); Assert.assertEquals("before remove", new String[] { "a1", "a2", "a3" }, atomSet1.getXMLContent()); atomSet1.removeAtoms(map, atomSet2); Assert.assertEquals("before remove", new String[] { "a3" }, atomSet1 .getXMLContent()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLAtomTypeListTest.java000066400000000000000000000042621477224461000306050ustar00rootroot00000000000000/* Copyright 2023 Gowri Shankar K * * 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.main; import nu.xom.Element; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.element.CMLAtomTypeList; public class CMLAtomTypeListTest { @Test public void testCMLAtomTypeList() { CMLAtomTypeList cmlAtomTypeList = new CMLAtomTypeList(); Assert.assertNotNull("constructor: ", cmlAtomTypeList); cmlAtomTypeList.setAttribute("atom", "atomTypeList"); CMLAtomTypeList cmlAtomTypeList1 = new CMLAtomTypeList(cmlAtomTypeList); Assert.assertEquals("CMLAtomTypeList attributeValue should be atomTypeList: ", cmlAtomTypeList.getAttributeValue("atom"), cmlAtomTypeList1.getAttributeValue("atom")); } @Test public void testCMLAtomTypeListCopy() { CMLAtomTypeList cmlAtomTypeList = new CMLAtomTypeList(); cmlAtomTypeList.setAttribute("atom", "atomTypeList"); CMLAtomTypeList cmlAtomTypeList1 = new CMLAtomTypeList(cmlAtomTypeList); Element copy = cmlAtomTypeList1.copy(); Assert.assertEquals("class should be CMLAtomTypeList: ", copy.getClass(), CMLAtomTypeList.class); } @Test public void testCMLAtomTypeListMakeElementInContext() { Element current = new Element("cmLAtomTypeList"); CMLAtomTypeList factoryElement = new CMLAtomTypeList(); CMLElement newElement = factoryElement.makeElementInContext(current); Assert.assertEquals("class should be CMLAtomTypeList: ", newElement.getClass(), CMLAtomTypeList.class); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLAtomTypeTest.java000066400000000000000000000367521477224461000277620ustar00rootroot00000000000000/** * Copyright 2023 Sakshi Jain * * 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.main; import nu.xom.Element; import org.junit.Test; import org.xmlcml.cml.base.CMLAttribute; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.element.*; import static org.junit.Assert.*; public class CMLAtomTypeTest { @Test public void testCopy() { CMLAtomType cml = new CMLAtomType(); Element cmlCopy = cml.copy(); assertEquals("Class should be CMLAtomType: ", CMLAtomType.class, cmlCopy.getClass()); } @Test public void testMakeElementInContext() { CMLAtomType cml = new CMLAtomType(); CMLElement actual = cml.makeElementInContext(null); assertEquals("Class should be CMLAtomType: ", CMLAtomType.class, actual.getClass()); } @Test public void testGetNameAttributeWhenNameIsSet() { CMLAtomType cml = new CMLAtomType(); cml.setName("testName"); CMLAttribute expected = new CMLAttribute("name"); expected.setCMLValue("testName"); CMLAttribute actual = cml.getNameAttribute(); assertEquals("LocalName should be 'name': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testName': ", expected.getValue(), actual.getValue()); } @Test public void testGetNameAttributeWhenNameIsNotSet() { CMLAtomType cml = new CMLAtomType(); CMLAttribute expected = null; CMLAttribute actual = cml.getNameAttribute(); assertEquals("Name attribute should be null: ", expected, actual); } @Test public void testGetNameWhenNameIsSet() { CMLAtomType cml = new CMLAtomType(); cml.setName("testName"); String expected = "testName"; String actual = cml.getName(); assertEquals("Name should be 'testName': ", expected, actual); } @Test public void testGetNameWhenNameIsNotSet() { CMLAtomType cml = new CMLAtomType(); String expected = null; String actual = cml.getName(); assertEquals("Name should be null: ", expected, actual); } @Test public void testGetRefAttributeWhenRefIsSet() { CMLAtomType cml = new CMLAtomType(); cml.setRef("testRef"); CMLAttribute expected = new CMLAttribute("ref"); expected.setCMLValue("testRef"); CMLAttribute actual = cml.getRefAttribute(); assertEquals("LocalName should be 'ref': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testRef': ", expected.getValue(), actual.getValue()); } @Test public void testGetRefAttributeWhenRefIsNotSet() { CMLAtomType cml = new CMLAtomType(); CMLAttribute expected = null; CMLAttribute actual = cml.getRefAttribute(); assertEquals("Ref attribute should be null: ", expected, actual); } @Test public void testGetRefWhenRefIsSet() { CMLAtomType cml = new CMLAtomType(); cml.setRef("testRef"); String expected = "testRef"; String actual = cml.getRef(); assertEquals("Ref should be 'testRef': ", expected, actual); } @Test public void testGetRefWhenRefIsNotSet() { CMLAtomType cml = new CMLAtomType(); String expected = null; String actual = cml.getRef(); assertEquals("Ref should be null: ", expected, actual); } @Test public void testGetAtomRefAttributeWhenAtomRefIsSet() { CMLAtomType cml = new CMLAtomType(); cml.setAtomRef("testAtomRef"); CMLAttribute expected = new CMLAttribute("atomRef"); expected.setCMLValue("testAtomRef"); CMLAttribute actual = cml.getAtomRefAttribute(); assertEquals("LocalName should be 'atomRef': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testAtomRef': ", expected.getValue(), actual.getValue()); } @Test public void testGetAtomRefAttributeWhenAtomRefIsNotSet() { CMLAtomType cml = new CMLAtomType(); CMLAttribute expected = null; CMLAttribute actual = cml.getAtomRefAttribute(); assertEquals("AtomRef attribute should be null: ", expected, actual); } @Test public void testGetAtomRefWhenAtomRefIsSet() { CMLAtomType cml = new CMLAtomType(); cml.setAtomRef("testAtomRef"); String expected = "testAtomRef"; String actual = cml.getAtomRef(); assertEquals("AtomRef should be 'testAtomRef': ", expected, actual); } @Test public void testGetAtomRefWhenAtomRefIsNotSet() { CMLAtomType cml = new CMLAtomType(); String expected = null; String actual = cml.getAtomRef(); assertEquals("AtomRef should be null: ", expected, actual); } @Test public void testGetTitleAttributeWhenTitleIsSet() { CMLAtomType cml = new CMLAtomType(); cml.setTitle("testTitle"); CMLAttribute expected = new CMLAttribute("title"); expected.setCMLValue("testTitle"); CMLAttribute actual = cml.getTitleAttribute(); assertEquals("LocalName should be 'title': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testTitle': ", expected.getValue(), actual.getValue()); } @Test public void testGetTitleAttributeWhenTitleIsNotSet() { CMLAtomType cml = new CMLAtomType(); CMLAttribute expected = null; CMLAttribute actual = cml.getTitleAttribute(); assertEquals("Title attribute should be null: ", expected, actual); } @Test public void testGetTitleWhenTitleIsSet() { CMLAtomType cml = new CMLAtomType(); cml.setTitle("testTitle"); String expected = "testTitle"; String actual = cml.getTitle(); assertEquals("Title should be 'testTitle': ", expected, actual); } @Test public void testGetTitleWhenTitleIsNotSet() { CMLAtomType cml = new CMLAtomType(); String expected = null; String actual = cml.getTitle(); assertEquals("Title should be null: ", expected, actual); } @Test public void testGetIdAttributeWhenIdIsSet() { CMLAtomType cml = new CMLAtomType(); cml.setId("testId"); CMLAttribute expected = new CMLAttribute("id"); expected.setCMLValue("testId"); CMLAttribute actual = cml.getIdAttribute(); assertEquals("LocalName should be 'id': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testId': ", expected.getValue(), actual.getValue()); } @Test public void testGetIdAttributeWhenIdIsNotSet() { CMLAtomType cml = new CMLAtomType(); CMLAttribute expected = null; CMLAttribute actual = cml.getIdAttribute(); assertEquals("Id attribute should be null: ", expected, actual); } @Test public void testGetIdWhenIdIsSet() { CMLAtomType cml = new CMLAtomType(); cml.setId("testId"); String expected = "testId"; String actual = cml.getId(); assertEquals("Id value should be 'testId': ", expected, actual); } @Test public void testGetIdWhenIdIsNotSet() { CMLAtomType cml = new CMLAtomType(); String expected = null; String actual = cml.getId(); assertEquals("Id value should be null: ", expected, actual); } @Test public void testGetConventionAttributeWhenConventionIsSet() { CMLAtomType cml = new CMLAtomType(); cml.setConvention("testConvention"); CMLAttribute expected = new CMLAttribute("convention"); expected.setCMLValue("testConvention"); CMLAttribute actual = cml.getConventionAttribute(); assertEquals("LocalName should be 'convention': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'testConvention': ", expected.getValue(), actual.getValue()); } @Test public void testGetConventionAttributeWhenConventionIsNotSet() { CMLAtomType cml = new CMLAtomType(); CMLAttribute expected = null; CMLAttribute actual = cml.getConventionAttribute(); assertEquals("Convention attribute should be null: ", expected, actual); } @Test public void testGetConventionWhenConventionIsSet() { CMLAtomType cml = new CMLAtomType(); cml.setConvention("testConvention"); String expected = "testConvention"; String actual = cml.getConvention(); assertEquals("Convention value should be 'testConvention': ", expected, actual); } @Test public void testGetConventionWhenConventionIsNotSet() { CMLAtomType cml = new CMLAtomType(); String expected = null; String actual = cml.getConvention(); assertEquals("Convention value should be null: ", expected, actual); } @Test public void testGetDictRefAttributeWhenDictRefIsSet() { CMLAtomType cml = new CMLAtomType(); cml.setDictRef("test:dictRef"); CMLAttribute expected = new CMLAttribute("dictRef"); expected.setCMLValue("test:dictRef"); CMLAttribute actual = cml.getDictRefAttribute(); assertEquals("LocalName should be 'dictRef': ", expected.getLocalName(), actual.getLocalName()); assertEquals("Value should be 'test:dictRef': ", expected.getValue(), actual.getValue()); } @Test public void testGetDictRefAttributeWhenDictRefIsNotSet() { CMLAtomType cml = new CMLAtomType(); CMLAttribute expected = null; CMLAttribute actual = cml.getDictRefAttribute(); assertEquals("dictRef attribute should be null: ", expected, actual); } @Test public void testGetDictRefWhenDictRefIsSet() { CMLAtomType cml = new CMLAtomType(); cml.setDictRef("test:dictRef"); String expected = "test:dictRef"; String actual = cml.getDictRef(); assertEquals("dictRef value should be 'test:dictRef': ", expected, actual); } @Test public void testGetDictRefWhenDictRefIsNotSet() { CMLAtomType cml = new CMLAtomType(); String expected = null; String actual = cml.getDictRef(); assertEquals("dictRef value should be null: ", expected, actual); } @Test public void testAddMolecule() { CMLAtomType cml = new CMLAtomType(); cml.addMolecule(new CMLMolecule()); CMLElements actual = cml.getMoleculeElements(); assertEquals("Molecules list size should be 1: ", 1, actual.size()); } @Test public void testGetMoleculeElementsWhenNoMoleculesAdded() { CMLAtomType cml = new CMLAtomType(); CMLElements actual = cml.getMoleculeElements(); assertEquals("Molecules list size should be 0: ", 0, actual.size()); } @Test public void testAddAtom() { CMLAtomType cml = new CMLAtomType(); cml.addAtom(new CMLAtom()); CMLElements actual = cml.getAtomElements(); assertEquals("Atom list size should be 1: ", 1, actual.size()); } @Test public void testGetAtomElementsWhenNoAtomsAdded() { CMLAtomType cml = new CMLAtomType(); CMLElements actual = cml.getAtomElements(); assertEquals("Atom list size should be 0: ", 0, actual.size()); } @Test public void testAddLabel() { CMLAtomType cml = new CMLAtomType(); cml.addLabel(new CMLLabel()); CMLElements actual = cml.getLabelElements(); assertEquals("Label list size should be 1: ", 1, actual.size()); } @Test public void testGetLabelElementsWhenNoLabelsAdded() { CMLAtomType cml = new CMLAtomType(); CMLElements actual = cml.getLabelElements(); assertEquals("Label list size should be 0: ", 0, actual.size()); } @Test public void testAddScalar() { CMLAtomType cml = new CMLAtomType(); cml.addScalar(new CMLScalar()); CMLElements actual = cml.getScalarElements(); assertEquals("Scalars list size should be 1: ", 1, actual.size()); } @Test public void testGetScalarElementsWhenNoScalarsAdded() { CMLAtomType cml = new CMLAtomType(); CMLElements actual = cml.getScalarElements(); assertEquals("Scalars list size should be 0: ", 0, actual.size()); } @Test public void testAddArray() { CMLAtomType cml = new CMLAtomType(); cml.addArray(new CMLArray()); CMLElements actual = cml.getArrayElements(); assertEquals("Arrays list size should be 1: ", 1, actual.size()); } @Test public void testGetArrayElementsWhenNoArraysAdded() { CMLAtomType cml = new CMLAtomType(); CMLElements actual = cml.getArrayElements(); assertEquals("Arrays list size should be 0: ", 0, actual.size()); } @Test public void testAddMatrix() { CMLAtomType cml = new CMLAtomType(); cml.addMatrix(new CMLMatrix()); CMLElements actual = cml.getMatrixElements(); assertEquals("Matrix list size should be 1: ", 1, actual.size()); } @Test public void testGetMatrixElementsWhenNoMatrixAdded() { CMLAtomType cml = new CMLAtomType(); CMLElements actual = cml.getMatrixElements(); assertEquals("Matrix list size should be 0: ", 0, actual.size()); } @Test public void testAddProperty() { CMLAtomType cml = new CMLAtomType(); cml.addProperty(new CMLProperty()); CMLElements actual = cml.getPropertyElements(); assertEquals("Property list size should be 1: ", 1, actual.size()); } @Test public void testGetPropertyElementsWhenNoPropertyAdded() { CMLAtomType cml = new CMLAtomType(); CMLElements actual = cml.getPropertyElements(); assertEquals("Property list size should be 0: ", 0, actual.size()); } @Test public void testSetAttribute() { CMLAtomType cml = new CMLAtomType(); cml.setAttribute("name", "testName"); cml.setAttribute("title", "testTitle"); cml.setAttribute("id", "testId"); cml.setAttribute("convention", "testConvention"); cml.setAttribute("dictRef", "test:dictRef"); cml.setAttribute("ref", "testRef"); cml.setAttribute("atomRef", "testAtomRef"); assertEquals("Name should be 'testName': ", "testName", cml.getName()); assertEquals("Title should be 'testTitle': ", "testTitle", cml.getTitle()); assertEquals("Id should be 'testId': ", "testId", cml.getId()); assertEquals("Convention should be 'testConvention': ", "testConvention", cml.getConvention()); assertEquals("DictRef should be 'test:dictRef': ", "test:dictRef", cml.getDictRef()); assertEquals("Ref condition value should be 'testRef': ", "testRef", cml.getRef()); assertEquals("AtomRef condition value should be 'testAtomRef': ", "testAtomRef", cml.getAtomRef()); } }cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLAtomicBasisFunctionTest.java000077500000000000000000000056101477224461000321140ustar00rootroot00000000000000/** * 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.main; import java.util.List; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLAtomicBasisFunction; import org.xmlcml.cml.element.CMLBasisSet.Basis; import org.xmlcml.molutil.ChemicalElement.AS; /** test CMLAtomicBasisFunction */ public class CMLAtomicBasisFunctionTest { /** * Test method for * 'org.xmlcml.cml.element.CMLAtomicBasisFunction.CMLAtomicBasisFunction(int * , int, int, String, String, String)' */ @Test public void testCMLAtomicBasisFunctionIntIntIntStringStringString() { int l = 2; int m = 1; int n = 2; String lm = "xx"; String symbol = "px"; String atomRef = "a1"; CMLAtomicBasisFunction abf = new CMLAtomicBasisFunction(l, m, n, lm, symbol, atomRef); Assert.assertEquals("l", 2, abf.getL()); Assert.assertEquals("m", 1, abf.getM()); Assert.assertEquals("n", 2, abf.getN()); Assert.assertEquals("lm", "xx", abf.getLm()); Assert.assertEquals("symbol", "px", abf.getSymbol()); Assert.assertEquals("atomRef", "a1", abf.getAtomRef()); } /** * Test method for * 'org.xmlcml.cml.element.CMLAtomicBasisFunction.getABFList(CMLAtom, * Basis)' */ @Test public void testGetABFList() { CMLAtom atom = new CMLAtom(); atom.setId("a1"); atom.setElementType(AS.H.value); List abfList = CMLAtomicBasisFunction .getABFList(atom, Basis.MINIMAL); Assert.assertEquals(AS.H.value, 1, abfList.size()); Assert.assertEquals("H1", "1s(s)(null)", abfList.get(0).getString()); atom.setElementType(AS.C.value); abfList = CMLAtomicBasisFunction.getABFList(atom, Basis.MINIMAL); Assert.assertEquals(AS.C.value, 4, abfList.size()); Assert.assertEquals("C1", "2s(s)(null)", abfList.get(0).getString()); Assert.assertEquals("C2", "2px(px)(null)", abfList.get(1).getString()); Assert.assertEquals("C3", "2py(py)(null)", abfList.get(2).getString()); Assert.assertEquals("C4", "2pz(pz)(null)", abfList.get(3).getString()); atom.setElementType("Q"); abfList = CMLAtomicBasisFunction.getABFList(atom, Basis.MINIMAL); Assert.assertEquals("Q", 0, abfList.size()); } /** * run tests. * * @return the suite. * */ } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLBandListTest.java000066400000000000000000000040371477224461000277070ustar00rootroot00000000000000/* Copyright 2023 Gowri Shankar K * * 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.main; import nu.xom.Element; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.element.CMLBandList; public class CMLBandListTest { @Test public void testCMLBandList() { CMLBandList cmlBandList = new CMLBandList(); Assert.assertNotNull("constructor: ", cmlBandList); cmlBandList.setAttribute("band", "bandList"); CMLBandList cmlBandList1 = new CMLBandList(cmlBandList); Assert.assertEquals("CMLBandList attributeValue should be bandList: ", cmlBandList.getAttributeValue("band"), cmlBandList1.getAttributeValue("band")); } @Test public void testCMLBandListCopy() { CMLBandList cmlBandList = new CMLBandList(); cmlBandList.setAttribute("band", "bandList"); CMLBandList cmlBandList1 = new CMLBandList(cmlBandList); Element copy = cmlBandList1.copy(); Assert.assertEquals("class should be CMLBandList: ", copy.getClass(), CMLBandList.class); } @Test public void testCMLBandListMakeElementInContext() { Element current = new Element("cmlYaxis"); CMLBandList factoryElement = new CMLBandList(); CMLElement newElement = factoryElement.makeElementInContext(current); Assert.assertEquals("class should be CMLBandList: ", newElement.getClass(), CMLBandList.class); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLBandTest.java000066400000000000000000000036421477224461000270540ustar00rootroot00000000000000/* Copyright 2023 Gowri Shankar K * * 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.main; import nu.xom.Element; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.element.CMLBand; public class CMLBandTest { @Test public void testCMLBand() { CMLBand cmlBand = new CMLBand(); Assert.assertNotNull("constructor: ", cmlBand); cmlBand.setAttribute("band", "bandValue"); CMLBand cmlBand1 = new CMLBand(cmlBand); Assert.assertEquals("CMLBand attributeValue should be bandValue: ", cmlBand.getAttributeValue("band"), cmlBand1.getAttributeValue("band")); } @Test public void testCMLBandCopy() { CMLBand cmlBand = new CMLBand(); cmlBand.setAttribute("band", "BandValue"); CMLBand cmlBand1 = new CMLBand(cmlBand); Element copy = cmlBand1.copy(); Assert.assertEquals("class should be CMLBand: ", copy.getClass(), CMLBand.class); } @Test public void testCMLBandMakeElementInContext() { Element current = new Element("cmlYaxis"); CMLBand factoryElement = new CMLBand(); CMLElement newElement = factoryElement.makeElementInContext(current); Assert.assertEquals("class should be CMLBand: ", newElement.getClass(), CMLBand.class); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLBasisSetTest.java000077500000000000000000000275561477224461000277420ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.base.CMLConstants.XSD_DOUBLE; import static org.xmlcml.euclid.EuclidConstants.EPS; import java.util.List; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLArray; import org.xmlcml.cml.element.CMLAtomicBasisFunction; import org.xmlcml.cml.element.CMLBasisSet; import org.xmlcml.cml.element.CMLEigen; import org.xmlcml.cml.element.CMLMatrix; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.CMLBasisSet.Basis; import org.xmlcml.euclid.EuclidConstants; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.RealArray; import org.xmlcml.euclid.test.DoubleTestBase; /** */ public class CMLBasisSetTest { String basisSetS = ""; CMLBasisSet basisSet = null; String moleculeS = "" + "" + " " + " " + " " + " " + " " + " " + ""; CMLMolecule molecule; String basisSetS2 = "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""; CMLBasisSet basisSet2; String coefficientS = "" + "" + " -37.90004 -20.34372 -13.10423 -12.71709 -12.07969 -7.47084" + " -3.44820 -1.14406 -.70572 .56580" + "" + "" + " -.08645 -.30627 .28127 .21650 .00000 .51104" + " .00000 .54076 .43797 .16535" + " -.38651 -.67196 .19755 .00002 .00000 .00000" + " .00000 -.58544 .00009 .13159" + " -.12937 .05529 -.29019 -.38339 .00000 -.38138" + " .00000 .02479 .63431 .44787" + " .19522 -.08345 .43789 -.25407 .00000 -.25274" + " .00000 -.03716 .42046 -.67572" + " .00000 .00000 .00000 .00000 .37511 .00000" + " .92698 .00000 .00000 .00000" + " -.08646 -.30626 .28121 -.21652 .00000 -.51109" + " .00000 .54056 -.43824 .16523" + " -.86876 .41200 .13042 .00000 .00000 .00001" + " .00000 .09466 .00001 -.22256" + " .08917 .23508 .39444 -.69478 .00000 .43176" + " .00000 -.13723 -.16033 .25987" + " -.13456 -.35475 -.59518 -.46042 .00000 .28617" + " .00000 .20700 -.10623 -.39217" + " .00000 .00000 .00000 .00000 .92698 .00000" + " -.37511 .00000 .00000 .00000" + "" + ""; CMLEigen coefficients = null; /** */ /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { molecule = (CMLMolecule)CMLXOMTestUtils.parseValidString(moleculeS); basisSet = new CMLBasisSet(); basisSet2 = (CMLBasisSet)CMLXOMTestUtils.parseValidString(basisSetS2); } /** * * Test method for * 'org.xmlcml.cml.element.CMLBasisSet.CMLBasisSet(CMLBasisSet)' */ @Test public void testCMLBasisSetCMLBasisSet() { CMLBasisSet basisSet1 = new CMLBasisSet(basisSet); Assert.assertNotNull("copy", basisSet1); } /** * * Test method for 'org.xmlcml.cml.element.CMLBasisSet.getABFsByL(int)' */ @Test public void testGetABFsByL() { List abfList = basisSet2.getABFsByL(1); Assert.assertEquals("getByL", 6, abfList.size()); Assert.assertEquals("getByL", "a4", abfList.get(1).getId()); abfList = basisSet2.getABFsByL(0); Assert.assertEquals("getByL", 4, abfList.size()); Assert.assertEquals("getByL", "a7", abfList.get(3).getId()); abfList = basisSet2.getABFsByL(2); Assert.assertEquals("getByL", 0, abfList.size()); } /** * * Test method for 'org.xmlcml.cml.element.CMLBasisSet.getABFsByN(int)' */ @Test public void testGetABFsByN() { List abfList = basisSet2.getABFsByN(1); Assert.assertEquals("getByN", 2, abfList.size()); Assert.assertEquals("getByN", "a6", abfList.get(1).getId()); abfList = basisSet2.getABFsByN(2); Assert.assertEquals("getByN", 8, abfList.size()); Assert.assertEquals("getByN", "a3", abfList.get(1).getId()); abfList = basisSet2.getABFsByN(0); Assert.assertEquals("getByN", 0, abfList.size()); } /** * Test method for 'org.xmlcml.cml.element.CMLBasisSet.getABFsByLM(String)' */ @Test public void testGetABFsByLM() { List abfList = basisSet2.getABFsByLM("s"); Assert.assertEquals("getByLM", 4, abfList.size()); Assert.assertEquals("getByLM", "a2", abfList.get(1).getId()); abfList = basisSet2.getABFsByLM("px"); Assert.assertEquals("getByLM", 2, abfList.size()); Assert.assertEquals("getByLM", "a8", abfList.get(1).getId()); abfList = basisSet2.getABFsByLM("z"); Assert.assertEquals("getByLM", 0, abfList.size()); } /** * * Test method for * 'org.xmlcml.cml.element.CMLBasisSet.getABFsBySymbol(String)' */ @Test public void testGetABFsBySymbol() { List abfList = basisSet2.getABFsBySymbol("S"); Assert.assertEquals("getBySymbol", 4, abfList.size()); Assert.assertEquals("getBySymbol", "a2", abfList.get(1).getId()); abfList = basisSet2.getABFsBySymbol("PX"); Assert.assertEquals("getBySymbol", 2, abfList.size()); Assert.assertEquals("getBySymbol", "a8", abfList.get(1).getId()); abfList = basisSet2.getABFsBySymbol("s"); Assert.assertEquals("getBySymbol", 0, abfList.size()); } /** * * Test method for * 'org.xmlcml.cml.element.CMLBasisSet.setAtomicOrbitalCoefficients(CMLEigen * ) ' */ @Test public void testSetMolecularOrbitalCoefficients() { setCoefficients(); CMLArray values = coefficients.getArrayElements().get(0); Assert.assertNotNull("values", values); Assert.assertEquals("values type", XSD_DOUBLE, values.getDataType()); double[] vv = values.getDoubles(); Assert.assertEquals("values size", 10, vv.length); CMLMatrix vectors = coefficients.getMatrixElements().get(0); Assert.assertNotNull("vectors", vectors); Assert.assertEquals("vectors type", XSD_DOUBLE, vectors.getDataType()); double[][] mm = vectors.getDoubleMatrix(); Assert.assertNotNull("double matrix not null", mm); Assert.assertEquals("vectors size", 10, mm.length); Assert.assertEquals("vectors size", 10, mm[0].length); } private void setCoefficients() { try { coefficients = (CMLEigen) new CMLBuilder() .parseString(coefficientS); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } basisSet2.setMolecularOrbitalCoefficients(coefficients); } /** * * Test method for 'org.xmlcml.cml.element.CMLBasisSet.CMLBasisSet(Basis, * CMLMolecule)' */ @Test public void testBasisSetBasisCMLMolecule() { CMLBasisSet basisSet = new CMLBasisSet(Basis.MINIMAL, molecule); Assert.assertNotNull("basisSet not null", basisSet); } /** * * Test method for * 'org.xmlcml.cml.element.CMLBasisSet.getElectronCount(Basis)' */ @Test public void testGetElectronCount() { basisSet2.setBasis(Basis.MINIMAL); basisSet2.setMolecule(molecule); int nElectrons = basisSet2.getElectronCount(); Assert.assertEquals("electron", 12, nElectrons); molecule.setFormalCharge(-1); basisSet2.setMolecule(molecule); nElectrons = basisSet2.getElectronCount(); Assert.assertEquals("electron", 13, nElectrons); } /** * testFindHOMO() */ @Test public void testFindHOMO() { basisSet2.setBasis(Basis.MINIMAL); basisSet2.setMolecule(molecule); int nElectrons = basisSet2.getElectronCount(); Assert.assertEquals("electrons", 12, nElectrons); int homo = nElectrons / 2 - 1; Assert.assertEquals("orbitals", 5, homo); setCoefficients(); RealArray homoVector = null; try { homoVector = coefficients.getEigenvector(homo); } catch (RuntimeException e) { throw new EuclidRuntimeException("should never throw " + e); } double[] test = new double[] { 0.51104, 0.0, -0.38138, -0.25274, 0.0, -0.51109, 1.0E-5, 0.43176, 0.28617, 0.0 }; Assert.assertNotNull("test should not be null (" + "homo vector" + EuclidConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + "homo vector" + EuclidConstants.S_RBRAK, homoVector); Assert.assertEquals("must be of equal length ", test.length, homoVector .getArray().length); DoubleTestBase.assertEquals("homo vector", test, homoVector.getArray(), EPS); } /** * tests getString() * */ @Test public void testGetString() { basisSet2.setBasis(Basis.MINIMAL); basisSet2.setMolecule(molecule); Assert.assertEquals("basis set string", "basis: MINIMAL\n" + "1s(S)(a1)\n" + "2s(S)(a2)\n" + "2px(PX)(a3)\n" + "2py(PY)(a4)\n" + "2pz(PZ)(a5)\n" + "1s(S)(a6)\n" + "2s(S)(a7)\n" + "2px(PX)(a8)\n" + "2py(PY)(a9)\n" + "2pz(PZ)(a10)", basisSet2.getString()); } /** * Test method for 'org.xmlcml.cml.element.CMLBasisSet.CMLBasisSet(Basis, * CMLMolecule)' */ @Test public void testCMLBasisSetBasisCMLMolecule() { // doesn't need testing as only sets variables } /** * Test method for 'org.xmlcml.cml.element.CMLBasisSet.getABFsByM(int)' */ @Test public void testGetABFsByM() { // don't think this is working List abfList = basisSet2.getABFsByM(1); Assert.assertEquals("getByM", 0, abfList.size()); // Assert.assertEquals("getByM", "a2", abfList.get(1).getId()); abfList = basisSet2.getABFsByM(0); Assert.assertEquals("getByM", 0, abfList.size()); // Assert.assertEquals("getByM", "a8", abfList.get(1).getId()); } /** * Test method for 'org.xmlcml.cml.element.CMLBasisSet.setBasis(Basis)' */ @Test public void testSetBasis() { // doesn't need testing as only sets variables } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLBondSetTest.java000077500000000000000000000337701477224461000275560ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.euclid.EuclidConstants.S_EMPTY; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLAtomSet; import org.xmlcml.cml.element.CMLBond; import org.xmlcml.cml.element.CMLBondSet; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.test.StringTestBase; /** * test BondSet. * * @author pmr * */ public class CMLBondSetTest { MoleculeAtomBondFixture fixture = new MoleculeAtomBondFixture(); CMLBondSet bondSet = null; CMLBondSet bondSet1 = null; CMLBondSet bondSet2 = null; CMLBondSet bondSet3 = null; CMLBondSet bondSet4 = null; List bonds = null; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { bondSet = new CMLBondSet(fixture.xmlMolecule); bonds = fixture.xmlMolecule.getBonds(); } private void makeBondSet12() { List bonds1 = fixture.xmlMolecule.getBonds(); List bonds2 = fixture.xmlMolecule.getBonds(); bonds1.remove(1); bonds2.remove(2); bondSet1 = new CMLBondSet(bonds1); bondSet2 = new CMLBondSet(bonds2); } private void makeBondSet34() { List bonds3 = fixture.xmlMolecule.getBonds(); List bonds4 = fixture.xmlMolecule.getBonds(); bonds3.remove(0); bonds3.remove(1); bonds4.remove(3); bonds4.remove(2); bondSet3 = new CMLBondSet(bonds3); bondSet4 = new CMLBondSet(bonds4); } /** * Test method for * 'org.xmlcml.cml.element.CMLBondSet.CMLBondSet(CMLMolecule)' */ @Test public void testCMLBondSetCMLMolecule() { Assert.assertEquals("bondSet size ", 4, bondSet.size()); Assert.assertEquals("bondSet content", "b1 b2 b3 b4", bondSet .getStringContent()); Assert.assertEquals("bondSet content", new String[] { "b1", "b2", "b3", "b4" }, bondSet.getXMLContent()); } /** * Test method for 'org.xmlcml.cml.element.CMLBondSet.CMLBondSet(CMLBond[])' */ @Test public void testCMLBondSetCMLBondArray() { Assert.assertEquals("bonds size ", 4, bonds.size()); bonds.remove(2); Assert.assertEquals("bonds size ", 3, bonds.size()); CMLBondSet bondSet = new CMLBondSet((CMLBond[]) bonds .toArray(new CMLBond[0])); Assert.assertEquals("bond set size ", 3, bondSet.size()); List bonds1 = bondSet.getBonds(); Assert.assertEquals("bonds size ", 3, bonds1.size()); Assert.assertEquals("bond ids", "b1 b2 b4", bondSet.getStringContent()); } /** * Test method for 'org.xmlcml.cml.element.CMLBondSet.addBonds(CMLBond[])' */ @Test public void testAddBonds() { bondSet = new CMLBondSet((CMLBond[]) bonds.toArray(new CMLBond[0])); } /** * Test method for 'org.xmlcml.cml.element.CMLBondSet.addBond(CMLBond)' */ @Test public void testAddBond() { bondSet = new CMLBondSet(); bondSet.addBond(bonds.get(0)); Assert.assertEquals("bond set size", 1, bondSet.size()); Assert.assertEquals("bond set ", "b1", bondSet.getStringContent()); bondSet.addBond(bonds.get(2)); Assert.assertEquals("bond set size", 2, bondSet.size()); Assert.assertEquals("bond set ", "b1 b3", bondSet.getStringContent()); try { String id = bonds.get(0).getId(); Assert.assertNotNull("id ", id); bondSet.addBond(bonds.get(0)); Assert.fail("should throw duplicate bond exception"); } catch (RuntimeException e) { Assert.assertEquals("duplicate bond ", "duplicate bond in bondSet: b1", e.getMessage()); } } /** * Test method for * 'org.xmlcml.cml.element.CMLBondSet.addBondSet(CMLBondSet)' */ @Test public void testAddBondSet() { CMLBondSet bondSet1 = null; try { bondSet1 = bondSet.getBondsById(new String[] { "b2", "b4" }); } catch (RuntimeException e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertEquals("bondset1", 2, bondSet1.size()); CMLBondSet bondSet2 = null; try { bondSet2 = bondSet.getBondsById(new String[] { "b3" }); } catch (RuntimeException e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertEquals("bondset2", 1, bondSet2.size()); bondSet1.addBondSet(bondSet2); Assert.assertEquals("bondset2", 3, bondSet1.size()); try { bondSet1.addBondSet(bondSet2); Assert.fail("should throw duplicate bond "); } catch (RuntimeException e) { Assert.assertEquals("duplicate bond", "duplicate bond in bondSet: b3", S_EMPTY + e.getMessage()); } Assert.assertEquals("bondset2", 3, bondSet1.size()); } /** * Test method for 'org.xmlcml.cml.element.CMLBondSet.getBonds()' */ @Test public void testGetBonds() { Assert.assertEquals("bonds", 4, bonds.size()); } /** * Test method for 'org.xmlcml.cml.element.CMLBondSet.contains(CMLBond)' */ @Test public void testContains() { Assert.assertTrue("contains ", bondSet.contains(bonds.get(0))); } /** * Test method for 'org.xmlcml.cml.element.CMLBondSet.size()' */ @Test public void testSize() { Assert.assertEquals("size ", 4, bondSet.size()); } /** * Test method for 'org.xmlcml.cml.element.CMLBondSet.getBondIDs()' */ @Test public void testGetBondIDs() { List bondIds = bondSet.getBondIDs(); Assert.assertEquals("bond ids ", 4, bondIds.size()); Assert.assertEquals("bond id", "b2", bondIds.get(1)); } /** * Test method for * 'org.xmlcml.cml.element.CMLBondSet.getBondsById(String[])' */ @Test public void testGetBondsById() { CMLBondSet bondSet1 = bondSet.getBondsById(new String[] { "b3", "b1" }); Assert.assertEquals("bonds by id", 2, bondSet1.size()); Assert .assertEquals("bond id", "b3", bondSet1.getBonds().get(0) .getId()); Assert .assertEquals("bond id", "b1", bondSet1.getBonds().get(1) .getId()); } /** * Test method for 'org.xmlcml.cml.element.CMLBondSet.getBondById(String)' */ @Test public void testGetBondById() { CMLBond bond = bondSet.getBondById("b2"); Assert.assertNotNull("bond by id", bond); Assert.assertEquals("bond by id", "b2", bond.getId()); bond = bondSet.getBondById("b6"); Assert.assertNull("bond by id", bond); } /** * Test method for 'org.xmlcml.cml.element.CMLBondSet.copy()' */ @Test public void testCopy() { CMLBondSet bondSet1 = (CMLBondSet) bondSet.copy(); StringTestBase.assertEquals("copy", bondSet1.getXMLContent(), bondSet .getXMLContent()); } /** * Test method for 'org.xmlcml.cml.element.CMLBondSet.addBonds(CMLBond[])' */ @Test public void testAddBondsCMLBondArray() { CMLBond[] bonds = new CMLBond[2]; bonds[0] = new CMLBond(); bonds[0].setId("b10"); String msg = "no atomRefs2 attribute"; // this contaminates the bonds try { bondSet.addBonds(bonds); Assert.fail("should throw no atomRefs2 attribute"); } catch (RuntimeException e) { Assert.assertEquals("no atomRefs2", msg, e.getMessage()); } // clear bonds try { setUp(); } catch (Exception e1) { Assert.fail("should never throw " + e1); } bonds[0].setAtomRefs2(new String[] { "a2", "a3" }); bonds[1] = new CMLBond(); bonds[1].setId("b11"); bonds[1].setAtomRefs2(new String[] { "a2", "a4" }); bondSet.addBonds(bonds); Assert.assertEquals("new bondSet", new String[] { "b1", "b2", "b3", "b4", "b10", "b11" }, bondSet.getXMLContent()); } /** * Test method for * 'org.xmlcml.cml.element.CMLBondSet.addBonds(List)' */ @Test public void testAddBondsListOfCMLBond() { List bonds = new ArrayList(); CMLBond bond = new CMLBond(); bonds.add(bond); bond.setId("b10"); String msg = "no atomRefs2 attribute"; // this contaminates the bonds try { bondSet.addBonds(bonds); Assert.fail("should throw no atomRefs2 attribute"); } catch (RuntimeException e) { Assert.assertEquals("no atomRefs2", msg, e.getMessage()); } // clear bonds try { setUp(); } catch (Exception e1) { Assert.fail("should never throw " + e1); } bond.setAtomRefs2(new String[] { "a2", "a3" }); bond = new CMLBond(); bond.setId("b11"); bond.setAtomRefs2(new String[] { "a2", "a4" }); bonds.add(bond); try { bondSet.addBonds(bonds); } catch (RuntimeException e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertEquals("new bondSet", new String[] { "b1", "b2", "b3", "b4", "b10", "b11" }, bondSet.getXMLContent()); } /** * create from bonds. */ @Test public final void testCMLBondSetListOfCMLBond() { fixture.makeMol5a(); List bondList = fixture.mol5a.getBonds(); Assert.assertEquals("mol5a bonds", 4, bondList.size()); CMLBondSet bondSet = null; bondSet = new CMLBondSet(bondList); Assert.assertEquals("mol5a bondSet", 4, bondSet.size()); CMLBond bond1 = bondList.get(1); CMLBond bond2 = bondList.get(2); Assert.assertTrue("mol5a bonds", bondSet.contains(bond1)); Assert.assertTrue("mol5a bonds", bondSet.contains(bond2)); bondList.remove(bondList.get(2)); Assert.assertEquals("mol5a bonds", 3, bondList.size()); bondSet = new CMLBondSet(bondList); Assert.assertEquals("mol5a bondSet", 3, bondSet.size()); Assert.assertTrue("mol5a bonds", bondSet.contains(bond1)); Assert.assertFalse("mol5a bonds", bondSet.contains(bond2)); } /** * test constructor. */ @Test public final void testCMLBondSetCMLMoleculeStringArray() { CMLBondSet bondSetx = new CMLBondSet(fixture.xomMolecule, new String[] { "b1", "b3" }); Assert.assertEquals("bond set b1 b3", 2, bondSetx.size()); } /** * test. */ @Test public final void testGetBond() { CMLBond bond = bondSet.getBond(2); Assert.assertNotNull("get bond", bond); Assert.assertEquals("get bond", "b3", bond.getId()); bond = bondSet.getBond(4); Assert.assertNull("get bond", bond); } /** * test. */ @Test public final void testGetAtomSet() { CMLAtomSet atomSet = bondSet.getAtomSet(); Assert.assertNotNull("get atomSet", atomSet); Assert.assertEquals("get atomSet", 5, atomSet.size()); List atoms = atomSet.getAtoms(); Assert.assertEquals(" atomSet 1", "a1", atoms.get(0).getId()); Assert.assertEquals(" atomSet 1", "a5", atoms.get(4).getId()); } /** * test. */ @Test public final void testHasContentEqualTo() { Assert.assertTrue("equality", bondSet.hasContentEqualTo(bondSet)); } /** * test. */ @Test public final void testComplement() { makeBondSet12(); CMLBondSet bondSetx = bondSet1.complement(bondSet2); Assert.assertEquals("complement", 1, bondSetx.size()); Assert.assertEquals("complement", "b3", bondSetx.getBonds().get(0) .getId()); bondSetx = bondSet2.complement(bondSet1); Assert.assertEquals("complement", 1, bondSetx.size()); Assert.assertEquals("complement", "b2", bondSetx.getBonds().get(0) .getId()); } /** * test. */ @Test public final void testUnion() { makeBondSet12(); makeBondSet34(); CMLBondSet bondSetx = bondSet1.union(bondSet2); Assert.assertEquals("union", 4, bondSetx.size()); bondSetx = bondSet3.union(bondSet4); Assert.assertEquals("union", 3, bondSetx.size()); // fragile Assert.assertEquals("complement", "b2", bondSetx.getBonds().get(0) .getId()); Assert.assertEquals("complement", "b4", bondSetx.getBonds().get(1) .getId()); Assert.assertEquals("complement", "b1", bondSetx.getBonds().get(2) .getId()); } /** * test. */ @Test public final void testSymmetricDifference() { makeBondSet12(); makeBondSet34(); CMLBondSet bondSetx = null; bondSetx = bondSet1.symmetricDifference(bondSet2); Assert.assertEquals("symmetricDifference", 2, bondSetx.size()); Assert.assertEquals("complement", "b3", bondSetx.getBonds().get(0) .getId()); Assert.assertEquals("complement", "b2", bondSetx.getBonds().get(1) .getId()); bondSetx = bondSet3.symmetricDifference(bondSet4); Assert.assertEquals("symmetricDifference", 2, bondSetx.size()); // fragile Assert.assertEquals("complement", "b4", bondSetx.getBonds().get(0) .getId()); Assert.assertEquals("complement", "b1", bondSetx.getBonds().get(1) .getId()); } /** * test. */ @Test public final void testGetMolecule() { CMLMolecule molecule = bondSet.getMolecule(); Assert.assertNotNull("get molecule", molecule); Assert.assertEquals("get molecule", fixture.xmlMolecule, molecule); } /** * tests equality against list of ids. (order of elements in set is * undefined) * * @param message * @param expectedBondIds * @param bondSet */ public static void assertEquals(String message, String[] expectedBondIds, CMLBondSet bondSet) { Assert.assertEquals(message + "; unequal sizes; expected " + expectedBondIds.length + ", found: " + bondSet.size(), expectedBondIds.length, bondSet.size()); Set expectedSet = new HashSet(); for (String es : expectedBondIds) { expectedSet.add(es); } Set foundSet = new HashSet(); List fss = bondSet.getBondIDs(); for (String fs : fss) { foundSet.add(fs); } Assert.assertTrue("compare atom sets", expectedSet.equals(foundSet)); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLBuilderTest.java000077500000000000000000000115441477224461000276010ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.element.main.AbstractTestBase.COMPLEX_RESOURCE; import java.io.InputStream; import junit.framework.Assert; import nu.xom.NodeFactory; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.Util; /** * test CMLBuilder routines. * * @author pm286 * */ public class CMLBuilderTest { /** * Test method for 'org.xmlcml.cml.element.CMLBuilder.CMLBuilder(boolean, * NodeFactory)' */ @Test public void testCMLBuilderBooleanNodeFactory() { // fails because default CMLBuilder uses OldNodeFactory // to validate element names String s = CMLConstants.S_EMPTY + "" + "" + ""; try { new CMLBuilder().parseString(s); Assert.fail("should throw: Unknown CML element: inchi"); } catch (Exception e) { // OK } // succeeds with ordinary NodeFactory // to validate element names CMLBuilder builder = new CMLBuilder(new NodeFactory()); try { builder.parseString(s); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } // // fails because XOM validation requires a DOCTYPE // boolean validate = true; // builder = new CMLBuilder(validate, new NodeFactory()); // try { // builder.parseString(s); // Assert.fail("should throw: Unknown CML element: inchi"); // } catch (Exception e) { // Assert // .assertEquals( // "OldNodeFactory validation", // "Document root element \"cml\", must match DOCTYPE root \"null\".", // e.getMessage()); // } // // fails through OldNodeFactory validation // validate = true; // builder = new CMLBuilder(validate, CMLNodeFactory.nodeFactory); // try { // builder.parseString(s); // Assert.fail("should throw: Unknown CML element: inchi"); // } catch (Exception e) { // // OK // } } /** * Test method for 'org.xmlcml.cml.element.CMLBuilder.parseString(String)' */ @Test public void testParseString() { // parse, validation by OldNodeFactory String s = CMLConstants.S_EMPTY + "" + ""; CMLBuilder builder = new CMLBuilder(); try { builder.parseString(s); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } // parse, validation by OldNodeFactory s = CMLConstants.S_EMPTY + "" + "" + ""; builder = new CMLBuilder(); try { builder.parseString(s); } catch (Exception e) { // OK } // // parse against DOCTYPE (tests XOM DTD validation) // s = "" // + "" + "]>" + "" + "" + ""; // boolean validate = true; // builder = new CMLBuilder(validate, new NodeFactory()); // try { // builder.parseString(s); // Assert // .fail("Should throw: Element type \"inchi\" must be declared."); // } catch (Exception e) { // Assert.assertEquals("missing element in doctype", // "Element type \"inchi\" must be declared.", e.getMessage()); // } } /** * Test method for 'org.xmlcml.cml.element.CMLBuilder.build(File)' */ @Test public void testBuildFile() { CMLBuilder builder = new CMLBuilder(); InputStream in = null; try { in = Util.getInputStreamFromResource(COMPLEX_RESOURCE +CMLConstants.U_S + "castep2.xml"); builder.build(in); in.close(); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } // fails because XOM can only validate against a DOCTYPE // and this file has a schema boolean validate = true; builder = new CMLBuilder(validate); try { in = Util.getInputStreamFromResource(COMPLEX_RESOURCE +CMLConstants.U_S + "castep2.xml"); builder.build(in); in.close(); } catch (Exception e) { Assert .assertEquals( "OldNodeFactory validation", "Document root element \"cml\", must match DOCTYPE root \"null\".", e.getMessage()); } } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLCellParameterTest.java000077500000000000000000000267311477224461000307370ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.base.CMLConstants.U_ANGSTROM; import static org.xmlcml.cml.base.CMLConstants.U_DEGREE; import static org.xmlcml.cml.base.CMLConstants.XSD_DOUBLE; import static org.xmlcml.euclid.EuclidConstants.EPS; import java.util.ArrayList; import java.util.List; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.attribute.IdAttribute; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLCellParameter; import org.xmlcml.cml.element.CMLCrystal; import org.xmlcml.cml.element.CMLScalar; import org.xmlcml.euclid.test.DoubleTestBase; /** * test for CellParameter. * * @author pmr * */ public class CMLCellParameterTest { CMLCrystal crystal1; String crystal1S = "" + "" + "4.500 5.500 6.500" + "45.00 55.00 65.00" + "" + "" + ""; CMLElements cellParameterList = null; /** * setup. * * @exception Exception */ @Before public synchronized void setUp() throws Exception { crystal1 = (CMLCrystal)CMLXOMTestUtils.parseValidString(crystal1S); cellParameterList = crystal1.getCellParameterElements(); Assert.assertEquals("setup ", 2, cellParameterList.size()); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLCellParameter test, CMLCellParameter expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); CMLCellParameterTest.assertEquals(msg, test.getType(), test .getXMLContent(), expected, epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param type * of parameter * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, String type, double[] test, CMLCellParameter expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("type should not be null (" + msg + CMLConstants.S_RBRAK, type); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertNotNull("expected should not have null type (" + msg + CMLConstants.S_RBRAK, expected.getType()); Assert.assertEquals("types must be equal", 3, test.length); DoubleTestBase.assertEquals(msg, test, expected.getXMLContent(), epsilon); } /** * Test method for * 'org.xmlcml.cml.element.CMLCellParameter.CMLCellParameter(CMLScalar[], * Type)' */ @Test public void testCMLCellParameterCMLScalarArrayType() { CMLScalar[] scalar = new CMLScalar[3]; scalar[0] = CMLCrystal.createScalar(CMLCellParameter.dictRef[0], 10., U_ANGSTROM); scalar[1] = CMLCrystal.createScalar(CMLCellParameter.dictRef[1], 11., U_ANGSTROM); scalar[2] = CMLCrystal.createScalar(CMLCellParameter.dictRef[2], 12., U_ANGSTROM); CMLCellParameter cp = new CMLCellParameter(scalar, CMLCellParameter.Type.LENGTH); CMLCellParameterTest.assertEquals("content", CMLCellParameter.Type.LENGTH.s, new double[] { 10., 11., 12. }, cp, EPS); Assert.assertEquals("units", U_ANGSTROM, cp.getUnits()); } /** * Test method for * 'org.xmlcml.cml.element.CMLCellParameter.CMLCellParameter(List * , Type)' */ @Test public void testCMLCellParameterListOfCMLScalarType() { List scalar = new ArrayList(); scalar.add(CMLCrystal.createScalar(CMLCellParameter.dictRef[0], 10., U_ANGSTROM)); scalar.add(CMLCrystal.createScalar(CMLCellParameter.dictRef[1], 11., U_ANGSTROM)); scalar.add(CMLCrystal.createScalar(CMLCellParameter.dictRef[2], 12., U_ANGSTROM)); CMLCellParameter cp = new CMLCellParameter(scalar, CMLCellParameter.Type.LENGTH); CMLCellParameterTest.assertEquals("content", CMLCellParameter.Type.LENGTH.s, new double[] { 10., 11., 12. }, cp, EPS); Assert.assertEquals("units", U_ANGSTROM, cp.getUnits()); } /** * Test method for * 'org.xmlcml.cml.element.CMLCellParameter.getCellParameter(List , Type)' */ @Test public void testGetCellParameterListOfCMLCellParameterType() { List cpList = new ArrayList(); List scalar = new ArrayList(); scalar.add(CMLCrystal.createScalar(CMLCellParameter.dictRef[0], 10., U_ANGSTROM)); scalar.add(CMLCrystal.createScalar(CMLCellParameter.dictRef[1], 11., U_ANGSTROM)); scalar.add(CMLCrystal.createScalar(CMLCellParameter.dictRef[2], 12., U_ANGSTROM)); cpList.add(new CMLCellParameter(scalar, CMLCellParameter.Type.LENGTH)); scalar = new ArrayList(); scalar.add(CMLCrystal.createScalar(CMLCellParameter.dictRef[3], 90., U_DEGREE)); scalar.add(CMLCrystal.createScalar(CMLCellParameter.dictRef[4], 91., U_DEGREE)); scalar.add(CMLCrystal.createScalar(CMLCellParameter.dictRef[5], 92., U_DEGREE)); cpList.add(new CMLCellParameter(scalar, CMLCellParameter.Type.ANGLE)); CMLCellParameter length = CMLCellParameter.getCellParameter(cpList, CMLCellParameter.Type.LENGTH); Assert.assertNotNull("length not null", length); CMLCellParameterTest.assertEquals("content", CMLCellParameter.Type.LENGTH.s, new double[] { 10., 11., 12. }, length, EPS); Assert.assertEquals("units", U_ANGSTROM, length.getUnits()); CMLCellParameter angle = CMLCellParameter.getCellParameter(cpList, CMLCellParameter.Type.ANGLE); Assert.assertNotNull("angle", angle); CMLCellParameterTest.assertEquals("content", CMLCellParameter.Type.ANGLE.s, new double[] { 90., 91., 92. }, angle, EPS); Assert.assertEquals("units", U_DEGREE, angle.getUnits()); } /** * Test method for * 'org.xmlcml.cml.element.CMLCellParameter.createCMLScalars(List * ) ' */ @Test public void testCreateCMLScalarsListOfCMLCellParameter() { List cpList = new ArrayList(); List scalar = new ArrayList(); scalar.add(CMLCrystal.createScalar(CMLCellParameter.dictRef[0], 10., U_ANGSTROM)); scalar.add(CMLCrystal.createScalar(CMLCellParameter.dictRef[1], 11., U_ANGSTROM)); scalar.add(CMLCrystal.createScalar(CMLCellParameter.dictRef[2], 12., U_ANGSTROM)); cpList.add(new CMLCellParameter(scalar, CMLCellParameter.Type.LENGTH)); scalar = new ArrayList(); scalar.add(CMLCrystal.createScalar(CMLCellParameter.dictRef[3], 90., U_DEGREE)); scalar.add(CMLCrystal.createScalar(CMLCellParameter.dictRef[4], 91., U_DEGREE)); scalar.add(CMLCrystal.createScalar(CMLCellParameter.dictRef[5], 92., U_DEGREE)); cpList.add(new CMLCellParameter(scalar, CMLCellParameter.Type.ANGLE)); List scalarList = CMLCellParameter.createCMLScalars(cpList); Assert.assertNotNull("scalarList not null", scalarList); Assert.assertEquals("scalar count", 6, scalarList.size()); Assert .assertEquals("scalar 0", 10., scalarList.get(0).getDouble(), EPS); Assert.assertEquals("scalar 0", U_ANGSTROM, scalarList.get(0) .getUnits()); Assert .assertEquals("scalar 0", 90., scalarList.get(3).getDouble(), EPS); Assert.assertEquals("scalar 0", U_DEGREE, scalarList.get(3).getUnits()); Assert .assertEquals("scalar 0", 92., scalarList.get(5).getDouble(), EPS); Assert.assertEquals("scalar 0", U_DEGREE, scalarList.get(5).getUnits()); } /** * Test method for 'org.xmlcml.cml.element.CMLCellParameter.copy()' */ @Test public void testCopy() { CMLCellParameter cellParameter1 = (CMLCellParameter) cellParameterList .get(0).copy(); // "4.500 5.500 6.500"+ Assert.assertEquals(IdAttribute.NAME, "scp1", cellParameter1.getId()); Assert.assertEquals("units", U_ANGSTROM, cellParameter1.getUnits()); DoubleTestBase.assertEquals("error", new double[] { 0.001, 0.002, 0.003 }, cellParameter1.getError(), EPS); CMLCellParameterTest.assertEquals("content", CMLCellParameter.Type.LENGTH.s, new double[] { 4.5, 5.5, 6.5 }, cellParameter1, EPS); } /** * Test method for'org.xmlcml.cml.element.CMLCellParameter.getCellParameter(CMLElements , Type)' */ @Test public void testGetCellParameterCMLElementsOfCMLCellParameterType() { CMLCellParameter cellParameter1 = CMLCellParameter.getCellParameter( cellParameterList, CMLCellParameter.Type.LENGTH); Assert.assertNotNull("cell parameter not null", cellParameter1); Assert.assertEquals(IdAttribute.NAME, "scp1", cellParameter1.getId()); Assert.assertEquals("units", U_ANGSTROM, cellParameter1.getUnits()); DoubleTestBase.assertEquals("error", new double[] { 0.001, 0.002, 0.003 }, cellParameter1.getError(), EPS); CMLCellParameterTest.assertEquals("content", CMLCellParameter.Type.LENGTH.s, new double[] { 4.5, 5.5, 6.5 }, cellParameter1, EPS); } /** * Test method for'org.xmlcml.cml.element.CMLCellParameter.createCMLScalars(CMLElements * ) ' */ @Test public void testCreateCMLScalarsCMLElementsOfCMLCellParameter() { List cmlScalarList = CMLCellParameter .createCMLScalars(cellParameterList); Assert.assertNotNull("cell scalars not null", cmlScalarList); Assert.assertEquals("scalars", 6, cmlScalarList.size()); Assert.assertEquals("units", U_ANGSTROM, cmlScalarList.get(0) .getUnits()); Assert.assertEquals("content", 4.5, cmlScalarList.get(0).getDouble(), EPS); Assert.assertEquals("dataType", XSD_DOUBLE, cmlScalarList.get(0) .getDataType()); Assert.assertEquals("dictRef", CMLCrystal.A, cmlScalarList.get(0) .getDictRef()); Assert.assertNotNull("error", cmlScalarList.get(0).getErrorValue()); Assert.assertEquals("error", 0.001, cmlScalarList.get(0) .getErrorValue(), EPS); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLCrystalTest.java000077500000000000000000000614141477224461000276350ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.base.CMLConstants.U_ANGSTROM; import static org.xmlcml.cml.base.CMLConstants.U_DEGREE; import static org.xmlcml.cml.base.CMLXOMTestUtils.assertEqualsCanonically; import static org.xmlcml.euclid.EuclidConstants.EPS; import static org.xmlcml.euclid.EuclidConstants.S_SPACE; import java.util.List; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLCellParameter; import org.xmlcml.cml.element.CMLCrystal; import org.xmlcml.cml.element.CMLLattice; import org.xmlcml.cml.element.CMLLatticeVector; import org.xmlcml.cml.element.CMLScalar; import org.xmlcml.cml.element.CMLSymmetry; import org.xmlcml.cml.element.CMLVector3; import org.xmlcml.cml.element.CMLCrystal.Centering; import org.xmlcml.euclid.EC; import org.xmlcml.euclid.RealSquareMatrix; import org.xmlcml.euclid.test.DoubleTestBase; /** * test for CMLCrystal. * * @author pmr * */ public class CMLCrystalTest { CMLCrystal crystal1; CMLCrystal crystal2; CMLCrystal crystal3; String crystal1S = "" + "" + "4.500" + "4.500" + "4.500" + "90" + "90" + "90" + "" + "" + ""; String crystal2S = "" + "" + "8" + "9" + "10" + "80" + "90" + "100" + "" + ""; String crystal3S = "" + "" + "8" + "9" + "10" + "90" + "90" + "90" + "" + ""; String lattice1S = "" + "" + "8 0 0" + "0 9 0" + "0 0 10" + "" + ""; String lattice2S = "" + "" + "8 4 0" + "0 9 0" + "0 0 10" + "" + ""; CMLLattice lattice1; CMLLattice lattice2; CMLElements latticeVectorList1 = null; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { crystal1 = (CMLCrystal)CMLXOMTestUtils.parseValidString(crystal1S); crystal2 = (CMLCrystal)CMLXOMTestUtils.parseValidString(crystal2S); crystal3 = (CMLCrystal)CMLXOMTestUtils.parseValidString(crystal3S); } private void makeLattice() { lattice1 = (CMLLattice)CMLXOMTestUtils.parseValidString(lattice1S); lattice2 = (CMLLattice)CMLXOMTestUtils.parseValidString(lattice2S); latticeVectorList1 = lattice1.getLatticeVectorElements(); } /** * Test method for 'org.xmlcml.cml.element.CMLCrystal.CMLCrystal()' */ @Test @Deprecated public void testCMLCrystal() { crystal2 = new CMLCrystal(); try { crystal2.getCellScalars(); Assert.fail("should throw"); // } catch (CMLException e) { // Assert.fail("should not throw "+e); } catch (RuntimeException e) { } } /** * Test method for * 'org.xmlcml.cml.element.CMLCrystal.CMLCrystal(CMLCrystal)' */ @Test public void testCMLCrystalCMLCrystal() { CMLCrystal crystal = new CMLCrystal(crystal1); assertEqualsCanonically("copy crystal", crystal, crystal1); } /** * Test method for * 'org.xmlcml.cml.element.CMLCrystal.getOrthogonalizationMatrix()' */ @Test public void testGetOrthogonalizationMatrix() { RealSquareMatrix matrix = crystal1.getOrthogonalizationMatrix(); double[] test = new double[] { 4.5, 0.0, 0.0, 0.0, 4.5, 0.0, 0.0, 0.0, 4.5 }; Assert.assertNotNull("test should not be null (" + "matrix contents " + EC.S_RBRAK, test); Assert.assertNotNull("ref should not be null (" + "matrix contents " + EC.S_RBRAK, matrix); Assert.assertEquals("rows should be equal (" + "matrix contents " + EC.S_RBRAK, 3, matrix.getRows()); DoubleTestBase.assertEquals("matrix contents ", test, matrix.getMatrixAsArray(), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLCrystal.setCellParameters(double, double, * double, double, double, double)' */ @Test @Deprecated public void testSetCellParametersDoubleDoubleDoubleDoubleDoubleDouble() { crystal1.setCellParameters(10, 11, 12, 80, 90, 100); List cell = null; cell = crystal1.getCellScalars(); // } catch (CMLException e) { // Assert.fail("should not throw "+e); Assert.assertNotNull("cell params should not be null", cell); Assert.assertNotNull("cell param a should not be null", cell.get(0)); Assert .assertEquals("a dictRef", CMLCrystal.A, cell.get(0) .getDictRef()); Assert.assertEquals("a", 10, cell.get(0).getDouble(), EPS); RealSquareMatrix matrix = crystal1.getOrthogonalizationMatrix(); double[] test = new double[] { 9.8433, 0.0, 0.0, -1.7632, 10.8329, 0.0, 0.0, 1.9101, 12.0 }; Assert.assertNotNull("test should not be null (" + "matrix contents " + EC.S_RBRAK, test); Assert.assertNotNull("ref should not be null (" + "matrix contents " + EC.S_RBRAK, matrix); Assert.assertEquals("rows should be equal (" + "matrix contents " + EC.S_RBRAK, 3, matrix.getRows()); DoubleTestBase.assertEquals("matrix contents ", test, matrix.getMatrixAsArray(), 0.0001); } /** * Test method for * 'org.xmlcml.cml.element.CMLCrystal.setCellParameters(double[])' */ @Test @Deprecated public void testSetCellParametersDoubleArray() { crystal1.setCellParameters(new double[] { 10, 11, 12, 80, 90, 100 }); List cell = crystal1.getCellScalars(); Assert.assertNotNull("cell params should not be null", cell); Assert.assertNotNull("cell param a should not be null", cell.get(0)); Assert .assertEquals("a dictRef", CMLCrystal.A, cell.get(0) .getDictRef()); Assert.assertEquals("a", 10, cell.get(0).getDouble(), EPS); RealSquareMatrix matrix = crystal1.getOrthogonalizationMatrix(); double[] test = new double[] { 9.8433, 0.0, 0.0, -1.7632, 10.8329, 0.0, 0.0, 1.9101, 12.0 }; Assert.assertNotNull("test should not be null (" + "matrix contents " + EC.S_RBRAK, test); Assert.assertNotNull("ref should not be null (" + "matrix contents " + EC.S_RBRAK, matrix); Assert.assertEquals("rows should be equal (" + "matrix contents " + EC.S_RBRAK, 3, matrix.getRows()); DoubleTestBase.assertEquals("matrix contents ", test, matrix.getMatrixAsArray(), 0.0001); crystal2 = new CMLCrystal(); crystal2.setCellParameters(new double[] { 10, 11, 12, 80, 90, 100 }); cell = crystal2.getCellScalars(); Assert.assertNotNull("cell params should not be null", cell); Assert.assertNotNull("cell param a should not be null", cell.get(0)); Assert .assertEquals("a dictRef", CMLCrystal.A, cell.get(0) .getDictRef()); Assert.assertEquals("a", 10, cell.get(0).getDouble(), EPS); matrix = crystal1.getOrthogonalizationMatrix(); double[] test1 = new double[] { 9.8433, 0.0, 0.0, -1.7632, 10.8329, 0.0, 0.0, 1.9101, 12.0 }; Assert.assertNotNull("test should not be null (" + "matrix contents " + EC.S_RBRAK, test1); Assert.assertNotNull("ref should not be null (" + "matrix contents " + EC.S_RBRAK, matrix); Assert.assertEquals("rows should be equal (" + "matrix contents " + EC.S_RBRAK, 3, matrix.getRows()); DoubleTestBase.assertEquals("matrix contents ", test1, matrix.getMatrixAsArray(), 0.0001); } /** * Test method for * 'org.xmlcml.cml.element.CMLCrystal.getCellParameterValues()' */ @Test public void testGetCellParameterValues() { double[] cell = crystal1.getCellParameterValues(); DoubleTestBase.assertEquals("cell contents ", new double[] { 4.5, 4.5, 4.5, 90., 90, 90 }, cell, EPS); crystal1.setCellParameters(new double[] { 10, 11, 12, 80, 90, 100 }); cell = crystal1.getCellParameterValues(); DoubleTestBase.assertEquals("cell contents ", new double[] { 10, 11, 12, 80, 90, 100 }, cell, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLCrystal.getCellScalars()' */ @Test public void testGetCellScalars() { double[] param = crystal2.getCellParameterValues(); DoubleTestBase.assertEquals("cell params", new double[] { 8., 9., 10., 80., 90., 100. }, param, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLCrystal.getLattice()' */ @Test public void testGetLattice() { CMLLattice lattice = crystal2.getLattice(); CMLLatticeVector a = lattice.getLatticeVectorElements().get(0); CMLLatticeVectorTest.assertEquals("a", new double[] { 7.874653194646171, -1.4106158456677196, 0. }, a, EPS); CMLLatticeVector b = lattice.getLatticeVectorElements().get(1); CMLLatticeVectorTest.assertEquals("b", new double[] { 0, 8.863269777109872, 1.5628335990023738 }, b, EPS); CMLLatticeVector c = lattice.getLatticeVectorElements().get(2); CMLLatticeVectorTest.assertEquals("c", new double[] { 0, 0., 10. }, c, EPS); Assert.assertEquals("length a", 8., a.getCMLVector3().getLength(), EPS); Assert.assertEquals("length b", 9., b.getCMLVector3().getLength(), EPS); Assert .assertEquals("length c", 10., c.getCMLVector3().getLength(), EPS); Assert.assertEquals("gamma", 80., b.getCMLVector3().getAngleMadeWith( c.getCMLVector3()).getDegrees(), EPS); Assert.assertEquals("beta", 90., c.getCMLVector3().getAngleMadeWith( a.getCMLVector3()).getDegrees(), EPS); Assert.assertEquals("gamma", 100., a.getCMLVector3().getAngleMadeWith( b.getCMLVector3()).getDegrees(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLCrystal.getCellVolume()' */ @Test public void testGetCellVolume() { double vol = crystal2.getCellVolume(); Assert.assertEquals("volume", 697.9517566532911, vol, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLCrystal.getCellVolume1()' */ @Test public void testGetCellVolume1() { double vol = crystal2.getCellVolume1(); Assert.assertEquals("volume", 697.9517566532911, vol, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLCrystal.getCellVolume2()' */ @Test public void testGetCellVolume2() { double vol = crystal2.getCellVolume2(); Assert.assertEquals("volume", 697.9517566532911, vol, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLCrystal.getReciprocalCellVolume()' */ @Test public void testGetReciprocalCellVolume() { double vol = crystal2.getReciprocalCellVolume(); Assert.assertEquals("volume", 1. / 697.9517566532911, vol, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLCrystal.getReciprocalCell()' */ @Test public void testGetReciprocalCell() { CMLCrystal recip = crystal2.getReciprocalCell(); double[] recipParams = recip.getCellParameterValues(); DoubleTestBase.assertEquals("recip cell", new double[] { 0.12698971945582077, 0.11462110273008476, 0.10159177556465662, 100.15588943429955, 91.7816819026984, 79.84411056570045 }, recipParams, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLCrystal.getReciprocalLattice()' */ @Test public void testGetReciprocalLattice() { CMLLattice reciprocalLattice = crystal2.getReciprocalLattice(); CMLVector3 a = reciprocalLattice.getCMLVector3(0); CMLVector3 b = reciprocalLattice.getCMLVector3(1); CMLVector3 c = reciprocalLattice.getCMLVector3(2); CMLVector3Test.assertEquals("a ", new double[] { 0.12698971945582077, 0.0, 0.0 }, a, EPS); CMLVector3Test.assertEquals("b ", new double[] { 0.020210792969870637, 0.1128251790984161, -0.0 }, b, EPS); CMLVector3Test.assertEquals("c ", new double[] { -0.0031586106315794863, -0.017632698070846504, 0.1 }, c, EPS); } /** * test gets primitive cell. */ @Test public void testGetPrimitiveLatticeCentering() { double vol = crystal3.getCellVolume(); Assert.assertEquals("full vol", 720., vol, EPS); CMLLattice primitiveLattice = crystal3.getPrimitiveLattice(); CMLVector3Test.assertEquals("a", new double[] { 8.0, 0.0, 0.0 }, primitiveLattice.getCMLVector3(0), EPS); CMLVector3Test.assertEquals("b", new double[] { 0.0, 9.0, 0.0 }, primitiveLattice.getCMLVector3(1), EPS); CMLVector3Test.assertEquals("c", new double[] { 0.0, 0.0, 10.0 }, primitiveLattice.getCMLVector3(2), EPS); // check volume CMLCrystal primitiveCrystal = new CMLCrystal(primitiveLattice); vol = primitiveCrystal.getCellVolume(); Assert.assertEquals("prim vol", 720., vol, EPS); primitiveLattice = crystal3.getPrimitiveLattice(Centering.A); CMLVector3Test.assertEquals("a", new double[] { 8.0, 0.0, 0.0 }, primitiveLattice.getCMLVector3(0), EPS); CMLVector3Test.assertEquals("b", new double[] { 0.0, 4.5, 5.0 }, primitiveLattice.getCMLVector3(1), EPS); CMLVector3Test.assertEquals("c", new double[] { 0.0, 4.5, -5.0 }, primitiveLattice.getCMLVector3(2), EPS); primitiveCrystal = new CMLCrystal(primitiveLattice); vol = primitiveCrystal.getCellVolume(); Assert.assertEquals("prim vol", 720. / 2., vol, EPS); primitiveLattice = crystal3.getPrimitiveLattice(Centering.B); CMLVector3Test.assertEquals("a", new double[] { 4.0, 0.0, 5.0 }, primitiveLattice.getCMLVector3(0), EPS); CMLVector3Test.assertEquals("b", new double[] { 0.0, 9.0, 0.0 }, primitiveLattice.getCMLVector3(1), EPS); CMLVector3Test.assertEquals("c", new double[] { 4.0, 0.0, -5.0 }, primitiveLattice.getCMLVector3(2), EPS); primitiveCrystal = new CMLCrystal(primitiveLattice); vol = primitiveCrystal.getCellVolume(); Assert.assertEquals("prim vol", 720. / 2., vol, EPS); primitiveLattice = crystal3.getPrimitiveLattice(Centering.C); CMLVector3Test.assertEquals("a", new double[] { 4.0, 4.5, 0.0 }, primitiveLattice.getCMLVector3(0), EPS); CMLVector3Test.assertEquals("b", new double[] { 4.0, -4.5, 0.0 }, primitiveLattice.getCMLVector3(1), EPS); CMLVector3Test.assertEquals("c", new double[] { 0.0, 0.0, 10.0 }, primitiveLattice.getCMLVector3(2), EPS); primitiveCrystal = new CMLCrystal(primitiveLattice); vol = primitiveCrystal.getCellVolume(); Assert.assertEquals("prim vol", 720. / 2., vol, EPS); primitiveLattice = crystal3.getPrimitiveLattice(Centering.I); CMLVector3Test.assertEquals("a", new double[] { 8.0, 0.0, 0.0 }, primitiveLattice.getCMLVector3(0), EPS); CMLVector3Test.assertEquals("b", new double[] { 4.0, 4.5, 5.0 }, primitiveLattice.getCMLVector3(1), EPS); CMLVector3Test.assertEquals("c", new double[] { 4.0, 4.5, -5.0 }, primitiveLattice.getCMLVector3(2), EPS); primitiveCrystal = new CMLCrystal(primitiveLattice); vol = primitiveCrystal.getCellVolume(); Assert.assertEquals("prim vol", 720. / 2., vol, EPS * 10.); primitiveLattice = crystal3.getPrimitiveLattice(Centering.F); CMLVector3Test.assertEquals("a", new double[] { 0.0, 4.5, 5.0 }, primitiveLattice.getCMLVector3(0), EPS); CMLVector3Test.assertEquals("b", new double[] { 4.0, 0.0, 5.0 }, primitiveLattice.getCMLVector3(1), EPS); CMLVector3Test.assertEquals("c", new double[] { 4.0, 4.5, 0.0 }, primitiveLattice.getCMLVector3(2), EPS); primitiveCrystal = new CMLCrystal(primitiveLattice); vol = primitiveCrystal.getCellVolume(); Assert.assertEquals("prim vol", 720. / 4., vol, EPS * 10.); } /** * test gets primitive cell. */ @Test public void testGetPrimitiveLattice() { double vol = crystal3.getCellVolume(); Assert.assertEquals("full vol", 720., vol, EPS); CMLLattice primitiveLattice = crystal3.getPrimitiveLattice(); CMLVector3Test.assertEquals("a", new double[] { 8.0, 0.0, 0.0 }, primitiveLattice.getCMLVector3(0), EPS); CMLVector3Test.assertEquals("b", new double[] { 0.0, 9.0, 0.0 }, primitiveLattice.getCMLVector3(1), EPS); CMLVector3Test.assertEquals("c", new double[] { 0.0, 0.0, 10.0 }, primitiveLattice.getCMLVector3(2), EPS); // check volume CMLCrystal primitiveCrystal = new CMLCrystal(primitiveLattice); vol = primitiveCrystal.getCellVolume(); Assert.assertEquals("prim vol", 720., vol, EPS); CMLSymmetry symmetry = new CMLSymmetry(CMLSymmetryTest.abm2); crystal3.appendChild(symmetry); primitiveLattice = crystal3.getPrimitiveLattice(); CMLVector3Test.assertEquals("a", new double[] { 8.0, 0.0, 0.0 }, primitiveLattice.getCMLVector3(0), EPS); CMLVector3Test.assertEquals("b", new double[] { 0.0, 4.5, 5.0 }, primitiveLattice.getCMLVector3(1), EPS); CMLVector3Test.assertEquals("c", new double[] { 0.0, 4.5, -5.0 }, primitiveLattice.getCMLVector3(2), EPS); primitiveCrystal = new CMLCrystal(primitiveLattice); vol = primitiveCrystal.getCellVolume(); Assert.assertEquals("prim vol", 720. / 2., vol, EPS); symmetry.detach(); symmetry = new CMLSymmetry(CMLSymmetryTest.fdd2); crystal3.appendChild(symmetry); primitiveLattice = crystal3.getPrimitiveLattice(); CMLVector3Test.assertEquals("a", new double[] { 0.0, 4.5, 5.0 }, primitiveLattice.getCMLVector3(0), EPS); CMLVector3Test.assertEquals("b", new double[] { 4.0, 0.0, 5.0 }, primitiveLattice.getCMLVector3(1), EPS); CMLVector3Test.assertEquals("c", new double[] { 4.0, 4.5, 0.0 }, primitiveLattice.getCMLVector3(2), EPS); primitiveCrystal = new CMLCrystal(primitiveLattice); vol = primitiveCrystal.getCellVolume(); Assert.assertEquals("prim vol", 720. / 4., vol, EPS * 10.); } /** * Test method for * 'org.xmlcml.cml.element.CMLCrystal.CMLCrystal(CMLLattice)' */ @Test public void testCMLCrystalCMLLattice() { makeLattice(); CMLCrystal crystal1 = new CMLCrystal(lattice1); List cellParameterList = crystal1 .createCellParameterElements(); Assert.assertNotNull("cell parameters", cellParameterList); Assert .assertEquals("cell parameters size", 2, cellParameterList .size()); Assert.assertNotNull("cell parameters not null", cellParameterList .get(0)); CMLCellParameterTest.assertEquals("cell lengths", CMLCellParameter.Type.LENGTH.s, new double[] { 8.0, 9.0, 10.0 }, cellParameterList.get(0), EPS); CMLCellParameterTest.assertEquals("cell angles", CMLCellParameter.Type.ANGLE.s, new double[] { 90., 90., 90. }, cellParameterList.get(1), EPS); CMLCrystal crystal2 = new CMLCrystal(lattice2); cellParameterList = crystal2.createCellParameterElements(); Assert.assertNotNull("cell parameters", cellParameterList); Assert .assertEquals("cell parameters size", 2, cellParameterList .size()); Assert.assertNotNull("cell parameters not null", cellParameterList .get(0)); CMLCellParameterTest.assertEquals("cell lengths", CMLCellParameter.Type.LENGTH.s, new double[] { Math.sqrt(80), 9.0, 10.0 }, cellParameterList.get(0), EPS); CMLCellParameterTest.assertEquals("cell angles", CMLCellParameter.Type.ANGLE.s, new double[] { 90., 90., 180. / Math.PI * Math.atan(2.) }, cellParameterList .get(1), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLCrystal.CMLCrystal(double[])' */ @Test public void testCMLCrystalDoubleArray() { CMLCrystal crystal = new CMLCrystal(new double[] { 8., 9., 10., 90., 90., 90. }); List cellParameterList = crystal .createCellParameterElements(); Assert.assertNotNull("cell parameters", cellParameterList); Assert .assertEquals("cell parameters size", 2, cellParameterList .size()); Assert.assertNotNull("cell parameters not null", cellParameterList .get(0)); CMLCellParameterTest.assertEquals("cell lengths", CMLCellParameter.Type.LENGTH.s, new double[] { 8.0, 9.0, 10.0 }, cellParameterList.get(0), EPS); CMLCellParameterTest.assertEquals("cell angles", CMLCellParameter.Type.ANGLE.s, new double[] { 90., 90., 90. }, cellParameterList.get(1), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLCrystal.CMLCrystal(CMLScalar[])' and * 'org.xmlcml.cml.element.CMLCrystal.createCellParameterElements()' and * 'org.xmlcml.cml.element.CMLCrystal.createScalar(String, double, String)' * and 'org.xmlcml.cml.element.CMLCrystal.createScalar(String, double, * String, double)' */ @Test public void testCMLCrystalCMLScalarArray() { CMLScalar[] scalars = new CMLScalar[6]; scalars[0] = CMLCrystal.createScalar(CMLCrystal.A, 8.0, U_ANGSTROM, 0.001); scalars[1] = CMLCrystal.createScalar(CMLCrystal.B, 9.0, U_ANGSTROM, 0.002); scalars[2] = CMLCrystal.createScalar(CMLCrystal.C, 10.0, U_ANGSTROM, 0.003); scalars[3] = CMLCrystal.createScalar(CMLCrystal.ALPHA, 80.0, U_DEGREE); scalars[4] = CMLCrystal.createScalar(CMLCrystal.BETA, 90.0, U_DEGREE); scalars[5] = CMLCrystal.createScalar(CMLCrystal.GAMMA, 100.0, U_DEGREE); CMLCrystal crystal = new CMLCrystal(scalars); List cellParameterList = crystal .createCellParameterElements(); Assert.assertNotNull("cell parameters", cellParameterList); Assert .assertEquals("cell parameters size", 2, cellParameterList .size()); Assert.assertNotNull("cell parameters not null", cellParameterList .get(0)); CMLCellParameterTest.assertEquals("cell lengths", CMLCellParameter.Type.LENGTH.s, new double[] { 8.0, 9.0, 10.0 }, cellParameterList.get(0), EPS); DoubleTestBase.assertEquals("cell length errors", new double[] { 0.001, 0.002, 0.003 }, cellParameterList.get(0).getError(), EPS); CMLCellParameterTest.assertEquals("cell angles", CMLCellParameter.Type.ANGLE.s, new double[] { 80., 90., 100. }, cellParameterList.get(1), EPS); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLDefinitionTest.java000077500000000000000000000055711477224461000303060ustar00rootroot00000000000000/** * 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.main; import java.util.List; import junit.framework.Assert; import nu.xom.Element; import org.junit.Test; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.element.CMLDefinition; public class CMLDefinitionTest { @Test public void testCMLDefinition() { CMLDefinition def = new CMLDefinition(); Assert.assertNotNull(def); } @Test public void testAddString(){ CMLDefinition def = new CMLDefinition(); def.addPlainText("Test!"); Assert.assertEquals(1, def.getChildCount()); Assert.assertEquals("Test!", def.getChild(0).getValue()); Assert.assertEquals(1, def.getXHTMLElementList().size()); String name=def.getXHTMLElementList().get(0).getLocalName(); Assert.assertEquals("p", name); } @Test public void testCopyConstructor(){ CMLDefinition def = new CMLDefinition(); def.addPlainText("This is a test."); def.addPlainText("Has this worked?"); CMLDefinition newDef = new CMLDefinition(def); Assert.assertEquals(2, newDef.getChildCount()); Assert.assertEquals("Has this worked?", newDef.getChild(1).getValue()); } @Test public void testGetXHTML(){ CMLDefinition def = new CMLDefinition(); def.addPlainText("This is a test."); def.addPlainText("Has this worked?"); CMLElement cml = new CMLElement("cml"); def.appendChild(cml); List list=def.getXHTMLElementList(); Assert.assertEquals(2, list.size()); Assert.assertEquals("This is a test.", list.get(0).getValue()); } @Test public void testRemoveXHTML(){ CMLDefinition def = new CMLDefinition(); def.addPlainText("This is a test."); def.addPlainText("Has this worked?"); def.removeXHTMLChildren(); Assert.assertEquals(0, def.getXHTMLElementList().size()); } @Test public void testFlatternText(){ CMLDefinition def = new CMLDefinition(); def.addPlainText("This is a test."); def.addPlainText("Has this worked?"); String text=def.getFlatText(); Assert.assertEquals(15, text.indexOf('\n')); Assert.assertEquals(-1,text.substring(16).indexOf('\n')); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLDescriptionTest.java000077500000000000000000000056111477224461000304740ustar00rootroot00000000000000/** * 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.main; import java.util.List; import junit.framework.Assert; import nu.xom.Element; import org.junit.Test; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.element.CMLDescription; public class CMLDescriptionTest { @Test public void testCMLDefinition() { CMLDescription def = new CMLDescription(); Assert.assertNotNull(def); } @Test public void testAddString(){ CMLDescription def = new CMLDescription(); def.addPlainText("Test!"); Assert.assertEquals(1, def.getChildCount()); Assert.assertEquals("Test!", def.getChild(0).getValue()); Assert.assertEquals(1, def.getXHTMLElementList().size()); String name=def.getXHTMLElementList().get(0).getLocalName(); Assert.assertEquals("p", name); } @Test public void testCopyConstructor(){ CMLDescription def = new CMLDescription(); def.addPlainText("This is a test."); def.addPlainText("Has this worked?"); CMLDescription newDef = new CMLDescription(def); Assert.assertEquals(2, newDef.getChildCount()); Assert.assertEquals("Has this worked?", newDef.getChild(1).getValue()); } @Test public void testGetXHTML(){ CMLDescription def = new CMLDescription(); def.addPlainText("This is a test."); def.addPlainText("Has this worked?"); CMLElement cml = new CMLElement("cml"); def.appendChild(cml); List list=def.getXHTMLElementList(); Assert.assertEquals(2, list.size()); Assert.assertEquals("This is a test.", list.get(0).getValue()); } @Test public void testRemoveXHTML(){ CMLDescription def = new CMLDescription(); def.addPlainText("This is a test."); def.addPlainText("Has this worked?"); def.removeXHTMLChildren(); Assert.assertEquals(0, def.getXHTMLElementList().size()); } @Test public void testFlatternText(){ CMLDescription def = new CMLDescription(); def.addPlainText("This is a test."); def.addPlainText("Has this worked?"); String text=def.getFlatText(); Assert.assertEquals(15, text.indexOf('\n')); Assert.assertEquals(-1,text.substring(16).indexOf('\n')); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLDictionaryTest.java000066400000000000000000000072301477224461000303120ustar00rootroot00000000000000/** * Copyright 2023 Sivasuriyan * * 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.main; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.element.CMLDictionary; import org.xmlcml.cml.element.CMLEntry; public class CMLDictionaryTest { private CMLEntry cmlEntry1 = new CMLEntry("1"); private CMLEntry cmlEntry2 = new CMLEntry("2"); @Test public void testRemoveEntryById() { CMLDictionary cmlDictionary = new CMLDictionary(); cmlDictionary.insertChild(cmlEntry1, 0); cmlDictionary.insertChild(cmlEntry2, 1); cmlDictionary.removeEntryById("1"); Assert.assertEquals(null, cmlDictionary.getCMLEntry("1")); Assert.assertEquals("2", cmlDictionary.getCMLEntry("2").getId()); } @Test public void testRemoveEntry() { CMLDictionary cmlDictionary = new CMLDictionary(); cmlDictionary.insertChild(cmlEntry1, 0); cmlDictionary.insertChild(cmlEntry2, 1); CMLEntry entryToBeRemoved = cmlEntry1; cmlDictionary.removeEntry(entryToBeRemoved); Assert.assertEquals(null, cmlDictionary.getCMLEntry("1")); Assert.assertEquals("2", cmlDictionary.getCMLEntry("2").getId()); } @Test public void testAddEntry() { CMLDictionary cmlDictionary = new CMLDictionary(); cmlDictionary.insertChild(cmlEntry1, 0); CMLEntry entryToBeAdded = new CMLEntry("4"); cmlDictionary.addEntry(entryToBeAdded); Assert.assertEquals("4", cmlDictionary.getCMLEntry("4").getId()); } @Test(expected = RuntimeException.class) public void testAddEntry_whenIdIsNull() { CMLDictionary cmlDictionary = new CMLDictionary(); CMLEntry entryToBeAdded = new CMLEntry(); cmlDictionary.addEntry(entryToBeAdded); } @Test(expected = RuntimeException.class) public void testAddEntry_whenIdIsAlreadyPresent() { CMLDictionary cmlDictionary = new CMLDictionary(); cmlDictionary.insertChild(cmlEntry1, 0); cmlDictionary.insertChild(cmlEntry2, 1); CMLEntry entryToBeAdded = cmlEntry1; cmlDictionary.addEntry(entryToBeAdded); } @Test public void testAddEntryInOrder() { CMLDictionary cmlDictionary = new CMLDictionary(); cmlDictionary.insertChild(cmlEntry1, 0); cmlDictionary.insertChild(cmlEntry2, 1); CMLEntry entryToBeAdded = new CMLEntry("0"); cmlDictionary.addEntryInOrder(entryToBeAdded); Assert.assertEquals("0", cmlDictionary.getCMLEntry("0").getId()); } @Test(expected = RuntimeException.class) public void testAddEntryInOrder_whenIdIsNull() { CMLDictionary cmlDictionary = new CMLDictionary(); CMLEntry entryToBeAdded = new CMLEntry(); cmlDictionary.addEntryInOrder(entryToBeAdded); } @Test public void testGetGenericEntry() { CMLDictionary cmlDictionary = new CMLDictionary(); cmlDictionary.insertChild(cmlEntry1, 0); cmlDictionary.insertChild(cmlEntry2, 1); CMLEntry actual = cmlDictionary.getGenericEntry("1"); Assert.assertEquals(actual,cmlEntry1); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLEigenTest.java000077500000000000000000000134111477224461000272350ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.euclid.EuclidConstants.EPS; import junit.framework.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.element.CMLArray; import org.xmlcml.cml.element.CMLEigen; import org.xmlcml.cml.element.CMLMatrix; import org.xmlcml.cml.element.CMLEigen.Orientation; import org.xmlcml.euclid.EuclidConstants; import org.xmlcml.euclid.RealArray; import org.xmlcml.euclid.test.DoubleTestBase; /** * tests eigen. * * @author pmr * */ public class CMLEigenTest { CMLEigen eigen1; CMLMatrix eigenvectors1; CMLArray eigenvalues1; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { eigenvalues1 = new CMLArray(new double[] { -37.90004, -20.34372, -13.10423, -12.71709, -12.07969, -7.47084, -3.44820, -1.14406, -.70572, .56580 }); eigenvectors1 = new CMLMatrix(10, 10, new double[] { -.08645, -.38651, -.12937, .19522, .00000, -.08646, -.86876, .08917, -.13456, .00000, -.30627, -.67196, .05529, -.08345, .00000, -.30626, .41200, .23508, -.35475, .00000, .28127, .19755, -.29019, .43789, .00000, .28121, .13042, .39444, -.59518, .00000, .21650, .00002, -.38339, -.25407, .00000, -.21652, .00000, -.69478, -.46042, .00000, .00000, .00000, .00000, .00000, .37511, .00000, .00000, .00000, .00000, .92698, .51104, .00000, -.38138, -.25274, .00000, -.51109, .00001, .43176, .28617, .00000, .00000, .00000, .00000, .00000, .92698, .00000, .00000, .00000, .00000, -.37511, .54076, -.58544, .02479, -.03716, .00000, .54056, .09466, -.13723, .20700, .00000, .43797, .00009, .63431, .42046, .00000, -.43824, .00001, -.16033, -.10623, .00000, .16535, .13159, .44787, -.67572, .00000, .16523, -.22256, .25987, -.39217, .00000 }); } /** * Test method for 'org.xmlcml.cml.element.CMLEigen.CMLEigen(CMLMatrix, * CMLArray, Orientation)' */ @Test public void testCMLEigenCMLMatrixCMLArrayOrientation() { Orientation orient = Orientation.VALUES_COLS; CMLEigen eigen = new CMLEigen(eigenvectors1, eigenvalues1, orient); Assert.assertNotNull("eigenvalues ", eigen.getEigenvalues()); Assert.assertNotNull("eigenvectors ", eigen.getEigenvectors()); } /** * Test method for 'org.xmlcml.cml.element.CMLEigen.getSize()' */ @Test public void testGetSize() { Orientation orient = Orientation.VALUES_COLS; CMLEigen eigen = new CMLEigen(eigenvectors1, eigenvalues1, orient); Assert.assertNotNull("eigenvalues ", eigen.getEigenvalues()); Assert.assertNotNull("eigenvectors ", eigen.getEigenvectors()); Assert.assertEquals("size ", 10, eigen.getSize()); } /** * Test method for 'org.xmlcml.cml.element.CMLEigen.getEigenvectors()' */ @Test public void testGetEigenvectors() { Orientation orient = Orientation.VALUES_COLS; CMLEigen eigen = new CMLEigen(eigenvectors1, eigenvalues1, orient); Assert.assertNotNull("eigenvectors ", eigen.getEigenvectors()); Assert.assertEquals("cols", 10, eigen.getEigenvectors().getColumns()); Assert.assertEquals("rows", 10, eigen.getEigenvectors().getRows()); } /** * Test method for 'org.xmlcml.cml.element.CMLEigen.getEigenvalues()' */ @Test public void testGetEigenvalues() { Orientation orient = Orientation.VALUES_COLS; CMLEigen eigen = new CMLEigen(eigenvectors1, eigenvalues1, orient); Assert.assertNotNull("eigenvalues ", eigen.getEigenvalues()); Assert.assertEquals("size", 10, eigen.getEigenvalues().getSize()); } /** * Test method for 'org.xmlcml.cml.element.CMLEigen.getEigenvector(int)' */ @Test public void testGetEigenvector() { Orientation orient = Orientation.VALUES_COLS; CMLEigen eigen = new CMLEigen(eigenvectors1, eigenvalues1, orient); RealArray eigenvector = eigen.getEigenvector(1); double[] test = new double[] { -0.38651, -0.67196, 0.19755, 2.0E-5, 0.0, 0.0, 0.0, -0.58544, 9.0E-5, 0.13159 }; org.junit.Assert.assertNotNull("test should not be null (" + "eigenvector" + EuclidConstants.S_RBRAK, test); org.junit.Assert.assertNotNull("expected should not be null (" + "eigenvector" + EuclidConstants.S_RBRAK, eigenvector); org.junit.Assert.assertEquals("must be of equal length ", test.length, eigenvector .getArray().length); DoubleTestBase.assertEquals("eigenvector", test, eigenvector.getArray(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLEigen.copy()' */ @Test public void testCopy() { Orientation orient = Orientation.VALUES_COLS; CMLEigen eigen = new CMLEigen(eigenvectors1, eigenvalues1, orient); Assert.assertNotNull("eigenvalues ", eigen.getEigenvalues()); Assert.assertNotNull("eigenvectors ", eigen.getEigenvectors()); Assert.assertEquals("size ", 10, eigen.getSize()); CMLEigen eigen1 = (CMLEigen) eigen.copy(); Assert.assertNotNull("eigenvalues ", eigen1.getEigenvalues()); Assert.assertNotNull("eigenvectors ", eigen1.getEigenvectors()); Assert.assertEquals("size ", 10, eigen1.getSize()); Assert.assertEquals("orient ", Orientation.VALUES_COLS.value, eigen1 .getOrientation()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLElementTest.java000077500000000000000000000461121477224461000276030ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.base.CMLConstants.C_E; import static org.xmlcml.cml.base.CMLXOMTestUtils.assertEqualsCanonically; import static org.xmlcml.cml.base.CMLXOMTestUtils.assertNotEqualsCanonically; import java.io.IOException; import java.io.StringReader; import java.util.List; import nu.xom.Attribute; import nu.xom.Builder; import nu.xom.Document; import nu.xom.Element; import nu.xom.Elements; import nu.xom.ParsingException; import nu.xom.ValidityException; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLLabel; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.euclid.Util; /** * test CMLElement. * * @author pmr * */ public class CMLElementTest { final static String ID = "id"; CMLElement atom; CMLElement cml1; Element elem1; Element elem2; // default namespace /** * main * * @param args */ public static void main(String[] args) { } /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { atom = new CMLElement(CMLAtom.TAG); atom.addAttribute(new Attribute("foo", "fooval")); CMLLabel label = new CMLLabel(); label.setCMLValue("value1"); atom.appendChild(label); atom.setProperty("foo", "fooString"); atom.setProperty("bar", "barString"); cml1 = new CMLElement("cml1"); CMLElement c = new CMLElement("cml2"); c.addAttribute(new Attribute(ID, "c1")); cml1.appendChild(c); Element noncml = new Element("noncml"); noncml.addAttribute(new Attribute(ID, "n1")); cml1.appendChild(noncml); c = new CMLElement("cml2"); c.addAttribute(new Attribute(ID, "c2")); cml1.appendChild(c); } /** * basic test of XOM.* Test method for 'org.xmlcml.cml.base.Element' */ @Test public void testElement() { String test1S = ""; Document doc1 = null; try { doc1 = new Builder().build(new StringReader(test1S)); } catch (ValidityException e) { Assert.fail("should not throw " + e); } catch (ParsingException e) { Assert.fail("should not throw " + e); } catch (IOException e) { Assert.fail("should not throw " + e); } Assert.assertNotNull("test1 ", doc1); Element cml = doc1.getRootElement(); Assert.assertEquals("test1 ", "cml", cml.getLocalName()); /* * -- omit deliberate error System.err.println("deliberate error:"); * String test2S = ""; Document doc2 = null; try { doc2 = new * Builder().build(new StringReader(test2S)); * Assert.fail("should throw parsing exception"); } catch * (ValidityException e) { Assert.fail("should not throw "+e); } catch * (ParsingException e) { Assert.assertEquals("should throw ", * "XML document structures must start and end within the same entity.", * e.getMessage()); } catch (IOException e) { * Assert.fail("should not throw "+e); } Assert.assertNull("test2 ", * doc2); System.err.println("end deliberate error:"); -- */ String test3S = "" + "" + ""; Document doc3 = null; try { doc3 = new Builder().build(new StringReader(test3S)); } catch (ValidityException e) { Assert.fail("should not throw " + e); } catch (ParsingException e) { Assert.fail("should not throw " + e); } catch (IOException e) { Assert.fail("should not throw " + e); } Assert.assertNotNull("test3 ", doc3); String test4S = "" + "" + ""; Document doc4 = null; try { doc4 = new Builder().build(new StringReader(test4S)); } catch (ValidityException e) { Assert.fail("should not throw " + e); } catch (ParsingException e) { Assert.fail("should not throw " + e); } catch (IOException e) { Assert.fail("should not throw " + e); } Assert.assertNotNull("test4 ", doc4); } /** * Test method for 'org.xmlcml.cml.base.CMLElement.CMLElement(String)' */ @Test public void testCMLElementString() { // at this stage we do not care whether the name is in the schema CMLElement element = new CMLElement("atom"); Assert.assertNotNull("constructor", element); Assert.assertEquals("default attribute count", 0, element .getAttributeCount()); Assert.assertEquals("namespace", "", element.getNamespacePrefix()); Assert.assertEquals("namespace", "atom", element.getLocalName()); Assert.assertEquals("namespace", CMLConstants.CML_NS, element.getNamespaceURI()); // explicit prefix element = new CMLElement(CMLAtom.NS); Assert.assertNotNull("constructor", element); Assert.assertEquals("default attribute count", 0, element .getAttributeCount()); Assert.assertEquals("namespace", "cml", element.getNamespacePrefix()); Assert.assertEquals("namespace", "atom", element.getLocalName()); // non-CML element element = new CMLElement("foo"); Assert.assertNotNull("constructor", element); Assert.assertEquals("default attribute count", 0, element .getAttributeCount()); Assert.assertEquals("namespace", "", element.getNamespacePrefix()); // non-CML element element = new CMLElement(C_E + "foo"); Assert.assertNotNull("constructor", element); Assert.assertEquals("default attribute count", 0, element .getAttributeCount()); Assert.assertEquals("namespace", "cml", element.getNamespacePrefix()); } /** * Test method for 'org.xmlcml.cml.base.CMLElement.CMLElement(CMLElement)' */ @Test public void testCMLElementCMLElement() { Element label = atom.getChildElements().get(0); CMLElement atom1 = new CMLElement(atom); // detach to test the deep copy label.detach(); // remove property to test deep copy atom.setProperty("foo", null); Assert.assertEquals("copy constructor", 0, atom.getChildCount()); Assert.assertNotNull("copy constructor", atom1); Assert.assertEquals("copy constructor", "", atom1.getNamespacePrefix()); Assert .assertEquals("copy constructor", CMLConstants.CML_NS, atom1 .getNamespaceURI()); Assert.assertEquals("copy constructor", 1, atom1.getChildCount()); // MUST remember the namespace! Element child = atom1.getFirstChildElement("label", CMLConstants.CML_NS); Assert.assertNotNull("child", child); Assert.assertEquals("copy child", CMLLabel.class, child.getClass()); label = (CMLLabel) child; Assert .assertEquals("child", "value1", label .getAttributeValue("value")); Assert.assertEquals("property", 2, atom1.getPropertyNames().size()); Assert.assertEquals("property", "fooString", atom1.getProperty("foo")); Assert.assertEquals("property", "barString", atom1.getProperty("bar")); } /** * Test method for 'org.xmlcml.cml.base.CMLElement.copy()' */ @Test public void testCopy() { CMLElement elem = (CMLElement) atom.copy(); Assert.assertEquals("copy", 0, elem.compareTo(atom)); } /** * Test method for 'org.xmlcml.cml.base.CMLElement.compareTo(CMLElement)' */ @Test public void testCompareTo() { CMLElement elem = (CMLElement) atom.copy(); Assert.assertEquals("copy", 0, elem.compareTo(atom)); } /** * Test method for 'org.xmlcml.cml.base.CMLElement.removeAttribute(String)' */ @Test public void testRemoveAttributeString() { String value = atom.getAttributeValue("foo"); Assert.assertEquals("att", "fooval", value); atom.removeAttribute("foo"); value = atom.getAttributeValue("foo"); Assert.assertNull("att", value); } /** * Test method for 'org.xmlcml.cml.base.CMLElement.setProperty(String, * Object)' */ @Test public void testGetSetProperty() { CMLAtom atom = new CMLAtom(); atom.setProperty("foo", "fooString"); atom.setProperty("bar", "barString"); List names = atom.getPropertyNames(); Assert.assertEquals("property", 2, names.size()); Assert.assertEquals("property", "fooString", atom.getProperty("foo")); Assert.assertEquals("property", "barString", atom.getProperty("bar")); atom.setProperty("foo", "fooPlugh"); names = atom.getPropertyNames(); Assert.assertEquals("property", 2, names.size()); Assert.assertEquals("property", "fooPlugh", atom.getProperty("foo")); Assert.assertEquals("property", "barString", atom.getProperty("bar")); atom.setProperty("foo", null); names = atom.getPropertyNames(); Assert.assertEquals("property", 1, names.size()); Assert.assertNull("property", atom.getProperty("foo")); Assert.assertEquals("property", "barString", atom.getProperty("bar")); atom.setProperty("foo", "fooXyzzy"); names = atom.getPropertyNames(); Assert.assertEquals("property", 2, names.size()); Assert.assertEquals("property", "fooXyzzy", atom.getProperty("foo")); Assert.assertEquals("property", "barString", atom.getProperty("bar")); } /** * Test method for 'org.xmlcml.cml.base.CMLElement.getChildCMLElements()' */ @Test public void testGetChildCMLElements() { String moleculeS = null; CMLMolecule molecule = null; /* * -- // this example tests atom code so is not a good test for simple * children moleculeS = "" + * " " + " " + * " " + "" + ""; CMLMolecule molecule = null; * try { molecule = (CMLMolecule) new * CMLBuilder().parseString(moleculeS); molecule.debug("MOL"); } catch * (Exception e1) { e1.printStackTrace(); * Assert.assertEquals("bad names", "Unknown CML element: foo", * e1.getMessage()); } CMLAtom atom = molecule.getAtom(0); String title * = atom.getTitle(); Assert.assertEquals("title", "atom1", title); * String id = atom.getId(); Assert.assertEquals("id", "a1", id); * Attribute idAtt = atom.getIdAttribute(); * Assert.assertNotNull("id att not null", idAtt); Attribute idAtt1 = * atom.getAttribute("id"); Assert.assertNotNull("id att not null", * idAtt1); * * // this example tests atom code so is not a good test for simple * children moleculeS = "" + * " " + " " + * " " + " " + " " * + " " + " " + " " + * " " + " " + " " + * "" + ""; molecule = null; try { molecule = (CMLMolecule) * new CMLBuilder().parseString(moleculeS); } catch (Exception e1) { * e1.printStackTrace(); Assert.assertEquals("bad names", * "Unknown CML Element : foo", e1.getMessage()); } -- */ moleculeS = "" + " " + " " + " " + " " + " " + " " + " " + "" + ""; try { molecule = (CMLMolecule) new CMLBuilder().build( new StringReader(moleculeS)).getRootElement(); } catch (Exception e) { e.printStackTrace(); Assert.assertEquals("unknown elements ", "x", e.getMessage()); } List childs = molecule.getChildCMLElements(); Assert.assertEquals("children", 2, childs.size()); Assert.assertEquals("children", "atomArray", childs.get(0) .getLocalName()); Assert.assertEquals("children", "bondArray", childs.get(1) .getLocalName()); } /** * Test method for * 'org.xmlcml.cml.base.CMLElement.getChildCMLElements(String)' */ @Test public void testGetChildCMLElementsString() { Elements elems = cml1.getChildCMLElements("cml2"); Assert.assertEquals("child cml", 2, elems.size()); Assert.assertEquals("child cml", CMLElement.class, elems.get(0) .getClass()); Assert.assertEquals("child cml id", "c1", elems.get(0) .getAttributeValue(ID)); Assert.assertEquals("child cml id", "c2", elems.get(1) .getAttributeValue(ID)); elems = cml1.getChildCMLElements("noncml"); Assert.assertEquals("child cml", 0, elems.size()); elems = cml1.getChildElements("noncml"); Assert.assertEquals("child cml", 1, elems.size()); Assert.assertEquals("child cml id", "n1", elems.get(0) .getAttributeValue(ID)); Assert .assertEquals("child cml", Element.class, elems.get(0) .getClass()); } /** * Test method for 'org.xmlcml.cml.base.CMLElement.getFirstCMLChild(String)' */ @Test public void testGetFirstCMLChild() { Element elem = cml1.getFirstCMLChild("cml2"); Assert.assertEquals("child cml", CMLElement.class, elem.getClass()); Assert.assertEquals("child cml id", "c1", elem.getAttributeValue(ID)); } /** * Test method for * 'org.xmlcml.cml.base.CMLElement.getChildCMLElement(String, int)' */ @Test public void testGetChildCMLElement() { Element elem = cml1.getChildCMLElement("cml2", 0); Assert.assertEquals("child cml", CMLElement.class, elem.getClass()); Assert.assertEquals("child cml id", "c1", elem.getAttributeValue(ID)); elem = cml1.getChildCMLElement("cml2", 1); Assert.assertEquals("child cml", CMLElement.class, elem.getClass()); Assert.assertEquals("child cml id", "c2", elem.getAttributeValue(ID)); elem = cml1.getChildCMLElement("cml2", 2); Assert.assertNull("child cml", elem); } /** * Test method for 'org.xmlcml.cml.base.CMLElement.getCMLChildCount(String)' */ @Test public void testGetCMLChildCount() { Assert.assertEquals("child count", 2, cml1.getCMLChildCount("cml2")); Assert.assertEquals("child count", 0, cml1.getCMLChildCount("cmlXX")); } /** * Test method for 'nu.xom.Element.getValue()' */ @Test public void testGetXOMStuff() { Assert.assertEquals("value", "", cml1.getValue()); Assert.assertEquals("URI", "", cml1.getBaseURI()); Assert.assertEquals("QName", "cml1", cml1.getQualifiedName()); } /** * Test method for 'nu.xom.Element.insertChild(String, int)' */ @Test public void testInsertChildStringInt() { } /** * Test method for 'nu.xom.Element.appendChild(String)' */ @Test public void testAppendChildString() { } /** * Test method for 'nu.xom.Element.removeChildren()' */ @Test public void testRemoveChildren() { } /** * Test method for 'nu.xom.Element.addNamespaceDeclaration(String, String)' */ @Test public void testAddNamespaceDeclaration() { } /** * Test method for 'nu.xom.Element.removeNamespaceDeclaration(String)' */ @Test public void testRemoveNamespaceDeclaration() { } /** * Test method for 'nu.xom.Element.getNamespaceDeclarationCount()' */ @Test public void testGetNamespaceDeclarationCount() { } /** * Test method for 'nu.xom.Element.getNamespacePrefix(int)' */ @Test public void testGetNamespacePrefixInt() { } /** * Test method for 'BaseTest1.assertEqualsCanonically(String, Element, * Element)' */ @Test public void testAssertEqualsCanonicallyStringElementElement() { elem1 = new Element("foo"); elem1.addAttribute(new Attribute("bar", "plugh")); elem1.addAttribute(new Attribute("y2", "xyzzy")); elem2 = new Element("foo"); elem2.addAttribute(new Attribute("y2", "xyzzy")); elem2.addAttribute(new Attribute("bar", "plugh")); assertEqualsCanonically("test canonicalization", elem1, elem2); String s1 = ""; String s2 = ""; try { elem1 = new Builder().build(new StringReader(s1)).getRootElement(); elem2 = new Builder().build(new StringReader(s2)).getRootElement(); } catch (ParsingException e) { Util.BUG(e); } catch (IOException e) { Util.BUG(e); } assertEqualsCanonically("test canonicalization", elem1, elem2); s1 = ""; s2 = ""; try { elem1 = new Builder().build(new StringReader(s1)).getRootElement(); elem2 = new Builder().build(new StringReader(s2)).getRootElement(); } catch (ParsingException e) { Util.BUG(e); } catch (IOException e) { Util.BUG(e); } assertEqualsCanonically("test canonicalization", elem1, elem2); s1 = ""; s2 = ""; try { elem1 = new Builder().build(new StringReader(s1)).getRootElement(); elem2 = new Builder().build(new StringReader(s2)).getRootElement(); } catch (ParsingException e) { Util.BUG(e); } catch (IOException e) { Util.BUG(e); } assertNotEqualsCanonically("test canonicalization", elem1, elem2); s1 = ""; s2 = ""; try { elem1 = new Builder().build(new StringReader(s1)).getRootElement(); elem2 = new Builder().build(new StringReader(s2)).getRootElement(); } catch (ParsingException e) { Util.BUG(e); } catch (IOException e) { Util.BUG(e); } assertNotEqualsCanonically("test canonicalization", elem1, elem2); } // FIXME this currently relies on classes in other package // /** // * test getNamespaceForPrefix. // */ // @Test // public void testGetNamespaceForPrefix() { // // String s = "" + "" // + " " + "" + ""; // Element cml = (Element) new Builder().build(new // StringReader(s)).getRootElement(); // Element molecule = (Element) cml // .getChild(0); // String ns = cml.getNamespaceForPrefix("a"); // Assert.assertEquals("namespace", "http://www.foo.org", ns); // ns = molecule.getNamespaceForPrefix("a"); // Assert.assertEquals("namespace", "http://www.foo.org", ns); // ns = cml.getNamespaceForPrefix("b"); // Assert.assertEquals("namespace", "http://www.bar.com", ns); // ns = molecule.getNamespaceForPrefix("b"); // Assert.assertEquals("namespace", "http://www.bar.com", ns); // ns = cml.getNamespaceForPrefix("z"); // Assert.assertNull("namespace", ns); // ns = molecule.getNamespaceForPrefix("z"); // Assert.assertNull("namespace", ns); // } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLGradientTest.java000066400000000000000000000031771477224461000277500ustar00rootroot00000000000000/** * Copyright 2023 Sivasuriyan * * 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.main; import nu.xom.Element; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.element.CMLGradient; public class CMLGradientTest { CMLGradient cmlGradient; @Before public void setup(){ cmlGradient = new CMLGradient(); } @Test public void testCMLGradientCopy() { Element copyElement = cmlGradient.copy(); Assert.assertEquals(copyElement.getClass(), CMLGradient.class); } @Test public void testMakeElementInContext() { Element element = new CMLGradient(); CMLElement actual = cmlGradient.makeElementInContext(element); Assert.assertEquals(CMLGradient.class, actual.getClass()); } @Test public void testCMLGradient() { CMLGradient cmlGradientOld = new CMLGradient(); CMLGradient cmlGradient = new CMLGradient(cmlGradientOld); Assert.assertEquals(cmlGradient.getClass(), CMLGradient.class); } }cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLIdentifierTest.java000066400000000000000000000032531477224461000302700ustar00rootroot00000000000000/** * Copyright 2023 Sivasuriyan * * 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.main; import nu.xom.Element; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.element.CMLIdentifier; public class CMLIdentifierTest { CMLIdentifier cmlIdentifier; @Before public void setUp() { cmlIdentifier = new CMLIdentifier(); } @Test public void testCMLIdentifierCopy() { Element copyElement = cmlIdentifier.copy(); Assert.assertEquals(copyElement.getClass(), CMLIdentifier.class); } @Test public void testMakeElementInContext() { Element element = new CMLIdentifier(); CMLElement actual = cmlIdentifier.makeElementInContext(element); Assert.assertEquals(CMLIdentifier.class, actual.getClass()); } @Test public void testCMLIdentifier() { CMLIdentifier cmlIdentifierOld = new CMLIdentifier(); CMLIdentifier cmlIdentifier = new CMLIdentifier(cmlIdentifierOld); Assert.assertEquals(cmlIdentifier.getClass(), CMLIdentifier.class); } }cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLIsotopeTest.java000066400000000000000000000031471477224461000276320ustar00rootroot00000000000000/** * Copyright 2023 Sivasuriyan * * 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.main; import nu.xom.Element; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.element.CMLIsotope; public class CMLIsotopeTest { CMLIsotope cmlIsotope; @Before public void setUp() { cmlIsotope = new CMLIsotope(); } @Test public void testCMLIsotopeCopy() { Element copyElement = cmlIsotope.copy(); Assert.assertEquals(copyElement.getClass(), CMLIsotope.class); } @Test public void testMakeElementInContext() { Element element = new CMLIsotope(); CMLElement actual = cmlIsotope.makeElementInContext(element); Assert.assertEquals(CMLIsotope.class, actual.getClass()); } @Test public void testCMLIsotope() { CMLIsotope cmlIsotopOld = new CMLIsotope(); CMLIsotope cmlIsotope = new CMLIsotope(cmlIsotopOld); Assert.assertEquals(cmlIsotope.getClass(), CMLIsotope.class); } }cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLJoinTest.java000077500000000000000000000046301477224461000271100ustar00rootroot00000000000000/** * 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.main; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import org.xmlcml.cml.element.CMLFragment; import org.xmlcml.cml.element.CMLJoin; public class CMLJoinTest { CMLFragment parent = new CMLFragment(); CMLJoin join1 = new CMLJoin(); CMLFragment childAndPrevious = new CMLFragment(); CMLJoin join2 = new CMLJoin(); CMLFragment next = new CMLFragment(); void setup() { parent = new CMLFragment(); join1 = new CMLJoin(); childAndPrevious = new CMLFragment(); join2 = new CMLJoin(); next = new CMLFragment(); join1.setMoleculeRefs2(CMLJoin.PARENT_S + " " + CMLJoin.CHILD_S); parent.appendChild(join1); join1.appendChild(childAndPrevious); join2.setMoleculeRefs2(CMLJoin.PREVIOUS_S + " " + CMLJoin.NEXT_S); join1.appendChild(join2); join1.appendChild(next); } @Test public void testGetParentOrPrevious() { setup(); assertTrue(join1.getParentOrPrevious() == parent); assertTrue(join2.getParentOrPrevious() == childAndPrevious); join1.setMoleculeRefs2(CMLJoin.PREVIOUS_S + " " + CMLJoin.NEXT_S); join2.setMoleculeRefs2("FOO BAR"); assertNull(join1.getParentOrPrevious()); assertNull(join2.getParentOrPrevious()); } @Test public void testGetChildOrNext() { setup(); assertTrue(join1.getChildOrNext() == childAndPrevious); assertTrue(join2.getChildOrNext() == next); join1.setMoleculeRefs2(CMLJoin.PREVIOUS_S + " " + CMLJoin.NEXT_S); join2.setMoleculeRefs2(CMLJoin.PARENT_S + " " + CMLJoin.CHILD_S); assertNull(join1.getChildOrNext()); assertNull(join2.getChildOrNext()); join1.setMoleculeRefs2("FOO BAR"); assertNull(join1.getChildOrNext()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLLatticeTest.java000077500000000000000000000160651477224461000276030ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.euclid.EuclidConstants.EPS; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLLattice; import org.xmlcml.cml.element.CMLLatticeVector; import org.xmlcml.cml.element.CMLVector3; import org.xmlcml.euclid.test.DoubleTestBase; /** * tests Lattice. * * @author pmr */ public class CMLLatticeTest { static String lattice1S = "" + "" + " 10. 6. 4." + " 7. 11. 5." + " 6.8 -4. -9." + "" + ""; static CMLLattice lattice1 = null; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { if (lattice1 == null) { lattice1 = (CMLLattice)CMLXOMTestUtils.parseValidString(lattice1S); } } /** * Test method for * 'org.xmlcml.cml.element.CMLLattice.CMLLattice(CMLLatticeVector[])' */ @Test public void testCMLLatticeCMLLatticeVectorArray() { CMLLattice lattice = new CMLLattice(new CMLLatticeVector[] { new CMLLatticeVector(new double[] { 1., 2., 3. }), new CMLLatticeVector(new double[] { 4., 5., 6. }), new CMLLatticeVector(new double[] { 7., 8., 9. }) }); CMLVector3Test.assertEquals("construct", new double[] { 1., 2., 3. }, lattice.getCMLVector3(0), EPS); CMLVector3Test.assertEquals("construct", new double[] { 4., 5., 6. }, lattice.getCMLVector3(1), EPS); CMLVector3Test.assertEquals("construct", new double[] { 7., 8., 9. }, lattice.getCMLVector3(2), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLLattice.CMLLattice(CMLLatticeVector, * CMLLatticeVector, CMLLatticeVector)' */ @Test public void testCMLLatticeCMLLatticeVectorCMLLatticeVectorCMLLatticeVector() { CMLLattice lattice = new CMLLattice(new CMLLatticeVector(new double[] { 1., 2., 3. }), new CMLLatticeVector(new double[] { 4., 5., 6. }), new CMLLatticeVector(new double[] { 7., 8., 9. })); CMLVector3Test.assertEquals("construct", new double[] { 1., 2., 3. }, lattice.getCMLVector3(0), EPS); CMLVector3Test.assertEquals("construct", new double[] { 4., 5., 6. }, lattice.getCMLVector3(1), EPS); CMLVector3Test.assertEquals("construct", new double[] { 7., 8., 9. }, lattice.getCMLVector3(2), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLattice.getCellParameters()' */ @Test public void testGetCellParameters() { double[] params = lattice1.getCellParameters(); DoubleTestBase.assertEquals("params", new double[] { 12.328828005937952, 13.96424004376894, 11.968291440301744, 104.34229064539636, 86.89206686722031, 25.025508299339933 }, params, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLattice.getCMLVector3(int)' */ @Test public void testGetCMLVector3() { CMLVector3 v = lattice1.getCMLVector3(0); CMLVector3Test.assertEquals("cml vector", new double[] { 10.0, 6.0, 4.0 }, v, EPS); v = lattice1.getCMLVector3(1); CMLVector3Test.assertEquals("cml vector", new double[] { 7.0, 11.0, 5.0 }, v, EPS); v = lattice1.getCMLVector3(2); CMLVector3Test.assertEquals("cml vector", new double[] { 6.8, -4.0, -9.0 }, v, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLattice.getVolume()' */ @Test public void testGetVolume() { double vol = lattice1.getVolume(); Assert.assertEquals("lattice volume", -619.2, vol, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLattice.getReducedCell()' */ @Test public void testGetReducedCell() { CMLVector3Test.assertEquals("a", new double[] { 10., 6., 4. }, lattice1 .getCMLVector3(0), EPS); Assert.assertEquals("alen", 12.328828005937952, lattice1.getCMLVector3( 0).getLength(), EPS); CMLVector3Test.assertEquals("b", new double[] { 7., 11., 5. }, lattice1 .getCMLVector3(1), EPS); Assert.assertEquals("blen", 13.96424004376894, lattice1 .getCMLVector3(1).getLength(), EPS); CMLVector3Test.assertEquals("c", new double[] { 6.8, -4., -9. }, lattice1.getCMLVector3(2), EPS); Assert.assertEquals("clen", 11.968291440301744, lattice1.getCMLVector3( 2).getLength(), EPS); Assert.assertEquals("vol", -619.2, lattice1.getVolume(), EPS); double[] params = lattice1.getCellParameters(); DoubleTestBase.assertEquals("params", new double[] { 12.328828005937952, 13.96424004376894, 11.968291440301744, 104.34229064539636, 86.89206686722031, 25.025508299339933 }, params, EPS); CMLLattice reducedLattice = lattice1.getReducedCell(); CMLVector3Test.assertEquals("a", new double[] { 3.0, -5.0, -1.0 }, reducedLattice.getCMLVector3(0), EPS); Assert.assertEquals("alen", 5.916079783099616, reducedLattice .getCMLVector3(0).getLength(), EPS); CMLVector3Test.assertEquals("b", new double[] { 3.8, 1.0, -8.0 }, reducedLattice.getCMLVector3(1), EPS); Assert.assertEquals("blen", 8.912911982062877, reducedLattice .getCMLVector3(1).getLength(), EPS); CMLVector3Test.assertEquals("c", new double[] { 10.0, 6.0, 4.0 }, reducedLattice.getCMLVector3(2), EPS); Assert.assertEquals("clen", 12.328828005937952, reducedLattice .getCMLVector3(2).getLength(), EPS); Assert.assertEquals("vol", 619.2, reducedLattice.getVolume(), EPS); params = reducedLattice.getCellParameters(); DoubleTestBase.assertEquals("params", new double[] { 5.916079783099616, 8.912911982062877, 12.328828005937952, 83.73054962879554, 93.14372638090103, 74.15166267765416 }, params, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLattice.copy()' */ @Test public void testCopy() { CMLLattice lattice = (CMLLattice) lattice1.copy(); Assert.assertEquals("copy", 3, lattice.getLatticeVectorElements() .size()); CMLLatticeVectorTest.assertEquals("copy", new double[] { 10., 6., 4. }, lattice.getLatticeVectorElements().get(0), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLattice.getString()' */ @Test public void testGetString() { String s = lattice1.getString(); String ss = "[10. 6. 4.](12.328828005937952)" + "[7. 11. 5.](13.96424004376894)" + "[6.8 -4. -9.](11.968291440301744)"; Assert.assertEquals("getString", s, ss); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLLatticeVectorTest.java000077500000000000000000000102431477224461000307560ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.euclid.EuclidConstants.EPS; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.element.CMLLatticeVector; import org.xmlcml.cml.element.CMLVector3; import org.xmlcml.euclid.test.DoubleTestBase; /** * test latticeVector. * * @author pm286 * */ public class CMLLatticeVectorTest { String latticeVector1S = "1. 2. 3."; CMLLatticeVector latticeVector1 = null; /** * setUp. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { latticeVector1 = (CMLLatticeVector) new CMLBuilder() .parseString(latticeVector1S); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLLatticeVector test, CMLLatticeVector expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); DoubleTestBase.assertEquals(msg, test.getXMLContent(), expected .getXMLContent(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 3 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, CMLLatticeVector expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); DoubleTestBase.assertEquals(msg, test, expected.getXMLContent(), epsilon); } /** * Test method for 'org.xmlcml.cml.element.CMLLatticeVector.copy()' */ @Test public void testCopy() { CMLLatticeVector latticeVector = (CMLLatticeVector) latticeVector1 .copy(); CMLLatticeVectorTest.assertEquals("copy", new double[] { 1., 2., 3. }, latticeVector, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLLatticeVector.CMLLatticeVector(double[])' */ @Test public void testCMLLatticeVectorDoubleArray() { CMLLatticeVector latticeVector = new CMLLatticeVector(new double[] { 1., 2., 3 }); CMLLatticeVectorTest.assertEquals("doubleArray constructor", new double[] { 1., 2., 3. }, latticeVector, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLLatticeVector.CMLLatticeVector(CMLVector3)' */ @Test public void testCMLLatticeVectorCMLVector3() { CMLVector3 v = new CMLVector3(1., 2., 3); CMLLatticeVector latticeVector = new CMLLatticeVector(v); CMLLatticeVectorTest.assertEquals("vector3 constructor", new double[] { 1., 2., 3. }, latticeVector, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLatticeVector.getCMLVector3()' */ @Test public void testGetCMLVector3() { CMLLatticeVector latticeVector = new CMLLatticeVector(new double[] { 1., 2., 3 }); CMLVector3 v = latticeVector.getCMLVector3(); CMLVector3Test.assertEquals("get vector3", new double[] { 1., 2., 3. }, v, EPS); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLLengthTest.java000077500000000000000000000125751477224461000274410ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.euclid.EuclidConstants.EPS; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLBond; import org.xmlcml.cml.element.CMLCml; import org.xmlcml.cml.element.CMLLength; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.test.StringTestBase; /** * test length. * * @author pm286 * */ public class CMLLengthTest { String s1 = "" + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "" + ""; CMLLength length0; CMLLength length1; CMLLength length2; CMLMolecule molecule1; /** * set up. * * @exception Exception */ @Before public synchronized void setUp() throws Exception { CMLCml cml = (CMLCml)CMLXOMTestUtils.parseValidString(s1); molecule1 = (CMLMolecule) cml.getChildCMLElements("molecule").get(0); length0 = (CMLLength) cml.getChildCMLElements("length").get(0); length1 = (CMLLength) cml.getChildCMLElements("length").get(1); length2 = (CMLLength) cml.getChildCMLElements("length").get(2); } /** * Test method for 'org.xmlcml.cml.element.CMLLength.copy()' */ @Test public final void testCopy() { CMLLength length00 = (CMLLength) length0.copy(); StringTestBase.assertEquals("atomRefs2", new String[] { "a1", "a2" }, length00.getAtomRefs2()); } /** * Test method for 'org.xmlcml.cml.element.CMLLength.getAtomIds()' */ @Test public final void testGetAtomIds() { List idList = length0.getAtomIds(); Assert.assertNotNull("atom ids should not be null", idList); Assert.assertEquals("atom ids", 2, idList.size()); Assert.assertEquals("atom id 0", "a1", idList.get(0)); Assert.assertEquals("atom id 1", "a2", idList.get(1)); length0.removeAttribute("atomRefs2"); idList = length0.getAtomIds(); Assert.assertNull("atom ids should be null", idList); } /** * Test method for 'org.xmlcml.cml.element.CMLLength.getAtoms2()' */ @Test public final void testGetAtoms() { List atomRefs2 = null; try { atomRefs2 = length0.getAtoms(molecule1); } catch (RuntimeException e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertNotNull("atomRefs2 not null", atomRefs2); String msg = RuntimeException.class.getName() + ": cannot find atom a4"; try { atomRefs2 = length2.getAtoms(molecule1); Assert.fail("should always throw " + msg); } catch (RuntimeException e) { Assert.assertEquals("non existent atom ", msg, "" + e); } } /** * Test method for * 'org.xmlcml.cml.element.CMLLength.getCalculatedLength(CMLMolecule)' */ @Test public final void testGetCalculatedLength() { double length = length0.getCalculatedLength(molecule1); Assert.assertEquals("length0 ", 1.0, length, EPS); length = length1.getCalculatedLength(molecule1); Assert.assertEquals("length1 ", 1.0, length, EPS); String msg = RuntimeException.class.getName() + ": cannot find atom a4"; try { length = length2.getCalculatedLength(molecule1); } catch (RuntimeException e) { Assert.assertEquals("non existent ", msg, "" + e); } } /** * Test method for * 'org.xmlcml.cml.element.CMLLength.getIndexedLengths(List)' */ @Test public final void testGetIndexedLengths() { List lengths = new ArrayList(); lengths.add(length0); lengths.add(length1); Map map = CMLLength.getIndexedLengths(lengths); Assert.assertEquals("size of map", 1, map.size()); // retrieve by atom ids CMLLength length = map.get(CMLBond.atomHash("a1", "a2")); Assert.assertNotNull("length not null", length); StringTestBase.assertEquals("atomRefs2 ", new String[] { "a2", "a1" }, length.getAtomRefs2()); // retrieve in other order length = map.get(CMLBond.atomHash("a2", "a1")); Assert.assertNotNull("length not null", length); StringTestBase.assertEquals("atomRefs2 ", new String[] { "a2", "a1" }, length.getAtomRefs2()); // non existent length = map.get(CMLBond.atomHash("a4", "a2")); Assert.assertNull("length null", length); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLLine3Test.java000077500000000000000000000325721477224461000271710ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.euclid.EuclidConstants.EPS; import java.io.StringReader; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.element.CMLLine3; import org.xmlcml.cml.element.CMLPlane3; import org.xmlcml.cml.element.CMLPoint3; import org.xmlcml.cml.element.CMLTransform3; import org.xmlcml.cml.element.CMLVector3; import org.xmlcml.euclid.Angle; import org.xmlcml.euclid.EuclidConstants; import org.xmlcml.euclid.Line3; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Vector3; import org.xmlcml.euclid.test.DoubleTestBase; /** * tset CMLLine3 * * @author pmr * */ public class CMLLine3Test extends GeomTestBase { CMLPoint3 pp = null; CMLVector3 vv = null; CMLLine3 ll = null; double s14 = Math.sqrt(14.); CMLPoint3 xomP; CMLPlane3 xomPl; CMLLine3 xomL; CMLVector3 xomV; CMLPoint3 xomP111; CMLPoint3 xomP100; CMLPoint3 xomP010; CMLPoint3 xomP001; CMLPoint3 xomP123; CMLPlane3 xomPl0100; CMLPlane3 xomPl1002; CMLPlane3 xomPl1115; CMLPlane3 xomPl1005; CMLLine3 xomL555111; CMLVector3 xomV000; CMLVector3 xomV100; CMLVector3 xomV010; CMLVector3 xomV001; CMLVector3 xomV111; CMLVector3 xomV123; CMLVector3 xomV321; CMLLine3 xomL220011; CMLTransform3 xomT1; String xmlP111S; String xmlP100S; String xmlP010S; String xmlP001S; String xmlP123S; CMLPoint3 xmlP111; CMLPoint3 xmlP100; CMLPoint3 xmlP010; CMLPoint3 xmlP001; CMLPoint3 xmlP123; /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ private static void assertEquals(String msg, CMLLine3 test, CMLLine3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); Assert.assertTrue(test.getEuclidLine3().isEqualTo(expected.getEuclidLine3())); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param testVector * @param testPoint * @param expected * @param epsilon */ private static void assertEquals(String msg, CMLPoint3 testPoint, CMLVector3 testVector, CMLLine3 expected, double epsilon) { Assert.assertNotNull("testVector should not be null (" + msg + CMLConstants.S_RBRAK, testVector); Assert.assertNotNull("testPoint should not be null (" + msg + CMLConstants.S_RBRAK, testPoint); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); Vector3 test = testVector.getEuclidVector3(); Vector3 expected1 = new Vector3(expected.getVector3()); Assert.assertNotNull("test should not be null (" + msg + EuclidConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + EuclidConstants.S_RBRAK, expected1); DoubleTestBase.assertEquals(msg, test.getArray(), expected1.getArray(), epsilon); Assert.assertTrue(testPoint.getEuclidPoint3().isEqualTo(new Point3(expected.getPoint3()))); } /** * Test method for 'org.xmlcml.cml.element.CMLLine3.CMLLine3()' */ @Test public void testCMLLine3() { CMLLine3 l = (CMLLine3) ll.copy(); CMLLine3Test.assertEquals("copy constructor", l, ll, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLine3 parse()' */ @Test public void testParse() { String s = "1. 2. 3. 4. 5. 6. "; CMLLine3 l = null; try { l = (CMLLine3) new CMLBuilder().build(new StringReader(s)) .getRootElement(); } catch (Exception e) { Assert.fail("should not throw exception" + e.getMessage()); } CMLLine3Test.assertEquals("parse", new CMLPoint3(4., 5., 6.), new CMLVector3(1., 2., 3.), l, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLine3.CMLLine3(CMLLine3)' */ @Test public void testCMLLine3CMLLine3() { CMLLine3 l = new CMLLine3(xomL220011); CMLLine3Test.assertEquals("copy", l, xomL220011, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLine3.CMLLine3(CMLPoint3, * CMLVector3)' */ @Test public void testCMLLine3CMLPoint3CMLVector3() { double x = 1. / Math.sqrt(14.); double[] v = new double[] { 1., 2., 3. }; double[] p = new double[] { 4., 5., 6. }; CMLLine3 l = new CMLLine3(new CMLPoint3(p), new CMLVector3(v)); CMLLine3Test.assertEquals("line", new CMLPoint3(p), new CMLVector3(x, 2 * x, 3 * x), l, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLine3.CMLLine3(CMLPoint3, * CMLPoint3)' */ @Test public void testCMLLine3CMLPoint3CMLPoint3() { double[] d1 = new double[] { 1., 2., 3. }; double[] d2 = new double[] { 4., 5., 6. }; CMLPoint3 p1 = new CMLPoint3(d1); CMLPoint3 p2 = new CMLPoint3(d2); CMLLine3 l = new CMLLine3(p1, p2); CMLLine3Test.assertEquals("line", new CMLPoint3(d1), new CMLVector3( -3., -3., -3.), l, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLine3.equals(CMLLine3)' */ @Test public void testEqualsCMLLine3() { CMLLine3 l = new CMLLine3(pp, vv); Assert.assertTrue("equals", l.isEqualTo(ll)); } /** * Test method for 'org.xmlcml.cml.element.CMLLine3.subtract()' */ @Test public void testSubtract() { CMLLine3 l2 = ll.subtract(); CMLLine3Test.assertEquals("subtract", new CMLPoint3(6., 5., 4.), new CMLVector3(-1., -2., -3.).normalize(), l2, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLLine3.transform(CMLTransform3)' */ @Test public void testTransform() { CMLVector3 v = new CMLVector3(new double[] { 1., 1., 1. }); CMLTransform3 t = new CMLTransform3(v, Math.PI * 2. / 3.); CMLTransform3Test.assertEquals("transform", new double[] { 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }, t, EPS); CMLLine3 l1 = ll.transform(t); CMLLine3Test.assertEquals("l1", new CMLPoint3(4., 6., 5.), new CMLVector3(3. / s14, 1. / s14, 2. / s14), l1, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLine3.isParallelTo(CMLLine3)' */ @Test public void testIsParallelTo() { CMLLine3 l2 = new CMLLine3(ll); Assert.assertTrue("parallel", ll.isParallelTo(l2)); CMLLine3 l3 = new CMLLine3(pp, new CMLVector3(1.1, 2.1, 3.1)); Assert.assertFalse("parallel", ll.isParallelTo(l3)); } /** * Test method for * 'org.xmlcml.cml.element.CMLLine3.containsPoint(CMLPoint3)' */ @Test public void testContainsPoint() { CMLPoint3 p = new CMLPoint3(new double[] { 6, 5, 4 }); Assert.assertTrue("contains", ll.containsPoint(p)); p = new CMLPoint3(new double[] { 4, 5, 6 }); Assert.assertFalse("contains", ll.containsPoint(p)); } /** * Test method for * 'org.xmlcml.cml.element.CMLLine3.getClosestPointTo(CMLPoint3)' */ @Test public void testGetClosestPointTo() { CMLPoint3 p0 = new CMLPoint3(0., 0., 0.); CMLPoint3 p = ll.getClosestPointTo(p0); double d = p0.getDistanceFromPoint(p); Assert.assertEquals("line distance", 4.58257569495584, d, 0.0001); // show result is perpendicular CMLVector3 v = p.subtract(p0); CMLVector3 vv = new CMLVector3(ll.getVector3()); Angle a = v.getAngleMadeWith(vv); Assert.assertNotNull("angle ", a); Assert.assertEquals("angle closest", Math.PI / 2., a.getRadian(), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLLine3.getDistanceFromPoint(CMLPoint3)' */ @Test public void testGetDistanceFromPoint() { CMLPoint3 p = new CMLPoint3(1., 1., 1.); CMLLine3 l = new CMLLine3(new CMLPoint3(4., 5., 6.), new CMLVector3(1., 2., 3.)); double d = l.getDistanceFromPoint(p); Assert.assertEquals("distance", 1.3093073414159544, d, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLLine3.getIntersectionWith(CMLPlane3)' */ @Test public void testGetIntersectionWith() { CMLPlane3 pl = new CMLPlane3(new CMLVector3(1., 2., 3.), 4.); CMLLine3 l = new CMLLine3(new CMLPoint3(4., 5., 6.), new CMLVector3(1., 2., 3.)); CMLPoint3 pp = l.getIntersectionWith(pl); CMLPoint3Test.assertEquals("intersection", new double[] { 2.7833306819354116, 2.5666613638708236, 2.349992045806235 }, pp, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLine3.copy()' */ @Test public void testCopy() { CMLLine3 l = (CMLLine3) ll.copy(); CMLVector3 vv = new CMLVector3(1., 2., 3.); CMLLine3Test.assertEquals("copy point", new CMLPoint3(6., 5., 4.), vv .normalize(), l, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLine3.CMLLine3(Line3)' */ @Test public void testCMLLine3Line3() { Line3 lll = new Line3(new Point3(1., 2., 3.), new Vector3(4., 5., 6.)); CMLLine3 l = new CMLLine3(lll); CMLLine3Test.assertEquals("construct point", new CMLPoint3(1., 2., 3.), new CMLVector3(4., 5., 6.).normalize(), l, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLine3.getEuclidLine3()' */ @Test public void testGetEuclidLine3() { Line3 l = ll.getEuclidLine3(); Line3 expected=new Line3(new Point3(6., 5., 4.), new Vector3(1., 2., 3.).normalize()); Assert.assertTrue(l.isEqualTo(expected)); } /** * Test method for 'org.xmlcml.cml.element.CMLLine3.setVector3(CMLVector3)' */ @Test public void testSetVector3CMLVector3() { double s = Math.sqrt(14.); DoubleTestBase.assertEquals("set vector", new double[] { 1. / s, 2. / s, 3. / s }, ll.getVector3(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLLine3.isEqualTo(CMLLine3)' */ @Test public void testIsEqualTo() { } /** * Test method for * 'org.xmlcml.cml.element.CMLLine3.isAntiparallelTo(CMLLine3)' */ @Test public void testIsAntiparallelTo() { } /** * Test method for 'org.xmlcml.cml.element.CMLLine3.getString()' */ @Test public void testGetString() { } /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { vv = new CMLVector3(1., 2., 3.); pp = new CMLPoint3(6., 5., 4.); ll = new CMLLine3(pp, vv); // create from XOM // xomP = new CMLPoint3(); // deliberately disallowed // xomPl = new CMLPlane3(); // deliberately disallowed // xomL = new CMLLine3(); // deliberately disallowed // xomV = new CMLVector3(); // deliberately disallowed xomP111 = new CMLPoint3(new double[] { 1., 1., 1. }); xomP100 = new CMLPoint3(new double[] { 1., 0., 0. }); xomP010 = new CMLPoint3(new double[] { 0., 1., 0. }); xomP001 = new CMLPoint3(new double[] { 0., 0., 1. }); xomP123 = new CMLPoint3(new double[] { 1., 2., 3. }); xomPl0100 = new CMLPlane3(new double[] { 0., 1., 0., 0. }); xomPl1002 = new CMLPlane3(new double[] { 1., 0., 0., 2. }); xomPl1005 = new CMLPlane3(new double[] { 1., 0., 0., 5. }); xomPl1115 = new CMLPlane3(new double[] { 1., 1., 1., 5. }); // xomL555111 = new CMLLine3(new double[]{5., 5., 5., 1., 1., 1.}); xomL220011 = new CMLLine3(new CMLPoint3(0., 1., 1.), new CMLVector3(2., 2., 0.)); xomV000 = new CMLVector3(new double[] { 0., 0., 0. }); xomV100 = new CMLVector3(new double[] { 1., 0., 0. }); xomV010 = new CMLVector3(new double[] { 0., 1., 0. }); xomV001 = new CMLVector3(new double[] { 0., 0., 1. }); xomV111 = new CMLVector3(new double[] { 1., 1., 1. }); xomV123 = new CMLVector3(new double[] { 1., 2., 3. }); xomV321 = new CMLVector3(new double[] { 3., 2., 1. }); // create from XML xmlP111S = "1. 1. 1."; xmlP100S = "1 0 0"; xmlP010S = "0 1.0E+00 0"; xmlP001S = "0 0 1"; xmlP123S = "1 2 3"; CMLBuilder builder = new CMLBuilder(); xmlP111 = (CMLPoint3) builder.build(new StringReader(xmlP111S)) .getRootElement(); xmlP123 = (CMLPoint3) builder.build(new StringReader(xmlP123S)) .getRootElement(); xmlP100 = (CMLPoint3) builder.build(new StringReader(xmlP100S)) .getRootElement(); xmlP010 = (CMLPoint3) builder.build(new StringReader(xmlP010S)) .getRootElement(); xmlP001 = (CMLPoint3) builder.build(new StringReader(xmlP001S)) .getRootElement(); } void makeXomT1() { xomT1 = new CMLTransform3(new double[] { 0., 1., 0., 0., 0., 0., 1., 0., -1., 0., 0., 0., 0., 0., 0., 1. }); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLMapTest.java000077500000000000000000000570031477224461000267300ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.base.CMLXOMTestUtils.assertEqualsCanonically; import java.util.ArrayList; import java.util.List; import nu.xom.Elements; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLBond; import org.xmlcml.cml.element.CMLLink; import org.xmlcml.cml.element.CMLMap; import org.xmlcml.cml.element.CMLPeak; import org.xmlcml.cml.element.CMLMap.Direction; import org.xmlcml.euclid.Util; import org.xmlcml.euclid.test.StringTestBase; /** * test CMLMap. * * @author pmr * */ public class CMLMapTest { CMLMap xomMap1; CMLMap xmlMap1; String xmlMap1S = "" + " " + " " + " " + "" + ""; CMLMap xmlMap2; String xmlMap2S = "" + " " + " " + " " + "" + CMLConstants.S_EMPTY; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { xmlMap1 = (CMLMap)CMLXOMTestUtils.parseValidString(xmlMap1S); xmlMap2 = (CMLMap)CMLXOMTestUtils.parseValidString(xmlMap2S); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.copy()' */ @Test public void testCopy() { CMLMap copyMap = (CMLMap) xmlMap1.copy(); Assert.assertEquals("copy", 0, copyMap.compareTo(xmlMap1)); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.CMLMap()' */ @Test public void testCMLMap() { xomMap1 = new CMLMap(); Assert.assertNotNull("map", xomMap1); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.CMLMap(CMLMap)' */ @Test public void testCMLMapCMLMap() { CMLMap copyMap = new CMLMap(xmlMap1); Assert.assertEquals("copy", 0, copyMap.compareTo(xmlMap1)); Assert.assertEquals("copy", -1, copyMap.compareTo(xmlMap2)); } /** * Test method for * 'org.xmlcml.cml.element.CMLMap.makeElementInContext(Element)' */ @Test public void testMakeElementInContext() { Assert.assertNotNull("constructor", xmlMap1); Assert.assertEquals("constructor", "m1", xmlMap1.getId()); Elements links = xmlMap1.getChildCMLElements(CMLLink.TAG); Assert.assertEquals("constructor", 3, links.size()); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getReverseToFrom(String)' */ @Test public void testGetReverseToFrom() { CMLMap.Direction reverse = CMLMap.getReverseToFrom(CMLMap.Direction.TO); Assert.assertEquals("to", true, reverse.equals(CMLMap.Direction.FROM)); reverse = CMLMap.getReverseToFrom(CMLMap.Direction.FROM); Assert.assertEquals("from", true, reverse.equals(CMLMap.Direction.TO)); reverse = CMLMap.getReverseToFrom(CMLMap.Direction.EITHER); Assert.assertNull("either", reverse); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.addLink(CMLLink)' */ @Test public void testAddLinkCMLLink() { CMLElements links = xmlMap1.getLinkElements(); Assert.assertEquals("links", 3, links.size()); CMLLink link = new CMLLink(); link.setTo("a4"); link.setFrom("a14"); xmlMap1.addLink(link); links = xmlMap1.getLinkElements(); Assert.assertEquals("links", 4, links.size()); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.addUniqueLink(CMLLink, * String)' */ @Test public void testAddUniqueLink() { CMLElements links = xmlMap1.getLinkElements(); Assert.assertEquals("links", 3, links.size()); CMLLink link = new CMLLink(); link.setTo("a4"); link.setFrom("a14"); xmlMap1.addUniqueLink(link, CMLMap.Direction.EITHER); links = xmlMap1.getLinkElements(); Assert.assertEquals("links", 4, links.size()); // dont add if currently exists link = new CMLLink(); link.setTo("a4"); link.setFrom("a15"); xmlMap1.addUniqueLink(link, CMLMap.Direction.NEITHER); links = xmlMap1.getLinkElements(); Assert.assertEquals("links", 4, links.size()); link = new CMLLink(); link.setTo("a4"); link.setFrom("a15"); xmlMap1.addUniqueLink(link, CMLMap.Direction.BOTH); links = xmlMap1.getLinkElements(); Assert.assertEquals("links", 5, links.size()); link = new CMLLink(); link.setTo("a4"); link.setFrom("a15"); xmlMap1.addUniqueLink(link, CMLMap.Direction.EITHER); links = xmlMap1.getLinkElements(); Assert.assertEquals("links", 5, links.size()); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.addMap(CMLMap)' */ @Test public void testAddMap() { Assert.assertEquals("add map1", 3, xmlMap1.getLinkElements().size()); xmlMap1.addMap(xmlMap2); Assert.assertEquals("add map1", 6, xmlMap1.getLinkElements().size()); Assert.assertEquals("add map2", 3, xmlMap2.getLinkElements().size()); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.removeLink(CMLLink)' */ @Test public void testRemoveLink() { CMLLink link; Assert.assertEquals("remove link", 3, xmlMap1.getLinkElements().size()); link = xmlMap1.getLink("a2", CMLMap.Direction.FROM); Assert.assertNotNull("get link", link); Assert.assertEquals("get link", "a12", link.getTo()); Assert.assertEquals("get link", "a2", link.getFrom()); xmlMap1.removeLink(link); Assert.assertEquals("remove link", 2, xmlMap1.getLinkElements().size()); link = xmlMap1.getLink("a2", CMLMap.Direction.FROM); Assert.assertNull("get link", link); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getToRefs()' */ @Test public void testGetToFromRefs() { List toRefs = xmlMap1.getToRefs(); Assert.assertNotNull("toRefs", toRefs); Assert.assertEquals("toRefs", 3, toRefs.size()); StringTestBase.assertEquals("toRefs", new String[] { "a11", "a12", "a13" }, toRefs.toArray(new String[0])); List fromRefs = xmlMap1.getFromRefs(); Assert.assertNotNull("fromRefs", fromRefs); Assert.assertEquals("fromRefs", 3, fromRefs.size()); StringTestBase.assertEquals("fromRefs", new String[] { "a1", "a2", "a3" }, fromRefs .toArray(new String[0])); xmlMap1.mergeMap(xmlMap2, Direction.NEITHER); toRefs = xmlMap1.getToRefs(); StringTestBase.assertEquals("toRefs", new String[] { "a11", "a12", "a13", "a14", "a15", "a16" }, toRefs.toArray(new String[0])); fromRefs = xmlMap1.getFromRefs(); StringTestBase.assertEquals("fromRefs", new String[] { "a1", "a2", "a3", "a4", "a5", "a6" }, fromRefs.toArray(new String[0])); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getToRef(String)' */ @Test public void testGetToFromRef() { String toRef; String fromRef; toRef = xmlMap1.getToRef("a1"); Assert.assertNotNull("toRef", toRef); Assert.assertEquals("toRef", "a11", toRef); toRef = xmlMap1.getToRef("a4"); Assert.assertNull("toRef", toRef); fromRef = xmlMap1.getFromRef("a11"); Assert.assertNotNull("fromRef", fromRef); Assert.assertEquals("fromRef", "a1", fromRef); fromRef = xmlMap1.getFromRef("a14"); Assert.assertNull("fromRef", fromRef); xmlMap1.mergeMap(xmlMap2, Direction.NEITHER); toRef = xmlMap1.getToRef("a4"); Assert.assertNotNull("toRef", toRef); Assert.assertEquals("toRef", "a14", toRef); fromRef = xmlMap1.getFromRef("a14"); Assert.assertNotNull("fromRef", fromRef); Assert.assertEquals("fromRef", "a4", fromRef); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getToRefs(List)' */ @Test public void testGetToFromRefsStringList() { String[] toS = new String[] { "a13", "a11", "a14" }; String[] fromS = new String[] { "a3", "a1", "a4" }; List toIds = Util.createList(toS); List fromIds = Util.createList(fromS); List toRefs; List fromRefs; toRefs = xmlMap1.getToRefs(fromIds); Assert.assertNotNull("toRefs", toRefs); Assert.assertEquals("toRefs", 3, toRefs.size()); StringTestBase.assertEquals("toRefs", new String[] { "a13", "a11", null }, toRefs .toArray(new String[0])); fromRefs = xmlMap1.getFromRefs(toIds); Assert.assertNotNull("fromRefs", fromRefs); Assert.assertEquals("fromRefs", 3, fromRefs.size()); StringTestBase.assertEquals("fromRefs", new String[] { "a3", "a1", null }, fromRefs .toArray(new String[0])); xmlMap1.mergeMap(xmlMap2, Direction.NEITHER); toRefs = xmlMap1.getToRefs(fromIds); Assert.assertNotNull("toRefs", toRefs); Assert.assertEquals("toRefs", 3, toRefs.size()); StringTestBase.assertEquals("toRefs", new String[] { "a13", "a11", "a14" }, toRefs.toArray(new String[0])); fromRefs = xmlMap1.getFromRefs(toIds); Assert.assertNotNull("fromRefs", fromRefs); Assert.assertEquals("fromRefs", 3, fromRefs.size()); StringTestBase.assertEquals("fromRefs", new String[] { "a3", "a1", "a4" }, fromRefs .toArray(new String[0])); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getRefs(String)' */ @Test public void testGetRefsString() { List toRefs = xmlMap1.getRefs(Direction.TO); Assert.assertNotNull("toRefs", toRefs); Assert.assertEquals("toRefs", 3, toRefs.size()); StringTestBase.assertEquals("toRefs", new String[] { "a11", "a12", "a13" }, toRefs.toArray(new String[0])); List fromRefs = xmlMap1.getRefs(Direction.FROM); Assert.assertNotNull("fromRefs", fromRefs); Assert.assertEquals("fromRefs", 3, fromRefs.size()); StringTestBase.assertEquals("fromRefs", new String[] { "a1", "a2", "a3" }, fromRefs .toArray(new String[0])); xmlMap1.mergeMap(xmlMap2, Direction.NEITHER); toRefs = xmlMap1.getRefs(Direction.TO); Assert.assertEquals("toRefs", new String[] { "a11", "a12", "a13", "a14", "a15", "a16" }, toRefs.toArray(new String[0])); fromRefs = xmlMap1.getRefs(Direction.FROM); Assert.assertEquals("fromRefs", new String[] { "a1", "a2", "a3", "a4", "a5", "a6" }, fromRefs.toArray(new String[0])); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getRefs(String[], String)' */ @Test public void testGetRefsStringArrayString() { String[] toS = new String[] { "a13", "a11", "a14" }; String[] fromS = new String[] { "a3", "a1", "a4" }; List toIds = Util.createList(toS); List fromIds = Util.createList(fromS); List toRefs; List fromRefs; toRefs = xmlMap1.getRefs(fromIds, Direction.TO); Assert.assertNotNull("toRefs", toRefs); Assert.assertEquals("toRefs", 3, toRefs.size()); StringTestBase.assertEquals("toRefs", new String[] { "a13", "a11", null }, toRefs .toArray(new String[0])); fromRefs = xmlMap1.getRefs(toIds, Direction.FROM); Assert.assertNotNull("fromRefs", fromRefs); Assert.assertEquals("fromRefs", 3, fromRefs.size()); StringTestBase.assertEquals("fromRefs", new String[] { "a3", "a1", null }, fromRefs .toArray(new String[0])); xmlMap1.mergeMap(xmlMap2, Direction.NEITHER); toRefs = xmlMap1.getRefs(fromIds, Direction.TO); Assert.assertNotNull("toRefs", toRefs); Assert.assertEquals("toRefs", 3, toRefs.size()); StringTestBase.assertEquals("toRefs", new String[] { "a13", "a11", "a14" }, toRefs.toArray(new String[0])); fromRefs = xmlMap1.getRefs(toIds, Direction.FROM); Assert.assertNotNull("fromRefs", fromRefs); Assert.assertEquals("fromRefs", 3, fromRefs.size()); StringTestBase.assertEquals("fromRefs", new String[] { "a3", "a1", "a4" }, fromRefs .toArray(new String[0])); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getRef(String, Direction)' */ @Test public void testGetRef() { String ref; ref = xmlMap1.getRef("a12", CMLMap.Direction.TO); Assert.assertNotNull("get ref", ref); Assert.assertEquals("get ref", "a2", ref); ref = xmlMap1.getRef("a2", CMLMap.Direction.FROM); Assert.assertNotNull("get ref", ref); Assert.assertEquals("get ref", "a12", ref); ref = xmlMap1.getRef("a2", CMLMap.Direction.TO); Assert.assertNull("get ref", ref); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getLink(String, * Direction)' */ @Test public void testGetLink() { CMLLink link; link = xmlMap1.getLink("a12", CMLMap.Direction.TO); Assert.assertNotNull("get link", link); Assert.assertEquals("get link", "a12", link.getTo()); Assert.assertEquals("get link", "a2", link.getFrom()); link = xmlMap1.getLink("a2", CMLMap.Direction.FROM); Assert.assertNotNull("get link", link); Assert.assertEquals("get link", "a12", link.getTo()); Assert.assertEquals("get link", "a2", link.getFrom()); link = xmlMap1.getLink("a2", CMLMap.Direction.TO); Assert.assertNull("get link", link); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getFromToLink(String, * String)' */ @Test public void testGetFromToLink() { CMLLink link; link = xmlMap1.getFromToLink("a2", "a12"); Assert.assertNotNull("get link", link); link = xmlMap1.getFromToLink("a12", "a2"); Assert.assertNull("get link", link); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.mergeMap(CMLMap, String)' */ @Test public void testMergeMap() { xmlMap1.mergeMap(xmlMap2, CMLMap.Direction.NEITHER); Assert.assertNotNull("merge", xmlMap1); Assert.assertEquals("merge", 6, xmlMap1.getLinkElements().size()); Assert.assertEquals("merge", 3, xmlMap2.getLinkElements().size()); } /** * Test method for * 'org.xmlcml.cml.element.CMLMap.setLinkFromContext(String)' */ @Test public void testSetLinkToFromContext() { String fromContext = "mol1"; String toContext = "mol2"; Assert.assertNull("context", xmlMap1.getToContext()); Assert.assertNull("context", xmlMap1.getFromContext()); for (CMLLink link : xmlMap1.getLinkElements()) { Assert.assertNull("link", link.getFromContext()); Assert.assertNull("link", link.getToContext()); } xmlMap1.setLinkFromContext(fromContext); xmlMap1.setLinkToContext(toContext); for (CMLLink link : xmlMap1.getLinkElements()) { Assert.assertEquals("link", fromContext, link.getFromContext()); Assert.assertEquals("link", toContext, link.getToContext()); } } /** * Test method for 'org.xmlcml.cml.element.CMLMap.setLinkFromType(String)' */ @Test public void testSetLinkToFromType() { Assert.assertEquals("type", CMLAtom.NS, xmlMap1.getToType()); Assert.assertEquals("type", CMLAtom.NS, xmlMap1.getFromType()); String toType = CMLPeak.NS; String fromType = CMLBond.NS; for (CMLLink link : xmlMap1.getLinkElements()) { Assert.assertNull("link", link.getFromType()); Assert.assertNull("link", link.getToType()); } xmlMap1.setLinkToType(toType); xmlMap1.setLinkFromType(fromType); Assert.assertEquals("type", CMLAtom.NS, xmlMap1.getToType()); Assert.assertEquals("type", CMLAtom.NS, xmlMap1.getFromType()); for (CMLLink link : xmlMap1.getLinkElements()) { Assert.assertEquals("type", fromType, link.getFromType()); Assert.assertEquals("type", toType, link.getToType()); } } /** * Test method for 'org.xmlcml.cml.element.CMLMap.annotateLinks(String, * String, String, String)' */ @Test public void testAnnotateLinks() { String toType = CMLPeak.NS; String fromType = CMLBond.NS; String fromContext = "mol1"; String toContext = "mol2"; for (CMLLink link : xmlMap1.getLinkElements()) { Assert.assertNull("link", link.getFromType()); Assert.assertNull("link", link.getToType()); Assert.assertNull("link", link.getFromContext()); Assert.assertNull("link", link.getToContext()); } xmlMap1.annotateLinks(fromType, fromContext, toType, toContext); for (CMLLink link : xmlMap1.getLinkElements()) { Assert.assertEquals("type", fromType, link.getFromType()); Assert.assertEquals("type", toType, link.getToType()); Assert.assertEquals("link", "mol1", link.getFromContext()); Assert.assertEquals("link", "mol2", link.getToContext()); } } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getToRefs()' */ @Test public void testGetToRefs() { List toRefList = xmlMap1.getToRefs(); StringTestBase.assertEquals("toRefs", new String[] { "a11", "a12", "a13" }, (String[]) toRefList.toArray(new String[0])); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getFromRefs()' */ @Test public void testGetFromRefs() { List fromRefList = xmlMap1.getFromRefs(); StringTestBase.assertEquals("fromRefs", new String[] { "a1", "a2", "a3" }, (String[]) fromRefList .toArray(new String[0])); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getToRef(String)' */ @Test public void testGetToRef() { String toRef = xmlMap1.getToRef("a1"); Assert.assertEquals("toRef", "a11", toRef); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getFromRef(String)' */ @Test public void testGetFromRef() { String fromRef = xmlMap1.getFromRef("a11"); Assert.assertEquals("fromRef", "a1", fromRef); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getToRefs(List)' */ @Test public void testGetToRefsListOfString() { List fromList = new ArrayList(); fromList.add("a2"); fromList.add("a3"); fromList.add("a1"); List toRef = xmlMap1.getToRefs(fromList); StringTestBase.assertEquals("toRef", new String[] { "a12", "a13", "a11" }, (String[]) toRef .toArray(new String[0])); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getFromRefs(List)' */ @Test public void testGetFromRefsListOfString() { List toList = new ArrayList(); toList.add("a12"); toList.add("a13"); toList.add("a11"); List fromRef = xmlMap1.getFromRefs(toList); StringTestBase.assertEquals("toRef", new String[] { "a2", "a3", "a1" }, (String[]) fromRef.toArray(new String[0])); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getRefs(Direction)' */ @Test public void testGetRefsDirection() { List ref = xmlMap1.getRefs(Direction.EITHER); StringTestBase.assertEquals("ref", new String[] { "a1", "a2", "a3" }, (String[]) ref.toArray(new String[0])); ref = xmlMap1.getRefs(Direction.BOTH); StringTestBase.assertEquals("ref", new String[] { "a1", "a2", "a3" }, (String[]) ref.toArray(new String[0])); ref = xmlMap1.getRefs(Direction.NEITHER); StringTestBase.assertEquals("ref", new String[] { "a1", "a2", "a3" }, (String[]) ref.toArray(new String[0])); ref = xmlMap1.getRefs(Direction.FROM); StringTestBase.assertEquals("ref", new String[] { "a1", "a2", "a3" }, (String[]) ref.toArray(new String[0])); ref = xmlMap1.getRefs(Direction.TO); StringTestBase.assertEquals("ref", new String[] { "a11", "a12", "a13" }, (String[]) ref .toArray(new String[0])); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getRefs(List, * Direction)' */ @Test public void testGetRefsListOfStringDirection() { List list = new ArrayList(); list.add("a12"); list.add("a3"); list.add("a11"); List ref = xmlMap1.getRefs(list, Direction.EITHER); StringTestBase.assertEquals("ref", new String[] { null, "a13", null }, (String[]) ref.toArray(new String[0])); ref = xmlMap1.getRefs(list, Direction.BOTH); StringTestBase.assertEquals("ref", new String[] { null, "a13", null }, (String[]) ref.toArray(new String[0])); ref = xmlMap1.getRefs(list, Direction.NEITHER); StringTestBase.assertEquals("ref", new String[] { null, "a13", null }, (String[]) ref.toArray(new String[0])); ref = xmlMap1.getRefs(list, Direction.FROM); StringTestBase.assertEquals("ref", new String[] { "a2", null, "a1" }, (String[]) ref.toArray(new String[0])); ref = xmlMap1.getRefs(list, Direction.TO); StringTestBase.assertEquals("ref", new String[] { null, "a13", null }, (String[]) ref.toArray(new String[0])); } /** * Test method for * 'org.xmlcml.cml.element.CMLMap.setLinkFromContext(String)' */ @Test public void testSetLinkFromContext() { xmlMap1.setLinkFromContext("foo"); String ss = "" + " " + " " + " " + ""; CMLMap expected = (CMLMap)CMLXOMTestUtils.parseValidString(ss); assertEqualsCanonically("set from", expected, xmlMap1); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.setLinkToContext(String)' */ @Test public void testSetLinkToContext() { xmlMap1.setLinkToContext("foo"); String ss = "" + " " + " " + " " + ""; CMLMap expected = (CMLMap)CMLXOMTestUtils.parseValidString(ss); assertEqualsCanonically("set to", expected, xmlMap1); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.setLinkFromType(String)' */ @Test public void testSetLinkFromType() { xmlMap1.setLinkFromType("foo"); String ss = "" + " " + " " + " " + ""; CMLMap expected = (CMLMap)CMLXOMTestUtils.parseValidString(ss); assertEqualsCanonically("set fromType", expected, xmlMap1); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.setLinkToType(String)' */ @Test public void testSetLinkToType() { xmlMap1.setLinkToType("foo"); String ss = "" + " " + " " + " " + ""; CMLMap expected = (CMLMap)CMLXOMTestUtils.parseValidString(ss); assertEqualsCanonically("set fromType", expected, xmlMap1); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getElementLinks(String)' */ @Test public void testGetElementLinks() { List links = xmlMap1.getElementLinks("foo"); Assert.assertEquals("links", 0, links.size()); } /** * Test method for 'org.xmlcml.cml.element.CMLMap.getType(CMLLink, * Direction)' */ @Test public void testGetType() { CMLLink link = xmlMap1.getLinkElements().get(0); String type = CMLMap.getType(link, Direction.TO); Assert.assertEquals("link type", CMLAtom.NS, type); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLMatrixTest.java000077500000000000000000000517251477224461000274640ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.base.CMLConstants.SIUNIT_NS; import static org.xmlcml.cml.base.CMLConstants.UNIT_NS; import static org.xmlcml.cml.base.CMLConstants.U_CELSIUS; import static org.xmlcml.cml.base.CMLConstants.U_DEGREE; import static org.xmlcml.cml.base.CMLConstants.U_KCAL; import static org.xmlcml.cml.base.CMLConstants.XSD_DOUBLE; import static org.xmlcml.cml.base.CMLConstants.XSD_INTEGER; import static org.xmlcml.euclid.EuclidConstants.EPS; import static org.xmlcml.euclid.EuclidConstants.S_RBRAK; import java.util.ArrayList; import java.util.List; import nu.xom.Elements; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLCml; import org.xmlcml.cml.element.CMLMatrix; import org.xmlcml.cml.element.CMLScalar; import org.xmlcml.euclid.EC; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.Int; import org.xmlcml.euclid.IntMatrix; import org.xmlcml.euclid.RealMatrix; import org.xmlcml.euclid.test.DoubleTestBase; /** * test matrix. * * @author pmr * */ public class CMLMatrixTest { String unitsS = "" + "" + " 180 90 " + " 45 0" + "" + " 100 50 " + " 0 -25" + "" + " 100 50" + " 0 -50" + ""; CMLCml cml = null; List matrixList = new ArrayList(); /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { if (cml == null) { cml = (CMLCml)CMLXOMTestUtils.parseValidString(unitsS); Elements matrixElements = cml.getChildCMLElements(CMLMatrix.TAG); Assert.assertEquals("matrix element count", 3, matrixElements .size()); for (int i = 0; i < matrixElements.size(); i++) { matrixList.add((CMLMatrix) matrixElements.get(i)); } } } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param rows * @param cols * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, int rows, int cols, double[] test, CMLMatrix expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + S_RBRAK, expected); Assert.assertEquals("rows ", rows, expected.getRows()); Assert.assertEquals("columns ", cols, expected.getColumns()); RealMatrix expected1 = expected .getEuclidRealMatrix(); Assert.assertNotNull("test should not be null (" + msg + EC.S_RBRAK, test); Assert.assertNotNull("ref should not be null (" + msg + EC.S_RBRAK, expected1); Assert.assertEquals("rows should be equal (" + msg + EC.S_RBRAK, rows, expected1.getRows()); Assert.assertEquals("columns should be equal (" + msg + EC.S_RBRAK, cols, expected1.getCols()); DoubleTestBase.assertEquals(msg, test, expected1.getMatrixAsArray(), epsilon); } /** * equality test. true if both args not null and equal * * @param msg * message * @param rows * @param cols * @param test * @param expected */ public static void assertEquals(String msg, int rows, int cols, int[] test, CMLMatrix expected) { Assert.assertNotNull("test should not be null (" + msg + S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + S_RBRAK, expected); Assert.assertEquals("rows ", rows, expected.getRows()); Assert.assertEquals("columns ", cols, expected.getColumns()); IntMatrix expected1 = expected .getEuclidIntMatrix(); Assert.assertNotNull("test should not be null (" + msg + S_RBRAK, test); Assert.assertNotNull("ref should not be null (" + msg + S_RBRAK, expected1); Assert.assertEquals("rows should be equal (" + msg + S_RBRAK, rows, expected1.getRows()); Assert.assertEquals("columns should be equal (" + msg + S_RBRAK, cols, expected1.getCols()); String s = Int.testEquals(test, expected1.getMatrixAsArray()); if (s != null) { Assert.fail(msg + "; " + s); } } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.getDataType()' */ @Test public void testGetDataType() { Assert.assertEquals("get data type", XSD_DOUBLE, matrixList.get(0) .getDataType()); Assert.assertEquals("get data type", XSD_DOUBLE, matrixList.get(1) .getDataType()); Assert.assertEquals("get data type", XSD_DOUBLE, matrixList.get(2) .getDataType()); } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.getRows()' */ @Test public void testGetRows() { Assert.assertEquals("get rows", 2, matrixList.get(0).getRows()); Assert.assertEquals("get rows", 2, matrixList.get(1).getRows()); Assert.assertEquals("get rows", 2, matrixList.get(2).getRows()); } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.getColumns()' */ @Test public void testGetColumns() { Assert.assertEquals("get columns", 2, matrixList.get(0).getColumns()); Assert.assertEquals("get columns", 2, matrixList.get(1).getColumns()); Assert.assertEquals("get columns", 2, matrixList.get(2).getColumns()); } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.CMLMatrix()' */ @Test public void testCMLMatrix() { } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.CMLMatrix(CMLMatrix)' */ @Test public void testCMLMatrixCMLMatrix() { } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.CMLMatrix(double[][])' */ @Test public void testCMLMatrixDoubleArrayArray() { double[][] mat = new double[][] { new double[] { 11., 12., 13. }, new double[] { 21., 22., 23. }, new double[] { 31., 32., 33. }, new double[] { 41., 42., 43. }, }; CMLMatrix testMat = null; try { testMat = new CMLMatrix(mat); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertEquals("double[][] constructor", 4, testMat.getRows()); Assert.assertEquals("double[][] constructor", 3, testMat.getColumns()); // Assert.assertEquals("double[][] constructor", 23., // testMat.getElement(2, 3), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.CMLMatrix(int[][])' */ @Test public void testCMLMatrixIntArrayArray() { int[][] mat = new int[][] { new int[] { 11, 12, 13 }, new int[] { 21, 22, 23 }, new int[] { 31, 32, 33 }, new int[] { 41, 42, 43 }, }; CMLMatrix testMat = null; try { testMat = new CMLMatrix(mat); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertEquals("int[][] constructor", 4, testMat.getRows()); Assert.assertEquals("int[][] constructor", 3, testMat.getColumns()); } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.CMLMatrix(int, int, * double[])' */ @Test public void testCMLMatrixIntIntDoubleArray() { double[] mat = new double[] { 11., 12., 13., 21., 22., 23., 31., 32., 33., 41., 42., 43., }; CMLMatrix testMat = null; try { testMat = new CMLMatrix(4, 3, mat); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertEquals("double[][] constructor", 4, testMat.getRows()); Assert.assertEquals("double[][] constructor", 3, testMat.getColumns()); } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.CMLMatrix(int, int, * int[])' */ @Test public void testCMLMatrixIntIntIntArray() { int[] mat = new int[] { 11, 12, 13, 21, 22, 23, 31, 32, 33, 41, 42, 43, }; CMLMatrix testMat = null; try { testMat = new CMLMatrix(4, 3, mat); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertEquals("int[][] constructor", 4, testMat.getRows()); Assert.assertEquals("int[][] constructor", 3, testMat.getColumns()); } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.getEuclidRealMatrix()' */ @Test public void testGetEuclidRealMatrix() { RealMatrix euclMatrix = matrixList.get(0).getEuclidRealMatrix(); Assert.assertNotNull("eucl realMatrix", euclMatrix); Assert.assertEquals("euclidMatrix", 2, euclMatrix.getRows()); Assert.assertEquals("euclidMatrix", 2, euclMatrix.getCols()); } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.getEuclidIntMatrix()' */ @Test public void testGetEuclidIntMatrix() { try { matrixList.get(0).getEuclidIntMatrix(); Assert.fail("int matrix should throw EuclidRuntimeException"); } catch (EuclidRuntimeException e) { } } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.setMatrix(double[][])' */ @Test public void testSetMatrixDoubleArrayArray() { CMLMatrix mat = matrixList.get(0); DoubleTestBase.assertEquals("set matrix double[][]", new double[] { 180., 90., 45, 0. }, mat.getDoubleArray(), EPS); Assert.assertEquals("set mat", XSD_DOUBLE, mat.getDataType()); try { mat.setMatrix(new double[][] { new double[] { 11., 12., 13. }, new double[] { 21., 22., 23. }, new double[] { 31., 32., 33. }, new double[] { 41., 42., 43. } }); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertEquals("set mat", XSD_DOUBLE, mat.getDataType()); Assert.assertEquals("set mat", 4, mat.getRows()); Assert.assertEquals("set mat", 3, mat.getColumns()); DoubleTestBase.assertEquals("set matrix double[][]", new double[] { 11., 12., 13., 21., 22., 23., 31., 32., 33., 41., 42., 43. }, mat.getDoubleArray(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.setMatrix(int[][])' */ @Test public void testSetMatrixIntArrayArray() { CMLMatrix mat = matrixList.get(0); // deliberately set doubles and change later DoubleTestBase.assertEquals("set matrix int[][]", new double[] { 180., 90., 45, 0. }, mat.getDoubleArray(), EPS); Assert.assertEquals("set mat", XSD_DOUBLE, mat.getDataType()); try { mat.setMatrix(new int[][] { new int[] { 11, 12, 13 }, new int[] { 21, 22, 23 }, new int[] { 31, 32, 33 }, new int[] { 41, 42, 43 } }); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertEquals("set mat", 4, mat.getRows()); Assert.assertEquals("set mat", 3, mat.getColumns()); String s = Int.testEquals((new int[] { 11, 12, 13, 21, 22, 23, 31, 32, 33, 41, 42, 43 }), mat.getIntegerArray()); if (s != null) { Assert.fail("set matrix int[][]" + "; " + s); } Assert.assertEquals("set mat", XSD_INTEGER, mat.getDataType()); } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.setArray(int, int, * double[])' */ @Test public void testSetArrayIntIntDoubleArray() { CMLMatrix mat = matrixList.get(0); DoubleTestBase.assertEquals("set matrix double[][]", new double[] { 180., 90., 45, 0. }, mat.getDoubleArray(), EPS); Assert.assertEquals("set mat", XSD_DOUBLE, mat.getDataType()); try { mat.setArray(4, 3, new double[] { 11., 12., 13., 21., 22., 23., 31., 32., 33., 41., 42., 43. }); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertEquals("set mat", XSD_DOUBLE, mat.getDataType()); Assert.assertEquals("set mat", 4, mat.getRows()); Assert.assertEquals("set mat", 3, mat.getColumns()); DoubleTestBase.assertEquals("set matrix double[][]", new double[] { 11., 12., 13., 21., 22., 23., 31., 32., 33., 41., 42., 43. }, mat.getDoubleArray(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.setArray(int, int, * int[])' */ @Test public void testSetArrayIntIntIntArray() { CMLMatrix mat = matrixList.get(0); DoubleTestBase.assertEquals("set matrix int, int, []", new double[] { 180., 90., 45, 0. }, mat.getDoubleArray(), EPS); Assert.assertEquals("set mat", XSD_DOUBLE, mat.getDataType()); try { mat.setArray(4, 3, new int[] { 11, 12, 13, 21, 22, 23, 31, 32, 33, 41, 42, 43 }); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertEquals("set mat", XSD_INTEGER, mat.getDataType()); Assert.assertEquals("set mat", 4, mat.getRows()); Assert.assertEquals("set mat", 3, mat.getColumns()); String s = Int.testEquals((new int[] { 11, 12, 13, 21, 22, 23, 31, 32, 33, 41, 42, 43 }), mat.getIntegerArray()); if (s != null) { Assert.fail("set matrix int, int []" + "; " + s); } } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.getDoubleArray()' */ @Test public void testGetDoubleArray() { CMLMatrix mat = matrixList.get(0); DoubleTestBase.assertEquals("get array []", new double[] { 180., 90., 45, 0. }, mat.getDoubleArray(), EPS); Assert.assertEquals("get array", XSD_DOUBLE, mat.getDataType()); } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.getDoubleMatrix()' */ @Test public void testGetDoubleMatrix() { CMLMatrix mat = matrixList.get(0); double[][] doubleMatrix = mat.getDoubleMatrix(); Assert.assertEquals("get matrix double[][]", 2, doubleMatrix.length); DoubleTestBase.assertEquals("get matrix double[][]", new double[] { 180., 90. }, doubleMatrix[0], EPS); DoubleTestBase.assertEquals("get matrix double[][]", new double[] { 45., 0. }, doubleMatrix[1], EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.isSquare()' */ @Test public void testIsSquare() { CMLMatrix mat = matrixList.get(0); Assert.assertTrue("square", mat.isSquare()); } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.isEqualTo(CMLMatrix, * double)' */ @Test public void testIsEqualTo() { CMLMatrix mat = matrixList.get(0); Assert.assertTrue("equals", mat.isEqualTo(mat, EPS)); } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.multiply(CMLMatrix)' */ @Test public void testMultiply() { CMLMatrix mat = matrixList.get(0); CMLMatrix mat1 = null; try { mat1 = mat.multiply(mat); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } CMLMatrixTest.assertEquals("multiply", 2, 2, new double[] { 36450., 16200., 8100., 4050. }, mat1, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.copy()' */ @Test public void testCopy() { CMLMatrix m = (CMLMatrix) matrixList.get(0).copy(); CMLMatrix expected = matrixList.get(0); Assert.assertNotNull("test should not be null (" + "copy" + S_RBRAK, m); Assert.assertNotNull("expected should not be null (" + "copy" + S_RBRAK, expected); if (m.getEuclidRealMatrix() != null) { RealMatrix test = m.getEuclidRealMatrix(); RealMatrix expected1 = expected.getEuclidRealMatrix(); Assert.assertNotNull("test should not be null (" + "copy" + EC.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + "copy" + EC.S_RBRAK, expected1); Assert.assertNotNull("expected should have columns (" + "copy" + EC.S_RBRAK, expected1.getCols()); Assert.assertNotNull("expected should have rows (" + "copy" + EC.S_RBRAK, expected1.getRows()); Assert.assertNotNull("test should have columns (" + "copy" + EC.S_RBRAK, test .getCols()); Assert.assertNotNull("test should have rows (" + "copy" + EC.S_RBRAK, test .getRows()); Assert.assertEquals("rows should be equal (" + "copy" + EC.S_RBRAK, test .getRows(), expected1.getRows()); Assert.assertEquals("columns should be equal (" + "copy" + EC.S_RBRAK, test .getCols(), expected1.getCols()); DoubleTestBase.assertEquals("copy", test.getMatrixAsArray(), expected1 .getMatrixAsArray(), EPS); } else if (m.getEuclidIntMatrix() != null) { IntMatrix test = m.getEuclidIntMatrix(); IntMatrix expected1 = expected .getEuclidIntMatrix(); Assert.assertNotNull("test should not be null (" + "copy" + S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + "copy" + S_RBRAK, expected1); Assert.assertNotNull("expected should have columns (" + "copy" + S_RBRAK, expected1.getCols()); Assert.assertNotNull("expected should have rows (" + "copy" + S_RBRAK, expected1.getRows()); Assert.assertNotNull("test should have columns (" + "copy" + S_RBRAK, test .getCols()); Assert.assertNotNull("test should have rows (" + "copy" + S_RBRAK, test .getRows()); Assert.assertEquals("rows should be equal (" + "copy" + S_RBRAK, test .getRows(), expected1.getRows()); Assert.assertEquals("columns should be equal (" + "copy" + S_RBRAK, test .getCols(), expected1.getCols()); String s = Int.testEquals(test.getMatrixAsArray(), expected1 .getMatrixAsArray()); if (s != null) { Assert.fail("copy" + "; " + s); } } else { Assert.fail("both matrices must be either real or int" + m); } } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.getIntegerArray()' */ @Test public void testGetIntegerArray() { int[] ii = new int[] { 11, 12, 13, 21, 22, 23 }; CMLMatrix m = new CMLMatrix(2, 3, ii); String s = Int.testEquals(ii, m.getIntegerArray()); if (s != null) { Assert.fail("int[]" + "; " + s); } } /** * Test method for 'org.xmlcml.cml.element.CMLMatrix.getIntegerMatrix()' */ @Test public void testGetIntegerMatrix() { CMLMatrix mat = new CMLMatrix(2, 3, new double[] { 1.1, 2.2, 3.3, 11.1, 12.2, 13.3 }); CMLMatrixTest.assertEquals("real mat", 2, 3, new double[] { 1.1, 2.2, 3.3, 11.1, 12.2, 13.3 }, mat, EPS); int[][] ii = mat.getIntegerMatrix(); Assert.assertNull("real is null", ii); mat = new CMLMatrix(2, 3, new int[] { 1, 2, 3, 11, 12, 13 }); CMLMatrixTest.assertEquals("int mat", 2, 3, new int[] { 1, 2, 3, 11, 12, 13 }, mat); ii = mat.getIntegerMatrix(); IntMatrix imat = new IntMatrix(ii); int[] test = new int[] { 1, 2, 3, 11, 12, 13 }; Assert.assertNotNull("test should not be null (" + "int mat" + S_RBRAK, test); Assert.assertNotNull("ref should not be null (" + "int mat" + S_RBRAK, imat); Assert.assertEquals("rows should be equal (" + "int mat" + S_RBRAK, 2, imat.getRows()); Assert.assertEquals("columns should be equal (" + "int mat" + S_RBRAK, 3, imat.getCols()); String s = Int.testEquals(test, imat.getMatrixAsArray()); if (s != null) { Assert.fail("int mat" + "; " + s); } } @Test public void testSerializedDelimiter() { CMLMatrix mat = new CMLMatrix(2, 3, new double[] { 1.1, 2.2, 3.3, 11.1, 12.2, 13.3 }); String xml = mat.toXML(); String ref = "1.1 2.2 3.3 11.1 12.2 13.3"; Assert.assertEquals("serial", ref, xml); } @Test public void testGetScalar() { CMLMatrix mat = new CMLMatrix(2, 3, new int[] { 11, 12, 13, 21, 22, 23 }); mat.setDictRef("foo:bar"); CMLScalar scalar = mat.getElementAt(1,1); String ref="22"; Assert.assertEquals("getElement", ref, scalar.toXML()); scalar = mat.getElementAt(0,2); ref="13"; Assert.assertEquals("getElement", ref, scalar.toXML()); } @Test public void testGetScalar1() { CMLMatrix mat = new CMLMatrix(2, 3, new int[] { 11, 12, 13, 21, 22, 23 }); mat.setDictRef("foo:bar"); CMLScalar scalar = mat.getElementAt(2,1); Assert.assertNull(scalar); scalar = mat.getElementAt(-1,1); Assert.assertNull(scalar); scalar = mat.getElementAt(1,-1); Assert.assertNull(scalar); scalar = mat.getElementAt(1,3); Assert.assertNull(scalar); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLMetadataListTest.java000077500000000000000000000101161477224461000305610ustar00rootroot00000000000000/** * 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.main; import java.util.List; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLMetadata; import org.xmlcml.cml.element.CMLMetadataList; import org.xmlcml.cml.element.CMLMolecule; /** * tests metadataList. * * @author pmr * */ public class CMLMetadataListTest { String moleculeS = "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "" + CMLConstants.S_EMPTY; CMLMolecule molecule; CMLMetadataList metadataList0; CMLMetadataList metadataList1; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { molecule = (CMLMolecule)CMLXOMTestUtils.parseValidString(moleculeS); metadataList0 = (CMLMetadataList) molecule .getFirstCMLChild(CMLMetadataList.TAG); metadataList1 = (CMLMetadataList) molecule.getChildCMLElements( CMLMetadataList.TAG).get(1); } /** * Test method for * 'org.xmlcml.cml.element.CMLMetadataList.CMLMetadataList()'. */ @Test public void testCMLMetadataList() { } /** * Test method for * 'org.xmlcml.cml.element.CMLMetadataList.CMLMetadataList(CMLMetadataList)' */ @Test public void testCMLMetadataListCMLMetadataList() { } /** * Test method for * 'org.xmlcml.cml.element.CMLMetadataList.getMetadataDescendants()' */ @Test public void testGetMetadataDescendants() { List metadatas = CMLMetadataList .getMetadataDescendants(molecule); Assert.assertEquals("metadata descendants", 6, metadatas.size()); Assert.assertEquals("metadata descendant 1", "foo:foo1", metadatas.get( 0).getName()); } /** * Test method for * 'org.xmlcml.cml.element.CMLMetadataList.getMetadataDescendants(CMLElement * ) ' */ @Test public void testGetMetadataDescendantsCMLElement() { List metadatas = metadataList0.getMetadataDescendants(); Assert.assertEquals("metadata descendants", 3, metadatas.size()); Assert.assertEquals("metadata descendant 2", "foo:foo2", metadatas.get( 1).getName()); } // /** // * Test method for // * // 'org.xmlcml.cml.element.CMLMetadataList.getMetadataDescendantsByNameListString' // */ // @Test // public void testGetMetadataDescendantsByNameListString() { // } // /** // * Test method for // * // 'org.xmlcml.cml.element.CMLMetadataList.getMetadataDescendantsByName(String)' // */ // @Test // public void testGetMetadataDescendantsByNameString() { // List metadatas = metadataList0 // .getMetadataDescendantsByName("foo:foo1"); // Assert.assertEquals("metadata descendants", 2, metadatas.size()); // Assert.assertEquals("metadata descendant 2", "bar31", metadatas.get(1) // .getContent()); // } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLMetadataTest.java000077500000000000000000000022001477224461000277200ustar00rootroot00000000000000/** * 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.main; import nu.xom.Attribute; import org.junit.Test; import org.xmlcml.cml.element.CMLMetadata; /** * test for metadata. * * @author pm286 * */ public class CMLMetadataTest { /** * Test method for * 'org.xmlcml.cml.element.CMLMetadata.addAttribute(Attribute)' */ @Test public void testAddAttributeAttribute() { CMLMetadata metadata = new CMLMetadata(); metadata.addAttribute(new Attribute("foo", "bar")); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLNodeFactoryTest.java000077500000000000000000000047741477224461000304370ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.base.CMLConstants.CML1; import nu.xom.Element; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.euclid.EuclidRuntimeException; /** * test OldNodeFactory. * * @author pmr * */ public class CMLNodeFactoryTest { /** * Test method for * 'org.xmlcml.cml.element.OldNodeFactory.startMakingElement(String, * String)' * DOES NOT TEST THIS ROUTINE!!!!!!! */ @Test public void testStartMakingElementStringString() { String s1 = ""; CMLElement cmlElement = (CMLElement)CMLXOMTestUtils.parseValidString(s1); String namespace = cmlElement.getNamespaceURI(); Assert.assertEquals("ok namespace", CMLConstants.CML_NS, namespace); // guess namespace s1 = ""; try { cmlElement = (CMLElement) new CMLBuilder().parseString(s1); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertTrue("is CMLElement", CMLElement.class .isAssignableFrom(cmlElement.getClass())); namespace = cmlElement.getNamespaceURI(); Assert.assertEquals("old namespace -> new", CMLConstants.CML_NS, namespace); Element element = null; // cannot guess namespace s1 = ""; try { element = (Element) new CMLBuilder().parseString(s1); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertFalse("is CMLElement", CMLElement.class .isAssignableFrom(element.getClass())); namespace = element.getNamespaceURI(); Assert.assertEquals("other namespace", "http://foo", namespace); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLParameterListTest.java000077500000000000000000000101261477224461000307620ustar00rootroot00000000000000/** * 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.main; import java.util.List; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLParameter; import org.xmlcml.cml.element.CMLParameterList; /** * tests parameterList. * * @author pm286 * */ public class CMLParameterListTest { String parameterS = CMLConstants.S_EMPTY + "" + " " + " 1.23" + " " + " " + " " + " 11.23" + " " + " " + "" + CMLConstants.S_EMPTY; CMLParameterList parameterList = null; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { parameterList = (CMLParameterList)CMLXOMTestUtils.parseValidString(parameterS); } /** * Test method for 'org.xmlcml.cml.element.CMLParameterList.copy()' */ @Test public void testCopy() { CMLParameterList parameterListX = (CMLParameterList) parameterList .copy(); Assert.assertNotNull("copy not null", parameterListX); } /** * Test method for * 'org.xmlcml.cml.element.CMLParameterList.getParameterDescendants()' */ @Test public void testGetParameterDescendants() { List paramList = parameterList.getParameterDescendants(); Assert.assertEquals("param list", 2, paramList.size()); // note order is variable Assert.assertEquals("param 0", "foo:mpt", paramList.get(0).getName()); Assert.assertEquals("param 1", "foo:angle", paramList.get(1).getName()); } /** * Test method for * 'org.xmlcml.cml.element.CMLParameterList.getParameterDescendants(CMLElement * ) ' */ @Test public void testGetParameterDescendantsCMLElement() { List paramList = CMLParameterList .getParameterDescendants(parameterList); Assert.assertEquals("param list", 2, paramList.size()); // note order is variable Assert.assertEquals("param 0", "foo:mpt", paramList.get(0).getName()); Assert.assertEquals("param 1", "foo:angle", paramList.get(1).getName()); } /** * Test method for'org.xmlcml.cml.element.CMLParameterList.getParameterDescendantsByDictRef(List , String)' */ @Test public void testGetParameterDescendantsByDictRef() { List paramList = CMLParameterList .getParameterDescendants(parameterList); Assert.assertEquals("param list", 2, paramList.size()); List paramListX = CMLParameterList .getParameterDescendantsByDictRef(paramList, "bar:xxx"); Assert.assertEquals("param list", 1, paramListX.size()); Assert .assertEquals("param 0", "foo:angle", paramListX.get(0) .getName()); } /** * Test method for * 'org.xmlcml.cml.element.CMLParameterList.getParameterDescendantsByName(String * ) ' */ @Test public void testGetParameterDescendantsByName() { List paramListX = parameterList .getParameterDescendantsByName("foo:angle"); Assert.assertEquals("param list", 1, paramListX.size()); Assert .assertEquals("param 0", "foo:angle", paramListX.get(0) .getName()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLParseTest.java000077500000000000000000000137721477224461000272720ustar00rootroot00000000000000/** * 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.main; import java.io.IOException; import java.io.StringReader; import nu.xom.Element; import nu.xom.ParsingException; import nu.xom.ValidityException; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLElement; /** * *

* superclass for manage common methods for unit tests *

* * @author Peter Murray-Rust * @version 5.0 * */ public class CMLParseTest { CMLBuilder builder = new CMLBuilder(); /** * Test method for 'org.xmlcml.cml.element.CMLPoint3 parse' */ @Test public void testBasicParse() { String xml1S = ""; try { Element e = builder.build(new StringReader(xml1S)).getRootElement(); Assert.assertFalse("non cml", (e instanceof CMLElement)); } catch (ValidityException e) { Assert .fail("should not throw validity exception " + e.getMessage()); } catch (ParsingException e) { Assert.fail("should not throw parse exception " + e.getMessage()); } catch (IOException e) { Assert.fail("should not throw IO exception " + e.getMessage()); } catch (RuntimeException e) { Assert.fail("should not throw CMLRuntime exception " + e.getMessage()); } // parsing errors can be caught but XOM seems to print errors on syserr // as well /* * -- deliberate error, but omit to avoid confusion String xml2S = * ""; try { builder.build(new StringReader(xml2S)); * Assert.fail("should throw parse exception "); } catch * (ValidityException e) { * Assert.fail("should not throw validity exception "+e.getMessage()); } * catch (ParsingException e) { Assert.assertEquals("parse exception ", * "XML document structures must start and end within the same entity.", * e.getMessage()); } catch (IOException e) { * Assert.fail("should not throw IO exception "+e.getMessage()); } catch * (CMLRuntime e) { * Assert.fail("should not throw CMLRuntime exception "+e.getMessage()); * } -- */ /* * -- deliberate error, but omit to avoid confusion String xml3S = * ""; try { builder.build(new * StringReader(xml3S)).getRootElement(); * Assert.fail("should throw parse exception "); } catch * (ValidityException e) { * Assert.fail("should not throw validity exception "+e.getMessage()); } * catch (ParsingException e) { Assert.assertEquals("parse exception ", * "Attribute \"a\" was already specified for element 'foo'.", * e.getMessage()); } catch (IOException e) { * Assert.fail("should not throw IO exception "+e.getMessage()); } catch * (CMLRuntime e) { * Assert.fail("should not throw CMLRuntime exception "+e.getMessage()); * } -- */ /* * -- deliberate error, but omit to avoid confusion String xml4S = * "<1foo a='a' a='b'/>"; try { builder.build(new * StringReader(xml4S)).getRootElement(); * Assert.fail("should throw parse exception "); } catch * (ValidityException e) { * Assert.fail("should not throw validity exception "+e.getMessage()); } * catch (ParsingException e) { Assert.assertEquals("parse exception ", * "The markup in the document preceding the root element must be well-formed." * , e.getMessage()); } catch (IOException e) { * Assert.fail("should not throw IO exception "+e.getMessage()); } catch * (CMLRuntime e) { * Assert.fail("should not throw CMLRuntime exception "+e.getMessage()); * } -- */ String xml5S = ""; try { builder.build(new StringReader(xml5S)).getRootElement(); } catch (ValidityException e) { Assert .fail("should not throw validity exception " + e.getMessage()); } catch (ParsingException e) { Assert.assertEquals("parse exception ", "Unprefixed attribute id cannot be in default namespace 1", e.getMessage()); } catch (IOException e) { Assert.fail("should not throw IO exception " + e.getMessage()); } catch (RuntimeException e) { Assert.fail("should not throw CMLRuntime exception " + e.getMessage()); } String xml6S = ""; try { builder.build(new StringReader(xml6S)).getRootElement(); } catch (ValidityException e) { Assert .fail("should not throw validity exception " + e.getMessage()); } catch (ParsingException e) { Assert .assertEquals( "parse exception ", "Unprefixed attribute id cannot be in default namespace a1", e.getMessage()); } catch (IOException e) { Assert.fail("should not throw IO exception " + e.getMessage()); } catch (RuntimeException e) { Assert.fail("should not throw CMLRuntime exception " + e.getMessage()); } String xml7S = ""; try { builder.build(new StringReader(xml7S)).getRootElement(); } catch (ValidityException e) { Assert .fail("should not throw validity exception " + e.getMessage()); } catch (ParsingException e) { Assert.assertEquals("parse exception ", "Unprefixed attribute b cannot be in default namespace b", e.getMessage()); } catch (IOException e) { Assert.fail("should not throw IO exception " + e.getMessage()); } catch (RuntimeException e) { Assert.fail("should not throw CMLRuntime exception " + e.getMessage()); } } /** * run tests. * * @return the suite. * */ } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLPlane3Test.java000077500000000000000000000375641477224461000273470ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.euclid.EuclidConstants.EPS; import java.io.StringReader; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.element.CMLLine3; import org.xmlcml.cml.element.CMLPlane3; import org.xmlcml.cml.element.CMLPoint3; import org.xmlcml.cml.element.CMLTransform3; import org.xmlcml.cml.element.CMLVector3; import org.xmlcml.euclid.EC; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.Plane3; import org.xmlcml.euclid.Util; import org.xmlcml.euclid.test.DoubleTestBase; /** * test CMLPlane3 * * @author pmr * */ public class CMLPlane3Test extends GeomTestBase { CMLPoint3 xomP; CMLPlane3 xomPl; CMLLine3 xomL; CMLVector3 xomV; CMLPoint3 xomP111; CMLPoint3 xomP100; CMLPoint3 xomP010; CMLPoint3 xomP001; CMLPoint3 xomP123; CMLPlane3 xomPl0100; CMLPlane3 xomPl1002; CMLPlane3 xomPl1115; CMLPlane3 xomPl1005; CMLLine3 xomL555111; CMLVector3 xomV000; CMLVector3 xomV100; CMLVector3 xomV010; CMLVector3 xomV001; CMLVector3 xomV111; CMLVector3 xomV123; CMLVector3 xomV321; CMLLine3 xomL220011; CMLTransform3 xomT1; String xmlP111S; String xmlP100S; String xmlP010S; String xmlP001S; String xmlP123S; CMLPoint3 xmlP111; CMLPoint3 xmlP100; CMLPoint3 xmlP010; CMLPoint3 xmlP001; CMLPoint3 xmlP123; /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLPlane3 test, CMLPlane3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); DoubleTestBase.assertEquals(msg, test.getArray(), expected.getArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 3 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, CMLPlane3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertEquals("must be of length 4", 4, test.length); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); DoubleTestBase.assertEquals(msg, test, expected.getArray(), epsilon); } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.CMLPlane3()' */ @Test public void testCMLPlane3() { // CMLPlane3 pl = new CMLPlane3(); // not visible } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.CMLPlane3(CMLPlane3)' */ @Test public void testCMLPlane3CMLPlane3() { CMLPlane3 p = new CMLPlane3(this.xomPl1002); CMLPlane3Test.assertEquals("copy", new double[] { 1., 0., 0., 2. }, p, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.CMLPlane3(double[])' */ @Test public void testCMLPlane3DoubleArray() { CMLPlane3 p = null; try { p = new CMLPlane3(new double[] { 1., 2., 3., 4. }); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } double x = Math.sqrt(14.); CMLPlane3Test.assertEquals("copy", new double[] { 1. / x, 2. / x, 3. / x, 4 }, p, EPS); try { p = new CMLPlane3(new double[] { 1., 2., 3. }); } catch (Exception e) { Assert.assertEquals("bad length", "array size required (4) found 3", e.getMessage()); } try { p = new CMLPlane3(new double[] { 0., 0., 0., 1. }); } catch (Exception e) { Assert.assertEquals("bad vector", "Cannot make plane with zero vector", e.getMessage()); } } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.CMLPlane3(double[], * double)' */ @Test public void testCMLPlane3DoubleArrayDouble() { double norm = Math.sqrt(14.); CMLPlane3 p = new CMLPlane3(new double[] { 1., 2., 3. }, 10.); CMLPlane3Test.assertEquals("new", new double[] { 1. / norm, 2. / norm, 3. / norm, 10 }, p, EPS); try { p = new CMLPlane3(new double[] { 1., 2. }, 20.); } catch (Exception e) { Assert .assertEquals( "bad length", "org.xmlcml.euclid.EuclidRuntimeException: array size required (3) found 2", e.getMessage()); } } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.CMLPlane3(CMLVector3, * double)' */ @Test public void testCMLPlane3CMLVector3Double() { double norm = Math.sqrt(14.); CMLPlane3 p = null; try { p = new CMLPlane3(new CMLVector3(new double[] { 1., 2., 3. }), 10.); } catch (RuntimeException e) { Util.BUG(e); } CMLPlane3Test.assertEquals("new", new double[] { 1. / norm, 2. / norm, 3. / norm, 10 }, p, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.CMLPlane3(CMLPoint3, * CMLPoint3, CMLPoint3)' */ @Test public void testCMLPlane3CMLPoint3CMLPoint3CMLPoint3() { double norm = Math.sqrt(3.); CMLPlane3 p = new CMLPlane3(xomP100, xomP010, xomP001); CMLPlane3Test.assertEquals("new", new double[] { 1. / norm, 1. / norm, 1. / norm, Math.sqrt(1. / 3.) }, p, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.CMLPlane3(CMLLine3, * CMLPoint3)' */ @Test public void testCMLPlane3CMLLine3CMLPoint3() { CMLPlane3 p = null; p = new CMLPlane3(xomL220011, xomP001); CMLPlane3Test.assertEquals("new", new double[] { 0.0, 0.0, -1.0, -1.0 }, p, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.setArray(double[])' */ @Test public void testSetArray() { try { xomPl1002.setArray(new double[] { 1., 2., 3., 4. }); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } double x = Math.sqrt(14.); CMLPlane3Test.assertEquals("new", new double[] { 1. / x, 2. / x, 3. / x, 4. }, xomPl1002, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.getArray()' */ @Test public void testGetArray() { double x = Math.sqrt(1. / 3.); double[] array = xomPl1115.getArray(); DoubleTestBase.assertEquals("get", new double[] { x, x, x, 5. }, array, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.getVector()' */ @Test public void testGetVector() { double x = Math.sqrt(1. / 3.); CMLVector3 v = xomPl1115.getVector(); CMLVector3Test.assertEquals("get", new double[] { x, x, x }, v, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.getDistance()' */ @Test public void testGetDistance() { // double x = Math.sqrt(1./3.); double d = xomPl1115.getDistance(); Assert.assertEquals("get", 5., d, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.negative()' */ @Test public void testNegative() { double x = -Math.sqrt(1. / 3.); xomPl1115.negative(); CMLPlane3Test.assertEquals("get", new double[] { x, x, x, 5. }, xomPl1115, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.equals(CMLPlane3)' */ @Test public void testEqualsCMLPlane3() { Assert.assertTrue("equal", xomPl1115.isEqualTo(xomPl1115)); Assert.assertFalse("equal", xomPl1002.isEqualTo(xomPl1115)); } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.subtract()' */ @Test public void testSubtract() { double x = -Math.sqrt(1. / 3.); CMLPlane3 p = xomPl1115.subtract(); CMLPlane3Test.assertEquals("subtract", new double[] { x, x, x, 5. }, p, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLPlane3.getDistanceFromPoint(CMLPoint3)' */ @Test public void testGetDistanceFromPoint() { Assert.assertEquals("distance", -2., xomPl1002.getDistanceFromPoint(new CMLPoint3(new double[] { 0., 0., 0. })), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLPlane3.isParallelTo(CMLPlane3)' */ @Test public void testIsParallelTo() { Assert.assertTrue("parallel", xomPl1115.isParallelTo(xomPl1115)); Assert.assertFalse("parallel", xomPl1115.isParallelTo(xomPl1002)); Assert.assertFalse("parallel", xomPl1115.isParallelTo(xomPl1115 .subtract())); } /** * Test method for * 'org.xmlcml.cml.element.CMLPlane3.isAntiparallelTo(CMLPlane3)' */ @Test public void testIsAntiparallelTo() { Assert.assertTrue("parallel", xomPl1115.isAntiparallelTo(xomPl1115 .subtract())); Assert.assertFalse("parallel", xomPl1115.isAntiparallelTo(xomPl1115)); Assert.assertFalse("parallel", xomPl1115.isAntiparallelTo(xomPl1002)); } /** * Test method for * 'org.xmlcml.cml.element.CMLPlane3.containsPoint(CMLPoint3)' */ @Test public void testContainsPoint() { double x = Math.sqrt(1. / 3.) * 5.; CMLPoint3 p = new CMLPoint3(new double[] { x, x, x }); Assert.assertTrue("contains", xomPl1115.containsPoint(p)); } /** * Test method for * 'org.xmlcml.cml.element.CMLPlane3.getClosestPointTo(CMLPoint3)' */ @Test public void testGetClosestPointTo() { double x = Math.sqrt(1. / 3.) * 5.; CMLPoint3 pp = new CMLPoint3(new double[] { x, x, x }); CMLPoint3 zz = xomPl1115.getClosestPointTo(pp); Assert.assertEquals("closest", 0.0, pp.getDistanceFromPoint(zz), EPS); CMLPoint3 ppp = new CMLPoint3(new double[] { 2 * x, 2 * x, 2 * x }); zz = xomPl1115.getClosestPointTo(ppp); double xx = 5. * Math.sqrt(1. / 3.); CMLPoint3Test.assertEquals("closest", new double[] { xx, xx, xx }, zz, .000000001); Assert.assertEquals("closest", 5., ppp.getDistanceFromPoint(zz), .000000001); } /** * Test method for * 'org.xmlcml.cml.element.CMLPlane3.getIntersectionWith(CMLLine3)' */ @Test public void testGetIntersectionWithCMLLine3() { CMLPoint3 p = xomPl1115.getIntersectionWith(xomL220011); Assert.assertTrue("intersection", p.isOnLine(xomL220011)); Assert.assertTrue("intersection", p.isOnPlane(xomPl1115)); } /** * Test method for * 'org.xmlcml.cml.element.CMLPlane3.getIntersectionWith(CMLPlane3)' */ @Test public void testGetIntersectionWithCMLPlane3() { CMLLine3 l = xomPl1115.getIntersectionWith(xomPl1002); CMLPoint3 p = new CMLPoint3(l.getPoint3()); Assert.assertTrue("intersection", p.isOnPlane(xomPl1115)); Assert.assertTrue("intersection", p.isOnPlane(xomPl1002)); } /** * Test method for * 'org.xmlcml.cml.element.CMLPlane3.getIntersectionWith(CMLPlane3, * CMLPlane3)' */ @Test public void testGetIntersectionWithCMLPlane3CMLPlane3() { CMLPoint3 p = xomPl1115.getIntersectionWith(xomPl1002, xomPl0100); // these seem to work! Assert.assertTrue("intersection", p.isOnPlane(xomPl1002)); Assert.assertTrue("intersection", p.isOnPlane(xomPl1115)); Assert.assertTrue("intersection", p.isOnPlane(xomPl0100)); } /** * Test method for * 'org.xmlcml.cml.element.CMLPlane3.getAngleMadeWith(CMLPlane3)' */ @Test public void testGetAngleMadeWith() { double a = xomPl1115.getAngleMadeWith(xomPl0100); double x = Math.acos(1. / Math.sqrt(3.)); Assert.assertEquals("angle", x, a, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.copy()' */ @Test public void testCopy() { CMLPlane3 p = new CMLPlane3(new CMLVector3(1., 2., 3.), 4.); CMLPlane3 pp = new CMLPlane3(p); CMLPlane3Test.assertEquals("copy", pp, p, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.CMLPlane3(Plane3)' */ @Test public void testCMLPlane3Plane3() { CMLPlane3 p = new CMLPlane3(new CMLVector3(1., 2., 3.), 4.); CMLPlane3 pp = new CMLPlane3(new Plane3(1., 2., 3., 4.)); CMLPlane3Test.assertEquals("constructor", pp, p, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.getEuclidPlane3()' */ @Test public void testGetEuclidPlane3() { CMLPlane3 p = new CMLPlane3(new CMLVector3(1., 2., 3.), 4.); Plane3 pp = p.getEuclidPlane3(); double d = Math.sqrt(14.); double[] test = new double[] { 1. / d, 2. / d, 3. / d, 4. }; Assert.assertNotNull("test should not be null (" + "getEuclidPlane" + EC.S_RBRAK, test); Assert.assertEquals("must be of length 4", 4, test.length); Assert.assertNotNull("ref should not be null (" + "getEuclidPlane" + EC.S_RBRAK, pp); DoubleTestBase.assertEquals("getEuclidPlane", test, pp.getArray(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPlane3.isEqualTo(CMLPlane3)' */ @Test public void testIsEqualTo() { CMLPlane3 p = new CMLPlane3(new CMLVector3(1., 2., 3.), 4.); CMLPlane3 pp = new CMLPlane3(p); Assert.assertTrue("isEqual", p.isEqualTo(pp)); } /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { // create from XOM // xomP = new CMLPoint3(); // deliberately disallowed // xomPl = new CMLPlane3(); // deliberately disallowed // xomL = new CMLLine3(); // deliberately disallowed // xomV = new CMLVector3(); // deliberately disallowed xomP111 = new CMLPoint3(new double[] { 1., 1., 1. }); xomP100 = new CMLPoint3(new double[] { 1., 0., 0. }); xomP010 = new CMLPoint3(new double[] { 0., 1., 0. }); xomP001 = new CMLPoint3(new double[] { 0., 0., 1. }); xomP123 = new CMLPoint3(new double[] { 1., 2., 3. }); xomPl0100 = new CMLPlane3(new double[] { 0., 1., 0., 0. }); xomPl1002 = new CMLPlane3(new double[] { 1., 0., 0., 2. }); xomPl1005 = new CMLPlane3(new double[] { 1., 0., 0., 5. }); xomPl1115 = new CMLPlane3(new double[] { 1., 1., 1., 5. }); // xomL555111 = new CMLLine3(new double[]{5., 5., 5., 1., 1., 1.}); xomL220011 = new CMLLine3(new CMLPoint3(0., 1., 1.), new CMLVector3(2., 2., 0.)); xomV000 = new CMLVector3(new double[] { 0., 0., 0. }); xomV100 = new CMLVector3(new double[] { 1., 0., 0. }); xomV010 = new CMLVector3(new double[] { 0., 1., 0. }); xomV001 = new CMLVector3(new double[] { 0., 0., 1. }); xomV111 = new CMLVector3(new double[] { 1., 1., 1. }); xomV123 = new CMLVector3(new double[] { 1., 2., 3. }); xomV321 = new CMLVector3(new double[] { 3., 2., 1. }); // create from XML xmlP111S = "1. 1. 1."; xmlP100S = "1 0 0"; xmlP010S = "0 1.0E+00 0"; xmlP001S = "0 0 1"; xmlP123S = "1 2 3"; CMLBuilder builder = new CMLBuilder(); xmlP111 = (CMLPoint3) builder.build(new StringReader(xmlP111S)) .getRootElement(); xmlP123 = (CMLPoint3) builder.build(new StringReader(xmlP123S)) .getRootElement(); xmlP100 = (CMLPoint3) builder.build(new StringReader(xmlP100S)) .getRootElement(); xmlP010 = (CMLPoint3) builder.build(new StringReader(xmlP010S)) .getRootElement(); xmlP001 = (CMLPoint3) builder.build(new StringReader(xmlP001S)) .getRootElement(); } void makeXomT1() { xomT1 = new CMLTransform3(new double[] { 0., 1., 0., 0., 0., 0., 1., 0., -1., 0., 0., 0., 0., 0., 0., 1. }); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLPoint3Test.java000077500000000000000000000566071477224461000274000ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.euclid.EuclidConstants.EPS; import static org.xmlcml.euclid.EuclidConstants.S_RBRAK; import java.io.IOException; import java.io.StringReader; import nu.xom.ParsingException; import nu.xom.ValidityException; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.element.CMLLine3; import org.xmlcml.cml.element.CMLPlane3; import org.xmlcml.cml.element.CMLPoint3; import org.xmlcml.cml.element.CMLTransform3; import org.xmlcml.cml.element.CMLVector3; import org.xmlcml.euclid.Angle; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.test.DoubleTestBase; /** * test CMLPoint3 * * @author pmr * */ public class CMLPoint3Test extends GeomTestBase { CMLBuilder builder = new CMLBuilder(); CMLPoint3 xomP; CMLPlane3 xomPl; CMLLine3 xomL; CMLVector3 xomV; CMLPoint3 xomP111; CMLPoint3 xomP100; CMLPoint3 xomP010; CMLPoint3 xomP001; CMLPoint3 xomP123; CMLPlane3 xomPl0100; CMLPlane3 xomPl1002; CMLPlane3 xomPl1115; CMLPlane3 xomPl1005; CMLLine3 xomL555111; CMLVector3 xomV000; CMLVector3 xomV100; CMLVector3 xomV010; CMLVector3 xomV001; CMLVector3 xomV111; CMLVector3 xomV123; CMLVector3 xomV321; CMLLine3 xomL220011; CMLTransform3 xomT1; String xmlP111S; String xmlP100S; String xmlP010S; String xmlP001S; String xmlP123S; CMLPoint3 xmlP111; CMLPoint3 xmlP100; CMLPoint3 xmlP010; CMLPoint3 xmlP001; CMLPoint3 xmlP123; /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLPoint3 test, CMLPoint3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + S_RBRAK, expected); DoubleTestBase.assertEquals(msg, test.getXYZ3(), expected.getXYZ3(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 3 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, CMLPoint3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("expected should not be null (" + msg + S_RBRAK, expected); DoubleTestBase.assertEquals(msg, test, expected.getXYZ3(), epsilon); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3 parse' */ @Test public void testParse() { String xml1S = ""; String xml2S = "1 2"; String xml3S = "1 2 x"; String xml4S = "1 2 3 4"; String xml5S = "1 2 3"; try { builder.build(new StringReader(xml1S)).getRootElement(); Assert.fail("should throw content failure"); } catch (ValidityException e) { Assert .fail("should not throw validity exception " + e.getMessage()); } catch (ParsingException e) { Assert.assertEquals("parse exception ", "point must not be empty", e.getMessage()); } catch (IOException e) { Assert.fail("should not throw IO exception " + e.getMessage()); } catch (RuntimeException e) { Assert.fail("should not throw CMLRuntime exception " + e.getMessage()); } try { builder.build(new StringReader(xml2S)).getRootElement(); Assert.fail("should throw content failure"); } catch (ValidityException e) { Assert .fail("should not throw validity exception " + e.getMessage()); } catch (ParsingException e) { Assert.assertEquals("parse exception ", "point must have 3 double components", e.getMessage()); } catch (IOException e) { Assert.fail("should not throw IO exception " + e.getMessage()); } catch (RuntimeException e) { Assert.fail("should not throw CMLRuntime exception " + e.getMessage()); } try { builder.build(new StringReader(xml3S)).getRootElement(); Assert.fail("should throw content failure"); } catch (ValidityException e) { Assert .fail("should not throw validity exception " + e.getMessage()); } catch (ParsingException e) { Assert.assertTrue(true); } catch (IOException e) { Assert.fail("should not throw IO exception " + e.getMessage()); } catch (RuntimeException e) { Assert.fail("should not throw CMLRuntime exception " + e.getMessage()); } try { builder.build(new StringReader(xml4S)).getRootElement(); Assert.fail("should throw content failure"); } catch (ValidityException e) { Assert .fail("should not throw validity exception " + e.getMessage()); } catch (ParsingException e) { Assert.assertEquals("parse exception ", "point must have 3 double components", e.getMessage()); } catch (IOException e) { Assert.fail("should not throw IO exception " + e.getMessage()); } catch (RuntimeException e) { Assert.fail("should not throw CMLRuntime exception " + e.getMessage()); } try { builder.build(new StringReader(xml5S)).getRootElement(); } catch (ValidityException e) { Assert .fail("should not throw validity exception " + e.getMessage()); } catch (ParsingException e) { Assert.assertEquals("parse exception ", "java.lang.NumberFormatException: empty String", e .getMessage()); } catch (IOException e) { Assert.fail("should not throw IO exception " + e.getMessage()); } catch (RuntimeException e) { Assert.fail("should not throw CMLRuntime exception " + e.getMessage()); } } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.CMLPoint3(CMLPoint3)' */ @Test public void testCMLPoint3CMLPoint3() { CMLPoint3 p = new CMLPoint3(xomP111); CMLPoint3Test.assertEquals("copy", new double[] { 1., 1., 1. }, p, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.CMLPoint3(double[])' */ @Test public void testCMLPoint3DoubleArray() { CMLPoint3 p = new CMLPoint3(new double[] { 1., 2., 3. }); CMLPoint3Test.assertEquals("copy", new double[] { 1., 2., 3. }, p, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.setXYZ3(double[])' */ @Test public void testSetXYZ3() { xomP111.setXYZ3(new double[] { 3., 2., 1. }); CMLPoint3Test.assertEquals("setXYZ3", new double[] { 3., 2., 1. }, xomP111, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.getXYZ3()' */ @Test public void testGetXYZ3() { CMLPoint3Test.assertEquals("setXYZ3", new double[] { 1., 1., 1. }, xomP111, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.equals(CMLPoint3)' */ @Test public void testEqualsCMLPoint3() { CMLPoint3 pp = new CMLPoint3(xomP111); Assert.assertTrue("equals", pp.isEqualTo(xomP111)); } /** * Test method for * 'org.xmlcml.cml.element.CMLPoint3.equalsCrystallographically(CMLPoint3)' */ @Test public void testEqualsCrystallographically() { CMLPoint3 pp = new CMLPoint3(new double[] { 0., 1., 2. }); Assert.assertTrue("equals", pp.equalsCrystallographically(xomP111)); } /** * Test method for * 'org.xmlcml.cml.element.CMLPoint3.isInvariant(CMLTransform3, boolean)' */ @Test public void testIsInvariant() { CMLPoint3 p = new CMLPoint3(new double[] { 1., 0., 3. }); CMLTransform3 yMirror = new CMLTransform3(new double[] { 1., 0., 0., 0., 0., -1., 0., 0., 0., 0., 1., 0., 1., 0., 0., 1. }); Assert.assertTrue("y mirror", p.isInvariant(yMirror, false)); CMLTransform3 xMirror = new CMLTransform3(new double[] { -1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1., 0., 1., 0., 0., 1. }); Assert.assertFalse("x mirror", p.isInvariant(xMirror, false)); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.subtract(CMLPoint3)' */ @Test public void testSubtractCMLPoint3() { CMLVector3 v = xomP111.subtract(xomP100); CMLVector3Test.assertEquals("subtract", new double[] { 0., 1., 1. }, v, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.plus(CMLPoint3)' */ @Test public void testPlusCMLPoint3() { CMLPoint3 v = xomP111.plus(xomP100); CMLPoint3Test.assertEquals("subtract", new double[] { 2., 1., 1. }, v, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.plusEquals(CMLPoint3)' */ @Test public void testPlusEqualsCMLPoint3() { xomP111.plusEquals(xomP100); CMLPoint3Test.assertEquals("subtract", new double[] { 2., 1., 1. }, xomP111, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.plus(CMLVector3)' */ @Test public void testPlusCMLVector3() { CMLPoint3 v = xomP111.plus(xomV111); CMLPoint3Test.assertEquals("plus", new double[] { 2., 2., 2. }, v, EPS); CMLVector3Test.assertEquals("plus", new double[] { 1., 1., 1. }, xomV111, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.plusEquals(CMLVector3)' */ @Test public void testPlusEqualsCMLVector3() { xomP111.plusEquals(xomV123); CMLPoint3Test.assertEquals("plusequals", new double[] { 2., 3., 4. }, xomP111, EPS); CMLVector3Test.assertEquals("plusequals", new double[] { 1., 2., 3. }, xomV123, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.subtract(CMLVector3)' */ @Test public void testSubtractCMLVector3() { CMLPoint3 v = xomP111.subtract(xomV123); CMLPoint3Test.assertEquals("subtract", new double[] { 0., -1., -2. }, v, EPS); CMLVector3Test.assertEquals("subtract", new double[] { 1., 2., 3. }, xomV123, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLPoint3.subtractEquals(CMLPoint3)' */ @Test public void testSubtractEqualsCMLPoint3() { xomP111.subtractEquals(this.xomP010); CMLPoint3Test.assertEquals("subtractequals", new double[] { 1., 0., 1. }, xomP111, EPS); CMLPoint3Test.assertEquals("subtractequals", new double[] { 0., 1., 0. }, xomP010, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLPoint3.subtractEquals(CMLVector3)' */ @Test public void testSubtractEqualsCMLVector3() { xomP111.subtractEquals(xomV123); CMLPoint3Test.assertEquals("subtractequals", new double[] { 0., -1., -2. }, xomP111, EPS); CMLVector3Test.assertEquals("subtractequals", new double[] { 1., 2., 3. }, xomV123, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.multiplyBy(double)' */ @Test public void testMultiplyBy() { CMLPoint3 p = xomP111.multiplyBy(2.0); CMLPoint3Test.assertEquals("multiplyBy", new double[] { 1., 1., 1. }, xomP111, EPS); CMLPoint3Test.assertEquals("multiplyBy", new double[] { 2., 2., 2. }, p, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.multiplyEquals(double)' */ @Test public void testMultiplyEquals() { xomP111.multiplyEquals(2.0); CMLPoint3Test.assertEquals("multiplyEquals", new double[] { 2., 2., 2. }, xomP111, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.divideBy(double)' */ @Test public void testDivideBy() { CMLPoint3 p = xomP111.divideBy(2.0); CMLPoint3Test.assertEquals("divideBy", new double[] { 1., 1., 1. }, xomP111, EPS); CMLPoint3Test.assertEquals("divideBy", new double[] { 0.5, 0.5, 0.5 }, p, EPS); p = xomP100.divideBy(0.0); CMLPoint3Test.assertEquals("divideBy", new double[] { 1., 1., 1. }, xomP111, EPS); Assert .assertTrue("divideBy", Double.isInfinite(p.getXYZ3()[0]) && Double.isNaN(p.getXYZ3()[1]) && Double.isNaN(p.getXYZ3()[2])); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.elementAt(int)' */ @Test public void testElementAt() { Assert.assertEquals("elementAt", 1., xomP123.elementAt(0), EPS); Assert.assertEquals("elementAt", 2., xomP123.elementAt(1), EPS); Assert.assertEquals("elementAt", 3., xomP123.elementAt(2), EPS); try { xomP123.elementAt(3); Assert.fail("should always throw " + "index out of range"); } catch (RuntimeException e) { Assert .assertEquals( "element at", "org.xmlcml.euclid.EuclidRuntimeException: index (3)out of range: 0/2", e.getMessage()); } } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.setElementAt(int, * double)' */ @Test public void testSetElementAt() { CMLPoint3Test.assertEquals("setElement", new double[] { 1., 2., 3. }, xomP123, EPS); xomP123.setElementAt(0, 11.); xomP123.setElementAt(1, 12.); xomP123.setElementAt(2, 13.); CMLPoint3Test.assertEquals("setElement", new double[] { 11., 12., 13. }, xomP123, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLPoint3.transform(CMLTransform3)' */ @Test public void testTransform() { makeXomT1(); CMLPoint3 p = xomP123.transform(xomT1); CMLPoint3Test.assertEquals("transform", new double[] { 2., 3., -1. }, p, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLPoint3.getDistanceFromOrigin()' */ @Test public void testGetDistanceFromOrigin() { Assert.assertEquals("origin", Math.sqrt(14.), xomP123 .getDistanceFromOrigin(), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLPoint3.getSquaredDistanceFromPoint(CMLPoint3)' */ @Test public void testGetSquaredDistanceFromPoint() { Assert.assertEquals("origin", 5., xomP123 .getSquaredDistanceFromPoint(xomP111), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLPoint3.getDistanceFromPoint(CMLPoint3)' */ @Test public void testGetDistanceFromPoint() { Assert.assertEquals("point2point", 3., xomP123 .getDistanceFromPoint(xomP001), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLPoint3.distanceFromPlane(CMLPlane3)' */ @Test public void testDistanceFromPlane() { Assert.assertEquals("point2plane", -1., xomP123 .distanceFromPlane(xomPl1002), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLPoint3.getClosestPointOnLine(CMLLine3)' */ @Test public void testGetClosestPointOnLine() { // FIXME // CMLPoint3 pp = xomP123.getClosestPointOnLine(this.xomL220011); // Assert.assertEquals("closestpoint", new double[] {8., 9., 1.}, // pp.getXMLContent(), EPS); // double d = pp.distanceFromLine(xomL220011); // Assert.assertEquals("closestpoint check", 1.2, d, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.isOnLine(CMLLine3)' */ @Test public void testIsOnLine() { double[] p = { 0., 0., 0. }; CMLPoint3 pp = new CMLPoint3(p); double[] v = { 2., 0., 0. }; CMLVector3 vv = new CMLVector3(v); CMLLine3 ll = new CMLLine3(pp, vv); double d = pp.distanceFromLine(ll); Assert.assertTrue("is on line", pp.isOnLine(ll)); d = d * 2; // to avoid not use warning } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.isOnPlane(CMLPlane3)' */ @Test public void testIsOnPlane() { double xx = Math.sqrt(1. / 3.); CMLPlane3 pl = new CMLPlane3(new double[] { 1., 1., 1., xx }); Assert.assertTrue("on plane", xomP100.isOnPlane(pl)); } /** * Test method for * 'org.xmlcml.cml.element.CMLPoint3.distanceFromLine(CMLLine3)' */ @Test public void testDistanceFromLine() { // FIXME double[] p = { 0., 0., 0. }; CMLPoint3 pp = new CMLPoint3(p); double[] l = { 2., 0., 0. }; CMLVector3 vv = new CMLVector3(l); CMLLine3 ll = new CMLLine3(pp, vv); double d; d = pp.distanceFromLine(ll); // FIXME must change distanceFrom // Assert.assertEquals("distance from line", 0., d, EPS); p = new double[] { 1., 2., 3. }; pp = new CMLPoint3(p); l = new double[] { 10., 0., 0. }; vv = new CMLVector3(l); ll = new CMLLine3(pp, vv); d = pp.distanceFromLine(ll); d += 0.0; // FIXME // Assert.assertEquals("distance from line", 0., d, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.getMidPoint(CMLPoint3)' */ @Test public void testGetMidPoint() { CMLPoint3 p = this.xomP001.getMidPoint(this.xomP010); CMLPoint3Test.assertEquals("midpoint", new double[] { 0., 0.5, 0.5 }, p, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.getAngle(CMLPoint3, * CMLPoint3)' */ @Test public void testGetAngle() { Angle angle = xomP100.getAngle(xomP010, xomP001); Assert.assertNotNull("angle", angle); Assert.assertEquals("angle", Math.PI / 3., angle.getRadian(), EPS); angle = xomP100.getAngle(xomP010, xomP010); Assert.assertNull("angle coincident atoms", angle); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.getTorsion(CMLPoint3, * CMLPoint3, CMLPoint3)' */ @Test public void testGetTorsion() { double a = Double.NaN; CMLPoint3 p000 = new CMLPoint3(new double[] { 0., 0., 0. }); a = xomP100.getTorsion(p000, xomP010, xomP001); Assert.assertEquals("angle", -Math.PI / 2., a, EPS); try { a = xomP100.getTorsion(p000, xomP010, xomP010); } catch (Throwable e) { Assert.assertEquals("getAngle", "cannot normalize zero-length vector", e.getMessage()); } } /** * Test method for * 'org.xmlcml.cml.element.CMLPoint3.calculateFromInternalCoordinates(CMLPoi * n t 3 , CMLPoint3, double, double, double)' */ @Test public void testCalculateFromInternalCoordinates() { CMLPoint3 p1 = new CMLPoint3(new double[] { -1, 1, 0 }); CMLPoint3 p2 = new CMLPoint3(new double[] { -1, 0, 0 }); CMLPoint3 p3 = new CMLPoint3(new double[] { 0, 0, 0 }); CMLPoint3 p4 = p1.calculateFromInternalCoordinates(p2, p3, 1.0, Math.PI * 2 / 3., 1.); CMLPoint3Test.assertEquals("internals", new double[] { 0.5, Math.sin(Math.PI * 2. / 3.) * Math.cos(1.), Math.sin(Math.PI * 2. / 3.) * Math.sin(1.) }, p4, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.isOrigin()' */ @Test public void testIsOrigin() { CMLPoint3 p000 = new CMLPoint3(new double[] { 0., 0., 0. }); Assert.assertTrue("origin", p000.isOrigin()); Assert.assertFalse("origin", xomP100.isOrigin()); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.copy()' */ @Test public void testCopy() { CMLPoint3 p = new CMLPoint3(1., 2., 3.); CMLPoint3 pp = (CMLPoint3) p.copy(); CMLPoint3Test.assertEquals("copy", p, pp, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.CMLPoint3(Point3)' */ @Test public void testCMLPoint3Point3() { CMLPoint3 p = new CMLPoint3(new Point3(1., 2., 3.)); CMLPoint3Test.assertEquals("copy", new double[] { 1., 2., 3. }, p, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.CMLPoint3(double, * double, double)' */ @Test public void testCMLPoint3DoubleDoubleDouble() { CMLPoint3 p = new CMLPoint3(1., 2., 3.); CMLPoint3Test.assertEquals("copy", new double[] { 1., 2., 3. }, p, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.getEuclidPoint3()' */ @Test public void testGetEuclidPoint3() { CMLPoint3 p = new CMLPoint3(new Point3(1., 2., 3.)); Point3 pp = p.getEuclidPoint3(); CMLPoint3Test.assertEquals("copy", pp.getArray(), p, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.isEqualTo(CMLPoint3)' */ @Test public void testIsEqualToCMLPoint3() { CMLPoint3 p = new CMLPoint3(1., 2., 3.); CMLPoint3 pp = (CMLPoint3) p.copy(); Assert.assertTrue("isEqual", p.isEqualTo(pp)); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.isEqualTo(CMLPoint3, * double)' */ @Test public void testIsEqualToCMLPoint3Double() { CMLPoint3 p = new CMLPoint3(1., 2., 3.); CMLPoint3 pp = (CMLPoint3) p.copy(); Assert.assertTrue("isEqual", p.isEqualTo(pp, EPS)); } /** * Test method for 'org.xmlcml.cml.element.CMLPoint3.getString()' */ @Test public void testGetString() { CMLPoint3 p = new CMLPoint3(1., 2., 3.); Assert.assertEquals("string", "(1.0, 2.0, 3.0)", p.getString()); } /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { // create from XOM // xomP = new CMLPoint3(); // deliberately disallowed // xomPl = new CMLPlane3(); // deliberately disallowed // xomL = new CMLLine3(); // deliberately disallowed // xomV = new CMLVector3(); // deliberately disallowed xomP111 = new CMLPoint3(new double[] { 1., 1., 1. }); xomP100 = new CMLPoint3(new double[] { 1., 0., 0. }); xomP010 = new CMLPoint3(new double[] { 0., 1., 0. }); xomP001 = new CMLPoint3(new double[] { 0., 0., 1. }); xomP123 = new CMLPoint3(new double[] { 1., 2., 3. }); xomPl0100 = new CMLPlane3(new double[] { 0., 1., 0., 0. }); xomPl1002 = new CMLPlane3(new double[] { 1., 0., 0., 2. }); xomPl1005 = new CMLPlane3(new double[] { 1., 0., 0., 5. }); xomPl1115 = new CMLPlane3(new double[] { 1., 1., 1., 5. }); // xomL555111 = new CMLLine3(new double[]{5., 5., 5., 1., 1., 1.}); xomL220011 = new CMLLine3(new CMLPoint3(0., 1., 1.), new CMLVector3(2., 2., 0.)); xomV000 = new CMLVector3(new double[] { 0., 0., 0. }); xomV100 = new CMLVector3(new double[] { 1., 0., 0. }); xomV010 = new CMLVector3(new double[] { 0., 1., 0. }); xomV001 = new CMLVector3(new double[] { 0., 0., 1. }); xomV111 = new CMLVector3(new double[] { 1., 1., 1. }); xomV123 = new CMLVector3(new double[] { 1., 2., 3. }); xomV321 = new CMLVector3(new double[] { 3., 2., 1. }); // create from XML xmlP111S = "1. 1. 1."; xmlP100S = "1 0 0"; xmlP010S = "0 1.0E+00 0"; xmlP001S = "0 0 1"; xmlP123S = "1 2 3"; CMLBuilder builder = new CMLBuilder(); xmlP111 = (CMLPoint3) builder.build(new StringReader(xmlP111S)) .getRootElement(); xmlP123 = (CMLPoint3) builder.build(new StringReader(xmlP123S)) .getRootElement(); xmlP100 = (CMLPoint3) builder.build(new StringReader(xmlP100S)) .getRootElement(); xmlP010 = (CMLPoint3) builder.build(new StringReader(xmlP010S)) .getRootElement(); xmlP001 = (CMLPoint3) builder.build(new StringReader(xmlP001S)) .getRootElement(); } void makeXomT1() { xomT1 = new CMLTransform3(new double[] { 0., 1., 0., 0., 0., 0., 1., 0., -1., 0., 0., 0., 0., 0., 0., 1. }); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLReactionComponentTest.java000077500000000000000000000364561477224461000316530ustar00rootroot00000000000000/** * 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.main; import java.util.List; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLBond; import org.xmlcml.cml.element.CMLFormula; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.CMLProduct; import org.xmlcml.cml.element.CMLReactant; /** * test ReactionComponent. * * @author pmr * */ public class CMLReactionComponentTest extends ReactionAllTestBase { /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { super.setUp(); } /** * Test method for 'org.xmlcml.cml.element.ReactionComponent.getMolecules()' */ @Test public void testGetMolecules() { List moleculeList = xmlReact1.getMolecules(); Assert.assertEquals("get molecules size", 7, moleculeList.size()); Assert.assertEquals("get molecules 1 ", "rm1", moleculeList.get(0) .getId()); Assert.assertEquals("get molecules 2 ", "rm2", moleculeList.get(1) .getId()); Assert.assertEquals("get molecules 3 ", "pm1", moleculeList.get(2) .getId()); Assert.assertEquals("get molecules 4 ", "pm2", moleculeList.get(3) .getId()); Assert.assertEquals("get molecules 5 ", "sm1", moleculeList.get(4) .getId()); Assert.assertEquals("get molecules 6 ", "sm2", moleculeList.get(5) .getId()); moleculeList = xmlReactantList1.getMolecules(); Assert.assertEquals("get molecules size", 2, moleculeList.size()); Assert.assertEquals("get reactants 1 ", "rm1", moleculeList.get(0) .getId()); Assert.assertEquals("get reactants 1 ", "rm2", moleculeList.get(1) .getId()); moleculeList = xmlProductList1.getMolecules(); Assert.assertEquals("get molecules size", 2, moleculeList.size()); Assert.assertEquals("get products 1 ", "pm1", moleculeList.get(0) .getId()); Assert.assertEquals("get products 1 ", "pm2", moleculeList.get(1) .getId()); moleculeList = xmlSpectatorList1.getMolecules(); Assert.assertEquals("get molecules size", 2, moleculeList.size()); Assert.assertEquals("get spectators 1 ", "sm1", moleculeList.get(0) .getId()); Assert.assertEquals("get spectators 1 ", "sm2", moleculeList.get(1) .getId()); moleculeList = xmlReactants1.get(0).getMolecules(); Assert.assertEquals("get molecules size", 1, moleculeList.size()); Assert.assertEquals("get reactant 1 ", "rm1", moleculeList.get(0) .getId()); moleculeList = xmlProducts1.get(0).getMolecules(); Assert.assertEquals("get molecules size", 1, moleculeList.size()); Assert.assertEquals("get product 1 ", "pm1", moleculeList.get(0) .getId()); moleculeList = xmlSpectators1.get(0).getMolecules(); Assert.assertEquals("get molecules size", 1, moleculeList.size()); Assert.assertEquals("get spectator 1 ", "sm1", moleculeList.get(0) .getId()); } /** * Test method for 'org.xmlcml.cml.element.ReactionComponent.getAtoms()' */ @Test public void testGetAtoms() { List atomList = xmlReact1.getAtoms(); Assert.assertEquals("get atoms size", 9, atomList.size()); Assert.assertEquals("get atoms 1 ", "a1", atomList.get(0).getId()); Assert.assertEquals("get atoms 2 ", "a2", atomList.get(1).getId()); Assert.assertEquals("get atoms 3 ", "a3", atomList.get(2).getId()); Assert.assertEquals("get atoms 4 ", "a1", atomList.get(3).getId()); Assert.assertEquals("get atoms 5 ", "a2", atomList.get(4).getId()); Assert.assertEquals("get atoms 6 ", "a3", atomList.get(5).getId()); Assert.assertEquals("get atoms 7 ", "a1", atomList.get(6).getId()); Assert.assertEquals("get atoms 8 ", "a2", atomList.get(7).getId()); Assert.assertEquals("get atoms 9 ", "a3", atomList.get(8).getId()); atomList = xmlReactantList1.getAtoms(); Assert.assertEquals("get atoms size", 3, atomList.size()); Assert.assertEquals("get reactants 1 ", "a1", atomList.get(0).getId()); Assert.assertEquals("get reactants 2 ", "a2", atomList.get(1).getId()); Assert.assertEquals("get reactants 3 ", "a3", atomList.get(2).getId()); atomList = xmlProductList1.getAtoms(); Assert.assertEquals("get atoms size", 3, atomList.size()); Assert.assertEquals("get products 1 ", "a1", atomList.get(0).getId()); Assert.assertEquals("get products 2 ", "a2", atomList.get(1).getId()); Assert.assertEquals("get products 3 ", "a3", atomList.get(2).getId()); atomList = xmlSpectatorList1.getAtoms(); Assert.assertEquals("get atoms size", 3, atomList.size()); Assert.assertEquals("get spectators 1 ", "a1", atomList.get(0).getId()); Assert.assertEquals("get spectators 2 ", "a2", atomList.get(1).getId()); Assert.assertEquals("get spectators 3 ", "a3", atomList.get(2).getId()); atomList = xmlReactants1.get(0).getAtoms(); Assert.assertEquals("get atoms size", 2, atomList.size()); Assert.assertEquals("get reactant 1 ", "a1", atomList.get(0).getId()); Assert.assertEquals("get reactant 2 ", "a2", atomList.get(1).getId()); atomList = xmlProducts1.get(0).getAtoms(); Assert.assertEquals("get atoms size", 2, atomList.size()); Assert.assertEquals("get product 1 ", "a1", atomList.get(0).getId()); Assert.assertEquals("get product 2 ", "a2", atomList.get(1).getId()); atomList = xmlSpectators1.get(0).getAtoms(); Assert.assertEquals("get atoms size", 2, atomList.size()); Assert.assertEquals("get spectator 1 ", "a1", atomList.get(0).getId()); Assert.assertEquals("get spectator 2 ", "a2", atomList.get(1).getId()); } /** * Test method for 'org.xmlcml.cml.element.ReactionComponent.getBonds()' */ @Test public void testGetBonds() { List bondList = xmlReact1.getBonds(); Assert.assertEquals("get bonds size", 2, bondList.size()); Assert.assertEquals("get bonds 1 ", "r_a1_a2", bondList.get(0).getId()); Assert.assertEquals("get bonds 2 ", "p_a1_a2", bondList.get(1).getId()); bondList = xmlReactantList1.getBonds(); Assert.assertEquals("get bonds size", 1, bondList.size()); Assert.assertEquals("get reactants 1 ", "r_a1_a2", bondList.get(0) .getId()); bondList = xmlProductList1.getBonds(); Assert.assertEquals("get bonds size", 1, bondList.size()); Assert.assertEquals("get products 1 ", "p_a1_a2", bondList.get(0) .getId()); bondList = xmlSpectatorList1.getBonds(); Assert.assertEquals("get bonds size", 0, bondList.size()); bondList = xmlReactants1.get(0).getBonds(); Assert.assertEquals("get bonds size", 1, bondList.size()); Assert.assertEquals("get reactant 1 ", "r_a1_a2", bondList.get(0) .getId()); bondList = xmlProducts1.get(0).getBonds(); Assert.assertEquals("get bonds size", 1, bondList.size()); Assert.assertEquals("get product 1 ", "p_a1_a2", bondList.get(0) .getId()); bondList = xmlSpectators1.get(0).getBonds(); Assert.assertEquals("get bonds size", 0, bondList.size()); } /** * Test method for 'org.xmlcml.cml.element.ReactionComponent.getFormulas()' */ @Test public void testGetFormulas() { makeXmlReact2(); List formulaList = xmlReact2.getFormulas(); Assert.assertEquals("get formulas size", 4, formulaList.size()); Assert.assertEquals("get formulas 1 ", "r_f1", formulaList.get(0) .getId()); Assert.assertEquals("get formulas 2 ", "r_f2", formulaList.get(1) .getId()); Assert.assertEquals("get formulas 3 ", "p_f1", formulaList.get(2) .getId()); Assert.assertEquals("get formulas 4 ", "p_f2", formulaList.get(3) .getId()); Assert.assertEquals("concise formulas 1 ", "H 1 Cl 1", formulaList.get( 0).getConcise()); Assert.assertEquals("concise formulas 2 ", "H 1 Na 1 O 1", formulaList .get(1).getConcise()); Assert.assertEquals("concise formulas 3 ", "H 2 O 1", formulaList .get(2).getConcise()); Assert.assertEquals("concise formulas 4 ", "Cl 1 Na 1", formulaList .get(3).getConcise()); List reactantList = xmlReact2.getDescendantReactants(); Assert.assertEquals("reactant count ", 2, reactantList.size()); List reactantFormulaList1 = reactantList.get(0) .getFormulas(); Assert.assertEquals("reactant 1 formula count ", 1, reactantFormulaList1.size()); Assert.assertEquals("concise formulas 1 ", "H 1 Cl 1", reactantFormulaList1.get(0).getConcise()); List reactantFormulaList2 = reactantList.get(1) .getFormulas(); Assert.assertEquals("reactant 2 formula count ", 1, reactantFormulaList2.size()); Assert.assertEquals("concise formulas 2 ", "H 1 Na 1 O 1", reactantFormulaList2.get(0).getConcise()); List productList = xmlReact2.getDescendantProducts(); Assert.assertEquals("product count ", 2, productList.size()); List productFormulaList1 = productList.get(0).getFormulas(); Assert.assertEquals("product 1 formula count ", 1, productFormulaList1 .size()); Assert.assertEquals("concise formulas 1 ", "H 2 O 1", productFormulaList1.get(0).getConcise()); List productFormulaList2 = productList.get(1).getFormulas(); Assert.assertEquals("product 2 formula count ", 1, productFormulaList2 .size()); Assert.assertEquals("concise formulas 1 ", "Cl 1 Na 1", productFormulaList2.get(0).getConcise()); } // /** // * Test method for // * 'org.xmlcml.cml.element.ReactionComponent.getReactionComponentDescendants()' // */ // @Test // public void testGetReactionComponentDescendants() { // List componentList = xmlReact1 // .getReactionComponentDescendants(); // Assert.assertEquals("descendants", 9, componentList.size()); // // reactantList // Assert.assertEquals("descendant 1", "rl1", ((CMLElement) componentList // .get(0)).getAttributeValue(IdAttribute.NAME)); // // reactants // Assert.assertEquals("descendant 2", "re1", ((CMLElement) componentList // .get(1)).getAttributeValue(IdAttribute.NAME)); // Assert.assertEquals("descendant 3", "re2", ((CMLElement) componentList // .get(2)).getAttributeValue(IdAttribute.NAME)); // // productList // Assert.assertEquals("descendant 4", "pl1", ((CMLElement) componentList // .get(3)).getAttributeValue(IdAttribute.NAME)); // // products // Assert.assertEquals("descendant 5", "pr1", ((CMLElement) componentList // .get(4)).getAttributeValue(IdAttribute.NAME)); // Assert.assertEquals("descendant 6", "pr2", ((CMLElement) componentList // .get(5)).getAttributeValue(IdAttribute.NAME)); // // spectatorList // Assert.assertEquals("descendant 7", "sl1", ((CMLElement) componentList // .get(6)).getAttributeValue(IdAttribute.NAME)); // // spectators // Assert.assertEquals("descendant 8", "sp1", ((CMLElement) componentList // .get(7)).getAttributeValue(IdAttribute.NAME)); // Assert.assertEquals("descendant 9", "sp2", ((CMLElement) componentList // .get(8)).getAttributeValue(IdAttribute.NAME)); // } // /** // * Test method for // * 'org.xmlcml.cml.element.ReactionComponent.getReactionComponentChildren()' // */ // @Test // public void testGetReactionComponentChildren() { // List componentList = xmlReact1 // .getReactionComponentChildren(); // Assert.assertEquals("children", 3, componentList.size()); // // reactantList // Assert.assertEquals("child 1", "rl1", ((CMLElement) componentList // .get(0)).getAttributeValue(IdAttribute.NAME)); // // productList // Assert.assertEquals("child 2", "pl1", ((CMLElement) componentList // .get(1)).getAttributeValue(IdAttribute.NAME)); // // spectatorList // Assert.assertEquals("child 3", "sl1", ((CMLElement) componentList // .get(2)).getAttributeValue(IdAttribute.NAME)); // // componentList = xmlReact1.getReactantListElements().get(0) // .getReactionComponentChildren(); // Assert.assertEquals("reactants", 2, componentList.size()); // Assert.assertEquals("reactant 1", "re1", ((CMLElement) componentList // .get(0)).getAttributeValue(IdAttribute.NAME)); // Assert.assertEquals("reactant 2", "re2", ((CMLElement) componentList // .get(1)).getAttributeValue(IdAttribute.NAME)); // // componentList = xmlReact1.getProductListElements().get(0) // .getReactionComponentChildren(); // Assert.assertEquals("products", 2, componentList.size()); // Assert.assertEquals("product 1", "pr1", ((CMLElement) componentList // .get(0)).getAttributeValue(IdAttribute.NAME)); // Assert.assertEquals("product 2", "pr2", ((CMLElement) componentList // .get(1)).getAttributeValue(IdAttribute.NAME)); // // componentList = xmlReact1.getSpectatorListElements().get(0) // .getReactionComponentChildren(); // Assert.assertEquals("spectators", 2, componentList.size()); // Assert.assertEquals("spectator 1", "sp1", ((CMLElement) componentList // .get(0)).getAttributeValue(IdAttribute.NAME)); // Assert.assertEquals("spectator 2", "sp2", ((CMLElement) componentList // .get(1)).getAttributeValue(IdAttribute.NAME)); // // } /** * run tests. * * @return the suite. * */ } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLReactionTest.java000077500000000000000000000331601477224461000277550ustar00rootroot00000000000000/** * 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.main; import java.util.List; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLBond; import org.xmlcml.cml.element.CMLFormula; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.CMLProduct; import org.xmlcml.cml.element.CMLProductList; import org.xmlcml.cml.element.CMLReactant; import org.xmlcml.cml.element.CMLReactantList; import org.xmlcml.cml.element.CMLReaction; import org.xmlcml.cml.element.CMLSpectator; import org.xmlcml.cml.element.CMLSpectatorList; import org.xmlcml.cml.element.CMLSubstance; import org.xmlcml.cml.element.CMLSubstanceList; import org.xmlcml.cml.element.CMLReaction.Component; /** * test CMLReaction. * * @author pmr * */ public class CMLReactionTest extends ReactionAllTestBase { /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { super.setUp(); } /** * Test method for 'org.xmlcml.cml.element.CMLReaction.copy()' */ @Test public void testCopy() { CMLReaction reaction = (CMLReaction) xmlReact1.copy(); CMLReactantList rl = reaction.getReactantList(); Assert.assertNotNull("reactantList", rl); CMLElements reactants = rl.getReactantElements(); Assert.assertEquals("reactants", 2, reactants.size()); } /** * Test method for * 'org.xmlcml.cml.element.CMLReaction.CMLReaction(CMLReaction)' */ @Test public void testCMLReactionCMLReaction() { CMLReaction reaction = new CMLReaction(xmlReact1); CMLReactantList rl = reaction.getReactantList(); Assert.assertNotNull("reactantList", rl); CMLElements reactants = rl.getReactantElements(); Assert.assertEquals("reactants", 2, reactants.size()); } /** * Test method for 'org.xmlcml.cml.element.CMLReaction.getId(String)' */ @Test public void testGetIdString() { String id = xmlReact1.getId(Component.REACTANT.name); Assert.assertEquals("reaction id", "r1.reactant", id); } /** * Test method for 'org.xmlcml.cml.element.CMLReaction.mergeProductLists()' */ @Test public void testMergeProductLists() { makeMultiProductReactantLists(); Assert.assertEquals("reactant lists", 2, multiReact1 .getReactantListElements().size()); Assert.assertEquals("product lists", 2, multiReact1 .getProductListElements().size()); multiReact1.mergeProductLists(); Assert.assertEquals("reactant lists", 2, multiReact1 .getReactantListElements().size()); Assert.assertEquals("product lists", 1, multiReact1 .getProductListElements().size()); multiReact1.mergeReactantLists(); Assert.assertEquals("reactant lists", 1, multiReact1 .getReactantListElements().size()); Assert.assertEquals("product lists", 1, multiReact1 .getProductListElements().size()); } /** * Test method for 'org.xmlcml.cml.element.CMLReaction.getReactantList()' */ @Test public void testGetReactantList() { CMLReactantList rl = xmlReact1.getReactantList(); Assert.assertNotNull("reactantList", rl); CMLElements reactants = rl.getReactantElements(); Assert.assertEquals("reactants", 2, reactants.size()); } /** * Test method for 'org.xmlcml.cml.element.CMLReaction.getProductList()' */ @Test public void testGetProductList() { CMLProductList pl = xmlReact1.getProductList(); Assert.assertNotNull("productList", pl); CMLElements products = pl.getProductElements(); Assert.assertEquals("products", 2, products.size()); } @Test public void testGetSpectatorList() { CMLSpectatorList sl = xmlReact1.getSpectatorList(); Assert.assertNotNull("spectatorList", sl); CMLElements spectators = sl.getSpectatorElements(); Assert.assertEquals("spectators", 2, spectators.size()); } /** * Test method for 'org.xmlcml.cml.element.CMLReaction.getFilename()' */ @Test public void testGetFilename() { String filename = xmlReact1.getFilename(); Assert.assertEquals("filename", "r1", filename); } /** * Test method for * 'org.xmlcml.cml.element.CMLReaction.getSpectatorMolecules(int)' */ @Test public void testGetSpectatorMolecules() { List spects = xmlReact1.getSpectatorMolecules(0); Assert.assertEquals("getSpectatorMolecules ", 2, spects.size()); Assert.assertEquals("getSpectatorMolecules 0", "sm1", spects.get(0) .getId()); Assert.assertEquals("getSpectatorMolecules 1", "sm2", spects.get(1) .getId()); Assert.assertEquals("getSpectatorMolecules 0", 2, spects.get(0) .getAtoms().size()); Assert.assertEquals("getSpectatorMolecules 1", 1, spects.get(1) .getAtoms().size()); } /** * Test method for * 'org.xmlcml.cml.element.CMLReaction.removeOrphanSubstances()' */ @Test public void testRemoveOrphanSubstances() { CMLElements substanceLists = xmlReact1 .getSubstanceListElements(); CMLElements substances = substanceLists.get(0) .getSubstanceElements(); Assert.assertEquals("substances ", 2, substances.size()); xmlReact1.removeOrphanSubstances(); substances = substanceLists.get(0).getSubstanceElements(); Assert.assertEquals("substances ", 1, substances.size()); Assert.assertEquals("substance 1", "benzene", substances.get(0) .getMoleculeElements().get(0).getTitle()); } /** * get all descendant atoms. */ @Test public void testGetAtoms() { List atoms = xmlReact1.getAtoms(); Assert.assertEquals("atoms", 9, atoms.size()); Assert.assertEquals("atoms 1", "a1", atoms.get(0).getId()); Assert.assertEquals("atoms 2", "a2", atoms.get(1).getId()); Assert.assertEquals("atoms 3", "a3", atoms.get(2).getId()); Assert.assertEquals("atoms 4", "a1", atoms.get(3).getId()); Assert.assertEquals("atoms 5", "a2", atoms.get(4).getId()); Assert.assertEquals("atoms 6", "a3", atoms.get(5).getId()); Assert.assertEquals("atoms 7", "a1", atoms.get(6).getId()); Assert.assertEquals("atoms 8", "a2", atoms.get(7).getId()); Assert.assertEquals("atoms 9", "a3", atoms.get(8).getId()); } /** * get all descendant bonds. */ @Test public void testGetBonds() { List bonds = xmlReact1.getBonds(); Assert.assertEquals("bonds", 2, bonds.size()); Assert.assertEquals("bonds 1", "r_a1_a2", bonds.get(0).getId()); Assert.assertEquals("bonds 2", "p_a1_a2", bonds.get(1).getId()); } /** * get all descendant formulas. */ @Test public void testGetFormulas() { makeXmlReact2(); List formulas = xmlReact2.getFormulas(); Assert.assertEquals("formulas", 4, formulas.size()); Assert.assertEquals("formulas 1", "r_f1", formulas.get(0).getId()); Assert.assertEquals("formulas 2", "r_f2", formulas.get(1).getId()); Assert.assertEquals("formulas 3", "p_f1", formulas.get(2).getId()); Assert.assertEquals("formulas 4", "p_f2", formulas.get(3).getId()); } /** * get all descendant molecules. */ @Test public void testGetMolecules() { List molecules = xmlReact1.getMolecules(); Assert.assertEquals("molecules", 7, molecules.size()); Assert.assertEquals("molecules 1", "rm1", molecules.get(0).getId()); Assert.assertEquals("molecules 2", "rm2", molecules.get(1).getId()); Assert.assertEquals("molecules 3", "pm1", molecules.get(2).getId()); Assert.assertEquals("molecules 4", "pm2", molecules.get(3).getId()); Assert.assertEquals("molecules 5", "sm1", molecules.get(4).getId()); Assert.assertEquals("molecules 6", "sm2", molecules.get(5).getId()); } /** * gets list of descendant reactants. convenience class */ @Test public void testGetDescendantReactants() { List reactants = xmlReact1.getDescendantReactants(); Assert.assertEquals("reactants", 2, reactants.size()); Assert.assertEquals("reactants 1", "re1", reactants.get(0).getId()); Assert.assertEquals("reactants 2", "re2", reactants.get(1).getId()); } /** * gets list of descendant products. convenience class */ @Test public void testGetDescendantProducts() { List products = xmlReact1.getDescendantProducts(); Assert.assertEquals("products", 2, products.size()); Assert.assertEquals("products 1", "pr1", products.get(0).getId()); Assert.assertEquals("products 2", "pr2", products.get(1).getId()); } /** * gets list of descendant spectators. convenience class */ @Test public void testGetDescendantSpectators() { List spectators = xmlReact1.getDescendantSpectators(); Assert.assertEquals("spectators", 2, spectators.size()); Assert.assertEquals("spectators 1", "sp1", spectators.get(0).getId()); Assert.assertEquals("spectators 2", "sp2", spectators.get(1).getId()); } /** * Test method for 'org.xmlcml.cml.element.CMLReaction.mergeReactantLists()' */ @Test public void testMergeReactantLists() { String reactionS = "" + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""; CMLReaction reaction = (CMLReaction)CMLXOMTestUtils.parseValidString(reactionS); Assert.assertEquals("before merge", 2, reaction .getReactantListElements().size()); reaction.mergeReactantLists(); Assert.assertEquals("after merge", 1, reaction .getReactantListElements().size()); CMLReactantList reactantList = reaction.getReactantListElements() .get(0); Assert.assertEquals("after merge", 4, reactantList .getReactantElements().size()); Assert.assertEquals("after merge", "re1", reactantList .getReactantElements().get(0).getId()); Assert.assertEquals("after merge", "re2", reactantList .getReactantElements().get(1).getId()); Assert.assertEquals("after merge", "re1a", reactantList .getReactantElements().get(2).getId()); Assert.assertEquals("after merge", "re2a", reactantList .getReactantElements().get(3).getId()); } @Test public void testAddReactant(){ CMLReaction reaction = new CMLReaction(); Assert.assertEquals(null, reaction.getReactantList()); CMLReactant reactant = new CMLReactant(); reaction.addReactant(reactant); Assert.assertEquals(reactant, reaction.getReactantList().getReactantElements().get(0)); } @Test public void testAddProduct(){ CMLReaction reaction = new CMLReaction(); Assert.assertEquals(null, reaction.getProductList()); CMLProduct product = new CMLProduct(); reaction.addProduct(product); Assert.assertEquals(product, reaction.getProductList().getProductElements().get(0)); } @Test public void testMergeSpectatorLists() { CMLReaction reaction = new CMLReaction(); CMLSpectatorList list1 = new CMLSpectatorList(); CMLSpectatorList list2 = new CMLSpectatorList(); list1.addSpectator(new CMLSpectator()); list2.addSpectator(new CMLSpectator()); list2.addSpectator(new CMLSpectator()); reaction.addSpectatorList(list1); reaction.addSpectatorList(list2); Assert.assertEquals(2, reaction.getSpectatorListElements().size()); Assert.assertEquals(1, list1.getChildCount()); Assert.assertEquals(2, list2.getChildCount()); reaction.mergeSpectatorLists(); Assert.assertEquals(1, reaction.getSpectatorListElements().size()); Assert.assertEquals(3, list1.getChildCount()); Assert.assertEquals(0, list2.getChildCount()); Assert.assertTrue(list1.getParent() == reaction); Assert.assertFalse(list2.getParent() == reaction); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLSpectatorTest.java000077500000000000000000000052461477224461000301610ustar00rootroot00000000000000/** * 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.main; import java.util.Iterator; import java.util.List; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.element.CMLAmount; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLBond; import org.xmlcml.cml.element.CMLSpectator; /** * tests spectator. * * @author pm286 * */ public class CMLSpectatorTest extends ReactionAllTestBase { CMLSpectator spectator = null; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { super.setUp(); spectator = xmlSpectatorList1.getSpectatorElements().get(0); } /** * Test method for 'org.xmlcml.cml.element.CMLSpectator.getAtoms()' */ @Test public void testGetAtoms() { List atoms = spectator.getAtoms(); Assert.assertEquals("atoms", 2, atoms.size()); } /** * Test method for 'org.xmlcml.cml.element.CMLSpectator.getBonds()' */ @Test public void testGetBonds() { List bonds = spectator.getBonds(); Assert.assertEquals("bonds", 0, bonds.size()); } @Test public void testAddAndGetAmounts() { CMLSpectator spectator = new CMLSpectator(); Assert.assertEquals(0, spectator.getAmountElements().size()); CMLAmount amount1 = new CMLAmount(); spectator.addAmount(amount1); Assert.assertEquals(1, spectator.getAmountElements().size()); Iterator iterator1 = spectator.getAmountElements().iterator(); Assert.assertTrue(iterator1.next() == amount1); CMLAmount amount2 = new CMLAmount(); spectator.addAmount(amount2); Assert.assertEquals(2, spectator.getAmountElements().size()); Iterator iterator2 = spectator.getAmountElements().iterator(); Assert.assertTrue(iterator2.next() == amount1); Assert.assertTrue(iterator2.next() == amount2); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLSpectrumTest.java000077500000000000000000000475611477224461000300250ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.element.main.AbstractTestBase.COMPLEX_RESOURCE; import static org.xmlcml.cml.element.main.AbstractTestBase.SIMPLE_RESOURCE; import static org.xmlcml.euclid.EuclidConstants.EPS; import java.io.IOException; import java.io.InputStream; import java.io.StringReader; import java.util.List; import nu.xom.Document; import nu.xom.Elements; import nu.xom.Nodes; import nu.xom.ParsingException; import nu.xom.ValidityException; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.element.CMLArray; import org.xmlcml.cml.element.CMLCml; import org.xmlcml.cml.element.CMLFormula; import org.xmlcml.cml.element.CMLMetadata; import org.xmlcml.cml.element.CMLMetadataList; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.CMLParameterList; import org.xmlcml.cml.element.CMLPeak; import org.xmlcml.cml.element.CMLPeakGroup; import org.xmlcml.cml.element.CMLPeakList; import org.xmlcml.cml.element.CMLSample; import org.xmlcml.cml.element.CMLSpectrum; import org.xmlcml.cml.element.CMLSpectrumData; import org.xmlcml.cml.element.CMLSpectrumList; import org.xmlcml.cml.element.CMLXaxis; import org.xmlcml.cml.element.CMLYaxis; import org.xmlcml.cml.element.lite.PeakSpectrumBase; import org.xmlcml.euclid.Util; /** * test Spectrum. * * @author pmr * */ public class CMLSpectrumTest extends PeakSpectrumBase { /** * Test method for reading a CMLSpectrum from file. uses first example * * @throws Exception */ @Test public void testReadCMLSpectrum1() throws Exception { CMLSpectrum spectrum = readSpectrum(1); Assert.assertNotNull("spectrum1: ", spectrum); /* * -- 78-92-2 - */ CMLElements samples = spectrum.getSampleElements(); Assert.assertEquals("sample children", 1, samples.size()); CMLElements molecules = samples.get(0) .getMoleculeElements(); Assert.assertEquals("molecule children", 1, molecules.size()); CMLElements formulas = molecules.get(0) .getFormulaElements(); Assert.assertEquals("formula children", 1, formulas.size()); Assert.assertEquals("concise formula", "C 4 H 10 O 1", formulas.get(0) .getConcise()); /* * -- 450 454 458 462 466 470 474 478 482 486 490 * 494 498 502 506 510 ... 1282 1286 1290 1294 1298 1302 1306 1310 1314 * 1318 1322 1326 1330 1334 1338 1342 331 179 99 148 146 150 187 165 249 206 189 224 * 253 230 267 236 167 137 96 109 ... 1758 1867 1968 2018 2005 1960 1969 * 2010 2063 2100 2175 2254 2344 2467 2557 3 1 15 1 1 17 10 9 1 7 35 2 * 19 -- */ CMLElements spectrumDatas = spectrum .getSpectrumDataElements(); Assert.assertEquals("spectrumData children", 1, spectrumDatas.size()); CMLElements xaxiss = spectrumDatas.get(0).getXaxisElements(); Assert.assertEquals("xaxiss children", 1, xaxiss.size()); CMLElements xarray = xaxiss.get(0).getArrayElements(); Assert.assertEquals("xarray children", 1, xarray.size()); double[] xarrayValues = null; xarrayValues = xarray.get(0).getDoubles(); Assert.assertNotNull("xvalues...", xarrayValues); Assert.assertNotNull("xvalues", xarrayValues); Assert.assertEquals("xvalues", 224, xarrayValues.length); Assert.assertEquals("xvalue 0", 450, xarrayValues[0], EPS); Assert.assertEquals("xvalue 223", 1342, xarrayValues[223], EPS); CMLElements yaxiss = spectrumDatas.get(0).getYaxisElements(); Assert.assertEquals("yaxiss children", 1, yaxiss.size()); CMLElements yarray = yaxiss.get(0).getArrayElements(); Assert.assertEquals("yarray children", 1, yarray.size()); Assert.assertEquals("yunits", "cmlsp:absorbance", yarray.get(0) .getUnits()); double[] yarrayValues = yarray.get(0).getDoubles(); Assert.assertNotNull("yvalues...", xarrayValues); Assert.assertNotNull("yvalues", yarrayValues); Assert.assertEquals("yvalues", 224, yarrayValues.length); Assert.assertEquals("yvalue 0", 331, yarrayValues[0], EPS); Assert.assertEquals("yvalue 223", 0, yarrayValues[223], EPS); /* * -- * -- */ CMLElements peakLists = spectrum.getPeakListElements(); Assert.assertEquals("peakList children", 1, peakLists.size()); CMLElements peakGroups = peakLists.get(0) .getPeakGroupElements(); Assert.assertEquals("peakGroup children", 1, peakGroups.size()); CMLElements peaks = peakGroups.get(0).getPeakElements(); Assert.assertEquals("peakGroup children", 3, peaks.size()); CMLPeak peak0 = peaks.get(0); Assert.assertEquals("peak0 title", "CH-stretch-1", peak0.getTitle()); Assert.assertEquals("peak0 multiplicity", "singlet", peak0 .getPeakMultiplicity()); Assert.assertEquals("peak0 shape", "sharp", peak0.getPeakShape()); Assert.assertEquals("peak0 xunits", "cmlsp:cm-1", peak0.getXUnits()); Assert.assertEquals("peak0 xvalue", 2974.0, peak0.getXValue(), EPS); Assert.assertEquals("peak0 xunits", "cmlsp:absorbance", peak0 .getYUnits()); Assert.assertEquals("peak0 xvalue", 1.0921, peak0.getYValue(), EPS); CMLPeak peak1 = peaks.get(1); Assert.assertEquals("peak1 title", "CH-stretch-2", peak1.getTitle()); Assert.assertNull("peak1 multiplicity", peak1.getPeakMultiplicity()); Assert.assertEquals("peak1 shape", "shoulder", peak1.getPeakShape()); Assert.assertEquals("peak1 xunits", "cmlsp:cm-1", peak1.getXUnits()); Assert.assertEquals("peak1 xvalue", 2938.0, peak1.getXValue(), EPS); Assert.assertEquals("peak1 xunits", "cmlsp:absorbance", peak1 .getYUnits()); Assert.assertEquals("peak1 xvalue", 0.653, peak1.getYValue(), EPS); CMLPeak peak2 = peaks.get(2); Assert.assertEquals("peak2 title", "CH-stretch-3", peak2.getTitle()); Assert.assertNull("peak2 multiplicity", peak2.getPeakMultiplicity()); Assert.assertNull("peak2 shape", peak2.getPeakShape()); Assert.assertEquals("peak2 xunits", "cmlsp:cm-1", peak2.getXUnits()); Assert.assertEquals("peak2 xvalue", 2890.0, peak2.getXValue(), EPS); Assert.assertEquals("peak2 xunits", "cmlsp:absorbance", peak2 .getYUnits()); Assert.assertEquals("peak2 xvalue", 0.470, peak2.getYValue(), EPS); CMLElements peakohs = peakLists.get(0).getPeakElements(); Assert.assertEquals("peakList peak children", 1, peakohs.size()); CMLPeak peakoh = peakohs.get(0); Assert.assertEquals("peakoh title", "CH-stretch???", peakoh.getTitle()); Assert.assertNull("peakoh multiplicity", peakoh.getPeakMultiplicity()); Assert.assertEquals("peakoh shape", "broad", peakoh.getPeakShape()); Assert.assertEquals("peakoh xunits", "cmlsp:cm-1", peakoh.getXUnits()); Assert.assertEquals("peakoh xvalue", 3657.0, peakoh.getXValue(), EPS); Assert.assertEquals("peakoh xunits", "cmlsp:absorbance", peakoh .getYUnits()); Assert.assertEquals("peakoh xvalue", 0.1092, peakoh.getYValue(), EPS); } /** * Test method for reading a CMLSpectrum from file. * * @throws Exception */ @Test public void testReadCMLSpectrum3() throws Exception { CMLSpectrum spectrum = readSpectrum(3); Assert.assertNotNull("spectrum3: ", spectrum); /* * -- D.HENNEBERG, MAX-PLANCK INSTITUTE, MULHEIM, WEST * GERMANY NIST Mass Spectrometry * Data Center 109-99-9 * 24 25 26 27 29 30 31 33 * 34 35 37 38 39 40 41 42 43 44 45 46 49 50 51 53 54 55 68 69 70 71 72 * 73 4 30 171 1545 * 792 21 258 5 26 10 105 165 1182 906 4060 9999 1586 325 100 3 7 11 19 * 27 10 6 7 20 107 2557 2868 147 * -- */ List metadatas = CMLMetadataList .getMetadataDescendants(spectrum); Assert.assertEquals("metadataLists", 2, metadatas.size()); CMLMetadata metadata1 = metadatas.get(0); Assert.assertEquals("origin", "D.HENNEBERG, MAX-PLANCK INSTITUTE, MULHEIM, WEST GERMANY", metadata1.getXMLContent()); CMLMetadata metadata2 = metadatas.get(1); Assert.assertEquals("owner", "NIST Mass Spectrometry Data Center", metadata2.getXMLContent()); CMLElements spectrumDatas = spectrum .getSpectrumDataElements(); Assert.assertEquals("spectrumData children", 1, spectrumDatas.size()); CMLElements xaxiss = spectrumDatas.get(0).getXaxisElements(); Assert.assertEquals("xaxiss children", 1, xaxiss.size()); CMLElements xarray = xaxiss.get(0).getArrayElements(); Assert.assertEquals("xarray children", 1, xarray.size()); Assert.assertEquals("xunits", "unit:mz", xarray.get(0).getUnits()); double[] xarrayValues = xarray.get(0).getDoubles(); Assert.assertNotNull("xvalues...", xarrayValues); Assert.assertNotNull("xvalues", xarrayValues); Assert.assertEquals("xvalues", 32, xarrayValues.length); Assert.assertEquals("xvalue 0", 24, xarrayValues[0], EPS); Assert.assertEquals("xvalue last", 73, xarrayValues[31], EPS); CMLElements yaxiss = spectrumDatas.get(0).getYaxisElements(); Assert.assertEquals("yaxiss children", 1, yaxiss.size()); CMLElements yarray = yaxiss.get(0).getArrayElements(); Assert.assertEquals("yarray children", 1, yarray.size()); Assert.assertEquals("yunits", "cmls:relativeAbundance", yarray.get(0) .getUnits()); double[] yarrayValues = yarray.get(0).getDoubles(); Assert.assertNotNull("yvalues...", xarrayValues); Assert.assertNotNull("yvalues", yarrayValues); Assert.assertEquals("yvalues", 32, yarrayValues.length); Assert.assertEquals("yvalue 0", 4, yarrayValues[0], EPS); Assert.assertEquals("yvalue last", 147, yarrayValues[31], EPS); CMLElements peakLists = spectrum.getPeakListElements(); Assert.assertEquals("peakList children", 0, peakLists.size()); } /** * Test method for reading a CMLSpectrum from file. uses Tobias Helmus * example from NMRShiftDB * * @throws IOException * @throws ParsingException * @throws ValidityException */ @Test public void testReadCMLSpectrum5() throws IOException, ValidityException, ParsingException { CMLCml cml = null; InputStream in = Util.getInputStreamFromResource(SIMPLE_RESOURCE +CMLConstants.U_S + testfile5); cml = (CMLCml) new CMLBuilder().build(in).getRootElement(); in.close(); Assert.assertNotNull("read cml file ", cml); Elements spectrumLists = cml.getChildCMLElements(CMLSpectrumList.TAG); Assert.assertEquals("spectrumList children", 1, spectrumLists.size()); CMLSpectrumList spectrumList = (CMLSpectrumList) spectrumLists.get(0); CMLElements spectrums = spectrumList.getSpectrumElements(); Assert.assertEquals("spectrumList children", 1, spectrumLists.size()); CMLSpectrum spectrum = spectrums.get(0); /* * -- 9.983196146941719|9.980751037924213| ... * -0.027080170724973485|-0.02952527974247765| * -0.004036283417140468|-0.004343061239674385| ... * -0.003940121065448903|-0.004554220000639289| * -- */ CMLElements spectrumDatas = spectrum .getSpectrumDataElements(); Assert.assertEquals("spectrumData children", 1, spectrumDatas.size()); CMLElements xaxiss = spectrumDatas.get(0).getXaxisElements(); Assert.assertEquals("xaxiss children", 1, xaxiss.size()); CMLElements xarray = xaxiss.get(0).getArrayElements(); Assert.assertEquals("xarray children", 1, xarray.size()); double[] xarrayValues = xarray.get(0).getDoubles(); Assert.assertNotNull("xvalues", xarrayValues); Assert.assertEquals("xvalues", 4096, xarrayValues.length); Assert .assertEquals("xvalue 0", 9.983196146941719, xarrayValues[0], EPS); Assert.assertEquals("xvalue last", -0.02952527974247765, xarrayValues[4095], EPS); CMLElements yaxiss = spectrumDatas.get(0).getYaxisElements(); Assert.assertEquals("yaxiss children", 1, yaxiss.size()); CMLElements yarray = yaxiss.get(0).getArrayElements(); Assert.assertEquals("yarray children", 1, yarray.size()); Assert.assertEquals("yunits", "unit:percent", yarray.get(0).getUnits()); double[] yarrayValues = yarray.get(0).getDoubles(); Assert.assertNotNull("yvalues...", xarrayValues); Assert.assertNotNull("yvalues", yarrayValues); Assert.assertEquals("yvalues", 4096, yarrayValues.length); Assert.assertEquals("yvalue 0", -0.004036283417140468, yarrayValues[0], EPS); Assert.assertEquals("yvalue last", -0.004554220000639289, yarrayValues[4095], EPS); /* * -- * -- */ CMLElements peakLists = spectrum.getPeakListElements(); Assert.assertEquals("peakList children", 1, peakLists.size()); CMLElements peakGroups = peakLists.get(0) .getPeakGroupElements(); Assert.assertEquals("peakGroup children", 0, peakGroups.size()); CMLElements peaks = peakLists.get(0).getPeakElements(); Assert.assertEquals("peakGroup children", 4, peaks.size()); CMLPeak peak0 = peaks.get(0); Assert.assertNull("peak0 title", peak0.getTitle()); Assert.assertNull("peak0 multiplicity", peak0.getPeakMultiplicity()); Assert.assertNull("peak0 shape", peak0.getPeakShape()); Assert.assertEquals("peak0 xunits", "unit:ppm", peak0.getXUnits()); Assert.assertEquals("peak0 xvalue", 1.6111428710035778, peak0 .getXValue(), EPS); Assert.assertEquals("peak0 xunits", "unit:percent", peak0.getYUnits()); Assert.assertEquals("peak0 xvalue", 11.475286136623545, peak0 .getYValue(), EPS); CMLPeak peak1 = peaks.get(1); Assert.assertNull("peak1 title", peak1.getTitle()); Assert.assertNull("peak1 multiplicity", peak1.getPeakMultiplicity()); Assert.assertNull("peak1 shape", peak1.getPeakShape()); Assert.assertEquals("peak1 xunits", "unit:ppm", peak1.getXUnits()); Assert.assertEquals("peak1 xvalue", 3.8753138212134832, peak1 .getXValue(), EPS); Assert.assertEquals("peak1 xunits", "unit:percent", peak1.getYUnits()); Assert.assertEquals("peak1 xvalue", 79.04079021244083, peak1 .getYValue(), EPS); CMLPeak peak2 = peaks.get(2); Assert.assertNull("peak2 title", peak2.getTitle()); Assert.assertNull("peak2 multiplicity", peak2.getPeakMultiplicity()); Assert.assertNull("peak2 shape", peak2.getPeakShape()); Assert.assertEquals("peak2 xunits", "unit:ppm", peak2.getXUnits()); Assert.assertEquals("peak2 xvalue", 4.897369390530698, peak2 .getXValue(), EPS); Assert.assertEquals("peak2 xunits", "unit:percent", peak2.getYUnits()); Assert.assertEquals("peak2 xvalue", 41.595181148451374, peak2 .getYValue(), EPS); CMLPeak peak3 = peaks.get(3); Assert.assertNull("peak3 title", peak3.getTitle()); Assert.assertNull("peak3 multiplicity", peak3.getPeakMultiplicity()); Assert.assertNull("peak3 shape", peak3.getPeakShape()); Assert.assertEquals("peak3 xunits", "unit:ppm", peak3.getXUnits()); Assert.assertEquals("peak3 xvalue", 7.256899592423311, peak3 .getXValue(), EPS); Assert.assertEquals("peak3 xunits", "unit:percent", peak3.getYUnits()); Assert.assertEquals("peak3 xvalue", 3.12841519811053, peak3.getYValue(), EPS); } /** test. */ @Test public void testGetSiblingMolecule() { CMLCml cml = null; try { cml = (CMLCml) new CMLBuilder().build( new StringReader("" + " " + " " + " " + " " + "")).getRootElement(); } catch (Exception e) { Assert.fail("should not throw " + e); } Assert.assertNotNull("cml ", cml); CMLSpectrum spectrum = (CMLSpectrum) cml.getChildCMLElements( CMLSpectrum.TAG).get(0); Assert.assertNotNull("spectrum ", spectrum); Assert.assertEquals("spectrum id", "s1", spectrum.getId()); CMLMolecule molecule = spectrum.getSiblingMolecule(); Assert.assertNotNull("molecule ", molecule); Assert.assertEquals("molecule id", "m1", molecule.getId()); } /** * test compound document. * * @throws IOException * @throws ParsingException * @throws ValidityException */ @Test public void testFindSpectraInDocument() throws IOException, ValidityException, ParsingException { Document document = null; InputStream in = Util.getInputStreamFromResource(COMPLEX_RESOURCE +CMLConstants.U_S + testCompoundFile1); document = new CMLBuilder().build(in); in.close(); Nodes cmlNodes = document.query("//" + CMLCml.NS, CMLConstants.CML_XPATH); Assert.assertEquals("spectra count", cmlNodes.size(), 1); CMLCml cml = (CMLCml) cmlNodes.get(0); Nodes spectrumNodes = cml.cmlQuery("//" + CMLSpectrum.NS); Assert.assertEquals("spectra count", spectrumNodes.size(), 1); CMLSpectrum spectrum = (CMLSpectrum) spectrumNodes.get(0); Nodes spectrumDataNodes = spectrum.cmlQuery(CMLSpectrumData.NS); Assert.assertEquals("spectrumData count", spectrumDataNodes.size(), 1); // CMLSpectrumData spectrumData = (CMLSpectrumData) // spectrumDataNodes.get(0); Nodes parameterListNodes = spectrum.cmlQuery(CMLParameterList.NS); Assert .assertEquals("parameterList count", parameterListNodes.size(), 1); // CMLParameterList parameterList = (CMLParameterList) // parameterListNodes.get(0); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLSymmetryTest.java000077500000000000000000000543751477224461000300550ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.euclid.EuclidConstants.EPS; import java.util.ArrayList; import java.util.List; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.element.CMLCrystal; import org.xmlcml.cml.element.CMLMatrix; import org.xmlcml.cml.element.CMLSymmetry; import org.xmlcml.cml.element.CMLTransform3; import org.xmlcml.euclid.Point3; /** * tests CMLSymmetry. * * @author pmr * */ public class CMLSymmetryTest { // space group (Pbca) but not finite group static String[] pbca = { "x, y, z", "-x+1/2, -y, z+1/2", "x+1/2, -y+1/2, -z", "-x, y+1/2, -z+1/2", "-x, -y, -z", "x-1/2, y, -z-1/2", "-x-1/2, y-1/2, z", "x, -y-1/2, z-1/2", }; // finite group (mmm = d2h) static String[] pmmm = { "x, y, z", "-x, -y, z", "x, -y, -z", "-x, y, -z", "-x, -y, -z", "x, y, -z", "-x, y, z", "x, -y, z", }; // incomplete group (only 7 elements) static String[] oper3 = { "x, y, z", "-x, -y, z", "x, -y, -z", "-x, y, -z", "-x, -y, -z", "x, y, -z", "-x, y, z", }; // space group without glides and screws (P222 with prigin = 1/4, 1/4, 1/4) static String[] p212121 = { "x, y, z", "-x, 1/2+y, 1/2-z", "1/2-x, -y, 1/2+z", "1/2+x, 1/2-y, -z", }; static String[] p21c = { "x, y, z", "-x, y+1/2, -z+1/2", "x, -y+1/2, z+1/2", "-x, -y, -z", }; static String[] p2m = { "x, y, z", "-x, y, -z", "x, -y, z", "-x, -y, -z", }; static String[] abm2 = { "x, y, z", "-x, -y, z", "x, 1/2-y, z", "-x, 1/2+y, z", "x, 1/2+y, 1/2+z", "-x, 1/2-y, 1/2+z", "x, -y, 1/2+z", "-x, y, 1/2+z", }; static String[] p21212 = { "x, y, z", "-x, -y, z", "1/2+x, 1/2-y, -z", "1/2-x, 1/2+y, -z", }; static String[] p1 = { "x, y, z", }; static String[] p21 = { "x, y, z", "x, 1/2+y, z", }; static String[] ibar42d = { "x, y, z", "y, -x, -z", "-x, -y, z", "-y, x, -z", "x, -y+1/2, -z+1/4", "-y+1/2, -x, z+3/4", "-x, y+1/2, -z+1/4", "y+1/2, x, z+3/4", "x+1/2, y+1/2, z+1/2", "y+1/2, -x+1/2, -z+1/2", "-x+1/2, -y+1/2, z+1/2", "-y+1/2, x+1/2, -z+1/2", "x+1/2, -y, -z+3/4", "-y, -x+1/2, z+1/4", "-x+1/2, y, -z+3/4", "y, x+1/2, z+1/4" }; static String[] c2c = { "x, y, z", "-x, y, -z+1/2", "x+1/2, y+1/2, z", "-x+1/2, y+1/2, -z+1/2", "-x, -y, -z", "x, -y, z-1/2", "-x+1/2, -y+1/2, -z", "x+1/2, -y+1/2, z-1/2" }; static String[] rbar3 = { "x, y, z", "-y, x-y, z", "-x+y, -x, z", "x+2/3, y+1/3, z+1/3", "-y+2/3, x-y+1/3, z+1/3", "-x+y+2/3, -x+1/3, z+1/3", "x+1/3, y+2/3, z+2/3", "-y+1/3, x-y+2/3, z+2/3", "-x+y+1/3, -x+2/3, z+2/3", "-x, -y, -z", "y, -x+y, -z", "x-y, x, -z", "-x+2/3, -y+1/3, -z+1/3", "y+2/3, -x+y+1/3, -z+1/3", "x-y+2/3, x+1/3, -z+1/3", "-x+1/3, -y+2/3, -z+2/3", "y+1/3, -x+y+2/3, -z+2/3", "x-y+1/3, x+2/3, -z+2/3" }; static String[] abar22a = { "x, y, z", "x+1/2, -y, -z", "x+1/2, -y, z", "x, y, -z", "x, y+1/2, z+1/2", "x+1/2, -y+1/2, -z+1/2", "x+1/2, -y+1/2, z+1/2", "x, y+1/2, -z+1/2" }; static String[] fdd2 = { "x, y, z", "-x, -y, z", "-x+1/4, y+1/4, z+1/4", "x+1/4, -y+1/4, z+1/4", "x, y+1/2, z+1/2", "-x, -y+1/2, z+1/2", "-x+1/4, y+3/4, z+3/4", "x+1/4, -y+3/4, z+3/4", "x+1/2, y, z+1/2", "-x+1/2, -y, z+1/2", "-x+3/4, y+1/4, z+3/4", "x+3/4, -y+1/4, z+3/4", "x+1/2, y+1/2, z", "-x+1/2, -y+1/2, z", "-x+3/4, y+3/4, z+1/4", "x+3/4, -y+3/4, z+1/4" }; CMLMatrix[] matrix1 = null; CMLTransform3[] transform31 = null; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { matrix1 = new CMLMatrix[] { new CMLMatrix(3, 4, new double[] { 1, 0, 0, 0.0, 0, 1, 0, 0.0, 0, 0, 1, 0.0 }), new CMLMatrix(3, 4, new double[] { -1, 0, 0, 0.5, 0, -1, 0, 0.0, 0, 0, 1, 0.5 }), new CMLMatrix(3, 4, new double[] { 1, 0, 0, 0.5, 0, -1, 0, 0.5, 0, 0, -1, 0.0 }), new CMLMatrix(3, 4, new double[] { -1, 0, 0, 0.0, 0, 1, 0, 0.5, 0, 0, -1, 0.5 }), new CMLMatrix(3, 4, new double[] { -1, 0, 0, 0.0, 0, -1, 0, 0.0, 0, 0, -1, 0.0 }), new CMLMatrix(3, 4, new double[] { 1, 0, 0, -0.5, 0, 1, 0, 0.0, 0, 0, -1, -0.5 }), new CMLMatrix(3, 4, new double[] { -1, 0, 0, -0.5, 0, 1, 0, -0.5, 0, 0, 1, 0.0 }), new CMLMatrix(3, 4, new double[] { 1, 0, 0, 0.0, 0, -1, 0, -0.5, 0, 0, 1, -0.5 }) }; transform31 = new CMLTransform3[] { new CMLTransform3(new double[] { 1, 0, 0, 0.0, 0, 1, 0, 0.0, 0, 0, 1, 0.0, 0, 0, 0, 1 }), new CMLTransform3(new double[] { -1, 0, 0, 0.5, 0, -1, 0, 0.0, 0, 0, 1, 0.5, 0, 0, 0, 1 }), new CMLTransform3(new double[] { 1, 0, 0, 0.5, 0, -1, 0, 0.5, 0, 0, -1, 0.0, 0, 0, 0, 1 }), new CMLTransform3(new double[] { -1, 0, 0, 0.0, 0, 1, 0, 0.5, 0, 0, -1, 0.5, 0, 0, 0, 1 }), new CMLTransform3(new double[] { -1, 0, 0, 0.0, 0, -1, 0, 0.0, 0, 0, -1, 0.0, 0, 0, 0, 1 }), new CMLTransform3(new double[] { 1, 0, 0, -0.5, 0, 1, 0, 0.0, 0, 0, -1, -0.5, 0, 0, 0, 1 }), new CMLTransform3(new double[] { -1, 0, 0, -0.5, 0, 1, 0, -0.5, 0, 0, 1, 0.0, 0, 0, 0, 1 }), new CMLTransform3(new double[] { 1, 0, 0, 0.0, 0, -1, 0, -0.5, 0, 0, 1, -0.5, 0, 0, 0, 1 }), }; } /** * Test method for * 'org.xmlcml.cml.element.CMLSymmetry.CMLSymmetry(String[])' */ @Test public void testCMLSymmetryStringArray() { Assert.assertEquals("opercount", 8, pbca.length); CMLSymmetry symmetry = new CMLSymmetry(pbca); CMLElements matrices = symmetry.getMatrixElements(); Assert.assertEquals("matrixcount", 0, matrices.size()); CMLElements transform3s = symmetry .getTransform3Elements(); Assert.assertEquals("transformcount", 8, transform3s.size()); int i = 0; for (CMLTransform3 transform3 : transform3s) { CMLTransform3Test.assertEquals("symmetry element transform3 " + i, transform31[i++], transform3, CMLConstants.EPS); } } /** * Test method for 'org.xmlcml.cml.element.CMLSymmetry.isGroup()' */ @Test public void testIsGroup() { CMLSymmetry symmetry = new CMLSymmetry(pbca); Assert.assertEquals("group", false, symmetry.isGroup()); symmetry = new CMLSymmetry(pmmm); Assert.assertEquals("group", true, symmetry.isGroup()); symmetry = new CMLSymmetry(oper3); Assert.assertEquals("group", false, symmetry.isGroup()); symmetry = new CMLSymmetry(p212121); Assert.assertEquals("group", false, symmetry.isGroup()); } /** * Test method for 'org.xmlcml.cml.element.CMLSymmetry.isSpaceGroup()' */ @Test public void testIsSpaceGroup() { CMLSymmetry symmetry = new CMLSymmetry(pbca); // Assert.assertEquals("group", true, symmetry.isSpaceGroup()); symmetry = new CMLSymmetry(p212121); Assert.assertEquals("group", true, symmetry.isSpaceGroup()); } /** * Test method for 'org.xmlcml.cml.element.CMLSymmetry.multiplyCMLSymmetry * sym) */ @Test public void testCMLSymmetrymultiplyCMLSymmetry() { CMLSymmetry sym1 = new CMLSymmetry(new String[] { "x, y, z", "-x, -y, -z" }); CMLSymmetry sym1Copy = new CMLSymmetry(sym1); Assert.assertTrue("convolute", sym1Copy.isEqualTo(sym1, EPS)); CMLSymmetry mmmGenerators = new CMLSymmetry(new String[] { "x, y, z", "-x, y, z", "x, -y, z", "x, y, -z", }); CMLSymmetry mmm = new CMLSymmetry(new String[] { "x, y, z", "-x, y, z", "x, -y, z", "x, y, -z", "-x, -y, -z", "x, -y, -z", "-x, y, -z", "-x, -y, z", }); CMLSymmetry sym2Copy = new CMLSymmetry(mmmGenerators); Assert.assertTrue("convolute", sym2Copy.isEqualTo(mmmGenerators, EPS)); // this generates a complete group CMLSymmetry sym = sym1.convolute(mmmGenerators); // make sure no corruption Assert.assertTrue("convolute", sym2Copy.isEqualTo(mmmGenerators, EPS)); Assert.assertTrue("convolute", sym1Copy.isEqualTo(sym1, EPS)); Assert.assertEquals("convolute", 8, sym.getTransform3Elements().size()); Assert.assertTrue("convolute", sym.isEqualTo(mmm, EPS)); sym = sym1.convolute(sym1); Assert.assertEquals("convolute", 2, sym.getTransform3Elements().size()); sym = mmmGenerators.convolute(mmmGenerators); // this does not generate a complete group (-x, -y, -z is missing) Assert.assertEquals("convolute", 7, sym.getTransform3Elements().size()); CMLSymmetry sym4 = new CMLSymmetry(new String[] { "x, y, z", "-x, y, z", "x, -y, z", "x, y, -z", "-x, -y, z", "-x, y, -z", "x, -y, -z", }); Assert.assertTrue("convolute", sym.isEqualTo(sym4, EPS)); } /** test. */ @Test public void testGetNonTranslations() { CMLSymmetry fullGroup = null; CMLSymmetry nonTranslationSubGroup = null; CMLElements subGroupElements = null; fullGroup = new CMLSymmetry(p212121); Assert.assertTrue("is group", fullGroup.isSpaceGroup()); nonTranslationSubGroup = fullGroup.getNonTranslations(); subGroupElements = nonTranslationSubGroup.getTransform3Elements(); Assert.assertEquals("group elements", 0, subGroupElements.size()); fullGroup = new CMLSymmetry(p21c); Assert.assertTrue("is group", fullGroup.isSpaceGroup()); nonTranslationSubGroup = fullGroup.getNonTranslations(); Assert.assertFalse("is group", nonTranslationSubGroup.isSpaceGroup()); subGroupElements = nonTranslationSubGroup.getTransform3Elements(); Assert.assertEquals("group elements", 1, subGroupElements.size()); fullGroup = new CMLSymmetry(pbca); Assert.assertTrue("is group", fullGroup.isSpaceGroup()); nonTranslationSubGroup = fullGroup.getNonTranslations(); Assert.assertFalse("is group", nonTranslationSubGroup.isSpaceGroup()); subGroupElements = nonTranslationSubGroup.getTransform3Elements(); Assert.assertEquals("group elements", 1, subGroupElements.size()); fullGroup = new CMLSymmetry(abm2); Assert.assertTrue("is group", fullGroup.isSpaceGroup()); nonTranslationSubGroup = fullGroup.getNonTranslations(); Assert.assertFalse("is not space group", nonTranslationSubGroup .isSpaceGroup()); subGroupElements = nonTranslationSubGroup.getTransform3Elements(); Assert.assertEquals("group elements", 2, subGroupElements.size()); } /** test. */ @Test public void testGetPureTranslations() { CMLSymmetry fullGroup = new CMLSymmetry(p212121); List operators = fullGroup.getPureTranslations(); Assert.assertEquals("translations", 0, operators.size()); fullGroup = new CMLSymmetry(ibar42d); operators = fullGroup.getPureTranslations(); Assert.assertEquals("translations", 1, operators.size()); CMLVector3Test.assertEquals("centering", new double[] { 0.5, 0.5, 0.5 }, operators.get(0) .getTranslation(), EPS); CMLCrystal.Centering centering = fullGroup.getCentering(); Assert.assertTrue("centering type", CMLCrystal.Centering.I .equals(centering)); fullGroup = new CMLSymmetry(c2c); operators = fullGroup.getPureTranslations(); Assert.assertEquals("translations", 1, operators.size()); CMLVector3Test.assertEquals("centering", new double[] { 0.5, 0.5, 0 }, operators.get(0).getTranslation(), EPS); centering = fullGroup.getCentering(); Assert.assertTrue("centering type", CMLCrystal.Centering.C .equals(centering)); fullGroup = new CMLSymmetry(rbar3); operators = fullGroup.getPureTranslations(); Assert.assertEquals("translations", 2, operators.size()); CMLVector3Test.assertEquals("centering", new double[] { 2. / 3., 1. / 3., 1. / 3. }, operators.get(0).getTranslation(), EPS); CMLVector3Test.assertEquals("centering", new double[] { 1. / 3., 2. / 3., 2. / 3. }, operators.get(1).getTranslation(), EPS); centering = fullGroup.getCentering(); Assert.assertTrue("centering type", CMLCrystal.Centering.R .equals(centering)); fullGroup = new CMLSymmetry(abar22a); operators = fullGroup.getPureTranslations(); Assert.assertEquals("translations", 1, operators.size()); CMLVector3Test.assertEquals("centering", new double[] { 0, 0.5, 0.5 }, operators.get(0).getTranslation(), EPS); centering = fullGroup.getCentering(); Assert.assertTrue("centering type", CMLCrystal.Centering.A .equals(centering)); fullGroup = new CMLSymmetry(fdd2); operators = fullGroup.getPureTranslations(); Assert.assertEquals("translations", 3, operators.size()); CMLVector3Test.assertEquals("centering", new double[] { 0, 0.5, 0.5 }, operators.get(0).getTranslation(), EPS); CMLVector3Test.assertEquals("centering", new double[] { 0.5, 0, 0.5 }, operators.get(1).getTranslation(), EPS); CMLVector3Test.assertEquals("centering", new double[] { 0.5, 0.5, 0 }, operators.get(2).getTranslation(), EPS); centering = fullGroup.getCentering(); Assert.assertTrue("centering type", CMLCrystal.Centering.F .equals(centering)); } /** test. */ @Test public void testGetPointGroupMultiplicity() { double eps = 0.0000001; CMLSymmetry group = null; Point3 p000 = new Point3(new double[] { 0., 0., 0. }); Point3 p123 = new Point3(new double[] { 0.1, 0.2, 0.3 }); Point3 p300 = new Point3(new double[] { 0.3, 0.0, 0.0 }); Point3 p304 = new Point3(new double[] { 0.3, 0.0, 0.4 }); Point3 p555 = new Point3(new double[] { 0.5, 0.5, 0.5 }); int multiplicity = 0; group = new CMLSymmetry(pmmm); Assert.assertTrue("is group", group.isSpaceGroup()); multiplicity = group.getPointGroupMultiplicity(p000, eps); Assert.assertEquals("multiplicity ", 8, multiplicity); multiplicity = group.getPointGroupMultiplicity(p123, eps); Assert.assertEquals("multiplicity ", 1, multiplicity); multiplicity = group.getPointGroupMultiplicity(p300, eps); Assert.assertEquals("multiplicity ", 4, multiplicity); multiplicity = group.getPointGroupMultiplicity(p304, eps); Assert.assertEquals("multiplicity ", 2, multiplicity); multiplicity = group.getPointGroupMultiplicity(p555, eps); Assert.assertEquals("multiplicity ", 1, multiplicity); multiplicity = group.getSpaceGroupMultiplicity(p555); Assert.assertEquals("multiplicity ", 8, multiplicity); group = new CMLSymmetry(p212121); Assert.assertTrue("is group", group.isSpaceGroup()); multiplicity = group.getPointGroupMultiplicity(p000, eps); Assert.assertEquals("multiplicity ", 1, multiplicity); } /** test. */ @Test public void testGetSpaceGroupMultiplicity() { /* * -- - 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 * 1.0 0.0 0.0 0.0 0.0 1.0 -1.0 0.0 0.0 0.0 * 0.0 -1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 * 1.0 0.0 0.0 0.5 0.0 -1.0 0.0 0.5 0.0 0.0 -1.0 0.0 0.0 * 0.0 0.0 1.0 -1.0 0.0 0.0 0.5 0.0 1.0 0.0 * 0.5 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 1.0 - - -- */ CMLSymmetry group = null; Point3 p1 = new Point3(new double[] { 0.0, 0.5, 0.8011 }); Point3 p1a = new Point3(new double[] { 1.0, 0.5, 0.8011 }); Point3 p1b = new Point3(new double[] { 0.0, -0.5, 0.8011 }); Point3 p2 = new Point3(new double[] { 0.33569, 0.98239, 0.88892 }); Point3 p3a = new Point3(new double[] { 0.5, 1.0, 0.8011 }); Point3 p3b = new Point3(new double[] { -0.5, 1.0, 0.8011 }); int multiplicity = 0; group = new CMLSymmetry(p21212); Assert.assertTrue("is group", group.isSpaceGroup()); multiplicity = group.getSpaceGroupMultiplicity(p1); Assert.assertEquals("multiplicity ", 2, multiplicity); multiplicity = group.getSpaceGroupMultiplicity(p1a); Assert.assertEquals("multiplicity ", 2, multiplicity); multiplicity = group.getSpaceGroupMultiplicity(p1b); Assert.assertEquals("multiplicity ", 2, multiplicity); multiplicity = group.getSpaceGroupMultiplicity(p2); Assert.assertEquals("multiplicity ", 1, multiplicity); multiplicity = group.getSpaceGroupMultiplicity(p3a); Assert.assertEquals("multiplicity ", 2, multiplicity); multiplicity = group.getSpaceGroupMultiplicity(p3b); Assert.assertEquals("multiplicity ", 2, multiplicity); // Ni 0.0000 0.0000 0.5000 0.02783(15) Uani d SU 1 . . Ni // 'x, y, z' // 'x+1/2, -y+1/2, z+1/2' // '-x, -y, -z' // '-x-1/2, y-1/2, -z-1/2' Point3 point = new Point3(0.0000, 0.0000, 0.5000); CMLSymmetry symmetry = new CMLSymmetry(new String[] { "x, y, z", "x+1/2, -y+1/2, z+1/2", "-x, -y, -z", "-x-1/2, y-1/2, -z-1/2" }); int mult = symmetry.getSpaceGroupMultiplicity(point); Assert.assertEquals("Multiplicity ", 2, mult); } /** * Test method for 'org.xmlcml.cml.element.CMLSymmetry.copy()' */ @Test public void testCopy() { CMLSymmetry symmetry = new CMLSymmetry(pbca); CMLSymmetry symmetry1 = (CMLSymmetry) symmetry.copy(); Assert.assertEquals("copy", symmetry.getMatrixElements().size(), symmetry1.getMatrixElements().size()); } /** * Test method for * 'org.xmlcml.cml.element.CMLSymmetry.CMLSymmetry(List)' */ @Test public void testCMLSymmetryListOfCMLTransform3() { List list = new ArrayList(); list.add(new CMLTransform3("x, y, z")); list.add(new CMLTransform3("-x, 1/2+y, -z")); CMLSymmetry symmetry = new CMLSymmetry(list); Assert.assertEquals("symmetry", 2, symmetry.getTransform3Elements() .size()); CMLTransform3 tr = symmetry.getTransform3Elements().get(1); CMLTransform3Test.assertEquals("symmetry 2", new double[] { -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.5, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0 }, tr, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLSymmetry.createFromXYZStrings(List)' */ @Test public void testCreateFromXYZStrings() { List list = new ArrayList(); list.add("x, y, z"); list.add("-x, 1/2+y, -z"); CMLSymmetry symmetry = CMLSymmetry.createFromXYZStrings(list); Assert.assertEquals("symmetry", 2, symmetry.getTransform3Elements() .size()); CMLTransform3 tr = symmetry.getTransform3Elements().get(1); CMLTransform3Test.assertEquals("symmetry 2", new double[] { -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.5, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0 }, tr, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLSymmetry.convolute(CMLSymmetry)' */ @Test public void testConvolute() { List list = new ArrayList(); list.add("x, y, z"); list.add("-x, 1/2+y, -z"); CMLSymmetry symmetry1 = CMLSymmetry.createFromXYZStrings(list); list = new ArrayList(); list.add("-x, -y, -z"); CMLSymmetry symmetry2 = CMLSymmetry.createFromXYZStrings(list); CMLSymmetry symmetry3 = symmetry1.convolute(symmetry2); Assert.assertNotNull(symmetry3); // doesn't give right answer } /** * Test method for * 'org.xmlcml.cml.element.CMLSymmetry.isEqualTo(CMLSymmetry, double)' */ @Test public void testIsEqualTo() { List list = new ArrayList(); list.add("x, y, z"); list.add("-x, 1/2+y, -z"); CMLSymmetry symmetry1 = CMLSymmetry.createFromXYZStrings(list); list = new ArrayList(); list.add("x, y, z"); list.add("-x, 1/2+y, -z"); CMLSymmetry symmetry2 = CMLSymmetry.createFromXYZStrings(list); Assert.assertTrue("is equal", symmetry1.isEqualTo(symmetry2, EPS)); } /** * Test method for * 'org.xmlcml.cml.element.CMLSymmetry.normalizeCrystallographically()' */ @Test public void testNormalizeCrystallographically() { List list = new ArrayList(); list.add("x, y, 2+z"); list.add("1-x, 1/2+y, 3-z"); CMLSymmetry symmetry1 = CMLSymmetry.createFromXYZStrings(list); list = new ArrayList(); list.add("x, y, z"); list.add("-x, 1/2+y, -z"); CMLSymmetry symmetry2 = CMLSymmetry.createFromXYZStrings(list); Assert.assertFalse("is equal", symmetry1.isEqualTo(symmetry2, EPS)); symmetry1.normalizeCrystallographically(); Assert.assertTrue("is equal", symmetry1.isEqualTo(symmetry2, EPS)); } /** * Test method for 'org.xmlcml.cml.element.CMLSymmetry.getCentering()' */ @Test public void testGetCentering() { List list = new ArrayList(); list.add("x, y, z"); list.add("-x, +y, -z"); list.add("1/2+x, 1/2+y, z"); list.add("1/2-x, 1/2+y, -z"); CMLSymmetry symmetry1 = CMLSymmetry.createFromXYZStrings(list); CMLCrystal.Centering center = symmetry1.getCentering(); Assert.assertEquals("center", CMLCrystal.Centering.C, center); } @Test public void testGetContainedSymmetry(){ CMLElement root = new CMLElement("root"); CMLSymmetry sym = new CMLSymmetry(); root.appendChild(sym); CMLSymmetry test=CMLSymmetry.getContainedSymmetry(root); Assert.assertEquals(sym, test); } @Test(expected = RuntimeException.class) public void testGetContainedSymmetry2() { CMLElement root = new CMLElement("root"); CMLSymmetry sym = new CMLSymmetry(); CMLSymmetry extra = new CMLSymmetry(); root.appendChild(sym); root.appendChild(extra); @SuppressWarnings("unused") CMLSymmetry test = CMLSymmetry.getContainedSymmetry(root); } @Test public void testGetContainedSymmetry3(){ CMLElement root = new CMLElement("root"); CMLElement container = new CMLElement("containter"); CMLSymmetry sym = new CMLSymmetry(); CMLSymmetry extra = new CMLSymmetry(); root.appendChild(container); container.appendChild(sym); root.appendChild(extra); CMLSymmetry test=CMLSymmetry.getContainedSymmetry(container); Assert.assertEquals(sym, test); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLTableCellTest.java000077500000000000000000000144561477224461000300470ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.base.CMLXOMTestUtils.assertEqualsCanonically; import static org.xmlcml.cml.base.CMLXOMTestUtils.assertWriteHTML; import static org.xmlcml.cml.base.CMLXOMTestUtils.logger; import java.io.File; import java.io.IOException; import java.net.URL; import nu.xom.ParsingException; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLArrayList; import org.xmlcml.cml.element.CMLTable; import org.xmlcml.cml.element.CMLTableCell; import org.xmlcml.cml.element.CMLTableContent; import org.xmlcml.cml.element.CMLTableHeader; import org.xmlcml.cml.element.CMLTableRow; import org.xmlcml.cml.element.CMLTableRowList; import org.xmlcml.euclid.Util; /** * @author pm286 * */ public class CMLTableCellTest extends AbstractTableBase { CMLTableCell cell = null; protected CMLTableRowList tableRowList = null; CMLTableRow tableRow = null; protected CMLTableContent tableContent = null; protected CMLTableHeader tableHeader = null; protected CMLArrayList arrayList = null; protected CMLTable columnTable1 = null; protected CMLTable contentTable1 = null; protected CMLTable rowTable1 = null; /** * set up. */ @Before public void makeCell() { cell = new CMLTableCell(); } /** * Test method for * {@link org.xmlcml.cml.element.CMLTableCell#writeHTML(java.io.Writer)}. */ @Test public final void testWriteHTML() { cell = new CMLTableCell("foo"); String ss = "foo"; CMLXOMTestUtils.assertWriteHTML(cell, ss); cell = new CMLTableCell(1.2); ss = "1.2"; assertWriteHTML(cell, ss); cell = new CMLTableCell(3); ss = "3"; assertWriteHTML(cell, ss); } /** * Test method for * {@link org.xmlcml.cml.element.CMLTableCell#CMLTableCell(java.lang.String)} * . */ @Test public final void testCMLTableCellString() { cell = new CMLTableCell("foo"); } /** * Test method for * {@link org.xmlcml.cml.element.CMLTableCell#CMLTableCell(double)}. */ @Test public final void testCMLTableCellDouble() { cell = new CMLTableCell(1.2); String ss = "1.2"; CMLTableCell expected = (CMLTableCell)CMLXOMTestUtils.parseValidString(ss); assertEqualsCanonically("cell double", expected, cell); } /** * Test method for * {@link org.xmlcml.cml.element.CMLTableCell#CMLTableCell(int)}. */ @Test public final void testCMLTableCellInt() { cell = new CMLTableCell(3); String ss = "3"; CMLTableCell expected = (CMLTableCell)CMLXOMTestUtils.parseValidString(ss); assertEqualsCanonically("cell double", expected, cell); } /** * Test method for * {@link org.xmlcml.cml.element.CMLTableCell#CMLTableCell(nu.xom.Element)}. */ @Test public final void testCMLTableCellElement() { String molS = ""; String mol1S = ""; CMLElement mol = (CMLElement)CMLXOMTestUtils.parseValidString(molS); cell = new CMLTableCell(mol); String ss = "" + mol1S + ""; CMLTableCell expected = (CMLTableCell)CMLXOMTestUtils.parseValidString(ss); assertEqualsCanonically("cell molecule", expected, cell); } /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { /* * 3 5 7Sue Fred Sandy *
*/ URL columnUrl1 = null; URL contentUrl1 = null; URL rowUrl1 = null; try { columnUrl1 = Util.getResource(COLUMN_TABLE1_XML); contentUrl1 = Util.getResource(CONTENT_TABLE1_XML); rowUrl1 = Util.getResource(ROW_TABLE1_XML); } catch (Exception e) { // Saw this once, being cautious. ~~~~jd323 e.printStackTrace(); } Assert.assertNotNull(columnUrl1); Assert.assertNotNull(contentUrl1); Assert.assertNotNull(rowUrl1); try { CMLBuilder builder = new CMLBuilder(); columnTable1 = (CMLTable) builder.build( new File(columnUrl1.toURI())).getRootElement(); contentTable1 = (CMLTable) builder.build( new File(contentUrl1.toURI())).getRootElement(); rowTable1 = (CMLTable) builder.build(new File(rowUrl1.toURI())) .getRootElement(); } catch (IOException e) { e.printStackTrace(); Assert.fail("Should not throw IOException"); } catch (ParsingException e) { e.printStackTrace(); logger.error("Parse exception " + e.getMessage()); Assert.fail("Should not throw ParsingException" + e.getCause()); } tableContent = (CMLTableContent)CMLXOMTestUtils.parseValidString(tableContentS); tableHeader = (CMLTableHeader)CMLXOMTestUtils.parseValidString(tableHeaderS); tableRowList = (CMLTableRowList)CMLXOMTestUtils.parseValidString(tableRowListS); tableRow = tableRowList.getTableRowElements().get(1); arrayList = (CMLArrayList)CMLXOMTestUtils.parseValidString(arrayListS); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLTableContentTest.java000077500000000000000000000103031477224461000305650ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.base.CMLXOMTestUtils.logger; import java.io.File; import java.io.IOException; import java.net.URL; import nu.xom.ParsingException; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLArrayList; import org.xmlcml.cml.element.CMLTable; import org.xmlcml.cml.element.CMLTableContent; import org.xmlcml.cml.element.CMLTableHeader; import org.xmlcml.cml.element.CMLTableRow; import org.xmlcml.cml.element.CMLTableRowList; import org.xmlcml.euclid.Util; import org.xmlcml.euclid.test.StringTestBase; /** * @author pm286 * */ public class CMLTableContentTest extends AbstractTableBase { protected CMLTableRowList tableRowList = null; CMLTableRow tableRow = null; protected CMLTableContent tableContent = null; protected CMLTableHeader tableHeader = null; protected CMLArrayList arrayList = null; protected CMLTable columnTable1 = null; protected CMLTable contentTable1 = null; protected CMLTable rowTable1 = null; /** set up. */ @Before public void makeContent() { } /** * Test method for {@link org.xmlcml.cml.element.CMLTableContent#getStrings()}. */ @Test public final void testGetStrings() { String[] ss = tableContent.getStrings(); StringTestBase.assertEquals("strings", new String[]{"1", "a", "2", "b", "3", "c"}, ss); } /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { /* * 3 5 7Sue Fred Sandy *
*/ URL columnUrl1 = null; URL contentUrl1 = null; URL rowUrl1 = null; try { columnUrl1 = Util.getResource(COLUMN_TABLE1_XML); contentUrl1 = Util.getResource(CONTENT_TABLE1_XML); rowUrl1 = Util.getResource(ROW_TABLE1_XML); } catch (Exception e) { // Saw this once, being cautious. ~~~~jd323 e.printStackTrace(); } Assert.assertNotNull(columnUrl1); Assert.assertNotNull(contentUrl1); Assert.assertNotNull(rowUrl1); try { CMLBuilder builder = new CMLBuilder(); columnTable1 = (CMLTable) builder.build( new File(columnUrl1.toURI())).getRootElement(); contentTable1 = (CMLTable) builder.build( new File(contentUrl1.toURI())).getRootElement(); rowTable1 = (CMLTable) builder.build(new File(rowUrl1.toURI())) .getRootElement(); } catch (IOException e) { e.printStackTrace(); Assert.fail("Should not throw IOException"); } catch (ParsingException e) { e.printStackTrace(); logger.error("Parse exception " + e.getMessage()); Assert.fail("Should not throw ParsingException" + e.getCause()); } tableContent = (CMLTableContent)CMLXOMTestUtils.parseValidString(tableContentS); tableHeader = (CMLTableHeader)CMLXOMTestUtils.parseValidString(tableHeaderS); tableRowList = (CMLTableRowList)CMLXOMTestUtils.parseValidString(tableRowListS); tableRow = tableRowList.getTableRowElements().get(1); arrayList = (CMLArrayList)CMLXOMTestUtils.parseValidString(arrayListS); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLTableHeaderTest.java000077500000000000000000000106161477224461000303520ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.base.CMLXOMTestUtils.assertWriteHTML; import static org.xmlcml.cml.base.CMLXOMTestUtils.logger; import java.io.File; import java.io.IOException; import java.net.URL; import nu.xom.ParsingException; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLArrayList; import org.xmlcml.cml.element.CMLTable; import org.xmlcml.cml.element.CMLTableContent; import org.xmlcml.cml.element.CMLTableHeader; import org.xmlcml.cml.element.CMLTableRow; import org.xmlcml.cml.element.CMLTableRowList; import org.xmlcml.euclid.Util; /** * @author pm286 * */ public class CMLTableHeaderTest extends AbstractTableBase { protected CMLTableRowList tableRowList = null; CMLTableRow tableRow = null; protected CMLTableContent tableContent = null; protected CMLTableHeader tableHeader = null; protected CMLArrayList arrayList = null; protected CMLTable columnTable1 = null; protected CMLTable contentTable1 = null; protected CMLTable rowTable1 = null; /** * Test method for * {@link org.xmlcml.cml.element.CMLTableHeader#writeHTML(java.io.Writer)}. */ @Test public final void testWriteHTML() { String expected = CMLConstants.S_EMPTY + "\nfoobar"; assertWriteHTML(tableHeader, expected); } /** * Test method for * {@link org.xmlcml.cml.element.CMLTableHeader#getColumnCount()}. */ @Test public final void testGetColumnCount() { Assert.assertEquals("count", 2, tableHeader.getColumnCount()); } /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { /* * 3 5 7Sue Fred Sandy *
*/ URL columnUrl1 = null; URL contentUrl1 = null; URL rowUrl1 = null; try { columnUrl1 = Util.getResource(COLUMN_TABLE1_XML); contentUrl1 = Util.getResource(CONTENT_TABLE1_XML); rowUrl1 = Util.getResource(ROW_TABLE1_XML); } catch (Exception e) { // Saw this once, being cautious. ~~~~jd323 e.printStackTrace(); } Assert.assertNotNull(columnUrl1); Assert.assertNotNull(contentUrl1); Assert.assertNotNull(rowUrl1); try { CMLBuilder builder = new CMLBuilder(); columnTable1 = (CMLTable) builder.build( new File(columnUrl1.toURI())).getRootElement(); contentTable1 = (CMLTable) builder.build( new File(contentUrl1.toURI())).getRootElement(); rowTable1 = (CMLTable) builder.build(new File(rowUrl1.toURI())) .getRootElement(); } catch (IOException e) { e.printStackTrace(); Assert.fail("Should not throw IOException"); } catch (ParsingException e) { e.printStackTrace(); logger.error("Parse exception " + e.getMessage()); Assert.fail("Should not throw ParsingException" + e.getCause()); } tableContent = (CMLTableContent)CMLXOMTestUtils.parseValidString(tableContentS); tableHeader = (CMLTableHeader)CMLXOMTestUtils.parseValidString(tableHeaderS); tableRowList = (CMLTableRowList)CMLXOMTestUtils.parseValidString(tableRowListS); tableRow = tableRowList.getTableRowElements().get(1); arrayList = (CMLArrayList)CMLXOMTestUtils.parseValidString(arrayListS); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLTableRowTest.java000077500000000000000000000115141477224461000277270ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.base.CMLXOMTestUtils.assertWriteHTML; import static org.xmlcml.cml.base.CMLXOMTestUtils.logger; import static org.xmlcml.euclid.EuclidConstants.S_COMMA; import static org.xmlcml.euclid.EuclidConstants.S_EMPTY; import static org.xmlcml.euclid.EuclidConstants.S_SPACE; import java.io.File; import java.io.IOException; import java.net.URL; import nu.xom.ParsingException; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLArrayList; import org.xmlcml.cml.element.CMLTable; import org.xmlcml.cml.element.CMLTableContent; import org.xmlcml.cml.element.CMLTableHeader; import org.xmlcml.cml.element.CMLTableRow; import org.xmlcml.cml.element.CMLTableRowList; import org.xmlcml.euclid.Util; /** * @author pm286 * */ public class CMLTableRowTest extends AbstractTableBase { protected CMLTableRowList tableRowList = null; CMLTableRow tableRow = null; protected CMLTableContent tableContent = null; protected CMLTableHeader tableHeader = null; protected CMLArrayList arrayList = null; protected CMLTable columnTable1 = null; protected CMLTable contentTable1 = null; protected CMLTable rowTable1 = null; /** * Test method for * {@link org.xmlcml.cml.element.CMLTableRow#writeHTML(java.io.Writer)}. */ @Test public final void testWriteHTML() { String tableRowS = "\n2b"; assertWriteHTML(tableRow, tableRowS); } /** * Test method for * {@link org.xmlcml.cml.element.CMLTableRow#getDelimitedString(java.lang.String)} * . */ @Test public final void testGetDelimitedString() { String tableRowS = tableRow.getDelimitedString(S_COMMA); Assert.assertEquals("comma", "2,b", tableRowS); tableRowS = tableRow.getDelimitedString(S_SPACE); Assert.assertEquals("comma", "2 b", tableRowS); tableRowS = tableRow.getDelimitedString(S_EMPTY); Assert.assertEquals("comma", "2 b", tableRowS); tableRowS = tableRow.getDelimitedString(null); Assert.assertEquals("comma", "2 b", tableRowS); } /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { /* * 3 5 7Sue Fred Sandy *
*/ URL columnUrl1 = null; URL contentUrl1 = null; URL rowUrl1 = null; try { columnUrl1 = Util.getResource(COLUMN_TABLE1_XML); contentUrl1 = Util.getResource(CONTENT_TABLE1_XML); rowUrl1 = Util.getResource(ROW_TABLE1_XML); } catch (Exception e) { // Saw this once, being cautious. ~~~~jd323 e.printStackTrace(); } Assert.assertNotNull(columnUrl1); Assert.assertNotNull(contentUrl1); Assert.assertNotNull(rowUrl1); try { CMLBuilder builder = new CMLBuilder(); columnTable1 = (CMLTable) builder.build( new File(columnUrl1.toURI())).getRootElement(); contentTable1 = (CMLTable) builder.build( new File(contentUrl1.toURI())).getRootElement(); rowTable1 = (CMLTable) builder.build(new File(rowUrl1.toURI())) .getRootElement(); } catch (IOException e) { e.printStackTrace(); Assert.fail("Should not throw IOException"); } catch (ParsingException e) { e.printStackTrace(); logger.error("Parse exception " + e.getMessage()); Assert.fail("Should not throw ParsingException" + e.getCause()); } tableContent = (CMLTableContent)CMLXOMTestUtils.parseValidString(tableContentS); tableHeader = (CMLTableHeader)CMLXOMTestUtils.parseValidString(tableHeaderS); tableRowList = (CMLTableRowList)CMLXOMTestUtils.parseValidString(tableRowListS); tableRow = tableRowList.getTableRowElements().get(1); arrayList = (CMLArrayList)CMLXOMTestUtils.parseValidString(arrayListS); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLTableTest.java000077500000000000000000000176461477224461000272530ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.base.CMLXOMTestUtils.logger; import java.io.File; import java.io.IOException; import java.io.StringWriter; import java.net.URL; import java.util.List; import nu.xom.ParsingException; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLArrayList; import org.xmlcml.cml.element.CMLTable; import org.xmlcml.cml.element.CMLTable.TableType; import org.xmlcml.cml.element.CMLTableContent; import org.xmlcml.cml.element.CMLTableHeader; import org.xmlcml.cml.element.CMLTableRow; import org.xmlcml.cml.element.CMLTableRowList; import org.xmlcml.euclid.Util; /** * test CMLTable. * * @author pmr * */ public class CMLTableTest extends AbstractTableBase { protected CMLTableRowList tableRowList = null; CMLTableRow tableRow = null; protected CMLTableContent tableContent = null; protected CMLTableHeader tableHeader = null; protected CMLArrayList arrayList = null; protected CMLTable columnTable1 = null; protected CMLTable contentTable1 = null; protected CMLTable rowTable1 = null; /** * Test method for 'org.xmlcml.cml.element.CMLTable.getRows()' */ @Test public void testGetRows() { Assert.assertEquals("rows ", 3, columnTable1.getRows()); Assert.assertEquals("rows ", 3, contentTable1.getRows()); Assert.assertEquals("rows ", 3, rowTable1.getRows()); } /** * Test method for 'org.xmlcml.cml.element.CMLTable.getColumns()' */ @Test public void testGetColumns() { Assert.assertEquals("columns ", 2, columnTable1.getColumns()); } /** * Test method for 'org.xmlcml.cml.element.CMLTable.writeHTML(Writer)' */ @Test public void testWriteHTML() { StringWriter sw = new StringWriter(); try { columnTable1.writeHTML(sw); sw.close(); } catch (IOException e) { Assert.fail("should not throw " + e); } String ss = "\n" + "\n" + "\n" + "\n" + "\n" + "
ds
1.0a
2.0b
3.0c
"; ss = "table"; String s = sw.toString(); Assert.assertEquals("HTML output ", ss, s); } /** * Test method for 'org.xmlcml.cml.element.CMLTable.copy()' */ @Test public void testCopy() { CMLTable tableX = (CMLTable) columnTable1.copy(); Assert.assertNotNull("copy not null", tableX); } /** * Test method for 'org.xmlcml.cml.element.CMLTable.getColumnValuesList()' */ @Test public void testGetColumnValuesList() { List> sListList = ((CMLTable) columnTable1).getColumnValuesList(); Assert.assertEquals("column values", 2, sListList.size()); List sList0 = sListList.get(0); Assert.assertEquals("col 0", new String[]{"1.0", "2.0", "3.0"}, (String[]) sList0.toArray(new String[0])); List sList1 = sListList.get(1); Assert.assertEquals("col 1", new String[]{"a", "b", "c"}, (String[]) sList1.toArray(new String[0])); } /** * Test method for {@link org.xmlcml.cml.element.CMLTable#setTableType(java.lang.String)}. */ @Test public final void testSetTableTypeString() { columnTable1.setTableType(TableType.COLUMN_BASED.value); try { columnTable1.setTableType(TableType.CONTENT_BASED.value); } catch (RuntimeException e) { Assert.assertEquals("set table fails", "bad table", e.getMessage()); } try { columnTable1.setTableType(TableType.ROW_BASED.value); } catch (RuntimeException e) { Assert.assertEquals("set table fails", "bad table", e.getMessage()); } } /** * Test method for {@link org.xmlcml.cml.element.CMLTable#setTableType(org.xmlcml.cml.element.CMLTable.TableType)}. */ @Test public final void testSetTableTypeTableType() { columnTable1.setTableType(TableType.COLUMN_BASED); try { columnTable1.setTableType(TableType.CONTENT_BASED); } catch (RuntimeException e) { Assert.assertEquals("set table fails", "bad table", e.getMessage()); } try { columnTable1.setTableType(TableType.ROW_BASED); } catch (RuntimeException e) { Assert.assertEquals("set table fails", "bad table", e.getMessage()); } } /** * Test method for {@link org.xmlcml.cml.element.CMLTable#getTableTypeEnum()}. */ @Test public final void testGetTableTypeEnum() { TableType tt = columnTable1.getTableTypeEnum(); Assert.assertTrue("type", tt == TableType.COLUMN_BASED); tt = contentTable1.getTableTypeEnum(); Assert.assertTrue("type", tt == TableType.CONTENT_BASED); tt = rowTable1.getTableTypeEnum(); Assert.assertTrue("type", tt == TableType.ROW_BASED); } /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { /* * 3 5 7Sue Fred Sandy *
*/ URL columnUrl1 = null; URL contentUrl1 = null; URL rowUrl1 = null; try { columnUrl1 = Util.getResource(COLUMN_TABLE1_XML); contentUrl1 = Util.getResource(CONTENT_TABLE1_XML); rowUrl1 = Util.getResource(ROW_TABLE1_XML); } catch (Exception e) { // Saw this once, being cautious. ~~~~jd323 e.printStackTrace(); } Assert.assertNotNull(columnUrl1); Assert.assertNotNull(contentUrl1); Assert.assertNotNull(rowUrl1); try { CMLBuilder builder = new CMLBuilder(); columnTable1 = (CMLTable) builder.build( new File(columnUrl1.toURI())).getRootElement(); contentTable1 = (CMLTable) builder.build( new File(contentUrl1.toURI())).getRootElement(); rowTable1 = (CMLTable) builder.build(new File(rowUrl1.toURI())) .getRootElement(); } catch (IOException e) { e.printStackTrace(); Assert.fail("Should not throw IOException"); } catch (ParsingException e) { e.printStackTrace(); logger.error("Parse exception " + e.getMessage()); Assert.fail("Should not throw ParsingException" + e.getCause()); } tableContent = (CMLTableContent)CMLXOMTestUtils.parseValidString(tableContentS); tableHeader = (CMLTableHeader)CMLXOMTestUtils.parseValidString(tableHeaderS); tableRowList = (CMLTableRowList)CMLXOMTestUtils.parseValidString(tableRowListS); tableRow = tableRowList.getTableRowElements().get(1); arrayList = (CMLArrayList)CMLXOMTestUtils.parseValidString(arrayListS); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLTorsionTest.java000077500000000000000000000143031477224461000276440ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.euclid.EuclidConstants.EPS; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLAtomSet; import org.xmlcml.cml.element.CMLBond; import org.xmlcml.cml.element.CMLCml; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.CMLTorsion; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.test.StringTestBase; /** * tests torsion. * * @author pm286 * */ public class CMLTorsionTest { String s1 = "" + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "" + ""; CMLTorsion torsion0; CMLTorsion torsion1; CMLTorsion torsion2; CMLMolecule molecule1; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { CMLCml cml = (CMLCml)CMLXOMTestUtils.parseValidString(s1); molecule1 = (CMLMolecule) cml.getChildCMLElements("molecule").get(0); torsion0 = (CMLTorsion) cml.getChildCMLElements("torsion").get(0); torsion1 = (CMLTorsion) cml.getChildCMLElements("torsion").get(1); torsion2 = (CMLTorsion) cml.getChildCMLElements("torsion").get(2); } /** * Test method for 'org.xmlcml.cml.element.CMLTorsion.copy()' */ @Test public void testCopy() { CMLTorsion torsion00 = (CMLTorsion) torsion0.copy(); StringTestBase.assertEquals("atomRefs4", new String[] { "a1", "a2", "a3", "a4" }, torsion00.getAtomRefs4()); } /** * test getIdList. */ @Test public void testGetIdList() { List idList = torsion0.getAtomIds(); Assert.assertNotNull("atom ids should not be null", idList); Assert.assertEquals("atom ids", 4, idList.size()); Assert.assertEquals("atom id 0", "a1", idList.get(0)); Assert.assertEquals("atom id 1", "a2", idList.get(1)); Assert.assertEquals("atom id 2", "a3", idList.get(2)); Assert.assertEquals("atom id 3", "a4", idList.get(3)); torsion0.removeAttribute("atomRefs4"); idList = torsion0.getAtomIds(); Assert.assertNull("atom ids should be null", idList); } /** * Test method for 'org.xmlcml.cml.element.CMLTorsion.getAtoms(CMLMolecule)' */ @Test public void testGetAtoms() { List atomRefs4 = null; try { atomRefs4 = torsion0.getAtoms(molecule1); } catch (RuntimeException e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertNotNull("atomRefs4 not null", atomRefs4); String msg = RuntimeException.class.getName() + ": cannot find atom a6"; try { atomRefs4 = torsion2.getAtoms(molecule1); Assert.fail("should always throw " + msg); } catch (RuntimeException e) { Assert.assertEquals("non existent atom ", msg, "" + e); } } /** * Test method for 'org.xmlcml.cml.element.CMLTorsion.getAtoms(CMLAtomSet)' */ @Test public void testGetAtomsFromAtomSet() { CMLAtomSet atomSet = new CMLAtomSet(molecule1); List atomRefs4 = null; try { atomRefs4 = torsion0.getAtoms(atomSet); } catch (RuntimeException e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertNotNull("atomRefs4 not null", atomRefs4); String msg = RuntimeException.class.getName() + ": cannot find atom a6"; try { atomRefs4 = torsion2.getAtoms(molecule1); Assert.fail("should always throw " + msg); } catch (RuntimeException e) { Assert.assertEquals("non existent atom ", msg, "" + e); } } /** * Test method for * 'org.xmlcml.cml.element.CMLTorsion.getCalculatedTorsion(CMLMolecule)' */ @Test public void testGetCalculatedTorsion() { double t = torsion0.getCalculatedTorsion(molecule1); Assert.assertEquals("calculated torsion", t, 90., EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLTorsion.atomHash(String, * String, String, String)' */ @Test public void testAtomHash() { String atomHash = CMLTorsion.atomHash("a1", "a2", "a3", "a4"); Assert .assertEquals("atomHash", "a4" + CMLBond.HASH_SYMB + "a3" + CMLBond.HASH_SYMB + "a2" + CMLBond.HASH_SYMB + "a1", atomHash); } /** * Test method for * 'org.xmlcml.cml.element.CMLTorsion.getIndexedTorsions(CMLTorsion[])' */ @Test public void testGetIndexedTorsions() { List torsions = new ArrayList(); torsions.add(torsion0); Map map = CMLTorsion.getIndexedTorsions(torsions); Assert.assertNotNull("indexed", map); Assert.assertEquals("indexed", 1, map.size()); Assert.assertEquals("indexed", torsion0, map.get("a4" + CMLBond.HASH_SYMB + "a3" + CMLBond.HASH_SYMB + "a2" + CMLBond.HASH_SYMB + "a1")); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLTransform3Test.java000077500000000000000000001037701477224461000302540ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.euclid.EuclidConstants.EPS; import static org.xmlcml.euclid.EuclidConstants.S_RBRAK; import java.io.IOException; import java.io.StringReader; import java.util.ArrayList; import java.util.List; import nu.xom.ParsingException; import nu.xom.ValidityException; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.element.CMLLine3; import org.xmlcml.cml.element.CMLMatrix; import org.xmlcml.cml.element.CMLPlane3; import org.xmlcml.cml.element.CMLPoint3; import org.xmlcml.cml.element.CMLTransform3; import org.xmlcml.cml.element.CMLVector3; import org.xmlcml.euclid.EC; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.Point3; import org.xmlcml.euclid.Transform3; import org.xmlcml.euclid.Transform3.Type; import org.xmlcml.euclid.test.DoubleTestBase; /** * test CMLTransform3. * * @author pmr * */ public class CMLTransform3Test extends GeomTestBase { /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLTransform3 test, CMLTransform3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + S_RBRAK, expected); Transform3 test1 = test.getEuclidTransform3(); Transform3 expected1 = expected .getEuclidTransform3(); Assert.assertNotNull("test should not be null (" + msg + EC.S_RBRAK, test1); Assert.assertNotNull("expected should not be null (" + msg + EC.S_RBRAK, expected1); DoubleTestBase.assertEquals(msg, test1.getMatrixAsArray(), expected1 .getMatrixAsArray(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 3 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, CMLTransform3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + S_RBRAK, test); Assert.assertEquals("must be of length 16", 16, test.length); Assert.assertNotNull("expected should not be null (" + msg + S_RBRAK, expected); Assert.assertTrue(msg, true); Transform3 expected1 = expected.getEuclidTransform3(); Assert.assertNotNull("test should not be null (" + msg + EC.S_RBRAK, test); Assert.assertEquals("test should have 16 elements (" + msg + EC.S_RBRAK, 16, test.length); Assert.assertNotNull("ref should not be null (" + msg + EC.S_RBRAK, expected1); DoubleTestBase.assertEquals(msg, test, expected1.getMatrixAsArray(), epsilon); } private CMLBuilder builder = new CMLBuilder(); CMLPoint3 xomP; CMLPlane3 xomPl; CMLLine3 xomL; CMLVector3 xomV; CMLPoint3 xomP111; CMLPoint3 xomP100; CMLPoint3 xomP010; CMLPoint3 xomP001; CMLPoint3 xomP123; CMLPlane3 xomPl0100; CMLPlane3 xomPl1002; CMLPlane3 xomPl1115; CMLPlane3 xomPl1005; CMLLine3 xomL555111; CMLVector3 xomV000; CMLVector3 xomV100; CMLVector3 xomV010; CMLVector3 xomV001; CMLVector3 xomV111; CMLVector3 xomV123; CMLVector3 xomV321; CMLLine3 xomL220011; CMLTransform3 xomT1; String xmlP111S; String xmlP100S; String xmlP010S; String xmlP001S; String xmlP123S; CMLPoint3 xmlP111; CMLPoint3 xmlP100; CMLPoint3 xmlP010; CMLPoint3 xmlP001; CMLPoint3 xmlP123; /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.CMLTransform3(CMLTransform3)' */ @Test public void testCMLTransform3CMLTransform3() { double[] d = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; CMLTransform3 t = new CMLTransform3(d); CMLTransform3 tt = new CMLTransform3(t); CMLTransform3Test.assertEquals("copy", d, tt, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLTransform3 parse' */ @Test public void testParse() { CMLTransform3 t = null; String s = "1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1"; try { t = (CMLTransform3) builder.build(new StringReader(s)) .getRootElement(); CMLTransform3Test .assertEquals("unit", CMLTransform3.UNIT44, t, EPS); } catch (ValidityException e) { Assert .fail("should not throw validity exception " + e.getMessage()); } catch (ParsingException e) { Assert.fail("should not throw parsing exception " + e.getMessage()); } catch (IOException e) { Assert.fail("should not throw IO exception " + e.getMessage()); } s = "1 0 0 0 0 1 0 0 0 0 1 0 0 0 1"; try { t = (CMLTransform3) builder.build(new StringReader(s)) .getRootElement(); Assert.fail("should not throw parsing exception"); } catch (ValidityException e) { Assert.fail("should not throw validity " + e.getMessage()); } catch (ParsingException e) { Assert.assertEquals("should throw parsing exception", "line must have 16 double components", e.getMessage()); } catch (IOException e) { Assert.fail("should not throw IO " + e.getMessage()); } s = "1 0 X 0 0 0 1 0 0 0 0 1 0 0 0 1"; try { t = (CMLTransform3) builder.build(new StringReader(s)) .getRootElement(); Assert.fail("should not throw parsing exception"); } catch (ValidityException e) { Assert.fail("should not throw validity " + e.getMessage()); } catch (ParsingException e) { Assert.assertTrue(true); } catch (IOException e) { Assert.fail("should not throw IO " + e.getMessage()); } } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.CMLTransform3(double[])' */ @Test public void testCMLTransform3DoubleArray() { double[] d = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; CMLTransform3 t = new CMLTransform3(d); CMLTransform3Test.assertEquals("copy", d, t, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLTransform3.CMLTransform3(int)' */ @Test public void testCMLTransform3Int() { /* * -- NULL(1, "none"), ROT_ORIG(2, "rotation about origin"), * ROT_TRANS(3, "rotation translation"), ROT_TRANS_SCALE(4, * "rotation translation scale"), ROT_TRANS_AXIAL_SCALE(5, * "rotation translation axial scale"), ROT_TRANS_SCALE_PERSP(6, * "perspective"), ANY(7, "any"); -- */ // this is probablyy not required CMLTransform3 t = new CMLTransform3(Type.NULL); CMLTransform3Test.assertEquals("type", CMLTransform3.UNIT44, t, EPS); t = new CMLTransform3(Type.ROT_ORIG); CMLTransform3Test.assertEquals("type", CMLTransform3.UNIT44, t, EPS); t = new CMLTransform3(Type.ROT_TRANS); CMLTransform3Test.assertEquals("type", CMLTransform3.UNIT44, t, EPS); t = new CMLTransform3(Type.ROT_TRANS_SCALE); CMLTransform3Test.assertEquals("type", CMLTransform3.UNIT44, t, EPS); t = new CMLTransform3(Type.ROT_TRANS_AXIAL_SCALE); CMLTransform3Test.assertEquals("type", CMLTransform3.UNIT44, t, EPS); t = new CMLTransform3(Type.ROT_TRANS_SCALE_PERSP); CMLTransform3Test.assertEquals("type", CMLTransform3.UNIT44, t, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.CMLTransform3(CMLVector3)' */ @Test public void testCMLTransform3CMLVector3() { // Vector is translation CMLVector3 v = new CMLVector3(new double[] { 5, 6, 7 }); CMLTransform3 t = new CMLTransform3(v); CMLTransform3Test.assertEquals("type", new double[] { 1, 0, 0, 5, 0, 1, 0, 6, 0, 0, 1, 7, 0, 0, 0, 1 }, t, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLTransform3.CMLTransform3(int, * double)' */ @Test public void testCMLTransform3IntDouble() { // rottaion about axes CMLTransform3 t = new CMLTransform3(1, Math.PI); CMLTransform3Test.assertEquals("type", new double[] { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 }, t, EPS); t = new CMLTransform3(1, Math.PI / 2); CMLTransform3Test.assertEquals("type", new double[] { 1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1 }, t, EPS); t = new CMLTransform3(2, Math.PI); CMLTransform3Test.assertEquals("type", new double[] { -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 }, t, EPS); t = new CMLTransform3(2, Math.PI / 2); CMLTransform3Test.assertEquals("type", new double[] { 0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1 }, t, EPS); t = new CMLTransform3(3, Math.PI); CMLTransform3Test.assertEquals("type", new double[] { -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }, t, EPS); t = new CMLTransform3(3, Math.PI / 2); CMLTransform3Test.assertEquals("type", new double[] { 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }, t, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.CMLTransform3(double, double, * double)' */ @Test public void testCMLTransform3DoubleDoubleDouble() { // rotation about axes CMLTransform3 t = new CMLTransform3(Math.PI, 0, 0); CMLTransform3Test.assertEquals("type", new double[] { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 }, t, EPS); // rotation about axes t = new CMLTransform3(Math.PI / 2, Math.PI / 2, 0); CMLTransform3Test.assertEquals("type", new double[] { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1 }, t, EPS); t = new CMLTransform3(0., 0., 0.); CMLTransform3Test.assertEquals("type", new double[] { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }, t, 10 * EPS); t = new CMLTransform3(0., 0., 0.); CMLTransform3Test.assertEquals("type", new double[] { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }, t, EPS); t = new CMLTransform3(Math.PI * 2, Math.PI * 2, Math.PI * 2); CMLTransform3Test.assertEquals("type", new double[] { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }, t, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.CMLTransform3(CMLTransform3, * CMLPoint3)' */ @Test public void testCMLTransform3CMLTransform3CMLPoint3() { CMLTransform3 t = new CMLTransform3("x, -y, -z"); CMLPoint3 p = new CMLPoint3(1., 2., 3); CMLTransform3 tt = new CMLTransform3(t, p); CMLTransform3Test.assertEquals("transform", new double[] { 1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 4.0, 0.0, 0.0, -1.0, 6.0, 0.0, 0.0, 0.0, 1.0 }, tt, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.CMLTransform3(CMLVector3, double)' */ @Test public void testCMLTransform3CMLVector3Double() { double c = Math.cos(Math.PI / 3); double s = Math.sin(Math.PI / 3); // rotation about vector and angle CMLVector3 v = new CMLVector3(new double[] { 1., 1., 1. }); CMLTransform3 t = new CMLTransform3(v, Math.PI * 2. / 3.); CMLTransform3Test.assertEquals("type", new double[] { 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }, t, EPS); v = new CMLVector3(new double[] { 1., 1., 1. }); t = new CMLTransform3(v, -Math.PI * 2. / 3.); CMLTransform3Test.assertEquals("type", new double[] { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1 }, t, EPS); v = new CMLVector3(new double[] { 1., 0., 0. }); t = new CMLTransform3(v, Math.PI / 3.); CMLTransform3Test.assertEquals("type", new double[] { 1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1 }, t, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.CMLTransform3(CMLLine3, double)' */ @Test public void testCMLTransform3CMLLine3Double() { CMLLine3 l = new CMLLine3(new CMLPoint3(4., 5., 6.), new CMLVector3(1., 2., 3.)); CMLTransform3 t = new CMLTransform3(l, Math.PI / 3.); CMLTransform3Test.assertEquals("transform", new double[] { 0.5357142857142858, -0.6229365034008422, 0.5700529070291328, 1.5515079319722704, 0.765793646257985, 0.642857142857143, -0.01716931065742361, -1.174444435373113, -0.3557671927434186, 0.4457407392288521, 0.8214285714285715, 0.2657936462579853, 0.0, 0.0, 0.0, 1.0 }, t, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.CMLTransform3(CMLVector3, * CMLVector3)' */ @Test public void testCMLTransform3CMLVector3CMLVector3() { // rotate one vector onto another CMLTransform3 t = new CMLTransform3(new CMLVector3(1., 0., 0.), new CMLVector3(0., 1., 0.)); CMLTransform3Test.assertEquals("transform", new double[] { 0., -1.0, 0., 0., 1.0, 0.0, 0.0, 0., 0., 0., 1., 0., 0., 0., 0., 1.0 }, t, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.CMLTransform3(CMLVector3, * CMLVector3, CMLVector3)' */ @Test public void testCMLTransform3CMLVector3CMLVector3CMLVector3() { CMLVector3 v1, v2, v3; CMLTransform3 t; v1 = new CMLVector3(new double[] { 1., 2., 3. }); v2 = new CMLVector3(new double[] { 4., 5., 6. }); v3 = new CMLVector3(new double[] { 7., 8., 9. }); t = new CMLTransform3(v1, v2, v3); CMLTransform3Test.assertEquals("type", new double[] { 1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9, 0, 0, 0, 0, 1 }, t, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.CMLTransform3(String)' */ @Test public void testCMLTransform3String() { CMLTransform3 t = null; String s; s = "x, y, z"; try { t = new CMLTransform3(s); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } CMLTransform3Test.assertEquals("type", new double[] { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }, t, EPS); s = "x, -y, -z"; try { t = new CMLTransform3(s); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } CMLTransform3Test.assertEquals("type", new double[] { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 }, t, EPS); s = "1/2+x, 1/2-y, 1/4-z"; try { t = new CMLTransform3(s); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } CMLTransform3Test.assertEquals("type", new double[] { 1, 0, 0, 0.5, 0, -1, 0, 0.5, 0, 0, -1, 0.25, 0, 0, 0, 1 }, t, EPS); s = "x+y, x-y, -z"; try { t = new CMLTransform3(s); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } CMLTransform3Test.assertEquals("type", new double[] { 1, 1, 0, 0, 1, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 }, t, EPS); s = "y, -x, 7/12-z"; try { t = new CMLTransform3(s); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } CMLTransform3Test.assertEquals("type", new double[] { 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, -1, 7. / 12., 0, 0, 0, 1 }, t, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.equals(CMLTransform3)' */ @Test public void testEqualsCMLTransform3() { double[] d = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; CMLTransform3 t = new CMLTransform3(d); CMLTransform3Test.assertEquals("equals", d, t, EPS); CMLTransform3 t1 = new CMLTransform3(d); CMLTransform3Test.assertEquals("equals", t, t1, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.concatenate(CMLTransform3)' */ @Test public void testConcatenate() { CMLTransform3 /* t, */t1, t2, t12; // rotation about axes t1 = new CMLTransform3(Math.PI / 2, 0, 0); CMLTransform3Test.assertEquals("type", new double[] { 1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1 }, t1, EPS); t2 = new CMLTransform3(0, Math.PI / 2, 0); CMLTransform3Test.assertEquals("type", new double[] { 0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1 }, t2, EPS); t12 = t1.concatenate(t2); CMLTransform3Test.assertEquals("type", new double[] { 0, 0, -1, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1 }, t12, EPS); t12 = t2.concatenate(t1); CMLTransform3Test.assertEquals("type", new double[] { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1 }, t12, EPS); // test translation components t1 = new CMLTransform3(new double[] { 1, 0, 0, 1, 0, 1, 0, 2, 0, 0, 1, 3, 0, 0, 0, 1 }); CMLTransform3Test.assertEquals("translate", new double[] { 1, 0, 0, 1, 0, 1, 0, 2, 0, 0, 1, 3, 0, 0, 0, 1 }, t1, EPS); t2 = new CMLTransform3(new double[] { 1, 0, 0, 4, 0, 1, 0, 5, 0, 0, 1, 6, 0, 0, 0, 1 }); CMLTransform3Test.assertEquals("translate", new double[] { 1, 0, 0, 4, 0, 1, 0, 5, 0, 0, 1, 6, 0, 0, 0, 1 }, t2, EPS); t12 = t1.concatenate(t2); CMLTransform3Test.assertEquals("type", new double[] { 1, 0, 0, 5, 0, 1, 0, 7, 0, 0, 1, 9, 0, 0, 0, 1 }, t12, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLTransform3.getAxisAndAngle()' */ @Test public void testGetAxisAndAngle() { // rotation about vector and angle CMLVector3 v = new CMLVector3(new double[] { 1., 1., 1. }); CMLTransform3 t = new CMLTransform3(v, Math.PI * 2. / 3.); CMLTransform3Test.assertEquals("type", new double[] { 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }, t, EPS); double[] aa = t.getAxisAndAngle(); double x = Math.sqrt(1. / 3.); DoubleTestBase.assertEquals("axis and angle", new double[] { x, x, x, Math.PI * 2. / 3. }, aa, EPS); v = new CMLVector3(new double[] { 1., 2., 3. }); t = new CMLTransform3(v, 1.234); aa = t.getAxisAndAngle(); double xx = 1. / Math.sqrt(14.); DoubleTestBase.assertEquals("axis and angle", new double[] { xx, 2 * xx, 3 * xx, 1.234 }, aa, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLTransform3.getTranslation()' */ @Test public void testGetTranslation() { double[] d = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0, 0, 0, 1 }; CMLTransform3 t = new CMLTransform3(d); CMLVector3 tr = t.getTranslation(); CMLVector3Test.assertEquals("equals", new double[] { 4, 8, 12 }, tr, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.getCentreOfRotation()' */ @Test public void testGetCentreOfRotation() { String s; CMLTransform3 t = null; s = "-x+1/2, -y+1/2, z"; t = new CMLTransform3(s); CMLTransform3Test.assertEquals("type", new double[] { -1, 0, 0, 0.5, 0, -1, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1 }, t, EPS); CMLPoint3 p = t.getCentreOfRotation(); // values not checked CMLPoint3Test.assertEquals("centre", new double[] { 0.5, 0.5, 0.0 }, p, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLTransform3.getScales()' */ @Test public void testGetScales() { double[] d = new double[] { 10, 0, 0, 4, 0, 20, 0, 8, 0, 0, 30, 12, 0, 0, 0, 1 }; CMLTransform3 t = new CMLTransform3(d); double[] sc = t.getScales(); DoubleTestBase.assertEquals("equals", new double[] { 10, 20, 30 }, sc, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLTransform3.getMatrix()' */ @Test public void testGetMatrix() { double[] d = new double[] { 10, 0, 0, 4, 0, 20, 0, 8, 0, 0, 30, 12, 0, 0, 0, 1 }; CMLTransform3 t = new CMLTransform3(d); CMLMatrix matrix = t.getMatrix(); Assert.assertEquals("matrix", 3, matrix.getRows()); Assert.assertEquals("matrix", 4, matrix.getColumns()); CMLMatrixTest.assertEquals("matrix", 3, 4, new double[] { 10, 0, 0, 4, 0, 20, 0, 8, 0, 0, 30, 12 }, matrix, EPS); } /** * tests CMLTransform3.normalizeCrystallographically() * */ @Test public void testNormalizeCrystallographically() { CMLTransform3 t = new CMLTransform3(new double[] { 1, 0, 0, 0.0, 0, 1, 0, -0.25, 1, 0, 1, 1.0, 0, 0, 0, 1, }); t.normalizeCrystallographically(); CMLTransform3Test.assertEquals("normalize crystallographically", new double[] { 1, 0, 0, 0.0, 0, 1, 0, 0.75, 1, 0, 1, 0.0, 0, 0, 0, 1, }, t, EPS); } /** * tests CMLTransform3.indexOf(List trList, CMLTransform3 tr, * double eps) * */ @Test public void testIndexOfListCMLTransform3CMLTransform3double() { List trList = new ArrayList(); CMLTransform3 tr1 = new CMLTransform3(new double[] { 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, -1, 0, 0, 0, 1 }); trList.add(tr1); CMLTransform3 tr2 = new CMLTransform3(new double[] { 0, 0, 1, 0, 0, 1, 0, -1, 1, 0, 0, 1, 0, 0, 0, 1 }); trList.add(tr2); CMLTransform3 tr3 = new CMLTransform3(new double[] { 0, 1, 1, 0.5, 1, 0, 0, -1, 0, 0, 1, 1, 0, 0, 0, 1 }); int idx = CMLTransform3.indexOf(trList, tr1, EPS); Assert.assertEquals("indexOf", 0, idx); idx = CMLTransform3.indexOf(trList, tr2, EPS); Assert.assertEquals("indexOf", 1, idx); idx = CMLTransform3.indexOf(trList, tr3, EPS); Assert.assertEquals("indexOf", -1, idx); trList.add(tr3); idx = CMLTransform3.indexOf(trList, tr3, EPS); Assert.assertEquals("indexOf", 2, idx); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.getEuclidTransform3()' */ @Test public void testGetEuclidTransform3() { CMLTransform3 t = null; try { t = new CMLTransform3("x, -y, 1/2+z"); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Transform3 tt = t.getEuclidTransform3(); double[] test = new double[] { 1., 0., 0., 0., 0., -1., 0., 0., 0., 0., 1., 0.5, 0., 0., 0., 1., }; Assert.assertNotNull("test should not be null (" + "get euclid" + EC.S_RBRAK, test); Assert.assertEquals("test should have 16 elements (" + "get euclid" + EC.S_RBRAK, 16, test.length); Assert.assertNotNull("ref should not be null (" + "get euclid" + EC.S_RBRAK, tt); DoubleTestBase.assertEquals("get euclid", test, tt.getMatrixAsArray(), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.setMatrix(double[])' */ @Test public void testSetMatrix() { CMLTransform3 t = null; try { t = new CMLTransform3(CMLTransform3.UNIT44); t.setMatrix(new double[] { 1., 0., 0., 0., 0., -1., 0., 0., 0., 0., 1., 0.5, 0., 0., 0., 1., }); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Transform3 tt = t.getEuclidTransform3(); double[] test = new double[] { 1., 0., 0., 0., 0., -1., 0., 0., 0., 0., 1., 0.5, 0., 0., 0., 1., }; Assert.assertNotNull("test should not be null (" + "get euclid" + EC.S_RBRAK, test); Assert.assertEquals("test should have 16 elements (" + "get euclid" + EC.S_RBRAK, 16, test.length); Assert.assertNotNull("ref should not be null (" + "get euclid" + EC.S_RBRAK, tt); DoubleTestBase.assertEquals("get euclid", test, tt.getMatrixAsArray(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLTransform3.getMatrixAsArray()' */ @Test public void testGetMatrixAsArray() { CMLTransform3 t = null; try { t = new CMLTransform3(CMLTransform3.UNIT44); t.setMatrix(new double[] { 1., 0., 0., 0., 0., -1., 0., 0., 0., 0., 1., 0.5, 0., 0., 0., 1., }); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } CMLTransform3Test .assertEquals("get euclid", new double[] { 1., 0., 0., 0., 0., -1., 0., 0., 0., 0., 1., 0.5, 0., 0., 0., 1., }, t, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.isEqualTo(CMLTransform3)' */ @Test public void testIsEqualToCMLTransform3() { CMLTransform3 t0 = null; CMLTransform3 t1 = null; try { t0 = new CMLTransform3(CMLTransform3.UNIT44); t1 = new CMLTransform3(CMLTransform3.UNIT44); t0.setMatrix(new double[] { 1., 0., 0., 0., 0., -1., 0., 0., 0., 0., 1., 0.5, 0., 0., 0., 1., }); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertFalse("equals", t0.isEqualTo(t1)); try { t1.setMatrix(new double[] { 1., 0., 0., 0., 0., -1., 0., 0., 0., 0., 1., 0.5, 0., 0., 0., 1., }); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertTrue("equals", t0.isEqualTo(t1)); try { t1.setMatrix(new double[] { 1., 0., 0., 0.0001, 0., -1., 0., 0., 0., 0., 1., 0.5, 0., 0., 0., 1., }); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertFalse("equals", t0.isEqualTo(t1)); Assert.assertTrue("equals", t0.isEqualTo(t1, 0.001)); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.hasNonZeroTranslationComponent()' */ @Test public void testHasNonZeroTranslationComponent() { CMLTransform3 t = null; try { t = new CMLTransform3("x, -y, 1/2+z"); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertTrue("non-zero translation", t .hasNonZeroTranslationComponent()); try { t = new CMLTransform3("x, 1/2-y, 1/2+z"); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertTrue("non-zero translation", t .hasNonZeroTranslationComponent()); try { t = new CMLTransform3("x, y, z"); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertFalse("non-zero translation", t .hasNonZeroTranslationComponent()); try { t = new CMLTransform3("x, -y, z"); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertFalse("non-zero translation", t .hasNonZeroTranslationComponent()); try { t = new CMLTransform3("x, -y, 1/2-z"); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertFalse("non-zero translation", t .hasNonZeroTranslationComponent()); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.isPureTranslation()' */ @Test public void testIsPureTranslation() { CMLTransform3 t = null; try { t = new CMLTransform3("1/2+x, y, z"); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertTrue("pure translation", t.isPureTranslation()); try { t = new CMLTransform3("1/2+x, 1/2+y, z"); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertTrue("pure translation", t.isPureTranslation()); try { t = new CMLTransform3("1/2+x, 1/2+y, 1/2+z"); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertTrue("pure translation", t.isPureTranslation()); try { t = new CMLTransform3("x, y, z"); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertFalse("pure translation", t.isPureTranslation()); try { t = new CMLTransform3("1/2+x, 1/2+y, 1/2-z"); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertFalse("pure translation", t.isPureTranslation()); } /** * Test method for 'org.xmlcml.cml.element.CMLTransform3.isUnit()' */ @Test public void testIsUnit() { CMLTransform3 t = null; try { t = new CMLTransform3("x, y, z"); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertTrue("is unit", t.isUnit()); try { t = new CMLTransform3("x, y, -z"); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertFalse("is unit", t.isUnit()); try { t = new CMLTransform3("1/2+x, y, z"); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Assert.assertFalse("is unit", t.isUnit()); } /** * Test method for 'org.xmlcml.cml.element.CMLTransform3.getRow(int)' */ @Test public void testGetRow() { CMLTransform3 t = null; try { t = new CMLTransform3("1/2+x-y, 1/4+y-z, -x"); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } double[] r = t.getRow(0); DoubleTestBase.assertEquals("row 0", new double[] { 1., -1., 0., 0.5 }, r, EPS); r = t.getRow(1); DoubleTestBase.assertEquals("row 1", new double[] { 0., 1., -1., 0.25 }, r, EPS); r = t.getRow(2); DoubleTestBase.assertEquals("row 2", new double[] { -1., 0., 0., 0. }, r, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.indexOf(List, * CMLTransform3, double)' */ @Test public void testIndexOfListOfCMLTransform3CMLTransform3Double() { List tList = new ArrayList(); try { tList.add(new CMLTransform3("1/2+x-y, 1/4+y-z, -x")); tList.add(new CMLTransform3("x, y, z")); tList.add(new CMLTransform3("x, -y, 1/2+z")); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } try { Assert.assertEquals("index ", 1, CMLTransform3.indexOf(tList, new CMLTransform3("x, y, z"), EPS)); Assert.assertEquals("index ", 0, CMLTransform3.indexOf(tList, new CMLTransform3("1/2+x-y, 1/4+y-z, -x"), EPS)); Assert.assertEquals("index ", -1, CMLTransform3.indexOf(tList, new CMLTransform3("1/2+x, 1/4+y-z, -x"), EPS)); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } } /** * Test method for 'org.xmlcml.cml.element.CMLTransform3.transform(Point3)' */ @Test public void testTransform() { CMLTransform3 t = null; try { t = new CMLTransform3("-x, 1/2+y, 1/4+z"); } catch (Exception e) { throw new EuclidRuntimeException("should never throw " + e); } Point3 p = t.transform(new Point3(0.1, 0.2, 0.3)); double[] test = new double[] { -0.1, 0.7, 0.55 }; Assert.assertNotNull("test should not be null (" + "transform" + S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("ref should not be null (" + "transform" + S_RBRAK, p); DoubleTestBase.assertEquals("transform", test, p.getArray(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLTransform3.copy()' */ @Test public void testCopy() { CMLTransform3 t = new CMLTransform3("x, y-x, 1/2+z"); CMLTransform3 tt = (CMLTransform3) t.copy(); Assert.assertNotNull("copy not null", tt); } /** * Test method for * 'org.xmlcml.cml.element.CMLTransform3.isEqualTo(CMLTransform3, double)' */ @Test public void testIsEqualToCMLTransform3Double() { CMLTransform3 t = new CMLTransform3("x, y-x, 1/2+z"); CMLTransform3 tt = (CMLTransform3) t.copy(); Assert.assertTrue("isEquals", t.isEqualTo(tt, EPS)); } /** * Test method for 'org.xmlcml.cml.element.CMLTransform3.getString()' */ @Test public void testGetString() { CMLTransform3 t = new CMLTransform3("x, y-x, 1/2+z"); String s = t.getString(); String ss = "{4,4}\n" + "(1.0,0.0,0.0,0.0)\n" + "(-1.0,1.0,0.0,0.0)\n" + "(0.0,0.0,1.0,0.5)\n" + "(0.0,0.0,0.0,1.0)"; Assert.assertEquals("string", ss, s); } /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { // create from XOM // xomP = new CMLPoint3(); // deliberately disallowed // xomPl = new CMLPlane3(); // deliberately disallowed // xomL = new CMLLine3(); // deliberately disallowed // xomV = new CMLVector3(); // deliberately disallowed xomP111 = new CMLPoint3(new double[] { 1., 1., 1. }); xomP100 = new CMLPoint3(new double[] { 1., 0., 0. }); xomP010 = new CMLPoint3(new double[] { 0., 1., 0. }); xomP001 = new CMLPoint3(new double[] { 0., 0., 1. }); xomP123 = new CMLPoint3(new double[] { 1., 2., 3. }); xomPl0100 = new CMLPlane3(new double[] { 0., 1., 0., 0. }); xomPl1002 = new CMLPlane3(new double[] { 1., 0., 0., 2. }); xomPl1005 = new CMLPlane3(new double[] { 1., 0., 0., 5. }); xomPl1115 = new CMLPlane3(new double[] { 1., 1., 1., 5. }); // xomL555111 = new CMLLine3(new double[]{5., 5., 5., 1., 1., 1.}); xomL220011 = new CMLLine3(new CMLPoint3(0., 1., 1.), new CMLVector3(2., 2., 0.)); xomV000 = new CMLVector3(new double[] { 0., 0., 0. }); xomV100 = new CMLVector3(new double[] { 1., 0., 0. }); xomV010 = new CMLVector3(new double[] { 0., 1., 0. }); xomV001 = new CMLVector3(new double[] { 0., 0., 1. }); xomV111 = new CMLVector3(new double[] { 1., 1., 1. }); xomV123 = new CMLVector3(new double[] { 1., 2., 3. }); xomV321 = new CMLVector3(new double[] { 3., 2., 1. }); // create from XML xmlP111S = "1. 1. 1."; xmlP100S = "1 0 0"; xmlP010S = "0 1.0E+00 0"; xmlP001S = "0 0 1"; xmlP123S = "1 2 3"; CMLBuilder builder = new CMLBuilder(); xmlP111 = (CMLPoint3) builder.build(new StringReader(xmlP111S)) .getRootElement(); xmlP123 = (CMLPoint3) builder.build(new StringReader(xmlP123S)) .getRootElement(); xmlP100 = (CMLPoint3) builder.build(new StringReader(xmlP100S)) .getRootElement(); xmlP010 = (CMLPoint3) builder.build(new StringReader(xmlP010S)) .getRootElement(); xmlP001 = (CMLPoint3) builder.build(new StringReader(xmlP001S)) .getRootElement(); } void makeXomT1() { xomT1 = new CMLTransform3(new double[] { 0., 1., 0., 0., 0., 0., 1., 0., -1., 0., 0., 0., 0., 0., 0., 1. }); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLVector3Test.java000077500000000000000000000511001477224461000275300ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.euclid.EuclidConstants.EPS; import java.io.StringReader; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.element.CMLLine3; import org.xmlcml.cml.element.CMLPlane3; import org.xmlcml.cml.element.CMLPoint3; import org.xmlcml.cml.element.CMLTransform3; import org.xmlcml.cml.element.CMLVector3; import org.xmlcml.euclid.Angle; import org.xmlcml.euclid.EuclidConstants; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.Vector3; import org.xmlcml.euclid.test.DoubleTestBase; /** * tests Vector3. * * @author pmr * */ public class CMLVector3Test extends GeomTestBase { CMLPoint3 xomP; CMLPlane3 xomPl; CMLLine3 xomL; CMLVector3 xomV; CMLPoint3 xomP111; CMLPoint3 xomP100; CMLPoint3 xomP010; CMLPoint3 xomP001; CMLPoint3 xomP123; CMLPlane3 xomPl0100; CMLPlane3 xomPl1002; CMLPlane3 xomPl1115; CMLPlane3 xomPl1005; CMLLine3 xomL555111; CMLVector3 xomV000; CMLVector3 xomV100; CMLVector3 xomV010; CMLVector3 xomV001; CMLVector3 xomV111; CMLVector3 xomV123; CMLVector3 xomV321; CMLLine3 xomL220011; CMLTransform3 xomT1; String xmlP111S; String xmlP100S; String xmlP010S; String xmlP001S; String xmlP123S; CMLPoint3 xmlP111; CMLPoint3 xmlP100; CMLPoint3 xmlP010; CMLPoint3 xmlP001; CMLPoint3 xmlP123; /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * @param expected * @param epsilon */ public static void assertEquals(String msg, CMLVector3 test, CMLVector3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); DoubleTestBase.assertEquals(msg, test.getXYZ3(), expected.getXYZ3(), epsilon); } /** * equality test. true if both args not null and equal within epsilon * * @param msg * message * @param test * array must be of length 3 * @param expected * @param epsilon */ public static void assertEquals(String msg, double[] test, CMLVector3 expected, double epsilon) { Assert.assertNotNull("test should not be null (" + msg + CMLConstants.S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("expected should not be null (" + msg + CMLConstants.S_RBRAK, expected); DoubleTestBase.assertEquals(msg, test, expected.getXYZ3(), epsilon); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.CMLVector3()' */ @Test public void testCMLVector3() { // new CMLVector3(); // deliberately not public } /** * Test method for * 'org.xmlcml.cml.element.CMLVector3.CMLVector3(CMLVector3)' */ @Test public void testCMLVector3CMLVector3() { CMLVector3 v = new CMLVector3(xomV123); CMLVector3Test .assertEquals("copy", new double[] { 1., 2., 3. }, v, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.CMLVector3(double[])' */ @Test public void testCMLVector3DoubleArray() { double[] dd = { 3., 2., 4. }; CMLVector3 v = new CMLVector3(dd); CMLVector3Test.assertEquals("copy", dd, v, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.CMLVector3(CMLPoint3)' */ @Test public void testCMLVector3CMLPoint3() { CMLVector3 v = new CMLVector3(xomP123); CMLVector3Test.assertEquals("from point", new double[] { 1., 2., 3. }, v, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.setXYZ3(double[])' */ @Test public void testSetXYZ3() { xomV100.setXYZ3(new double[] { 3., 2., 4. }); CMLVector3Test.assertEquals("set", new double[] { 3., 2., 4. }, xomV100, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.getXYZ3()' */ @Test public void testGetXYZ3() { CMLVector3Test.assertEquals("copy", new double[] { 1., 2., 3. }, xomV123, EPS); xomV123.setXYZ3(new double[] { 4., 5., 6. }); CMLVector3Test.assertEquals("copy", new double[] { 4., 5., 6. }, xomV123, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.equals(CMLVector3)' */ @Test public void testEqualsCMLVector3() { CMLVector3 v1 = new CMLVector3(new double[] { 4., 5., 6. }); CMLVector3 v2 = new CMLVector3(new double[] { 4., 5., 6. }); Assert.assertTrue("equals", v1.isEqualTo(v2)); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.getLength()' */ @Test public void testGetLength() { Assert.assertEquals("length", Math.sqrt(14.), xomV123.getLength(), EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLVector3.getCrossProduct(CMLVector3)' */ @Test public void testGetCrossProduct() { CMLVector3 x = xomV100.getCrossProduct(xomV010); CMLVector3Test.assertEquals("cross", new double[] { 0., 0., 1. }, x, EPS); Assert.assertTrue("cross", xomV001.isEqualTo(x)); CMLVector3Test.assertEquals("cross", new double[] { 1., 0., 0. }, xomV100, EPS); CMLVector3Test.assertEquals("cross", new double[] { 0., 1., 0. }, xomV010, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLVector3.longerThan(CMLVector3)' */ @Test public void testLongerThan() { Assert.assertEquals("longer", true, xomV123.longerThan(xomV100)); Assert.assertEquals("longer", true, !xomV100.longerThan(xomV100)); Assert.assertEquals("longer", true, !xomV100.longerThan(xomV123)); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.multiplyBy(double)' */ @Test public void testMultiplyBy() { CMLVector3 v = xomV123.multiplyBy(2.); CMLVector3Test.assertEquals("multiply", new double[] { 2., 4., 6. }, v, EPS); CMLVector3Test.assertEquals("multiply", new double[] { 1., 2., 3. }, xomV123, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.plus(CMLVector3)' */ @Test public void testPlus() { CMLVector3 v = xomV100.plus(xomV010); CMLVector3Test.assertEquals("subtract", new double[] { 1., 0., 0. }, xomV100, EPS); CMLVector3Test.assertEquals("subtract", new double[] { 1., 1., 0. }, v, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.subtract(CMLVector3)' */ @Test public void testSubtract() { CMLVector3 v = xomV100.subtract(xomV010); CMLVector3Test.assertEquals("subtract", new double[] { 1., 0., 0. }, xomV100, EPS); CMLVector3Test.assertEquals("subtract", new double[] { 1., -1., 0. }, v, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.elementAt(int)' */ @Test public void testElementAt() { double d = xomV123.elementAt(0); Assert.assertEquals("element", 1., d, EPS); d = xomV123.elementAt(1); Assert.assertEquals("element", 2., d, EPS); d = xomV123.elementAt(2); Assert.assertEquals("element", 3., d, EPS); try { xomV123.elementAt(-1); } catch (EuclidRuntimeException e) { Assert.assertEquals("set", "index (-1)out of range: 0/2", e .getMessage()); } try { xomV123.elementAt(3); } catch (EuclidRuntimeException e) { Assert.assertEquals("set", "index (3)out of range: 0/2", e .getMessage()); } } /** * Test method for 'org.xmlcml.cml.element.CMLVector3Test.setElementAt(int, * double)' */ @Test public void testSetElementAt() { CMLVector3Test.assertEquals("set", new double[] { 1., 2., 3. }, xomV123, EPS); xomV123.setElementAt(0, 11.); CMLVector3Test.assertEquals("set", new double[] { 11., 2., 3. }, xomV123, EPS); xomV123.setElementAt(1, 12.); CMLVector3Test.assertEquals("set", new double[] { 11., 12., 3. }, xomV123, EPS); xomV123.setElementAt(2, 13.); CMLVector3Test.assertEquals("set", new double[] { 11., 12., 13. }, xomV123, EPS); try { xomV123.setElementAt(-1, 20.); } catch (EuclidRuntimeException e) { Assert.assertEquals("set", "index (-1)out of range: 0/2", e .getMessage()); } try { xomV123.setElementAt(3, 20.); } catch (EuclidRuntimeException e) { Assert.assertEquals("set", "index (3)out of range: 0/2", e .getMessage()); } } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.isZero()' */ @Test public void testIsZero() { Assert.assertEquals("zero", true, !xomV123.isZero()); Assert.assertEquals("zero", true, xomV000.isZero()); } /** * Test method for * 'org.xmlcml.cml.element.CMLVector3.transform(CMLTransform3)' */ @Test public void testTransform() { CMLVector3 v = new CMLVector3(new double[] { 1., 2., 3. }); CMLTransform3 t = new CMLTransform3(new double[] { 0., 0., 1., 10., -1., 0., 0., 99., 0, 1, 0., -10., 0, 0, 0., 1. }); // note that the translation is not applied to the vector CMLVector3 vv = v.transform(t); CMLVector3Test.assertEquals("transformed vector", new double[] { 3., -1., 2., }, vv, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.normalize()' */ @Test public void testNormalize() { CMLVector3 v = xomV123.normalize(); double x = Math.sqrt(14.); CMLVector3Test.assertEquals("normalize", new double[] { 1. / x, 2. / x, 3. / x }, xomV123, EPS); CMLVector3Test.assertEquals("normalize", new double[] { 1. / x, 2. / x, 3. / x }, v, EPS); try { xomV000.normalize(); } catch (RuntimeException e) { Assert.assertEquals("normalize", "Cannot normalize zero vector", e .getMessage()); } } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.dot(CMLVector3)' */ @Test public void testDot() { double d = xomV123.dot(xomV321); Assert.assertEquals("dot", 10., d, EPS); CMLVector3Test.assertEquals("dot", new double[] { 1., 2., 3. }, xomV123, EPS); CMLVector3Test.assertEquals("dot", new double[] { 3., 2., 1. }, xomV321, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLVector3.getAngleMadeWith(CMLVector3)' */ @Test public void testGetAngleMadeWith() { Angle a = null; a = xomV100.getAngleMadeWith(xomV010); Assert.assertNotNull("angle", a); Assert.assertEquals("angle", Math.PI / 2., a.getRadian(), EPS); CMLVector3Test.assertEquals("angle", new double[] { 1., 0., 0. }, xomV100, EPS); CMLVector3Test.assertEquals("angle", new double[] { 0., 1., 0. }, xomV010, EPS); a = xomV100.getAngleMadeWith(xomV100); Assert.assertNotNull("angle", a); Assert.assertEquals("angle", 0., a.getRadian(), EPS); CMLVector3Test.assertEquals("angle", new double[] { 1., 0., 0. }, xomV100, EPS); CMLVector3Test.assertEquals("angle", new double[] { 0., 1., 0. }, xomV010, EPS); a = xomV321.getAngleMadeWith(xomV123); Assert.assertNotNull("angle", a); double aa = 2 * Math.asin(Math.sqrt(2.) / Math.sqrt(14.)); Assert.assertEquals("angle", aa, a.getRadian(), EPS); CMLVector3Test.assertEquals("angle", new double[] { 1., 2., 3. }, xomV123, EPS); CMLVector3Test.assertEquals("angle", new double[] { 3., 2., 1. }, xomV321, EPS); a = xomV100.getAngleMadeWith(xomV000); Assert.assertNull("angle zero vector", a); } /** * Test method for * 'org.xmlcml.cml.element.CMLVector3.getScalarTripleProduct(CMLVector3, * CMLVector3)' */ @Test public void testGetScalarTripleProduct() { double a = Double.NaN; a = xomV100.getScalarTripleProduct(xomV010, xomV001); Assert.assertEquals("stp", 1, a, EPS); CMLVector3Test.assertEquals("stp", new double[] { 1., 0., 0. }, xomV100, EPS); CMLVector3Test.assertEquals("stp", new double[] { 0., 1., 0. }, xomV010, EPS); a = xomV100.getScalarTripleProduct(xomV010, xomV000); Assert.assertEquals("stp", 0, a, EPS); CMLVector3Test.assertEquals("stp", new double[] { 1., 0., 0. }, xomV100, EPS); CMLVector3Test.assertEquals("stp", new double[] { 0., 1., 0. }, xomV010, EPS); a = xomV100.getScalarTripleProduct(xomV321, xomV123); Assert.assertEquals("stp", 4, a, EPS); CMLVector3Test.assertEquals("stp", new double[] { 1., 2., 3. }, xomV123, EPS); CMLVector3Test.assertEquals("stp", new double[] { 3., 2., 1. }, xomV321, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLVector3.projectOnto(CMLVector3)' */ @Test public void testProjectOnto() { CMLVector3 v = xomV123.projectOnto(xomV100); CMLVector3Test.assertEquals("project", new double[] { 1., 0., 0. }, v, EPS); CMLVector3Test.assertEquals("project", new double[] { 1., 2., 3. }, xomV123, EPS); v = xomV123.projectOnto(xomV010); CMLVector3Test.assertEquals("project", new double[] { 0., 2., 0. }, v, EPS); CMLVector3Test.assertEquals("project", new double[] { 1., 2., 3. }, xomV123, EPS); v = xomV123.projectOnto(xomV001); CMLVector3Test.assertEquals("project", new double[] { 0., 0., 3. }, v, EPS); CMLVector3Test.assertEquals("project", new double[] { 1., 2., 3. }, xomV123, EPS); v = xomV123.projectOnto(xomV000); Assert.assertNull("project", v); CMLVector3Test.assertEquals("project", new double[] { 1., 2., 3. }, xomV123, EPS); v = xomV000.projectOnto(xomV123); Assert.assertNull("project", v); CMLVector3Test.assertEquals("project", new double[] { 1., 2., 3. }, xomV123, EPS); } /** * Test method for * 'org.xmlcml.cml.element.CMLVector3.isColinearVector(CMLVector3)' */ @Test public void testIsColinearVector() { Assert.assertFalse("colinear", xomV123.isColinearVector(xomV100)); Assert.assertTrue("colinear", xomV100.isColinearVector(xomV100)); CMLVector3 xomV200 = new CMLVector3(new double[] { 2., 0., 0. }); Assert.assertTrue("colinear", xomV100.isColinearVector(xomV200)); } /** * Test method for * 'org.xmlcml.cml.element.CMLVector3.getNonColinearVector()' */ @Test public void testGetNonColinearVector() { CMLVector3 v = xomV100.getNonColinearVector(); Assert.assertFalse("noncolinear", v.isColinearVector(xomV100)); CMLVector3Test.assertEquals("noncolinear", new double[] { 1., 0., 0. }, xomV100, EPS); v = xomV123.getNonColinearVector(); Assert.assertFalse("noncolinear", v.isColinearVector(xomV123)); CMLVector3Test.assertEquals("noncolinear", new double[] { 1., 2., 3. }, xomV123, EPS); v = xomV000.getNonColinearVector(); Assert.assertFalse("noncolinear", v.isZero()); Assert.assertTrue("noncolinear", xomV000.isZero()); } /** * Test method for * 'org.xmlcml.cml.element.CMLVector3.getPerpendicularVector()' */ @Test public void testGetPerpendicularVector() { CMLVector3 v = xomV100.getPerpendicularVector(); Assert.assertEquals("perpendicular", true, !v.isZero()); Angle a = v.getAngleMadeWith(xomV100); Assert.assertNotNull("angle ", a); Assert.assertEquals("perpendicular", Math.PI / 2., a.getRadian(), EPS); v = xomV123.getPerpendicularVector(); Assert.assertEquals("perpendicular", true, !v.isZero()); a = v.getAngleMadeWith(xomV123); Assert.assertNotNull("angle ", a); Assert.assertEquals("perpendicular", Math.PI / 2., a.getRadian(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.copy()' */ @Test public void testCopy() { CMLVector3 v = new CMLVector3(1., 2., 3.); CMLVector3 vv = (CMLVector3) v.copy(); CMLVector3Test.assertEquals("copy ", new double[] { 1., 2., 3. }, vv, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.CMLVector3(Vector3)' */ @Test public void testCMLVector3Vector3() { CMLVector3 v = new CMLVector3(new Vector3(1., 2., 3.)); CMLVector3Test.assertEquals("constructor ", new double[] { 1., 2., 3. }, v, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.CMLVector3(double, * double, double)' */ @Test public void testCMLVector3DoubleDoubleDouble() { CMLVector3 v = new CMLVector3(1., 2., 3.); CMLVector3Test.assertEquals("constructor ", new double[] { 1., 2., 3. }, v, EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.getEuclidVector3()' */ @Test public void testGetEuclidVector3() { CMLVector3 v = new CMLVector3(1., 2., 3.); double[] test = new double[] { 1., 2., 3. }; Vector3 expected = v.getEuclidVector3(); Assert.assertNotNull("test should not be null (" + "euclidVector " + EuclidConstants.S_RBRAK, test); Assert.assertEquals("must be of length 3", 3, test.length); Assert.assertNotNull("expected should not be null (" + "euclidVector " + EuclidConstants.S_RBRAK, expected); DoubleTestBase.assertEquals("euclidVector ", test, expected.getArray(), EPS); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.isEqualTo(CMLVector3)' */ @Test public void testIsEqualToCMLVector3() { CMLVector3 v = new CMLVector3(1., 2., 3.); CMLVector3 vv = new CMLVector3(1., 2., 3.); Assert.assertTrue("isEqual ", v.isEqualTo(vv)); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.isEqualTo(CMLVector3, * double)' */ @Test public void testIsEqualToCMLVector3Double() { CMLVector3 v = new CMLVector3(1., 2., 3.); CMLVector3 vv = new CMLVector3(1., 2., 3.); Assert.assertTrue("isEqual ", v.isEqualTo(vv, EPS)); } /** * Test method for 'org.xmlcml.cml.element.CMLVector3.getString()' */ @Test public void testGetString() { CMLVector3 v = new CMLVector3(1., 2., 3.); String s = v.getString(); Assert.assertEquals("getString", "(1.0,2.0,3.0)", s); } /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { // create from XOM // xomP = new CMLPoint3(); // deliberately disallowed // xomPl = new CMLPlane3(); // deliberately disallowed // xomL = new CMLLine3(); // deliberately disallowed // xomV = new CMLVector3(); // deliberately disallowed xomP111 = new CMLPoint3(new double[] { 1., 1., 1. }); xomP100 = new CMLPoint3(new double[] { 1., 0., 0. }); xomP010 = new CMLPoint3(new double[] { 0., 1., 0. }); xomP001 = new CMLPoint3(new double[] { 0., 0., 1. }); xomP123 = new CMLPoint3(new double[] { 1., 2., 3. }); xomPl0100 = new CMLPlane3(new double[] { 0., 1., 0., 0. }); xomPl1002 = new CMLPlane3(new double[] { 1., 0., 0., 2. }); xomPl1005 = new CMLPlane3(new double[] { 1., 0., 0., 5. }); xomPl1115 = new CMLPlane3(new double[] { 1., 1., 1., 5. }); // xomL555111 = new CMLLine3(new double[]{5., 5., 5., 1., 1., 1.}); xomL220011 = new CMLLine3(new CMLPoint3(0., 1., 1.), new CMLVector3(2., 2., 0.)); xomV000 = new CMLVector3(new double[] { 0., 0., 0. }); xomV100 = new CMLVector3(new double[] { 1., 0., 0. }); xomV010 = new CMLVector3(new double[] { 0., 1., 0. }); xomV001 = new CMLVector3(new double[] { 0., 0., 1. }); xomV111 = new CMLVector3(new double[] { 1., 1., 1. }); xomV123 = new CMLVector3(new double[] { 1., 2., 3. }); xomV321 = new CMLVector3(new double[] { 3., 2., 1. }); // create from XML xmlP111S = "1. 1. 1."; xmlP100S = "1 0 0"; xmlP010S = "0 1.0E+00 0"; xmlP001S = "0 0 1"; xmlP123S = "1 2 3"; CMLBuilder builder = new CMLBuilder(); xmlP111 = (CMLPoint3) builder.build(new StringReader(xmlP111S)) .getRootElement(); xmlP123 = (CMLPoint3) builder.build(new StringReader(xmlP123S)) .getRootElement(); xmlP100 = (CMLPoint3) builder.build(new StringReader(xmlP100S)) .getRootElement(); xmlP010 = (CMLPoint3) builder.build(new StringReader(xmlP010S)) .getRootElement(); xmlP001 = (CMLPoint3) builder.build(new StringReader(xmlP001S)) .getRootElement(); } void makeXomT1() { xomT1 = new CMLTransform3(new double[] { 0., 1., 0., 0., 0., 0., 1., 0., -1., 0., 0., 0., 0., 0., 0., 1. }); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLXaxisTest.java000066400000000000000000000042551477224461000273050ustar00rootroot00000000000000/* Copyright 2023 Gowri Shankar K * * 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.main; import nu.xom.Element; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.element.CMLAxis; import org.xmlcml.cml.element.CMLXaxis; public class CMLXaxisTest { @Test public void testCMLXaxisList() { CMLXaxis cmlXaxis = new CMLXaxis(); Assert.assertNotNull("constructor: ", cmlXaxis); cmlXaxis.setAttribute("axis", "Xaxis"); CMLXaxis cmlXaxis1 = new CMLXaxis(cmlXaxis); Assert.assertEquals("CMLXaxis attributeValue should be Xaxis: ", cmlXaxis.getAttributeValue("axis"), cmlXaxis1.getAttributeValue("axis")); } @Test public void testCMLXaxisCopy() { CMLXaxis cmlXaxis = new CMLXaxis(); cmlXaxis.setAttribute("axis", "Xaxis"); CMLXaxis cmlXaxis1 = new CMLXaxis(cmlXaxis); Element copy = cmlXaxis1.copy(); Assert.assertEquals("class should be CMLXaxis: ", copy.getClass(), CMLXaxis.class); } @Test public void testCMLXaxisMakeElementInContext() { Element current = new Element("cmlXaxis"); CMLXaxis factoryElement = new CMLXaxis(); CMLElement newElement = factoryElement.makeElementInContext(current); Assert.assertEquals("class should be CMLXaxis: ", newElement.getClass(), CMLXaxis.class); } @Test public void testCMLXaxisGetAxisType() { CMLXaxis cmlXaxis = new CMLXaxis(); Assert.assertEquals("AxisType should be X: ", CMLAxis.AxisType.X, cmlXaxis.getAxisType()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLYaxisTest.java000066400000000000000000000044261477224461000273060ustar00rootroot00000000000000/* Copyright 2023 Gowri Shankar K * * 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.main; import nu.xom.Element; import org.junit.Assert; import org.junit.Test; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.element.CMLAxis; import org.xmlcml.cml.element.CMLYaxis; public class CMLYaxisTest { @Test public void testCMLYaxisList() { CMLYaxis cmlYaxis = new CMLYaxis(); Assert.assertNotNull("constructor: ", cmlYaxis); cmlYaxis.setAttribute("axis", "Yaxis"); CMLYaxis cmlYaxis1 = new CMLYaxis(cmlYaxis); Assert.assertEquals("CMLYaxis attributeValue should be Yaxis: ", cmlYaxis.getAttributeValue("axis"), cmlYaxis1.getAttributeValue("axis")); } @Test public void testCMLYaxisCopy() { CMLYaxis cmlYaxis = new CMLYaxis(); cmlYaxis.setAttribute("axis", "Yaxis"); CMLYaxis cmlYaxis1 = new CMLYaxis(cmlYaxis); Element copy = cmlYaxis1.copy(); Assert.assertEquals("class should be CMLYaxis: ", copy.getClass(), CMLYaxis.class); } @Test public void testCMLYaxisMakeElementInContext() { Element current = new Element("cmlYaxis"); CMLYaxis factoryElement = new CMLYaxis(); CMLElement newElement = factoryElement.makeElementInContext(current); Assert.assertEquals("class should be CMLYaxis: ", newElement.getClass(), CMLYaxis.class); } @Test public void testCMLYaxisGetAxisType() { CMLYaxis cmlYaxis = new CMLYaxis(); Assert.assertEquals("AxisType should be Y: ", CMLAxis.AxisType.Y, cmlYaxis.getAxisType()); Assert.assertNotEquals("AxisType should not be Z: ", CMLAxis.AxisType.Z, cmlYaxis.getAxisType()); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/CMLZMatrixTest.java000077500000000000000000000311571477224461000276130ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.cml.element.main.AbstractTestBase.EXPERIMENTAL_RESOURCE; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import junit.framework.Assert; import nu.xom.Document; import nu.xom.ParsingException; import nu.xom.Serializer; import nu.xom.ValidityException; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLUtil; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLCml; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.cml.element.CMLZMatrix; import org.xmlcml.euclid.EuclidRuntimeException; import org.xmlcml.euclid.Util; /** * test ZMatrix. * * @author pm286 * */ public class CMLZMatrixTest { /** * Test method for * 'org.xmlcml.cml.element.CMLZMatrix.CMLZMatrix(CMLElement)' * * @exception Exception */ @Test public void testCMLZMatrixCMLElement() throws Exception { String zmatS = CMLConstants.S_EMPTY + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "1.54" + "1.54" + "111" + "1.40" + "111" + "120" + "1.54" + "1.54" + "111" + "1.40" + "111" + "120" + "1.54" + "1.54" + "111" + "1.40" + "111" + "120" + "105" + "1.40" + "105" + "140" + "140" + "140" + "105" + "1.40" + "105" + "160" + "160" + "160" + "1.40" + "105" + "90" + "1.10" + "105" + "60" + "" + CMLConstants.S_EMPTY; CMLMolecule molecule = (CMLMolecule) new CMLBuilder() .parseString(zmatS); CMLZMatrix zmat = new CMLZMatrix(molecule); zmat.addCartesiansTo(molecule); // test for bad input String zmatBadS = "" + "1.54" + "1.54" + "111" + "1.40" + "111" + "120" + "1.54" + "1.54" + "" + CMLConstants.S_EMPTY; CMLCml cml = (CMLCml)CMLXOMTestUtils.parseValidString(zmatBadS); try { zmat = new CMLZMatrix(cml); } catch (RuntimeException e) { Assert .assertEquals( "test number of components", "wrong number of angle elements (2) for length Elements (5) in ZMatrix", e.getMessage()); } zmatBadS = "" + "1.54" + "1.54" + "111" + "1.40" + "111" + "" + CMLConstants.S_EMPTY; cml = (CMLCml)CMLXOMTestUtils.parseValidString(zmatBadS); try { zmat = new CMLZMatrix(cml); } catch (RuntimeException e) { Assert .assertEquals( "test number of components", "wrong number of torsion elements (0) for length Elements (3) in ZMatrix", e.getMessage()); } } /** * another test for the constructor. * */ @Test public void testZMatrixElement2() { String moleculeS = CMLConstants.S_EMPTY + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "1.32" + "1.25" + "1.52" + "1.54" + "1.4" + "1.39" + "1.54" + "120" + "120" + "111" + "120" + "120" + "111" + "120" + "120" + "180" + "-90" + "120" + ""; CMLMolecule molecule = (CMLMolecule)CMLXOMTestUtils.parseValidString(moleculeS); /* CMLZMatrix zMatrix = */new CMLZMatrix(molecule); } @Test public void testAddCoordinates() { CMLMolecule molecule = (CMLMolecule) CMLUtil.parseQuietlyIntoCML( "" + " " + " 1.0" + " 1.07046" + " 90.08384" + " 1.07046" + " 90.08384" + " 120.0" + " 1.07046" + " 90.08384" + " -120.0" + " " + " " + " " + " " + " " + " " + " " + " " + ""); CMLZMatrix zMatrix = (CMLZMatrix) molecule.getChildElements().get(0); zMatrix.addCartesiansTo(molecule); } @SuppressWarnings("unused") private void testExample(String infileS, String outfileS) throws IOException, ValidityException, ParsingException { Document doc = null; CMLMolecule mol = null; InputStream in = Util.getInputStreamFromResource(EXPERIMENTAL_RESOURCE +CMLConstants.U_S + infileS); doc = new CMLBuilder().build(in); in.close(); mol = (CMLMolecule) doc.getRootElement(); CMLZMatrix zmat = new CMLZMatrix(mol); /* * -- add random torsions for fun Elements torsionList = * zmat.getChildCMLElements(CMLTorsion.TAG); for (int i = 0; i < * torsionList.size(); i++) { CMLTorsion torsion = (CMLTorsion) * torsionList.get(i); double tangle = torsion.getXMLContent(); tangle * += 30 Math.random(); torsion.setXMLContent(tangle); } -- */ zmat.addCartesiansTo(mol); File outfile = new File(outfileS); Serializer serializer = null; try { serializer = new Serializer(new FileOutputStream(outfile)); } catch (FileNotFoundException e) { throw new EuclidRuntimeException("should never throw " + e); } try { serializer.write(doc); } catch (IOException e) { throw new EuclidRuntimeException("should never throw " + e); } } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/ElementsTest.java000077500000000000000000000106661477224461000274370ustar00rootroot00000000000000/** * 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.main; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import nu.xom.Attribute; import nu.xom.Elements; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLElement; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLAtomArray; /** * test CMLElements * * @author pmr * */ public class ElementsTest { CMLElement cml1; Elements elems; CMLElements cmlElems; CMLElements atoms; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { cml1 = new CMLElement("cml1"); CMLElement cml2 = new CMLElement("cml2"); cml2.addAttribute(new Attribute("id", "id1")); cml1.appendChild(cml2); cml2 = new CMLElement("cml2"); cml2.addAttribute(new Attribute("id", "id2")); cml1.appendChild(cml2); elems = cml1.getChildElements(); cmlElems = new CMLElements(elems); CMLAtomArray atomArray = new CMLAtomArray(); CMLAtom atom = new CMLAtom(); atom.setId("a1"); atomArray.appendChild(atom); atom = new CMLAtom(); atom.setId("a2"); atomArray.appendChild(atom); atoms = atomArray.getAtomElements(); } /** * Test method for 'org.xmlcml.cml.base.CMLElements.CMLElements(Elements)' */ @Test public void testCMLElements() { CMLElements cc = new CMLElements(elems); Assert.assertEquals("constructor", 2, cc.size()); } /** * Test method for 'org.xmlcml.cml.base.CMLElements.iterator()' */ @Test public void testIterator() { Iterator it = cmlElems.iterator(); int i = 0; while (it.hasNext()) { CMLElement elem = it.next(); Assert.assertEquals("class", CMLElement.class, elem.getClass()); Assert.assertEquals("id", "id" + (++i), elem .getAttributeValue("id")); } } /** * Test method for 'org.xmlcml.cml.base.CMLElements.get(int)' */ @Test public void testGet() { CMLElement elem = (CMLElement) elems.get(0); Assert.assertEquals("get", CMLElement.class, elem.getClass()); Assert.assertEquals("id", "id1", elem.getAttributeValue("id")); elem = (CMLElement) elems.get(1); Assert.assertEquals("get", CMLElement.class, elem.getClass()); Assert.assertEquals("id", "id2", elem.getAttributeValue("id")); try { elem = (CMLElement) elems.get(2); Assert.fail("should throw IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { System.out.println(e.getMessage()); Set allowedStrings = new HashSet(); allowedStrings.add("Index 2 out of bounds for length 2"); allowedStrings.add("Index: 2, Size: 2"); Assert.assertTrue("array error", allowedStrings.contains(e.getMessage())); } } /** * Test method for 'org.xmlcml.cml.base.CMLElements.size()' */ @Test public void testSize() { Assert.assertEquals("size", 2, elems.size()); } /** * Test method for 'org.xmlcml.cml.base.CMLElements.getType()' */ @Test public void testGetType() { Class classx = cmlElems.getType(); Assert.assertEquals("type", org.xmlcml.cml.base.CMLElement.class, classx); Assert.assertEquals("class", org.xmlcml.cml.element.CMLAtom.class, atoms.get(0).getClass()); Assert.assertEquals("size", 2, atoms.size()); classx = atoms.getType(); Assert.assertEquals("type", org.xmlcml.cml.element.CMLAtom.class, classx); } /** * Test method for 'org.xmlcml.cml.base.CMLElements.getList()' */ @Test public void testGetList() { List atomList = atoms.getList(); Assert.assertEquals("list", 2, atomList.size()); } /** * run tests. * * @return the suite. * */ } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/GeomTestBase.java000077500000000000000000000017321477224461000273370ustar00rootroot00000000000000/** * 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.main; import org.apache.log4j.Logger; /** * provides communal resources for testing. e.g. files and moelcules subclassed * by atom- molecule and bond-aware */ public abstract class GeomTestBase { final static Logger logger = Logger.getLogger(GeomTestBase.class.getName()); } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/MiscTest.java000077500000000000000000000071701477224461000265520ustar00rootroot00000000000000/** * 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.main; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import nu.xom.Document; import nu.xom.Element; import nu.xom.Serializer; import nu.xom.Text; import org.junit.Assert; import org.junit.Test; /** * miscellaneous test stuff * * @author pmr * */ public class MiscTest { /** * test XOM */ @Test public void testXomText() { Element a = new Element("a"); new Document(a); Assert.assertEquals("empty element", "" + (char) 13 + (char) 10, output(a)); Text text = new Text("x"); a.appendChild(text); Assert.assertEquals("non-empty text", "x" + (char) 13 + (char) 10, output(a)); text.setValue("y"); Assert.assertEquals("non-empty text", "y" + (char) 13 + (char) 10, output(a)); text.setValue(""); Assert.assertEquals("empty text", "" + (char) 13 + (char) 10, output(a)); Assert.assertEquals("empty text count", 1, a.getChildCount()); Assert.assertEquals("empty text value", "", text.getValue()); text.setValue(null); Assert.assertEquals("nullValue text", "" + (char) 13 + (char) 10, output(a)); Assert.assertEquals("nullValue child count", 1, a.getChildCount()); // should fail but doesn't Assert.assertNotNull("nullValue text", text.getValue()); // should fail but doesn't Assert.assertEquals("empty text child value", "", text.getValue()); text.setValue("z"); Assert.assertEquals("empty text child", "z" + (char) 13 + (char) 10, output(a)); a = new Element("a"); new Document(a); Assert.assertEquals("empty element", "" + (char) 13 + (char) 10, output(a)); String s = null; text = new Text(s); Assert.assertEquals("nullValue text", "", text.getValue()); a.appendChild(text); Assert.assertEquals("nullValue text", "" + (char) 13 + (char) 10, output(a)); Assert.assertEquals("nullValue child count", 1, a.getChildCount()); // should fail but doesn't Assert.assertNotNull("nullValue text", text.getValue()); // should fail but doesn't Assert.assertEquals("empty text child value", "", text.getValue()); try { text = new Text((Text) null); Assert.fail("should throw NullPointer"); } catch (NullPointerException npe) { ; } } private String output(Element a) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); String actual = null; try { baos = new ByteArrayOutputStream(); Serializer ser = new MockSerializer(baos); ser.write((Document) a.getParent()); actual = baos.toString(); } catch (IOException e) { throw new RuntimeException("bug " + e); } return actual; } /** * run tests. * * @return the suite. * */ } class MockSerializer extends Serializer { /** * constructor * * @param os */ public MockSerializer(OutputStream os) { super(os); } /** * test * */ public void writeXMLDeclaration() { } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/MoleculeAtomBondFixture.java000077500000000000000000000434541477224461000315640ustar00rootroot00000000000000/** * 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.main; import java.io.IOException; import java.io.StringReader; import java.util.List; import nu.xom.Document; import nu.xom.ParsingException; import org.apache.log4j.Logger; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLUtil; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLAtom; import org.xmlcml.cml.element.CMLBond; import org.xmlcml.cml.element.CMLBondArray; import org.xmlcml.cml.element.CMLCml; import org.xmlcml.cml.element.CMLCrystal; import org.xmlcml.cml.element.CMLMolecule; import org.xmlcml.molutil.ChemicalElement.AS; /** * provides communal resources for testing. e.g. files and moelcules subclassed * by atom- molecule and bond-aware * */ public final class MoleculeAtomBondFixture { public MoleculeAtomBondFixture() { try { setUp(); } catch (Exception e) { throw new RuntimeException(e); } } final static Logger logger = Logger.getLogger(MoleculeAtomBondFixture.class .getName()); Document xmlDocument = null; // build xom public final int NATOM = 5; protected final int NBOND = 5; protected String[] elementTypes = { AS.C.value, AS.N.value, AS.O.value, AS.S.value, AS.B.value }; protected int[] hCounts = { 2, 1, 0, 0, 1 }; public CMLMolecule xomMolecule; public CMLAtom[] xomAtom; public CMLBond[] xomBond; // // read into xom; not a stable molecule... (CH3)[N+](S-)(O)(F) // 2 1 3 4 5 protected String xmlMolS = CMLConstants.S_EMPTY + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " "; public CMLMolecule xmlMolecule; public List xmlAtoms; public CMLAtom[] xmlAtom; public List xmlBonds; protected int xmlNatoms; public int xmlNbonds; public CMLMolecule mol1 = null; public CMLMolecule mol2 = null; protected CMLMolecule mol3 = null; protected CMLMolecule mol4 = null; public CMLMolecule mol5 = null; public CMLMolecule mol5a = null; protected CMLMolecule mol6 = null; public CMLMolecule mol7 = null; public CMLMolecule mol8 = null; protected CMLMolecule mol9 = null; protected CMLMolecule mol10 = null; protected CMLMolecule mol11 = null; protected CMLCrystal crystal = null; protected CMLCml cmlCryst = null; protected CMLMolecule cmlCrystMol = null; protected CMLCrystal cmlCrystCryst = null; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { // build reference molecule xomMolecule = new CMLMolecule(); xomMolecule.setId("xom1"); xomAtom = new CMLAtom[NATOM]; for (int i = 0; i < NATOM; i++) { xomAtom[i] = new CMLAtom(); xomAtom[i].setId("a" + (i + 1)); xomMolecule.getOrCreateAtomArray().appendChild(xomAtom[i]); xomAtom[i].setElementType(elementTypes[i]); xomAtom[i].setX3((double) i); xomAtom[i].setY3((double) (i + 1)); xomAtom[i].setZ3((double) (i + 2)); xomAtom[i].setX2((double) i * 10); xomAtom[i].setY2((double) (i * 10 + 1)); xomAtom[i].setHydrogenCount(hCounts[i]); } xomBond = new CMLBond[NBOND]; for (int j = 0; j < NBOND; j++) { // form a cycle... // have to set id at this stage. Pehaps we should trap it xomBond[j] = new CMLBond(xomAtom[j], xomAtom[(j + 1) % NATOM]); xomBond[j].setId("b" + (j + 1)); CMLBondArray bondArray = xomMolecule.getOrCreateBondArray(); bondArray.appendChild(xomBond[j]); xomBond[j].setOrder((j == 0) ? "2" : "1"); } // read reference moelcule try { xmlDocument = new CMLBuilder().build(new StringReader(xmlMolS)); } catch (IOException e) { Assert.fail("Should not throw IOException"); } catch (ParsingException e) { e.printStackTrace(); logger.error("Parse exception " + e); Assert.fail("Should not throw ParsingException " + e.getMessage()); } xmlMolecule = (CMLMolecule) xmlDocument.getRootElement(); xmlAtoms = xmlMolecule.getAtoms(); xmlAtom = new CMLAtom[xmlAtoms.size()]; for (int i = 0; i < xmlAtom.length; i++) xmlAtom[i] = (CMLAtom) xmlAtoms.get(i); xmlBonds = xmlMolecule.getBonds(); xmlNatoms = 5; xmlNbonds = 4; Assert.assertEquals("check atoms in setup", xmlNatoms, xmlAtoms.size()); Assert.assertEquals("check bonds in setup", xmlNbonds, xmlBonds.size()); } /** * test building from XML* Test method for * 'org.xmlcml.cml.element.CMLMolecule.createAndAddAtom(String)' */ @Test public void testParse() { // Assert that reference molecule read correctly CMLMolecule molecule = (CMLMolecule) xmlDocument.getRootElement(); Assert.assertNotNull("root should not be null", molecule); Assert.assertEquals("molecule id", "m1", molecule.getId()); CMLAtom atom = (CMLAtom) molecule.getAtom(0); Assert.assertNotNull("atom should not be null", atom); Assert.assertEquals("atom id", atom.getId(), "a1"); Assert.assertEquals("atom elementType", atom.getElementType(), AS.N.value); CMLBond bond = (CMLBond) molecule.getBonds().get(0); Assert.assertNotNull("bond should not be null", bond); Assert.assertEquals("bond atomrefs", bond.getAtomRefs2()[0], "a1"); // test for incorrect XML // duplicate id xmlMolS = " " + " " + " " + " " + " " + " " + " " + " " + " " + " "; try { xmlDocument = new CMLBuilder().build(new StringReader(xmlMolS)); Assert.fail("should trap duplicate atom id"); } catch (IOException e) { Assert.fail("Should not throw IOException"); } catch (ParsingException e) { Assert.assertEquals("duplicate id", "Index atom: duplicate atom: a1", e.getMessage()); } // missing id - no longer checked here // xmlMolS = " " + " " // + " " + " " + " " // + " " + " " // + " " + " "; // try { // xmlDocument = new CMLBuilder().build(new StringReader(xmlMolS)); // Assert.fail("should trap missing atom id"); // } catch (IOException e) { // Assert.fail("Should not throw IOException"); // } catch (ParsingException e) { // Assert.assertEquals("unset id", "Atom id must not be null", e // .getMessage()); // } } public void makeMol1() { String s = " " + " " + " " + " " + " " + " " + " "; mol1 = (CMLMolecule)CMLXOMTestUtils.parseValidString(s); } public void makeMol2() { mol2 = (CMLMolecule)CMLXOMTestUtils.parseValidString(" " + " " + " " + " " + " " + " " + " "); } protected void makeMol3() { mol3 = (CMLMolecule)CMLXOMTestUtils.parseValidString(" " + " " + " " + " " + " " + " " + " "); } protected void makeMol4() { mol4 = (CMLMolecule)CMLXOMTestUtils.parseValidString(" " + " " + " " + " " + " " + " " + " "); } protected void makeCrystal() { crystal = (CMLCrystal)CMLXOMTestUtils.parseValidString(" " + " 9.0" + " 10.0" + " 11.0" + " 90.0" + " 90.0" + " 90.0" + " " + " "); } public void makeMol5() { mol5 = (CMLMolecule)CMLXOMTestUtils.parseValidString(" " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " "); } public void makeMol5a() { mol5a = (CMLMolecule)CMLXOMTestUtils.parseValidString(" " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " "); } public void makeMolCryst() { cmlCryst = (CMLCml)CMLXOMTestUtils.parseValidString("" + " " + " 9.0" + " 10.0" + " 11.0" + " 90.0" + " 90.0" + " 90.0" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""); cmlCrystMol = (CMLMolecule) CMLUtil.getQueryNodes(cmlCryst, ".//" + CMLMolecule.NS, CMLConstants.CML_XPATH).get(0); cmlCrystCryst = (CMLCrystal) CMLUtil.getQueryNodes(cmlCryst, ".//" + CMLCrystal.NS, CMLConstants.CML_XPATH).get(0); } protected void makeMol6() { mol6 = (CMLMolecule)CMLXOMTestUtils.parseValidString(" " + " " + " " + " " + " " + " " + " "); } public void makeMol7() { mol7 = (CMLMolecule)CMLXOMTestUtils.parseValidString(" " + " " + " " + " " + " " + " " + " "); } public void makeMol8() { mol8 = (CMLMolecule)CMLXOMTestUtils.parseValidString("" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""); } protected void makeMol9() { mol9 = (CMLMolecule)CMLXOMTestUtils.parseValidString("" + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""); } protected void makeMol10() { mol10 = (CMLMolecule)CMLXOMTestUtils.parseValidString("" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "" + CMLConstants.S_EMPTY); } protected void makeMol11() { mol11 = (CMLMolecule)CMLXOMTestUtils.parseValidString("" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "" + CMLConstants.S_EMPTY); } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/ParserWrapper.java000077500000000000000000000057721477224461000276220ustar00rootroot00000000000000/** * 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.main; import nu.xom.Document; import nu.xom.Text; import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.SAXNotSupportedException; /** * Encapsulates a DOM parser. * * @version $Id: ParserWrapper.java 213 2007-01-02 19:06:36Z petermr $ */ public interface ParserWrapper { // // ParserWrapper methods // /** * Parses the specified URI and returns the document. * * @param uri * @return document * @throws Exception */ public Document parse(String uri) throws Exception; /** * Set the state of a feature. * * Set the state of any feature in a SAX2 parser. The parser might not * recognize the feature, and if it does recognize it, it might not be able * to fulfill the request. * * @param featureId * The unique identifier (URI) of the feature. * @param state * The requested state of the feature (true or false). * * @exception org.xml.sax.SAXNotRecognizedException * If the requested feature is not known. * @exception org.xml.sax.SAXNotSupportedException * If the requested feature is known, but the requested state * is not supported. * @exception org.xml.sax.SAXNotRecognizedException * If there is any other problem fulfilling the request. */ public void setFeature(String featureId, boolean state) throws SAXNotRecognizedException, SAXNotSupportedException; /** * Returns the document information. * * @return info */ public DocumentInfo getDocumentInfo(); // // Interfaces // /** * This interface is here to query information about the document * implementation returned by the ParserWrapper#parse method. * * @author Andy Clark, IBM */ public interface DocumentInfo { // // DocumentInfo methods // /** * Returns true if the specified text node is ignorable whitespace. * * @param text * @return ignorable * */ public boolean isIgnorableWhitespace(Text text); } // interface DocumentInfo } // interface ParserWrapper cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/cml/element/main/ReactionAllTestBase.java000077500000000000000000000236711477224461000306530ustar00rootroot00000000000000/** * 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.main; import static org.xmlcml.euclid.EuclidConstants.S_EMPTY; import java.io.IOException; import java.io.StringReader; import nu.xom.ParsingException; import nu.xom.ValidityException; import org.junit.Assert; import org.junit.Before; import org.xmlcml.cml.base.CMLBuilder; import org.xmlcml.cml.base.CMLConstants; import org.xmlcml.cml.base.CMLElements; import org.xmlcml.cml.base.CMLXOMTestUtils; import org.xmlcml.cml.element.CMLProduct; import org.xmlcml.cml.element.CMLProductList; import org.xmlcml.cml.element.CMLReactant; import org.xmlcml.cml.element.CMLReactantList; import org.xmlcml.cml.element.CMLReaction; import org.xmlcml.cml.element.CMLSpectator; import org.xmlcml.cml.element.CMLSpectatorList; /** * test for reaction elements. * * @author pmr * */ public abstract class ReactionAllTestBase { protected CMLReaction xomReact1; protected CMLReaction xomReact2; protected final static String xmlReact1S = "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " boiling chip" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "" + S_EMPTY; protected CMLReaction xmlReact1; protected CMLReaction multiReact1; protected CMLElements xmlReactantLists1; protected CMLElements xmlProductLists1; protected CMLElements xmlSpectatorLists1; // the first and only instances protected CMLReactantList xmlReactantList1; protected CMLProductList xmlProductList1; protected CMLSpectatorList xmlSpectatorList1; protected CMLElements xmlReactants1; protected CMLElements xmlProducts1; protected CMLElements xmlSpectators1; protected final static String xmlReact2S = "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "" + S_EMPTY; protected CMLReaction xmlReact2; /** * setup. * * @throws Exception */ @Before public synchronized void setUp() throws Exception { xmlReact1 = (CMLReaction)CMLXOMTestUtils.parseValidString(xmlReact1S); xmlReactantLists1 = xmlReact1.getReactantListElements(); xmlProductLists1 = xmlReact1.getProductListElements(); xmlSpectatorLists1 = xmlReact1.getSpectatorListElements(); Assert.assertEquals("reactantList size", 1, xmlReactantLists1.size()); Assert.assertEquals("productList size", 1, xmlProductLists1.size()); Assert.assertEquals("spectatorList size", 1, xmlSpectatorLists1.size()); xmlReactantList1 = xmlReactantLists1.get(0); xmlProductList1 = xmlProductLists1.get(0); xmlSpectatorList1 = xmlSpectatorLists1.get(0); xmlReactants1 = xmlReactantList1.getReactantElements(); xmlProducts1 = xmlProductList1.getProductElements(); xmlSpectators1 = xmlSpectatorList1.getSpectatorElements(); Assert.assertEquals("reactants size", 2, xmlReactants1.size()); Assert.assertEquals("products size", 2, xmlProducts1.size()); Assert.assertEquals("spectators size", 2, xmlSpectators1.size()); } protected void makeMultiProductReactantLists() { String multiReact1S = "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "" + S_EMPTY; try { multiReact1 = (CMLReaction) new CMLBuilder().build( new StringReader(multiReact1S)).getRootElement(); } catch (ValidityException e) { Assert.fail("should not throw ValidityException " + e); } catch (ParsingException e) { Assert.fail("should not throw ParsingException " + e); } catch (IOException e) { Assert.fail("should not throw IOException " + e); } } protected void makeXmlReact2() { try { xmlReact2 = (CMLReaction) new CMLBuilder().build( new StringReader(xmlReact2S)).getRootElement(); } catch (ValidityException e) { Assert.fail("should not throw ValidityException " + e); } catch (ParsingException e) { Assert.fail("should not throw ParsingException " + e); } catch (IOException e) { Assert.fail("should not throw IOException " + e); } } } cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/molutil/000077500000000000000000000000001477224461000225015ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/molutil/test/000077500000000000000000000000001477224461000234605ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/java/org/xmlcml/molutil/test/ChemicalElementTest.java000077500000000000000000000376761477224461000302300ustar00rootroot00000000000000/** * 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.molutil.test; import static org.xmlcml.euclid.EuclidConstants.EPS; import static org.xmlcml.euclid.EuclidConstants.S_EMPTY; import java.awt.Color; import java.util.ArrayList; import java.util.List; import org.junit.Assert; import org.junit.Test; import org.xmlcml.euclid.Int; import org.xmlcml.euclid.test.DoubleTestBase; import org.xmlcml.molutil.ChemicalElement; import org.xmlcml.molutil.ChemicalElement.AS; /** * tests Chemical Element. * * @author pmr * */ public class ChemicalElementTest { /** * Test method for 'org.xmlcml.molutil.ChemicalElement initialisation' */ @Test public void testInit() { Assert.assertNotNull("init", ChemicalElement.periodicTable); Assert.assertEquals("init", ChemicalElement.MAXELEM, ChemicalElement.periodicTable.length); } /** * Test method for * 'org.xmlcml.molutil.ChemicalElement.ChemicalElement(String, int, double)' */ @Test public void testChemicalElement() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("new", el); Assert.assertEquals("new", "Yz", el.getSymbol()); } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.getSymbol()' */ @Test public void testGetSymbol() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("new", el); Assert.assertEquals("new", "Yz", el.getSymbol()); el = ChemicalElement.getChemicalElement(AS.C.value); Assert.assertEquals("get", AS.C.value, el.getSymbol()); } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.getAtomicNumber()' */ @Test public void testGetAtomicNumber() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("new", el); Assert.assertEquals("new", 123, el.getAtomicNumber()); el = ChemicalElement.getChemicalElement(AS.C.value); Assert.assertEquals("get", 6, el.getAtomicNumber()); } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.getAtomicWeight()' */ @Test public void testGetAtomicWeight() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("new", el); Assert.assertEquals("new", 299.99, el.getAtomicWeight(), EPS); el = ChemicalElement.getChemicalElement(AS.C.value); // FIXME Assert.assertEquals("get", 12.0107, el.getAtomicWeight(), 0.0001); } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.getGroup()' */ @Test public void testGetGroup() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("new", el); Assert.assertEquals("new", 0, el.getGroup()); el = ChemicalElement.getChemicalElement(AS.C.value); Assert.assertEquals("get", 14, el.getGroup()); } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.getPeriod()' */ @Test public void testGetPeriod() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("new", el); Assert.assertEquals("new", 0, el.getPeriod()); el = ChemicalElement.getChemicalElement(AS.H.value); Assert.assertEquals("get", 1, el.getPeriod()); el = ChemicalElement.getChemicalElement(AS.C.value); Assert.assertEquals("get", 2, el.getPeriod()); } /** * Test method for * 'org.xmlcml.molutil.ChemicalElement.getElectronicGroundState()' */ @Test public void testGetElectronicGroundState() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("new", el); Assert.assertNull("new", el.getElectronicGroundState()); el = ChemicalElement.getChemicalElement(AS.C.value); Assert.assertEquals("get", "[He].2s2.2p2", el .getElectronicGroundState()); } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.setIsotopes(int[], * double[])' */ @Test public void testSetIsotopes() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("iso", el); int[] iso = el.getIsotopeMasses(); Assert.assertNull("iso", iso); int[] masses = { 11, 12, 13, 14 }; double[] abundances = { 0.0001, 98.9, 1.01, 0.0001 }; el.setIsotopes(masses, abundances); iso = el.getIsotopeMasses(); Assert.assertNotNull("iso", iso); Assert.assertEquals("iso", 4, iso.length); String s = Int.testEquals((new int[] { 11, 12, 13, 14 }), iso); if (s != null) { Assert.fail("iso" + "; " + s); } double[] dd = el.getIsotopeAbundances(); Assert.assertNotNull("iso", dd); Assert.assertEquals("iso", 4, dd.length); DoubleTestBase.assertEquals("iso", new double[] { 0.0001, 98.9, 1.01, 0.0001 }, dd, EPS); masses = new int[] { 1, 2, 3 }; abundances = new double[] { .2, .3, .5 }; el.setIsotopes(masses, abundances); iso = el.getIsotopeMasses(); Assert.assertNotNull("iso", iso); Assert.assertEquals("iso", 3, iso.length); s = Int.testEquals((new int[] { 1, 2, 3 }), iso); if (s != null) { Assert.fail("iso" + "; " + s); } dd = el.getIsotopeAbundances(); Assert.assertNotNull("iso", dd); Assert.assertEquals("iso", 3, dd.length); DoubleTestBase .assertEquals("iso", new double[] { .2, .3, .5 }, dd, EPS); } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.getIsotopeMasses()' */ @Test public void testGetIsotopeMasses() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("iso", el); int[] iso = el.getIsotopeMasses(); Assert.assertNull("iso", iso); el = ChemicalElement.getChemicalElement(AS.C.value); iso = el.getIsotopeMasses(); Assert.assertNotNull("iso", iso); Assert.assertEquals("iso", 2, iso.length); String s = Int.testEquals((new int[] { 12, 13 }), iso); if (s != null) { Assert.fail("iso" + "; " + s); } } /** * Test method for * 'org.xmlcml.molutil.ChemicalElement.getIsotopeAbundances()' */ @Test public void testGetIsotopeAbundances() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("iso", el); double[] iso = el.getIsotopeAbundances(); Assert.assertNull("iso", iso); el = ChemicalElement.getChemicalElement(AS.C.value); iso = el.getIsotopeAbundances(); Assert.assertNotNull("iso", iso); Assert.assertEquals("iso", 2, iso.length); DoubleTestBase.assertEquals("iso", new double[] { 98.93, 1.07 }, iso, EPS); } @Test public void getIsotopePreciseMassesNotSet() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("iso", el); double[] iso = el.getIsotopePreciseMasses(); Assert.assertNull("iso", iso); } @Test public void getIsotopePreciseMassesCarbon() { ChemicalElement el = ChemicalElement.getChemicalElement(AS.C.value); double [] iso = el.getIsotopePreciseMasses(); Assert.assertNotNull("iso", iso); Assert.assertEquals("iso", 2, iso.length); DoubleTestBase.assertEquals("iso", new double[] { 12.000000, 13.003354 }, iso, EPS); } @Test public void getIsotopePreciseMassesHydrogen() { ChemicalElement el = ChemicalElement.getChemicalElement(AS.H.value); double [] iso = el.getIsotopePreciseMasses(); Assert.assertNotNull("iso", iso); Assert.assertEquals("iso", 2, iso.length); DoubleTestBase.assertEquals("iso", new double[] { 1.007825032, 2.014101778 }, iso, EPS); } @Test public void getIsotopePreciseMassesNotSpecified() { //will need to be changed to a different element if the precise masses for //Uranium are ever added to elementdata.xml ChemicalElement el = ChemicalElement.getChemicalElement("U"); double [] iso = el.getIsotopePreciseMasses(); Assert.assertEquals(3, iso.length); for (double d : iso) { Assert.assertTrue(Double.isNaN(d)); } } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.getMainIsotope()' */ @Test public void testGetMainIsotope() { ChemicalElement el = ChemicalElement.getChemicalElement(AS.C.value); int iso = el.getMainIsotope(); Assert.assertEquals("iso", 12, iso); } /** * Test method for * 'org.xmlcml.molutil.ChemicalElement.setCovalentRadius(double)' */ @Test public void testSetCovalentRadius() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("iso", el); Assert.assertEquals("covrad", 1.4, el.getCovalentRadius(), EPS); el.setCovalentRadius(1.8); Assert.assertEquals("covrad", 1.8, el.getCovalentRadius(), EPS); } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.getCovalentRadius()' */ @Test public void testGetCovalentRadius() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("covrad", el); Assert.assertEquals("covrad", 1.4, el.getCovalentRadius(), EPS); el = ChemicalElement.getChemicalElement(AS.C.value); Assert.assertEquals("covrad", 0.77, el.getCovalentRadius(), 0.0001); } /** * Test method for * 'org.xmlcml.molutil.ChemicalElement.setAtomicRadius(double)' */ @Test public void testSetAtomicRadius() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("iso", el); Assert.assertEquals("covrad", 1.6, el.getAtomicRadius(), EPS); el.setAtomicRadius(1.2); Assert.assertEquals("covrad", 1.2, el.getAtomicRadius(), EPS); } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.getAtomicRadius()' */ @Test public void testGetAtomicRadius() { ChemicalElement el = ChemicalElement.getChemicalElement(AS.C.value); double en = el.getVDWRadius(); Assert.assertEquals("get", 1.7, en, EPS); } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.setVDWRadius(double)' */ @Test public void testSetVDWRadius() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("iso", el); Assert.assertEquals("covrad", 2.0, el.getVDWRadius(), EPS); el.setVDWRadius(1.2); Assert.assertEquals("covrad", 1.2, el.getVDWRadius(), EPS); } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.getVDWRadius()' */ @Test public void testGetVDWRadius() { ChemicalElement el = ChemicalElement.getChemicalElement(AS.C.value); double en = el.getVDWRadius(); Assert.assertEquals("get", 1.7, en, EPS); } /** * Test method for * 'org.xmlcml.molutil.ChemicalElement.setElectronegativity(double)' */ @Test public void testSetElectronegativity() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("iso", el); Assert.assertEquals("covrad", 0.0, el.getElectronegativity(), EPS); el.setElectronegativity(2.3); Assert.assertEquals("covrad", 2.3, el.getElectronegativity(), EPS); } /** * Test method for * 'org.xmlcml.molutil.ChemicalElement.getElectronegativity()' */ @Test public void testGetElectronegativity() { ChemicalElement el = ChemicalElement.getChemicalElement(AS.C.value); double en = el.getElectronegativity(); Assert.assertEquals("get", 2.55, en, EPS); } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.setColor(Color)' */ @Test public void testSetColor() { ChemicalElement el = new ChemicalElement("Yz", 123, 299.99); Assert.assertNotNull("col", el); Color col = el.getColor(); Assert.assertNull("col", col); el.setColor(Color.red); Assert.assertEquals("col", true, Color.red.equals(el.getColor())); } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.getColor()' */ @Test public void testGetColor() { ChemicalElement el = ChemicalElement.getChemicalElement(AS.C.value); Color col = el.getColor(); Assert.assertEquals("get", true, col.equals(new Color(128, 128, 128))); } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.getColorString()' */ @Test public void testGetColorString() { ChemicalElement el = ChemicalElement.getChemicalElement(AS.C.value); Assert.assertEquals("get", "#808080", el.getColorString()); } /** * Test method for * 'org.xmlcml.molutil.ChemicalElement.getValenceElectrons()' */ @Test public void testGetValenceElectrons() { ChemicalElement el = ChemicalElement.getChemicalElement(AS.C.value); Assert.assertEquals("get", 4, el.getValenceElectrons()); } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.toString()' */ @Test public void testToString() { ChemicalElement el = ChemicalElement.getChemicalElement(AS.C.value); Assert.assertEquals("get", "C: 12.0107", el.toString()); } /** * Test method for * 'org.xmlcml.molutil.ChemicalElement.getChemicalElement(String)' */ @Test public void testGetChemicalElement() { ChemicalElement el = ChemicalElement.getChemicalElement(AS.C.value); Assert.assertEquals("get", AS.C.value, el.getSymbol()); el = ChemicalElement.getChemicalElement("CA"); Assert.assertNull("get", el); el = ChemicalElement.getChemicalElement("Dummy"); Assert.assertNotNull("get", el); Assert.assertEquals("get", "Dummy", el.getSymbol()); } /** * Test method for 'org.xmlcml.molutil.ChemicalElement.getElement(int)' */ @Test public void testGetElement() { ChemicalElement el = ChemicalElement.getElement(6); Assert.assertEquals("get", AS.C.value, el.getSymbol()); el = ChemicalElement.getElement(0); Assert.assertNull("elem", el); el = ChemicalElement.getElement(1000); Assert.assertNull("elem", el); el = ChemicalElement.getElement(ChemicalElement.MAXELEM); Assert.assertNull("elem", el); } /** * Test method for * 'org.xmlcml.molutil.ChemicalElement.getBondingRadiusTolerance()' */ @Test public void testGetSetBondingRadiusTolerance() { double rad = ChemicalElement.getBondingRadiusTolerance(); Assert.assertEquals("default tolerance", 0.2, rad, EPS); ChemicalElement.setBondingRadiusTolerance(0.3); rad = ChemicalElement.getBondingRadiusTolerance(); Assert.assertEquals("default tolerance", 0.3, rad, EPS); } /** * tests grabChemicalElement(String s). * */ @Test public void testGrabChemicalElementString() { ChemicalElement elem = ChemicalElement.grabChemicalElement("He"); Assert.assertNotNull("helium", elem); Assert.assertEquals("helium 2", 2, elem.getAtomicNumber()); elem = ChemicalElement.grabChemicalElement("Qxz"); Assert.assertNull("qxz", elem); elem = ChemicalElement.grabChemicalElement(AS.H.value); Assert.assertNotNull("hydrogen", elem); Assert.assertEquals(AS.H.value, 1, elem.getAtomicNumber()); elem = ChemicalElement.grabChemicalElement("Hx"); Assert.assertNotNull("hydrogen", elem); Assert.assertEquals("Hx", 1, elem.getAtomicNumber()); elem = ChemicalElement.grabChemicalElement("z"); Assert.assertNull("z", elem); elem = ChemicalElement.grabChemicalElement(S_EMPTY); Assert.assertNull("empty", elem); String s = "HeCClNBr"; List elemList = new ArrayList(); while (s.length() > 0) { elem = ChemicalElement.grabChemicalElement(s); Assert.assertNotNull("concat:" + s, elem); s = s.substring(elem.getSymbol().length()); elemList.add(elem); } Assert.assertEquals("elements ", 5, elemList.size()); Assert.assertEquals("elem 0", 2, elemList.get(0).getAtomicNumber()); Assert.assertEquals("elem 1", 6, elemList.get(1).getAtomicNumber()); Assert.assertEquals("elem 2", 17, elemList.get(2).getAtomicNumber()); Assert.assertEquals("elem 3", 7, elemList.get(3).getAtomicNumber()); Assert.assertEquals("elem 4", 35, elemList.get(4).getAtomicNumber()); } } cmlxom-cmlxom-4.11/src/test/resources/000077500000000000000000000000001477224461000200225ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/checkstyle.xml000077500000000000000000000064751477224461000227210ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/000077500000000000000000000000001477224461000206115ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/000077500000000000000000000000001477224461000221055ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/000077500000000000000000000000001477224461000226605ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/base/000077500000000000000000000000001477224461000235725ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/base/cml0.xml000077500000000000000000000016301477224461000251520ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/base/cml0.xsd000077500000000000000000000026761477224461000251630ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/base/junk000077500000000000000000000000001477224461000244550ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/base/noSchema.xml000077500000000000000000000013531477224461000260560ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/000077500000000000000000000000001477224461000243115ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/000077500000000000000000000000001477224461000261275ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/complex/000077500000000000000000000000001477224461000275765ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/complex/4CDF.xml000077500000000000000000020470171477224461000310160ustar00rootroot00000000000000 100.000000000 0.00000000000 0.190000000000E-02 0.200000000000 0.155574000000E-02 0.679773000000E-02 75.589 37.795 18.897 1.571 1.571 1.571 molecule 250 128 64 100.0000 107.9597 7066.133151 1905.843841 1974.443343 164.738919 0.000001 0.000000 0.000000 -972.039097 0.000000 0.000000 0.000000 -3978.686175 -3993.146145 -3993.146145 -3978.6861754 -3993.1461445 -6.5675517 -3986.4110208 -3959.0983533 -1.2084810 -3970.4964952 -3962.6729751 -2.9733741 -3969.2967360 -3964.4021267 -3.8485510 -3969.1491046 -3965.5998373 -4.1173453 -3969.1177668 -3966.4821737 -4.2122838 -3969.1076716 -3967.1394950 -4.2494254 -3969.1039210 -3967.6309954 -4.2659876 -3969.1024757 -3967.9990532 -4.2741944 -3969.1018750 -3968.2748246 -4.2785335 -3969.1016342 -3968.4815596 -4.2809165 -3969.1015698 -3968.6366029 -4.2822145 -3969.1016044 -3968.7529170 -4.2829204 -3969.1014871 -3968.8399877 -4.2833099 -3969.1015241 -3968.9054066 -4.2834866 -3969.1015185 -3968.9544334 -4.2835733 -3969.1014995 -3968.9911871 -4.2836021 -3969.1014943 -3969.0187606 -4.2836014 -3969.1014485 -3969.0393985 -4.2835950 -3969.1014896 -3969.0549522 -4.2835694 -3969.1015084 -3969.0666054 -4.2835493 -3969.1015121 -3969.0753349 -4.2835355 -3969.1014932 -3969.0818603 -4.2835238 -3969.1015052 -3969.0867806 -4.2835074 -3969.1015410 -3969.0904975 -4.2834986 -3969.1015116 -3969.0932289 -4.2834864 -3969.1015074 -3969.0952954 -4.2834846 -3969.1015051 -3969.0968461 -4.2834817 -3969.098012 -3969.098012 0.066 0.218 0.170 1.267 -2.247 0.008 -0.301 0.800 0.022 0.772 2.589 0.004 -0.081 -1.374 -0.022 1.856 1.310 0.014 -0.499 0.995 -0.040 3.109 -1.727 0.043 -1.081 -0.271 0.004 3.014 -0.513 -0.002 3.017 2.902 -0.044 -2.058 3.334 -0.029 1.374 -0.933 -0.001 0.196 -0.059 -0.008 -0.146 0.332 0.022 -4.141 3.460 -0.035 -0.463 -0.158 -0.003 -5.358 0.651 0.009 -3.152 -4.346 0.036 2.124 -4.987 0.040 0.345 0.010 0.009 -0.005 -0.001 0.008 0.2084 0.0691 0.2084 75.589 37.795 18.897 1.571 1.571 1.571 -3970.0067582 -3969.9776084 -4.0521621 -3970.2260176 -3969.8358947 -5.3729061 -3969.9556349 -3969.8681180 -4.4761191 -3969.9494524 -3969.8888751 -4.4523121 -3969.9481671 -3969.9037023 -4.4400050 -3969.9479336 -3969.9148332 -4.4345795 -3969.9478419 -3969.9230876 -4.4317987 -3969.9478125 -3969.9292683 -4.4303091 -3969.9477993 -3969.9338979 -4.4294906 -3969.9477934 -3969.9373697 -4.4290372 -3969.9477870 -3969.9399700 -4.4287871 -3969.9478171 -3969.9419547 -4.4286317 -3969.9478055 -3969.9434087 -4.4285512 -3969.9478002 -3969.9445027 -4.4285043 -3969.9477791 -3969.9453060 -4.4284748 -3969.9477903 -3969.9459355 -4.4284552 -3969.9477818 -3969.9463906 -4.4284471 -3969.946731 0.539 0.213 0.149 0.792 -0.198 0.023 0.415 0.575 0.013 0.946 0.679 -0.000 -0.261 -0.484 -0.018 0.839 0.194 -0.002 0.845 0.616 -0.024 -0.578 0.576 0.017 -0.404 -0.801 0.007 -1.119 0.790 -0.003 -0.630 -0.872 -0.011 1.271 -0.711 0.013 0.843 0.781 0.003 0.492 0.082 -0.005 -0.185 0.447 0.019 -1.502 1.353 -0.019 -0.510 -0.115 -0.003 -2.118 0.226 0.005 -0.968 -1.477 0.017 0.679 -1.780 -0.009 0.473 -0.082 0.009 -0.005 0.000 0.007 0.0824 0.0265 0.0824 75.589 37.795 18.897 1.571 1.571 1.571 -3969.3822900 -3969.6486227 -4.0626703 -3970.1895583 -3968.7637746 -3.9673214 -3969.2036326 -3968.8821974 -4.8172939 -3969.1789004 -3968.9579798 -4.7786780 -3969.1745317 -3969.0124421 -4.7559512 -3969.1735592 -3969.0528656 -4.7466546 -3969.1732674 -3969.0829864 -4.7420310 -3969.1731661 -3969.1055257 -4.7396637 -3969.1731744 -3969.1224659 -4.7384187 -3969.1731271 -3969.1351029 -4.7377564 -3969.1731181 -3969.1446025 -4.7373872 -3969.1731310 -3969.1517452 -4.7371777 -3969.1731875 -3969.1571484 -4.7370503 -3969.1731828 -3969.1611537 -4.7369795 -3969.1731395 -3969.1641178 -4.7369393 -3969.1731379 -3969.1663716 -4.7369113 -3969.1731551 -3969.1680804 -4.7368932 -3969.1731484 -3969.1693424 -4.7368801 -3969.1731496 -3969.1702950 -4.7368729 -3969.1731341 -3969.1709932 -4.7368685 -3969.171533 1.402 0.209 0.118 -0.104 2.864 0.043 1.481 0.068 0.000 1.052 -2.282 -0.007 -0.542 1.035 -0.011 -0.763 -1.337 -0.024 2.954 0.176 -0.001 -4.868 2.747 -0.016 0.625 -1.519 0.011 -5.894 2.837 -0.009 -5.640 -5.124 0.039 6.422 -5.139 0.037 0.105 3.105 0.008 1.053 0.337 0.001 -0.243 0.637 0.015 1.127 -0.723 -0.002 -0.596 -0.051 -0.003 1.178 -0.221 0.003 1.159 1.274 -0.004 -0.753 1.323 -0.052 0.698 -0.232 0.007 -0.006 -0.001 0.006 0.2498 0.0782 0.2498 75.589 37.795 18.897 1.571 1.571 1.571 -3970.1120429 -3969.4258833 -5.0182039 -3970.6148628 -3969.7296796 -3.1616265 -3969.9961816 -3969.7973621 -4.4675750 -3969.9835636 -3969.8448134 -4.4534923 -3969.9813187 -3969.8791279 -4.4658388 -3969.9807728 -3969.9046087 -4.4716423 -3969.9806268 -3969.9236403 -4.4748757 -3969.9805287 -3969.9378300 -4.4766289 -3969.9805234 -3969.9485124 -4.4775603 -3969.9805740 -3969.9565700 -4.4780355 -3969.9805330 -3969.9625314 -4.4782902 -3969.9805486 -3969.9670479 -4.4784203 -3969.9805627 -3969.9704374 -4.4784813 -3969.9805455 -3969.9729515 -4.4785147 -3969.9805326 -3969.9748372 -4.4785280 -3969.9805414 -3969.9762699 -4.4785301 -3969.977336 0.691 0.212 0.143 0.636 0.402 0.027 0.621 0.495 0.011 0.982 0.113 -0.001 -0.316 -0.204 -0.017 0.535 -0.120 -0.006 1.246 0.517 -0.020 -1.501 1.096 0.010 -0.204 -0.948 0.008 -2.138 1.175 -0.004 -1.618 -1.806 -0.001 2.230 -1.694 0.021 0.694 1.253 0.004 0.589 0.128 -0.004 -0.196 0.482 0.018 -0.891 0.868 -0.015 -0.526 -0.102 -0.003 -1.363 0.123 0.004 -0.466 -0.823 0.012 0.344 -1.046 -0.019 0.513 -0.110 0.008 -0.005 0.000 0.007 0.0867 0.0301 0.0867 75.589 37.795 18.897 1.571 1.571 1.571 -3970.5080810 -3969.4319503 -4.4592147 -3971.1214815 -3970.1369358 -3.4028456 -3970.4121275 -3970.2087327 -4.7251581 -3970.4008827 -3970.2573327 -4.7960158 -3970.3999115 -3970.2930192 -4.8003696 -3970.3996687 -3970.3196261 -4.8003694 -3970.3996927 -3970.3396937 -4.7991288 -3970.3995930 -3970.3546045 -4.7981270 -3970.3996591 -3970.3659215 -4.7974329 -3970.3996667 -3970.3743650 -4.7970170 -3970.3996898 -3970.3807142 -4.7967515 -3970.3996402 -3970.3854087 -4.7966115 -3970.3996567 -3970.3889832 -4.7965083 -3970.3996705 -3970.3916655 -4.7964445 -3970.3996373 -3970.3936335 -4.7964165 -3970.3996230 -3970.3951202 -4.7963922 -3970.3996131 -3970.3962360 -4.7963819 -3970.3996203 -3970.3970875 -4.7963677 -3970.397710 0.793 0.447 0.088 -0.450 0.794 0.032 0.178 -1.121 0.001 0.012 -0.239 0.018 0.895 0.884 -0.007 0.138 -0.283 -0.011 -0.515 -0.348 -0.018 -0.687 0.564 0.015 -0.099 0.932 0.000 -0.873 -0.621 0.000 0.028 -0.126 -0.016 -0.222 -0.737 0.025 0.150 -0.266 0.014 0.797 0.206 -0.001 -0.048 0.604 0.015 -0.104 0.233 -0.008 -0.548 -0.177 -0.003 -0.601 0.195 0.003 -0.199 -0.460 0.007 0.301 -0.443 -0.025 0.759 -0.015 0.007 -0.011 0.001 0.005 0.0436 0.0167 0.0436 75.589 37.795 18.897 1.571 1.571 1.571 -3970.2599539 -3968.7116028 -4.6917161 -3972.7933011 -3968.8569631 -3.7705495 -3969.9271256 -3969.1111734 -3.8818348 -3969.8754142 -3969.3038873 -4.1112503 -3969.8722343 -3969.4461912 -4.1085309 -3969.8717079 -3969.5525491 -4.1096220 -3969.8716993 -3969.6324222 -4.1074944 -3969.8716640 -3969.6922358 -4.1058255 -3969.8716700 -3969.7371098 -4.1046959 -3969.8716509 -3969.7707351 -4.1039969 -3969.8716266 -3969.7959416 -4.1035611 -3969.8716297 -3969.8148668 -4.1032930 -3969.8716214 -3969.8290496 -4.1031251 -3969.8716137 -3969.8396850 -4.1030147 -3969.8716017 -3969.8476553 -4.1029499 -3969.8715787 -3969.8536189 -4.1029071 -3969.8715888 -3969.8581190 -4.1028744 -3969.8715859 -3969.8614836 -4.1028589 -3969.8715925 -3969.8640157 -4.1028406 -3969.8715591 -3969.8658766 -4.1028387 -3969.8715675 -3969.8673056 -4.1028265 -3969.868376 1.138 0.850 0.004 -1.828 1.579 0.038 -0.476 -3.732 -0.017 -1.424 -0.805 0.041 2.380 2.672 0.012 -0.495 -0.509 -0.019 -2.600 -1.416 -0.013 0.277 -0.200 0.013 -0.080 3.367 -0.008 0.691 -2.618 0.007 1.642 1.820 -0.024 -2.769 0.434 0.024 -0.517 -2.577 0.027 1.153 0.333 0.004 0.180 0.813 0.010 0.931 -0.630 0.007 -0.582 -0.290 -0.002 0.543 0.320 0.001 0.179 0.057 -0.000 0.255 0.426 -0.031 1.153 0.129 0.004 -0.010 0.001 0.003 0.1452 0.0470 0.1452 75.589 37.795 18.897 1.571 1.571 1.571 -3970.7121158 -3971.1809771 -4.2038717 -3972.5376423 -3969.6554658 -4.2887116 -3970.4436815 -3969.8371173 -5.0827390 -3970.4112839 -3969.9819096 -4.8688016 -3970.4088754 -3970.0888594 -4.8592883 -3970.4084189 -3970.1687652 -4.8573918 -3970.4082756 -3970.2286301 -4.8586161 -3970.4082106 -3970.2735067 -4.8597979 -3970.4082093 -3970.3071920 -4.8605662 -3970.4082145 -3970.3324555 -4.8610201 -3970.4082486 -3970.3514310 -4.8612598 -3970.4082261 -3970.3656136 -4.8613908 -3970.4082447 -3970.3762856 -4.8614421 -3970.4082757 -3970.3843065 -4.8614682 -3970.4082446 -3970.3902677 -4.8614784 -3970.4082322 -3970.3947496 -4.8614787 -3970.4082609 -3970.3981490 -4.8614673 -3970.4082406 -3970.4006567 -4.8614726 -3970.4082403 -3970.4025523 -4.8614635 -3970.4082110 -3970.4039450 -4.8614642 -3970.405033 0.824 0.497 0.077 -0.649 0.879 0.033 0.090 -1.446 -0.001 -0.176 -0.309 0.021 1.109 1.106 -0.004 0.060 -0.314 -0.012 -0.824 -0.500 -0.018 -0.543 0.460 0.015 -0.087 1.277 -0.001 -0.644 -0.930 0.001 0.298 0.172 -0.018 -0.630 -0.567 0.026 0.053 -0.563 0.016 0.842 0.222 -0.000 -0.019 0.628 0.015 0.039 0.115 -0.007 -0.552 -0.192 -0.003 -0.452 0.214 0.004 -0.146 -0.389 0.006 0.293 -0.326 -0.026 0.808 0.004 0.006 -0.012 0.002 0.005 0.0563 0.0191 0.0563 75.589 37.795 18.897 1.571 1.571 1.571 -3970.5752901 -3968.0416887 -4.6016460 -3970.7244475 -3970.4076508 -4.5226882 -3970.5218414 -3970.4430448 -4.5182970 -3970.5124790 -3970.4608983 -4.5311860 -3970.5113668 -3970.4736136 -4.5371366 -3970.5111948 -3970.4830805 -4.5396813 -3970.5110715 -3970.4900443 -4.5408153 -3970.5110700 -3970.4953192 -4.5413438 -3970.5110665 -3970.4992604 -4.5416262 -3970.5110608 -3970.5022090 -4.5417899 -3970.5110718 -3970.5044340 -4.5418840 -3970.5110791 -3970.5061012 -4.5419407 -3970.5110627 -3970.5073294 -4.5419788 -3970.5110916 -3970.5082917 -4.5420005 -3970.5110834 -3970.5089835 -4.5420152 -3970.5110302 -3970.5094553 -4.5420316 -3970.509856 -0.804 0.065 -0.015 1.581 -1.195 0.035 -0.747 1.328 0.007 0.696 -0.021 0.047 -1.603 -0.959 -0.009 -0.196 2.121 -0.008 -0.041 0.213 -0.007 0.095 0.394 0.005 0.336 -0.176 -0.002 0.538 -0.575 -0.003 -0.437 -0.799 0.003 -0.145 0.409 0.004 -0.205 -1.332 0.024 -0.053 -0.091 -0.009 -0.098 -0.266 0.021 -0.027 0.225 -0.003 0.251 0.077 -0.002 0.025 0.098 0.003 0.493 0.378 -0.006 0.014 0.102 -0.027 0.191 0.049 0.013 -0.005 0.002 0.003 0.0825 0.0219 0.0825 75.589 37.795 18.897 1.571 1.571 1.571 -3970.5754577 -3971.3955490 -4.6331125 -3970.5954016 -3970.5535573 -4.6376875 -3970.5684820 -3970.5581719 -4.6577754 -3970.5673173 -3970.5605577 -4.6506767 -3970.5671822 -3970.5622290 -4.6483907 -3970.5670669 -3970.5633767 -4.6473880 -3970.5671047 -3970.5643443 -4.6469485 -3970.5670658 -3970.5649979 -4.6467604 -3970.5671174 -3970.5655674 -4.6466420 -3970.5671206 -3970.5659584 -4.6465859 -3970.5670875 -3970.5662160 -4.6465548 -3970.5670682 -3970.5664146 -4.6465344 -3970.5670643 -3970.5665741 -4.6465166 -3970.566693 -0.305 0.228 0.018 0.758 -0.479 0.033 -0.465 0.480 0.004 0.390 -0.115 0.038 -0.583 -0.304 -0.008 -0.115 1.233 -0.009 -0.311 -0.040 -0.011 -0.135 0.420 0.009 0.198 0.317 -0.002 0.119 -0.701 -0.002 -0.184 -0.467 -0.005 -0.305 0.075 0.012 -0.118 -1.075 0.022 0.252 0.014 -0.006 -0.071 0.037 0.019 -0.000 0.185 -0.005 -0.029 -0.017 -0.002 -0.141 0.142 0.004 0.280 0.122 -0.001 0.111 -0.039 -0.027 0.406 0.031 0.011 -0.010 0.002 0.003 0.0479 0.0124 0.0479 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6443431 -3969.6658254 -4.8202547 -3970.8555897 -3970.5055340 -4.8341202 -3970.6055202 -3970.5331371 -4.9751294 -3970.6020592 -3970.5505885 -4.9065151 -3970.6017237 -3970.5633941 -4.8935890 -3970.6016214 -3970.5729345 -4.8894968 -3970.6015916 -3970.5800948 -4.8877736 -3970.6015922 -3970.5854761 -4.8868738 -3970.6015859 -3970.5895013 -4.8863557 -3970.6015851 -3970.5925226 -4.8860286 -3970.6016024 -3970.5948059 -4.8858209 -3970.6016542 -3970.5965570 -4.8856827 -3970.6016175 -3970.5977947 -4.8856049 -3970.6016256 -3970.5987585 -4.8855434 -3970.6015973 -3970.5994471 -4.8855094 -3970.599997 0.067 -0.748 -0.017 -0.416 1.188 0.020 0.180 -0.193 0.005 -0.451 -0.540 0.035 0.086 0.007 0.007 0.000 -0.793 -0.003 0.131 1.058 -0.008 0.047 -0.262 0.003 -0.238 -0.170 -0.002 0.186 0.583 -0.004 -0.154 -0.269 0.004 0.087 -0.824 0.006 0.228 0.645 0.024 -0.129 0.096 -0.010 -0.160 -0.205 0.018 -0.230 0.393 -0.002 0.415 0.190 -0.002 0.375 -0.095 0.001 0.112 -0.174 -0.002 -0.166 0.306 -0.027 -0.165 -0.092 0.017 -0.008 0.004 0.002 0.0462 0.0131 0.0462 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6343590 -3970.9672072 -4.8113342 -3970.6672890 -3970.6127294 -4.8140704 -3970.6282661 -3970.6170201 -4.7540032 -3970.6277930 -3970.6197675 -4.7780511 -3970.6276922 -3970.6217137 -4.7829799 -3970.6276683 -3970.6231936 -4.7845202 -3970.6277017 -3970.6243485 -4.7851675 -3970.6276678 -3970.6251539 -4.7855083 -3970.6276950 -3970.6258099 -4.7857041 -3970.6277172 -3970.6263036 -4.7858183 -3970.6276970 -3970.6266368 -4.7858998 -3970.6276800 -3970.6268849 -4.7859492 -3970.627066 -0.088 -0.363 -0.004 0.050 0.562 0.026 -0.060 0.053 0.004 -0.137 -0.379 0.036 -0.164 -0.108 0.002 -0.057 -0.030 -0.006 -0.043 0.636 -0.009 -0.023 0.005 0.005 -0.075 0.019 -0.002 0.169 0.087 -0.003 -0.166 -0.345 0.001 -0.062 -0.473 0.008 0.084 -0.029 0.024 0.021 0.067 -0.009 -0.126 -0.116 0.019 -0.137 0.311 -0.003 0.247 0.110 -0.003 0.177 -0.001 0.002 0.179 -0.055 -0.002 -0.059 0.177 -0.028 0.055 -0.041 0.014 -0.008 0.003 0.003 0.0247 0.0066 0.0247 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6490064 -3970.2072521 -4.8747182 -3970.7274550 -3970.5943109 -4.1742530 -3970.6337760 -3970.6047484 -4.6769655 -3970.6317099 -3970.6115389 -4.6748354 -3970.6314514 -3970.6165383 -4.6806043 -3970.6313807 -3970.6202398 -4.6819237 -3970.6313559 -3970.6230118 -4.6824385 -3970.6313656 -3970.6251110 -4.6826653 -3970.6313818 -3970.6266921 -4.6827850 -3970.6313876 -3970.6278708 -4.6828644 -3970.6313895 -3970.6287520 -4.6829143 -3970.6313591 -3970.6293810 -4.6829542 -3970.6313724 -3970.6298889 -4.6829650 -3970.6313746 -3970.6302619 -4.6829850 -3970.6313716 -3970.6305372 -4.6829939 -3970.6313688 -3970.6307429 -4.6829992 -3970.630919 -0.178 -0.036 0.001 -0.663 -1.098 -0.002 0.216 -0.388 0.010 -0.385 0.328 0.026 0.510 0.629 0.014 -0.010 0.543 -0.001 0.014 -0.245 0.005 0.072 0.377 -0.003 0.065 -0.217 -0.001 -0.013 -0.052 -0.000 0.482 0.556 -0.003 -0.067 0.535 -0.006 -0.183 -0.304 0.026 -0.135 0.074 -0.010 -0.057 0.379 0.011 0.027 0.097 0.002 0.072 0.089 -0.003 0.309 -0.065 0.000 -0.286 -0.580 0.001 0.127 -0.427 -0.020 -0.147 -0.060 0.017 -0.009 0.005 0.002 0.0427 0.0112 0.0427 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6506835 -3970.8355157 -4.6403582 -3970.6681360 -3970.6385493 -4.9720476 -3970.6474036 -3970.6409594 -4.7351423 -3970.6468729 -3970.6423868 -4.7350970 -3970.6468576 -3970.6435402 -4.7323968 -3970.6468309 -3970.6443526 -4.7317720 -3970.6468058 -3970.6449496 -4.7315224 -3970.6468218 -3970.6454304 -4.7314115 -3970.6468336 -3970.6457903 -4.7313474 -3970.6468284 -3970.6460460 -4.7313119 -3970.6467905 -3970.6462038 -4.7312918 -3970.6467861 -3970.6463460 -4.7312734 -3970.646452 -0.142 -0.190 -0.002 -0.340 -0.326 0.011 0.088 -0.179 0.007 -0.269 -0.000 0.031 0.210 0.288 0.008 -0.033 0.265 -0.003 -0.006 0.166 -0.002 0.027 0.204 0.001 -0.001 -0.105 -0.001 0.073 0.012 -0.002 0.168 0.121 -0.001 -0.057 0.056 0.000 -0.060 -0.184 0.024 -0.062 0.069 -0.009 -0.090 0.141 0.014 -0.052 0.196 -0.000 0.155 0.100 -0.003 0.247 -0.035 0.001 -0.061 -0.325 -0.000 0.034 -0.137 -0.023 -0.053 -0.051 0.015 -0.009 0.003 0.003 0.0132 0.0051 0.0132 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6631991 -3970.5888823 -4.7636742 -3970.6786308 -3970.6520752 -4.5291844 -3970.6602441 -3970.6543689 -4.7021395 -3970.6596947 -3970.6556739 -4.6984827 -3970.6596344 -3970.6566556 -4.7000672 -3970.6596220 -3970.6573948 -4.7001949 -3970.6596458 -3970.6579772 -4.7002509 -3970.6596847 -3970.6584338 -4.7002853 -3970.6596929 -3970.6587550 -4.7003230 -3970.6597116 -3970.6590081 -4.7003521 -3970.6597177 -3970.6591902 -4.7003695 -3970.659320 -0.231 0.025 0.006 0.123 0.072 0.004 -0.047 0.124 0.011 0.060 -0.146 0.019 -0.009 -0.145 0.009 -0.151 -0.178 -0.002 0.039 -0.132 0.004 -0.088 0.001 -0.002 0.132 0.322 -0.001 0.045 -0.109 0.001 -0.059 0.040 0.001 0.155 0.097 -0.002 -0.174 0.083 0.024 -0.098 0.071 -0.010 -0.057 0.364 0.011 0.044 0.091 0.002 0.017 0.034 -0.003 0.157 -0.042 0.001 0.003 -0.186 -0.002 0.022 -0.205 -0.021 -0.137 -0.058 0.017 -0.010 0.005 0.003 0.0142 0.0042 0.0142 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6596934 -3970.6594071 -4.7003413 -3970.659703 -0.232 0.025 0.006 0.123 0.072 0.004 -0.047 0.123 0.011 0.060 -0.146 0.019 -0.009 -0.145 0.009 -0.152 -0.178 -0.002 0.039 -0.133 0.004 -0.088 0.002 -0.002 0.133 0.322 -0.001 0.045 -0.109 0.001 -0.059 0.040 0.001 0.155 0.097 -0.002 -0.174 0.082 0.024 -0.099 0.071 -0.010 -0.057 0.364 0.011 0.044 0.091 0.002 0.017 0.034 -0.003 0.157 -0.042 0.001 0.002 -0.186 -0.002 0.022 -0.205 -0.021 -0.137 -0.058 0.017 -0.010 0.005 0.003 0.0142 0.0042 0.0142 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6720777 -3970.6180730 -4.6698857 -3970.6778676 -3970.6675601 -4.7853538 -3970.6708715 -3970.6685274 -4.7032940 -3970.6706573 -3970.6690738 -4.7029831 -3970.6706336 -3970.6694647 -4.7018042 -3970.6706351 -3970.6697617 -4.7015408 -3970.6706517 -3970.6699974 -4.7014751 -3970.6706501 -3970.6701597 -4.7014598 -3970.6706485 -3970.6702808 -4.7014544 -3970.6706024 -3970.6703266 -4.7014515 -3970.670412 -0.006 0.065 0.013 0.043 -0.097 -0.004 -0.076 -0.021 0.014 -0.077 0.249 0.013 -0.163 0.017 0.009 0.034 -0.118 0.001 -0.057 -0.042 0.004 0.029 0.180 -0.004 0.120 0.041 0.000 0.039 0.055 0.004 -0.017 -0.278 0.003 -0.007 -0.193 0.002 0.110 0.071 0.018 -0.161 0.048 -0.010 -0.054 0.191 0.011 0.076 0.024 0.003 -0.009 0.033 -0.003 -0.006 -0.044 0.000 0.111 0.028 -0.004 -0.032 -0.061 -0.018 -0.184 -0.047 0.018 -0.011 0.004 0.003 0.0108 0.0033 0.0108 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6566114 -3970.5804357 -4.6534641 -3970.6703004 -3970.6452013 -4.8250394 -3970.6532836 -3970.6475541 -4.7024017 -3970.6527299 -3970.6488662 -4.7022896 -3970.6526812 -3970.6498301 -4.7005782 -3970.6527003 -3970.6505703 -4.7002032 -3970.6526946 -3970.6510991 -4.7001252 -3970.6526774 -3970.6514813 -4.7001073 -3970.6527015 -3970.6518046 -4.7000983 -3970.6527014 -3970.6520288 -4.7000877 -3970.6526906 -3970.6521862 -4.7000846 -3970.652303 0.432 0.120 0.024 -0.082 -0.362 -0.016 -0.123 -0.253 0.018 -0.300 0.886 0.002 -0.408 0.273 0.009 0.331 -0.023 0.006 -0.211 0.099 0.004 0.207 0.481 -0.008 0.092 -0.419 0.003 0.031 0.322 0.008 0.060 -0.785 0.004 -0.275 -0.668 0.005 0.580 0.051 0.008 -0.262 0.009 -0.011 -0.051 -0.076 0.012 0.131 -0.084 0.004 -0.051 0.034 -0.004 -0.277 -0.048 -0.000 0.273 0.366 -0.008 -0.119 0.181 -0.013 -0.256 -0.029 0.019 -0.011 0.003 0.003 0.0345 0.0101 0.0345 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6739371 -3970.7339124 -4.7437226 -3970.6851434 -3970.6647100 -4.5884488 -3970.6713082 -3970.6666396 -4.6993228 -3970.6709170 -3970.6677703 -4.6993858 -3970.6708867 -3970.6685648 -4.7009595 -3970.6708512 -3970.6691166 -4.7012958 -3970.6708518 -3970.6695525 -4.7013736 -3970.6708228 -3970.6698488 -4.7013910 -3970.6708009 -3970.6700706 -4.7014042 -3970.6708347 -3970.6702870 -4.7014015 -3970.6708251 -3970.6704144 -4.7014105 -3970.670518 0.031 0.072 0.015 0.031 -0.122 -0.005 -0.081 -0.042 0.014 -0.098 0.309 0.012 -0.185 0.041 0.009 0.063 -0.109 0.002 -0.072 -0.029 0.004 0.046 0.207 -0.005 0.116 -0.002 0.001 0.038 0.080 0.004 -0.011 -0.326 0.003 -0.031 -0.237 0.002 0.153 0.068 0.017 -0.171 0.044 -0.010 -0.054 0.166 0.011 0.081 0.015 0.003 -0.014 0.033 -0.003 -0.030 -0.045 0.000 0.127 0.060 -0.004 -0.041 -0.040 -0.018 -0.191 -0.045 0.018 -0.011 0.004 0.003 0.0127 0.0038 0.0127 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6800096 -3970.6896361 -4.7229895 -3970.6880654 -3970.6727394 -4.9497229 -3970.6778596 -3970.6742343 -4.7895674 -3970.6774944 -3970.6750589 -4.7887987 -3970.6774173 -3970.6756335 -4.7874004 -3970.6774222 -3970.6760938 -4.7870561 -3970.6775136 -3970.6765197 -4.7868520 -3970.6774831 -3970.6767384 -4.7867378 -3970.6774783 -3970.6769200 -4.7866613 -3970.6774344 -3970.6770157 -4.7866080 -3970.6774470 -3970.6771330 -4.7865679 -3970.677211 0.267 0.109 0.015 -0.213 0.036 -0.008 -0.070 0.071 0.016 0.070 -0.099 0.004 0.052 0.019 0.008 -0.006 -0.024 0.000 0.081 0.164 0.003 0.112 -0.018 -0.003 -0.172 0.048 0.001 0.009 -0.317 0.009 0.147 0.124 -0.001 -0.039 0.005 0.002 -0.227 0.100 0.015 -0.110 0.046 -0.009 -0.047 -0.118 0.013 0.009 0.046 0.002 0.016 0.061 -0.003 -0.133 -0.035 -0.000 0.003 -0.041 -0.005 -0.006 -0.061 -0.013 -0.024 -0.037 0.017 -0.011 0.003 0.003 0.0123 0.0035 0.0123 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6779805 -3970.6741383 -4.7823072 -3970.6782599 -3970.6776417 -4.7367422 -3970.6778903 -3970.6777443 -4.7689499 -3970.6778671 -3970.6777689 -4.7690449 -3970.6778637 -3970.6777917 -4.7693239 -3970.6778517 -3970.6777981 -4.7693868 -3970.6778666 -3970.6778265 -4.7694283 -3970.677819 0.219 0.103 0.014 -0.165 0.005 -0.007 -0.072 0.048 0.015 0.035 -0.018 0.006 0.006 0.023 0.009 0.007 -0.041 0.001 0.052 0.128 0.003 0.101 0.027 -0.003 -0.115 0.038 0.001 0.016 -0.239 0.008 0.115 0.035 -0.000 -0.037 -0.043 0.002 -0.152 0.094 0.016 -0.124 0.046 -0.010 -0.050 -0.065 0.013 0.024 0.040 0.002 0.011 0.056 -0.003 -0.112 -0.037 -0.000 0.028 -0.021 -0.005 -0.013 -0.056 -0.014 -0.058 -0.038 0.017 -0.011 0.003 0.002 0.0093 0.0027 0.0093 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6830825 -3970.6135239 -4.7508557 -3970.6853784 -3970.6807910 -4.6395738 -3970.6822422 -3970.6811773 -4.7116598 -3970.6822039 -3970.6814760 -4.7144127 -3970.6821712 -3970.6816365 -4.7154978 -3970.6821374 -3970.6817391 -4.7158705 -3970.6821527 -3970.6818548 -4.7160449 -3970.6821541 -3970.6819310 -4.7161460 -3970.6821512 -3970.6819839 -4.7162158 -3970.6821506 -3970.6820252 -4.7162556 -3970.682072 -0.043 0.039 0.001 0.145 0.079 -0.001 0.022 -0.156 0.014 -0.007 0.139 0.010 -0.150 -0.005 0.004 -0.201 0.128 -0.003 0.175 -0.013 0.005 -0.035 -0.085 -0.002 -0.036 0.073 0.002 -0.150 0.149 0.010 0.012 -0.105 0.001 0.150 0.153 0.002 -0.149 -0.183 0.010 -0.008 0.041 -0.008 -0.011 -0.082 0.013 0.041 0.021 0.001 -0.041 0.052 -0.004 0.001 -0.103 -0.000 0.022 -0.006 -0.006 0.002 -0.029 -0.010 -0.017 -0.018 0.017 -0.011 0.004 0.002 0.0078 0.0030 0.0078 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6823952 -3970.6937530 -4.7196218 -3970.6824694 -3970.6823299 -4.7388795 -3970.6823695 -3970.6823369 -4.7264949 -3970.6823693 -3970.6823471 -4.7259923 -3970.6823610 -3970.6823447 -4.7258049 -3970.682332 -0.001 0.050 0.003 0.092 0.064 -0.002 0.005 -0.121 0.015 0.001 0.114 0.009 -0.124 -0.000 0.005 -0.166 0.099 -0.002 0.154 0.012 0.004 -0.011 -0.066 -0.002 -0.049 0.068 0.002 -0.121 0.082 0.010 0.031 -0.081 0.000 0.118 0.120 0.002 -0.150 -0.134 0.011 -0.028 0.042 -0.008 -0.017 -0.079 0.013 0.038 0.024 0.001 -0.032 0.053 -0.004 -0.019 -0.092 -0.000 0.023 -0.009 -0.006 -0.000 -0.034 -0.010 -0.024 -0.022 0.017 -0.011 0.003 0.002 0.0065 0.0025 0.0065 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6852755 -3970.6633926 -4.7471118 -3970.6917145 -3970.6809951 -4.6778847 -3970.6841172 -3970.6818318 -4.7315381 -3970.6839669 -3970.6823631 -4.7309580 -3970.6839541 -3970.6827654 -4.7307657 -3970.6839593 -3970.6830705 -4.7307535 -3970.6839443 -3970.6832783 -4.7307617 -3970.6839282 -3970.6834289 -4.7307660 -3970.6839243 -3970.6835499 -4.7307676 -3970.6839425 -3970.6836617 -4.7307698 -3970.683737 -0.132 0.008 -0.007 -0.073 0.006 0.002 0.039 0.062 0.012 -0.008 -0.064 0.011 0.088 -0.040 0.003 0.076 0.065 -0.002 -0.215 -0.049 0.002 0.044 0.072 -0.001 -0.006 -0.033 0.002 0.006 -0.058 0.011 -0.104 0.133 0.001 -0.055 -0.165 0.004 0.154 0.168 0.006 0.018 0.035 -0.007 0.027 -0.023 0.012 0.062 -0.000 0.000 -0.094 0.050 -0.003 -0.050 -0.095 0.000 0.008 -0.047 -0.007 -0.003 0.074 -0.009 -0.048 -0.011 0.018 -0.010 0.003 0.002 0.0083 0.0025 0.0083 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6849078 -3970.6914778 -4.7227455 -3970.6857322 -3970.6842491 -4.7487240 -3970.6847328 -3970.6844167 -4.7285219 -3970.6846919 -3970.6844700 -4.7287813 -3970.6846773 -3970.6845129 -4.7288614 -3970.6846948 -3970.6845718 -4.7288589 -3970.6847001 -3970.6846080 -4.7288599 -3970.684649 -0.082 0.025 -0.003 -0.014 0.028 0.001 0.025 -0.006 0.013 -0.004 0.000 0.010 0.008 -0.024 0.004 -0.012 0.078 -0.002 -0.078 -0.028 0.003 0.023 0.021 -0.001 -0.022 0.004 0.002 -0.040 -0.007 0.011 -0.055 0.054 0.001 0.010 -0.059 0.003 0.041 0.056 0.008 0.000 0.038 -0.007 0.011 -0.043 0.012 0.053 0.009 0.001 -0.071 0.051 -0.003 -0.038 -0.094 0.000 0.013 -0.032 -0.006 -0.002 0.034 -0.009 -0.039 -0.015 0.018 -0.011 0.003 0.002 0.0036 0.0013 0.0036 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6867503 -3970.7192855 -4.7463634 -3970.6916302 -3970.6839385 -4.7306415 -3970.6859528 -3970.6844342 -4.7416993 -3970.6859609 -3970.6848542 -4.7424179 -3970.6858862 -3970.6850592 -4.7424818 -3970.6859251 -3970.6853056 -4.7425388 -3970.6859112 -3970.6854467 -4.7425526 -3970.6859478 -3970.6855995 -4.7425386 -3970.685676 -0.014 0.003 -0.003 -0.105 0.083 0.002 -0.084 0.026 0.011 -0.019 -0.022 0.010 0.004 0.050 0.004 0.074 -0.097 -0.001 -0.026 0.055 0.001 -0.113 -0.060 0.001 0.034 -0.063 0.001 0.057 0.046 0.009 0.060 -0.061 0.002 -0.137 0.177 0.002 0.009 -0.060 0.007 0.003 0.042 -0.007 0.012 0.013 0.011 0.026 0.025 -0.000 -0.058 0.060 -0.003 -0.067 -0.070 0.001 0.011 -0.003 -0.007 0.040 -0.040 -0.007 0.028 -0.003 0.016 -0.010 0.004 0.002 0.0069 0.0020 0.0069 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6860548 -3970.6791325 -4.7391262 -3970.6862153 -3970.6859256 -4.7421168 -3970.6860161 -3970.6859587 -4.7400037 -3970.6859775 -3970.6859358 -4.7398704 -3970.685941 -0.027 0.006 -0.003 -0.088 0.073 0.002 -0.062 0.019 0.011 -0.017 -0.017 0.010 0.005 0.035 0.004 0.057 -0.062 -0.001 -0.036 0.038 0.001 -0.086 -0.044 0.000 0.023 -0.051 0.001 0.038 0.036 0.009 0.038 -0.038 0.002 -0.108 0.133 0.002 0.015 -0.038 0.008 0.003 0.041 -0.007 0.012 0.003 0.011 0.031 0.022 -0.000 -0.061 0.058 -0.003 -0.061 -0.074 0.001 0.011 -0.009 -0.007 0.032 -0.025 -0.008 0.016 -0.005 0.017 -0.010 0.004 0.002 0.0052 0.0016 0.0052 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6876889 -3970.6897653 -4.7353373 -3970.6885170 -3970.6871438 -4.7095401 -3970.6875401 -3970.6872305 -4.7251612 -3970.6874716 -3970.6872590 -4.7264377 -3970.6874620 -3970.6873055 -4.7267672 -3970.6874414 -3970.6873246 -4.7268867 -3970.6874489 -3970.6873615 -4.7269270 -3970.687377 -0.015 0.007 -0.001 -0.040 -0.012 0.002 -0.052 0.059 0.010 -0.025 -0.017 0.009 -0.039 0.031 0.005 0.015 -0.023 -0.001 0.023 -0.005 0.001 -0.059 -0.062 0.002 -0.017 -0.058 0.000 0.002 -0.003 0.008 -0.010 -0.022 0.003 -0.031 0.052 0.001 -0.017 -0.008 0.008 0.007 0.035 -0.006 0.009 0.045 0.010 -0.022 0.044 -0.001 -0.033 0.055 -0.002 -0.025 -0.059 0.002 0.013 0.009 -0.007 0.002 0.043 -0.006 0.051 -0.005 0.015 -0.010 0.004 0.002 0.0024 0.0011 0.0024 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6880376 -3970.6920552 -4.7199930 -3970.6899671 -3970.6864424 -4.6795011 -3970.6875810 -3970.6867891 -4.7039201 -3970.6875329 -3970.6869885 -4.7059957 -3970.6875212 -3970.6871202 -4.7065082 -3970.6875048 -3970.6872055 -4.7066904 -3970.6875488 -3970.6873247 -4.7067558 -3970.6875270 -3970.6873591 -4.7067960 -3970.6875427 -3970.6874168 -4.7068167 -3970.687414 0.011 0.014 0.002 0.041 -0.158 0.002 -0.034 0.124 0.007 -0.038 -0.017 0.007 -0.110 0.028 0.006 -0.048 0.035 -0.002 0.118 -0.075 0.002 -0.020 -0.090 0.005 -0.082 -0.073 -0.001 -0.057 -0.065 0.005 -0.087 0.005 0.005 0.092 -0.076 -0.000 -0.073 0.042 0.008 0.014 0.019 -0.005 0.005 0.115 0.009 -0.109 0.077 -0.003 0.012 0.055 -0.002 0.035 -0.031 0.003 0.014 0.036 -0.008 -0.044 0.150 -0.003 0.108 -0.004 0.014 -0.010 0.004 0.002 0.0062 0.0023 0.0062 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6880767 -3970.6851520 -4.7103639 -3970.6885593 -3970.6876221 -4.7312495 -3970.6878769 -3970.6876656 -4.7186993 -3970.6879210 -3970.6877759 -4.7176208 -3970.6878964 -3970.6877895 -4.7173549 -3970.6879440 -3970.6878643 -4.7172531 -3970.687824 -0.004 0.010 0.001 0.001 -0.083 0.002 -0.043 0.091 0.008 -0.031 -0.017 0.008 -0.074 0.030 0.005 -0.016 0.008 -0.002 0.069 -0.040 0.002 -0.039 -0.075 0.003 -0.049 -0.067 -0.000 -0.027 -0.033 0.007 -0.047 -0.008 0.004 0.028 -0.011 0.001 -0.045 0.016 0.008 0.013 0.029 -0.006 0.007 0.080 0.009 -0.064 0.059 -0.002 -0.011 0.055 -0.002 0.004 -0.045 0.002 0.013 0.021 -0.007 -0.020 0.094 -0.005 0.080 -0.004 0.014 -0.010 0.004 0.002 0.0037 0.0015 0.0037 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6897878 -3970.6487394 -4.7079825 -3970.6907709 -3970.6887384 -4.7235051 -3970.6894284 -3970.6889722 -4.7142719 -3970.6893929 -3970.6890803 -4.7131741 -3970.6893526 -3970.6891213 -4.7129711 -3970.6894048 -3970.6892319 -4.7128944 -3970.6894050 -3970.6892756 -4.7128854 -3970.6894219 -3970.6893250 -4.7128705 -3970.6894116 -3970.6893389 -4.7128696 -3970.689376 0.017 -0.063 0.004 0.022 0.013 0.001 -0.051 -0.072 0.004 -0.081 0.085 0.006 0.037 -0.064 0.006 0.028 -0.098 -0.001 -0.079 -0.016 0.000 0.054 0.059 0.004 -0.151 0.077 -0.001 -0.009 0.034 0.004 0.043 0.047 0.004 -0.020 -0.008 0.000 0.035 0.005 0.007 -0.002 -0.001 -0.005 -0.010 0.039 0.008 -0.050 0.001 -0.002 -0.028 0.015 -0.001 0.022 -0.017 0.004 -0.030 -0.009 -0.007 -0.009 0.072 -0.002 0.024 0.015 0.013 -0.009 0.004 0.002 0.0059 0.0016 0.0059 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6894726 -3970.6930888 -4.7136904 -3970.6894745 -3970.6894569 -4.7121929 -3970.6894843 -3970.6894803 -4.7130801 -3970.689492 0.014 -0.057 0.004 0.019 0.005 0.002 -0.050 -0.057 0.005 -0.077 0.076 0.006 0.027 -0.056 0.006 0.024 -0.089 -0.001 -0.066 -0.018 0.000 0.046 0.046 0.004 -0.140 0.063 -0.001 -0.011 0.028 0.004 0.035 0.042 0.004 -0.016 -0.008 0.000 0.028 0.006 0.007 -0.001 0.001 -0.005 -0.008 0.042 0.008 -0.051 0.006 -0.002 -0.026 0.018 -0.002 0.020 -0.019 0.004 -0.026 -0.006 -0.007 -0.010 0.075 -0.002 0.030 0.013 0.014 -0.009 0.004 0.002 0.0055 0.0014 0.0055 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6906874 -3970.6507660 -4.7010159 -3970.6920853 -3970.6893935 -4.7246920 -3970.6902475 -3970.6896227 -4.7129579 -3970.6902556 -3970.6898328 -4.7101943 -3970.6902688 -3970.6899584 -4.7096507 -3970.6902756 -3970.6900441 -4.7094625 -3970.6902368 -3970.6900635 -4.7093981 -3970.6902360 -3970.6901062 -4.7093574 -3970.690146 -0.002 -0.047 0.006 0.009 -0.051 0.002 -0.004 -0.031 0.003 0.039 -0.108 0.003 -0.126 0.085 0.005 -0.023 0.035 -0.001 0.059 0.018 0.002 -0.101 0.122 0.003 0.093 0.006 0.002 -0.012 -0.028 0.002 -0.011 0.009 0.002 0.015 0.110 0.001 -0.015 0.078 0.007 -0.023 -0.029 -0.005 -0.025 -0.044 0.007 0.010 -0.055 -0.001 -0.082 -0.018 -0.001 0.001 0.007 0.005 -0.015 0.031 -0.007 0.021 -0.020 -0.001 -0.028 0.033 0.013 -0.009 0.004 0.002 0.0049 0.0017 0.0049 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6904569 -3970.7024225 -4.7130378 -3970.6906242 -3970.6903584 -4.7057243 -3970.6904919 -3970.6904299 -4.7092974 -3970.6904695 -3970.6904276 -4.7101639 -3970.6904426 -3970.6904118 -4.7103397 -3970.6904990 -3970.6904761 -4.7103904 -3970.690440 0.002 -0.051 0.005 0.013 -0.033 0.002 -0.018 -0.039 0.003 0.002 -0.050 0.004 -0.079 0.041 0.005 -0.009 -0.004 -0.001 0.019 0.008 0.001 -0.055 0.099 0.003 0.021 0.024 0.001 -0.011 -0.010 0.003 0.004 0.019 0.003 0.006 0.073 0.001 -0.002 0.056 0.006 -0.016 -0.020 -0.005 -0.021 -0.017 0.008 -0.009 -0.036 -0.001 -0.066 -0.006 -0.001 0.007 -0.002 0.005 -0.019 0.019 -0.007 0.011 0.010 -0.001 -0.010 0.026 0.013 -0.009 0.004 0.002 0.0038 0.0011 0.0038 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6914405 -3970.6558474 -4.7168714 -3970.6922692 -3970.6908194 -4.7328447 -3970.6913369 -3970.6910186 -4.7229711 -3970.6912832 -3970.6910646 -4.7225701 -3970.6912826 -3970.6911205 -4.7221631 -3970.6912596 -3970.6911383 -4.7220901 -3970.691150 -0.025 -0.006 0.004 -0.053 -0.034 0.002 0.015 0.072 0.003 -0.011 -0.016 0.003 0.029 -0.021 0.004 -0.023 0.009 -0.001 -0.005 0.025 0.002 0.021 -0.049 0.003 0.011 0.105 0.002 -0.017 -0.028 0.002 -0.022 -0.038 0.001 0.026 0.033 0.002 0.025 -0.002 0.006 -0.015 -0.029 -0.004 -0.013 -0.038 0.007 -0.065 0.020 -0.002 -0.040 -0.005 -0.001 -0.024 0.015 0.005 0.004 0.047 -0.006 0.008 0.016 -0.000 -0.039 0.040 0.012 -0.008 0.004 0.002 0.0041 0.0011 0.0041 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6899104 -3970.6333445 -4.7322640 -3970.6920367 -3970.6883268 -4.7580018 -3970.6894442 -3970.6886320 -4.7420236 -3970.6893975 -3970.6888394 -4.7413665 -3970.6893592 -3970.6889451 -4.7407222 -3970.6893731 -3970.6890634 -4.7406012 -3970.6893526 -3970.6891205 -4.7405727 -3970.689210 -0.067 0.059 0.002 -0.156 -0.035 0.003 0.066 0.253 0.001 -0.035 0.040 0.002 0.196 -0.120 0.001 -0.047 0.027 -0.001 -0.044 0.055 0.003 0.146 -0.287 0.003 -0.001 0.235 0.004 -0.030 -0.058 0.001 -0.063 -0.130 -0.003 0.057 -0.038 0.003 0.070 -0.110 0.003 -0.014 -0.044 -0.003 -0.003 -0.070 0.005 -0.156 0.109 -0.002 -0.002 -0.001 -0.000 -0.072 0.041 0.006 0.040 0.091 -0.005 0.003 0.027 0.001 -0.085 0.063 0.011 -0.008 0.004 0.001 0.0112 0.0033 0.0112 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6918051 -3970.7455078 -4.7302725 -3970.6938301 -3970.6902637 -4.7063215 -3970.6914167 -3970.6906328 -4.7210183 -3970.6913441 -3970.6908056 -4.7215505 -3970.6913025 -3970.6909031 -4.7221814 -3970.6912925 -3970.6909938 -4.7222949 -3970.6912833 -3970.6910595 -4.7223232 -3970.691109 -0.025 -0.005 0.004 -0.056 -0.033 0.002 0.015 0.077 0.003 -0.012 -0.016 0.003 0.032 -0.022 0.004 -0.024 0.008 -0.001 -0.006 0.026 0.002 0.024 -0.054 0.003 0.009 0.107 0.002 -0.017 -0.029 0.002 -0.024 -0.040 0.001 0.026 0.031 0.002 0.027 -0.004 0.005 -0.015 -0.029 -0.004 -0.013 -0.039 0.007 -0.066 0.021 -0.002 -0.038 -0.005 -0.001 -0.024 0.016 0.005 0.004 0.047 -0.006 0.008 0.016 -0.000 -0.040 0.040 0.012 -0.008 0.004 0.002 0.0042 0.0011 0.0042 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6922130 -3970.6813111 -4.7130704 -3970.6936001 -3970.6913122 -4.7225794 -3970.6920099 -3970.6914935 -4.7134336 -3970.6919683 -3970.6916147 -4.7152176 -3970.6919685 -3970.6917084 -4.7149990 -3970.6919617 -3970.6917676 -4.7149885 -3970.6919601 -3970.6918148 -4.7149841 -3970.691846 -0.040 0.033 0.001 -0.015 0.039 0.003 -0.032 -0.030 0.001 -0.013 0.050 0.003 -0.020 0.037 0.002 -0.057 -0.010 -0.001 0.012 -0.010 0.003 -0.010 0.049 0.001 0.005 -0.078 0.004 0.025 0.032 0.002 0.034 0.024 -0.002 -0.006 -0.058 0.003 0.005 -0.048 0.004 -0.014 -0.038 -0.004 -0.006 -0.018 0.005 -0.033 0.001 -0.001 0.031 0.024 -0.000 -0.042 0.025 0.005 -0.016 0.001 -0.005 0.007 0.028 0.001 -0.020 0.048 0.011 -0.008 0.004 0.001 0.0030 0.0010 0.0030 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6919674 -3970.6937235 -4.7167026 -3970.6920999 -3970.6920175 -4.7149676 -3970.6920371 -3970.6920183 -4.7166527 -3970.6920673 -3970.6920545 -4.7163060 -3970.6920531 -3970.6920436 -4.7163523 -3970.692066 -0.038 0.026 0.002 -0.023 0.025 0.003 -0.023 -0.010 0.001 -0.013 0.038 0.003 -0.009 0.026 0.002 -0.051 -0.007 -0.001 0.009 -0.004 0.003 -0.004 0.030 0.001 0.005 -0.043 0.004 0.018 0.021 0.002 0.023 0.012 -0.001 0.000 -0.042 0.003 0.008 -0.042 0.005 -0.012 -0.037 -0.004 -0.007 -0.022 0.005 -0.039 0.005 -0.001 0.018 0.019 -0.001 -0.038 0.023 0.005 -0.012 0.010 -0.005 0.007 0.025 0.001 -0.023 0.047 0.011 -0.008 0.004 0.001 0.0020 0.0008 0.0020 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6927192 -3970.7224438 -4.7216294 -3970.6939053 -3970.6919050 -4.7356703 -3970.6924954 -3970.6920568 -4.7230052 -3970.6924388 -3970.6921355 -4.7252957 -3970.6924513 -3970.6922271 -4.7251085 -3970.6924264 -3970.6922589 -4.7250835 -3970.6924795 -3970.6923541 -4.7250422 -3970.692337 -0.005 0.058 -0.000 -0.008 0.035 0.003 0.011 0.018 0.001 0.007 -0.073 0.001 -0.025 -0.029 0.001 0.024 -0.007 0.001 -0.065 0.002 0.003 -0.042 -0.006 0.001 -0.020 0.008 0.003 -0.056 0.004 0.001 0.008 0.030 -0.003 -0.017 -0.007 0.003 -0.085 0.069 0.005 -0.030 -0.047 -0.003 0.008 0.014 0.004 -0.001 -0.016 0.000 0.041 0.022 0.000 0.020 0.018 0.005 -0.012 -0.001 -0.004 0.028 -0.038 0.001 0.026 0.040 0.010 -0.008 0.004 0.001 0.0033 0.0011 0.0033 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6925228 -3970.6886569 -4.7243627 -3970.6924983 -3970.6924668 -4.7225685 -3970.6924749 -3970.6924679 -4.7241622 -3970.6925188 -3970.6925140 -4.7238771 -3970.692513 -0.010 0.054 -0.000 -0.010 0.034 0.003 0.007 0.015 0.001 0.004 -0.060 0.001 -0.023 -0.022 0.001 0.016 -0.007 0.000 -0.056 0.001 0.002 -0.037 -0.002 0.001 -0.017 0.002 0.003 -0.048 0.005 0.001 0.010 0.028 -0.002 -0.014 -0.012 0.003 -0.075 0.056 0.005 -0.028 -0.045 -0.003 0.006 0.010 0.004 -0.006 -0.013 0.000 0.039 0.022 0.000 0.012 0.018 0.005 -0.012 0.000 -0.004 0.025 -0.030 0.001 0.021 0.041 0.010 -0.008 0.004 0.001 0.0029 0.0009 0.0029 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6931206 -3970.7045035 -4.7226584 -3970.6932768 -3970.6929048 -4.7070856 -3970.6930700 -3970.6929900 -4.7147426 -3970.6930912 -3970.6930353 -4.7166489 -3970.6930750 -3970.6930335 -4.7169011 -3970.693039 0.017 0.009 -0.001 -0.024 -0.017 0.002 -0.005 -0.014 0.001 -0.020 0.047 0.001 -0.016 -0.014 0.001 0.006 0.039 0.001 -0.055 -0.006 0.003 -0.045 -0.034 0.001 -0.012 0.025 0.002 -0.021 0.023 0.001 -0.043 0.002 -0.003 -0.011 0.021 0.002 -0.036 0.020 0.004 -0.016 -0.038 -0.003 0.012 0.029 0.003 0.005 -0.016 0.001 0.022 0.012 0.000 0.016 0.016 0.005 0.003 0.011 -0.003 0.030 -0.056 0.001 0.013 0.041 0.009 -0.007 0.004 0.001 0.0022 0.0008 0.0022 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6931401 -3970.7114555 -4.7151807 -3970.6936760 -3970.6927317 -4.6905616 -3970.6930342 -3970.6928317 -4.7026672 -3970.6929865 -3970.6928449 -4.7057116 -3970.6930110 -3970.6929059 -4.7060985 -3970.6929612 -3970.6928826 -4.7062567 -3970.692939 0.057 -0.051 -0.004 -0.052 -0.092 0.001 -0.026 -0.062 -0.000 -0.058 0.218 0.001 -0.003 -0.001 0.002 -0.008 0.110 0.003 -0.055 -0.021 0.002 -0.056 -0.086 0.001 -0.009 0.065 0.001 0.021 0.049 -0.000 -0.128 -0.039 -0.004 -0.003 0.069 0.001 0.025 -0.045 0.004 -0.002 -0.034 -0.002 0.022 0.061 0.002 0.022 -0.019 0.001 -0.006 -0.006 0.001 0.023 0.013 0.005 0.026 0.028 -0.002 0.038 -0.096 0.002 0.005 0.039 0.008 -0.007 0.004 0.001 0.0085 0.0019 0.0085 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6931744 -3970.6830316 -4.7072601 -3970.6933238 -3970.6930498 -4.7206639 -3970.6931518 -3970.6930924 -4.7141362 -3970.6931769 -3970.6931355 -4.7124775 -3970.6931677 -3970.6931370 -4.7122634 -3970.693111 0.033 -0.019 -0.003 -0.035 -0.056 0.001 -0.014 -0.036 0.000 -0.037 0.129 0.001 -0.010 -0.009 0.001 -0.000 0.071 0.002 -0.055 -0.014 0.002 -0.051 -0.057 0.001 -0.011 0.044 0.002 -0.001 0.035 0.000 -0.083 -0.017 -0.003 -0.007 0.043 0.002 -0.007 -0.009 0.004 -0.009 -0.034 -0.002 0.017 0.044 0.003 0.013 -0.017 0.001 0.009 0.004 0.000 0.020 0.015 0.005 0.013 0.019 -0.003 0.034 -0.074 0.002 0.010 0.040 0.009 -0.007 0.004 0.001 0.0050 0.0013 0.0050 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6942547 -3970.7161757 -4.7149323 -3970.6944585 -3970.6940509 -4.7024036 -3970.6941439 -3970.6940417 -4.7139566 -3970.6941267 -3970.6940589 -4.7124616 -3970.6941604 -3970.6941112 -4.7124744 -3970.6941411 -3970.6941046 -4.7124574 -3970.694091 0.042 -0.030 -0.004 -0.014 0.015 -0.001 -0.020 0.009 0.000 0.002 0.076 -0.001 -0.020 0.005 0.002 -0.064 0.022 0.003 -0.018 0.004 0.002 -0.028 -0.025 0.001 -0.011 -0.014 0.001 0.020 -0.019 -0.001 -0.074 0.012 -0.003 -0.023 -0.009 0.000 0.025 0.040 0.004 0.020 -0.015 -0.002 0.011 0.046 0.001 0.013 -0.015 0.002 -0.027 -0.016 0.001 0.011 0.020 0.004 0.000 -0.006 -0.002 0.008 -0.038 0.004 -0.006 0.033 0.008 -0.006 0.004 0.001 0.0030 0.0009 0.0030 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6941125 -3970.7291878 -4.7167898 -3970.6946070 -3970.6935724 -4.6972506 -3970.6939218 -3970.6936645 -4.7154893 -3970.6938944 -3970.6937235 -4.7130624 -3970.6939076 -3970.6937832 -4.7130894 -3970.6939053 -3970.6938128 -4.7130455 -3970.6938873 -3970.6938182 -4.7130285 -3970.6938968 -3970.6938450 -4.7130168 -3970.693828 0.068 -0.045 -0.006 0.027 0.114 -0.003 -0.026 0.084 0.000 0.057 -0.007 -0.003 -0.033 0.021 0.002 -0.166 -0.055 0.006 0.042 0.032 0.002 0.007 0.030 0.002 0.004 -0.113 -0.000 0.055 -0.104 -0.002 -0.061 0.060 -0.003 -0.047 -0.093 -0.003 0.078 0.121 0.003 0.068 0.017 -0.000 0.002 0.050 -0.001 0.013 -0.011 0.004 -0.080 -0.048 0.001 -0.002 0.029 0.003 -0.020 -0.046 0.000 -0.034 0.020 0.007 -0.033 0.023 0.005 -0.003 0.003 0.000 0.0065 0.0019 0.0065 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6943813 -3970.6722568 -4.7103146 -3970.6946004 -3970.6942087 -4.7223848 -3970.6943931 -3970.6942947 -4.7111341 -3970.6944010 -3970.6943358 -4.7126073 -3970.6943695 -3970.6943221 -4.7125979 -3970.6943493 -3970.6943141 -4.7126265 -3970.694322 0.052 -0.036 -0.005 0.000 0.051 -0.002 -0.022 0.038 0.000 0.021 0.044 -0.001 -0.027 0.011 0.002 -0.106 -0.009 0.005 0.005 0.015 0.002 -0.016 -0.003 0.001 -0.003 -0.054 0.000 0.033 -0.053 -0.001 -0.069 0.032 -0.003 -0.031 -0.041 -0.001 0.046 0.065 0.003 0.039 -0.002 -0.001 0.007 0.048 0.000 0.014 -0.014 0.003 -0.047 -0.028 0.001 0.006 0.024 0.004 -0.008 -0.022 -0.001 -0.008 -0.016 0.005 -0.017 0.029 0.007 -0.005 0.003 0.001 0.0041 0.0011 0.0041 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6948030 -3970.6571223 -4.7084429 -3970.6979423 -3970.6926045 -4.7035551 -3970.6941458 -3970.6930099 -4.7136302 -3970.6941081 -3970.6933070 -4.7090421 -3970.6940993 -3970.6935055 -4.7090892 -3970.6941043 -3970.6936606 -4.7090539 -3970.6941019 -3970.6937695 -4.7090513 -3970.6941122 -3970.6938631 -4.7090432 -3970.693910 -0.036 0.138 -0.004 0.036 -0.079 -0.003 0.040 -0.007 -0.000 -0.016 -0.080 -0.004 0.078 -0.018 0.001 0.101 0.013 0.006 -0.097 0.109 0.001 0.079 -0.026 0.002 -0.079 0.010 -0.001 -0.078 0.140 -0.002 0.142 -0.146 -0.003 0.015 0.121 -0.002 -0.105 -0.079 0.001 -0.035 -0.010 0.000 -0.005 0.007 -0.002 -0.023 0.013 0.004 -0.062 -0.051 0.002 0.037 0.016 0.002 -0.038 -0.039 0.000 -0.046 0.022 0.007 0.009 0.024 0.005 -0.003 0.003 0.000 0.0057 0.0022 0.0057 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6950391 -3970.7139279 -4.7113063 -3970.6958964 -3970.6943562 -4.7137014 -3970.6949033 -3970.6945748 -4.7084915 -3970.6949012 -3970.6946697 -4.7109295 -3970.6948745 -3970.6947030 -4.7109037 -3970.6948700 -3970.6947418 -4.7109220 -3970.694756 0.011 0.045 -0.004 0.017 -0.015 -0.002 0.008 0.016 -0.000 0.005 -0.016 -0.003 0.022 -0.003 0.002 -0.009 0.002 0.005 -0.042 0.060 0.002 0.029 -0.013 0.002 -0.038 -0.024 -0.000 -0.018 0.036 -0.002 0.029 -0.050 -0.003 -0.010 0.035 -0.001 -0.025 0.001 0.002 0.005 -0.006 -0.001 0.002 0.028 -0.001 -0.002 -0.002 0.003 -0.054 -0.039 0.001 0.020 0.020 0.003 -0.022 -0.030 -0.000 -0.025 0.002 0.006 -0.003 0.025 0.006 -0.004 0.003 0.001 0.0023 0.0008 0.0023 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6954669 -3970.6574434 -4.7012121 -3970.6955870 -3970.6952619 -4.7134512 -3970.6953457 -3970.6952601 -4.7063517 -3970.6953207 -3970.6952661 -4.7055286 -3970.6953166 -3970.6952769 -4.7053238 -3970.6952919 -3970.6952624 -4.7052437 -3970.695286 -0.021 0.025 -0.002 0.001 0.019 -0.002 0.025 -0.034 -0.001 0.001 0.012 -0.003 -0.007 0.016 0.000 0.033 0.048 0.004 0.034 0.010 0.002 -0.048 -0.013 0.001 -0.007 -0.001 0.000 0.042 -0.007 -0.001 -0.009 0.023 -0.002 0.034 -0.008 -0.001 -0.019 -0.029 0.000 -0.036 -0.010 0.000 -0.009 0.022 -0.001 0.004 -0.012 0.004 -0.030 -0.035 0.002 -0.011 0.023 0.002 -0.018 -0.029 0.000 -0.043 0.043 0.007 -0.008 0.020 0.005 -0.004 0.003 0.001 0.0019 0.0008 0.0019 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6944313 -3970.6339638 -4.6896382 -3970.6948401 -3970.6940134 -4.7093094 -3970.6942983 -3970.6940821 -4.6977727 -3970.6943141 -3970.6941759 -4.6964957 -3970.6942713 -3970.6941707 -4.6961798 -3970.6942934 -3970.6942186 -4.6960393 -3970.6942953 -3970.6942393 -4.6959868 -3970.6942829 -3970.6942410 -4.6959605 -3970.694258 -0.072 -0.018 0.002 -0.018 0.060 -0.001 0.052 -0.118 -0.001 -0.005 0.056 -0.004 -0.055 0.047 -0.002 0.102 0.121 0.001 0.155 -0.063 0.004 -0.173 -0.011 0.000 0.047 0.034 0.000 0.139 -0.075 -0.001 -0.069 0.137 -0.001 0.103 -0.075 -0.002 -0.011 -0.079 -0.003 -0.099 -0.014 0.001 -0.022 0.007 -0.002 0.014 -0.029 0.005 0.005 -0.028 0.002 -0.060 0.027 0.001 -0.011 -0.027 0.001 -0.071 0.110 0.008 -0.013 0.011 0.004 -0.002 0.003 0.000 0.0067 0.0023 0.0067 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6955444 -3970.7526279 -4.7108228 -3970.6958356 -3970.6950852 -4.6919627 -3970.6953467 -3970.6951488 -4.7029837 -3970.6952967 -3970.6951705 -4.7042010 -3970.6953142 -3970.6952225 -4.7045144 -3970.6953485 -3970.6952803 -4.7046403 -3970.6953237 -3970.6952727 -4.7047005 -3970.6953251 -3970.6952868 -4.7047279 -3970.695304 -0.023 0.023 -0.002 -0.000 0.021 -0.002 0.026 -0.038 -0.001 0.000 0.015 -0.003 -0.009 0.017 0.000 0.037 0.052 0.004 0.039 0.006 0.002 -0.053 -0.012 0.001 -0.005 0.000 0.000 0.047 -0.010 -0.001 -0.011 0.028 -0.002 0.037 -0.011 -0.001 -0.019 -0.031 -0.000 -0.040 -0.011 0.000 -0.009 0.022 -0.001 0.004 -0.013 0.004 -0.029 -0.034 0.002 -0.013 0.023 0.002 -0.017 -0.029 0.000 -0.044 0.046 0.007 -0.008 0.020 0.005 -0.004 0.003 0.001 0.0021 0.0008 0.0021 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6960090 -3970.6712710 -4.7064138 -3970.6965762 -3970.6955471 -4.7252396 -3970.6958568 -3970.6956286 -4.7094799 -3970.6958298 -3970.6956722 -4.7115839 -3970.6958569 -3970.6957406 -4.7113650 -3970.6958667 -3970.6957799 -4.7113051 -3970.6958522 -3970.6957871 -4.7112677 -3970.695816 -0.020 -0.016 0.001 -0.040 0.069 -0.000 0.041 0.031 -0.002 0.018 -0.002 -0.003 0.004 -0.022 -0.002 0.019 0.010 0.001 -0.016 -0.043 0.003 0.024 0.010 0.002 -0.017 0.015 0.000 -0.029 -0.029 -0.001 0.009 -0.021 -0.002 -0.053 0.003 -0.000 0.028 0.024 -0.002 -0.011 0.014 0.001 -0.017 0.005 -0.002 -0.026 0.004 0.004 0.014 -0.024 0.002 0.023 0.018 0.001 0.013 0.019 0.001 -0.021 0.007 0.006 -0.008 0.011 0.004 -0.003 0.003 0.001 0.0027 0.0008 0.0027 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6958591 -3970.6984251 -4.7110738 -3970.6958686 -3970.6958564 -4.7089932 -3970.6958612 -3970.6958584 -4.7107101 -3970.695847 -0.020 -0.013 0.001 -0.036 0.064 -0.000 0.039 0.024 -0.001 0.016 0.000 -0.003 0.003 -0.018 -0.001 0.020 0.015 0.002 -0.010 -0.037 0.003 0.016 0.007 0.002 -0.016 0.013 0.000 -0.021 -0.027 -0.001 0.006 -0.016 -0.002 -0.043 0.001 -0.000 0.023 0.017 -0.002 -0.013 0.012 0.001 -0.018 0.009 -0.002 -0.023 0.002 0.004 0.009 -0.025 0.002 0.020 0.019 0.001 0.010 0.014 0.001 -0.023 0.012 0.006 -0.008 0.012 0.004 -0.003 0.003 0.001 0.0025 0.0007 0.0025 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6961865 -3970.6780199 -4.7027093 -3970.6971653 -3970.6954740 -4.6805836 -3970.6959224 -3970.6955452 -4.6891506 -3970.6959619 -3970.6957035 -4.6932011 -3970.6959245 -3970.6957337 -4.6936472 -3970.6958898 -3970.6957473 -4.6938198 -3970.6958937 -3970.6957869 -4.6938782 -3970.695792 -0.007 0.057 0.002 0.006 -0.076 0.002 -0.077 -0.073 -0.003 0.025 0.013 -0.002 -0.036 0.052 -0.003 -0.021 0.006 -0.000 -0.005 0.022 0.002 -0.011 0.015 0.002 0.021 -0.030 0.001 0.051 0.063 -0.001 -0.044 -0.008 -0.001 0.026 0.061 0.001 -0.018 -0.023 -0.003 0.030 0.038 0.002 -0.029 -0.037 -0.002 -0.014 0.000 0.004 0.032 -0.011 0.003 0.002 0.013 0.000 0.017 0.019 0.001 -0.004 -0.022 0.005 0.010 0.001 0.003 -0.002 0.003 0.001 0.0030 0.0011 0.0030 75.589 37.795 18.897 1.571 1.571 1.571 -3970.6961430 -3970.7037389 -4.6972836 -3970.6963106 -3970.6959860 -4.7070419 -3970.6961022 -3970.6960295 -4.7032980 -3970.6960978 -3970.6960480 -4.7015069 -3970.6960945 -3970.6960578 -4.7013071 -3970.6960768 -3970.6960494 -4.7012347 -3970.696063 -0.013 0.025 0.001 -0.012 -0.017 0.001 -0.026 -0.031 -0.002 0.021 0.008 -0.002 -0.019 0.021 -0.002 -0.004 0.010 0.000 -0.007 -0.003 0.002 0.001 0.011 0.002 0.005 -0.012 0.001 0.020 0.024 -0.001 -0.022 -0.012 -0.001 -0.003 0.035 0.000 -0.001 -0.002 -0.003 0.012 0.026 0.002 -0.023 -0.019 -0.002 -0.018 0.001 0.004 0.022 -0.017 0.002 0.009 0.016 0.001 0.014 0.017 0.001 -0.013 -0.007 0.005 0.003 0.005 0.004 -0.002 0.003 0.001 0.0014 0.0005 0.0014 75.589 37.795 18.897 1.571 1.571 1.571 75.589 37.795 18.897 1.571 1.571 1.571 -4.70123 1 -2.111 -1.710 -1.662 -1.651 -1.604 -1.571 -1.529 -1.443 -1.406 -1.348 -1.326 -1.205 -1.193 -1.121 -1.067 -1.007 -0.978 -0.963 -0.893 -0.883 -0.870 -0.858 -0.840 -0.824 -0.787 -0.770 -0.754 -0.725 -0.715 -0.698 -0.694 -0.662 -0.633 -0.628 -0.600 -0.579 -0.572 -0.566 -0.556 -0.524 -0.487 -0.444 -0.434 -0.197 -0.146 -0.117 -0.110 -0.082 -0.053 -0.034 0.034 0.076 0.104 0.124 0.141 0.161 0.182 0.182 0.241 0.267 0.285 0.309 0.334 0.346 0.372 0.384 0.397 0.415 0.416 0.426 0.431 0.441 0.444 0.465 0.471 0.484 0.504 0.510 0.519 0.529 0.538 0.538 0.567 0.569 0.579 0.587 0.589 0.603 0.612 0.629 0.637 0.642 0.648 0.683 0.694 0.694 0.708 0.711 0.729 0.736 0.752 0.775 0.775 0.782 0.794 0.802 0.830 0.849 0.851 0.872 0.873 0.906 0.922 0.946 0.949 0.989 1.023 1.040 1.052 1.069 1.079 1.089 1.095 1.121 1.132 1.133 1.169 1.172 1.175 1.188 1.221 1.235 1.246 1.257 1.264 1.309 1.320 1.351 1.375 1.397 1.425 1.455 1.492 1.506 1.521 1.579 1.610 1.632 1.654 1.698 1.727 1.745 1.776 1.877 1.942 1.972 2.033 2.098 2.128 2.134 2.149 2.217 2.249 2.307 2.335 2.370 2.392 2.447 2.466 2.480 2.509 2.532 2.548 2.620 2.665 2.730 2.773 2.784 2.795 2.812 2.920 2.943 3.034 3.047 3.061 3.062 3.076 3.086 3.132 3.181 3.203 3.220 3.292 3.319 3.335 3.376 3.378 3.444 3.482 3.495 3.549 3.645 3.707 3.831 3.911 3.939 3.998 4.065 4.195 4.239 4.244 4.363 4.414 4.499 4.575 4.615 4.716 4.748 4.758 4.842 4.844 5.000 5.134 5.201 5.391 5.509 5.562 5.636 5.729 5.850 5.973 6.404 6.421 6.834 7.155 7.392 7.704 7.997 8.533 8.850 9.231 7066.133151 1909.227107 2255.429527 -4.829780 -79.950428 7.283934 0.000000 -991.723272 0.000000 0.000000 0.000000 -3970.696077 -3970.696063 -3970.696063 2255.429527 15305.800123 0.000000 -991.723272 -32710.410011 12170.207571 0.000000 -3970.696063 -0.000 -0.000 -0.000 -0.000 0.000 0.000 -0.000 0.000 -0.000 8000.0000 -0.0123 0.0045 -0.458 -0.364 -0.005 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/complex/TaC.xml000077500000000000000000000126571477224461000310050ustar00rootroot00000000000000 330.000000000 3.230 3.230 3.230 60.000 60.000 60.000 3.230 3.230 3.230 60.000 60.000 60.000 -2.92669908E+002 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/complex/castep2.xml000077500000000000000000000137461477224461000316770ustar00rootroot00000000000000 330.000000000 -0.125 -0.125 0.125 0.125 0.125 0.125 -0.375 0.125 0.125 -0.375 -0.125 0.375 -0.375 -0.125 0.125 0.375 0.125 0.125 -0.375 -0.375 0.375 -0.375 -0.375 0.125 0.375 0.375 0.125 0.375 0.375 0.375 3.230 3.230 3.230 60.000 60.000 60.000 3.230 3.230 3.230 60.000 60.000 60.000 -2.92669907E+002 -0.011403 0.000000 0.000000 0.000000 -0.011403 0.000000 0.000000 0.000000 -0.011403 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/complex/castep3.xml000077500000000000000000000170121477224461000316660ustar00rootroot00000000000000 300.000 0.333333 0.333333 0.333333 0.333333 0.333333 0.000000 0.333333 0.333333 -0.333333 0.333333 0.000000 0.000000 0.333333 0.000000 -0.333333 0.000000 0.000000 0.000000 6.450049 6.450049 6.450049 46.187747 46.187747 46.187747 6.686258 6.686258 6.686258 44.531023 44.531023 44.531023 -4.94191728E+003 -0.012139 0.000000 0.000000 0.000000 -0.012139 0.000000 0.000000 0.000000 -0.014096 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/complex/index.xml000077500000000000000000000014051477224461000314320ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/complex/spectrum4.xml000077500000000000000000000576641477224461000322730ustar00rootroot00000000000000 INSTITUTE OF ENERGY PROBLEMS OF CHEMICAL PHYSICS, RAS INEP CP RAS, NIST OSRD 109-99-9 199.1212 199.1212 199.1164 199.1164 199.1107 199.1107 199.1030 199.0977 199.0964 199.0898 199.0895 199.0893 199.0891 199.0858 199.0855 199.0853 199.0851 199.0680 199.0665 198.8244 198.8009 198.7893 198.6686 198.6686 198.6383 198.6079 198.5775 198.5775 198.5734 198.5682 198.5612 198.5612 198.5086 198.3795 198.2234 198.0650 198.0160 197.9815 197.9798 197.9307 197.7450 197.6996 197.6814 197.6768 197.6721 197.5620 197.5489 197.5115 197.5115 197.4962 197.4584 197.4496 197.4416 197.4416 197.3958 197.2085 197.1864 197.1478 196.9264 196.8891 196.8776 196.8642 196.6951 196.6504 196.6483 196.6300 196.3837 196.3827 196.3715 196.2983 196.2669 196.2646 196.2427 196.2318 196.2189 196.1948 196.1948 196.1942 196.1904 196.1549 196.0903 196.0689 196.0579 196.0466 196.0238 196.0233 196.0228 196.0224 196.0224 196.0220 196.0125 196.0011 195.9888 195.9877 195.9515 195.9144 195.8027 195.7443 195.6989 195.6894 195.6780 195.6656 195.6272 195.6173 195.6095 195.6095 195.6056 195.5929 195.5290 195.4507 195.4162 195.3820 195.3115 195.2401 195.2065 195.1937 195.1888 195.1888 195.1809 195.1681 195.1576 195.1264 195.0952 195.0952 195.0728 195.0623 195.0486 195.0234 195.0035 194.9902 194.9448 194.9314 194.8861 194.8726 194.8525 194.8397 194.8346 194.8268 194.8139 194.8139 194.7552 194.7167 194.6858 194.6858 194.5864 194.5243 194.4464 194.4464 194.4137 194.4092 194.4037 194.3963 194.3279 194.2690 194.2311 194.2311 194.1704 194.1097 194.0492 194.0492 193.9125 193.7814 193.6788 193.6788 193.6586 193.6455 193.6383 193.6171 193.6112 193.5941 193.5751 193.5751 193.5565 193.5559 193.5553 193.5548 193.4188 193.3674 193.3650 193.3375 193.3086 193.3000 193.2995 193.2990 193.2986 193.2798 193.2510 193.2510 193.2474 193.2430 193.2381 193.2367 193.2334 193.2279 193.2205 193.2205 193.1975 193.1522 193.1462 193.1070 193.0720 193.0617 193.0617 193.0528 193.0420 193.0304 192.9978 192.9978 192.9574 192.9139 192.8977 192.8647 192.8307 192.8301 192.7970 192.7963 192.7957 192.7950 192.7950 192.7945 192.6492 192.5792 192.5425 192.5241 192.5241 192.5209 192.4974 192.4743 192.4729 192.4438 192.4068 192.4065 192.4065 192.3980 192.3874 192.3758 192.3431 192.3427 192.3422 192.3418 192.3418 192.3330 192.2967 192.2596 192.2507 192.2029 192.1862 192.1862 192.1385 192.0899 192.0395 192.0395 192.0074 191.9946 191.9858 191.9623 191.9498 191.9380 191.9050 191.9050 191.8129 191.7387 191.6574 191.6185 191.6126 191.5864 191.5777 191.5671 191.5670 191.5557 191.5195 191.5195 191.4217 191.3059 191.2282 191.1958 191.1949 191.1624 191.1623 191.1521 191.1401 191.1273 191.1273 191.1270 191.0737 191.0187 190.9629 190.9629 190.9302 190.9144 190.9014 190.8727 190.8651 190.8447 190.8440 190.8358 190.8251 190.8140 190.8140 190.8135 190.7080 190.6003 190.5216 190.4919 190.4894 190.4598 190.4563 190.4470 190.4412 190.4342 190.4215 190.4215 190.3881 190.3877 190.3872 190.3868 190.3860 190.3292 190.3107 190.3104 190.3101 190.3098 190.2748 190.2715 190.2398 190.2307 190.2194 190.1972 190.1866 190.1742 190.1425 190.1425 190.0412 189.9046 189.7854 189.7654 189.7559 189.7445 189.7241 189.7233 189.7226 189.7218 189.7218 189.7054 189.6017 189.5381 189.4780 189.4602 189.4602 189.4570 189.4343 189.4106 189.2668 189.1305 189.0452 189.0452 189.0260 189.0174 189.0070 188.9957 188.9638 188.9635 188.9632 188.9629 188.9614 188.8633 188.8521 188.8082 188.7531 188.6990 188.6986 188.6983 188.6980 188.6980 188.6816 188.6816 188.6668 188.6666 188.6664 188.6662 188.6142 188.5460 188.4973 188.4765 188.4761 188.4761 188.4540 188.4306 188.4214 188.3659 188.3091 188.3088 188.3088 188.2884 188.2660 188.2427 188.2116 188.1800 188.1476 188.1135 188.0281 187.8859 187.8458 187.8029 187.7815 187.7809 187.7703 187.7601 187.7591 187.7479 187.7173 187.7173 187.6880 187.6579 187.6262 187.5954 187.5944 187.5400 187.4856 187.4313 187.3584 187.2482 187.1707 187.1707 187.1394 187.1389 187.1384 187.1378 187.1242 187.1033 187.0842 187.0768 187.0643 187.0426 187.0278 187.0278 186.9671 186.9048 186.8417 186.8417 186.6281 186.4786 186.3124 186.3124 186.2816 186.2500 186.2167 186.2167 186.1491 186.1084 186.0598 186.0297 185.9986 185.9667 185.9331 185.9331 185.8911 185.8491 185.8071 185.8071 185.7770 185.7460 185.7142 185.7134 185.6659 185.6127 185.5517 185.5517 185.5060 185.4594 185.4112 185.4112 185.2922 185.1870 185.1073 185.1073 185.0375 184.9965 184.9491 184.9491 184.8922 184.8345 184.7752 184.7752 184.6749 184.6234 184.5764 184.5764 184.5345 184.4925 184.4506 184.4506 184.1962 184.0557 183.8944 183.8944 183.7707 183.5478 183.3678 183.3678 183.2839 183.1985 183.1124 183.1124 182.9905 182.9000 182.7297 182.7297 182.6207 182.5274 182.4729 182.4729 182.4395 182.3726 182.3587 182.2779 182.2708 182.1972 182.1683 182.1683 182.0670 181.9177 181.7480 181.7189 181.6901 181.6895 181.6593 181.6276 181.6183 181.5430 181.3997 181.3997 181.3343 181.2689 181.2036 181.2036 181.1269 181.0734 180.9974 180.9653 180.8603 180.7810 180.7096 180.7096 180.6447 180.6190 180.5938 180.5798 180.5686 180.5434 180.5150 180.5150 180.4554 180.4508 180.4285 180.4281 180.4277 180.4273 180.4016 180.3918 180.3821 180.3723 180.3446 180.3260 180.3169 180.3057 180.2846 180.2414 180.0083 179.8316 179.6953 179.6187 179.5900 179.5842 179.5833 179.5767 179.5676 179.5606 179.5578 179.5296 179.5296 179.5069 179.4620 179.4202 179.3872 179.3608 179.3526 179.3321 179.3310 179.3173 179.3173 179.3122 179.3100 179.3062 179.2918 179.2845 179.2712 179.2710 179.2708 179.2707 179.2707 179.1969 179.1445 179.1443 179.1441 179.1439 179.1086 179.0494 179.0193 179.0187 179.0105 179.0092 178.9991 178.9889 178.9715 178.9326 178.9326 178.8477 178.7628 178.7348 178.6959 178.6780 178.6562 178.6495 178.6380 178.6322 178.6264 178.6149 178.6149 178.5410 178.4090 178.1352 178.1066 178.0368 177.9780 177.9657 177.9375 177.9363 177.9087 177.9082 177.8995 177.8919 177.8893 177.8782 177.8782 177.8374 177.8104 177.8055 177.8050 177.8045 177.8041 177.7878 177.7878 177.6645 177.5797 177.5058 177.5058 177.4923 177.4745 177.4675 177.4551 177.4349 177.4292 177.4071 177.3960 177.3909 177.3909 177.3849 177.3738 177.2469 177.1596 177.0934 177.0429 177.0151 177.0129 176.9866 176.9821 176.9747 176.9658 176.9565 176.9565 176.9561 176.9203 176.8559 176.7086 176.7066 176.6892 176.6808 176.6723 176.6710 176.6649 176.6622 176.6514 176.6514 176.6068 176.5960 176.5924 176.5893 176.5801 176.5248 176.4251 176.4100 176.4100 176.4069 176.3872 176.3667 176.3659 176.3262 176.2571 176.2567 176.2567 176.2397 176.2247 176.2208 176.2012 176.1913 176.1738 176.1650 176.1571 176.1571 176.1547 176.1436 176.1260 176.0711 175.9974 175.9249 175.9095 175.9095 175.8976 175.8702 175.8494 175.8429 175.7893 175.7293 175.7293 175.7024 175.6882 175.6844 175.6649 175.6463 175.6446 175.6030 175.6030 175.4998 175.4996 175.4994 175.4992 175.4391 175.3489 175.3214 175.3055 175.3055 175.2941 175.2661 175.2576 175.2365 175.1918 175.1532 175.1260 175.0980 175.0685 175.0273 175.0273 174.9750 174.9532 174.9527 174.9521 174.9515 174.9042 174.8617 174.8453 174.8416 174.8372 174.8313 174.2959 174.2957 174.2955 174.2954 174.2319 174.2239 174.2145 174.2043 174.2026 174.2022 174.2018 174.2015 174.0597 173.9785 173.9082 173.8216 173.8082 173.7947 173.7943 173.7943 173.7813 173.7698 173.7452 173.7207 173.7207 173.6946 173.6770 173.6578 173.6389 173.6380 173.5777 173.4846 173.4846 173.4292 173.3297 173.1944 173.1866 173.1804 173.1804 173.1774 173.1675 173.1532 173.1252 173.0957 173.0957 173.0925 173.0885 173.0831 173.0831 173.0128 172.9666 172.9050 172.9050 172.8599 172.8094 172.7100 172.7100 172.6973 172.6709 172.6437 172.6189 172.6150 172.5651 172.5024 172.5024 172.5021 172.5018 172.5015 172.4758 172.4554 172.4335 172.4109 172.4109 172.3877 172.3645 172.3413 172.3413 172.2100 172.1203 172.0685 172.0422 172.0152 171.9871 171.9871 171.9868 171.9617 171.9356 171.9081 171.9081 171.8782 171.8550 171.8423 171.8065 171.8004 171.7707 171.7452 171.7452 171.7153 171.6841 171.6521 171.6521 171.5631 171.4800 171.3961 171.3704 171.3068 171.2588 171.2202 171.2012 171.1903 171.1781 171.1656 171.1656 171.0744 170.9832 170.8922 170.8911 170.8669 170.8650 170.8567 170.8466 170.8382 170.8365 170.8365 170.8099 170.7809 170.7238 170.6661 170.6661 170.6487 170.6476 170.6318 170.6300 170.6152 170.6105 170.6105 170.5972 170.5368 170.4854 170.4125 170.4125 170.4121 170.3951 170.3767 170.3701 170.3576 170.3283 170.2512 170.2512 170.2219 170.1706 170.1186 170.0653 170.0303 169.8136 169.8026 169.7412 169.6785 169.6151 169.5394 169.5394 169.5302 169.5209 169.5117 169.5117 169.4958 169.4791 169.4610 169.4610 169.4254 169.3376 169.2281 169.2281 169.1947 169.1288 169.1254 169.0777 169.0293 168.9796 168.9796 168.9765 168.9727 168.9676 168.9553 168.9553 168.9431 168.9301 168.9158 168.9147 168.9076 168.8991 168.8909 168.8907 168.8905 168.8903 168.8903 168.8899 168.7949 168.7859 168.7199 168.6981 168.6539 168.6008 168.6008 168.5880 168.3198 168.0845 168.0720 168.0596 168.0472 167.9732 167.9327 167.9039 167.8737 167.8428 167.7507 167.7507 167.7256 167.6791 167.6326 167.5862 167.4693 167.4322 167.3944 167.3851 167.3552 167.0609 167.0486 167.0363 167.0334 167.0240 166.8589 166.8466 166.8335 166.8191 166.6868 166.3366 166.3258 166.2256 166.1255 166.0255 165.9743 165.9743 165.9227 165.8894 165.8562 165.8230 165.8002 165.7237 165.6957 165.6662 165.6362 165.5502 165.3995 165.3995 165.3751 165.3629 165.3501 165.3359 165.2252 165.2042 165.1832 165.1623 165.1262 165.0999 165.0849 165.0692 165.0522 164.9011 164.6585 164.6585 164.5958 164.4964 164.3877 164.3877 164.3406 164.3286 164.3159 164.3020 164.1512 164.0958 164.0839 164.0712 164.0573 163.9988 163.9751 163.9508 163.9252 163.8753 163.8636 163.8518 163.8401 163.7787 163.7631 163.7500 163.7463 163.7287 163.4367 163.4367 163.4129 163.4011 163.3893 163.3776 163.3587 163.2932 163.2697 163.2543 163.2455 163.2200 163.1946 163.1946 163.1708 163.1473 163.1427 163.1232 163.0993 163.0977 163.0753 163.0753 163.0513 163.0431 163.0242 163.0110 162.9959 162.9788 162.9788 162.9703 162.9668 162.9618 162.9533 162.9533 162.9293 162.9181 162.8973 162.8823 162.8652 162.8453 162.8453 162.8332 162.8104 162.8018 162.7931 162.7844 162.7121 162.6802 162.6482 162.6391 162.6163 162.5935 162.5382 162.4822 162.4249 162.3758 162.3188 161.9523 2.101893 2.101893 2.103183 2.103183 2.104424 2.104424 2.105568 2.023428 2.029936 2.062438 2.063674 2.064814 2.065905 2.082156 2.083448 2.084692 2.085839 2.170344 2.177494 2.120816 2.128324 2.121665 2.179248 2.179248 2.178582 2.177917 2.177252 2.177252 2.175508 2.173716 2.171826 2.171826 2.172450 2.166318 2.229950 2.191451 2.183256 2.182372 2.190814 2.347641 2.284857 2.251575 2.256116 2.279518 2.302919 2.373074 2.379569 2.373049 2.373049 2.378892 2.380174 2.374744 2.378215 2.378215 2.490011 2.419046 2.406907 2.406888 2.457267 2.457248 2.465686 2.474074 2.581448 2.583030 2.593864 2.577386 2.507483 2.512683 2.519981 2.573967 2.559432 2.572216 2.568946 2.559414 2.565628 2.559395 2.559395 2.562212 2.555155 2.550755 2.550457 2.550446 2.542423 2.550435 2.543272 2.545655 2.548039 2.550422 2.550422 2.552156 2.551059 2.549914 2.548672 2.553872 2.564688 2.575504 2.584942 2.582753 2.579078 2.578198 2.577270 2.576244 2.578175 2.579036 2.582499 2.582499 2.579897 2.580757 2.593125 2.595203 2.596799 2.594943 2.594634 2.594228 2.594211 2.595071 2.598536 2.598536 2.595931 2.596792 2.607613 2.616642 2.625575 2.625575 2.626206 2.621874 2.626787 2.627272 2.621619 2.625521 2.621316 2.625491 2.620917 2.625460 2.620899 2.622410 2.627174 2.623920 2.625430 2.625430 2.648707 2.657114 2.659602 2.659602 2.651148 2.646902 2.643226 2.643226 2.639525 2.640815 2.642056 2.643200 2.660677 2.681819 2.699890 2.699890 2.712202 2.724466 2.736634 2.736634 2.725976 2.711325 2.697651 2.697651 2.695040 2.698003 2.691996 2.688951 2.698258 2.685905 2.698464 2.698464 2.687619 2.690652 2.693686 2.696719 2.758271 2.790236 2.782064 2.773968 2.773728 2.775682 2.778218 2.780657 2.783049 2.773440 2.773055 2.773055 2.769153 2.765250 2.754196 2.761346 2.756079 2.757866 2.759604 2.759604 2.772161 2.771912 2.760207 2.771615 2.760762 2.771222 2.771222 2.768553 2.765786 2.762971 2.761220 2.761220 2.752435 2.745670 2.746865 2.746848 2.746830 2.735128 2.735977 2.739653 2.743280 2.746811 2.746811 2.749411 2.802346 2.824501 2.824040 2.834865 2.834865 2.824028 2.824016 2.828924 2.824003 2.821885 2.805982 2.807715 2.807715 2.802943 2.799904 2.796864 2.796847 2.799230 2.801614 2.803997 2.803997 2.807179 2.803973 2.806546 2.803949 2.803923 2.805865 2.805865 2.798680 2.791447 2.784117 2.784117 2.781499 2.784462 2.781857 2.782118 2.784711 2.782329 2.784912 2.784912 2.802721 2.822513 2.848707 2.861255 2.848683 2.859504 2.856465 2.853426 2.848658 2.850386 2.848633 2.848633 2.828757 2.809545 2.805354 2.805336 2.789083 2.805318 2.790799 2.795714 2.800531 2.805299 2.805299 2.807033 2.826507 2.845981 2.865454 2.865454 2.868037 2.865428 2.871055 2.874073 2.865401 2.873408 2.877092 2.871662 2.869866 2.865374 2.865374 2.867974 2.845316 2.825161 2.817542 2.804957 2.817524 2.804940 2.817506 2.809203 2.819232 2.813369 2.817488 2.817488 2.824621 2.827004 2.829388 2.831771 2.851049 2.882817 2.875070 2.876803 2.878537 2.880270 2.896504 2.914488 2.912737 2.897130 2.908601 2.904415 2.897756 2.900133 2.898382 2.898382 2.877339 2.855748 2.845963 2.845953 2.833379 2.845941 2.833361 2.837631 2.841804 2.845929 2.845929 2.848520 2.891082 2.912283 2.919474 2.930299 2.930299 2.919462 2.919450 2.919437 2.899574 2.876008 2.862678 2.862678 2.859850 2.857462 2.855073 2.852683 2.854399 2.856285 2.858074 2.859816 2.863635 2.865179 2.865975 2.865148 2.865118 2.859671 2.861557 2.863346 2.865088 2.865088 2.868762 2.868762 2.863337 2.864573 2.865712 2.866804 2.892771 2.916731 2.910050 2.910039 2.940594 2.940594 2.910027 2.910014 2.916662 2.892634 2.866606 2.868557 2.868557 2.866370 2.866085 2.865703 2.864819 2.865443 2.866019 2.866498 2.876973 2.895000 2.900588 2.900564 2.911387 2.915071 2.908773 2.900540 2.906110 2.903351 2.900517 2.900517 2.889168 2.877722 2.866227 2.864476 2.869893 2.869863 2.869833 2.869802 2.872386 2.881956 2.896744 2.896744 2.898460 2.901486 2.904463 2.907344 2.896493 2.905591 2.903566 2.896194 2.901444 2.899273 2.895797 2.895797 2.882914 2.869933 2.856903 2.856903 2.855291 2.860792 2.870907 2.870907 2.870665 2.870375 2.869987 2.869987 2.857741 2.852156 2.848444 2.845610 2.847752 2.849844 2.851840 2.851840 2.851816 2.851792 2.851768 2.851768 2.848870 2.845875 2.838280 2.842830 2.843389 2.847677 2.853356 2.853356 2.853106 2.852806 2.852410 2.852410 2.829901 2.805811 2.791126 2.791126 2.796520 2.801160 2.809022 2.809022 2.809631 2.810192 2.810656 2.810656 2.794578 2.787582 2.783670 2.783670 2.786897 2.790123 2.793349 2.793349 2.788796 2.778241 2.759873 2.759873 2.762794 2.765996 2.767584 2.767584 2.752302 2.736922 2.721494 2.721494 2.726287 2.730953 2.732972 2.732972 2.724456 2.715806 2.704866 2.704866 2.706797 2.704583 2.706749 2.706702 2.704250 2.706654 2.703820 2.703820 2.689145 2.670540 2.658714 2.658696 2.655862 2.659048 2.659303 2.659509 2.658332 2.662725 2.672809 2.672809 2.672770 2.672731 2.672692 2.672692 2.665856 2.659756 2.649165 2.646545 2.651402 2.657045 2.663511 2.663511 2.663472 2.666057 2.666042 2.663433 2.666027 2.666012 2.663394 2.663394 2.643494 2.620160 2.642539 2.644922 2.647306 2.649689 2.631687 2.625397 2.619107 2.612817 2.606516 2.604490 2.600215 2.602367 2.600195 2.601036 2.624461 2.653934 2.684325 2.690589 2.690572 2.705087 2.710504 2.700957 2.696779 2.690554 2.692503 2.690535 2.690535 2.673322 2.651279 2.641928 2.641683 2.635607 2.641389 2.637323 2.643607 2.640998 2.640998 2.643595 2.638747 2.639699 2.643583 2.645529 2.640103 2.641339 2.642479 2.643570 2.643570 2.681448 2.699402 2.700638 2.701777 2.702869 2.717366 2.739000 2.749600 2.753283 2.738976 2.746712 2.743728 2.740696 2.738952 2.738928 2.738928 2.717856 2.696784 2.695467 2.695443 2.675712 2.695419 2.677428 2.683481 2.697137 2.689485 2.695393 2.695393 2.726825 2.753503 2.770726 2.774392 2.764742 2.754737 2.758052 2.758035 2.744599 2.758017 2.745448 2.749713 2.759740 2.753880 2.757998 2.757998 2.832052 2.859115 2.840733 2.843758 2.846735 2.849616 2.864125 2.864125 2.850116 2.834589 2.818009 2.818009 2.815401 2.811858 2.818355 2.808218 2.804530 2.818604 2.804513 2.808776 2.818805 2.818805 2.812942 2.817060 2.865505 2.892311 2.909339 2.912202 2.911960 2.926702 2.911669 2.924732 2.921196 2.917563 2.911281 2.911281 2.913881 2.905078 2.887060 2.841781 2.854349 2.854338 2.842847 2.846735 2.854326 2.856273 2.850573 2.854314 2.854314 2.880581 2.956238 2.930822 2.905517 2.981505 3.006364 3.021681 3.030556 3.030556 3.021670 3.021657 3.021644 3.025817 3.018095 2.998171 3.000771 3.000771 2.993112 3.001121 2.987956 2.982750 3.001372 2.982733 2.988514 3.001575 3.001575 2.994198 2.999833 3.026151 3.063064 3.098014 3.105878 3.116703 3.116703 3.105861 3.105843 3.107997 3.105826 3.099291 3.090585 3.090585 3.087751 3.090928 3.087515 3.087229 3.091174 3.086847 3.091371 3.091371 3.120127 3.121363 3.122502 3.123594 3.148412 3.175498 3.173971 3.188264 3.188264 3.173954 3.173936 3.177438 3.173917 3.170020 3.164763 3.164745 3.164727 3.164708 3.168366 3.168366 3.187587 3.188038 3.191714 3.195341 3.198872 3.218738 3.233053 3.251896 3.252913 3.253833 3.254704 3.277763 3.278999 3.280138 3.281230 3.322578 3.324459 3.326243 3.327978 3.338812 3.341195 3.343579 3.345962 3.374692 3.379551 3.381961 3.379955 3.380588 3.381174 3.383621 3.383621 3.381662 3.391406 3.399192 3.406977 3.406977 3.403276 3.403265 3.403252 3.404973 3.403239 3.404428 3.404873 3.404873 3.414091 3.417405 3.414652 3.415513 3.419193 3.419193 3.416374 3.417235 3.423445 3.427600 3.431706 3.431706 3.430557 3.429310 3.428014 3.428014 3.426138 3.425434 3.425297 3.425297 3.428622 3.434882 3.449439 3.449439 3.445747 3.445730 3.445712 3.448866 3.445693 3.449280 3.451036 3.451036 3.452922 3.454712 3.456453 3.452969 3.451214 3.449410 3.447509 3.447509 3.449010 3.450512 3.452014 3.452014 3.452858 3.454693 3.457901 3.457883 3.457865 3.456113 3.456113 3.457847 3.450181 3.444152 3.438075 3.438075 3.441739 3.437815 3.441490 3.441194 3.437506 3.440800 3.437100 3.437100 3.434198 3.431200 3.428153 3.428153 3.428021 3.427171 3.423431 3.421464 3.424720 3.425820 3.428731 3.429874 3.429867 3.428703 3.425878 3.425878 3.408697 3.391517 3.374336 3.381703 3.370852 3.382922 3.373871 3.376842 3.384044 3.379717 3.379717 3.385116 3.379182 3.378549 3.377868 3.377868 3.380016 3.394108 3.391714 3.382114 3.389319 3.384115 3.384115 3.386923 3.383704 3.381719 3.376830 3.376830 3.379431 3.379419 3.379407 3.377067 3.379394 3.378892 3.383872 3.383872 3.386670 3.386635 3.386600 3.386564 3.381002 3.373511 3.371866 3.371600 3.371284 3.370872 3.367136 3.367136 3.365115 3.362998 3.360833 3.360833 3.360822 3.360811 3.360798 3.360798 3.350862 3.337471 3.328351 3.328351 3.319066 3.315441 3.317445 3.318705 3.319916 3.321029 3.321029 3.319879 3.318633 3.317337 3.314728 3.314728 3.311461 3.308146 3.304733 3.311883 3.311011 3.310139 3.302765 3.304057 3.305301 3.306449 3.306449 3.309266 3.306752 3.310061 3.309791 3.306958 3.309472 3.307116 3.307116 3.309058 3.296031 3.284222 3.283988 3.283707 3.283329 3.280517 3.276965 3.276078 3.275191 3.274302 3.266003 3.266003 3.267936 3.267029 3.266074 3.265022 3.258656 3.257763 3.256870 3.254410 3.255976 3.240383 3.240150 3.239868 3.238093 3.239491 3.231356 3.231123 3.230841 3.230462 3.220166 3.203744 3.207576 3.203604 3.199633 3.195661 3.191940 3.191940 3.191037 3.189496 3.187956 3.186415 3.181599 3.180060 3.179173 3.178285 3.177397 3.173033 3.160108 3.160108 3.161824 3.161591 3.161309 3.160929 3.154565 3.153676 3.152738 3.151703 3.145979 3.145374 3.144272 3.143121 3.141872 3.123264 3.101932 3.101932 3.091766 3.078058 3.070314 3.070314 3.065729 3.065496 3.065214 3.064834 3.046691 3.047565 3.047332 3.047050 3.046670 3.040127 3.038376 3.036624 3.034872 3.031152 3.030276 3.029401 3.028526 3.021980 3.021102 3.017745 3.020222 3.019343 2.992908 2.992908 2.994841 2.994607 2.994326 2.993948 2.989199 2.985651 2.984767 2.982629 2.983883 2.982997 2.974744 2.974744 2.976677 2.975784 2.973028 2.974844 2.970789 2.973806 2.965771 2.965771 2.969437 2.964881 2.967900 2.963990 2.966363 2.963099 2.963099 2.960926 2.964824 2.958753 2.956580 2.956580 2.960246 2.955462 2.958705 2.954296 2.957165 2.953033 2.953033 2.955624 2.951056 2.950183 2.949310 2.948437 2.942099 2.940558 2.939018 2.933654 2.937477 2.932910 2.931504 2.930002 2.928450 2.925597 2.921545 2.915252 spectrum_and_structure1.xml000077500000000000000000006115671477224461000351510ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/complex Stefan Kuhn 18 400.13200065 ^1H 32 SIMULTANEOUS 4006.41025641027 4005.431890047288 4004.4535236843067 4003.475157321325 4002.496790958343 4001.5184245953615 4000.5400582323796 3999.5616918693977 3998.583325506416 3997.6049591434344 3996.6265927804525 3995.6482264174706 3994.669860054489 3993.6914936915073 3992.7131273285254 3991.734760965544 3990.756394602562 3989.77802823958 3988.7996618765983 3987.821295513617 3986.842929150635 3985.864562787653 3984.8861964246717 3983.9078300616898 3982.929463698708 3981.9510973357264 3980.9727309727446 3979.9943646097627 3979.015998246781 3978.0376318837993 3977.0592655208175 3976.0808991578356 3975.102532794854 3974.1241664318723 3973.1458000688904 3972.167433705909 3971.189067342927 3970.210700979945 3969.2323346169633 3968.253968253982 3967.275601891 3966.297235528018 3965.3188691650366 3964.3405028020547 3963.362136439073 3962.3837700760914 3961.4054037131095 3960.4270373501276 3959.4486709871458 3958.4703046241643 3957.4919382611824 3956.5135718982006 3955.535205535219 3954.5568391722372 3953.5784728092553 3952.600106446274 3951.621740083292 3950.64337372031 3949.6650073573282 3948.686640994347 3947.708274631365 3946.729908268383 3945.7515419054016 3944.7731755424197 3943.794809179438 3942.8164428164564 3941.8380764534745 3940.8597100904926 3939.8813437275107 3938.9029773645293 3937.9246110015474 3936.9462446385655 3935.967878275584 3934.989511912602 3934.0111455496203 3933.032779186639 3932.054412823657 3931.076046460675 3930.0976800976932 3929.119313734712 3928.14094737173 3927.162581008748 3926.1842146457666 3925.2058482827847 3924.227481919803 3923.2491155568214 3922.2707491938395 3921.2923828308576 3920.3140164678757 3919.3356501048943 3918.3572837419124 3917.3789173789305 3916.400551015949 3915.422184652967 3914.4438182899853 3913.465451927004 3912.487085564022 3911.50871920104 3910.530352838058 3909.551986475077 3908.573620112095 3907.595253749113 3906.6168873861316 3905.6385210231497 3904.660154660168 3903.6817882971864 3902.7034219342045 3901.7250555712226 3900.7466892082407 3899.7683228452593 3898.7899564822774 3897.8115901192955 3896.833223756314 3895.854857393332 3894.8764910303503 3893.898124667369 3892.919758304387 3891.941391941405 3890.963025578423 3889.9846592154418 3889.00629285246 3888.027926489478 3887.0495601264965 3886.0711937635147 3885.0928274005328 3884.1144610375513 3883.1360946745694 3882.1577283115876 3881.1793619486057 3880.2009955856242 3879.2226292226424 3878.2442628596605 3877.265896496679 3876.287530133697 3875.3091637707153 3874.330797407734 3873.352431044752 3872.37406468177 3871.395698318788 3870.4173319558067 3869.438965592825 3868.460599229843 3867.4822328668615 3866.5038665038796 3865.5255001408977 3864.5471337779163 3863.5687674149344 3862.5904010519525 3861.6120346889707 3860.633668325989 3859.6553019630073 3858.6769356000254 3857.698569237044 3856.720202874062 3855.7418365110802 3854.763470148099 3853.785103785117 3852.806737422135 3851.828371059153 3850.8500046961717 3849.87163833319 3848.893271970208 3847.9149056072265 3846.9365392442446 3845.9581728812627 3844.9798065182813 3844.0014401552994 3843.0230737923175 3842.0447074293356 3841.066341066354 3840.0879747033723 3839.1096083403904 3838.131241977409 3837.152875614427 3836.174509251445 3835.196142888464 3834.217776525482 3833.2394101625 3832.261043799518 3831.2826774365367 3830.304311073555 3829.325944710573 3828.3475783475915 3827.3692119846096 3826.3908456216277 3825.4124792586463 3824.4341128956644 3823.4557465326825 3822.4773801697006 3821.499013806719 3820.5206474437373 3819.5422810807554 3818.563914717774 3817.585548354792 3816.60718199181 3815.6288156288288 3814.650449265847 3813.672082902865 3812.693716539883 3811.7153501769017 3810.73698381392 3809.758617450938 3808.7802510879565 3807.8018847249746 3806.8235183619927 3805.8451519990113 3804.8667856360294 3803.8884192730475 3802.9100529100656 3801.931686547084 3800.9533201841023 3799.9749538211204 3798.996587458139 3798.018221095157 3797.039854732175 3796.0614883691937 3795.083122006212 3794.10475564323 3793.126389280248 3792.1480229172666 3791.1696565542848 3790.191290191303 3789.2129238283214 3788.2345574653395 3787.2561911023577 3786.2778247393762 3785.2994583763943 3784.3210920134125 3783.3427256504306 3782.364359287449 3781.3859929244672 3780.4076265614854 3779.429260198504 3778.450893835522 3777.47252747254 3776.4941611095587 3775.515794746577 3774.537428383595 3773.559062020613 3772.5806956576316 3771.6023292946497 3770.623962931668 3769.6455965686864 3768.6672302057045 3767.6888638427226 3766.710497479741 3765.7321311167593 3764.7537647537774 3763.775398390796 3762.797032027814 3761.818665664832 3760.8402993018503 3759.861932938869 3758.883566575887 3757.905200212905 3756.9268338499237 3755.948467486942 3754.97010112396 3753.991734760978 3753.0133683979966 3752.0350020350147 3751.056635672033 3750.0782693090514 3749.0999029460695 3748.1215365830876 3747.143170220106 3746.1648038571243 3745.1864374941424 3744.208071131161 3743.229704768179 3742.251338405197 3741.2729720422153 3740.294605679234 3739.316239316252 3738.33787295327 3737.3595065902887 3736.381140227307 3735.402773864325 3734.424407501343 3733.4460411383616 3732.4676747753797 3731.489308412398 3730.5109420494164 3729.5325756864345 3728.5542093234526 3727.575842960471 3726.5974765974893 3725.6191102345074 3724.640743871526 3723.662377508544 3722.684011145562 3721.7056447825803 3720.727278419599 3719.748912056617 3718.770545693635 3717.7921793306537 3716.8138129676718 3715.83544660469 3714.857080241708 3713.8787138787266 3712.9003475157447 3711.921981152763 3710.9436147897813 3709.9652484267995 3708.9868820638176 3708.008515700836 3707.0301493378543 3706.0517829748724 3705.073416611891 3704.095050248909 3703.116683885927 3702.1383175229453 3701.159951159964 3700.181584796982 3699.203218434 3698.2248520710186 3697.2464857080367 3696.268119345055 3695.289752982073 3694.3113866190915 3693.3330202561096 3692.3546538931278 3691.3762875301463 3690.3979211671644 3689.4195548041826 3688.441188441201 3687.4628220782192 3686.4844557152373 3685.506089352256 3684.527722989274 3683.549356626292 3682.5709902633103 3681.592623900329 3680.614257537347 3679.635891174365 3678.6575248113836 3677.6791584484017 3676.70079208542 3675.722425722438 3674.7440593594565 3673.7656929964746 3672.7873266334927 3671.8089602705113 3670.8305939075294 3669.8522275445475 3668.873861181566 3667.895494818584 3666.9171284556023 3665.938762092621 3664.960395729639 3663.982029366657 3663.0036630036752 3662.025296640694 3661.046930277712 3660.06856391473 3659.0901975517486 3658.1118311887667 3657.133464825785 3656.155098462803 3655.1767320998215 3654.1983657368396 3653.2199993738577 3652.2416330108763 3651.2632666478944 3650.2849002849125 3649.306533921931 3648.328167558949 3647.3498011959673 3646.371434832986 3645.393068470004 3644.414702107022 3643.43633574404 3642.457969381059 3641.479603018077 3640.501236655095 3639.5228702921136 3638.5445039291317 3637.56613756615 3636.587771203168 3635.6094048401865 3634.6310384772046 3633.6526721142227 3632.6743057512413 3631.6959393882594 3630.7175730252775 3629.739206662296 3628.760840299314 3627.7824739363323 3626.804107573351 3625.825741210369 3624.847374847387 3623.869008484405 3622.8906421214238 3621.912275758442 3620.93390939546 3619.9555430324785 3618.9771766694967 3617.9988103065148 3617.020443943533 3616.0420775805514 3615.0637112175696 3614.0853448545877 3613.1069784916062 3612.1286121286244 3611.1502457656425 3610.171879402661 3609.193513039679 3608.2151466766973 3607.236780313716 3606.258413950734 3605.280047587752 3604.30168122477 3603.3233148617887 3602.344948498807 3601.366582135825 3600.3882157728435 3599.4098494098616 3598.4314830468797 3597.453116683898 3596.4747503209164 3595.4963839579345 3594.5180175949527 3593.539651231971 3592.5612848689893 3591.5829185060074 3590.604552143026 3589.626185780044 3588.6478194170622 3587.669453054081 3586.691086691099 3585.712720328117 3584.734353965135 3583.7559876021537 3582.777621239172 3581.79925487619 3580.8208885132085 3579.8425221502266 3578.8641557872447 3577.885789424263 3576.9074230612814 3575.9290566982995 3574.9506903353176 3573.972323972336 3572.9939576093543 3572.0155912463724 3571.037224883391 3570.058858520409 3569.080492157427 3568.102125794446 3567.123759431464 3566.145393068482 3565.1670267055 3564.1886603425187 3563.210293979537 3562.231927616555 3561.2535612535735 3560.2751948905916 3559.2968285276097 3558.318462164628 3557.3400958016464 3556.3617294386645 3555.3833630756826 3554.404996712701 3553.4266303497193 3552.4482639867374 3551.469897623756 3550.491531260774 3549.513164897792 3548.5347985348108 3547.556432171829 3546.578065808847 3545.5996994458656 3544.6213330828837 3543.642966719902 3542.66460035692 3541.6862339939385 3540.7078676309566 3539.7295012679747 3538.751134904993 3537.7727685420114 3536.7944021790295 3535.8160358160476 3534.837669453066 3533.8593030900843 3532.8809367271024 3531.902570364121 3530.924204001139 3529.945837638157 3528.9674712751757 3527.989104912194 3527.010738549212 3526.0323721862305 3525.0540058232486 3524.0756394602668 3523.097273097285 3522.1189067343034 3521.1405403713215 3520.1621740083397 3519.183807645358 3518.2054412823763 3517.2270749193945 3516.2487085564126 3515.270342193431 3514.2919758304492 3513.3136094674674 3512.335243104486 3511.356876741504 3510.378510378522 3509.4001440155407 3508.421777652559 3507.443411289577 3506.4650449265955 3505.4866785636136 3504.5083122006317 3503.52994583765 3502.5515794746684 3501.5732131116865 3500.5948467487046 3499.6164803857228 3498.6381140227413 3497.6597476597594 3496.6813812967775 3495.703014933796 3494.724648570814 3493.7462822078323 3492.767915844851 3491.789549481869 3490.811183118887 3489.8328167559057 3488.854450392924 3487.876084029942 3486.8977176669605 3485.9193513039786 3484.9409849409967 3483.962618578015 3482.9842522150334 3482.0058858520515 3481.0275194890696 3480.0491531260877 3479.0707867631063 3478.0924204001244 3477.1140540371425 3476.135687674161 3475.157321311179 3474.1789549481973 3473.200588585216 3472.222222222234 3471.243855859252 3470.2654894962707 3469.287123133289 3468.308756770307 3467.3303904073255 3466.3520240443436 3465.3736576813617 3464.39529131838 3463.4169249553984 3462.4385585924165 3461.4601922294346 3460.4818258664527 3459.5034595034713 3458.5250931404894 3457.5467267775075 3456.568360414526 3455.589994051544 3454.6116276885623 3453.633261325581 3452.654894962599 3451.676528599617 3450.6981622366357 3449.7197958736538 3448.741429510672 3447.7630631476904 3446.7846967847086 3445.8063304217267 3444.827964058745 3443.8495976957634 3442.8712313327815 3441.8928649697996 3440.9144986068177 3439.9361322438363 3438.9577658808544 3437.9793995178725 3437.001033154891 3436.022666791909 3435.0443004289273 3434.065934065946 3433.087567702964 3432.109201339982 3431.1308349770006 3430.1524686140187 3429.174102251037 3428.1957358880554 3427.2173695250735 3426.2390031620916 3425.2606367991098 3424.2822704361283 3423.3039040731464 3422.3255377101646 3421.3471713471827 3420.3688049842012 3419.3904386212193 3418.4120722582375 3417.433705895256 3416.455339532274 3415.4769731692923 3414.498606806311 3413.520240443329 3412.541874080347 3411.5635077173656 3410.5851413543837 3409.606774991402 3408.6284086284204 3407.6500422654385 3406.6716759024566 3405.693309539475 3404.7149431764933 3403.7365768135114 3402.7582104505295 3401.7798440875476 3400.801477724566 3399.8231113615843 3398.8447449986024 3397.866378635621 3396.888012272639 3395.9096459096572 3394.931279546676 3393.952913183694 3392.974546820712 3391.9961804577306 3391.0178140947487 3390.039447731767 3389.0610813687854 3388.0827150058035 3387.1043486428216 3386.12598227984 3385.1476159168583 3384.1692495538764 3383.1908831908945 3382.2125168279126 3381.234150464931 3380.2557841019493 3379.2774177389674 3378.299051375986 3377.320685013004 3376.342318650022 3375.363952287041 3374.385585924059 3373.407219561077 3372.4288531980956 3371.4504868351137 3370.472120472132 3369.4937541091504 3368.5153877461685 3367.5370213831866 3366.558655020205 3365.5802886572233 3364.6019222942414 3363.6235559312595 3362.6451895682776 3361.666823205296 3360.6884568423143 3359.7100904793324 3358.731724116351 3357.753357753369 3356.774991390387 3355.7966250274058 3354.818258664424 3353.839892301442 3352.8615259384605 3351.8831595754787 3350.9047932124968 3349.9264268495153 3348.9480604865334 3347.9696941235516 3346.99132776057 3346.0129613975882 3345.0345950346064 3344.0562286716245 3343.0778623086426 3342.099495945661 3341.1211295826793 3340.1427632196974 3339.164396856716 3338.186030493734 3337.207664130752 3336.2292977677707 3335.250931404789 3334.272565041807 3333.2941986788255 3332.3158323158436 3331.3374659528617 3330.3590995898803 3329.3807332268984 3328.4023668639165 3327.424000500935 3326.445634137953 3325.4672677749713 3324.4889014119894 3323.5105350490076 3322.532168686026 3321.5538023230442 3320.5754359600624 3319.597069597081 3318.618703234099 3317.640336871117 3316.6619705081357 3315.683604145154 3314.705237782172 3313.7268714191905 3312.7485050562086 3311.7701386932267 3310.7917723302453 3309.8134059672634 3308.8350396042815 3307.8566732413 3306.878306878318 3305.8999405153363 3304.9215741523544 3303.9432077893725 3302.964841426391 3301.986475063409 3301.0081087004273 3300.029742337446 3299.051375974464 3298.073009611482 3297.0946432485007 3296.116276885519 3295.137910522537 3294.1595441595555 3293.1811777965736 3292.2028114335917 3291.2244450706103 3290.2460787076284 3289.2677123446465 3288.289345981665 3287.310979618683 3286.3326132557013 3285.3542468927194 3284.3758805297375 3283.397514166756 3282.419147803774 3281.4407814407923 3280.462415077811 3279.484048714829 3278.505682351847 3277.5273159888657 3276.548949625884 3275.570583262902 3274.5922168999205 3273.6138505369386 3272.6354841739567 3271.6571178109753 3270.6787514479934 3269.7003850850115 3268.72201872203 3267.743652359048 3266.7652859960663 3265.7869196330844 3264.8085532701025 3263.830186907121 3262.851820544139 3261.8734541811573 3260.895087818176 3259.916721455194 3258.938355092212 3257.9599887292306 3256.9816223662488 3256.003256003267 3255.0248896402854 3254.0465232773035 3253.0681569143217 3252.0897905513402 3251.1114241883583 3250.1330578253765 3249.154691462395 3248.176325099413 3247.1979587364312 3246.2195923734494 3245.241226010468 3244.262859647486 3243.284493284504 3242.3061269215223 3241.327760558541 3240.349394195559 3239.371027832577 3238.3926614695956 3237.4142951066137 3236.435928743632 3235.4575623806504 3234.4791960176685 3233.5008296546866 3232.522463291705 3231.5440969287233 3230.5657305657414 3229.58736420276 3228.608997839778 3227.630631476796 3226.6522651138143 3225.673898750833 3224.695532387851 3223.717166024869 3222.7387996618872 3221.760433298906 3220.782066935924 3219.803700572942 3218.8253342099606 3217.8469678469787 3216.868601483997 3215.8902351210154 3214.9118687580335 3213.9335023950516 3212.95513603207 3211.9767696690883 3210.9984033061064 3210.020036943125 3209.041670580143 3208.063304217161 3207.0849378541793 3206.106571491198 3205.128205128216 3204.149838765234 3203.171472402252 3202.193106039271 3201.214739676289 3200.236373313307 3199.2580069503256 3198.2796405873437 3197.301274224362 3196.3229078613804 3195.3445414983985 3194.3661751354166 3193.387808772435 3192.4094424094533 3191.4310760464714 3190.45270968349 3189.474343320508 3188.495976957526 3187.5176105945443 3186.539244231563 3185.560877868581 3184.582511505599 3183.604145142617 3182.6257787796358 3181.647412416654 3180.669046053672 3179.6906796906906 3178.7123133277087 3177.733946964727 3176.7555806017454 3175.7772142387635 3174.7988478757816 3173.8204815128 3172.8421151498183 3171.8637487868364 3170.885382423855 3169.907016060873 3168.928649697891 3167.9502833349093 3166.971916971928 3165.993550608946 3165.015184245964 3164.036817882982 3163.0584515200007 3162.080085157019 3161.101718794037 3160.1233524310555 3159.1449860680736 3158.1666197050918 3157.1882533421103 3156.2098869791284 3155.2315206161466 3154.253154253165 3153.2747878901832 3152.2964215272013 3151.31805516422 3150.339688801238 3149.361322438256 3148.3829560752743 3147.404589712293 3146.426223349311 3145.447856986329 3144.469490623347 3143.4911242603657 3142.512757897384 3141.534391534402 3140.5560251714205 3139.5776588084386 3138.5992924454567 3137.6209260824753 3136.6425597194934 3135.6641933565115 3134.68582699353 3133.707460630548 3132.7290942675663 3131.750727904585 3130.772361541603 3129.793995178621 3128.8156288156392 3127.837262452658 3126.858896089676 3125.880529726694 3124.902163363712 3123.9237970007307 3122.945430637749 3121.967064274767 3120.9886979117855 3120.0103315488036 3119.0319651858217 3118.0535988228403 3117.0752324598584 3116.0968660968765 3115.118499733895 3114.140133370913 3113.1617670079313 3112.18340064495 3111.205034281968 3110.226667918986 3109.248301556004 3108.269935193023 3107.291568830041 3106.313202467059 3105.334836104077 3104.3564697410957 3103.378103378114 3102.399737015132 3101.4213706521505 3100.4430042891686 3099.4646379261867 3098.4862715632053 3097.5079052002234 3096.5295388372415 3095.55117247426 3094.572806111278 3093.5944397482963 3092.616073385315 3091.637707022333 3090.659340659351 3089.680974296369 3088.7026079333878 3087.724241570406 3086.745875207424 3085.767508844442 3084.7891424814607 3083.8107761184788 3082.832409755497 3081.8540433925155 3080.8756770295336 3079.8973106665517 3078.9189443035702 3077.9405779405884 3076.9622115776065 3075.983845214625 3075.005478851643 3074.0271124886613 3073.04874612568 3072.070379762698 3071.092013399716 3070.1136470367346 3069.1352806737527 3068.156914310771 3067.178547947789 3066.200181584807 3065.2218152218256 3064.2434488588437 3063.265082495862 3062.2867161328804 3061.3083497698985 3060.3299834069167 3059.351617043935 3058.3732506809533 3057.3948843179714 3056.41651795499 3055.438151592008 3054.4597852290262 3053.481418866045 3052.503052503063 3051.524686140081 3050.5463197770996 3049.5679534141177 3048.589587051136 3047.611220688154 3046.632854325172 3045.6544879621906 3044.6761215992087 3043.697755236227 3042.7193888732454 3041.7410225102635 3040.7626561472816 3039.7842897843 3038.8059234213183 3037.8275570583364 3036.849190695355 3035.870824332373 3034.892457969391 3033.91409160641 3032.935725243428 3031.957358880446 3030.9789925174646 3030.0006261544827 3029.022259791501 3028.043893428519 3027.065527065537 3026.0871607025556 3025.1087943395737 3024.130427976592 3023.1520616136104 3022.1736952506285 3021.1953288876466 3020.216962524665 3019.2385961616833 3018.2602297987014 3017.28186343572 3016.303497072738 3015.325130709756 3014.3467643467748 3013.368397983793 3012.390031620811 3011.4116652578296 3010.4332988948477 3009.454932531866 3008.476566168884 3007.498199805902 3006.5198334429206 3005.5414670799387 3004.563100716957 3003.5847343539754 3002.6063679909935 3001.6280016280116 3000.64963526503 2999.6712689020483 2998.6929025390664 2997.714536176085 2996.736169813103 2995.757803450121 2994.7794370871397 2993.801070724158 2992.822704361176 2991.8443379981945 2990.8659716352126 2989.8876052722308 2988.909238909249 2987.930872546267 2986.9525061832855 2985.9741398203037 2984.995773457322 2984.0174070943403 2983.0390407313585 2982.0606743683766 2981.082308005395 2980.1039416424132 2979.1255752794314 2978.14720891645 2977.168842553468 2976.190476190486 2975.2121098275047 2974.233743464523 2973.255377101541 2972.2770107385595 2971.298644375577 2970.3202780125957 2969.3419116496143 2968.363545286632 2967.3851789236505 2966.4068125606686 2965.4284461976868 2964.4500798347053 2963.4717134717234 2962.4933471087415 2961.51498074576 2960.536614382778 2959.5582480197963 2958.579881656815 2957.601515293833 2956.623148930851 2955.6447825678697 2954.666416204888 2953.688049841906 2952.7096834789245 2951.731317115942 2950.7529507529607 2949.7745843899793 2948.796218026997 2947.8178516640155 2946.8394853010336 2945.8611189380517 2944.8827525750703 2943.9043862120884 2942.9260198491065 2941.947653486125 2940.969287123143 2939.9909207601613 2939.01255439718 2938.034188034198 2937.055821671216 2936.0774553082347 2935.099088945253 2934.120722582271 2933.1423562192895 2932.163989856307 2931.1856234933257 2930.2072571303443 2929.228890767362 2928.2505244043805 2927.2721580413986 2926.2937916784167 2925.3154253154353 2924.3370589524534 2923.3586925894715 2922.38032622649 2921.401959863508 2920.4235935005263 2919.445227137545 2918.466860774563 2917.488494411581 2916.5101280485997 2915.5317616856178 2914.553395322636 2913.5750289596544 2912.596662596672 2911.6182962336907 2910.6399298707092 2909.661563507727 2908.6831971447455 2907.7048307817636 2906.7264644187817 2905.7480980558003 2904.7697316928184 2903.7913653298365 2902.812998966855 2901.834632603873 2900.8562662408913 2899.87789987791 2898.899533514928 2897.921167151946 2896.9428007889646 2895.9644344259827 2894.986068063001 2894.0077017000194 2893.029335337037 2892.0509689740556 2891.072602611074 2890.094236248092 2889.1158698851104 2888.1375035221286 2887.1591371591467 2886.1807707961652 2885.2024044331833 2884.2240380702015 2883.24567170722 2882.267305344238 2881.2889389812563 2880.310572618275 2879.332206255293 2878.353839892311 2877.3754735293296 2876.3971071663477 2875.418740803366 2874.4403744403844 2873.462008077402 2872.4836417144206 2871.505275351439 2870.526908988457 2869.5485426254754 2868.5701762624935 2867.5918098995116 2866.61344353653 2865.6350771735483 2864.6567108105664 2863.678344447585 2862.699978084603 2861.7216117216212 2860.74324535864 2859.764878995658 2858.786512632676 2857.8081462696946 2856.8297799067127 2855.851413543731 2854.8730471807494 2853.894680817767 2852.9163144547856 2851.937948091804 2850.959581728822 2849.9812153658404 2849.0028490028585 2848.0244826398766 2847.046116276895 2846.0677499139133 2845.0893835509314 2844.11101718795 2843.132650824968 2842.154284461986 2841.175918099005 2840.197551736023 2839.219185373041 2838.2408190100596 2837.2624526470777 2836.284086284096 2835.3057199211144 2834.3273535581325 2833.3489871951506 2832.370620832169 2831.392254469187 2830.4138881062054 2829.435521743224 2828.4571553802416 2827.47878901726 2826.5004226542783 2825.5220562912964 2824.543689928315 2823.565323565333 2822.586957202351 2821.6085908393698 2820.630224476388 2819.651858113406 2818.6734917504245 2817.6951253874427 2816.7167590244608 2815.7383926614793 2814.7600262984975 2813.7816599355156 2812.803293572534 2811.824927209552 2810.8465608465704 2809.868194483589 2808.8898281206066 2807.911461757625 2806.9330953946433 2805.9547290316614 2804.97636266868 2803.997996305698 2803.019629942716 2802.0412635797347 2801.062897216753 2800.084530853771 2799.1061644907895 2798.1277981278076 2797.1494317648257 2796.1710654018443 2795.1926990388624 2794.2143326758805 2793.235966312899 2792.2575999499168 2791.2792335869353 2790.300867223954 2789.3225008609716 2788.34413449799 2787.3657681350082 2786.3874017720264 2785.409035409045 2784.430669046063 2783.452302683081 2782.4739363200997 2781.495569957118 2780.517203594136 2779.5388372311545 2778.5604708681726 2777.5821045051907 2776.6037381422093 2775.6253717792274 2774.6470054162455 2773.668639053264 2772.6902726902817 2771.7119063273003 2770.733539964319 2769.7551736013365 2768.776807238355 2767.798440875373 2766.8200745123913 2765.84170814941 2764.863341786428 2763.884975423446 2762.9066090604647 2761.928242697483 2760.949876334501 2759.9715099715195 2758.9931436085376 2758.0147772455557 2757.0364108825743 2756.0580445195924 2755.0796781566105 2754.101311793629 2753.1229454306467 2752.1445790676653 2751.166212704684 2750.1878463417015 2749.20947997872 2748.231113615738 2747.2527472527563 2746.274380889775 2745.296014526793 2744.317648163811 2743.3392818008297 2742.360915437848 2741.382549074866 2740.4041827118845 2739.4258163489026 2738.4474499859207 2737.4690836229393 2736.4907172599574 2735.5123508969755 2734.533984533994 2733.5556181710117 2732.5772518080303 2731.598885445049 2730.6205190820665 2729.642152719085 2728.663786356103 2727.6854199931213 2726.70705363014 2725.728687267158 2724.750320904176 2723.7719545411946 2722.7935881782128 2721.815221815231 2720.8368554522494 2719.8584890892676 2718.8801227262857 2717.9017563633042 2716.9233900003223 2715.9450236373405 2714.966657274359 2713.9882909113767 2713.0099245483952 2712.031558185414 2711.0531918224315 2710.07482545945 2709.096459096468 2708.1180927334863 2707.139726370505 2706.161360007523 2705.182993644541 2704.2046272815596 2703.2262609185777 2702.247894555596 2701.2695281926144 2700.2911618296325 2699.3127954666506 2698.334429103669 2697.3560627406873 2696.3776963777054 2695.399330014724 2694.4209636517417 2693.44259728876 2692.464230925779 2691.4858645627965 2690.507498199815 2689.529131836833 2688.5507654738512 2687.57239911087 2686.594032747888 2685.615666384906 2684.6373000219246 2683.6589336589427 2682.680567295961 2681.7022009329794 2680.7238345699975 2679.7454682070156 2678.767101844034 2677.7887354810523 2676.8103691180704 2675.832002755089 2674.8536363921066 2673.875270029125 2672.8969036661438 2671.9185373031614 2670.94017094018 2669.961804577198 2668.983438214216 2668.005071851235 2667.026705488253 2666.048339125271 2665.0699727622896 2664.0916063993077 2663.113240036326 2662.1348736733444 2661.1565073103625 2660.1781409473806 2659.199774584399 2658.2214082214173 2657.2430418584354 2656.264675495454 2655.2863091324716 2654.30794276949 2653.3295764065087 2652.3512100435264 2651.372843680545 2650.394477317563 2649.416110954581 2648.4377445915998 2647.459378228618 2646.481011865636 2645.5026455026546 2644.5242791396727 2643.545912776691 2642.5675464137094 2641.5891800507275 2640.6108136877456 2639.632447324764 2638.6540809617823 2637.6757145988004 2636.697348235819 2635.7189818728366 2634.740615509855 2633.7622491468737 2632.7838827838914 2631.80551642091 2630.827150057928 2629.848783694946 2628.8704173319647 2627.892050968983 2626.913684606001 2625.9353182430195 2624.9569518800376 2623.9785855170558 2623.0002191540743 2622.0218527910924 2621.0434864281106 2620.065120065129 2619.0867537021472 2618.1083873391653 2617.130020976184 2616.1516546132016 2615.17328825022 2614.1949218872387 2613.2165555242564 2612.238189161275 2611.259822798293 2610.281456435311 2609.3030900723297 2608.324723709348 2607.346357346366 2606.3679909833845 2605.3896246204026 2604.4112582574207 2603.4328918944393 2602.4545255314574 2601.4761591684755 2600.497792805494 2599.519426442512 2598.5410600795303 2597.562693716549 2596.5843273535666 2595.605960990585 2594.6275946276037 2593.6492282646213 2592.67086190164 2591.692495538658 2590.714129175676 2589.7357628126947 2588.757396449713 2587.779030086731 2586.8006637237495 2585.8222973607676 2584.8439309977857 2583.8655646348043 2582.8871982718224 2581.9088319088405 2580.930465545859 2579.952099182877 2578.9737328198953 2577.995366456914 2577.0170000939315 2576.03863373095 2575.0602673679687 2574.0819010049863 2573.103534642005 2572.125168279023 2571.146801916041 2570.1684355530597 2569.190069190078 2568.211702827096 2567.2333364641145 2566.2549701011326 2565.2766037381507 2564.2982373751693 2563.3198710121874 2562.3415046492055 2561.363138286224 2560.384771923242 2559.4064055602603 2558.428039197279 2557.4496728342965 2556.471306471315 2555.4929401083336 2554.5145737453513 2553.53620738237 2552.557841019388 2551.579474656406 2550.6011082934247 2549.6227419304428 2548.644375567461 2547.6660092044795 2546.6876428414976 2545.7092764785157 2544.7309101155342 2543.7525437525524 2542.7741773895705 2541.795811026589 2540.817444663607 2539.8390783006253 2538.860711937644 2537.8823455746615 2536.90397921168 2535.9256128486986 2534.9472464857163 2533.968880122735 2532.990513759753 2532.012147396771 2531.0337810337896 2530.0554146708077 2529.077048307826 2528.0986819448444 2527.1203155818625 2526.1419492188807 2525.163582855899 2524.1852164929173 2523.2068501299354 2522.228483766954 2521.250117403972 2520.2717510409902 2519.293384678009 2518.3150183150265 2517.336651952045 2516.3582855890636 2515.3799192260813 2514.4015528631 2513.423186500118 2512.444820137136 2511.4664537741546 2510.4880874111727 2509.509721048191 2508.5313546852094 2507.5529883222275 2506.5746219592456 2505.596255596264 2504.6178892332823 2503.6395228703004 2502.661156507319 2501.682790144337 2500.704423781355 2499.726057418374 2498.747691055392 2497.76932469241 2496.7909583294286 2495.8125919664462 2494.834225603465 2493.8558592404834 2492.877492877501 2491.8991265145196 2490.9207601515377 2489.942393788556 2488.9640274255744 2487.9856610625925 2487.0072946996106 2486.028928336629 2485.0505619736473 2484.0721956106654 2483.093829247684 2482.115462884702 2481.13709652172 2480.1587301587388 2479.180363795757 2478.201997432775 2477.2236310697936 2476.245264706811 2475.26689834383 2474.2885319808483 2473.310165617866 2472.3317992548846 2471.3534328919027 2470.375066528921 2469.3967001659394 2468.4183338029575 2467.4399674399756 2466.461601076994 2465.4832347140123 2464.5048683510304 2463.526501988049 2462.548135625067 2461.569769262085 2460.5914028991037 2459.613036536122 2458.63467017314 2457.6563038101585 2456.677937447176 2455.6995710841948 2454.7212047212133 2453.742838358231 2452.7644719952496 2451.7861056322677 2450.807739269286 2449.8293729063043 2448.8510065433225 2447.8726401803406 2446.894273817359 2445.9159074543772 2444.9375410913954 2443.959174728414 2442.980808365432 2442.00244200245 2441.0240756394687 2440.045709276487 2439.067342913505 2438.0889765505235 2437.110610187541 2436.1322438245597 2435.1538774615783 2434.175511098596 2433.1971447356145 2432.2187783726326 2431.2404120096508 2430.2620456466693 2429.2836792836874 2428.3053129207055 2427.326946557724 2426.348580194742 2425.3702138317603 2424.391847468779 2423.413481105797 2422.435114742815 2421.4567483798337 2420.478382016852 2419.50001565387 2418.5216492908885 2417.543282927906 2416.5649165649247 2415.5865502019433 2414.608183838961 2413.6298174759795 2412.6514511129976 2411.6730847500157 2410.6947183870343 2409.7163520240524 2408.7379856610705 2407.759619298089 2406.781252935107 2405.8028865721253 2404.824520209144 2403.846153846162 2402.86778748318 2401.8894211201987 2400.911054757217 2399.932688394235 2398.9543220312535 2397.975955668271 2396.9975893052897 2396.0192229423083 2395.040856579326 2394.0624902163445 2393.0841238533626 2392.1057574903807 2391.1273911273993 2390.1490247644174 2389.1706584014355 2388.192292038454 2387.213925675472 2386.2355593124903 2385.257192949509 2384.278826586527 2383.300460223545 2382.3220938605637 2381.3437274975818 2380.3653611346 2379.3869947716184 2378.408628408636 2377.4302620456547 2376.4518956826732 2375.473529319691 2374.4951629567095 2373.5167965937276 2372.5384302307457 2371.5600638677643 2370.5816975047824 2369.6033311418005 2368.624964778819 2367.646598415837 2366.6682320528553 2365.689865689874 2364.711499326892 2363.73313296391 2362.7547666009286 2361.7764002379467 2360.798033874965 2359.8196675119834 2358.841301149001 2357.8629347860197 2356.884568423038 2355.906202060056 2354.9278356970744 2353.9494693340926 2352.9711029711107 2351.9927366081292 2351.0143702451473 2350.0360038821655 2349.057637519184 2348.079271156202 2347.1009047932203 2346.122538430239 2345.144172067257 2344.165805704275 2343.1874393412936 2342.2090729783117 2341.23070661533 2340.2523402523484 2339.273973889366 2338.2956075263846 2337.317241163403 2336.338874800421 2335.3605084374394 2334.3821420744575 2333.4037757114756 2332.425409348494 2331.4470429855123 2330.4686766225304 2329.490310259549 2328.511943896567 2327.5335775335852 2326.555211170604 2325.576844807622 2324.59847844464 2323.6201120816586 2322.6417457186767 2321.663379355695 2320.6850129927134 2319.706646629731 2318.7282802667496 2317.749913903768 2316.771547540786 2315.7931811778044 2314.8148148148225 2313.8364484518406 2312.858082088859 2311.8797157258773 2310.9013493628954 2309.922982999914 2308.944616636932 2307.96625027395 2306.987883910969 2306.009517547987 2305.031151185005 2304.0527848220236 2303.0744184590417 2302.09605209606 2301.1176857330784 2300.139319370096 2299.1609530071146 2298.182586644133 2297.204220281151 2296.2258539181694 2295.2474875551875 2294.2691211922056 2293.290754829224 2292.3123884662423 2291.3340221032604 2290.355655740279 2289.377289377297 2288.398923014315 2287.4205566513338 2286.442190288352 2285.46382392537 2284.4854575623885 2283.5070911994067 2282.5287248364248 2281.5503584734433 2280.571992110461 2279.5936257474796 2278.615259384498 2277.636893021516 2276.6585266585344 2275.6801602955525 2274.7017939325706 2273.723427569589 2272.7450612066073 2271.7666948436254 2270.788328480644 2269.809962117662 2268.83159575468 2267.8532293916987 2266.874863028717 2265.896496665735 2264.9181303027535 2263.9397639397716 2262.9613975767898 2261.9830312138083 2261.004664850826 2260.0262984878445 2259.047932124863 2258.0695657618808 2257.0911993988993 2256.1128330359174 2255.1344666729356 2254.156100309954 2253.1777339469722 2252.1993675839904 2251.221001221009 2250.242634858027 2249.264268495045 2248.2859021320637 2247.307535769082 2246.3291694061 2245.3508030431185 2244.3724366801366 2243.3940703171547 2242.4157039541733 2241.437337591191 2240.4589712282095 2239.480604865228 2238.5022385022457 2237.5238721392643 2236.5455057762824 2235.5671394133005 2234.588773050319 2233.610406687337 2232.6320403243553 2231.653673961374 2230.675307598392 2229.69694123541 2228.7185748724287 2227.740208509447 2226.761842146465 2225.7834757834835 2224.8051094205016 2223.8267430575197 2222.8483766945383 2221.870010331556 2220.8916439685745 2219.913277605593 2218.9349112426107 2217.9565448796293 2216.9781785166474 2215.9998121536655 2215.021445790684 2214.043079427702 2213.0647130647203 2212.086346701739 2211.107980338757 2210.129613975775 2209.1512476127937 2208.172881249812 2207.19451488683 2206.2161485238485 2205.2377821608666 2204.2594157978847 2203.2810494349033 2202.302683071921 2201.3243167089395 2200.345950345958 2199.3675839829757 2198.3892176199943 2197.4108512570124 2196.4324848940305 2195.454118531049 2194.475752168067 2193.4973858050853 2192.519019442104 2191.540653079122 2190.56228671614 2189.5839203531586 2188.6055539901768 2187.627187627195 2186.6488212642134 2185.6704549012316 2184.6920885382497 2183.7137221752682 2182.735355812286 2181.7569894493045 2180.778623086323 2179.8002567233407 2178.8218903603592 2177.8435239973774 2176.8651576343955 2175.886791271414 2174.908424908432 2173.9300585454503 2172.951692182469 2171.973325819487 2170.994959456505 2170.0165930935236 2169.0382267305417 2168.05986036756 2167.0814940045784 2166.1031276415965 2165.1247612786146 2164.146394915633 2163.1680285526513 2162.1896621896694 2161.211295826688 2160.2329294637057 2159.254563100724 2158.276196737743 2157.2978303747605 2156.319464011779 2155.341097648797 2154.3627312858152 2153.384364922834 2152.405998559852 2151.42763219687 2150.4492658338886 2149.4708994709067 2148.492533107925 2147.5141667449434 2146.5358003819615 2145.5574340189796 2144.579067655998 2143.6007012930163 2142.6223349300344 2141.643968567053 2140.6656022040706 2139.687235841089 2138.7088694781078 2137.7305031151254 2136.752136752144 2135.773770389162 2134.79540402618 2133.817037663199 2132.838671300217 2131.860304937235 2130.8819385742536 2129.9035722112717 2128.92520584829 2127.9468394853084 2126.9684731223265 2125.9901067593446 2125.011740396363 2124.0333740333813 2123.0550076703994 2122.076641307418 2121.0982749444356 2120.119908581454 2119.1415422184728 2118.1631758554904 2117.184809492509 2116.206443129527 2115.228076766545 2114.2497104035638 2113.271344040582 2112.2929776776 2111.3146113146186 2110.3362449516367 2109.357878588655 2108.3795122256734 2107.4011458626915 2106.4227794997096 2105.444413136728 2104.4660467737463 2103.4876804107644 2102.509314047783 2101.5309476848006 2100.552581321819 2099.5742149588377 2098.5958485958554 2097.617482232874 2096.639115869892 2095.66074950691 2094.6823831439287 2093.704016780947 2092.725650417965 2091.7472840549835 2090.7689176920017 2089.7905513290198 2088.8121849660383 2087.8338186030564 2086.8554522400746 2085.877085877093 2084.8987195141112 2083.9203531511293 2082.941986788148 2081.9636204251656 2080.985254062184 2080.0068876992027 2079.0285213362204 2078.050154973239 2077.071788610257 2076.093422247275 2075.1150558842937 2074.136689521312 2073.15832315833 2072.1799567953485 2071.2015904323666 2070.2232240693847 2069.2448577064033 2068.2664913434214 2067.2881249804395 2066.309758617458 2065.331392254476 2064.3530258914943 2063.374659528513 2062.3962931655306 2061.417926802549 2060.4395604395677 2059.4611940765853 2058.482827713604 2057.504461350622 2056.52609498764 2055.5477286246587 2054.569362261677 2053.590995898695 2052.6126295357135 2051.6342631727316 2050.6558968097497 2049.6775304467683 2048.6991640837864 2047.7207977208045 2046.7424313578229 2045.7640649948412 2044.7856986318593 2043.8073322688776 2042.8289659058958 2041.850599542914 2040.8722331799324 2039.8938668169505 2038.915500453969 2037.937134090987 2036.9587677280053 2035.9804013650237 2035.0020350020418 2034.0236686390601 2033.0453022760782 2032.0669359130966 2031.088569550115 2030.110203187133 2029.1318368241514 2028.1534704611695 2027.1751040981878 2026.1967377352062 2025.2183713722243 2024.2400050092426 2023.2616386462607 2022.283272283279 2021.3049059202974 2020.3265395573155 2019.3481731943339 2018.369806831352 2017.3914404683703 2016.4130741053887 2015.4347077424068 2014.456341379425 2013.4779750164432 2012.4996086534616 2011.52124229048 2010.542875927498 2009.5645095645164 2008.5861432015345 2007.6077768385528 2006.6294104755711 2005.6510441125893 2004.6726777496076 2003.6943113866257 2002.715945023644 2001.7375786606624 2000.7592122976805 1999.7808459346988 1998.802479571717 1997.8241132087353 1996.8457468457536 1995.8673804827718 1994.88901411979 1993.9106477568082 1992.9322813938265 1991.9539150308449 1990.975548667863 1989.9971823048813 1989.0188159418994 1988.0404495789178 1987.0620832159361 1986.0837168529542 1985.1053504899726 1984.1269841269907 1983.148617764009 1982.1702514010274 1981.1918850380455 1980.2135186750638 1979.235152312082 1978.2567859491003 1977.2784195861186 1976.3000532231367 1975.321686860155 1974.3433204971732 1973.3649541341915 1972.3865877712099 1971.408221408228 1970.4298550452463 1969.4514886822644 1968.4731223192828 1967.494755956301 1966.5163895933192 1965.5380232303376 1964.5596568673557 1963.581290504374 1962.6029241413924 1961.6245577784105 1960.6461914154288 1959.667825052447 1958.6894586894653 1957.7110923264836 1956.7327259635017 1955.7543596005198 1954.7759932375384 1953.7976268745565 1952.8192605115746 1951.8408941485932 1950.8625277856113 1949.8841614226294 1948.905795059648 1947.927428696666 1946.9490623336842 1945.9706959707023 1944.9923296077209 1944.013963244739 1943.035596881757 1942.0572305187757 1941.0788641557938 1940.100497792812 1939.1221314298305 1938.1437650668486 1937.1653987038667 1936.1870323408848 1935.2086659779034 1934.2302996149215 1933.2519332519396 1932.2735668889582 1931.2952005259763 1930.3168341629944 1929.338467800013 1928.360101437031 1927.3817350740492 1926.4033687110673 1925.4250023480859 1924.446635985104 1923.468269622122 1922.4899032591406 1921.5115368961588 1920.5331705331769 1919.5548041701954 1918.5764378072136 1917.5980714442317 1916.6197050812498 1915.6413387182683 1914.6629723552865 1913.6846059923046 1912.7062396293231 1911.7278732663412 1910.7495069033594 1909.771140540378 1908.792774177396 1907.8144078144142 1906.8360414514323 1905.8576750884508 1904.879308725469 1903.900942362487 1902.9225759995056 1901.9442096365237 1900.9658432735419 1899.9874769105604 1899.0091105475785 1898.0307441845966 1897.0523778216148 1896.0740114586333 1895.0956450956514 1894.1172787326695 1893.1389123696881 1892.1605460067062 1891.1821796437243 1890.203813280743 1889.225446917761 1888.2470805547791 1887.2687141917972 1886.2903478288158 1885.311981465834 1884.333615102852 1883.3552487398706 1882.3768823768887 1881.3985160139068 1880.4201496509254 1879.4417832879435 1878.4634169249616 1877.4850505619797 1876.5066841989983 1875.5283178360164 1874.5499514730345 1873.571585110053 1872.5932187470712 1871.6148523840893 1870.6364860211079 1869.658119658126 1868.679753295144 1867.7013869321622 1866.7230205691808 1865.744654206199 1864.766287843217 1863.7879214802356 1862.8095551172537 1861.8311887542718 1860.8528223912904 1859.8744560283085 1858.8960896653266 1857.9177233023447 1856.9393569393633 1855.9609905763814 1854.9826242133995 1854.004257850418 1853.0258914874362 1852.0475251244543 1851.0691587614729 1850.090792398491 1849.112426035509 1848.1340596725272 1847.1556933095458 1846.1773269465639 1845.198960583582 1844.2205942206006 1843.2422278576187 1842.2638614946368 1841.2854951316554 1840.3071287686735 1839.3287624056916 1838.3503960427097 1837.3720296797283 1836.3936633167464 1835.4152969537645 1834.436930590783 1833.4585642278012 1832.4801978648193 1831.5018315018378 1830.523465138856 1829.545098775874 1828.5667324128922 1827.5883660499107 1826.6099996869289 1825.631633323947 1824.6532669609655 1823.6749005979837 1822.6965342350018 1821.7181678720203 1820.7398015090384 1819.7614351460566 1818.7830687830747 1817.8047024200932 1816.8263360571113 1815.8479696941295 1814.869603331148 1813.8912369681661 1812.9128706051843 1811.9345042422028 1810.956137879221 1809.977771516239 1808.9994051532572 1808.0210387902757 1807.0426724272938 1806.064306064312 1805.0859397013305 1804.1075733383486 1803.1292069753667 1802.1508406123853 1801.1724742494034 1800.1941078864215 1799.2157415234396 1798.2373751604582 1797.2590087974763 1796.2806424344944 1795.302276071513 1794.3239097085311 1793.3455433455492 1792.3671769825678 1791.388810619586 1790.410444256604 1789.4320778936221 1788.4537115306407 1787.4753451676588 1786.496978804677 1785.5186124416955 1784.5402460787136 1783.5618797157317 1782.5835133527503 1781.6051469897684 1780.6267806267865 1779.6484142638046 1778.6700479008232 1777.6916815378413 1776.7133151748594 1775.734948811878 1774.756582448896 1773.7782160859142 1772.7998497229328 1771.821483359951 1770.843116996969 1769.8647506339871 1768.8863842710057 1767.9080179080238 1766.929651545042 1765.9512851820605 1764.9729188190786 1763.9945524560967 1763.0161860931153 1762.0378197301334 1761.0594533671515 1760.0810870041696 1759.1027206411882 1758.1243542782063 1757.1459879152244 1756.167621552243 1755.189255189261 1754.2108888262792 1753.2325224632978 1752.2541561003159 1751.275789737334 1750.297423374352 1749.3190570113707 1748.3406906483888 1747.3623242854069 1746.3839579224255 1745.4055915594436 1744.4272251964617 1743.4488588334802 1742.4704924704984 1741.4921261075165 1740.5137597445346 1739.5353933815531 1738.5570270185713 1737.5786606555894 1736.600294292608 1735.621927929626 1734.6435615666442 1733.6651952036627 1732.6868288406808 1731.708462477699 1730.730096114717 1729.7517297517356 1728.7733633887538 1727.7949970257719 1726.8166306627904 1725.8382642998085 1724.8598979368267 1723.8815315738452 1722.9031652108633 1721.9247988478814 1720.9464324848996 1719.9680661219181 1718.9896997589362 1718.0113333959544 1717.032967032973 1716.054600669991 1715.0762343070091 1714.0978679440277 1713.1195015810458 1712.141135218064 1711.162768855082 1710.1844024921006 1709.2060361291187 1708.2276697661368 1707.2493034031554 1706.2709370401735 1705.2925706771916 1704.3142043142102 1703.3358379512283 1702.3574715882464 1701.3791052252645 1700.400738862283 1699.4223724993012 1698.4440061363193 1697.465639773338 1696.487273410356 1695.5089070473741 1694.5305406843927 1693.5521743214108 1692.573807958429 1691.595441595447 1690.6170752324656 1689.6387088694837 1688.6603425065018 1687.6819761435204 1686.7036097805385 1685.7252434175566 1684.7468770545752 1683.7685106915933 1682.7901443286114 1681.8117779656295 1680.833411602648 1679.8550452396662 1678.8766788766843 1677.8983125137029 1676.919946150721 1675.941579787739 1674.9632134247577 1673.9848470617758 1673.006480698794 1672.028114335812 1671.0497479728306 1670.0713816098487 1669.0930152468668 1668.1146488838854 1667.1362825209035 1666.1579161579216 1665.1795497949402 1664.2011834319583 1663.2228170689764 1662.244450705995 1661.266084343013 1660.2877179800312 1659.3093516170493 1658.3309852540679 1657.352618891086 1656.374252528104 1655.3958861651226 1654.4175198021408 1653.4391534391589 1652.4607870761774 1651.4824207131956 1650.5040543502137 1649.5256879872318 1648.5473216242503 1647.5689552612685 1646.5905888982866 1645.6122225353051 1644.6338561723232 1643.6554898093414 1642.67712344636 1641.698757083378 1640.7203907203962 1639.7420243574143 1638.7636579944328 1637.785291631451 1636.806925268469 1635.8285589054876 1634.8501925425057 1633.8718261795239 1632.8934598165424 1631.9150934535605 1630.9367270905786 1629.9583607275968 1628.9799943646153 1628.0016280016334 1627.0232616386515 1626.0448952756701 1625.0665289126882 1624.0881625497063 1623.109796186725 1622.131429823743 1621.1530634607611 1620.1746970977792 1619.1963307347978 1618.217964371816 1617.239598008834 1616.2612316458526 1615.2828652828707 1614.3044989198888 1613.3261325569074 1612.3477661939255 1611.3693998309436 1610.3910334679617 1609.4126671049803 1608.4343007419984 1607.4559343790165 1606.477568016035 1605.4992016530532 1604.5208352900713 1603.5424689270899 1602.564102564108 1601.585736201126 1600.6073698381442 1599.6290034751628 1598.650637112181 1597.672270749199 1596.6939043862176 1595.7155380232357 1594.7371716602538 1593.7588052972724 1592.7804389342905 1591.8020725713086 1590.8237062083267 1589.8453398453453 1588.8669734823634 1587.8886071193815 1586.9102407564 1585.9318743934182 1584.9535080304363 1583.9751416674549 1582.996775304473 1582.018408941491 1581.0400425785092 1580.0616762155278 1579.0833098525459 1578.104943489564 1577.1265771265826 1576.1482107636007 1575.1698444006188 1574.1914780376374 1573.2131116746555 1572.2347453116736 1571.2563789486917 1570.2780125857103 1569.2996462227284 1568.3212798597465 1567.342913496765 1566.3645471337832 1565.3861807708013 1564.4078144078198 1563.429448044838 1562.451081681856 1561.4727153188742 1560.4943489558927 1559.5159825929109 1558.537616229929 1557.5592498669475 1556.5808835039657 1555.6025171409838 1554.6241507780023 1553.6457844150204 1552.6674180520386 1551.6890516890567 1550.7106853260752 1549.7323189630933 1548.7539526001115 1547.77558623713 1546.7972198741481 1545.8188535111663 1544.8404871481848 1543.862120785203 1542.883754422221 1541.9053880592392 1540.9270216962577 1539.9486553332758 1538.970288970294 1537.9919226073125 1537.0135562443306 1536.0351898813487 1535.0568235183673 1534.0784571553854 1533.1000907924035 1532.1217244294216 1531.1433580664402 1530.1649917034583 1529.1866253404764 1528.208258977495 1527.2298926145131 1526.2515262515312 1525.2731598885498 1524.294793525568 1523.316427162586 1522.3380607996041 1521.3596944366227 1520.3813280736408 1519.402961710659 1518.4245953476775 1517.4462289846956 1516.4678626217137 1515.4894962587323 1514.5111298957504 1513.5327635327685 1512.5543971697866 1511.5760308068052 1510.5976644438233 1509.6192980808414 1508.64093171786 1507.662565354878 1506.6841989918962 1505.7058326289148 1504.727466265933 1503.749099902951 1502.7707335399691 1501.7923671769877 1500.8140008140058 1499.835634451024 1498.8572680880425 1497.8789017250606 1496.9005353620787 1495.9221689990973 1494.9438026361154 1493.9654362731335 1492.9870699101516 1492.0087035471702 1491.0303371841883 1490.0519708212064 1489.073604458225 1488.095238095243 1487.1168717322612 1486.1385053692798 1485.1601390062979 1484.181772643316 1483.203406280334 1482.2250399173527 1481.2466735543708 1480.2683071913889 1479.2899408284075 1478.3115744654256 1477.3332081024437 1476.3548417394622 1475.3764753764804 1474.3981090134985 1473.4197426505166 1472.4413762875351 1471.4630099245533 1470.4846435615714 1469.50627719859 1468.527910835608 1467.5495444726262 1466.5711781096447 1465.5928117466628 1464.614445383681 1463.636079020699 1462.6577126577176 1461.6793462947358 1460.7009799317539 1459.7226135687724 1458.7442472057905 1457.7658808428087 1456.7875144798272 1455.8091481168453 1454.8307817538634 1453.8524153908816 1452.8740490279001 1451.8956826649182 1450.9173163019364 1449.938949938955 1448.960583575973 1447.9822172129911 1447.0038508500097 1446.0254844870278 1445.047118124046 1444.068751761064 1443.0903853980826 1442.1120190351007 1441.1336526721188 1440.1552863091374 1439.1769199461555 1438.1985535831736 1437.2201872201922 1436.2418208572103 1435.2634544942284 1434.2850881312465 1433.306721768265 1432.3283554052832 1431.3499890423013 1430.37162267932 1429.393256316338 1428.4148899533561 1427.4365235903747 1426.4581572273928 1425.479790864411 1424.501424501429 1423.5230581384476 1422.5446917754657 1421.5663254124838 1420.5879590495024 1419.6095926865205 1418.6312263235386 1417.6528599605572 1416.6744935975753 1415.6961272345934 1414.7177608716115 1413.73939450863 1412.7610281456482 1411.7826617826663 1410.8042954196849 1409.825929056703 1408.847562693721 1407.8691963307397 1406.8908299677578 1405.912463604776 1404.934097241794 1403.9557308788126 1402.9773645158307 1401.9989981528488 1401.0206317898674 1400.0422654268855 1399.0638990639036 1398.0855327009222 1397.1071663379403 1396.1287999749584 1395.1504336119765 1394.172067248995 1393.1937008860132 1392.2153345230313 1391.2369681600499 1390.258601797068 1389.280235434086 1388.3018690711046 1387.3235027081228 1386.3451363451409 1385.366769982159 1384.3884036191776 1383.4100372561957 1382.4316708932138 1381.4533045302323 1380.4749381672505 1379.4965718042686 1378.5182054412871 1377.5398390783052 1376.5614727153234 1375.5831063523415 1374.60473998936 1373.6263736263782 1372.6480072633963 1371.6696409004148 1370.691274537433 1369.712908174451 1368.7345418114696 1367.7561754484877 1366.7778090855059 1365.799442722524 1364.8210763595425 1363.8427099965606 1362.8643436335788 1361.8859772705973 1360.9076109076154 1359.9292445446335 1358.9508781816521 1357.9725118186702 1356.9941454556883 1356.0157790927065 1355.037412729725 1354.0590463667431 1353.0806800037612 1352.1023136407798 1351.123947277798 1350.145580914816 1349.1672145518346 1348.1888481888527 1347.2104818258708 1346.232115462889 1345.2537490999075 1344.2753827369256 1343.2970163739437 1342.3186500109623 1341.3402836479804 1340.3619172849985 1339.383550922017 1338.4051845590352 1337.4268181960533 1336.4484518330714 1335.47008547009 1334.491719107108 1333.5133527441262 1332.5349863811448 1331.556620018163 1330.578253655181 1329.5998872921996 1328.6215209292177 1327.6431545662358 1326.6647882032544 1325.6864218402725 1324.7080554772906 1323.7296891143087 1322.7513227513273 1321.7729563883454 1320.7945900253635 1319.816223662382 1318.8378572994002 1317.8594909364183 1316.8811245734369 1315.902758210455 1314.924391847473 1313.9460254844912 1312.9676591215098 1311.9892927585279 1311.010926395546 1310.0325600325646 1309.0541936695827 1308.0758273066008 1307.0974609436194 1306.1190945806375 1305.1407282176556 1304.1623618546737 1303.1839954916923 1302.2056291287104 1301.2272627657285 1300.248896402747 1299.2705300397652 1298.2921636767833 1297.3137973138018 1296.33543095082 1295.357064587838 1294.3786982248562 1293.4003318618747 1292.4219654988929 1291.443599135911 1290.4652327729295 1289.4868664099477 1288.5085000469658 1287.5301336839843 1286.5517673210024 1285.5734009580206 1284.5950345950387 1283.6166682320572 1282.6383018690753 1281.6599355060935 1280.681569143112 1279.7032027801301 1278.7248364171483 1277.7464700541668 1276.768103691185 1275.789737328203 1274.8113709652212 1273.8330046022397 1272.8546382392578 1271.876271876276 1270.8979055132945 1269.9195391503126 1268.9411727873307 1267.9628064243493 1266.9844400613674 1266.0060736983855 1265.0277073354036 1264.0493409724222 1263.0709746094403 1262.0926082464584 1261.114241883477 1260.1358755204951 1259.1575091575132 1258.1791427945318 1257.20077643155 1256.222410068568 1255.2440437055861 1254.2656773426047 1253.2873109796228 1252.308944616641 1251.3305782536595 1250.3522118906776 1249.3738455276957 1248.3954791647143 1247.4171128017324 1246.4387464387505 1245.4603800757686 1244.4820137127872 1243.5036473498053 1242.5252809868234 1241.546914623842 1240.56854826086 1239.5901818978782 1238.6118155348968 1237.633449171915 1236.655082808933 1235.6767164459511 1234.6983500829697 1233.7199837199878 1232.741617357006 1231.7632509940245 1230.7848846310426 1229.8065182680607 1228.8281519050793 1227.8497855420974 1226.8714191791155 1225.8930528161336 1224.9146864531522 1223.9363200901703 1222.9579537271884 1221.979587364207 1221.001221001225 1220.0228546382432 1219.0444882752618 1218.0661219122799 1217.087755549298 1216.109389186316 1215.1310228233347 1214.1526564603528 1213.1742900973709 1212.1959237343895 1211.2175573714076 1210.2391910084257 1209.2608246454442 1208.2824582824624 1207.3040919194805 1206.3257255564986 1205.3473591935171 1204.3689928305353 1203.3906264675534 1202.412260104572 1201.43389374159 1200.4555273786082 1199.4771610156267 1198.4987946526448 1197.520428289663 1196.542061926681 1195.5636955636996 1194.5853292007178 1193.6069628377359 1192.6285964747544 1191.6502301117725 1190.6718637487907 1189.6934973858092 1188.7151310228273 1187.7367646598454 1186.7583982968636 1185.7800319338821 1184.8016655709002 1183.8232992079184 1182.844932844937 1181.866566481955 1180.8882001189731 1179.9098337559917 1178.9314673930098 1177.953101030028 1176.974734667046 1175.9963683040646 1175.0180019410827 1174.0396355781008 1173.0612692151194 1172.0829028521375 1171.1045364891556 1170.1261701261742 1169.1478037631923 1168.1694374002104 1167.1910710372285 1166.212704674247 1165.2343383112652 1164.2559719482833 1163.277605585302 1162.29923922232 1161.3208728593381 1160.3425064963567 1159.3641401333748 1158.385773770393 1157.407407407411 1156.4290410444296 1155.4506746814477 1154.4723083184658 1153.4939419554844 1152.5155755925025 1151.5372092295206 1150.5588428665392 1149.5804765035573 1148.6021101405754 1147.6237437775935 1146.645377414612 1145.6670110516302 1144.6886446886483 1143.7102783256669 1142.731911962685 1141.753545599703 1140.7751792367217 1139.7968128737398 1138.818446510758 1137.840080147776 1136.8617137847946 1135.8833474218127 1134.9049810588308 1133.9266146958494 1132.9482483328675 1131.9698819698856 1130.9915156069042 1130.0131492439223 1129.0347828809404 1128.0564165179585 1127.078050154977 1126.0996837919952 1125.1213174290133 1124.1429510660319 1123.16458470305 1122.186218340068 1121.2078519770866 1120.2294856141048 1119.2511192511229 1118.272752888141 1117.2943865251596 1116.3160201621777 1115.3376537991958 1114.3592874362143 1113.3809210732325 1112.4025547102506 1111.4241883472691 1110.4458219842872 1109.4674556213054 1108.4890892583235 1107.510722895342 1106.5323565323602 1105.5539901693783 1104.5756238063968 1103.597257443415 1102.618891080433 1101.6405247174516 1100.6621583544697 1099.6837919914879 1098.705425628506 1097.7270592655245 1096.7486929025426 1095.7703265395608 1094.7919601765793 1093.8135938135974 1092.8352274506155 1091.8568610876341 1090.8784947246522 1089.9001283616703 1088.9217619986885 1087.943395635707 1086.9650292727251 1085.9866629097432 1085.0082965467618 1084.02993018378 1083.051563820798 1082.0731974578166 1081.0948310948347 1080.1164647318528 1079.138098368871 1078.1597320058895 1077.1813656429076 1076.2029992799257 1075.2246329169443 1074.2462665539624 1073.2679001909805 1072.289533827999 1071.3111674650172 1070.3328011020353 1069.3544347390534 1068.376068376072 1067.39770201309 1066.4193356501082 1065.4409692871268 1064.462602924145 1063.484236561163 1062.5058701981816 1061.5275038351997 1060.5491374722178 1059.570771109236 1058.5924047462545 1057.6140383832726 1056.6356720202907 1055.6573056573093 1054.6789392943274 1053.7005729313455 1052.722206568364 1051.7438402053822 1050.7654738424003 1049.7871074794184 1048.808741116437 1047.830374753455 1046.8520083904732 1045.8736420274918 1044.8952756645099 1043.916909301528 1042.9385429385466 1041.9601765755647 1040.9818102125828 1040.003443849601 1039.0250774866195 1038.0467111236376 1037.0683447606557 1036.0899783976743 1035.1116120346924 1034.1332456717105 1033.154879308729 1032.1765129457472 1031.1981465827653 1030.2197802197834 1029.241413856802 1028.26304749382 1027.2846811308382 1026.3063147678567 1025.3279484048749 1024.349582041893 1023.3712156789115 1022.3928493159297 1021.4144829529478 1020.4361165899659 1019.4577502269844 1018.4793838640026 1017.5010175010207 1016.5226511380392 1015.5442847750573 1014.5659184120755 1013.587552049094 1012.6091856861121 1011.6308193231303 1010.6524529601484 1009.6740865971669 1008.695720234185 1007.7173538712032 1006.7389875082217 1005.7606211452398 1004.782254782258 1003.8038884192765 1002.8255220562946 1001.8471556933127 1000.8687893303309 999.8904229673494 998.9120566043675 997.9336902413856 996.9553238784042 995.9769575154223 994.9985911524404 994.020224789459 993.0418584264771 992.0634920634952 991.0851257005138 990.1067593375319 989.12839297455 988.1500266115681 987.1716602485867 986.1932938856048 985.2149275226229 984.2365611596415 983.2581947966596 982.2798284336777 981.3014620706963 980.3230957077144 979.3447293447325 978.3663629817506 977.3879966187692 976.4096302557873 975.4312638928054 974.452897529824 973.4745311668421 972.4961648038602 971.5177984408788 970.5394320778969 969.561065714915 968.5826993519331 967.6043329889517 966.6259666259698 965.6476002629879 964.6692339000065 963.6908675370246 962.7125011740427 961.7341348110613 960.7557684480794 959.7774020850975 958.7990357221156 957.8206693591342 956.8423029961523 955.8639366331704 954.885570270189 953.9072039072071 952.9288375442252 951.9504711812438 950.9721048182619 949.99373845528 949.0153720922981 948.0370057293167 947.0586393663348 946.0802730033529 945.1019066403715 944.1235402773896 943.1451739144077 942.1668075514262 941.1884411884444 940.2100748254625 939.2317084624806 938.2533420994992 937.2749757365173 936.2966093735354 935.3182430105539 934.339876647572 933.3615102845902 932.3831439216087 931.4047775586268 930.426411195645 929.4480448326631 928.4696784696816 927.4913121066998 926.5129457437179 925.5345793807364 924.5562130177545 923.5778466547727 922.5994802917912 921.6211139288093 920.6427475658274 919.6643812028456 918.6860148398641 917.7076484768822 916.7292821139004 915.7509157509189 914.772549387937 913.7941830249551 912.8158166619737 911.8374502989918 910.8590839360099 909.880717573028 908.9023512100466 907.9239848470647 906.9456184840828 905.9672521211014 904.9888857581195 904.0105193951376 903.0321530321562 902.0537866691743 901.0754203061924 900.0970539432105 899.1186875802291 898.1403212172472 897.1619548542653 896.1835884912839 895.205222128302 894.2268557653201 893.2484894023387 892.2701230393568 891.2917566763749 890.313390313393 889.3350239504116 888.3566575874297 887.3782912244478 886.3999248614664 885.4215584984845 884.4431921355026 883.4648257725212 882.4864594095393 881.5080930465574 880.5297266835755 879.5513603205941 878.5729939576122 877.5946275946303 876.6162612316489 875.637894868667 874.6595285056851 873.6811621427037 872.7027957797218 871.7244294167399 870.746063053758 869.7676966907766 868.7893303277947 867.8109639648128 866.8325976018314 865.8542312388495 864.8758648758676 863.8974985128862 862.9191321499043 861.9407657869224 860.9623994239405 859.9840330609591 859.0056666979772 858.0273003349953 857.0489339720139 856.070567609032 855.0922012460501 854.1138348830686 853.1354685200868 852.1571021571049 851.178735794123 850.2003694311416 849.2220030681597 848.2436367051778 847.2652703421963 846.2869039792145 845.3085376162326 844.3301712532511 843.3518048902692 842.3734385272874 841.3950721643055 840.416705801324 839.4383394383422 838.4599730753603 837.4816067123788 836.503240349397 835.5248739864151 834.5465076234336 833.5681412604517 832.5897748974699 831.611408534488 830.6330421715065 829.6546758085246 828.6763094455428 827.6979430825613 826.7195767195794 825.7412103565975 824.7628439936161 823.7844776306342 822.8061112676523 821.8277449046705 820.849378541689 819.8710121787071 818.8926458157252 817.9142794527438 816.9359130897619 815.95754672678 814.9791803637986 814.0008140008167 813.0224476378348 812.0440812748529 811.0657149118715 810.0873485488896 809.1089821859077 808.1306158229263 807.1522494599444 806.1738830969625 805.1955167339811 804.2171503709992 803.2387840080173 802.2604176450354 801.282051282054 800.3036849190721 799.3253185560902 798.3469521931088 797.3685858301269 796.390219467145 795.4118531041636 794.4334867411817 793.4551203781998 792.4767540152179 791.4983876522365 790.5200212892546 789.5416549262727 788.5632885632913 787.5849222003094 786.6065558373275 785.6281894743461 784.6498231113642 783.6714567483823 782.6930903854004 781.714724022419 780.7363576594371 779.7579912964552 778.7796249334738 777.8012585704919 776.82289220751 775.8445258445286 774.8661594815467 773.8877931185648 772.9094267555829 771.9310603926015 770.9526940296196 769.9743276666377 768.9959613036563 768.0175949406744 767.0392285776925 766.060862214711 765.0824958517292 764.1041294887473 763.1257631257654 762.147396762784 761.1690303998021 760.1906640368202 759.2122976738387 758.2339313108569 757.255564947875 756.2771985848935 755.2988322219117 754.3204658589298 753.3420994959479 752.3637331329664 751.3853667699846 750.4070004070027 749.4286340440212 748.4502676810393 747.4719013180575 746.493534955076 745.5151685920941 744.5368022291123 743.5584358661304 742.5800695031489 741.601703140167 740.6233367771852 739.6449704142037 738.6666040512218 737.68823768824 736.7098713252585 735.7315049622766 734.7531385992947 733.7747722363129 732.7964058733314 731.8180395103495 730.8396731473676 729.8613067843862 728.8829404214043 727.9045740584224 726.926207695441 725.9478413324591 724.9694749694772 723.9911086064953 723.0127422435139 722.034375880532 721.0560095175501 720.0776431545687 719.0992767915868 718.1209104286049 717.1425440656235 716.1641777026416 715.1858113396597 714.2074449766778 713.2290786136964 712.2507122507145 711.2723458877326 710.2939795247512 709.3156131617693 708.3372467987874 707.358880435806 706.3805140728241 705.4021477098422 704.4237813468603 703.4454149838789 702.467048620897 701.4886822579151 700.5103158949337 699.5319495319518 698.5535831689699 697.5752168059885 696.5968504430066 695.6184840800247 694.6401177170428 693.6617513540614 692.6833849910795 691.7050186280976 690.7266522651162 689.7482859021343 688.7699195391524 687.791553176171 686.8131868131891 685.8348204502072 684.8564540872253 683.8780877242439 682.899721361262 681.9213549982801 680.9429886352987 679.9646222723168 678.9862559093349 678.0078895463535 677.0295231833716 676.0511568203897 675.0727904574078 674.0944240944264 673.1160577314445 672.1376913684626 671.1593250054812 670.1809586424993 669.2025922795174 668.2242259165359 667.245859553554 666.2674931905722 665.2891268275907 664.3107604646088 663.332394101627 662.3540277386451 661.3756613756636 660.3972950126818 659.4189286496999 658.4405622867184 657.4621959237365 656.4838295607547 655.5054631977732 654.5270968347913 653.5487304718094 652.5703641088276 651.5919977458461 650.6136313828642 649.6352650198824 648.6568986569009 647.678532293919 646.7001659309371 645.7217995679557 644.7434332049738 643.7650668419919 642.78670047901 641.8083341160286 640.8299677530467 639.8516013900648 638.8732350270834 637.8948686641015 636.9165023011196 635.9381359381382 634.9597695751563 633.9814032121744 633.0030368491925 632.0246704862111 631.0463041232292 630.0679377602473 629.0895713972659 628.111205034284 627.1328386713021 626.1544723083207 625.1761059453388 624.1977395823569 623.219373219375 622.2410068563936 621.2626404934117 620.2842741304298 619.3059077674484 618.3275414044665 617.3491750414846 616.3708086785032 615.3924423155213 614.4140759525394 613.4357095895575 612.4573432265761 611.4789768635942 610.5006105006123 609.5222441376309 608.543877774649 607.5655114116671 606.5871450486857 605.6087786857038 604.6304123227219 603.65204595974 602.6736795967586 601.6953132337767 600.7169468707948 599.7385805078134 598.7602141448315 597.7818477818496 596.8034814188682 595.8251150558863 594.8467486929044 593.8683823299225 592.8900159669411 591.9116496039592 590.9332832409773 589.9549168779959 588.976550515014 587.9981841520321 587.0198177890506 586.0414514260688 585.0630850630869 584.084718700105 583.1063523371236 582.1279859741417 581.1496196111598 580.1712532481783 579.1928868851965 578.2145205222146 577.2361541592331 576.2577877962513 575.2794214332694 574.3010550702875 573.322688707306 572.3443223443242 571.3659559813423 570.3875896183608 569.409223255379 568.4308568923971 567.4524905294156 566.4741241664337 565.4957578034519 564.51739144047 563.5390250774885 562.5606587145066 561.5822923515248 560.6039259885433 559.6255596255614 558.6471932625795 557.6688268995981 556.6904605366162 555.7120941736343 554.7337278106525 553.755361447671 552.7769950846891 551.7986287217072 550.8202623587258 549.8418959957439 548.863529632762 547.8851632697806 546.9067969067987 545.9284305438168 544.9500641808349 543.9716978178535 542.9933314548716 542.0149650918897 541.0365987289083 540.0582323659264 539.0798660029445 538.1014996399631 537.1231332769812 536.1447669139993 535.1664005510174 534.188034188036 533.2096678250541 532.2313014620722 531.2529350990908 530.2745687361089 529.296202373127 528.3178360101456 527.3394696471637 526.3611032841818 525.3827369211999 524.4043705582185 523.4260041952366 522.4476378322547 521.4692714692733 520.4909051062914 519.5125387433095 518.5341723803281 517.5558060173462 516.5774396543643 515.5990732913824 514.620706928401 513.6423405654191 512.6639742024372 511.68560783945577 510.7072414764739 509.728875113492 508.75050875051056 507.7721423875287 506.7937760245468 505.8154096615649 504.83704329858347 503.8586769356016 502.8803105726197 501.90194420963826 500.92357784665637 499.9452114836745 498.96684512069305 497.98847875771116 497.0101123947293 496.0317460317474 495.05337966876596 494.07501330578407 493.0966469428022 492.11828057982075 491.13991421683886 490.161547853857 489.18318149087554 488.20481512789365 487.22644876491177 486.2480824019299 485.26971603894845 484.29134967596656 483.31298331298467 482.33461695000324 481.35625058702135 480.37788422403946 479.39951786105803 478.42115149807614 477.44278513509425 476.46441877211237 475.48605240913093 474.50768604614905 473.52931968316716 472.5509533201857 471.57258695720384 470.59422059422195 469.6158542312405 468.63748786825863 467.65912150527674 466.68075514229486 465.7023887793134 464.72402241633154 463.74565605334965 462.7672896903682 461.7889233273863 460.81055696440444 459.832190601423 458.8538242384411 457.87545787545923 456.89709151247735 455.9187251494959 454.940358786514 453.96199242353214 452.9836260605507 452.0052596975688 451.02689333458693 450.0485269716055 449.0701606086236 448.0917942456417 447.11342788265983 446.1350615196784 445.1566951566965 444.1783287937146 443.1999624307332 442.2215960677513 441.2432297047694 440.264863341788 439.2864969788061 438.3081306158242 437.3297642528423 436.3513978898609 435.373031526879 434.3946651638971 433.4162988009157 432.4379324379338 431.4595660749519 430.4811997119705 429.5028333489886 428.5244669860067 427.5461006230248 426.5677342600434 425.5893678970615 424.6110015340796 423.6326351710982 422.6542688081163 421.6759024451344 420.69753608215296 419.7191697191711 418.7408033561892 417.7624369932073 416.78407063022587 415.805704267244 414.8273379042621 413.84897154128066 412.8706051782988 411.8922388153169 410.91387245233545 409.93550608935357 408.9571397263717 407.9787733633898 407.00040700040836 406.02204063742647 405.0436742744446 404.06530791146315 403.08694154848126 402.1085751854994 401.13020882251794 400.15184245953606 399.17347609655417 398.1951097335723 397.21674337059085 396.23837700760896 395.2600106446271 394.28164428164564 393.30327791866375 392.32491155568187 391.34654519270043 390.36817882971854 389.38981246673666 388.41144610375477 387.43307974077334 386.45471337779145 385.47634701480956 384.49798065182813 383.51961428884624 382.54124792586435 381.5628815628829 380.58451519990103 379.60614883691915 378.62778247393726 377.6494161109558 376.67104974797394 375.69268338499205 374.7143170220106 373.73595065902873 372.75758429604684 371.7792179330654 370.8008515700835 369.82248520710164 368.84411884411975 367.8657524811383 366.8873861181564 365.90901975517454 364.9306533921931 363.9522870292112 362.97392066622933 361.9955543032479 361.017187940266 360.0388215772841 359.06045521430224 358.0820888513208 357.1037224883389 356.12535612535703 355.1469897623756 354.1686233993937 353.1902570364118 352.2118906734304 351.2335243104485 350.2551579474666 349.2767915844847 348.2984252215033 347.3200588585214 346.3416924955395 345.3633261325581 344.3849597695762 343.4065934065943 342.4282270436129 341.449860680631 340.4714943176491 339.4931279546672 338.5147615916858 337.5363952287039 336.558028865722 335.5796625027406 334.6012961397587 333.6229297767768 332.64456341379537 331.6661970508135 330.6878306878316 329.70946432485016 328.7310979618683 327.7527315988864 326.7743652359045 325.79599887292306 324.8176325099412 323.8392661469593 322.86089978397786 321.88253342099597 320.9041670580141 319.92580069503265 318.94743433205076 317.9690679690689 316.990701606087 316.01233524310555 315.03396888012367 314.0556025171418 313.07723615416035 312.09886979117846 311.12050342819657 310.14213706521514 309.16377070223325 308.18540433925136 307.2070379762695 306.22867161328804 305.25030525030616 304.27193888732427 303.29357252434284 302.31520616136095 301.33683979837906 300.3584734353976 299.38010707241574 298.40174070943385 297.42337434645196 296.44500798347053 295.46664162048864 294.48827525750676 293.5099088945253 292.53154253154344 291.55317616856155 290.5748098055801 289.59644344259823 288.61807707961634 287.63971071663445 286.661344353653 285.68297799067113 284.70461162768925 283.7262452647078 282.7478789017259 281.76951253874404 280.7911461757626 279.8127798127807 278.83441344979883 277.85604708681694 276.8776807238355 275.8993143608536 274.92094799787174 273.9425816348903 272.9642152719084 271.9858489089265 271.0074825459451 270.0291161829632 269.0507498199813 268.07238345699943 267.094017094018 266.1156507310361 265.1372843680542 264.1589180050728 263.1805516420909 262.202185279109 261.2238189161276 260.2454525531457 259.2670861901638 258.2887198271819 257.3103534642005 256.3319871012186 255.3536207382367 254.37525437525528 253.3968880122734 252.4185216492915 251.44015528631007 250.46178892332819 249.4834225603463 248.5050561973644 247.52668983438298 246.5483234714011 245.5699571084192 244.59159074543777 243.61322438245588 242.634858019474 241.65649165649256 240.67812529351067 239.6997589305288 238.7213925675469 237.74302620456547 236.76465984158358 235.7862934786017 234.80792711562026 233.82956075263837 232.85119438965648 231.87282802667505 230.89446166369316 229.91609530071128 228.9377289377294 227.95936257474796 226.98099621176607 226.00262984878418 225.02426348580275 224.04589712282086 223.06753075983897 222.08916439685754 221.11079803387565 220.13243167089377 219.15406530791188 218.17569894493045 217.19733258194856 216.21896621896667 215.24059985598524 214.26223349300335 213.28386713002146 212.30550076704003 211.32713440405814 210.34876804107626 209.37040167809437 208.39203531511293 207.41366895213105 206.43530258914916 205.45693622616773 204.47856986318584 203.50020350020395 202.52183713722252 201.54347077424063 200.56510441125874 199.58673804827686 198.60837168529542 197.63000532231354 196.65163895933165 195.67327259635022 194.69490623336833 193.71653987038644 192.738173507405 191.75980714442312 190.78144078144123 189.80307441845935 188.8247080554779 187.84634169249603 186.86797532951414 185.8896089665327 184.91124260355082 183.93287624056893 182.9545098775875 181.9761435146056 180.99777715162372 180.01941078864184 179.0410444256604 178.06267806267851 177.08431169969663 176.1059453367152 175.1275789737333 174.14921261075142 173.17084624777 172.1924798847881 171.2141135218062 170.23574715882432 169.2573807958429 168.279014432861 167.30064806987912 166.32228170689768 165.3439153439158 164.3655489809339 163.38718261795248 162.4088162549706 161.4304498919887 160.4520835290068 159.47371716602538 158.4953508030435 157.5169844400616 156.53861807708017 155.56025171409829 154.5818853511164 153.60351898813497 152.62515262515308 151.6467862621712 150.6684198991893 149.69005353620787 148.71168717322598 147.7333208102441 146.75495444726266 145.77658808428077 144.7982217212989 143.81985535831745 142.84148899533557 141.86312263235368 140.8847562693718 139.90638990639036 138.92802354340847 137.94965718042658 136.97129081744515 135.99292445446326 135.01455809148138 134.03619172849994 133.05782536551806 132.07945900253617 131.10109263955428 130.12272627657285 129.14435991359096 128.16599355060907 127.18762718762764 126.20926082464575 125.23089446166387 124.25252809868243 123.27416173570055 122.29579537271866 121.31742900973677 120.33906264675534 119.36069628377345 118.38232992079156 117.40396355781013 116.42559719482824 115.44723083184635 114.46886446886492 113.49049810588303 112.51213174290115 111.53376537991926 110.55539901693783 109.57703265395594 108.59866629097405 107.62029992799262 106.64193356501073 105.66356720202884 104.68520083904741 103.70683447606552 102.72846811308364 101.75010175010175 100.77173538712032 99.79336902413843 98.81500266115654 97.83663629817511 96.85826993519322 95.87990357221133 94.9015372092299 93.92317084624801 92.94480448326613 91.96643812028424 90.9880717573028 90.00970539432092 89.03133903133903 88.0529726683576 87.07460630537571 86.09623994239382 85.11787357941239 84.1395072164305 83.16114085344861 82.18277449046673 81.2044081274853 80.2260417645034 79.24767540152152 78.26930903854009 77.2909426755582 76.31257631257631 75.33420994959488 74.35584358661299 73.3774772236311 72.39911086064922 71.42074449766778 70.4423781346859 69.46401177170401 68.48564540872258 67.50727904574069 66.5289126827588 65.55054631977737 64.57217995679548 63.59381359381359 62.615447230831705 61.63708086785027 60.658714504868385 59.6803481418865 58.701981778905065 57.72361541592318 56.74524905294129 55.76688268995986 54.78851632697797 53.81014996399608 52.831783601014195 51.85341723803276 50.875050875050874 49.89668451206899 48.918318149087554 47.93995178610567 46.96158542312378 45.983219060142346 45.00485269716046 44.02648633417857 43.048119971196684 42.06975360821525 41.09138724523336 40.113020882251476 39.13465451927004 38.156288156288156 37.17792179330627 36.199555430324835 35.22118906734295 34.24282270436106 33.26445634137917 32.28608997839774 31.307723615415853 30.329357252433965 29.350990889452532 28.372624526470645 27.394258163488757 26.415891800507325 25.437525437525437 24.45915907454355 23.480792711561662 22.50242634858023 21.524059985598342 20.545693622616454 19.56732725963502 18.588960896653134 17.610594533671247 16.632228170689814 15.653861807707926 14.675495444726039 13.697129081744151 12.718762718762719 11.740396355780831 10.762029992798944 9.78366362981751 8.805297266835623 7.826930903853736 6.848564540872303 5.8701981778904155 4.891831814908528 3.9134654519266405 2.9350990889452078 1.9567327259633203 0.9783663629814328 0.0 -0.004238252118204266 -0.0045603805769371284 -0.005030642488652811 -0.004965798448258534 -0.004725057817351921 -0.0037501153097230047 -0.0030330276958613622 -0.003305144475345852 -0.0032802337149597806 -0.003526488941677051 -0.0033593396410712744 -0.002659366290070292 -0.0020191027006053884 -0.002223332904075928 -0.0018470092796176434 -0.0016863253672036716 -9.270225716190685E-4 -8.351760276001946E-4 -5.501284717320954E-4 -2.5443204119514123E-4 -4.927006119107705E-4 -1.8825689146725698E-4 6.857114652837664E-4 3.962902644623874E-4 1.445204419344599E-5 1.0059383392543327E-4 3.282135299722076E-4 0.0010671693686002486 0.0011050109053699297 -1.6144454631889006E-4 -0.002067212795091465 -0.003117838376259743 -0.002516557274421898 -0.0015963804079470933 -0.0013864454501896673 -0.0012227190021560225 -3.516030225484426E-4 -6.242902774616208E-4 -6.695479948042543E-4 -4.5124606409272807E-4 -1.658181912721698E-4 1.5440868269839662E-4 9.222686097133296E-5 -7.80600544922313E-4 -0.0012303253412052047 -5.255980282984831E-4 -6.043236374575178E-4 -2.2077399090251044E-4 -2.586155276721914E-5 1.7114262860659725E-6 6.161134629837502E-5 -1.293077638360957E-4 -3.9743121531976474E-5 0.001686135208727442 0.0031790694056056585 0.002912086904979367 0.003411252905081942 0.002343132744100546 0.0011582552787142042 -2.9170310253613354E-4 -8.593261540813477E-4 -4.601835124755171E-5 9.376714462879233E-4 0.0010433995590715547 5.76180182975544E-4 -0.001014305312208433 -0.001743563068548767 -0.0016288975073823467 -0.0011285905564223941 1.7114262860659724E-5 2.4568475128858183E-4 -4.0960135779845606E-4 8.269992131223239E-4 0.0021712294815890306 0.0016271860810962808 0.001499209426593792 0.0024969709513702537 0.0010806706204125468 -9.298749487625117E-5 -0.0014807640543995253 -0.0023459851212439893 -0.0026831360995989858 -0.003105478075304822 -0.0022800001299923345 -0.0017486973474069648 -7.123336519559036E-4 -1.7627690746479518E-4 2.169708213779194E-4 -7.471326531059118E-4 -0.0011576848032855155 -5.539316412566864E-4 0.0011358165785191172 6.936981212854075E-4 -5.345354766812721E-4 -0.0016307990921446422 -0.001414208587719182 -2.886605669164607E-4 -1.4318933260085303E-4 -1.2664554516888195E-4 1.3158966555085034E-4 6.168740968886683E-4 0.0012483903964470122 3.495112793099175E-4 -7.594929540608327E-4 -0.0014530009168700106 -0.0010127840443985966 -9.568774523871082E-4 -0.0016488641473864497 -0.0029641903274662644 -0.0027603404409481842 -0.0019437999440184857 -0.001084473789937138 -6.902752687132756E-5 -3.038732450148249E-4 -3.995229585582898E-4 -6.55286109087038E-4 -6.275229715575233E-6 -2.6241869719678245E-4 -5.037298035320846E-4 -2.9531611358449506E-4 3.2117766635171417E-4 8.878499255157807E-4 0.0010608941388846735 4.3051879018370684E-4 -5.556430675427524E-4 -5.043002789607733E-4 2.230558926172651E-4 5.615379803058686E-4 -5.16280262963235E-4 -0.0012712094135945585 -2.4473395890743405E-4 4.215813418009179E-4 -1.9966640004103013E-5 7.728040473969014E-4 0.0010051777053494146 5.839766805009558E-4 0.002326969273621034 0.0028090210108629495 0.0011097648672756684 2.8447708043941055E-4 6.46728977656708E-4 9.878732840125253E-4 0.001238692314159305 5.427122911591428E-4 -0.0011445638684256766 -0.0015807874128962699 -0.0015475096795560983 -0.0011198432665158347 -5.349157936337312E-4 -2.5119934709923886E-4 -4.320400579935433E-4 -4.947923551492956E-4 3.1566307054105716E-5 5.004971094361822E-4 0.0013704721381863848 0.001823809945517638 0.001316847447889651 5.206539079165147E-4 0.0010295179903067973 5.864487406919399E-4 1.0268557716395834E-5 -6.971209738575395E-4 -0.0013834029145699945 -0.0024218583532595807 -7.901084687337907E-4 9.517431735289102E-4 3.94768996652551E-4 -4.2728609608780446E-4 1.2759633755002973E-4 -3.919166195091077E-4 -4.335613258033797E-4 2.8713929910662427E-5 -3.3524939359270105E-4 -8.623686897010205E-4 -5.459449852550452E-4 -4.411676648525618E-4 -3.4418684197549005E-4 -1.2550459431150466E-5 7.208907833862336E-4 3.991426416058307E-4 8.836664390387305E-4 0.001029137673354338 0.0015927673968987317 0.002588817495389128 0.003286128627722897 0.0038566040564115543 0.0033098984372515908 0.002857701580777715 0.0017707557306495929 8.410709403633107E-4 -2.9531611358449506E-4 -0.0011749892246224049 -5.444237174452089E-4 1.3881568764757332E-5 -4.088407238935379E-4 -2.618482217680938E-4 9.70568862675636E-4 6.528140488960537E-4 6.549057921345789E-4 9.557365015297308E-4 7.842135559706745E-4 2.0213846023201432E-4 -0.0010460617777387684 5.8949127631161276E-5 5.581151277337365E-4 0.001858608946667646 0.001856136886476662 5.219850172501216E-4 0.0015446573024126549 0.0018648841763832214 0.001262462123687999 5.170408968681533E-4 -8.477264870313451E-4 -8.355563445526537E-4 7.054879468116398E-5 5.773211338329214E-4 0.001212830761392086 6.575680108017926E-4 6.712594210903203E-4 0.0014364571294380396 0.0013109525351265349 3.888740838894349E-4 0.0011090042333707503 0.0012525738829240623 9.173244893313613E-4 0.0010983553587018953 0.0014278999980077097 0.002302628988663651 0.002199943411499693 0.00198449385793161 0.0022562303204636406 0.0018129709123725535 2.3294413338120182E-4 -1.2835697145494794E-4 6.957898645239326E-4 0.0012539049922576692 9.730409228666201E-4 8.486772794124928E-4 6.847606729026186E-4 0.0012440167514937324 0.0023343854541939867 0.002957154463845771 0.0028637866520170607 0.0010293278318305678 -3.932477288427146E-4 -7.026355696681965E-4 -1.3976648002872108E-4 -3.810775863640232E-4 -0.001773608107793036 -0.001662745716151207 7.587323201559144E-5 4.476330530443666E-4 1.7152294555905636E-4 8.56663935414134E-4 0.0010403570234518817 -9.878732840125253E-4 -0.0011921034874830647 -0.0012346989861584843 -0.001102348686702716 -0.0010511960565969662 -9.477498455280896E-4 -9.857815407740003E-4 -0.001287182725597841 -0.0019757465680250506 -0.001647913355005302 -1.137147687852724E-4 0.0013894879858093402 0.0015844004239446315 9.796964695346544E-4 0.001355069301611791 0.0019023453962004433 0.0010044170714444962 0.0014490075888691902 0.0018205772514217357 7.807907033985426E-4 -2.645104404353075E-4 5.328240503952061E-4 0.001443492993058533 3.4057383092712853E-4 3.6092078788369067E-4 8.382185632198674E-4 -1.409074308860984E-4 -0.0026158199990137243 -0.005224794292883184 -0.0028166273499121318 -3.4456715892794914E-4 4.6018351247551707E-4 3.9610010598615787E-4 7.149958706231174E-5 3.5255381492959036E-4 4.4059718942387316E-4 9.924370874420344E-4 0.001894358740198802 0.0015781251942290561 4.961234644829025E-4 -8.102652672141232E-4 -0.0014784821526847708 -9.466088946707123E-4 -5.286405639181559E-4 -3.536947657869677E-5 2.1240701794841013E-4 0.0015878232765167634 0.001227663122537991 2.325638164287427E-4 -2.78772326152524E-4 1.7399500575004053E-4 5.636297235443936E-4 6.341785182255576E-4 0.0011727073229076503 4.339416427558388E-4 0.0010607039804084437 0.001189441268815851 2.937948457746586E-4 -7.98475441687891E-4 -1.0458716192625388E-5 0.0011852577823388008 6.214379003181776E-4 -0.001199139351103558 -0.0016296581412872648 -7.013044603345896E-4 -8.31182699599374E-4 1.2113094935822494E-4 6.360801029878531E-4 -3.751826736009071E-4 -6.164937799362092E-4 -7.17277772337872E-4 -8.868991331346329E-4 1.3881568764757333E-4 0.0012822386052158724 0.0017466056041684397 9.557365015297308E-4 7.49604713296896E-4 -3.673861760754954E-4 -0.001522979236122486 -4.887072839099499E-4 8.441134759829836E-4 0.002535192805092394 0.0031885773294171365 0.0027753629605703186 0.002965141119847412 0.0021847307334013286 0.0019209809268709395 0.0021915764385455924 0.002257751588273477 0.002385157767347277 0.0012398332650166823 7.541685167264052E-4 0.0013697115042814666 0.0018030826716086167 0.0012512427735904554 9.498415887666148E-4 0.0021925272309267405 0.002303579781044799 0.00121530282158307 7.838332390182154E-4 8.65601383796923E-4 4.660784252386332E-4 0.0011356264200428874 0.0024087374183997417 0.002289888370756271 0.0011738482737650275 0.0018755330510520764 0.0019719433985004595 0.001680620612916785 0.0024370710313579447 0.0025369042313784598 0.001581167729848729 5.714262210698052E-4 0.0014520501244888629 0.002758248697709659 0.0017918633215110733 0.0016633161915798958 0.0017931944308446802 0.0018291343828520654 0.002971986824991676 0.00425783844125591 0.0025159867989932093 2.4321269109759764E-4 -0.001124787386897803 -7.473228115821414E-4 -1.777981752746316E-4 -7.809808618747721E-4 -0.0010120234104936785 -6.904654271895051E-4 -3.679566515041841E-4 2.9968975853777476E-4 4.812911033369974E-4 3.605404709312315E-4 4.791993600984723E-5 -4.078899315123901E-4 -0.001533628110791341 -8.408807818870811E-4 1.481334529828214E-4 2.3389492576234957E-4 1.79319443084468E-4 0.0014385488726765647 0.001791483004558614 1.557397920320035E-4 -5.835963635484967E-4 3.1965639854187775E-4 3.854512313173029E-4 4.881368084812613E-4 6.615613388026131E-4 6.003303094566973E-4 7.035863620493443E-5 -6.294245563198187E-5 8.56663935414134E-4 0.0014642202669675542 0.0016648374593897322 0.0018915063630553588 0.001577364560324138 0.0019698516552619344 0.00235834542219891 0.001367809919519171 9.608707803879288E-4 5.778916092616101E-4 5.691443193550506E-4 5.5241037344685E-4 1.7038199470167904E-4 4.1644706294272E-5 -2.650809158639962E-4 -4.01995018749274E-4 2.759199490090807E-4 0.0013444204269429361 0.0026947357666489884 0.0021615313993013233 0.0022969242343767646 0.002585204484340766 0.0033534447283081583 0.0033865323031721005 0.00208641880119065 0.0013212210928429309 0.0010650776253617236 0.0020019884377447286 0.0016808107713930146 5.854979483107921E-4 6.476797700378558E-4 5.632494065919345E-4 4.288073638976409E-4 8.16730655405928E-4 -4.5447875818863044E-5 -2.768707413902284E-4 -0.001115849938515014 -7.562602599649303E-4 -3.561668259779518E-4 2.129774933770988E-4 7.174679308141015E-4 -1.4642202669675543E-4 -9.401435064789076E-4 -0.001059753188027296 1.4927440384019872E-4 9.29304473333823E-4 4.799599940033905E-4 -4.2728609608780446E-4 -3.814579033164823E-4 5.476564115411112E-5 5.354862690624199E-4 9.593495125780923E-4 0.0012046539469142152 8.555229845567567E-4 2.5804505224350275E-4 0.0010637465160281167 0.002176934235875917 0.0017593462220758197 0.0012261418547281546 7.372444123419751E-4 4.1359468579927667E-4 5.193227985829079E-4 -5.094345578189712E-4 -0.0017123770784471203 -0.001390819095142947 2.2400668499841285E-4 0.0012778649602625928 0.002047436313563592 0.0013773178433306487 0.0019282069489676623 0.0016931710723479354 0.0013446105854191658 0.0016064588071872596 0.0018430159516168228 0.0017378583142618803 0.002612397146441592 0.0014900818197347734 7.032060450968852E-4 -2.814345448197377E-5 2.2153462480742865E-4 -5.826455711673489E-4 -7.96764015401825E-5 7.178482477665607E-4 1.2151126631068405E-4 7.018749357632783E-4 0.0016598933390077639 0.001736337046452044 0.0010677398440289373 4.259549867541976E-4 -2.958865890131837E-4 -4.466822606632188E-4 -0.0010420684497379478 -0.001030468782687945 -9.566872939108786E-4 -5.642001989730823E-4 -1.7152294555905636E-4 -2.694545608172759E-4 -8.492477548411814E-4 -0.0010103119842076124 -0.0011379083217576422 -0.0010700217457436918 -0.0014126873199093455 -9.173244893313613E-4 -2.9474563815580638E-5 5.079132900091347E-4 -1.6353628955741514E-5 3.824086956976301E-4 5.075329730566756E-4 2.1811177223529673E-4 -4.470625776156779E-4 -4.2177150027714744E-4 -5.653411498304596E-4 -8.024687696887116E-5 1.9833529070742325E-4 -4.5219685647387585E-4 -0.001122695643659278 -9.464187361944828E-4 -7.142352367181992E-4 -0.001217014247869136 -5.4195165725422465E-5 0.001182595563671587 2.656513912926848E-4 6.031826866001405E-4 0.0017819750807471365 0.003113654889782693 0.002081284522332452 0.0017327240354036823 7.427590081526321E-4 -5.449941928738974E-4 -0.0010833328390797605 -8.939349967551263E-4 -0.0012274729640617615 -0.0013288274318921129 -7.035863620493442E-4 -3.9838200770091247E-4 -0.0010445405099289318 -1.2778649602625928E-4 3.1566307054105714E-4 1.184687306910112E-4 3.295446393058145E-4 0.0016349825786216923 0.001673774907772521 0.0010367440124035203 -2.169708213779194E-4 -3.2060719092302553E-4 -8.336547597903582E-4 -0.0021805472469242785 -0.002440684042406306 -0.0019388558236365172 -0.0018608908483824008 -0.0015338182692675704 -0.0020845172164283545 -0.0021830193071152625 -4.0047375093943757E-4 0.0010709725381248397 0.0010656481007904122 -0.0010129742028748261 -0.002098018468240653 -0.0012105488596773312 -5.624887726870162E-4 -4.1207341798944026E-4 4.056080297976355E-4 7.560701014887008E-4 9.669558516272745E-4 7.680500854911626E-4 4.7501587362142213E-4 8.802435864665985E-4 7.326806089124658E-4 8.173011308346167E-4 4.90799027148475E-4 0.00120256220367569 0.002007122716602927 0.001243826593017503 3.1680402139843447E-4 2.989291246328565E-4 4.006639094156671E-4 8.477264870313451E-4 4.8490411438535886E-4 9.63342840578913E-4 5.495579963034067E-4 1.1181318402297686E-4 0.0012299450242527455 0.002047436313563592 6.950292306190143E-4 -4.582819277132215E-4 -2.4283237414513854E-4 0.001707813275017611 0.0012605605389257035 -0.0012936481137896456 -0.0019230726701094645 -7.273561715780383E-4 1.0572811278363119E-4 5.103853502001189E-4 -2.1430860271070567E-4 -8.587556786526591E-4 -7.201301494813153E-4 -6.940784382378667E-4 -0.0010224821266863037 -5.997598340280086E-4 6.436864420370352E-4 0.0011152794630863254 1.0934112383199268E-4 -6.269524961288346E-4 -0.0019565405619258657 -0.0016629358746274366 -4.772977753361768E-5 0.0018156331310397672 0.00235416193572186 0.001960343731450457 8.484871209362633E-4 8.254779453124874E-4 0.0010297081487830268 0.0015551160186052803 0.0010618449312658211 4.000934339869785E-4 -8.792927940854508E-4 -6.46728977656708E-4 -3.938182042714032E-4 3.9933280008206024E-6 5.607773464009503E-4 -2.017581432795552E-4 -0.0013955730570486859 -0.0017334846693086005 -1.445204419344599E-4 7.35532986055909E-4 0.0015338182692675704 0.0013750359416158941 0.001542945876126589 0.0013697115042814666 8.271893715985534E-5 -1.3596331050413004E-4 3.4114430635581716E-4 5.510792641132431E-4 7.419983742477139E-4 2.357965105246451E-4 -0.0011245972284215735 -0.0013212210928429309 -0.001780073495984841 -7.187990401477084E-4 -4.447806759009233E-4 -2.759199490090807E-4 -0.0013472728040863796 -7.760367414928037E-4 8.956464230411923E-5 0.001761818282266804 0.002308333742950538 0.0013719934059962212 0.0011411410158535446 0.0016703520552003891 0.002229608133791503 0.002387249510585802 0.002703863373508007 0.0025485038984284624 0.0020394496575619507 9.068657731387358E-4 4.772977753361768E-5 -1.4870392841151005E-4 -5.767506584042327E-4 -1.384353706951142E-4 -0.0011084337579420616 -0.0022524271509390494 -0.001828944224375836 -0.002423759938021876 -0.0027261119152268646 -0.002392003472491541 -0.002700060203983416 -0.002519029334612882 -0.002442965944121061 -0.002115703206530001 -0.0019550192941160294 -0.0017059116902553154 -0.001633461310811856 -8.965972154223401E-4 -6.699283117567134E-4 6.632727650886792E-4 9.59919988006781E-4 -2.213444663311991E-4 -9.099083087584087E-4 7.587323201559144E-5 -2.856180312967879E-4 -0.0012130209198683154 -9.855913822977706E-4 -0.0013887273519044218 -0.0012567573694011124 -8.296614317895376E-4 5.109558256288076E-4 9.606806219116992E-4 0.0016060784902348004 0.0020611277238521196 8.007573434026455E-4 0.0013993762265732768 0.0019974246343152195 0.0016775780772971122 7.754662660641151E-4 -6.288540808911301E-4 -5.976680907894836E-4 0.001607980074997096 0.001405271139336393 0.0018116398030389466 0.0014971176833552668 3.052043543484318E-4 -4.5371812428371226E-4 -6.769641753772068E-4 -7.303987071977111E-4 -0.0010401668649756522 -0.0012067456901527402 -0.0012364104124445504 -0.0015657648932741353 -0.0021079067090045895 -5.767506584042327E-4 8.199633495018304E-4 0.0011173712063248505 0.001274442107690461 0.0013100017427453872 0.001026665613163354 2.6736281757875084E-4 -3.263119452099121E-4 -5.29020880870615E-4 -9.412844573362849E-5 -5.001167924837231E-4 -0.001551503007556919 -0.0022029859471193658 -0.0036622620937049517 -0.0029978483777588954 -0.0016119734029979166 -9.431860420985804E-4 -5.35866586014879E-4 7.574012108223076E-4 8.138782782624848E-4 -1.5269725641233066E-4 1.7513595660741785E-4 9.108591011395565E-5 -5.318732580140583E-4 -0.0010105021426838419 3.3334780883040554E-4 5.603970294484912E-4 6.870425746173732E-4 0.0013236931530339149 1.8996831775332294E-4 -9.363403369543165E-4 -0.0017595363805520492 -7.659583422526374E-4 5.23506285059958E-4 -4.206305494197701E-4 -0.0012706389381658698 -0.0013210309343667011 -0.0017216948437823684 -0.0016699717382479301 -8.80433744942828E-4 -8.754896245608598E-4 -5.172310553443828E-4 -4.56380342950926E-5 1.224620586918318E-4 0.001115089304610096 0.0032309826696163267 0.004111416414559155 0.0022562303204636406 8.663620177018412E-4 -1.2778649602625928E-4 -9.19986707998575E-4 -0.0011025388451789454 -7.328707673886954E-4 1.0934112383199268E-4 -2.491076038607138E-5 -3.118599010164661E-4 -2.165905044254603E-4 -0.0013885371934281923 -0.0024631227426013935 -0.0032083538109450097 -0.0021870126351160833 -0.0015224087606937973 -0.0011960968154838853 -7.42378691200173E-4 -6.058449052673543E-4 -0.001474108507731491 -0.0011388591141387899 1.854045143238137E-4 0.0012002803019609354 0.0018329375523766565 0.0016395463820512016 0.001270068462737181 8.707356626551209E-4 -4.215813418009179E-4 -6.520534149911355E-4 -2.042302034705394E-4 7.465621776772231E-4 9.713294965805542E-4 8.00567184926416E-4 7.682402439673921E-4 0.001213971712249463 0.0015419950837454411 0.0026589859731178324 0.002017581432795552 5.794128770714465E-4 5.969074568845653E-4 8.93174362850208E-4 -2.8923104234514934E-4 -0.001488560551924937 -0.001405271139336393 -3.3448875968778287E-4 2.40930789382843E-4 -7.876364085428064E-4 -0.002438592299167781 -0.0017930042723684504 -5.590659201148843E-5 -2.6831360995989857E-4 -2.4283237414513854E-4 -6.997831925247533E-5 -3.3886240464106257E-4 -8.479166455075746E-4 -0.0017500284567405716 -0.001066218576219101 -6.492010378476923E-4 -0.001306198573220796 -7.522669319641096E-4 5.476564115411112E-5 -3.633928480746748E-4 3.0843704844433416E-4 5.645805159255414E-4 -1.753261150836474E-4 -9.814078958207205E-4 -0.0010783887186977923 3.80316952459105E-7 1.3101919012216168E-4 -4.620850972378126E-4 -8.173011308346167E-4 -1.4832361145905095E-5 -8.081735239755981E-4 -9.928174043944936E-4 -4.383152877091185E-4 -1.8445372194266592E-4 5.91963336502597E-4 -2.6679234215006215E-4 4.0370644503533995E-4 8.907023026592239E-4 -3.086272069205637E-4 -1.1656714592871568E-4 4.5181653952141676E-4 1.1029191621314045E-4 1.5364804879347842E-4 0.0010700217457436918 8.838565975149601E-4 -2.814345448197377E-5 -5.607773464009503E-4 -1.4147790631478707E-4 -5.661017837353778E-4 -9.753228245813748E-4 -4.483936869492848E-4 1.2797665450248882E-4 -4.7710761685994723E-4 -0.002229988450743962 -0.0020656915272816287 -8.247173114075692E-4 -3.099583162541706E-5 -8.100751087378936E-5 -3.303052732107327E-4 -5.727573304034121E-4 -7.06248580716558E-4 -4.8053046943207916E-4 2.502485547180911E-4 6.967406569050804E-4 8.981184832321764E-4 9.220784512371001E-4 0.0012584687956871785 2.0822353147135998E-4 3.310659071156509E-4 5.008774263886412E-4 7.400967894854183E-4 -9.869224916313775E-5 -2.5081903014677977E-4 -6.31896616510803E-4 -4.348924351369866E-4 -8.646505914157752E-4 -0.0012907957366462023 -9.606806219116992E-4 -2.9816849072793834E-4 -6.465388191804785E-4 -0.0015889642273741408 -0.0012086472749150356 -7.052977883354102E-4 -8.633194820821683E-4 -8.144487536911733E-4 4.078899315123901E-4 0.0017097148597799065 0.0029455547967957682 0.002591289555580112 6.423553327034283E-4 -5.91963336502597E-4 -9.376714462879233E-4 -9.639133160076016E-4 1.9434196270660264E-4 2.586155276721914E-4 -0.0018104988521815695 -0.003079806681013832 -0.0025779784622440433 -0.0012590392711158672 -0.001715039297114334 -0.002204126897976743 -0.0020751994510931062 -0.002189294536830838 -0.0019110926861070027 -0.0011126172444191117 -0.0014588958296331267 -0.0015001602189749397 -0.0020109258861275175 -0.0018270426396135404 -5.752293905943964E-4 1.1314429335658373E-4 0.0013221718852240785 0.0019268758396340554 0.0020464855211824442 0.0014638399500150952 5.683836854501324E-4 0.0010951226646059929 0.001022862443638763 -0.001876103526480765 -0.0028512361925859104 -0.0022377849482693737 -0.002122168594721806 -0.0020459150457537555 -0.001865074334859451 -0.001921171085347169 -0.002024046820987357 -0.0021742720172087033 -0.00198867734440866 -0.0021350993711054156 -2.858081897730174E-4 -3.668157006468068E-4 -6.585188031829403E-4 -5.752293905943964E-4 -9.561168184821899E-4 -0.0025163671159456683 -0.0036820385752328252 -0.0026882703784571835 -0.002245391287318556 -0.0024861319182251694 -0.0026667824706432443 -0.0027917165895260604 -0.002774031851236712 -0.002205077690357891 -0.0016559000110069433 -0.0013191293496044058 -0.0012251910623470067 -0.0023203137269529996 -0.0034201903534647315 -0.0030758133530130118 -0.0027487407738981816 -0.0028850844013547706 -0.0036078767695032995 -0.004074715828646851 -0.0032564639054310867 -0.003717408051811522 -0.0031973246193236957 -0.0033871027786007892 -0.004111606573035384 -0.0035373279748221356 -0.0017355764125471258 -3.7328108883861154E-4 -8.36697295410031E-6 5.872093745968581E-4 5.632494065919345E-4 1.3463220117052317E-4 -4.444003589484642E-4 -0.0010472027285961456 -9.699983872469473E-4 -4.4630194371075973E-4 -0.0019825922731693145 -0.00226916109684725 -0.001693741547776624 -0.0017874896765577935 -0.0017483170304545058 -0.002756156954471134 -0.0029727474588965943 -0.002124260337960331 -0.0011907723781494578 -6.689775193755657E-4 -0.002060557248423431 -0.0019407574083988128 -5.560233844952115E-4 -6.967406569050804E-4 -8.296614317895376E-4 -2.875196160590834E-4 -0.0017496481397881126 -0.002951639868035114 -0.002631222835588318 -0.0026502386832112732 -0.0034059284677475147 -0.003382919292123739 -0.0011818349297666687 -0.001190582219673228 -0.0024325072279284357 -0.0025369042313784598 -0.002580260363958798 -0.0020381185482283436 -0.001383593073046224 -0.0010795296695551696 -7.256447452919723E-4 -3.350592351164715E-4 5.360567444911086E-4 0.0027498817247555585 0.007330989575601708 0.01732077496584502 0.025658653673082208 0.014451283559541072 0.005788804333380037 0.0013339617107503109 -8.216747757878964E-4 -0.0016667390441520277 -0.002145367928821811 -0.0020132077878422723 -0.0013307290166544084 -0.0011382886387101012 -0.001645821611766777 -0.0016178683157610327 -0.0024146323311628574 -0.0031765973454146745 -0.0023071927920931606 -0.0020521902754693307 -0.0023608174823898944 -0.0015796464620388927 -0.0029727474588965943 -0.003955866781003381 -0.003814959350117282 -0.004688927706868306 -0.004718021953731427 -0.0037455515062934956 -0.0031509259511236848 -0.0035675631725426344 -0.0035517800190155817 -0.0032591261240983004 -0.003926772534140259 -0.0037008642643795507 -0.0031790694056056585 -0.003407069418604892 -0.003702005215236928 -0.004086695812649313 -0.0039984622796788005 -0.003334619039161433 -0.003404977675366367 -0.0038284606019295805 -0.0036141519992188747 -0.0035673730140664047 -0.0029094246863121532 -0.003362952652119636 -0.003510895946626228 -0.003139516442549912 -0.0034397766765163753 -0.0042063054941977015 -0.004818425629180631 -0.005483029503602917 -0.005236393959933187 -0.0037906190651598995 -0.004122825923132928 -0.003880564024416478 -0.0033648542368819316 -0.0036822287337090545 -0.0049243439004404916 -0.005605871879247208 -0.004683222952581419 -0.0037124639314295533 -0.003883036084607462 -0.004707753396015031 -0.004765181255836356 -0.005682125428215258 -0.00676907127834338 -0.00505232055494298 -0.0036907858651393844 -0.003876190379463198 -0.0034312195450860454 -0.0021101886107193443 -0.0029369976653654383 -0.004954008622732302 -0.0054261721192102805 -0.004692730876392897 -0.0037221620137172606 -0.004267536523543617 -0.004979299700070832 -0.004092780883888658 -0.0035458851062524655 -0.0032530410528589545 -0.003092737457397442 -0.0026778116622645583 -0.0018070759996094373 -0.001355069301611791 -9.513628565764511E-4 -8.372677708387196E-4 -8.540017167469202E-4 -3.7290077188615245E-4 8.241468359788805E-4 9.618215727690766E-4 0.002113611463291476 0.0037328108883861156 0.005344213815955344 0.007906028807719874 0.009814649433635893 0.012742709650618543 0.016673285354283394 0.022753412473247105 0.0319007958137935 0.04613624950281403 0.0677106794234379 0.10176673140681715 0.16038118011981442 0.2614774127394462 0.44415676594041414 0.802585907310069 1.5870601705516543 3.2849557302415127 4.525309268849159 2.790891301739224 1.4264344466314085 0.8263789161728631 0.5393082642761576 0.38262870905462765 0.2868702248627595 0.2260752289028379 0.18095024217661265 0.14807317274585663 0.12449960676463147 0.10557617616112377 0.09142990679745491 0.07878722050533311 0.0678818220520445 0.05959889914443765 0.05291768108211233 0.047314471421532334 0.04291325348919934 0.039553343372699376 0.03649654586730932 0.03432208369162439 0.031747718240428706 0.02920929274124041 0.026641202519760307 0.02436196302367289 0.02341402301966857 0.021788738523334586 0.020386700078094094 0.019306599933110236 0.018364935158821493 0.01848777753446578 0.018610049434681385 0.017152484714381865 0.015536327824906899 0.015012441222894482 0.014686509594637027 0.013747507039015498 0.012558065770199647 0.012566052426201289 0.013957251838296695 0.013667070003570397 0.012737004896331656 0.012204941479841368 0.011632944783342874 0.009544624397389928 0.008603530098529873 0.007919720218008403 0.00798893790335596 0.008203056347590436 0.0070765575344065666 0.006461965339232653 0.0065015183022884 0.006209625041276037 0.006878032085222914 0.006475656749521181 0.005527336428564403 0.005537414827804569 0.005337368110811079 0.005738982812607894 0.0063109795091063885 0.006447893611991666 0.006499997034478564 0.006795883623491747 0.007097665125268047 0.006698902800614676 0.0061679803349817645 0.0069253815458040725 0.008211613479020765 0.007941017967346113 0.007518105516211588 0.007396213932948445 0.007297331525309077 0.005675850198499683 0.004101718332271447 0.003089694921777769 0.003073151134345798 0.0031944722421802523 0.002853898411253124 0.0030915965065400645 0.0038718167345099183 0.004570268817701065 0.00421980674601 0.003901861773754188 0.0033407041104007783 0.003460694108901626 0.0038691545158427046 0.005038058669225764 0.005785951956236594 0.004718592429160116 0.0034823721751917947 0.003015342957572014 0.003774265436204158 0.002792667381907208 0.0024834696995579557 0.0030963504684458033 0.0027789759716186804 0.0013524070829445773 0.0016053178563298822 0.0014237165115306596 0.002315179448094802 0.002916460549932647 0.003154729120648276 0.0036519935359885557 0.003901671615277958 0.005715973636984118 0.010205995577716313 0.02107678518833114 0.028774590464579655 0.017539837530461462 0.009062572660148012 0.0056718568704988625 0.005471239678076684 0.005926669228646463 0.004867106199095396 0.0030992028455892467 0.0030809476318712095 0.0025825422656735523 0.0019930509893619397 0.0027517833095178543 0.0035053813508155707 0.004192614083909174 0.004982532394166734 0.0036879334879959414 0.0030699184402498956 0.0034557499885196578 0.0034418684197549004 0.002294071857233321 0.0017500284567405716 0.0014906522951634621 8.492477548411814E-4 8.975480078034878E-5 5.891109593591536E-4 0.0014113562105757386 0.0010650776253617236 6.492010378476923E-4 6.883736839509801E-4 5.438532420165202E-4 -3.078665730156455E-4 -3.654845913131999E-4 -7.22792368148529E-4 -7.655780253001783E-4 -2.546221996713708E-4 0.0018099283767528808 0.00259205018948503 0.002659556448546521 0.0026941652912202997 0.0022170576743603524 0.001732914193879912 0.0020424921931816234 0.0020780518282365497 0.0028856548767834593 0.003214248723708126 0.003066685746153993 0.0017952861740832052 0.0010603236634559848 0.0011607273389051885 0.0012632227575929173 1.7912928460823846E-4 5.879700085017764E-4 0.0024842303334628737 0.0028535180943006647 0.0025570610298587923 0.0012449675438748803 4.320400579935433E-4 9.694279118182586E-4 0.0011308724581371487 0.0011746089076699459 0.0016431593930995633 0.0021527841093947637 0.0016294679828110354 0.002157918388252962 0.003067066063106452 0.0015383820726970797 -4.628457311427308E-4 -3.7727441683943215E-4 1.5022519622134647E-5 8.454445853165904E-4 6.288540808911301E-4 6.271426546050642E-4 -6.92176853475571E-5 -5.389091216345518E-4 2.662218667213735E-4 -3.987623246533716E-4 -0.001065267783837953 -0.0014531910753462403 -0.001385684816284749 -2.0594162975660536E-4 0.0010586122371699187 9.838799560117047E-4 7.22792368148529E-4 3.5179318102467215E-5 -8.595163125575773E-5 0.0010310392581166336 0.002247102713604622 0.0018614613238110895 9.928174043944936E-4 0.0015328674768864228 0.0028966840684047732 0.0022714429985620046 0.0017836865070332024 0.0010692611118387737 0.0010156364215420399 0.0010530976413592617 -5.001167924837231E-5 -0.002336667355908741 -0.0023461752797202186 -9.428057251461213E-4 -7.265955376731201E-4 -7.526472489165688E-4 -0.0011805038204330618 -9.57828244768256E-4 -0.0015049141808806785 -0.0011183219987059984 -6.606105464214654E-4 -0.001068310319457626 -0.0011088140748945206 -2.567139429098959E-4 -4.40216872471414E-4 -6.08507123934568E-6 6.982619247149168E-4 9.686672779133404E-4 2.4720601909841826E-6 -0.0010635563575518872 -0.0010877064840330403 -0.001583259473087254 -0.0028765272699244407 -0.0019185088666799552 -8.380284047436379E-4 -6.115496595542408E-4 -8.467756946501973E-4 2.2533779433201972E-4 6.550959506108083E-4 4.7273397190666753E-4 3.0976815777794103E-4 -3.076764145394159E-4 -4.137848442755062E-4 -9.663853761985858E-4 -0.0015058649732618262 -0.002364050176485797 -0.0021615313993013233 -0.0019552094525922587 -9.979516832526916E-4 9.294946318100526E-4 0.001340236940465886 0.001206365373200281 1.017347847828106E-4 3.9096582712795994E-4 3.320166994967987E-4 3.067256221582682E-4 0.0014123070029568865 0.002991953464995779 0.003209114444849928 0.0019476031135430766 5.562135429714411E-4 -2.2552795280824926E-4 2.249574773795606E-4 3.194662400656482E-5 8.564737769379045E-4 0.002488033502987465 0.0020831861070947475 0.002575886719005518 0.0025777883037678135 0.0021356698465341043 7.00733984905901E-4 5.571643353525888E-5 4.573311353320738E-4 3.270725791148303E-5 1.753261150836474E-4 4.158765875140313E-4 0.0013862552917134378 0.0021103787691955735 0.0017557332110274583 0.0017688541458872973 0.002191386280069363 0.0019940017817430874 8.140684367387142E-4 2.3047207319021762E-4 -5.415713403017655E-4 -3.7898584312549816E-4 -2.2324605109349464E-4 9.393828725739893E-5 7.684304024436217E-4 0.002123880021007872 0.0023739384172497334 0.0028478133400137782 0.0027050043243653844 9.825488466780978E-4 -1.5954296155659456E-4 -1.6638866670085843E-4 6.769641753772069E-5 -8.055113053083844E-4 -4.4725273609190746E-4 2.793428015812126E-4 0.0013185588741757171 0.002185491367306247 0.0017059116902553154 3.434262080705718E-4 -0.0011263086547076394 1.5421852422216708E-4 0.0010584220786936892 0.0010378849632608975 5.9709761536079484E-5 4.027556526541922E-4 0.001348794071896216 6.412143818460511E-4 -1.844537219426659E-5 -1.1029191621314045E-5 -2.1392828575824658E-4 -5.373878538247153E-4 -6.545254751821197E-4 -4.7957967705093143E-4 -3.755629905533662E-4 -0.0012890843103601365 -9.949091476330186E-4 8.76630575418237E-4 7.585421616796849E-4 -4.2082070789599966E-4 -1.2189158326314315E-4 7.471326531059118E-4 6.653645083272042E-4 9.739917152477679E-4 0.0015853512163257792 0.0013166572894134216 6.560467429919561E-5 -2.1849208918775582E-4 -3.4494747588040823E-4 -0.0013544988261831024 -0.001966618961166032 -9.464187361944828E-4 -1.2740617907380017E-5 -4.0769977303616056E-4 -6.04703954409977E-5 1.7057215317790858E-4 -4.799599940033905E-4 2.3389492576234957E-5 2.582352107197323E-4 -3.1775481377958225E-4 -6.940784382378666E-5 -1.5250709793610112E-4 -1.5840201069921723E-4 1.1257381792789509E-4 2.7953296005744216E-4 0.001050055105739589 0.0018150626556110785 0.0016150159386175895 0.0016629358746274366 0.0015193662250741246 6.472994530853967E-4 -8.635096405583979E-4 -0.001437978397247876 -0.001617678157284803 -0.0018194363005643584 -8.074128900706799E-4 -9.684771194371108E-4 1.0401668649756522E-4 0.0012942185892183343 0.0017521201999790967 7.828824466370677E-4 -1.3196998250330943E-4 -4.1264389341812895E-4 9.686672779133404E-4 0.0014569942448708312 -5.402402309681587E-4 -8.385988801723265E-4 -0.0012938382722658753 -0.0024220485117358104 -0.0032674930970524006 -0.0019778383112635757 -7.030158866206556E-4 -3.2117766635171417E-4 -6.461585022280193E-4 -3.869724991271393E-4 -6.086972824107976E-4 -4.913695025771637E-4 2.0727273909021223E-4 3.683369684566432E-4 8.781518432280735E-4 2.485371284320251E-4 -9.024921281854561E-4 -0.0012702586212134108 1.7152294555905636E-4 4.841434804804407E-4 -3.339182842590942E-4 -0.001273491315309313 -0.00235834542219891 -0.0024311761185948286 -0.0017254980133069595 -0.0018949292156274907 -0.0012919366875035797 -0.0016996364605397403 -0.001231466292062582 -7.08340323955083E-4 -0.0016804304544405554 -0.00210771655052836 -0.002117985108244756 -9.104787841870974E-4 -1.0515763735494253E-4 -9.603003049592401E-5 5.392894385870109E-4 6.009007848853859E-4 1.0192494325904014E-4 -0.0015602502974634783 -0.0019770776773586573 -0.0014638399500150952 -0.0010770576093641854 -0.0019131844293455277 -0.002854659045158042 -0.001944940894875863 -0.001711616444542202 -0.002395426325063673 -0.0022834229825644662 -0.001209407908819954 -0.0015090976673577286 -0.0012464888116847166 -0.0011611076558576475 -2.909424686312153E-5 9.842602729641637E-4 0.0014647907423962429 9.230292436182479E-4 2.078432145189009E-4 9.576380862920264E-4 -7.4161805729525475E-6 -0.0019124237954406095 -0.003516790859389344 -0.0035673730140664047 -0.002211352920073466 -0.0011666222516683047 -0.0013577315202790048 -0.0021075263920521305 -0.0017344354616897484 -0.0010985455171781248 -4.050375543689468E-5 8.730175643698755E-4 0.0016001835774716842 0.0012010409358658536 -2.42642215668909E-4 -0.001488940868877396 -0.0015277331980282248 -0.0019529275508775041 -0.003041204510339233 -0.0028192895685793455 -8.281401639797011E-4 -2.563336259574368E-4 -0.0012558065770199647 -0.001700206935968429 -2.8675898215416515E-4 6.994028755722941E-4 5.444237174452089E-4 1.5383820726970796E-4 5.227456511550399E-4 -5.4195165725422465E-5 -1.1637698745248612E-4 3.306855901631918E-4 1.5669058441315127E-4 0.0014239066700068891 0.0014820951637331322 0.0022910293216136485 0.002980163639469547 0.0025367140729022305 0.002394095215730066 0.002465594802792378 0.002219719893027566 9.718999720092429E-4 -2.534812488139935E-4 -8.123570104526483E-4 -9.629625236264539E-4 -3.7099918712385694E-4 5.271192961083196E-4 4.932710873394592E-4 -8.27759847027242E-4 -0.0010241935529723698 -5.9899920012309036E-5 0.0010200100664953197 7.277364885304974E-4 -5.139983612484805E-4 -5.683836854501324E-4 -9.907256611559685E-5 4.685504854296174E-4 -1.7570643203610652E-4 -0.0010658382592666417 -0.002329821650764477 -0.0037206407459074243 -0.004600504015421563 -0.00876668607113483 -0.016082272810161943 -0.017369075218807324 -0.010375236621560613 -0.006058639211149772 -0.0031686106894130333 -0.0018730609908610921 -0.001517844957264288 -0.0014499583812503378 -0.001327496322558506 -0.0012997331850289914 -0.0012057948977715924 -0.0015385722311733092 -0.00211190003700541 -0.0027050043243653844 -0.003143319612074503 -0.0023547324111505485 -0.001550171898223312 -0.0010196297495428605 -5.50698947160784E-4 -0.0013660984932331052 -0.0013501251812298228 -8.258582622649465E-4 -6.290442393673596E-4 -9.289241563813639E-4 -0.0017437532270249965 -0.0013231226776052262 -0.0011795530280519142 -9.230292436182479E-4 -5.786522431665283E-4 5.482268869697999E-4 0.0011529308413797768 0.0016743453832012097 0.0016578015957692386 0.0018074563165618965 5.339650012525834E-4 -0.0014457748947732877 -0.0016781485527258009 -0.001799089343607796 -9.985221586813803E-4 -5.100050332476598E-4 -3.850709143648438E-4 -3.1338116882630255E-4 7.226022096722995E-5 -5.229358096312694E-5 0.001148176879474038 0.0022518566755103608 0.0017652411348389359 0.0022370243143644557 0.0033882437294581666 0.0035143187991983596 0.0010928407628912381 5.816947787862011E-4 3.105287916828592E-4 5.704754286886575E-7 2.734478888180965E-4 3.2403004349515745E-4 -6.788657601395025E-5 7.387656801518115E-4 0.0028031260980998333 0.0036019818567401833 0.0031446507214081096 0.001175749858527323 -1.2037031545330673E-4 8.557131430329862E-6 -5.136180442960213E-4 -0.0017215046853061389 -0.001981641480788167 -0.001832747393900427 -0.001380550537426551 -0.002012066836984895 -0.0015309658921241272 -4.828123711468338E-4 9.237898775231661E-4 0.002612206987965363 0.003915933500995175 0.004007399728061589 0.0019116631615356914 3.922969364615668E-4 -7.574012108223076E-4 -0.0017931944308446802 -0.0018513829245709232 -8.433528420780654E-4 -3.542652412156563E-4 9.184654401887386E-5 1.557397920320035E-4 -1.956730720402095E-4 -2.2590826976070838E-4 -0.001224240269965859 -0.001872680673908633 -0.0015292544658380611 -0.0010059383392543328 -8.342252352190468E-4 -9.410942988600554E-4 -5.21414541821433E-4 4.153061120853427E-4 4.592327200943693E-4 -0.0011846873069101121 -0.0013767473679019602 -3.7061887017139785E-4 9.863520162026887E-4 0.0024307958016423696 0.0038773313303205755 0.002498111902227631 8.414512573157698E-4 -3.327773334017169E-5 3.671960175992659E-4 4.5866224466568065E-4 6.362702614640827E-4 -8.153995460723211E-4 -0.0018827590731487992 -4.8794665000503174E-4 4.734946058115857E-4 0.0012464888116847166 0.0024338383372620423 0.0022269459151242894 0.001539142706601998 0.0011666222516683047 -1.0154462630658104E-4 2.700250362459645E-4 3.671960175992659E-4 2.4283237414513854E-4 -7.005438264296714E-4 -0.0013735146738060578 -9.79125994105966E-4 4.995463170550344E-4 -1.1960968154838853E-4 -3.8906424236566443E-4 7.294479148165634E-4 0.0016287073489061172 0.002389531412300557 0.0025344321711874757 0.0017496481397881126 0.00127482242464292 6.541451582296605E-5 -5.912027025976787E-4 -1.8920768384840474E-4 -1.6201502174757873E-4 3.219383002566324E-4 1.9529275508775042E-4 -2.3446540119103823E-4 -0.0016475330380528428 -0.0013461318532290022 -1.5592995050823304E-4 -3.922969364615668E-4 3.1281069339761386E-4 1.9206006099184802E-5 -0.0020968775173832756 -0.0034663988631885127 -0.002745508079802279 -0.0016077899165208665 -6.868524161411436E-4 -4.731142888591266E-4 3.379116122599148E-4 9.555463430535013E-4 0.0014050809808601634 0.0017892011028438595 0.00107933951107894 0.001320270300461783 0.0011751793830986343 4.603736709517466E-4 2.350358766197269E-4 2.0651210518529402E-4 -5.9709761536079484E-5 -4.01995018749274E-4 2.4720601909841826E-6 3.3334780883040554E-4 -7.577815277747667E-4 -0.001378458794188026 -9.331076428584141E-4 -0.0012639833914978354 -0.00248156811479566 -0.0020063620826980084 -7.203203079575449E-4 6.602302294690062E-4 0.001149888305760104 0.0010873261670805811 0.0017338649862610597 0.0021630526671111597 0.0026772411868358696 0.0024119701124956437 0.001877814952766831 0.001194955864626508 0.0010747757076494306 0.0014022286037167202 0.001370852455138844 0.0012487707133994712 0.0014425422006773853 0.0017551627355987696 0.0013972844833347517 3.791760016017277E-4 -5.001167924837231E-5 0.0011232661190879666 0.002466165278221066 0.001678909186630719 8.714962965600391E-4 9.171343308551317E-4 1.8825689146725698E-5 -3.854512313173029E-4 8.886105594206989E-4 0.0020381185482283436 0.0023370476728612004 0.0018346489786627226 0.001024954186877288 6.743019567099932E-4 -2.4150126481153168E-5 4.023753357017331E-4 0.0010962636154633703 0.0014708758136355886 9.028724451379152E-4 0.0011373378463289535 0.0016686406289143233 6.961701814763917E-4 9.218882927608705E-4 0.002453044343361227 0.0028902186802129684 0.0019122336369643798 0.0010498649472633593 0.0018915063630553588 0.002822712421151477 0.0036692979573254452 0.002968183655467085 0.0011685238364306002 9.528841243862876E-4 0.0019664288026898023 0.0024410643593587656 0.0034690610818557265 0.0042498517852542685 0.004223039440105902 0.004385054461853481 0.0033652345538343906 0.002894782483642478 0.0029752195190875783 0.0026479567814965185 0.004054939347118977 0.004423846791004309 0.003486175344716386 0.002920263719457238 0.0024007507623981005 0.002544890887380101 0.002671156115596524 0.003146171989217946 0.004052277128451764 0.003994088634725521 0.003071439708059732 0.0027215481117973555 0.0030912161895876055 0.0020383087067045733 0.0020301318922267024 0.0031885773294171365 0.0034315998620385044 0.0033589593241188155 0.003523636564533608 0.004458645792154318 0.0042466190911583665 0.0048150027766084985 0.005013908542744611 0.004623513191045339 0.0038541319962205702 0.0036886941219008594 0.0038016482567812134 0.004131953529991946 0.004289975223738704 0.004040677461401761 0.0033087574863942134 0.003085891752253178 0.002517698225279275 0.0019822119562168555 0.0025397566085219032 0.002782018507238353 0.0027029125811268593 0.0025669492706227293 0.0029369976653654383 0.004190522340670648 0.004939556578538856 0.004507326362069083 0.004713077833349458 0.005245331408315976 0.0050228459911273995 0.004001314656822244 0.0043205907384116626 0.0038628792861271294 0.00415591349799687 0.004892397276433927 0.0054377717862602835 0.0062936750877694994 0.005286976114610248 0.005098909381619221 0.004882889352622449 0.0045900452992289386 0.0048001704154625935 0.005116974436861028 0.0056414315143021344 0.00599170342751697 0.005866388991681694 0.006215710112515383 0.00677781856824994 0.006439906955990025 0.007162128848709866 0.006418419048176085 0.005870952795111204 0.006153908607740778 0.006408530807412149 0.006994028755722941 0.006856163860456515 0.0069483907214278485 0.006254312283189982 0.005991893585993199 0.0052462822006971235 0.0044559835734871035 0.005966032033225981 0.006882786047128653 0.006145161317834219 0.006730849424621241 0.007650455815667356 0.008020504210410066 0.0071233365195590365 0.006292534136912122 0.0048511328870921135 0.005467626667028323 0.006036390669430914 0.006194412363177673 0.006722862768619599 0.006158852728122746 0.005716544112412807 0.0056644406899259096 0.006514449078672009 0.006479269760569542 0.0067200103914761555 0.006416137146461331 0.006334178843206394 0.006106939464112078 0.006833154684832739 0.007441471650291078 0.007233628435772177 0.007382522522659917 0.00799255091440432 0.007806385766175589 0.0072465592121557865 0.007145014585849206 0.007643990427475551 0.007914015463721516 0.007817034640844444 0.00800567184926416 0.008747289906559414 0.010909962256718116 0.01049560693701392 0.00885587039648649 0.009325371674297254 0.010727410119537746 0.011807320106045373 0.011394486054151016 0.011159260019055059 0.01002876787787037 0.009694659435135046 0.010150469302657283 0.011390112409197736 0.010805755411744321 0.011635607002010087 0.011992724620369188 0.011372237512432158 0.011663940614968291 0.012900541185889071 0.014395186809053355 0.013896401125903238 0.012994669631622699 0.013231797251480952 0.013377838961225248 0.013839353583034371 0.013826993282079451 0.013913705547240127 0.013660034139949904 0.013965428652774566 0.014594663050618155 0.014485131768309931 0.01562056802987659 0.015999553873002087 0.015304904959335532 0.01618248632713492 0.017359377136519617 0.01764746722800739 0.01652172904872844 0.016936845002337553 0.017797692424228736 0.018016374671892724 0.018779100320049456 0.02036654327961376 0.021656958699307505 0.02360037832637353 0.027216051593402242 0.03175171156842953 0.041119488582925974 0.05481089887145375 0.08146427153369275 0.13825586109355353 0.24462100477255372 0.28508920057439346 0.17060467027734386 0.09709605891366688 0.06505302455965369 0.04942751240939512 0.040207488530929036 0.035352552474312335 0.033040795878789664 0.031227254490988423 0.030209526326207856 0.029170880729042042 0.02850950954871566 0.028339698029442667 0.028156955733786068 0.02865269888131651 0.029089873218168253 0.029292011678400266 0.029395267730992915 0.029232301916864187 0.029217089238765825 0.029343924942410934 0.03003362973569552 0.029581052562269186 0.027454320164117873 0.024867974728919728 0.024095360839999056 0.0280297397131885 0.029613189344751982 0.03128297092452368 0.033627244619481605 0.035820912801265724 0.03833100468749582 0.03972258441654368 0.040629069872729955 0.042419221767954964 0.043664189311829846 0.04412209092259061 0.04436035949330624 0.044641603879649744 0.046068362926800076 0.04797337054166773 0.050212676757746946 0.053338501790008326 0.05659268379372466 0.057745994952056894 0.05720252202699284 0.057776420308253626 0.058095316072890583 0.05837180649732835 0.057886902382942994 0.05558427339427934 0.049166995296960635 0.029334226860123228 -0.026251567801965952 -0.07657054314792522 0.05084609464206758 0.10680212785737571 0.12552456095150874 0.13707440648073932 0.1478111343656123 0.15893122173856408 0.1713525635643547 0.18335993038739354 0.1980080279698322 0.21693583221829316 0.23958104451856566 0.26589878747025947 0.2961942654277231 0.3314661907081141 0.3763475844262893 0.4321779228888097 0.5006779501470765 0.5895218918262857 0.7081355232761838 0.8686336508588794 1.0961095870976243 1.4358617432489649 1.9650685991093324 2.828234433142707 4.320969534096312 7.048851444419921 12.471759303227245 23.848591805079014 43.350072039542056 43.67653268868038 23.306807487283873 11.967596128527834 6.8912049333467635 4.424456058762149 3.070560605424123 2.245002032917714 1.7037957968903092 1.3325440793100194 1.0645413784587563 0.863290197676829 0.7070234765071934 0.5820045469439791 0.4839122477733455 0.40803178973565735 0.34707344764465464 0.2976894815263161 0.2577508770807756 0.2242535107005588 0.1964270503984597 0.1729356328789657 0.15424780862750642 0.13824255000021746 0.12496321312967912 0.11363775460239943 0.10427929535323822 0.09584576693245758 0.08736089572309494 0.08051024645844909 0.07523829286346097 0.06968129171260476 0.06347071587894758 0.056934208417032936 0.05134564095912262 0.04729716700019545 0.04473021772957272 0.04276055623278701 0.03944172034715263 0.03594090279976657 0.0340769694157645 0.03292746142695685 0.030589462961714504 0.027653606247206444 0.025698206636137956 0.024186446750113014 0.022960495053861087 0.02176934235875917 0.021602002899677165 0.020563167144035117 0.019055020269058538 0.01760049808437869 0.016646473009135025 0.01673394590820062 0.016971644003487562 0.014893021699822323 0.013095453624024362 0.011008274188928795 0.009377094779831693 0.009143960487974261 0.007837761914753466 0.007271469972541858 0.007807907033985426 0.006628163847457282 0.006239670080520306 0.007244277310441032 0.0067791496775835465 0.005934846043124334 0.0053333747828102586 0.005857261384822676 0.0064990462420974155 0.005768267217947246 0.005253888539746306 0.004387146205092006 0.004071292976074719 0.004413197916335454 0.005187903548494651 0.005340410646430752 0.0062394799220440765 0.008263526743031433 0.009904023917463783 0.011854099091197844 0.017841809190713993 0.030724285321361258 0.05857071226346446 0.11845408848834153 0.2309512725503161 0.26336074228802364 0.14835822030172474 0.07788035473219437 0.046120276190810744 0.029597786508177387 0.020989122130789316 0.014867160147055103 0.010238512677151566 0.00787826567019036 0.0078830196320961 0.0056644406899259096 0.002819860044008034 0.0024823287487005783 0.0014474863210593536 -1.7114262860659724E-4 -9.139016367592293E-4 -0.0016433495515757927 -0.0017471760795971284 -5.03539645055855E-4 -1.9034863470578206E-4 -5.476564115411112E-5 -0.0012173945648215952 -0.0027728909003793345 -0.003473434726809006 -0.002292550589423485 -0.0017819750807471365 -0.001418011757243773 -8.996397510420129E-4 -0.0015914362875651248 -0.0027498817247555585 -0.003065544795296616 -0.0028881269369744433 -0.002417104391353842 -0.0012402135819691415 -7.387656801518115E-4 -0.0011211743758494416 -0.0010947423476535337 -8.741585152272529E-4 -0.001202181886723231 -0.0011704254211928956 -0.0012906055781699728 -9.521234904813694E-4 -9.013511773280789E-4 -0.0014556631355372243 -9.260717792379207E-4 -2.1392828575824658E-4 -0.001658562229674157 -0.0033910961066016096 -0.004173788394762448 -0.004264113670971485 -0.004106852611129645 -0.004188810914384582 -0.0029560135129883935 -0.002792287064954749 -0.002831649869534266 -0.0021894846953070674 -0.0019175580742988073 -0.0019006339699143772 -0.003755249588581203 -0.004328387235937074 -0.004413388074811684 -0.004677328039818303 -0.0035339051222500035 -0.002275056009610366 -0.0019306790091586465 -0.0022307490846488805 -0.0020394496575619507 -0.0016770076018684235 -0.0014672628025872271 0.001209407908819954 0.006128997847354707 0.008918242376689783 0.004010252105205033 -4.8205173724191557E-4 -0.002100870845384096 -0.002482518907176808 -0.0029383287746990454 -0.0035458851062524655 -0.0033401336349720896 -0.002944033528985932 -0.0028116832295301633 -0.0017224554776872866 -0.0014625088406814883 -0.0014041301884790156 -0.001986015125741446 -0.0018684971874315828 -0.0011854479408150303 -0.0018641235424783032 -0.0030585089316761222 -0.0033941386422212828 -0.002391242838586623 -0.0011940050722453602 -0.0017034396300643314 -0.002615059365108806 -0.003856794214887784 -0.003827509809548433 -0.0028957332760236256 -0.002673818334263738 -0.002767946779997366 -0.0033656148707868496 -0.003260076916479448 -0.003351733302022092 -0.0032093046033261578 -0.003517551493294262 -0.003313511448299952 -0.0029118967465031373 -0.0029666623876572484 -0.0033057149507745407 -0.0029976582192826656 -0.003674051919231184 -0.004881177926336383 -0.005572784304383266 -0.0046657283727683 -0.0033542053622130767 -0.0026433929780670094 -0.002703483056555548 -0.003355346313070454 -0.0030379718162433307 -0.0011415213328060036 1.274061790738002E-4 -8.123570104526483E-4 -0.002030322050702932 -0.0024009409208743298 -0.0018856114502922427 -0.0011744187491937162 -0.0012156831385355291 -0.0020925038724299958 -0.0030488108493884154 -0.002032413793941457 -5.231259681074989E-4 -2.778215337713762E-4 9.774145678198998E-5 -0.0010479633625010637 -0.0023648108103907148 -0.0023627190671521897 -0.0014748691416364092 1.4185822326724616E-4 -7.20700624910004E-5 5.1913264010667836E-5 5.632494065919345E-4 6.185855231747343E-4 6.037531620288292E-4 -4.215813418009179E-4 -5.071526561042165E-4 -3.869724991271393E-4 0.001601514686805291 0.002553067701857972 0.0024186256591636783 0.002058845822137365 0.002465784961268607 0.002780307080952287 0.003066875904630223 0.004491923525494489 0.005784430688426758 0.006380007035977716 0.0043295281867944515 0.00438524462032971 0.004932330556442132 0.005064680855897901 0.004896961079863436 0.0041003872229378405 0.004520447296928922 0.004740840970878973 0.004441531529293658 0.004231216254583773 0.003089694921777769 0.0027681369384735957 0.0033872929370770185 0.0027643337689490046 0.0016692111043430118 8.640801159870866E-4 4.940317212443774E-4 4.444003589484642E-4 6.299950317485074E-4 5.415713403017655E-4 8.243369944551101E-4 0.0018032728300848464 0.0014436831515347627 0.0012301351827289752 0.0016144454631889008 0.003013631531285948 0.0042498517852542685 0.0047501587362142215 0.004619900179996978 0.004898482347673272 0.004745594932784712 0.0042842704694518174 0.003884747510893528 0.004140510661422276 0.003509564837292621 0.003646478940177899 0.0042281737189641 0.003895776702514842 0.0033041936829647043 0.004175309662572285 0.004289404748310016 0.004451229611581365 0.004606969403613368 0.004694632461155192 0.004130812579134569 0.004894298861196222 0.006015663395521893 0.005925908594741545 0.00436851067442151 0.004038395559687006 0.005557761784761131 0.006906365698181117 0.006908267282943413 0.006237578337281781 0.006112073742970276 0.005994936121612872 0.00669300788785156 0.007087586726027881 0.00790355674752889 0.0076023457211812796 0.007666048810718179 0.007378339036182867 0.007352857800368107 0.007352857800368107 0.007788891186362471 0.008870512599156164 0.008547243189565925 0.00846034076592902 0.00806500129384778 0.007481975405727973 0.0089408712353611 0.010970622810635343 0.012286139149191386 0.012045778835237232 0.011701591993261743 0.011972948138841314 0.01201250110189706 0.011876157474440471 0.011884334288918342 0.012777888968721009 0.012847106654068567 0.012274919799093844 0.013387727201989184 0.014114322739662304 0.014833692255238702 0.016421135214803005 0.017214856694585157 0.01736203935518683 0.018164698283351773 0.02031158747998342 0.024481953022173736 0.029679934969908554 0.03779856095405307 0.05456939760664222 0.08846362472675012 0.13598099524241938 0.1352049585009266 0.0956149145423149 0.08052888198911959 0.09091172494972938 0.13159156713561262 0.211322544158473 0.2911750324476441 0.24427377539495856 0.156392986397852 0.10798015961761778 0.09498986363094836 0.1101203932675814 0.16022429937692503 0.20000126911767035 0.14492148616082803 0.08984854890912995 0.0638749927994116 0.05277905555294098 0.04821297022171697 0.04460946709716695 0.04327797744660762 0.042107361866938496 0.04253578891388368 0.042192933181241794 0.04184171047564581 0.043265426987176475 0.04383514178196021 0.04368415595183395 0.04320647785954531 0.043514154274084726 0.04612388920185911 0.047676533160273406 0.04963668673324763 0.05253146921689011 0.055367682889853886 0.057884050005799555 0.059958869139940196 0.06064629203151003 0.06282474753519579 0.06714609890751237 0.07169335854958965 0.07442042125719767 0.0776668067633886 0.08117808302696727 0.08486601651496321 0.09041674243610386 0.0961361389256601 0.10144631437437035 0.10845213295561953 0.1158858081083852 0.12338870094649843 0.13231740203938083 0.1416165318439584 0.15109155823904832 0.16096800917745882 0.1726473526290017 0.18759380886064453 0.20430037194826808 0.22269268992766664 0.24328038751513537 0.26599805019485134 0.29313442538671336 0.3243010193237846 0.3620162908652491 0.4081774511284492 0.4627837394794799 0.5288088541696191 0.6108300998801882 0.7132131349084654 0.8388078643377028 1.0047334951489424 1.2328888676232552 1.5529358516753085 2.0131775526445517 2.7027922108114057 3.7158620633997756 5.279618122531022 7.886451992592042 12.665805189186358 22.147082093389937 42.596562421935786 82.99585582118158 100.0 57.135834780488466 28.932360388503884 16.51277543687517 10.5996259054132 7.437159616684097 5.5482861878906125 4.263794014572944 3.333951582909867 2.634573618097959 2.134437809766613 1.7611416984083792 1.4656704155072808 1.2332387592195178 1.0515035428530295 0.9080464671176451 0.7920583537490484 0.6990967204255645 0.6220804458093572 0.5581183604278325 0.502495865179831 0.45445042457567225 0.4113683103595811 0.37461409975698073 0.3446127969622442 0.3184043951343824 0.29481999012001214 0.2736532599724244 0.25487282854304133 0.23794587178146773 0.22386121376409723 0.21053148489735807 0.19869278864273482 0.18891179725939156 0.17950617870812544 0.16969114895753706 0.15943723344381092 0.15001278920339806 0.14288641014821934 0.13666556575684577 0.13003302826443522 0.12384888445897393 0.11896770653263755 0.11302525415046404 0.10841086856627771 0.10325453132483717 0.09778348180523672 0.09457817052991138 0.09058275078585225 0.08768986988697207 0.08570043190865849 0.0837785001894064 0.08002781440425472 0.0762010652286112 0.07331331860858921 0.07143265127867894 0.07000151858657533 0.06963128003335639 0.06893549016883245 0.06667964016532127 0.06543010881801688 0.06449110626239535 0.06353118627438857 0.06220635217049728 0.061558482241983195 0.06263382842506131 0.06679696794515491 0.07620962236004153 0.09532245080587384 0.13630844813848667 0.2019595211058823 0.19795668518125023 0.13622230634875468 0.10906653499231721 0.11157681703702353 0.1415965652039543 0.2169244227097194 0.29691972001453887 0.2594360614971219 0.15908429931192886 0.10955714386098946 0.09286389186670196 0.09944888974005514 0.1317800141855561 0.15501680950537874 0.1151594027291883 0.07423292499963532 0.05413488548845769 0.043498561279033905 0.03677398708412824 0.03216074245079929 0.029687541308957736 0.028579487867968136 0.02763459039958349 0.025941229168759322 0.024252621899840895 0.023652862065812887 0.022154223114647785 0.02120095867330904 0.020704264733397447 0.01983999445893413 0.018555283793527274 0.017302139435174523 0.016136467975887366 0.015795703986484007 0.016110796581596375 0.016878846667087537 0.01613551718350622 0.015288361171903561 0.015917405411270923 0.016212531366379186 0.015400364514402768 0.015108661411866635 0.014865448720769036 0.014721688912739495 0.013960674690868827 0.01335121677455311 0.013794286024167967 0.01316010750594241 0.012584307639919325 0.012123933968967578 0.011838125779194561 0.012169381844786442 0.013294929865589163 0.012459943996465198 0.00988348680203099 0.009226299108181658 0.008521952112227395 0.008752234026941384 0.008327800307997022 0.0083456752047626 0.0081545659361519 0.008470229006692956 0.00902568191575948 0.008044464178414989 0.007150909498612322 0.007226972889104143 0.00834092124285686 0.008181188122824038 0.008297945427228982 0.007934172262201849 0.008776954628851225 0.009804380875919498 0.008845982155722553 0.008198872861113385 0.007160607580900029 0.006395029555599851 0.006747012895100752 0.006578532485161368 0.0062550729170948996 0.006364794357879352 0.006701755177758119 0.006639383197554825 0.0061622755806948785 0.0056456150007791845 0.005678322258690667 0.00543910289559389 0.005139983612484804 0.004335993574986256 0.004268677474400994 0.005929901922742366 0.007378529194659096 0.007494145548206664 0.006450175513706421 0.0040962037364607904 0.0038413913783131902 0.003941414736809935 0.004392280483950204 0.004804924377368332 0.003958719158146824 0.0030615514672957954 0.0027852512013342556 0.002538995974616985 0.002036787438894737 0.0027751728020940893 0.003202268739705664 0.002672487224930131 0.0026437732950194684 0.0028601736409686993 0.003582966009117228 0.00401595685949192 0.003636210382461503 0.002735809997514572 0.0020628391501381856 0.0014381685557241055 0.0013449909023716248 0.003093117774349901 0.004754342222691272 0.0034201903534647315 0.0017505989321692603 0.0010732544398395943 0.0013162769724609624 0.001298972551124073 0.002944413845938391 0.0041931845593378625 0.0036647341538959357 0.0022180084667415005 0.001088276959461729 2.7725105834268757E-4 2.4568475128858183E-4 6.44637234418183E-4 0.0024623621086964755 0.0023071927920931606 -1.0458716192625388E-4 -0.0020487674228971985 -0.0020147290556521086 -0.0014170609648626253 -4.514362225689576E-4 6.189658401271934E-4 8.486772794124928E-4 8.583753617001999E-4 6.130709273640773E-4 -2.612777463394051E-4 1.0097415087789237E-4 5.206539079165147E-4 1.4071727240986886E-5 -2.078432145189009E-4 1.481334529828214E-4 -8.323236504567513E-4 -0.001610071818235621 -0.0026629793011186532 -0.001920220292966021 -0.0014982586342126441 -0.0016327006769069378 -0.0024604605239341797 -0.0025072395090866497 -0.0018044137809422236 -9.785555186772772E-4 -0.0013792194280929442 -0.0022259951227431417 -0.0017918633215110733 -0.0017627690746479516 -0.001792433796939762 -0.0012250009038707772 -5.744687566894781E-4 -2.1640034594923074E-4 -5.896814347878423E-4 -1.66578825177088E-4 -1.7228357946397457E-4 -2.8599834824924697E-4 -7.705221456821467E-4 -9.332978013346436E-4 -0.0020978283097644232 -0.0020700651722349085 -0.001769424621315986 -0.002104674014908687 -0.0013769375263781897 -2.856180312967879E-4 -6.71829896519009E-4 -0.0020913629215726184 -0.0034038367245089896 -0.0031231628135941704 -0.0034966340609090115 -0.0038046907924008866 -0.0028251844813424617 -0.0014836164315429686 -0.0010025154866822009 1.7399500575004053E-4 2.9911928310908607E-4 -3.278332130197485E-4 -6.676464100419589E-4 -0.0011593962295715816 -0.0021622920332062417 -0.0018791460621004378 -0.0017547824186463104 -0.0015528341168905258 -0.002055993444993922 -0.0033152228745860182 -0.004287313005071491 -0.003455179513090969 -0.002357584788293992 -0.0030261819907170984 -0.0039722204099591225 -0.002459129414600573 -0.0021482203059652546 -0.0037027658491418465 -0.004471956885490386 -0.0028788091716391954 -0.0018513829245709232 -0.0022356932050308486 -0.0014463453702019764 5.149491536296281E-4 1.6277565565249693E-4 -4.571409768558442E-4 -0.0014611777313478815 -0.0017403303744528646 -0.0017705655721733634 -0.002904860882882644 -0.0029723671419441353 -0.001890175253721752 -0.0015167040064069108 -7.323002919600067E-4 -4.641768404763377E-4 -1.7114262860659724E-5 -0.001040737340404341 -0.0024245205719267944 -0.003247526457048298 -0.0036325973714131416 -0.002109808293766885 -0.0021465088796791885 -0.002006932558126697 -0.0024053145658276096 -0.0029803537979457765 -0.002782398824190812 -3.3448875968778287E-4 9.325371674297255E-4 0.0011365772124240353 0.0013086706334117803 0.0012767240094052155 3.7727441683943215E-4 -7.558799430124712E-4 -9.814078958207205E-4 -3.767039414107435E-4 -8.224354096928146E-4 -0.0021470793551078772 -0.0015060551317380559 -8.465855361739677E-4 -7.077698485263945E-4 -0.0013558299355167093 -0.002037548072799655 -0.0023079534259980786 -0.003001271230331027 -0.003149214524837619 -0.002987769978518729 -0.0033551561545942243 -0.004085364703315706 -0.003189147804845825 -9.317765335248073E-4 -1.4356964955331215E-4 -7.38955838628041E-4 -0.001582879156134795 -9.715196550567838E-4 -0.0012544754676863579 -0.002514465531183373 -0.0030261819907170984 -0.0037455515062934956 -0.002739993483991622 -0.0017173211988290886 -0.0020934546648111434 -0.00243916277459647 -0.0023501686077210394 -0.002746268713707197 -0.0014005171774306541 -9.283536809526754E-4 -9.433762005748099E-4 1.3311093336068676E-4 0.001445204419344599 3.2726273759105983E-4 -3.981918492246829E-4 -5.57924969257507E-4 -1.317798240270799E-4 -5.497481547796362E-4 -0.0014547123431560766 -0.0028995364455482167 -0.0032720569004819097 -0.0028238533720088546 -0.002428513899927615 -0.0022353128880783896 -3.894445593181235E-4 3.2650210368614165E-4 -0.001039406231070734 -0.0019302986922061873 -0.002030702367655391 -8.06081780737073E-4 -1.7114262860659724E-4 -2.445438004312045E-4 -6.048941128862065E-4 1.901584762295525E-6 8.688340778928254E-4 -2.1754129680660807E-4 -0.0011304921411846897 -0.0013940517892388493 -0.0024325072279284357 -0.0026200034854907744 -0.0019234529870619235 -0.0025718933910046974 -0.003959669950527971 -0.004443623272532182 -0.0033275831755409393 -0.0012902252612175136 -7.121434934796742E-4 -6.254312283189982E-4 1.8863720841971607E-4 8.199633495018304E-4 7.014946188108192E-4 0.001018488798685483 2.470158606221887E-4 -0.0012333678768248774 -0.00206512105185294 -0.002449051015360407 -0.002493928415750581 -0.0018717298815274853 -0.002833931771249021 -0.003617194534838548 -0.0017186523081626954 -0.0010513862150731959 -0.0012483903964470122 -0.0011976180832937216 -0.0015916264460413545 -0.0021273028735800037 -0.0014556631355372243 -7.758465830165742E-4 -0.0012877532010265296 -0.0018312261260905905 -0.0015509325321282302 -0.0016182486327134917 -0.00255382833576289 -0.0023843971334423586 -0.002215156089598057 -0.0027987524531465535 -0.002782398824190812 -0.002319553093048081 -0.002979973480993317 -0.0041266290926575185 -0.003050141958722022 -0.0025294880508055072 -0.001986585601170135 -5.392894385870109E-4 0.001856136886476662 0.004278565715164931 0.0019932411478381694 9.005905434231607E-4 3.879232915082871E-5 -0.0010856147407945153 -9.720901304854724E-4 -8.406906234108516E-4 -7.104320671936081E-4 -2.618482217680938E-4 -0.001428660631912628 -0.002397518068302198 -0.0018705889306701079 -6.497715132763809E-4 -4.172076968476382E-4 -6.942685967140962E-4 -7.701418287296877E-5 -6.493911963239218E-4 -0.0012544754676863579 -0.0010837131560322197 -0.001576984243371679 -0.0017661919272200836 -0.0013638165915183505 -0.0015878232765167634 -0.002295593125043158 -0.0015233595530749452 -2.202035154738218E-4 0.001120603900420753 0.0013425188421806406 5.757998660230849E-4 -3.067256221582682E-4 8.081735239755982E-5 -3.898248762705826E-5 -0.0013556397770404798 -0.002445438004312045 -0.002569991806242402 -0.0036818484167565955 -0.00379042890668367 -0.003537137816345906 -0.0039845807109140435 -0.0033800669149802957 -7.233628435772177E-4 1.8920768384840474E-4 -9.34438752192021E-4 -0.0011466556116642016 -0.0010527173244068027 9.717098135330132E-5 6.743019567099932E-4 5.153294705820873E-4 -4.837631635279816E-4 -0.0011567340109043679 -6.668857761370406E-4 -5.666722591640665E-4 -0.001035603061546143 -7.458015437723049E-4 -1.9396164575414355E-4 -8.127373274051074E-4 -6.438766005132648E-4 -0.0010097415087789237 -8.376480877911788E-4 -0.0010430192421190955 -8.922235704690604E-4 -8.395496725534743E-4 -5.951960305984993E-4 -0.0013853044993322899 -0.001848910864379939 -0.0013991860680970473 -0.001039786548023193 -0.0012584687956871785 -8.718766135124982E-4 -0.0010871360086043517 -0.0015286839904093727 -7.883970424477246E-4 -6.21247741841948E-4 -8.308023826469149E-4 -4.96313622959132E-4 3.143319612074503E-4 -7.40667264914107E-4 -0.0010711626966010692 -0.0021417549177734497 -0.0020067423996504674 -0.0012945989061707935 -6.967406569050804E-4 1.1219350097543597E-5 1.1238365945166553E-4 0.0010367440124035203 0.0024682570214595917 0.0021725605909226372 0.0016471527211003839 0.0013660984932331052 9.076264070436541E-4 8.262385792174056E-4 0.001361534689803596 0.0012162536139642178 0.002204507214929202 0.0023891510953480974 0.0014971176833552668 7.71663096539524E-4 0.0012615113313068512 0.001660653972912682 0.0013541185092306434 1.8065055241807488E-4 -8.773912093231552E-4 -0.0016171076818561145 -0.001390819095142947 -9.580184032444855E-4 -8.484871209362633E-4 -0.002410639003162037 -0.0038332145638353193 -0.003145791672265487 -0.0010253345038297472 5.514595810657023E-4 0.0015315363675528159 0.001153691475284695 0.0010000434264912166 7.20700624910004E-5 -2.5215013948038664E-4 6.634629235649087E-4 0.0015528341168905258 0.0021717999570177193 0.0024397332500251585 0.0016013245283290616 0.00113030198270846 0.001366668968661794 0.0012449675438748803 6.210575833657184E-4 0.0011529308413797768 0.0012634129160691468 1.814111863229931E-4 9.393828725739893E-5 7.644370744428011E-4 8.733978813223346E-4 7.203203079575449E-4 -8.964070569461105E-4 -2.1678066290168983E-5 0.0016017048452815208 0.0010764871339354967 4.7957967705093143E-4 0.001307149365601944 0.0016699717382479301 -6.028023696476814E-4 -0.001601134369852832 -8.443036344592131E-4 -4.1891912313370415E-4 5.050609128656915E-4 0.0020312728430840797 0.0018354096125676408 7.739449982542787E-4 -3.2688242063860074E-4 -4.925104534345409E-4 -6.906555856657346E-4 -5.860684237394808E-4 2.702151947221941E-4 0.0010154462630658104 4.7767809228863587E-4 -8.813845373239758E-4 -0.0012413545328265187 -0.0010723036474584466 -0.0010135446783035148 -0.0012980217587429254 -9.85401223821541E-4 -0.0017391894235954872 -0.0016608441313889115 -9.622018897215357E-4 -0.0013303486997019492 -5.959566645034175E-4 0.0013714229305675327 0.0024079767844948233 0.002401321237826789 0.0022102119692160886 9.912961365846572E-4 -6.273328130812937E-4 -0.0012038933130092968 -8.63889957510857E-4 -1.977648152787346E-5 6.277131300337528E-4 0.002302248671711192 0.0020097849352701406 0.001232797401396189 0.0016233829115716897 0.0010747757076494306 5.965271399321062E-4 0.001083142680603531 0.001811069327610258 0.001615206097093819 2.911326271074449E-4 2.4834696995579557E-4 5.242669189648762E-4 4.476330530443666E-4 0.001486849125638871 0.002713181138843255 0.0018257115302799335 8.169208138821576E-4 2.833361295820332E-4 -4.96313622959132E-4 -5.096247162952007E-5 0.0023990393361120344 0.00301705438385808 0.0027135614557957143 0.0020394496575619507 9.954796230617073E-4 0.0012655046593076718 7.969541738780545E-4 6.320867749870325E-4 7.585421616796849E-4 6.507223056575286E-4 9.855913822977706E-4 0.0015686172704175785 0.001293077638360957 -9.336781182871027E-4 -0.0012270926471093023 -5.46895777636193E-4 5.982385662181721E-4 8.572344108428227E-4 8.952661060887332E-4 9.426155666698917E-4 0.001250101822733078 0.0015197465420265835 0.0017616281237905745 0.0025574413468112517 0.002666021836738326 0.0019407574083988128 0.002503816656514518 0.004133855114754242 0.0042080169204837675 0.0027810677148572055 0.0022773379113251208 0.0020400201329906394 0.001684423782441376 6.530042073722833E-4 9.228390851420183E-4 0.002557251188335022 0.0029172211838375648 0.0016467724041479247 0.0012592294295920967 0.0025367140729022305 0.0033485006079261898 0.0021252111303414786 9.226489266657887E-4 0.001103489637560093 0.0018186756666594402 0.0018036531470373054 0.0019166072819176596 0.0027563471129473634 0.002610305403203067 0.0021023921131939323 0.003278902605626174 0.002892500581927723 0.0018745822586709285 0.0014853278578290346 0.0019719433985004595 0.0015979016757569297 0.0019145155386791346 0.0026241869719678245 0.0036588392411328195 0.003558055248731157 0.0020143487386996496 0.0013695213458052372 0.0012540951507338987 0.0015001602189749397 0.0016975447173012152 0.0010650776253617236 0.0015446573024126549 0.0025956632005333918 0.0031043371244474445 0.0044708159346330085 0.00438961826528299 0.003576310462449194 0.003249618200286823 0.003523446406057378 0.004835159575088831 0.005388330582440599 0.005367603308531578 0.004631119530094522 0.005192277193447931 0.004997745072265099 0.005843379816057918 0.007485968733728793 0.009661001384842416 0.014638399500150952 0.024336862104810588 0.0418706145640327 0.062268343833748116 0.04260785897637468 0.021305165518282834 0.012469261761800446 0.008721618512268426 0.007421885327239434 0.005953101256842371 0.005265868523748768 0.005299526574041398 0.004865014455856871 0.005054222139705276 0.005413431501302901 0.004535089499598598 0.0038668726141279502 0.0037352829485770996 0.004038015242734548 0.003816480617927119 0.0025524972264292832 0.0014079333580036067 0.0023716565155349786 0.0036177650102672365 0.00432154153079281 0.004983293028071653 0.005730615839653794 0.005335276367572555 0.005102142075715123 0.005612527425915242 0.0059643206069399145 0.005352770947385673 0.004664967738863382 0.003991996891486996 0.004172457285428841 0.006716207221951565 0.009384130643452187 0.01045320159681473 0.012520604550382425 0.015106189351675651 0.011860374320913419 0.009179520123029188 0.007391459971042706 0.007664147225955884 0.008662669384637264 0.008500654362889685 0.008684537609403662 0.008616270716437254 0.00807374858375434 0.007892527555907577 0.007340117182460726 0.00612785689649733 0.005812764301384961 0.005454695890644713 0.0059532914153186 0.004628647469903538 0.003395659910031119 0.0039378017257615736 0.005375019489104531 0.004728100352971594 0.004530525696169088 0.0054508927211201225 0.006285308114815398 0.006884877790367178 0.005653601656780825 0.005750392321181667 0.006769831912248298 0.0075397835825017565 0.007315967055979573 0.00684969847226471 0.006532133816961358 0.0062649611578588366 0.004710795931634704 0.004399696664523156 0.005661398154306237 0.005930852715123513 0.006577201375827762 0.007300564219404979 0.007379860303992703 0.006957518328286867 0.006760133829960591 0.008129655175765828 0.007369401587800078 0.0062271196210891555 0.00758066765489111 0.007674415783672279 0.00820571856625765 0.008049788615749417 0.008555229845567567 0.008560364124425766 0.008175103051584691 0.008857391664296325 0.00840994876972819 0.008645745280252835 0.00795965349801661 0.008093525065282214 0.008512444188415918 0.007588464152416522 0.006396550823409687 0.006462155497708883 0.0064440904424670755 0.006625501628790068 0.008168067187964197 0.008271703557509304 0.008382375790674903 0.008533932096229857 0.008949618525267659 0.009189978839221813 0.010688237473434458 0.013039927348965334 0.013978549587634405 0.013955160095058169 0.013353688834744094 0.01337707832732033 0.013228184240432591 0.01333429267016868 0.012444160842938146 0.011875206682059325 0.011597955623716636 0.01131576044499198 0.012249058246326624 0.012446823061605359 0.01214903488782988 0.011115143252569803 0.010861852162232039 0.010847019801086134 0.011305491887275585 0.011773471897276514 0.012551410223531612 0.013244537869388331 0.013626185931181043 0.013753972427207302 0.013357492004268686 0.013214682988620292 0.01335102661607688 0.013481095013817895 0.014296494559890216 0.014899296929537897 0.014100631329373777 0.013489461986771995 0.012253622049756134 0.012520794708858654 0.014657035030821448 0.014672057550443582 0.01581129698153483 0.01646601261519318 0.016203593917996396 0.017791607352989392 0.01843377252721659 0.01769006272668281 0.017869001852814818 0.018415327155022324 0.017726573154118883 0.018109742483721433 0.018830823425583895 0.01859997103544122 0.018859727513970786 0.019392551564365992 0.019638616632607034 0.01836550563425018 0.016907370438521974 0.018500137835420705 0.021177759339209033 0.02212208633216499 0.02195284528832069 0.02199429983613873 0.023357926269180852 0.024185115640779405 0.023999520967979363 0.023582313271131725 0.0243060564316614 0.02468161942221477 0.024601752862198355 0.026678853898053755 0.029427214354999478 0.029841189357751215 0.029576488758839677 0.029759231054496276 0.03048487579978825 0.031673556434699185 0.032298417187589495 0.03228130292472883 0.03312503608375936 0.03426256408856454 0.03580817218335834 0.03599433733158707 0.03697403380112173 0.038502527633054874 0.04007190553737737 0.04148573380814409 0.04299178893988215 0.044467038398471014 0.0467460877360822 0.04943625969930168 0.051534658484494796 0.05296826323678939 0.055231149103921066 0.057559069169923247 0.05977878906295081 0.06263649064372853 0.06511463590595205 0.06841502641939216 0.0720951634098627 0.07598713694285295 0.07984792448574156 0.0861843852306627 0.0941400454006785 0.1012953285442441 0.10828365254568015 0.1169352927386961 0.12794071455048145 0.1410162015345017 0.15584609062021582 0.17240452025485656 0.19281575077638427 0.2173446729421867 0.24788051121360447 0.2875492807813752 0.3398285998587849 0.4112078166056434 0.5086398855468078 0.6480309927434518 0.8612783209983204 1.2037999451974681 1.7808329889389019 2.8212478205675575 4.85416268209388 8.689856912459232 12.049489777900853 9.067467339326162 4.8792280413211255 2.6897868923051145 1.6435575849487878 1.0941209097532156 0.774003186748005 0.5724549784262072 0.4385474712085948 0.34697494555396774 0.2858543982827412 0.2465049047965599 0.21744203408201623 0.18799713498872742 0.15476732158456558 0.11927234041155729 0.09126370828923028 0.0726549899638825 0.05948461390022369 0.04993428474854688 0.04219388397362295 0.03478397863038597 0.029255881567916652 0.025081522697725515 0.02116216634415821 0.017200024333439253 0.015333618889246196 0.0146560842384403 0.013127210089554697 0.011326979795089525 0.008373248183815886 0.005280510726418443 0.005026459002175761 0.004425368058814146 0.003039493084053167 0.001614255304712671 6.80767344901798E-4 2.0042703394594833E-4 -4.250041943730498E-4 -0.0015227890776462565 -0.0010650776253617236 -5.115263010574962E-4 -4.529574903787941E-4 0.0013018249282675165 0.001420103500482298 7.38575521675582E-4 7.256447452919723E-4 2.49868237765632E-4 -9.622018897215357E-4 -0.002284944250374303 -0.0032361169484745244 -0.002745888396754738 -0.0026475764645440595 -0.0017454646533110623 -0.002181688197781656 -0.002432697386404665 -0.0022358833635070783 -0.0028557999960154195 -0.003224517281424522 -0.0034447207968983434 -0.0034192395610835834 -0.0046556499735281335 -0.004190332182194419 -0.004112177048464073 -0.0041545823886632634 -0.0050713364025659355 -0.005008774263886413 -0.0043327608808903535 -0.004076617413409147 -0.00428788348050018 -0.004303096158598543 -0.0033775948547893116 -0.003219383002566324 -0.004753771747262583 -0.004793514868794559 -0.004357671641276425 -0.004617237961329765 -0.002425471364307942 -3.2897416387712586E-5 0.0015893445443265998 9.494612718141557E-4 -5.984287246944017E-4 -7.532177243452574E-4 -1.654378743197107E-5 5.630592481157049E-4 7.952427475919886E-4 0.0020674029535676947 0.0023992294945882637 0.0011768908093847004 -3.2726273759105983E-4 -9.928174043944936E-4 -0.0015714696475610218 -0.0023402803669571024 -0.0034036465660327603 -0.0034388258841352272 -0.0023326740279079206 4.4725273609190746E-4 0.0016813812468217033 0.0016340317862405447 6.113595010780112E-4 0.0011401902234723967 4.966939399115911E-4 -1.4204838174347573E-4 6.199166325083412E-5 -5.564037014476706E-4 -8.458249022690495E-4 -7.952427475919886E-4 -2.6146790481563467E-4 -5.609675048771799E-4 -4.143553197041949E-4 9.445171514321873E-4 0.0015324871599339636 6.22959168128014E-4 2.2609842823693792E-4 3.80316952459105E-7 1.9909592461234146E-4 9.376714462879233E-4 0.0015313462090765864 0.0013919600460003242 0.0018394029405684614 0.00172949134130778 0.0020569442373750695 0.0018367407219012477 0.0014480567964880423 0.0020166306404144044 0.0029784522131834808 0.003302672415154868 0.0038856983032746757 0.004254225430207549 0.004656981082861741 0.004305568218789527 0.004089358031316526 0.004503903509496951 0.004898292189197043 0.005996077072470249 0.008083826982994506 0.009330125636202993 0.009698082287707178 0.0101898321072368 0.011930542798642123 0.015048000857949408 0.017062159438172828 0.018372921814823133 0.019595640816979155 0.02297551757348322 0.02746306745402443 0.03252337466496905 0.04048473958927173 0.053670328331028895 0.07291645786869813 0.09740145342649155 0.12539125985967184 0.14097569777906482 0.11891655390253181 0.07894676346688971 0.052970925455456605 0.03833404722311549 0.03073170150193421 0.025939327583997026 0.022607560921979037 0.020339921092941624 0.019810139578166092 0.018792411413385526 0.018670139513169922 0.018579433920008426 0.01838281005558707 0.016943880865958046 0.014414773132104998 0.013758536230636812 0.012960441105901381 0.012830943183589055 0.010980701209875508 0.010260761218870424 0.00999853268014987 0.009371009708592348 0.008079263179564996 0.006352434056924431 0.005614048693725078 0.005115263010574962 0.00420250232467311 0.004323633274031335 0.0042203772214386885 0.004525011100358431 0.004723156232589625 0.004447046125104315 0.0033793062810753773 0.0029828258581367606 8.304220656944558E-4 3.2441036044761654E-4 0.0010960734569871405 9.281635224764458E-4 0.0012799567035011179 0.0019314396430635647 0.0021413746008209908 9.945288306805597E-4 6.585188031829403E-4 7.693811948247695E-4 7.891576763526429E-4 0.00109208012898632 0.001311332852078994 0.002240637325412817 0.002920073560981008 0.0031438900875031916 0.0022413979593177355 0.0019485539059242245 0.002761101074853102 0.004936514042919183 0.0061997368005121 0.007327756881505805 0.007203393238051678 0.007263673475016446 0.009282586017145605 0.013434696345617884 0.015921018422319282 0.015848948359828283 0.013048104163443205 0.010209418430288443 0.0075751530590804535 0.007443943710482062 0.006808814399875357 0.0066180854482171154 0.006651363181557287 0.005436440676926676 0.003891403057561562 0.0036841303184713503 0.003064594002915468 0.0019183187082037257 0.0014408307743913192 8.456347437928199E-4 0.0013328207598929335 0.0013816914882839285 9.48890796385467E-4 -0.0015186055911692062 -0.0035272495755819693 -0.0022855147258029917 -0.0010987356756543543 -0.0014670726441109976 -0.0015113795690724833 -0.0022239033795046167 -0.002326018481239886 -0.0018141118632299309 -8.545721921756089E-4 -8.233862020739623E-5 -5.59636395543573E-4 -0.0016781485527258009 -0.0017011577283495766 -0.0022699217307521682 -0.001455853294013454 -0.0011322035674707555 -0.0013221718852240785 -0.001168143519478141 -0.0012107390181535609 -2.122168594721806E-4 3.4114430635581716E-4 -6.282836054624415E-4 -0.001600373735947914 -0.0013039166715060415 5.210342248689739E-5 1.673394590820062E-4 0.0013073395240781735 0.0027023421056981706 0.0034165773424163696 0.002769848364759662 0.0028002737209563903 0.0031094714033056423 0.0031718433835089357 0.002917981817742483 0.002140423808439843 0.0028149159236260657 0.0040642571124542256 0.003583536484545917 0.002948217015462982 0.002279429654563646 0.0023478867060062847 0.0015490309473659347 0.0014516698075364037 0.003103196173590067 0.0035145089576745893 0.0034867458201450745 0.004796367245938003 0.004676377247437155 0.0042597400260182055 0.0037541086377238255 0.002155826645014437 4.90799027148475E-4 6.714495795665499E-4 0.0012208174173937271 0.0018793362205766673 0.003647239574082817 0.004239393069061644 0.003745361347817266 0.004525201258834661 0.005926098753217774 0.00560073760038901 0.004940127053967545 0.007075036266596731 0.009293995525719379 0.010573001436839348 0.01165595395896665 0.012156451068402832 0.012757922328716908 0.013870539573136019 0.014660457883393579 0.016370553060125945 0.01894263660960687 0.020234383138634224 0.019341018617307786 0.017529378814268838 0.015546025907194606 0.014680614681873911 0.013815964090458138 0.01435829606466482 0.015519403720522467 0.014497492069264853 0.01453229107041486 0.013135577062508797 0.01311808248269568 0.013676007451953187 0.01203836265466428 0.010630619455136903 0.010191353375046636 0.010234709507626975 0.011922936459592942 0.013765762252733535 0.013407503683517058 0.011674779648113375 0.010094752869122025 0.008108547584904348 0.007127710164512317 0.006921768534755711 0.006602872770118752 0.006307746815010486 0.00620848409041866 0.005616901070868522 0.004133094480849323 0.004189191231337042 0.0042236099155345905 0.003477618213286056 0.003408780844890958 0.004137848442755062 0.0049464022836831194 0.004021281296826346 0.003188006853988448 0.002199943411499693 0.0024496214907890955 0.0023121369124751287 7.861151407329701E-4 1.1048207468937001E-4 5.033494865796255E-4 6.370308953690009E-4 7.480834454870595E-4 0.0011400000649961673 0.0015767940848954492 0.0016811910883454736 0.0014427323591536148 0.0018192461420881289 0.0022294179753152735 0.0028175781422932794 0.003972790885387811 0.0040847942278870175 0.003465828387759824 0.002935096080603143 0.0021543053772046005 0.002294071857233321 0.002785061042858026 0.003024660722907262 0.0022187691006464185 0.0012405938989216005 3.58638886168936E-4 5.586856031624252E-4 0.00122804343949045 0.001637644797288906 0.002445438004312045 0.0023807841223939972 0.0021868224766398536 0.0010217214927813855 -3.926772534140259E-4 -6.252410698427686E-4 -0.0011607273389051885 -7.220317342436108E-4 4.656981082861741E-4 4.7900920162224274E-4 -0.0013761768924732715 -0.001557017603367576 -0.0020466756796586735 -0.001374275307710976 -0.0018742019417184695 -0.002436120238976797 -0.0012151126631068405 -0.001085234423842056 -0.0020208141268914545 -0.0022043170564529724 -0.0019361936049693035 -0.002088130227476716 -0.002306241999712013 -0.0022914096385661074 -0.0023144188141898834 -0.002121217802340658 -0.0013586823126601527 -2.8200502024842636E-4 -6.505321471812992E-4 -0.0017612478068381153 -0.0021936681817841175 -0.002520740760898948 -0.001401848286764261 -5.461351437312748E-4 -0.0010053678638256441 -0.0018196264590405878 -0.0024228091456407284 -0.0016323203599544786 -0.00206093756537589 -0.002052000116993101 -0.001869257821336501 -0.0018913162045791291 -0.0018958800080086384 -0.001397664800287211 -0.0019186990251561847 -0.003377024379360623 -0.0028251844813424617 -0.00229464233266201 -0.0017321535599749936 -0.0019573011958307837 -0.002143466344059516 -0.0025329109033776394 -0.0026513796340686506 -0.002041731559276705 -0.0020076931920316155 -0.002293501381804633 -0.002024046820987357 -0.00252834709994813 -0.0020999200530029483 -0.0017173211988290886 -0.0027278233415129307 -0.0028133946558162293 -0.002955443037559705 -0.0036462887817016692 -0.0029364271899367496 -0.002563716576526827 -0.002553067701857972 -0.0021381419067250883 -0.002931292911078552 -0.0030488108493884154 -0.00200560144879309 -0.0017190326251151546 -0.0019348624956356966 -0.002200323728452152 -0.0030722003419646504 -0.003179639881034347 -0.0032482870909532158 -0.004336373891938715 -0.005722439025175923 -0.004913885184247866 -0.0015543553847003622 -7.49604713296896E-4 -1.7304421336889278E-4 -4.56380342950926E-5 -8.412610988395402E-4 -0.0019557799280209474 -0.0036738617607549543 -0.0040979151627468565 -0.0032568442223835457 -0.0027742220097129416 -0.0022906490046611895 -0.0022183887836939595 -0.0018445372194266592 -0.001260370380449474 -0.0012639833914978354 -0.0015631026746069216 -0.0021417549177734497 -0.002127683190532463 -0.0017279700734979435 -0.00122804343949045 -6.001401509804677E-4 -0.0013704721381863848 -0.0021516431585373867 -0.002850095241728533 -0.0022548992111300335 -0.0013341518692265404 -0.0013143753876986668 -4.1777817227632683E-4 -0.0016834729900602283 -0.0026091644523456897 -0.002077101035855402 -7.956230645444477E-4 7.454212268198459E-5 -1.4337949107708257E-4 -6.625121311837609E-4 -0.001057661444788771 -0.0014157298555290184 -0.0017389992651192577 -0.0028130143388637703 -0.0022394963745554397 -0.0014777215187798524 -8.868991331346329E-4 -8.726372474174164E-4 -8.07793207023139E-4 -1.709524701303677E-4 4.278565715164931E-5 -3.966705814148465E-4 -4.1739785532386774E-4 -8.153995460723211E-4 -6.516730980386764E-4 -3.498915962623766E-4 -0.0010827623636510718 -0.001483426273066739 -0.0016872761595848192 -0.002138332065201318 -0.0014866589671626415 -5.784620846902987E-4 -3.6890744388533184E-4 -0.0012660751347363605 -0.0016174879988085735 -6.997831925247532E-4 -7.064387391927876E-4 -0.0011335346768043624 -1.1466556116642016E-4 0.001068690636410085 0.0014959767324978896 0.0013514562905634297 0.0019679500704996387 0.0012736814737855427 3.717598210287751E-4 -1.2151126631068405E-4 5.622986142107868E-4 4.970742568640502E-4 -3.046338789197431E-4 -1.9966640004103013E-5 -4.6018351247551707E-4 -0.0016463920871954655 -0.001866785761145517 -0.0010141151537322035 -8.285204809321602E-4 -5.700951117361984E-4 5.210342248689739E-4 7.302085487214816E-4 4.3165974104108415E-5 -8.481068039838042E-4 -0.0011071026486084547 -4.982152077214275E-4 3.122402179689252E-4 -3.303052732107327E-4 -0.0015465588871749504 -0.002500203645466156 -0.0018974012758184748 -5.873995330730877E-4 -1.2759633755002973E-4 -1.3919600460003242E-4 -1.2360300954920912E-5 5.415713403017655E-4 6.587089616591699E-4 0.0016085505504257846 5.999499925042381E-4 -2.7515931510416246E-4 -1.0934112383199268E-4 0.001285851616264234 0.0015452277778413436 1.9909592461234146E-4 -7.111927010985264E-5 0.0011900117442445396 0.0010778182432691036 -1.0268557716395834E-5 2.1887240614021494E-4 0.0010924604459387791 0.0017582052712184423 0.0010667890516477896 5.033494865796255E-4 -1.846438804188955E-4 -5.543119582091455E-4 -7.283069639591861E-5 3.624420556935271E-4 3.0558467130089087E-4 -9.812177373444909E-5 -5.440434004927497E-4 -0.0012350793031109435 -5.178015307730715E-4 -2.2096414937874002E-4 3.9933280008206025E-4 0.0010601335049797553 6.421651742271988E-4 -4.289975223738704E-4 -0.001098925834130584 -0.0010897982272715654 3.671960175992659E-4 0.0010350325861174542 0.0012596097465445559 3.584487276927065E-4 2.2590826976070838E-4 0.0014433028345823035 0.0016104521351880802 0.0024083571014472823 0.0027759334359990073 0.001600373735947914 7.870659331141178E-4 9.424254081936622E-4 0.0012270926471093023 0.0021972811928324793 0.0029773112623261034 0.002340470525433332 0.0010669792101240191 3.122402179689252E-4 7.929608458772339E-5 7.701418287296877E-5 3.2688242063860074E-4 0.0012660751347363605 0.0024695881307931983 0.002183589782543951 0.001222148526727334 9.05534663805129E-4 0.0012645538669265241 0.0018443470609504297 0.0016680701534856346 0.0010112627765887603 8.773912093231552E-4 0.0015184154326929767 0.0016020851622339798 0.0014202936589585277 0.002743796653516213 0.0026755297605498035 0.0027886740539063873 0.0034036465660327603 0.003487506454049993 0.003010208678713816 0.0037584822826771053 0.0043829627186149555 0.004008920995871426 0.0032671127800999416 0.002516937591374357 0.0019502653322102904 0.0011934345968166715 9.445171514321873E-4 0.0012423053252076665 0.0011692844703355184 8.791026356092212E-4 0.0016072194410921778 0.0021716097985414896 0.0018962603249610976 0.0014575647202995199 0.0013208407758904717 7.418082157714843E-4 5.891109593591536E-4 7.735646813018196E-4 0.001235269461587173 0.0016277565565249695 0.0015695680627987264 5.48607203922259E-4 -6.528140488960537E-4 -0.001393291155333931 -0.0012791960695961997 -0.0015488407888897052 -0.0012232894775847112 -4.288073638976409E-4 -4.1796833075255637E-4 -0.0013910092536191766 -0.0020268991981308 -9.256914622854616E-4 -3.101484747304001E-4 -5.828357296435784E-4 -7.887773594001838E-4 -7.475129700583709E-4 -0.0011749892246224049 -0.0012078866410101174 -0.0013516464490396592 -0.0020906022876677 -0.0023785022206792425 -0.0030320769034802146 -0.0026342653712079908 -0.0023248775303825087 -0.0027901953217162236 -0.0037375648502918544 -0.0036736716022787246 -0.002611636512536674 -0.002780687397904746 -0.0041372779673263735 -0.004782105360220786 1 1 2 2 4 4 6 6 5 5 3 3 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/dict/000077500000000000000000000000001477224461000270525ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/dict/castepDict.xml000077500000000000000000000250351477224461000316670ustar00rootroot00000000000000 Distribution of CASTEP. Currently either Academic Release or Materials Studio.
CASTEP version number. It may be worth noting that with the F90 rewrite, the version numbers were reset! Now should now move in step with Materials Studio releases. Task of current calculation. eg. SINGLEPOINT, GEOMETRYOPTIMIZATION, MOLECULARDYNAMICS, OPTICS, PHONON, EFIELD, TRANSITIONSTATESEARCH, MAGRES
The approximation used for the exchange-correlation potential. eg. LDA, PW91, PBE, RPBE
The quality of the basis set, as determined by values in the pseudopotential file(s). eg. COARSE, MEDIUM, FINE. Either this term, or 'cutoff' (see below) must exist, but not both.
The quality of the plane wave basis set, quoted as the maximum allowed kinetic energy of a component wave
The number of electrons in the system
Net charge of the system
Net Spin of System
Is the spin fixed or variable? Logical value
Is the occupancy fixed? Do we know the material is an insulator? Logical value.
This determines the method used in calculations on metals. eg. None, DM (Density Mixing), EDFT (Ensemble DFT). Only available if fixOcc is false.
The method to use for geometry optimization. eg. BFGS, DampedMD, Delocalized
Files used for pseudopotentials, assumed from standard Accelrys library.
The system unit cell
Total energy of the system
Total time taken for calcultion.
cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/dict/catalog.xml000077500000000000000000000020411477224461000312060ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/dict/cmlDict.xml000077500000000000000000000336521477224461000311670ustar00rootroot00000000000000 The full cell volume. Contrast primitive cell volume which may not reflect the full symmetry. ang An angle defined by three atoms The atoms are described by atomRefs. atid An identfier for an atom Should be unique within a molecule a The a cell parameter b The b cell parameter c The c cell parameter alpha The alpha cell angle beta The beta cell angle gamma The gamma cell angle The IUPAC IChI identifier The IChI is calculated from the connection table The IUPAC IChI charge The IChI charge on the molecule is calculated from the connection table len A length defined by two atoms See Schema: The atoms are described by atomRefs. Spacegroup This should normally be held in the cml:crystal element tor A torsion defined by four atoms Also known as "dihedral". See Schema: The atoms are described by atomRefs. cellvol The full cell volume family The symmetry of the crystal system class Crystal class (Groth - 1921) centro The centrosymmetric nature of the crystal SG The spacegroup PG The Patterson group symbol date A generic date (role determined by context) Volume of the full crystal cell deltaHR Heat of reaction (state not specified) negative logarithm (base 10) of hydrogen ion molarity The primitive crystallographic cell Volume of the primitive crystal cell Molecular weight Determined by summing average atomic masses P Pressure Role of the pressure is determined by context refs Bibliographic references T Temperature Role of the temperature is determined by context ref PG The pointgroup of a molecule The Schoenflies convention is normally used, but Hermann Mauguin is also allowed. ver Version of a program or specification vol The volume of an object or substance lambda Wavelength Usage determined by context Temperature at which a substance undergoes a transition from glass to ??? Usage determined by context Temperature at which a plolymer undergoes a transition from glass to ??? Usage determined by context cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/dict/cmlDictCopy.xml000077500000000000000000000336561477224461000320260ustar00rootroot00000000000000 The full cell volume. Contrast primitive cell volume which may not reflect the full symmetry. ang An angle defined by three atoms The atoms are described by atomRefs. atid An identfier for an atom Should be unique within a molecule a The a cell parameter b The b cell parameter c The c cell parameter alpha The alpha cell angle beta The beta cell angle gamma The gamma cell angle The IUPAC IChI identifier The IChI is calculated from the connection table The IUPAC IChI charge The IChI charge on the molecule is calculated from the connection table len A length defined by two atoms See Schema: The atoms are described by atomRefs. Spacegroup This should normally be held in the cml:crystal element tor A torsion defined by four atoms Also known as "dihedral". See Schema: The atoms are described by atomRefs. cellvol The full cell volume family The symmetry of the crystal system class Crystal class (Groth - 1921) centro The centrosymmetric nature of the crystal SG The spacegroup PG The Patterson group symbol date A generic date (role determined by context) Volume of the full crystal cell deltaHR Heat of reaction (state not specified) negative logarithm (base 10) of hydrogen ion molarity The primitive crystallographic cell Volume of the primitive crystal cell Molecular weight Determined by summing average atomic masses P Pressure Role of the pressure is determined by context refs Bibliographic references T Temperature Role of the temperature is determined by context ref PG The pointgroup of a molecule The Schoenflies convention is normally used, but Hermann Mauguin is also allowed. ver Version of a program or specification vol The volume of an object or substance lambda Wavelength Usage determined by context Temperature at which a substance undergoes a transition from glass to ??? Usage determined by context Temperature at which a plolymer undergoes a transition from glass to ??? Usage determined by context cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/dict/index.xml000077500000000000000000000013621477224461000307100ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/dict/siesta.xml000077500000000000000000000413741477224461000311000ustar00rootroot00000000000000 1 The full cell volume. Contrast primitive cell volume which may not reflect the full symmetry. ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/000077500000000000000000000000001477224461000306245ustar00rootroot00000000000000adgluc_concise.xml000077500000000000000000000017161477224461000342410ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental amylose_concise.xml000077500000000000000000000016751477224461000344570ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/br_concise.xml000077500000000000000000000017101477224461000334560ustar00rootroot00000000000000 branch00_concise.xml000077500000000000000000000017771477224461000344060ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/branch0_basic.xml000077500000000000000000000037661477224461000340430ustar00rootroot00000000000000 1.4 150.0 1.2 1.5 120.0 150.0 1.4 1.39 1.54 branch0_concise.xml000077500000000000000000000020041477224461000343060ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental branch0_intermed.xml000077500000000000000000000072461477224461000345070ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental m1_{$idx}_a1 m1_{$idx}_a2 m1_{$idx}_a3 m1_{$idx}_a4 m1_{$idx}_a5 m1_{$idx}_a1_m1_{$idx}_a2 m1_{$idx}_a1 m1_{$idx}_a2 m1_{$idx}_a2_m1_{$idx}_a3 m1_{$idx}_a2 m1_{$idx}_a3 m1_{$idx}_a3_m1_{$idx}_a4 m1_{$idx}_a3 m1_{$idx}_a4 m1_{$idx}_a4_m1_{$idx}_a5 m1_{$idx}_a4 m1_{$idx}_a5 m1_{$idx}_l1 m1_{$idx}_a1 m1_{$idx}_a2 {$l1} m1_{$idx}_len2 m1_{$idx}_a2 m1_{$idx}_a3 {$len2} m1_{$idx}_a1 m1_{$idx}_a1 m1_{$idx}_a2 m1_{$idx}_a3 {$a1} m1_{$idx}_ang2 m1_{$idx}_a2 m1_{$idx}_a3 m1_{$idx}_a4 {$ang2} m1_{$idx}_t1 m1_{$idx}_a1 m1_{$idx}_a2 m1_{$idx}_a3 m1_{$idx}_a4 {$t1} m1_{$idx}_tor2 m1_{$idx}_a2 m1_{$idx}_a3 m1_{$idx}_a4 m1_{$idx}_a5 {$tor2} m1_{$idx} branch2_concise.xml000077500000000000000000000020001477224461000343040ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental branch_concise.xml000077500000000000000000000020031477224461000342250ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental copoly_concise.xml000077500000000000000000000016541477224461000343100ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental coxyacet_concise.xml000077500000000000000000000016001477224461000346110ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental etoac1_concise.xml000077500000000000000000000016051477224461000341530ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/etoac_concise.xml000077500000000000000000000016041477224461000341500ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/gly0_concise.xml000077500000000000000000000017201477224461000337270ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/gly1_concise.xml000077500000000000000000000023501477224461000337300ustar00rootroot00000000000000 1 0 0 10 0 1 0 20 0 0 1 30 0 0 0 1 linear2_concise.xml000077500000000000000000000016021477224461000343300ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental linear3_concise.xml000077500000000000000000000016301477224461000343320ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental linear4_concise.xml000077500000000000000000000017021477224461000343330ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/mixed_basic.xml000077500000000000000000000060701477224461000336230ustar00rootroot00000000000000 1 0 0 4 0 1 0 8 0 0 1 12 0 0 0 1 180 90 60 1.51 95 1.53 114 113 105 115 112 125 -35 -45 naphthyl0_concise.xml000077500000000000000000000017101477224461000347030ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental naphthyl_concise.xml000077500000000000000000000017051477224461000346270ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/new1_basic.xml000077500000000000000000000031201477224461000333600ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/new2_basic.xml000077500000000000000000000140671477224461000333750ustar00rootroot00000000000000 100 180 180 180 180 180 100 180 180 180 180 180 100 180 180 180 180 180 100 180 180 180 180 180 100 180 180 180 180 180 100 180 180 180 180 180 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/new3_basic.xml000077500000000000000000000036321477224461000333720ustar00rootroot00000000000000 1.51 95 1.53 114 113 105 115 112 125 -35 -45 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/new3a_basic.xml000077500000000000000000000025041477224461000335300ustar00rootroot00000000000000 1.51 95 125 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/new4_basic.xml000077500000000000000000000054151477224461000333740ustar00rootroot00000000000000 1.51 95 1.53 105 115 125 -35 -45 1.51 45 1.53 85 125 135 35 65 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/new5_basic.xml000077500000000000000000000071171477224461000333760ustar00rootroot00000000000000 1.35 180 1.50 140 1.50 140 1.35 180 1.40 180 1.54 180 1.35 180 1.35 180 1.50 140 1.50 140 1.35 180 1.40 180 1.54 180 1.35 180 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/new5a_basic.xml000077500000000000000000000053201477224461000335310ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/new6_basic.xml000077500000000000000000000030421477224461000333700ustar00rootroot00000000000000 180 90 60 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/new6a_basic.xml000077500000000000000000000032201477224461000335270ustar00rootroot00000000000000 180 60 180 60 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/new7_basic.xml000077500000000000000000000022701477224461000333730ustar00rootroot00000000000000 1.51 95 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/peo1mid.xml000077500000000000000000000142721477224461000327150ustar00rootroot00000000000000 1.54 1.54 111 1.40 111 180 1.54 1.54 111 1.40 111 180 1.54 1.54 111 1.40 111 180 105 1.40 105 180 180 180 105 1.40 105 180 180 180 1.40 105 180 1.10 105 180 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/peo3zmat.xml000077500000000000000000000122161477224461000331150ustar00rootroot00000000000000 1.54 1.54 111 1.40 111 120 1.54 1.54 111 1.40 111 120 1.54 1.54 111 1.40 111 120 105 1.40 105 140 140 -140 105 1.40 105 160 160 -140 1.40 105 90 1.10 105 60 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/phen_basic.xml000077500000000000000000000037471477224461000334570ustar00rootroot00000000000000 1.39 1.5 120.0 1.5 120.0 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/poly0_concise.xml000077500000000000000000000016741477224461000341270ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/poly1_concise.xml000077500000000000000000000016661477224461000341310ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/poly_concise.xml000077500000000000000000000016751477224461000340500ustar00rootroot00000000000000 polystyreneList_basic.xml000077500000000000000000000034501477224461000356660ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental 1 0 0 10 0 1 0 0 0 0 1 0 0 0 0 1 180 60 polystyreneRandom_basic.xml000077500000000000000000000032041477224461000361700ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental 180 90 60 polystyrene_basic.xml000077500000000000000000000031051477224461000350270ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental 180 90 60 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/pspeo_basic.xml000077500000000000000000000041231477224461000336400ustar00rootroot00000000000000 180 90 60 180 180 randomBranchPoly_concise.xml000077500000000000000000000017701477224461000362440ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental randomPoly_concise.xml000077500000000000000000000017221477224461000351230ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/star1_basic.xml000077500000000000000000000051231477224461000335450ustar00rootroot00000000000000 1.4 115 1.39 1.4 1.5 120.0 1.39 1.4 124.0 1.39 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/star2_basic.xml000077500000000000000000000027471477224461000335570ustar00rootroot00000000000000 1.4 115 1.39 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/star3_basic.xml000077500000000000000000000067111477224461000335530ustar00rootroot00000000000000 1.5 120.0 1.39 1.4 124.0 1.39 1.5 120.0 1.39 1.4 124.0 1.39 1.5 120.0 1.39 1.4 124.0 1.39 starPoly1_concise.xml000077500000000000000000000017131477224461000346750ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental starPoly_concise.xml000077500000000000000000000016501477224461000346140ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/experimental/star_basic.xml000077500000000000000000000037771477224461000335010ustar00rootroot00000000000000 1.4 1.5 120.0 1.39 1.4 124.0 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/misc/000077500000000000000000000000001477224461000270625ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/misc/columnTable1.xml000077500000000000000000000016761477224461000321470ustar00rootroot00000000000000 1 2 3 a b c
cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/misc/columnTableToColumn1.xml000077500000000000000000000016311477224461000336170ustar00rootroot00000000000000 1 2 3 a b c
cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/misc/columnTableToContent1.xml000077500000000000000000000017201477224461000337730ustar00rootroot00000000000000 1.0 a 2.0 b 3.0 c
cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/misc/columnTableToRow1.xml000077500000000000000000000023431477224461000331320ustar00rootroot00000000000000 1.0 a 2.0 b 3.0 c
cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/misc/contentTable1.xml000077500000000000000000000017671477224461000323250ustar00rootroot00000000000000 1 a 2 b 3 c
cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/misc/contentTableToColumn1.xml000077500000000000000000000016651477224461000340030ustar00rootroot00000000000000 1.0 2.0 3.0 a b c
contentTableToContent1.xml000077500000000000000000000017671477224461000341040ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/misc 1 a 2 b 3 c
cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/misc/contentTableToRow1.xml000077500000000000000000000023411477224461000333050ustar00rootroot00000000000000 1 a 2 b 3 c
cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/misc/inline.xml000077500000000000000000000034271477224461000310730ustar00rootroot00000000000000 1.3 1.35 108.0 1.4 120.0 145.0 1.45 100.0 120.0 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/misc/rowTable1.xml000077500000000000000000000023701477224461000314510ustar00rootroot00000000000000 1 a 2 b 3 c
cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/misc/rowTableToColumn1.xml000077500000000000000000000016651477224461000331400ustar00rootroot00000000000000 1.0 2.0 3.0 a b c
cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/misc/rowTableToContent1.xml000077500000000000000000000017141477224461000333100ustar00rootroot00000000000000 1 a 2 b 3 c
cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/misc/rowTableToRow1.xml000077500000000000000000000023701477224461000324440ustar00rootroot00000000000000 1 a 2 b 3 c
cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/misc/table1.xml000077500000000000000000000015501477224461000307600ustar00rootroot00000000000000 a b c1 2 3
cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/units/000077500000000000000000000000001477224461000272715ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/units/castepUnits.xml000077500000000000000000000061021477224461000323170ustar00rootroot00000000000000 The energy of a photon of frequency f. The energy of a photon is defined as hf, where h is Planck's constant; therefore, we can use frequency as a measure of energy. One Kelvin of energy, in this context, is defined as 1K*k_B, the Boltzmann constant. The Kelvin is a reasonably commonly encountered unit for energy, but the definition can be somewhat ambiguous. Here, the energy referred to is simply defined as the product of the magnitude and the Boltzmann constant, which gives the correct dimensionality. Note that this is unrelated to the number of particles in the system (i.e., the resulting energy is not per-particle or per-mole); thus, a mole of particles with a per-particle energy of 1K/particle (in this terminology) would have an energy of 8.314 Jmol-1K-1 (the molar gas constant). cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/units/catalog.xml000077500000000000000000000021431477224461000314300ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/units/index.xml000077500000000000000000000013131477224461000311230ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/units/siUnitsDict.xml000077500000000000000000001140321477224461000322610ustar00rootroot00000000000000 The SI base unit of time, equal to the duration of 9192631770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the caesium-133 atom. The second has had many definitions throughout history; originally, it was one sixtieth of one twenty-fourth of a solar day (the factor of sixty coming from Babylonian counting and the factor of 24 from Ancient Egypt). The present definition dates from the Thirteenth General Conference on Weights and Measures, which took place in 1967. The SI base unit of length, defined as the length of the path travelled by light in absolute vacuum during 1/299792458 of a second. The modern metre dates from 1791, when it was defined one ten-millionth of the length of the earth's meridian along a quadrant; it became France's official unit of length in 1793. Until 1960, the metre (like the kilogram) was defined by a prototype - in this case, a platinum-iridium bar; in 1960, the SI defined the metre as 1650763.73 wavelengths of the orange-red emission line (the 2p10 - 5d5 transition) in the EM spectrum of Krypton-86 in vacuum. Since 1983, the present definition has been used. The SI unit of current, defined as that constant current which if maintained in two straight parallel conductors of infinite length and negligible circular cross-section, placed 1 metre apart in vacuum, would produce between those conductors a force of 2E-7 newton per metre length. This is equivalent to setting the permeability of vacuum to pi*4E-7 Hm^-1. Prior to 1948, the International Ampere (equal to 0.99985 A) was used; it was defined in terms of the electrolytic deposition rate of silver. The SI base unit of mass, defined as being equal to the mass of the international prototype of the kilogram. It is the only SI base unit that employs a prefix, and the only SI unit that is still defined in relation to an artifact (a platinum-iridium mass) rather than to a fundamental physical property. The SI unit of temperature, defined as 1/273.16 of the thermodynamic temperature of the triple point of water. A temperature in Kelvin is measured with respect to absolute zero - where, except for zero-point motion, molecular motion stops. The unit is named after William Thomson, first Baron Kelvin, a Scottish physicist and engineer. The SI unit identifying the number of particles in a given amount of matter, a dimensionless number equal to the number of elementary entities in 0.012 kilograms of carbon 12 where the carbon 12 atoms are unbound, at rest, and in their ground state. The number of atoms in 12 grams of carbon 12 is commonly known as Avogadro's number; it is approximately 6.0221415E23. Prior to 1959, IUPAP and IUPAC defined the mole in terms of oxygen (though the definitions were slightly different from each other); in 1959/1960, the two organizations unified on the present definition. The SI base unit of luminous intensity, defined as a radiant intensity of 1/683 watt per steradian in a given direction from a monochromatic source at 540E12 Hz. This is based on an older unit, the candlepower, which was referenced to the luminous intensity of a "standard candle" of known composition. The frequency chosen is in the visible spectrum near green, which is within the range where the human eye is most sensitive. m m-1 The SI unit of plane angle. A radian is equal to the angle subtended at the centre of a circle by an arc of circumference equal in length to the circle's radius The radian is therefore formally dimensionless, as it is a ratio of two lengths. There are 2*pi radians in a complete circle. m2 m-2 The SI unit of solid angle, defined as the solid angle subtended at the centre of a sphere of radius r by a portion of the surface of the sphere having an area r^2. Since the surface area of a sphere is 4*pi*r^2, a sphere measures 4*pi steradians. The steradian is the solid analogue of the radian, and like that unit, is formally dimensionless (in this case, being the ratio of two areas.) s-1 s-1 The SI derived unit of frequency, defined as one cycle per second. Periodically varying angles are typically not expressed in Hz, but instead in an appropriate angular unit (such as radians per second). m.kg.s-2 m.kg.s-2 The SI derived unit of force, defined as the force necessary to accelerate a mass of one kilogram at a rate of 1m s^-2. Named after Sir Isaac Newton, the Newton was adopted as the name for the MKS (direct predecessor of the SI) unit of force in 1948. A small apple, fittingly, exerts a gravitational force of about 1N on Earth. N m m2.kg.s-2 The SI derived unit of energy, defined as the energy required to exert a force of one newton for a distance of one metre. This is dimensionally, but not semantically, equivalent to the newton metre, which is typically used as a unit of torque. It is also, significantly, the work required to move an electric charge of one coulomb through an electric potential difference of one volt. J/s m2.kg.s-3 The SI derived unit of power, defined as one joule of energy per second. The watt dates back to the Second Congress of the British Association of the Advancement of Science in 1889, and is named after James Watt, one of the key engineers to the development of the steam engine. N/m2 m-1.kg.s-2 The SI derived unit of pressure, equal to one newton per square metre. The pascal, named after Blaise Pascal, is also used to measure stress, Young's modulus, and tensile strength. For atmospheric pressures, however, it is commonly regarded as an inconveniently small unit. s.A The SI unit of electric charge, defined as the amount of electric charge carried by a current of one ampere flowing for one second. Also the unit of electric flux. The Coulomb could, in principle, be defined in terms of the elementary charge of the electron and the Josephson and von Klitzing constants; in this case, the kilogram would become a derived rather than fundamental unit. W/A = J/C m2.kg.s-3.A-1 The SI unit of electric potential difference, defined as the potential difference across a conductor when a current of one ampere dissipates one watt of power. The number of volts is a measure of the strength of an electrical source in the sense of how much power is produced for a given current level. It is named in honor of Alessandro Volta (1745–1827), who invented the voltaic pile, the first chemical battery. Since 1990 the volt is maintained internationally for practical measurement using the Josephson effect. V/A m2.kg.s-3.A-2 The SI unit of electrical impedance/resistance; a resistance of one ohm produces a potential difference of one volt when one ampere of current flows through it. Named after Georg Ohm, the German physicist who discovered Ohm's Law; since 1990, the unit has been internationally maintained using the Quantum Hall Effect and a conventional value for the von Klitzing constant. C/V m-2.kg-1.s4.A2 The SI derived unit of capacitance, equal to one coulomb of stored charge causing a potential difference of one volt across the terminals of the capacitor being measured. Capacitance is a measure of the total amount of electric charge stored for a given electric potential. The farad is a very large unit; typical capacitors are in the microfarad to picofarad range. Although the farad is named after Michael Faraday, it should not be confused with the Faraday - an older unit of capacitance. [Omega]-1 m-2.kg-1 s3.A2 The SI derived unit of electrical conductance, defined as the reciprocal of the system's electrical resistance. This is equivalent to the obsolete "mho" unit (derived from spelling "ohm" backwards and written with an upside-down capital omega). m2.kg.s-2.A-1 m2.kg.s-2.A-1 The SI derived unit of magnetic flux; a change in flux of one weber per second through a loop will induce an electromotive force of one volt. The weber, like the farad, is a very large unit. V.s.m-2 = Wb/m2 kg.s-2.A-1 The SI derived unit of magnetic flux density, defined as one weber per metre squared. The tesla is the value of the total magnetic flux (in some sense, the "power" of a magnet) over area; hence reducing the affected area generally increases the magnetic flux density. Like many of the other electromagnetic units, one tesla is very large. V.s.A-1 = Wb/A m2.kg.s-2.A-2 The SI derived unit of magnetic inductance; a circuit with an inductance of one henry gives rise to an EMF of one volt when the rate of change of current in the circuit is 1 A.s^-1. Inductance is a measure of how much magnetic flux is produced for a given circuit. s-1 s-1 The SI derived unit of radioactivity, defined as the activity of a quantity of radioactive material in which one nucleus decays per second. This, therefore, has the same dimensionality as the hertz (s^-1, reciprocal time) - a frequency, in other words. The reason for having a specific unit for radioactivity is slightly unusual; it was specifically introduced because of the dangers to human health which might arise from mistakes involving the units reciprocal second. Using the becquerel unit, a more active (and so, all the other things fixed, more dangerous) source has a higher number. Using 1/s or s as a second instead may lead to confusion. J/kg m2.s-2 The SI derived unit of absorbed radioactive dose, defined as the absorption of one joule of radiation energy by one kilogram of matter. Note that these are the same units as the sievert. To avoid any risk of confusion between the absorbed dose and the equivalent dose, one must use the corresponding special units, namely the gray instead of the joule per kilogram for absorbed dose and the sievert instead of the joule per kilogram for the dose equivalent. J/kg m2.s-2 The SI derived unit of equivalent radioactive dose, equal to the absorbed dose in grays multiplied by two dimensionless constants - Q, dependent on radiation type, and N dependent on all other factors. The sievert attempts to reflect the biological effects of radiation as opposed to the physical aspects, which are characterised by the absorbed dose, measured in grays. Note that these are the same units as the sievert. To avoid any risk of confusion between the absorbed dose and the equivalent dose, one must use the corresponding special units, namely the gray instead of the joule per kilogram for absorbed dose and the sievert instead of the joule per kilogram for the dose equivalent. mol/s s-1.mol The derived SI unit for expressing quantity values of catalytic activity, in mol s^-1. The katal is not used to express the rate of a reaction; that is expressed in moles per second. Rather, it is used to express catalytic activity which is a property of the catalyst. The katal is invariant of the measurement procedure, but the numerical quantity value is not and depends on the experimental conditions. Therefore, in order to define the quantity of a catalyst, the rate of conversion of a defined chemical reaction has to be specified, preferably of the first order, under strictly controlled conditions. mol/L 103.m-3.mol not yet added mol/kg kg-1.mol not yet added m2 not yet added m3 not yet added m.s-1 not yet added m.s-2 not yet added s-1 not yet added kg.m.s-1 not yet added kg.m2.s-1 not yet added kg.m2.s-2 not yet added m-1 not yet added kg.m-3 not yet added kg-1.m3 not yet added m-3.mol not yet added m3.mol-1 not yet added kg.m2.s-2.K-1 not yet added kg.m2.s-2.K-1.mol-1 not yet added m2.s-2.K-1 not yet added kg.m2.s-2.mol-1 not yet added m2.s-2 not yet added kg.m-1.s-2 not yet added kg.s-2 not yet added kg.s-3 not yet added kg.m.s-3.K-1 not yet added m2.s-1 not yet added kg.m-1.s-1 not yet added m-3.s.A not yet added A.m-2 not yet added kg-1.m-3.s3.A2 not yet added kg-1.s3.mol-1.A2 not yet added kg-1.m-3.s4.A2 not yet added kg.m.s-2.A-2 not yet added kg.m.s-3.A-1 not yet added A.m-1 not yet added cd.m-2 not yet added kg-1.s.A not yet added m2.s-3 not yet added Gradient of energy with respect to length. Although formally identical to force, many authors report energy gradients as energy per unit length and this unitType preserves the dimensional representation. cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/units/siestaUnits.xml000077500000000000000000000071611477224461000323360ustar00rootroot00000000000000 the "infinity" Rydberg constant The Rydberg constant is named after physicist Janne Rydberg, and is a physical constant discovered when measuring the spectrum of hydrogen, and building upon results from Anders Jonas Angstrom and Johann Balmer. Each chemical element has its own Rydberg constant, which can be derived from the "infinity" Rydberg constant. The "infinity" Rydberg constant is (according to 2002 CODATA results): This constant is often used in atomic physics in the form of an energy (see RyEnergy) energy equivalent of 1 Rydberg h * c * Ryinf = 13.6056923 eV This constant is often used in atomic physics in the form of an energy ... ... ... ... ... ... pressure??? ... ... ... ... cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/units/unitTypeDict.xml000077500000000000000000000442321477224461000324500ustar00rootroot00000000000000 Gradient of energy with respct to length. cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/units/unitsDict.xml000077500000000000000000000344101477224461000317660ustar00rootroot00000000000000 unknown unit and unknown unitType 1E-10 metres. The angstrom is named after the Swedish physicist Anders Jonas Angstrom (1814-1874), one of the founders of spectroscopy, after his spectrum chart of solar radiation in the electromagnetic spectrum on the order of multiples of one ten-millionth of a millimetre, or 1E-10 metres. derived inverse length a measurement of plane angle, representing 1/360 of a full rotation The degree and its subdivisions are the only units in use which are written without a separating space between the number and unit symbol (e.g. 15[deg] 30', not 15 [deg] 30 '). 1/12 of the mass of one atom of carbon-12. The unit is convenient because one hydrogen atom has a mass of approximately 1 amu, and more generally an atom or molecule that contains n protons and neutrons will have a mass approximately equal to n amu. (The reason is that a carbon-12 atom contains 6 protons, 6 neutrons and 6 electrons, with the protons and neutrons having about the same mass and the electron mass being negligible in comparison.) This is only a rough approximation however, since it does not account for the mass contained in the binding energy of an atom's nucleus; this binding energy mass is not a fixed fraction of an atom's total mass. The degree Celsius ([deg]C) is a unit of temperature named after the Swedish astronomer Anders Celsius (1701-1744), who first proposed a similar system in 1742. The Celsius scale sets 0.01 [deg]C to be at the triple point of water and a degree Celsius to be 1/273.16 of the difference in temperature between the triple point of water and absolute zero. Until 1954 the scale was defined with the freezing point of water at 0 [deg]C and the boiling point at 100 [deg]C at standard atmospheric pressure. This definition is still a close approximation to the actual definition and has lead many to wrongly refer to the scale as Centigrade. CGS units for electric dipole 3600 seconds One bar is 1 x 10^5 pascal. A common unit in meteorology for describing atmospheric pressures. One atmospheric pressure is defined as 101325.027 Pa. Formerly common in meteorology (and diving), this is very close to equal to one bar - which, due to the ease of interconversion with SI, has mostly supplanted it. One thousand bar, and therefore 1E8 pascals. There are 3 main definitons of calorie which differ by ca 0.05% so cal and kcal should be deprecated. The energy of a single photon of light, possessing a reciprocal wavelength as given (in inverse centimetres) in vacuum. The historical reason for using this quantity is that it is proportional to energy, but not dependent on the speed of light or Planck's constant, which were not known with sufficient accuracy (or rather not at all known). As a unit of energy, the speed of light is implicit. A measure of the frequency of a radiation, possessing a reciprocal wavelength as given, in vacuum. The speed of light is a constant, so frequency and reciprocal wavelength are inversely proportional and hence equivalently valid as units. pH is measured in log units so has no dimensions; this entry allows the quantityType to be captured Andrew to fill in Andrew to fill in The commonest unit of dynamic viscosity. see parents ??? 10-11 C/n (whatever that is!) perts per million can apply to many ratios arbitrary unit and unknown unitType cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/000077500000000000000000000000001477224461000267255ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/action1.xml000077500000000000000000000034001477224461000310050ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/action2.xml000077500000000000000000000047441477224461000310220ustar00rootroot00000000000000 This is a conversion of a chemical synthesis to STMML. We have deliberately not marked up the chemistry in this example! Take 1 mmol of the diol and dissolve in dioxan in 25 Place flask in water bath with magnetic stirrer Add 0.5 ml 1 M H2SO4 extract solution and check diol spot on TLC Add 10 ml water to flask Neutralize acid with 10% NaHCO3 Extract with 10ml ether Combine ether layers Wash ether with 10 ml water Wash ether with 10 ml saturated NaCl Dry over anhydrous Na2SO4 and remove solvent on rotary evaporator cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/actionList1.xml000077500000000000000000000032151477224461000316450ustar00rootroot00000000000000 Roast meat Keep warm in oven Heat water Cook potatoes Keep warm in oven cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/alternative1.xml000077500000000000000000000021131477224461000320460ustar00rootroot00000000000000 Spirits of hartshorn NH3 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/alternativeType1.xml000077500000000000000000000022031477224461000327100ustar00rootroot00000000000000 ethylene dichloride DCE dichloroethane cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/amount1.xml000077500000000000000000000016751477224461000310470ustar00rootroot00000000000000 100 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/angle1.xml000077500000000000000000000021771477224461000306300ustar00rootroot00000000000000 123.4 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/annotation1.xml000077500000000000000000000022541477224461000317100ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/appinfo1.xml000077500000000000000000000020261477224461000311670ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/arg1.xml000077500000000000000000000024471477224461000303130ustar00rootroot00000000000000 42 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/array1.xml000077500000000000000000000017221477224461000306530ustar00rootroot00000000000000 1.23 2.34 3.45 4.56 5.67 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/array2.xml000077500000000000000000000017741477224461000306630ustar00rootroot00000000000000 /A B//C/D-E/F/ cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/array3.xml000077500000000000000000000025531477224461000306600ustar00rootroot00000000000000 11 12.5 10.9 10.2 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/atom1.xml000077500000000000000000000024351477224461000304770ustar00rootroot00000000000000 0.2 1 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/atom2.xml000077500000000000000000000025241477224461000304770ustar00rootroot00000000000000 0.2 0.3 0.4 1 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/atomArray1.xml000077500000000000000000000026031477224461000314730ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/atomArray2.xml000077500000000000000000000032771477224461000315040ustar00rootroot00000000000000 0.2 -0.3 0.1 0.2 -0.3 0.1 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/atomIDType1.xml000077500000000000000000000025011477224461000315500ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/atomParity1.xml000077500000000000000000000017411477224461000316670ustar00rootroot00000000000000 1 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/atomRefArrayType1.xml000077500000000000000000000020011477224461000327620ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/atomRefType1.xml000077500000000000000000000020361477224461000317730ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/atomRefs21.xml000077500000000000000000000021311477224461000313720ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/atomRefs31.xml000077500000000000000000000022461477224461000314020ustar00rootroot00000000000000 123.4 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/atomRefs41.xml000077500000000000000000000023051477224461000313770ustar00rootroot00000000000000 123.4 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/atomSet1.xml000077500000000000000000000025051477224461000311510ustar00rootroot00000000000000 a2 a3 a4 a2 a4 a5 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/atomTest.xml000077500000000000000000000021251477224461000312520ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/atomType1.xml000077500000000000000000000032671477224461000313450ustar00rootroot00000000000000 1.7 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/atomTypeList1.xml000077500000000000000000000021121477224461000321650ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/atomicBasisFunction1.xml000077500000000000000000000043231477224461000335010ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/band1.xml000077500000000000000000000023651477224461000304450ustar00rootroot00000000000000 0.45456 1.3455 3.5653 6.3454 0.47567 1.2456 3.4365 6.1434 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/basisSet1.xml000077500000000000000000000017261477224461000313160ustar00rootroot00000000000000 631-G* cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/basisSet2.xml000077500000000000000000000122321477224461000313110ustar00rootroot00000000000000 C2V -37.90004 -20.34372 -13.10423 -12.71709 -12.07969 -7.47084 -3.44820 -1.14406 -.70572 .56580 -.08645 -.30627 .28127 .21650 .00000 .51104 .00000 .54076 .43797 .16535 -.38651 -.67196 .19755 .00002 .00000 .00000 .00000 -.58544 .00009 .13159 -.12937 .05529 -.29019 -.38339 .00000 -.38138 .00000 .02479 .63431 .44787 .19522 -.08345 .43789 -.25407 .00000 -.25274 .00000 -.03716 .42046 -.67572 .00000 .00000 .00000 .00000 .37511 .00000 .92698 .00000 .00000 .00000 -.08646 -.30626 .28121 -.21652 .00000 -.51109 .00000 .54056 -.43824 .16523 -.86876 .41200 .13042 .00000 .00000 .00001 .00000 .09466 .00001 -.22256 .08917 .23508 .39444 -.69478 .00000 .43176 .00000 -.13723 -.16033 .25987 -.13456 -.35475 -.59518 -.46042 .00000 .28617 .00000 .20700 -.10623 -.39217 .00000 .00000 .00000 .00000 .92698 .00000 -.37511 .00000 .00000 .00000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/basisSet3.xml000077500000000000000000000414731477224461000313230ustar00rootroot00000000000000 -1.9603 -1.5114 -1.3910 -1.2870 -0.9252 -0.8508 -0.8505 -0.8014 -0.7580 -0.7233 -0.6950 -0.6768 -0.6662 -0.6041 -0.5566 -0.5344 -0.0252 0.0362 0.0412 0.1597 0.2347 0.2870 0.3149 0.3492 0.3615 0.4229 0.8013 -0.4195 -0.7817 -0.0056 0.2985 0.1112 -0.0249 -0.0206 -0.0277 0.0746 -0.0249 -0.0742 -0.0050 -0.0373 -0.1171 -0.1094 -0.0258 -0.0089 0.0078 -0.0785 -0.0129 0.0374 -0.0185 -0.0031 0.1751 0.0456 -0.0992 -0.1392 -0.0003 0.0067 -0.0035 0.0221 -0.0264 0.2733 -0.7538 0.0605 -0.0551 -0.0309 -0.0420 -0.0043 0.0513 -0.0023 0.0472 -0.0030 0.5809 0.0301 -0.0464 -0.0152 0.0115 -0.0116 -0.0164 0.0121 0.0018 0.0013 0.0023 0.0202 -0.0172 -0.0115 0.0033 0.1132 0.9164 0.0530 -0.0280 0.0442 -0.0430 -0.0686 -0.0724 -0.0209 0.0297 0.0136 0.0336 -0.3506 -0.0289 0.0413 0.0174 -0.0099 0.0164 0.0109 -0.0060 -0.0029 0.0010 -0.0168 0.0071 -0.0029 0.0197 0.0075 -0.0710 -0.2238 -0.6331 0.0815 -0.0387 0.0034 0.0452 0.0575 0.0393 0.0392 -0.0249 0.0224 -0.7199 -0.0438 0.0653 0.0187 -0.0119 0.0112 0.0189 -0.0109 0.0130 -0.0052 -0.0101 -0.3551 -0.0057 -0.0167 0.0566 -0.5432 0.1332 0.0886 0.2713 -0.4154 0.1828 0.3028 0.1203 -0.2375 0.1652 0.0804 0.0087 -0.0029 0.0160 0.0057 -0.1485 0.0360 0.0023 -0.0631 0.0296 0.0028 -0.0187 0.2119 -0.0698 0.0505 -0.0068 -0.0102 -0.0120 -0.0001 -0.0186 -0.2117 0.0802 0.2500 -0.0307 0.0523 0.0830 -0.0855 0.3527 0.3640 -0.0741 -0.0058 -0.7418 -0.0669 -0.1240 0.0302 0.0548 -0.0232 0.0210 -0.1091 0.1043 0.2528 -0.2027 0.0061 0.0678 0.0645 0.0057 -0.0015 -0.0048 -0.1713 0.2023 0.2190 0.1444 -0.2956 0.1766 0.1566 0.0772 0.0653 -0.2233 0.0024 0.5669 -0.1708 0.0110 0.1732 -0.2032 -0.0336 0.0895 -0.3357 0.0037 -0.0045 -0.0018 -0.0009 -0.0084 -0.0116 -0.0011 -0.1522 -0.1400 -0.2536 -0.1769 0.2485 -0.1901 0.0622 0.1482 0.1016 -0.0475 0.8140 0.0467 0.2049 -0.0524 -0.1123 -0.0085 0.0212 -0.0342 -0.0365 0.0033 0.0194 0.0613 -0.0717 0.0806 -0.0713 0.0232 0.0036 0.0548 0.2321 -0.0577 0.1744 0.1673 0.0141 -0.1117 0.0261 -0.0248 0.0098 0.0482 0.0007 0.2440 0.0770 0.6172 -0.5411 -0.0257 0.1665 -0.2722 -0.0436 -0.0052 -0.0189 0.1886 -0.0779 -0.0616 0.0137 -0.0147 -0.0006 0.2004 0.1942 -0.0230 -0.0160 -0.0787 0.1325 -0.0481 -0.1623 0.0172 0.1918 -0.0050 -0.0447 -0.0230 0.3251 0.4253 0.0824 0.6489 0.2569 0.0517 -0.0085 -0.1510 -0.0665 -0.0420 0.0771 -0.0014 0.0138 0.1635 -0.0069 0.1137 -0.0811 0.1085 0.1258 -0.0447 0.0589 -0.0496 -0.0013 0.1120 0.0619 -0.2571 -0.6207 0.2548 -0.2069 -0.1511 -0.2323 0.4801 -0.0134 -0.0015 0.1256 -0.0600 -0.1430 -0.0307 0.0197 0.0012 -0.0350 -0.1044 0.0809 -0.1463 0.1803 -0.0059 -0.0233 -0.2071 -0.1133 -0.0006 -0.1206 -0.0873 0.2614 -0.2228 0.1277 0.0861 0.7879 -0.2022 -0.0250 0.0621 -0.3254 -0.1010 0.0118 -0.1639 0.1176 -0.0190 -0.0273 -0.1730 0.1096 -0.0658 -0.0068 0.0400 0.1374 0.1480 0.0358 0.0228 0.0289 -0.1229 0.1323 0.4038 0.0532 0.0869 0.0761 -0.2180 -0.1438 0.1374 0.6721 -0.4263 0.0332 0.0787 -0.7658 0.2211 -0.0046 -0.0339 0.0796 -0.0004 0.0127 0.0945 0.0071 -0.1498 -0.0615 0.0110 0.0241 0.0070 0.0019 -0.0036 -0.0096 -0.0007 -0.0478 -0.0876 -0.0521 0.0517 -0.0879 -0.3299 -0.0064 -0.0278 0.0037 0.0318 0.1087 -0.0458 -0.0030 -0.0062 0.1063 0.0821 0.0860 -0.0953 0.0022 -0.0760 0.6862 0.2738 0.0193 -0.0625 0.4899 -0.1099 0.0466 0.0261 0.0208 0.3705 0.0274 0.0121 0.0175 -0.1389 -0.0107 -0.0070 -0.0211 -0.2182 0.0087 0.0612 -0.1132 0.0122 0.0779 -0.1966 0.0856 0.5897 0.6112 0.0775 0.0113 0.0208 -0.0138 0.0824 0.0497 -0.0033 -0.0428 -0.0776 0.0046 0.0449 -0.0953 -0.3276 -0.0161 0.0103 -0.0097 0.0016 0.0130 -0.0359 0.0081 -0.1884 -0.2976 -0.3480 -0.1512 0.0713 -0.1097 0.0794 -0.2742 0.6505 0.0482 -0.2334 0.1068 -0.1561 -0.0605 0.2496 0.0098 -0.0075 0.2048 0.0836 -0.0273 -0.3512 0.3352 -0.6503 0.2579 0.1860 -0.0311 -0.0002 0.2319 0.1176 -0.0183 -0.1000 0.0499 -0.0776 0.0281 0.0181 0.0379 -0.0127 -0.0210 -0.0609 0.1308 0.0950 -0.0897 0.0621 -0.0050 0.1369 0.2659 -0.1362 -0.0121 0.0319 -0.0465 0.0385 0.0976 -0.0045 -0.0867 -0.5870 0.0005 0.2090 0.3070 -0.1561 -0.1783 0.2180 -0.1288 -0.0614 -0.0171 0.0814 -0.0382 -0.1011 0.1853 -0.0619 -0.3731 0.1612 -0.0377 0.3821 -0.0470 -0.0966 0.0257 -0.0320 -0.0234 -0.2754 0.0725 0.0323 -0.2518 -0.1888 -0.1319 0.2743 0.0910 0.4435 -0.5758 0.0160 -0.0295 -0.0152 0.0177 0.0554 0.1886 0.0179 -0.0732 0.1241 -0.0249 0.1308 0.2645 -0.1703 -0.0275 0.0057 0.0033 -0.0122 0.0424 -0.0453 0.0024 -0.1878 -0.4528 -0.0808 -0.4926 -0.0339 -0.1283 -0.0773 0.3588 -0.4456 -0.0549 -0.2243 -0.0775 -0.0150 0.1365 0.1534 -0.1479 -0.0859 0.1430 0.0584 -0.0077 -0.3639 0.3669 0.6047 0.3634 -0.0005 -0.0026 -0.0096 -0.0426 0.1488 -0.0234 -0.1010 -0.0153 -0.1348 -0.0674 -0.0138 0.0023 0.0096 -0.1040 0.0607 0.1417 -0.2847 -0.1723 -0.1389 -0.0237 0.0372 0.0281 -0.0994 0.0324 0.0168 0.0099 0.0051 0.0613 0.0451 -0.0110 -0.0859 0.0037 0.6109 -0.2922 0.5120 -0.0055 -0.2329 -0.1851 0.1297 0.0201 -0.0027 0.2579 -0.0791 0.2181 -0.1031 -0.0602 -0.1347 0.0207 -0.0617 0.0425 -0.0829 0.0021 -0.0624 -0.0780 -0.5031 -0.0168 -0.0326 -0.1150 0.2630 0.1008 -0.3183 -0.3515 -0.2205 -0.1202 -0.0261 0.1179 0.0000 0.0466 0.0753 0.0877 0.1459 0.2509 0.1557 -0.1026 -0.3849 0.0970 -0.2037 0.0015 -0.0095 -0.0007 -0.0244 -0.1520 0.0348 -0.0138 -0.1836 0.3638 -0.3629 0.1020 0.6002 -0.1907 0.0928 0.1463 -0.1934 0.0150 -0.2262 -0.0487 -0.2773 0.0703 -0.0163 0.1702 -0.0148 -0.1588 0.0754 -0.0819 -0.1686 0.1410 -0.2774 0.1120 0.0917 -0.0057 -0.0540 -0.4071 -0.0922 0.1088 0.1574 -0.0911 -0.0492 -0.0137 -0.0493 -0.1859 0.0206 0.0384 0.2159 -0.1660 -0.3836 0.1540 0.2832 -0.1545 -0.0336 -0.4897 -0.0122 -0.1364 0.1447 0.2669 0.1811 0.3486 -0.0034 0.0187 0.1101 -0.2375 0.0328 0.1519 0.0722 0.1648 0.0497 -0.0006 -0.0025 -0.0060 0.1426 -0.0824 -0.0967 0.3678 0.4183 0.2857 -0.0074 -0.3864 0.0698 -0.1563 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/bond1.xml000077500000000000000000000023761477224461000304650ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/bond3.xml000077500000000000000000000034641477224461000304660ustar00rootroot00000000000000 C cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/bondArray1.xml000077500000000000000000000030151477224461000314530ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/bondSet1.xml000077500000000000000000000026741477224461000311420ustar00rootroot00000000000000 b4 b1 b2 b3 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/bondStereo1.xml000077500000000000000000000026411477224461000316420ustar00rootroot00000000000000 C cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/bondTypeList1.xml000077500000000000000000000017121477224461000321540ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/box31.xml000077500000000000000000000023751477224461000304150ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/cml2.xml000077500000000000000000000034471477224461000303170ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/cmlone.xml000077500000000000000000000036131477224461000307320ustar00rootroot00000000000000 45.03 Storeroom 12.3 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/complexObject1.xml000077500000000000000000000024351477224461000323350ustar00rootroot00000000000000 1 2 3 1 2 3 4 5 6 7 8 9 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/conditionList1.xml000077500000000000000000000020141477224461000323520ustar00rootroot00000000000000 23 coordinateComponentArrayType1.xml000077500000000000000000000017521477224461000353340ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd coordinateComponentArrayType2.xml000077500000000000000000000017371477224461000353400ustar00rootroot00000000000000cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/countType1.xml000077500000000000000000000021031477224461000315210ustar00rootroot00000000000000 Add 10 ml reagent cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/crystal1.xml000077500000000000000000000035261477224461000312220ustar00rootroot00000000000000 4.500 4.500 4.500 90 90 90 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/crystal2.xml000077500000000000000000000035631477224461000312240ustar00rootroot00000000000000 9.4620 8.3920 5.2210 90.0000 110.1800 90.0000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/dataTypeType1.xml000077500000000000000000000043301477224461000321500ustar00rootroot00000000000000 23.2 42 the mouse ran up the clock defaults to string cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/definition1.xml000077500000000000000000000026261477224461000316710ustar00rootroot00000000000000 An enzyme that contains a region to which small, regulatory molecules ('effectors') may bind in addition to and separate from the substrate binding site and thereby affect the catalytic activity. On binding the effector, the catalytic activity of the enzyme towards the substrate may be enhanced, in which case the effector is an activator, or reduced, in which case it is a de-activator or inhibitor. cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/delimiterType1.xml000077500000000000000000000017541477224461000323620ustar00rootroot00000000000000 |A|B12||D and E| cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/description1.xml000077500000000000000000000025051477224461000320600ustar00rootroot00000000000000 In general, an enzyme catalyzes only one reaction type (reaction selectivity) and operates on only one type of substrate (substrate selectivity). Substrate molecules are transformed at the same site (regioselectivity) and only one or preferentially one of chiral a substrate or of a racemate is transformed (enantioselectivity[special form of stereoselectivity]). cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/dictRefGroup1.xml000077500000000000000000000021011477224461000321220ustar00rootroot00000000000000 50 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/dictRefGroup2.xml000077500000000000000000000025601477224461000321340ustar00rootroot00000000000000 We observed constructing dwellings of different material A domesticated animal. Predators include wolves Sus scrofa cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/dictionary1.xml000077500000000000000000000025451477224461000317060ustar00rootroot00000000000000 CDMixAmp cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/dictionary2.xml000077500000000000000000000020121477224461000316740ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/dimension1.xml000077500000000000000000000020711477224461000315200ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/dimension2.xml000077500000000000000000000021601477224461000315200ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/documentation1.xml000077500000000000000000000017361477224461000324130ustar00rootroot00000000000000 Transcribed from IUPAC website cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/eigen1.xml000077500000000000000000000020421477224461000306200ustar00rootroot00000000000000 1 2 3 1 2 3 4 5 6 7 8 9 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/eigen2.xml000077500000000000000000000043601477224461000306260ustar00rootroot00000000000000 0. 0. 0. 0. 0. 0. 1. 2. 3. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 01 02 03 04 05 06 07 08 09 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/electron1.xml000077500000000000000000000020471477224461000313510ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/electron2.xml000077500000000000000000000023361477224461000313530ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/elementTypeArrayType1.xml000077500000000000000000000017741477224461000337000ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/elementTypeType1.xml000077500000000000000000000021621477224461000326710ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/entry1.xml000077500000000000000000000017211477224461000306750ustar00rootroot00000000000000 The alpha cell angle cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/enumeration1.xml000077500000000000000000000031031477224461000320560ustar00rootroot00000000000000 A crystal system No constraints on lengths and angles--> Two cell angles are right angles; no other constraints cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/expression1.xml000077500000000000000000000025131477224461000317330ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/formalChargeType1.xml000077500000000000000000000021051477224461000327650ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/formula1.xml000077500000000000000000000017521477224461000312050ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/formula2.xml000077500000000000000000000027221477224461000312040ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/formula3.xml000077500000000000000000000023401477224461000312010ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/formulaType1.xml000077500000000000000000000024511477224461000320440ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/fragment1.xml000077500000000000000000000025721477224461000313440ustar00rootroot00000000000000 1.4 115 1.39 120 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/fragment1_basic.xml000077500000000000000000000053511477224461000325030ustar00rootroot00000000000000 1.4 115 1.39 120 1.39 1.4 1.5 120.0 1.39 1.4 124.0 1.39 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/fragment2.xml000077500000000000000000000040721477224461000313420ustar00rootroot00000000000000 1.4 1.5 120.0 1.39 1.4 124.0 1.39 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/fragmentList1_basic.xml000077500000000000000000000027231477224461000333370ustar00rootroot00000000000000 1.4 115 1.39 120 1.39 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/gradient1.xml000077500000000000000000000017361477224461000313370ustar00rootroot00000000000000 1.3 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/ichi.xml000077500000000000000000000021321477224461000303640ustar00rootroot00000000000000 C6H3ClN2O5,7-4-1H-3(8(10)11)2H-5(6(4)14H)9(12)13 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/idArrayType1.xml000077500000000000000000000017321477224461000317730ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/identifier1.xml000077500000000000000000000017411477224461000316600ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/identifier2.xml000077500000000000000000000021341477224461000316560ustar00rootroot00000000000000 C6H3ClN2O5,7-4-1H-3(8(10)11)2H-5(6(4)14H)9(12)13 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/index.html000077500000000000000000000072171477224461000307340ustar00rootroot00000000000000 Examples
up
Examples

Examples

We have attempted to provide at least one example for each element. (There are also some examples for many of the attributes and types). The examples for the elements are used for:

  • Validation. The concatenated examples are validated against the schema. This ensures the schema is valid and also provides examples of how to write valid documents. Note that XMLSchema validators sometimes have different levels of strictness. In particular Xerces does not allow documentation in references to elements; this has been highlighted in public discussion. The only area where our examples do not always validate are in namespaceed data values (e.g. within dictRef values).
  • Guidelines for usage. The examples show minimal examples of how each element can be used and so are a guide to its semantics.
  • Code generation. The schema code will autogenerate Java code for each example. This will show how to construct a DOM containing this element, and also how to read such a DOM element. It also acts as a secondary check on the validity of the autogenerated code.
By convention an element foo will have an example foo1.xml. There may be other examples (foo2.xml, etc.) which are often more complex and so will not be used for autogeneration.

Some examples:

  • <molecule id="m1" title="angle example" >
    <?cml example="compilable"?>
      <atomArray>
        <atom id="a1"/>
        <atom id="a2"/>
        <atom id="a3"/>
      </atomArray>
      <angle units="degrees" atomRefs3="a1 a2 a3">123.4</angle>
    </molecule>
    
    Note:
    • This is the example for angle, even although the root element is not angle.
    • The title attribute should reflect this.
    • The processing instruction is probably obsolete
    • The example is validatable (e.g. the angle value must conform to nonNegativeAngleType).
  • <atom id="a1" title="O3'" elementType="O" 
      formalCharge="1" hydrogenCount="1"
      isotope="17" occupancy="0.7" 
      x2="1.2" y2="2.3" 
      x3="3.4" y3="4.5" z3="5.6"
      convention="abc:chem" dictRef="chem:atom"
    >
      <scalar title="dipole" dictRef="ccml:dipole" 
        units="units:debye">0.2</scalar>
      <atomParity atomRefs4="a3 a7 a2 a4">1</atomParity>
      <electron id="e1" atomRef="a1" count="2"/>
    </atom>
    
    Note:
    • This demonstrates all the main attributes and child elements.
    • The examples should all be well-formed XML documents.
cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/index.xml000077500000000000000000000202211477224461000305560ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/isotope1.xml000077500000000000000000000017461477224461000312250ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/isotope2.xml000077500000000000000000000023371477224461000312230ustar00rootroot00000000000000 100 100 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/isotope3.xml000077500000000000000000000026521477224461000312240ustar00rootroot00000000000000 75.75 24.25 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/isotope4.xml000077500000000000000000000017041477224461000312220ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/isotopeList1.xml000077500000000000000000000023271477224461000320550ustar00rootroot00000000000000 75.75 24.25 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/join1.xml000077500000000000000000000041031477224461000304700ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/kpoint1.xml000077500000000000000000000032151477224461000310400ustar00rootroot00000000000000 -0.125 -0.125 0.125 0.125 0.125 0.125 -0.375 0.125 0.125 -0.375 -0.125 0.375 -0.375 -0.125 0.125 0.375 0.125 0.125 -0.375 -0.375 0.375 -0.375 -0.375 0.125 0.375 0.375 0.125 0.375 0.375 0.375 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/label1.xml000077500000000000000000000016751477224461000306230ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/lattice3.xml000077500000000000000000000022251477224461000311630ustar00rootroot00000000000000 0.2 0.25 1.2 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/latticeVector1.xml000077500000000000000000000023331477224461000323440ustar00rootroot00000000000000 10.0 0.0 0.0 0.0 10.0 0.0 1.0 0.0 11.0 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/latticeVector2.xml000077500000000000000000000023701477224461000323460ustar00rootroot00000000000000 10.0 0.0 0.0 0.0 10.0 6.0 0.0 0.0 11.0 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/length1.xml000077500000000000000000000020171477224461000310140ustar00rootroot00000000000000 1.534 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/line31.xml000077500000000000000000000016621477224461000305520ustar00rootroot00000000000000 1 2 3 4 5 6 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/list1.xml000077500000000000000000000017711477224461000305140ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/matrix1.xml000077500000000000000000000021271477224461000310410ustar00rootroot00000000000000 |1.1|1.2|1.3|1.2|2.2|2.3|1.3|2.3|3.3| cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/maxType1.xml000077500000000000000000000017241477224461000311660ustar00rootroot00000000000000 15 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/mechanism1.xml000077500000000000000000000017271477224461000315060ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/mechanismComponent1.xml000077500000000000000000000022011477224461000333550ustar00rootroot00000000000000 The precise order of the formation of the C-X bond and the rupture of C-Y is not known experimentally. cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/metadata1.xml000077500000000000000000000046411477224461000313200ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/module1.xml000077500000000000000000000025061477224461000310230ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/molecule1.xml000077500000000000000000000026321477224461000313430ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/molecule2.xml000077500000000000000000000037231477224461000313460ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/moleculeTable1.xml000077500000000000000000000044251477224461000323150ustar00rootroot00000000000000 O 1 8.002485575 -3.823362985 -2.138277620 6.333476866 1.408404093 -3.760703825 H 2 7.196819640 -3.407152949 -1.716753294 6.604013418 15.57210052 -17.28030869 H 3 8.825722038 -3.351466988 -1.822671748 7.290961006 4.999519121 -11.69655263 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/name1.xml000077500000000000000000000022141477224461000304520ustar00rootroot00000000000000 aspirin 2-acetoxybenzoic acid acetylsalicylic acid cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/namespaceRefType1.xml000077500000000000000000000021211477224461000327620ustar00rootroot00000000000000 123 123 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/nonNegativeAngleType.xml000077500000000000000000000017601477224461000335440ustar00rootroot00000000000000 123.4 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/object1.xml000077500000000000000000000017071477224461000310060ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/observation1.xml000077500000000000000000000017501477224461000320710ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/parameter1.xml000077500000000000000000000017321477224461000315160ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/parameterList1.xml000077500000000000000000000031401477224461000323450ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/particleRefType1.xml000077500000000000000000000020671477224461000326420ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/peak1.xml000077500000000000000000000021511477224461000304520ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/peak2.xml000077500000000000000000000040241477224461000304540ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/peakGroup1.xml000077500000000000000000000020501477224461000314650ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/peakList1.xml000077500000000000000000000023671477224461000313170ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/peakStructure1.xml000077500000000000000000000045561477224461000324060ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/peakStructure1Schema.xml000077500000000000000000000045561477224461000335270ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/peakStructure2.xml000077500000000000000000000052031477224461000323750ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/peakStructure2Schema.xml000077500000000000000000000051331477224461000335200ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/plane31.xml000077500000000000000000000023331477224461000307160ustar00rootroot00000000000000 1 2 3 4 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/point31.xml000077500000000000000000000016131477224461000307500ustar00rootroot00000000000000 1 2 3 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/positiveAngleType.xml000077500000000000000000000022121477224461000331220ustar00rootroot00000000000000 70.123 80.456 90.789 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/potential1.xml000077500000000000000000000035571477224461000315440ustar00rootroot00000000000000 0.115E+04 0.280 .000E+00 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/potentialForm1.xml000077500000000000000000000040031477224461000323530ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/potentialList1.xml000077500000000000000000000044471477224461000323770ustar00rootroot00000000000000 0.180E+05 0.205 134. 0.139E+04 0.362 175. cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/productList1.xml000077500000000000000000000021721477224461000320510ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/property1.xml000077500000000000000000000023101477224461000314130ustar00rootroot00000000000000 buckminsteremptierene 123 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/propertyList1.xml000077500000000000000000000024421477224461000322550ustar00rootroot00000000000000 penguinone black 1.23 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reactant1.xml000077500000000000000000000024031477224461000313330ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reactantList1.xml000077500000000000000000000022011477224461000321630ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reaction1.xml000077500000000000000000000044131477224461000313410ustar00rootroot00000000000000 25 0.25 12.345 7.23 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reaction10a.xml000077500000000000000000000052401477224461000315610ustar00rootroot00000000000000 70 04:00 water H+ cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reaction10b.xml000077500000000000000000000050211477224461000315570ustar00rootroot00000000000000 70 04:00 water H+ cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reaction11.xml000077500000000000000000000020531477224461000314200ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reaction5.xml000077500000000000000000000031101477224461000313360ustar00rootroot00000000000000 220 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reaction6.xml000077500000000000000000000045171477224461000313530ustar00rootroot00000000000000 1 0.1M HCl 0.25 65 0.25 1.2 75.3 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reaction7.xml000077500000000000000000000030741477224461000313510ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reaction8.xml000077500000000000000000000053161477224461000313530ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reaction9a.xml000077500000000000000000000045641477224461000315210ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reactionList1.xml000077500000000000000000000031451477224461000321760ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reactionList2.xml000077500000000000000000000054621477224461000322030ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reactionScheme1.xml000077500000000000000000000073021477224461000324660ustar00rootroot00000000000000 Assume the following synthesis. The three branches are independent and the three numbered products are then combined to create X. A..>B..>1 \\ C..>2...> X / D + E..>3 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reactionScheme3.xml000077500000000000000000000042161477224461000324710ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reactionScheme4a.xml000077500000000000000000000034321477224461000326320ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reactionScheme4b.xml000077500000000000000000000030111477224461000326240ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reactionStepList1.xml000077500000000000000000000030461477224461000330320ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reactionStepList2.xml000077500000000000000000000030101477224461000330220ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reactionStepList3.xml000077500000000000000000000030751477224461000330360ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reactionStepList4.xml000077500000000000000000000025561477224461000330420ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reactionStepList5a.xml000077500000000000000000000027571477224461000332070ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/reactiveCentre1.xml000077500000000000000000000031061477224461000324760ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/refGroup1.xml000077500000000000000000000022301477224461000313210ustar00rootroot00000000000000 The action of on cardiac muscle ... cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/region1.xml000077500000000000000000000017431477224461000310230ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/region2.xml000077500000000000000000000017431477224461000310240ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/sample1.xml000077500000000000000000000017151477224461000310200ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/scalar1.xml000077500000000000000000000020611477224461000307770ustar00rootroot00000000000000 34.3 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/schema.xsd000077500000000000000000017304331477224461000307230ustar00rootroot00000000000000 Describes whether child elements are sequential or parallel. There is no default. The type of an alternative. This adds semantics to an _alternative_ and might be used by an RDF or related engine. An enumeration of allowed angle units. May be obsolete. An identifier for an atom. Of the form prefix:suffix where prefix and suffix are purely alphanumeric (with _ and -) and prefix is optional. This is similar to XML IDs (and we promote this as good practice for atomIDs. Other punctuation and whitespace is forbidden, so IDs from (say) PDB files are not satisfactory. The prefix is intended to form a pseudo-namespace so that atom IDs in different molecules may have identical suffixes. It is also useful if the prefix is the ID for the molecule (though this clearly has its limitation). Atom IDs should not be typed as XML IDs since they may not validate. 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. A reference to two distinct existing atoms in order. A reference to three distinct existing atoms in order. A reference to four distinct existing atoms in order. A reference to an existing atom. An array of references to bonds. The references cannot (yet) cannot be schema- or schematron-validated. Instances of this type will be used in array-style representation of electron counts, etc. It can also be used for arrays of bondIDTypes such as in complex stereochemistry, geometrical definitions, bond groupings, etc. A reference to an existing bond. A reference to a bond may be made by atoms (e.g. for multicentre or pi-bonds), electrons (for annotating reactions or describing electronic properties) or possibly other bonds (no examples yet). The semantics are relatively flexible. A box in 3-space. Defined by 6 real numbers (x1 y1 z1 x2 y2 z2). By default these are Cartesian coordinates (with units specified elsewhere - responsibility of schema creator.) If there is a means of specifying oblique axes (e.g. crystallographic cell) the box may be a parallelipiped. The components are grouped in threes ans separated by a semicolon to avoid problems of guessing the convention. The chirality of a system or molecule. This is being actively investigated by a IUPAC committee (2002) so the convention is likely to change. No formal default. A pair of floats representing a complex number. This example is schema-invalid as it has three floats An x/y coordinate pair. An x/y coordinate pair consisting of two real numbers, separated by whitespace or a comma. In arrays and matrices, it may be useful to set a separate delimiter An x/y/z coordinate triple. An x/y/z coordinate triple consisting of three real numbers, separated by whitespace or commas. In arrays and matrices, it may be useful to set a separate delimiter. An array of coordinateComponents for a single coordinate. An array of coordinateComponents for a single coordinate where these all refer to an X-coordinate (NOT x,y,z).Instances of this type will be used in array-style representation of 2-D or 3-D coordinates. Currently no machine validation. Currently not used in STMML, but re-used by CML (see example). Array of counts. Normally, but not always, integers. can be used with a number of elements 2005-11-01: PMR the combination of dataType and list does not work with JUMBO5.0 - so for the meantime we have removed the restriction A count multiplier for an object. Many elements represent objects which can occur an arbitrary number of times in a scientific context. Examples are action, object or molecules. 2005-10-16. Changed to positiveNumerType. an enumerated type for all dataTypes in STM. dataTypeType represents an enumeration of allowed dataTypes (at present identical with those in XML-Schemas (Part2- datatypes). This means that implementers should be able to use standard XMLSchema-based tools for validation without major implementation problems. It will often be used an an attribute on scalar, array or matrix elements. Note: the attribute xsi:type might be used to enforce the type-checking but I haven't worked this through yet. A single non-whitespace character to separate components in arrays. Some STMML elements (such as array) have content representing concatenated values. The default separator is whitespace (which can be normalised) and this should be used whenever possible. However in some cases the values are empty, or contain whitespace or other problematic punctuation, and a delimiter is required. Note that the content string MUST start and end with the delimiter so there is no ambiguity as to what the components are. Only printable characters from the ASCII character set should be used, and character entities should be avoided. When delimiters are used to separate precise whitespace this should always consist of spaces and not the other allowed whitespace characters (newline, tabs, etc.). If the latter are important it is probably best to redesign the application. At present there is a controlled pattern of characters selected so as not to collide with common usage in XML document The values in the array are "A", "B12", "" (empty string) and "D and E" note the spaces A dictionaryPrefix used to identify a dictionary, units, convention or other metadata. 2005-12-12: PMR. Added for use with dictionary The dictionary prefix must conform to XSD. Allowed values for dimension Types in quantities. These are the 7 types prescribed by the SI system, together with the "dimensionless" type. We intend to be somewhat uncoventional and explore enhanced values of "dimensionless", such as "angle". This may be heretical, but we find the present system impossible to implement in many cases. Used for constructing entries in a dictionary of units An angl. (formally dimensionless, but useful to have units). An array of elementTypes. Instances of this type will be used in array-style representation of atoms. Allowed elementType values. The periodic table (up to element number 118. In addition the following strings are allowed: Du. ("dummy") This does not correspond to a "real" atom and can support a point in space or within a chemical graph. R. ("R-group") This indicates that an atom or group of atoms could be attached at this point. Any isotope of hydrogen. There are no special element symbols for D and T which should use the isotope attribute. A point or object with no chemical semantics. Examples can be centroids, bond-midpoints, orienting "atoms" in small z-matrices. Note "Dummy" has the same semantics but is now deprecated. A point at which an atom or group might be attached. Examples are abbreviated organic functional groups, Markush representations, polymers, unknown atoms, etc. Semantics may be determined by the role attribute on the atom. The basis of an error value. Errors in values can be of several types and this simpleType provides a small controlled vocabulary. Array of error estimate values. An observed or calculated estimate of the error in the value of a numeric quantity. It should be ignored for dataTypes such as URL, date or string. The statistical basis of the errorValueType is not defined - it could be a range, an estimated standard deviation, an observed standard error, etc. This information can be added through _errorBasisType_. An estimate of the error in the value of a quantity. An observed or calculated estimate of the error in the value of a numeric quantity. It should be ignored for dataTypes such as URL, date or string. The statistical basis of the errorValueType is not defined - it could be a range, an estimated standard deviation, an observed standard error, etc. This information can be added through _errorBasisType_. An array of floats. An array of floats or other real numbers. Not used in STM Schema, but re-used by CML and other languages. Array of formalCharges. Used for electron-bookeeping. This has no relation to its calculated (fractional) charge or oxidation state. The formal charge on an object. Used for electron-bookeeping. This has no relation to its calculated (fractional) charge or oxidation state. Format of a spectrum. The data structure of the spectrum. (Not the format of the data). This describes how the data structure is to be interpreted. one dimensional spectru. Data are represented by two _array_s, one representing the independent variable (e.g. wavelength, mass number) and the other the measured dependent variable (absorption, intensity, etc.). This can normally be plotted directly with the independent variable as the x-axis. The order of the points is not necessarily significant and may be increasing or decreasing. Two dimensional spectru. Data are represented by a single symmetric _matrix_ with both axes identical (i.e. the same independent variable). A typical example is a "2D 1HNMR spectrum". The dependent variable is represented by the matrix elements. This can normally be plotted as a square symmentric about a diagonal. Two dimensional spectrum with different axe. Data are represented by non-square _matrix_ with independent axes. A typical example is a "2D 1H 13C NMR spectrum". The dependent variable is represented by the matrix elements. . A concise representation for a molecular formula. This MUST adhere to a whitespaced syntax so that it is trivially machine-parsable. Each element is followed by its count (which may be decimal), and the string is optionally ended by a formal charge (of form d or -d, i.e. no '+') NO brackets or other nesting is allowed. 2005-08-30: allowed decimal points Domain of an FT spectrum. Indicates whether a spectrum is raw FID or has been transforme. Data are raw, so will normally require transforming. Data have been transformed. This value indicates that an FT experiment and transformation have been performe. This was not known to be an FT experiment. (It may have been, but the author or abstracter omitted to mention it). Array of hydrogenCounts. The total number of hydrogen atoms bonded to an atom or contained in a molecule, whether explicitly included as atoms or not. It is an error to have hydrogen count less than the explicit hydrogen count. There is no default value and no assumptions about hydrogen Count can be made if it is not given. If hydrogenCount is given on every atom, then the values can be summed to give the total hydrogenCount for the (sub)molecule. Because of this hydrogenCount should not be used where hydrogen atoms bridge 2 or more atoms. The total number of hydrogen atoms bonded to an object. The total number of hydrogen atoms bonded to an atom or contained in a molecule, whether explicitly included as atoms or not. It is an error to have hydrogen count less than the explicit hydrogen count. There is no default value and no assumptions about hydrogen Count can be made if it is not given. If hydrogenCount is given on every atom, then the values can be summed to give the total hydrogenCount for the (sub)molecule. Because of this hydrogenCount should not be used where hydrogen atoms bridge 2 or more atoms. An array of ids or idRefs. See idType. A unique ID for an element. This is not formally of type ID (an XML NAME which must start with a letter and contain only letters, digits and .-_:). It is recommended that IDs start with a letter, and contain no punctuation or whitespace. The function in XSLT will generate semantically void unique IDs. It is difficult to ensure uniqueness when documents are merged. We suggest namespacing IDs, perhaps using the containing elements as the base. Thus mol3:a1 could be a useful unique ID. However this is still experimental. Inheritance mechanism. A reference to an existing element can be used to supplement values such as coordinates. The inheritance attribute determines whether the values are supplemented, overwritten or deleted. In the example: <molecule id="m1" view="initial"> <atomArray> <atom id="a1" x3="0.1"/> </atomArray> </molecule> <!-- this adds more information --> <molecule ref="m1" view="initial" inherit="supplement"> <atomArray> <atom id="a1" hydrogenCount="1"/> </atomArray> </molecule> <!-- this will overwrite the previous values --> <molecule ref="m1" inherit="overwrite" view="final" id="m2"> <atomArray> <atom id="a1" x3="0.1"/> </atomArray> </molecule> <!-- this will delete the previous values --> <molecule ref="m1" inherit="delete" view="restart"> <atomArray> <atom id="a1" hydrogenCount=""/> </atomArray> </molecule> The first molecule/@ref adds complementary information, the second changes the values. Software is allowed to generate two independent copies of the molecule and reference them by different IDs (m1 and m2). This mechanism is necessary to manage the implied inheritance of partial information during minimisations and dynamics. It requires careful software implementation. Values from this element will be merged. The merging is element-specific with the intention that information from the current element will not conflict with the existing information. It is an error if there is a conflict. Values from this element will replace existing information. The merging is element-specific with the intention that information from the current element will replace the existing information. Components of this element will de deleted if they exist. An array of integers. An array of integers; for re-use by other schemas. Not machine-validatable. The numeric representation of an isotope. In core CML this represents a single number; either the combined proton/neutron count or a more accurate estimate of the nuclear mass. This is admittedly fuzzy, and requires a more complex object (which can manage conventions, lists of isotopic masses, etc.) See isotope. The default is "natural abundance" - whatever that can be interpreted as. Delta values (i.e. deviations from the most abundant istopic mass) are never allowed. A fractional representation of the spin of the nucleus. Allowed lattice types. lattice with A centering. A lattice which uses the translation operator {0, 0.5, 0.5}. User-defined lattice-type. This definition must be by reference to a namespaced dictionary entry. An unbounded line in 3-space. Defined by 6 real numbers, conventionally an arbitrary point on the line and a vector3. There is no significance to the point (i.e. it is not the "end of the line") and there are an infinite number of ways of representing the line. The type of the link. A container for locators. A link to an element. A labelled link. symbolic represention of l amd m. takes avlues of s, p, px, dxy, dx2y2, f, etc. A 4x4 transformation matrix ... Allowed matrix types. Many are square matrices. By default all elements must be included. For symmetric, antisymmetric and diagonal matrices some compression is possible by not reporting the identical or forced zero elements. These have their own subtypes, usually with UT or LT appended. Use these with caution as there is chance of confusion and you cannot rely on standard software to read these. The matrix type fixes the order and semantics of the elements in the XML element but does not mandate any local syntax. Thus an application may insert newline characters after each row or use a <row> element. Rectangular with no semantic constraints and ordered rowwise (i.e. the column index runs fastest). 1 2 3 4 0 3 5 6 Square with no semantic constraints. 1 2 78 3 4 -1 -34 2 7 Square symmetric with all elements explicit. 1 2 3 2 7 1 3 1 9 Square symmetric with the diagonal and lower triangle explicit and the upper triangle omitted. Rows are of length 1, 2, 3... 1 2 7 3 1 9 is equivalent to 1 2 3 2 7 1 3 1 9 Square symmetric with the diagonal and upper triangle explicit. Rows are of length n, n-1, ... 2, 1 1 7 9 2 -1 34 is equivalent to 1 7 9 7 2 -1 9 -1 34 Square antisymmetric with all elements explicit. The diagonal is necessarily zero. 0 -2 3 2 0 1 -3 -1 0 Square symmetric with the lower triangle explicit and diagonal and upper triangle omitted. Rows are of length 1, 2,... n-1. -7 -9 1 is equivalent to 0 7 9 -7 0 -1 -9 1 0 Square symmetric with the upper triangle explicit and diagonal and lower triangle omitted. Rows are of length n-1, n-2,... 2,1. 7 9 -1 is equivalent to 0 7 9 -7 0 -1 -9 1 0 Symmetric. Elements are zero except on the diagonal. No compressed representation available (use array element). 1 0 0 0 3 0 0 0 4 Square. Elements are zero below the diagonal 1 2 3 4 0 3 5 6 0 0 4 8 0 0 0 2 Square. Elements below the diagonal are zero and omitted, and rows are of length n, n-1, ... , 2, 1. 1 2 3 4 3 5 6 4 8 2 is equivalent to 1 2 3 4 0 3 5 6 0 0 4 8 0 0 0 2 Square. Elements are zero above the diagonal 1 0 0 7 3 0 9 2 4 Square. Elements above the diagonal are zero and omitted, and rows are of length 1, 2, ...n. 1 3 7 9 2 3 is equivalent to 1 0 0 3 7 0 9 2 3 Square. Diagonal elements are 1 and off-diagonal are zero. 1 0 0 0 1 0 0 0 1 Square. When multiplied by its transpose gives the unit matrix. 0 -1 0 1 0 0 0 0 1 Square. Each row corresponds to an eigenvector of a square matrix. Elements are real. The length of the eigenvectors is undefined, i.e. they are not required to be normalised to 1. 0 -1 0 1 0 0 0 0 1 The rotation is defined by the matrix premultiplyin a column vector (x, y) . 0 -1 1 0 produces (-y, x), i.e. a rotation of -90 degrees. A third column defining the translation is added to a rotation22. 0 -1 22 1 0 33 produces (-y + 22, x + 33), i.e. a rotation of -90 degrees followed by a translation of (22, 33). User-defined matrix-type. This definition must be by reference to a namespaced dictionary entry. The maximum INCLUSIVE value of a quantity. The maximum INCLUSIVE value of a sortable quantity such as numeric, date or string. It should be ignored for dataTypes such as URL. The use of min and max attributes can be used to give a range for the quantity. The statistical basis of this range is not defined. The value of max is usually an observed quantity (or calculated from observations). To restrict a value, the maxExclusive type in a dictionary should be used. The type of the maximum is the same as the quantity to which it refers - numeric, date and string are currently allowed Type of spectral measurement. The nature of the measured data. This is not an exhaustive list and should only be used if it affects the storage or immediate processing. Data are transmittance, so "peaks" are usually troughs. Data are absorbanc. so "peaks" are normally peaks. The name of the metadata. Metadata consists of name-value pairs (value is in the "content" attribute). The names are from a semi-restricted vocabulary, mainly Dublin Core. The content is unrestricted. The order of metadata has no implied semantics at present. Users can create their own metadata names using the namespaced prefix syntax (e.g. foo:institution). Ideally these names should be defined in an STMML dictionary. 2003-03-05: Added UNION to manage non-controlled name. The extent or scope of the content of the resource. Coverage will typically include spatial location (a place name or geographic coordinates), temporal period (a period label, date, or date range) or jurisdiction (such as a named administrative entity). Recommended best practice is to select a value from a controlled vocabulary (for example, the Thesaurus of Geographic Names [TGN]) and that, where appropriate, named places or time periods be used in preference to numeric identifiers such as sets of coordinates or date ranges. An account of the content of the resource. Description may include but is not limited to: an abstract, table of contents, reference to a graphical representation of content or a free-text account of the content. An unambiguous reference to the resource within a given context. Recommended best practice is to identify the resource by means of a string or number conforming to a formal identification system. Example formal identification systems include the Uniform Resource Identifier (URI) (including the Uniform Resource Locator (URL)), the Digital Object Identifier (DOI) and the International Standard Book Number (ISBN). The physical or digital manifestation of the resource. Typically, Format may include the media-type or dimensions of the resource. Format may be used to determine the software, hardware or other equipment needed to display or operate the resource. Examples of dimensions include size and duration. Recommended best practice is to select a value from a controlled vocabulary (for example, the list of Internet Media Types [MIME] defining computer media formats). A reference to a related resource. Recommended best practice is to reference the resource by means of a string or number conforming to a formal identification system. Information about rights held in and over the resource. Typically, a Rights element will contain a rights management statement for the resource, or reference a service providing such information. Rights information often encompasses Intellectual Property Rights (IPR), Copyright, and various Property Rights. If the Rights element is absent, no assumptions can be made about the status of these and other rights with respect to the resource. The topic of the content of the resource. Typically, a Subject will be expressed as keywords, key phrases or classification codes that describe a topic of the resource. Recommended best practice is to select a value from a controlled vocabulary or formal classification scheme. A name given to the resource. Typically, a Title will be a name by which the resource is formally known. The nature or genre of the content of the resource. Type includes terms describing general categories, functions, genres, or aggregation levels for content. Recommended best practice is to select a value from a controlled vocabulary (for example, the working draft list of Dublin Core Types [DCT1]). To describe the physical or digital manifestation of the resource, use the FORMAT element. An entity responsible for making contributions to the content of the resource. Examples of a Contributor include a person, an organisation, or a service. Typically, the name of a Contributor should be used to indicate the entity. An entity primarily responsible for making the content of the resource. Examples of a Creator include a person, an organisation, or a service. Typically, the name of a Creator should be used to indicate the entity. An entity responsible for making the resource available. Examples of a Publisher include a person, an organisation, or a service. Typically, the name of a Publisher should be used to indicate the entity. A Reference to a resource from which the present resource is derived. The present resource may be derived from the Source resource in whole or in part. Recommended best practice is to reference the resource by means of a string or number conforming to a formal identification system. A language of the intellectual content of the resource. Recommended best practice for the values of the Language element is defined by RFC 1766 [RFC1766] which includes a two-letter Language Code (taken from the ISO 639 standard [ISO639]), followed optionally, by a two-letter Country Code (taken from the ISO 3166 standard [ISO3166]). For example, 'en' for English, 'fr' for French, or 'en-uk' for English used in the United Kingdom. A date associated with an event in the life cycle of the resource. Typically, Date will be associated with the creation or availability of the resource. Recommended best practice for encoding the date value is defined in a profile of ISO 8601 [W3CDTF] and follows the YYYY-MM-DD format. Entry contains information relating to chemical safety. Typically the content will be a reference to a handbook, MSDS, threshhold or other human-readable strin. Part or whole of the information was computer-generated. Typically the content will be the name of a method or a progra. 3D structure included. details include. The minimum INCLUSIVE value of a quantity. The minimum INCLUSIVE value of a sortable quantity such as numeric, date or string. It should be ignored for dataTypes such as URL. The use of min and min attributes can be used to give a range for the quantity. The statistical basis of this range is not defined. The value of min is usually an observed quantity (or calculated from observations). To restrict a value, the minExclusive type in a dictionary should be used. The type of the minimum is the same as the quantity to which it refers - numeric, date and string are currently allowed An array of moleculeRefs. Typical applications are the annotation of peaks in chromatograms and mapping reactions. The context of the id resolution is the childOrSibling concept. A reference to an existing molecule. An array of namespaceURIs with required protocol. used to identify dictionaries, units, conventions or other metadata. 2005-12-17: PMR. Added for use with unitList An XML QName with required prefix. A string referencing a dictionary, units, convention or other metadata. The purpose is to allow authors to extend the vocabulary through their own namespaces without altering the schema. The prefix is mandatory. This convention is only used within STMML and related languages; it is NOT a generic URI. The namespace prefix must start with an alpha character and can only contain alphanumeric and '_'. The suffix can have characters from the XML ID specification (alphanumeric, '_', '.' and '-' A namespaceURI with required protocol. used to identify a dictionary, units, convention or other metadata. Not yet confirmant with XSD 2005-12-10: PMR. Added for use with dictionary The namespace prefix must start with a protocol. The number of non-hydrogen atoms attached to an atom. Obsolete in core CML. Only useful in CML queries. A non-signed angle. Re-used by _angle_. Note that we also provide positiveAngleType (e.g. for cell angles) and torsionAngleType for _torsion_. A nonNegative number. Note that we also provide positiveNumber to avoid inclusive zero. The maximum number is 1.0E+999 since 'unbounded' is more difficult to implement. This is greater than Eddington's estimate of the number of particles in the universe so it should work for most people. Array of atomic occupancies. Primarily for crystallography. Values outside 0-1 are not allowed. A floating point number between 0 and 1 inclusive Originally for crystallographic occupancy but re-usable for fractinal yield, etc. An array of bond orders. See order. Bond order. This is purely conventional and used for bond/electron counting. There is no default value. The emptyString attribute can be used to indicate a bond of unknown or unspecified type. The interpretation of this is outside the scope of CML-based algorithms. It may be accompanied by a convention attribute on the bond which links to a dictionary. Example: <bond convention="ccdc:9" atomRefs2="a1 a2"/> could represent a delocalised bond in the CCDC convention. Hydrogen bond. Carries no semantics but will normally be between a hydrogen atom and an element with lone pairs. Partial bond. Can be used for a partial bond in a transition state, intermolecular interaction, etc. There is no numeric value associated and the bond order could be anywhere between 0 and single. Single bond. synonymous with "1. Single bond. Intermediate between 1 and . Could be used for a transition state or a delocalised system. Double bond. Double bond. Intermediate between 2 and . Could be used for a transition state or a delocalised system. Triple bond. Triple bond. Aromatic bond. Multiplicity of a peak. Uses a semi-controlled vocabulary. A single maximum within the peak rang. Two maxima (not necessarily equal) within the peak rang. Three maxima (not necessarily equal) within the peak rang. Four maxima (not necessarily equal) within the peak rang. Five maxima (not necessarily equal) within the peak rang. Six maxima (not necessarily equal) within the peak rang. Several maxima (not necessarily equal) within the peak rang. User contributed vocabulary of type foo:ba. Shape of a peak. Semi-controlled vocabulary such as broad or sharp. A sharp peak. A broad peak. A brodening of a peak suggesting the presence of a smaller incompletely resolved component. User contributed vocabulary of type foo:bar. type of a peakStructure. Semi-controlled vocabulary such as coupling or splitting. A coupling such as in NMR. A splitting such as in NMR. User contributed vocabulary. The width of a peak. At present we allow a peakWidth to be positive or exactly zero (to signal that the peak should not be integrated). An unbounded plane in 3-space. Defined by 4 real numbers, conventionally a vector3 normal to the plane and a signed scalar representing the distance to the origin. The vector must not be of zero length (and need not be normalized. The first three numbers are the vector, followed by the distance A point in 3-space. The 3 components can have any signed value. A non-signed angle such as a cell angle. Re-used by _crystal_. Note that we also provide nonNegativeAngleType (e.g. for bond angles). A positive number. Note that we also provide nonNegativeNumber with inclusive zero. The maximum number is (quite large) since 'unbounded' is more difficult to implement. The format of the reaction. This is provided for machine-understanding of the format of the reaction steps and components. Semantics are semi-controlled. The commonest representation with reactantList and productList. A list of molecules representing snap shots on a reaction pathway. The role of the reaction within a reactionList. Semantics are semi-controlled. On reactionList signifies that the children are the complete description of the reaction. The overall reaction in a multi-step reaction. Normally this would be the first reaction in a reactionList and the individual steps are held in a following sibling reactionList. The rate-determining step in a multi-step reaction. This implies also that the reaction has a role of step. A step in a multi-step reaction. This reaction will normally be a child of reactionList. a reactionList containing steps Examples could be "myDict:step1", "foo:chainPropagation", etc. The sequence of steps in a reactionStepList. By default the reactions in a reactionStepList are assumed to take place in sequence (e.g. one or more products of reaction n are used in reaction n+1 or later. However there are cases where it is known that reactions take place in parallel (e.g. if there is no overlap of molecular identities). Alternatively there are points at which there are two or more competing reactions which may depend on conditions or concentrations. A small semi-controlled vocabulary is suggested. The semantic of these are not fully explored, but we suggest that consecutive and simultaneous should be the first to be supported The order of the steps is unknown. The reaction proceeds through the steps in the order given. The reaction may proceed through either (or possibly both) of the contained reactions or reactionScheme, but it may not be known which. The two or more independent reaction/List children proceed independently. The semantic type of the reaction. This is provided for machine-understanding of the topology or logic of the reaction steps and components (i.e. not for a general classification for which label is more appropriate.) Semantics are semi-controlled. Some terms are appropriate to multistep reactions, and can be used with or without explicit steps. A reaction in which one or more reactive reaction intermediates (frequently radicals) are continuously regenerated, usually through a repetitive cycle of elementary steps (the 'propagation step') (IUPAC GoldBook). A reaction or process generating free radicals (or some other reactive reaction intermediates) which then induce a chain reaction. For example, in the chlorination of alkanes by a radical mechanism the initiation step is the dissociation of molecular chlorine. IUPAC Compendium of Chemical Terminology 2nd Edition (1997). The steps in a chain reaction in which reactive intermediates are destroyed or rendered inactive, thus ending the chain. IUPAC Compendium of Chemical Terminology 2nd Edition (1997) . A reaction which can proceed in the forward direction as readily as in the reverse direction (IUPAC GoldBook). A reference to an existing object. A reference to an existing element in the document. The target of the ref attribute must exist. The test for validity will normally occur in the element's _appinfo_. Any DOM Node created from this element will normally be a reference to another Node, so that if the target node is modified a the dereferenced content is modified. At present there are no deep copy semantics hardcoded into the schema. The semantic of reference are normally identical to an idType (e.g. "a123b"). Howevere there are some cases where compound references are required, such as "a123b:pq456". It is likely that this will be superseded at by RDF or Xpointer, but as long as we have non-uniqueIds this is a problem Type of relatedEntry. Type represents a the type of relationship in a relatedEntry element. The sequence of steps in a reactionList. By default the reactions in a reactionStepList are assumed to take place in sequence (e.g. one or more products of reaction n are used in reaction n+1 or later. However there are cases where it is known that reactions take place in parallel (e.g. if there is no overlap of molecular identities). Alternatively there are points at which there are two or more competing reactions which may depend on conditions or concentrations. A small semi-controlled vocabulary is suggested. The order of the steps is unknow. The reaction proceeds through the steps in the order give. The reaction may proceed through either of the contained reactions or reactionScheme. The two or more independent reaction/List children proceed independently. This can be extended to synthetic chemistry where two parts of the synthesis are conducted in parallel. The size of an array. The size of an array. Redundant, but serves as a check for processing software (useful if delimiters are used). Signifies real or reciprocal space. Likely to be used on types such as lattice, plane, point. A synonym for reciprocal. A synonym for reciprocal. User-defined space-type. No obvious possibilities, but who know. The type of the spectrum. An infrared spectrum. The measurement should denote transmittance or absorbanc. A "simple" mass spectrum. This excludes experiments such as GC/MS, MS/MS, etc. though these could be constructed out of individual spectra with some care. The spectrum may be continuous ( data or a peakList). An NMR spectrum. This can include any experiment which creates a "1D" or "2D" data array. The symmetry of the spectrum can be specified but the details of the NMR experiment (COSY, NOESY, etc.) are not part of CMLSpect. They can be described though the normal dictRef mechanism. A spectrum somewhere in the UV VIS region of the spectrum. The measurement should denote transmittance or absorbance. A sphere in 3-space. Defined by 4 real numbers, conventionally a point3 at the centre of the sphere and a nonNegative scalar for the radius. State of a substance or property. The state(s) of matter appropriate to a substance or property. It follows a partially controlled vocabulary. It can be extended through namespace codes to dictionaries. An aqueous solutio. Gas or vapor. The default state for computation on isolated molecule. A glassy stat. Normally pure liquid (use solution where appropriate. The nematic phas. The smectic phas. A soli. A solid solutio. A (liquid) solutio. Bond stereochemistry as a string. This is purely conventional. There is no default value. The emptyString attribute can be used to indicate a bond of unknown or unspecified type. The interpretation of this is outside the scope of CML-based algorithms. It may be accompanied by a convention attribute which links to a dictionary. A cis bond. A trans bond. A wedge bond. A hatch bond. empty or missing. An array of strings, separated by whitespace. An array of strings, separated by whitespace. If the strings have embedded whitespace or may be empty (zero-length), a non-whitespace single-character delimiter must be used. At present no machine validation Type of the substanceList. Extension is allowed through the "other" value. The type of a torsion angle. Type of unitList. Required to differentiate between the two types of unitList (units and unitTypes) child elements are unit child elements are unitType Scientific units. These will be linked to dictionaries of units with conversion information, using namespaced references (e.g. si:m). Distinguish carefully from _unitType_ which is an element describing a type of a unit in a _unitList_. A vector in 3-space. No constraints on magnitude (i.e. could be zero. The name of an XMLElement. (Distinguish from a chemical element as in elementTypeType). Currently used for assigning XMLElement types to references (e.g. to='a1' toType='atom'). Semantics are not controlled and in principle elements outside the CML tagSet could be used. Implementers cannot assume that namespace prefixes can be resolved and default usage is probably the local name. Abbreviation. Abbreviation for units, terms, etc. Describes whether child elements are sequential or parallel. There is no default. The type of an alternative. This adds semantics to an _alternative_ and might be used by an RDF or related engine. Restricts units to radians or degrees. An array of atom IDs. Normally an attribute of an array-based element. A reference to a map providing mappings between atoms The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking atoms. The topology of the linking is defined by the application - it could be overlay of molecular fragments, reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of atoms are of equal size and have 1:1 mapping between each id. This is another way of saying that the atoms mapped by a given ID are "the same atom". A reference to an atom. Used by bond, electron, etc. The first atoms in each bond. Currently only used in bondArray in CML2 array mode. The second atoms in each bond. Only used in bondArray in CML2 array mode. An array of references to atoms. Typical use would be to atoms defining a plane. A reference to a list of atoms. Used by bonds, electrons, atomSets, etc. References to two different atoms. Available for any reference to atoms but normally will be the normal reference attribute on the bond element. The order of atoms is preserved and may matter for some conventions (e.g. wedge/hatch or donor bonds. A list of three references to atoms. Typically used for defining angles, but could also be used to define a three-centre bond. 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. An atomSet describing the region. Any point falling within atomOffset of any atom in the set lies within the region. This means the region could consist of disjoint fragments. The IDs for an array of bond. Required in CML2 array mode. A reference to a map providing mappings between bonds The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking bonds. The topology of the linking is defined by the application - it could be overlay of molecular fragments, reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of bonds are of equal size and have 1:1 mapping between each id. This is another way of saying that the bonds mapped by a given ID are "the same bond". A reference to a bond. used by electron, etc. A reference to a list of bonds. Used by electrons, bondSets, etc. A parallelipiped box. By default the box uses isometric Cartesians axes but can also be linked to lattice Vector. Any point falling within the box or on a boundary is within the regio. builtin children. CML1-only - now deprecated. The chirality of a system or molecule. This is being actively investigated by a IUPAC committee (2002) so the convention is likely to change. No formal default. Number of columns. A concise formula. The string represents an (unstructured) formula i.e. no submolecules. Recommended to use the format "H 2 O 1", etc. The constant to add to the raw data. add *after* applying any multiplier. 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. Constraint on a parameter. Semantics not yet finalised. We anticipate "fixed", "none" and symbolic relationships to other parameters. content of metadata. 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. The value of an element with a _convention_. When convention is used this attribute must be present and element content must be empty. 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. Array of object counts. No fixed semantics or default, normally integral. It is presumed that the element can be multiplied by the count value. The data type of the object. Normally applied to scalar/array objects but may extend to more complex one. default value in an enumeration. A non-whitespace string (value is irrelevant) indicates that the content of this enumeration is the default value (usually of a scalar). It is an error to have more than one default. If the scalar in an instance document has no value (i.e. is empty or contains only whitespace) its value is given by the default. If the scalar in the instance is empty and no enumerations have a default attribute, an application may throw an error. A delimiter character for arrays and matrices. By default array components ('elements' in the non-XML sense) are whitespace-separated. This fails for components with embedded whitespace or missing completely: Example: In the protein database ' CA' and 'CA' are different atom types, and and array could be: <array delimiter="/" dictRef="pdb:atomTypes">/ N/ CA/CA/ N/</array> Note that the array starts and ends with the delimiter, which must be chosen to avoid accidental use. There is currently no syntax for escaping delimiters. The namespacePrefix for a data item. The dictionaryPrefix is associated with elements such as dictionaries and units and allows them to be referenced namespaces. The dictionaryPrefix is normally unbound but it may be necessary to hardcode them occasionally. Thus if a value is fixed (e.g. "xsd:double") the prefix must be identified and fixed. A reference to a dictionary entry. Elements in data instances such as _scalar_ may have a dictRef attribute to point to an entry in a dictionary. To avoid excessive use of (mutable) filenames and URIs we recommend a namespace prefix, mapped to a namespace URI in the normal manner. In this case, of course, the namespace URI must point to a real XML document containing _entry_ elements and validated against STMML Schema. Where there is concern about the dictionary becoming separated from the document the dictionary entries can be physically included as part of the data instance and the normal XPointer addressing mechanism can be used. This attribute can also be used on _dictionary_ elements to define the namespace prefix Dimensionality of a coordinate system. Note that this means that coordinates of higher dimensionality are ignored or an error is flagged. Thus z3 and dimensionality='2' are incompatible. At present higher dimensionalities than 3 (cf. Wondratschek) are not supported. The labelling of the axes id not controlled. ?? should we have an explicit attribute for labelling convention?. The basis of the dimension. Normally taken from the seven SI types but possibly expandable. The duration of the action. Semantics undefined. A reference to a map providing mappings between electrons The map will normally be contained within the same document and referenced by its ID. It will contain a list of links with from and to attributes linking electrons. The topology of the linking is defined by the application - it could be reactant/product mapping, etc. The reserved phrase "USE_IDS" assume that the sets of electrons are of equal size and have 1:1 mapping between each id. This is another way of saying that the electrons mapped by a given ID are "the same electron". The identity of a chemical element. Normally mandatory on _atom_, _isotope_, etc. The identity of a chemical element. Normally mandatory on _atom_, _isotope_, etc. The end time. The start time in any allowable XSD representation of date, time or dateTime. This will normally be a clock time or date. 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. Basis of the error estimate. Value of the error. Reports the author's estimate of the error in a scalar value. Only meaningful for dataTypes mapping to real number. 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. Information identifying the name of a file or other resource. This allows an element (such as cml) to carry limited information about provenance such as the name of the document used to provide the content. It is not a complete solution but can help to protect a document becoming separated from its external metadata. It is restricted to the basic XML character set (printable ANSI) and whitespace (which should anyway be discouraged) is normalized to single space (attribute values cannot carry newlines). Quotation marks and other horrors (as used in some OS) should be avoided. A reference to a functional form. Currently used for potential. 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. 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. Format of a spectrum. The data structure of the spectrum. (Not the format of the data). This describes how the data structure is to be interpreted. Simple chemical formula. This attribute should only be used for simple formulae (i.e. without brackets or other nesting for which a _formula_ child element should be used. The attribute might be used as a check on the child elements or for ease of representation. Essentially the same as _concise_ attribute on _formula. Number of digits after the point. This is used in dictionaries to define precision. However it might be replaced by xsd:facet. The base of one or more links. On link elements the value is the single id of an element within the document or context specified in map@fromRef attributes. It must identify the element uniquely. The reserved value 'null' implies that no mapping has been provided for the object(s) in the 'to' attribute. This implies no semantics but may be used by software to keep count of which elements have been mapped. For multiple targets use 'fromSet'. 2005-06-18: updated docs The context for the 'from' links in a map. A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. 2005-06-18: created A set of ids representing the base of a link. For a partial mapping where a number of 'from' elements are known to link to a number of 'to' elements it can be useful to aggregate these into a single attribute value. The primary use is to assert that n links exist between a set of n 'from' elements and n 'to' elements but that the precise links are unknown. The semantics of the reference are the same as for 'from' and all the elements must be of the same type (which can be specified with 'fromType' either on the link or the containing map). No order information is implied. In general there will be the same number of idRefs in the 'toSet' and all implicit links will share the same attributes (e.g. 'role'). In many cases the sets will be later split into discrete links thorugh further calculation or experiment (e.g. peak assignment). Sets should never be used as a lazy or concise alternative where the all the links are explicitly known. 2005-06-18: created The type of the base of a link. The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. 2005-06-18: created Domain of an FT spectrum. Indicates whether a spectrum is raw FID or has been transforme. address of a resource. Links to another element in the same or other file. For dictionary/@dictRef requires the prefix and the physical URI address to be contained within the same file. We can anticipate that better mechanisms will arise - perhaps through XMLCatalogs. At least it works at present. 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. 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. A unique ID for an element. Id is used for machine identification of elements and in general should not have application semantics. It is similar to the XML ID type as containing only alphanumerics, '_', ',' and '-' and and must start with an alphabetic character. Ids are case sensitive. Ids should be unique within local scope, thus all atoms within a molecule should have unique ids, but separated molecules within a document (such as a published article) might have identical ids. Software should be able to search local scope (e.g. all atoms within a molecule). However this is under constant review. Inheritance mechanism. A reference to an existing element can be used to supplement values such as coordinates. The inheritance attribute determines whether the values are supplemented, overwritten or deleted. In the example: <molecule id="m1" view="initial"> <atomArray> <atom id="a1" x3="0.1"/> </atomArray> </molecule> <!-- this adds more information --> <molecule ref="m1" view="initial" inherit="supplement"> <atomArray> <atom id="a1" hydrogenCount="1"/> </atomArray> </molecule> <!-- this will overwrite the previous values --> <molecule ref="m1" inherit="overwrite" view="final" id="m2"> <atomArray> <atom id="a1" x3="0.1"/> </atomArray> </molecule> <!-- this will delete the previous values --> <molecule ref="m1" inherit="delete" view="restart"> <atomArray> <atom id="a1" hydrogenCount=""/> </atomArray> </molecule> The first molecule/@ref adds complementary information, the second changes the values. Software is allowed to generate two independent copies of the molecule and reference them by different IDs (m1 and m2). This mechanism is necessary to manage the implied inheritance of partial information during minimisations and dynamics. It requires careful software implementation. An inline representation of the object. This can represent a wide range of information from formal serialization as ASCII through to domain-specific textual representations. It will often be used in conjunction with the "convention" attribute. For example it could be used to represent IUPAC formula, SMILES strings, TeX equations, etc. Characters should conforma to the XML character set, and XML markup (lt and amp) should be escaped. IT SHOULD NEVER BE USED FOR INLINE XML Area under a peak. Unfortunately units are usually arbitrary and not related to the x- and y- axis units, and in this case _peakUnits_ should be use. A symmetry species. No fixed semantics, though we may provide a controlled-extensible list in the future. The isotope for an element. A real number describing the isotope. Probably obsolet. 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.. 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). Reference to a fuller description of the isotope. The description may be found in an external collection (e.g. IUPAC) or within the current document. indicates whether a unit is an SI or derived SI unit. required on SI unit elements with value 'true'. Optional on other units with attribute 'false'. A unitList should contain either SI units or non-SI units but not both. The k vector. The k-vector with 3 components. The secondary quantum number. takes values 0, 1, etc. A label. The semantics of label are not defined in the schema but are normally commonly used standard or semi-standard text strings. This attribute has the the same semantics as the more common _label_ element. The primitivity of a lattice. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency between spacegroups, symmetry operators, etc. Length of a scalar. Probably will be replaced with xsd:schema tool. The type of the link. symbolic represention of l amd m. takes avlues of s, p, px, dxy, dx2y2, f, etc. The azimuthal quantum number. takes values -1, 0, 1, etc. An attribute providing a mandatory unique ID for an element. This is a horrible hack. It should be possible to add 'required' to the attributeGroup where used... (Maybe it is and I am still fighting Schema Wars. Type of matrix. Mainly square, but extensible through the _xsd:union_ mechanis. Maximum value allowed for an element or attribute. maximum exclusive value. by analogy with xsd:schema. minimum inclusive value. by analogy with xsd:schem. maximum length of a scalar. by analogy with xsd:schem. Maximum values for numeric _matrix_ or _array. A whitespace-separated list of the same length as the array in the parent element. Type of spectral measurement. The nature of the measured data. This is not an exhaustive list and should only be used if it affects the storage or immediate processing. The metadata type. This is likely to be the Dublin Core name or something similar. The use of "type" is an infelicitous misnomer and we shall try to remove it. The minimum value allowed for an element or attribute. minimum exclusive value. by analogy with xsd:schema. minimum inclusive value. by analogy with xsd:schema. minimum length of a scalar. by analogy with xsd:schema. Minimum values for numeric _matrix_ or _array. A whitespace-separated lists of the same length as the array in the parent element. A reference to a molecule. Used by spectrum, etc. A reference to one or more molecules. Uses the id attribute as the target identification. The order of molecules is preserved. It is not necessarily an error to have repeated references to the same molecule 2005-11-22: PMR. added this attribute. The scale by which to multiply the raw data. The scale is applied *before* adding the constant. 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. The principal quantum number. Takes values 1, 2, 3, etc. 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. The namespace for a data item. The namespace is associated with elements such as dictionaries and units and allows them to be referenced through free namespace prefixes. A number determined by context Used for isotope number in isotope, and rotational symmetry number in symmetry for calculation of entropy, etc. 2003-03-30: added number attribut. The class of an object. The type of this information. This is not controlled, but examples might include: label summary note usage qualifier It might be used to control display or XSL filtering. The attribute is named 'objectClass' to avoid clashes with other class attributes and inappropriate conversion to foo.getClass(). 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. Array of occupancies. Normally only found in crystallography. Defaults to 1.0. The occupancy is required to calculate the molecular formula from the atoms. The order of the bond. There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. The order of the bond. There is NO default. This order is for bookkeeping only and is not related to length, QM calculations or other experimental or theoretical calculations. A dictRef like reference to the id of the parent SI unit. This parent should occur in this or another dictionary and be accessible through the dictRef mechanism. This attribute is forbidden for SI Units themselves. The mechanism holds for base SI units (7) and all compound (derived) units made by combinations of base Units. Pattern constraint. Based on xsd:schema. Height of a peak. For 1-dimensional data (e.g. y vs x) hould use the same units as the appropriate axis (e.g. y). Multiplicity of a peak. Uses a semi-controlled vocabulary. Shape of a peak. Semi-controlled vocabulary such as broad or sharp. Type of this structure. Semi-controlled vocabulary such as coupling or splitting. Units for a peak or peak integral. For 2-dimensional spectra the units represent the observation. For an integral they are usually arbitrary and not related to the x- and y- axis units. Thus NMR spectra may use hydrogen count as the units for the peak area. Is the axis periodic. Any or all of the axes may be periodic or aperiodic. An example could be a surface where 2 periodic axes (not necessarily orthogonal) are used to describe the coordinates in the surface, perhaps representing lattice vectors of a 3D crystal or 2D layer. The third vector is orthogonal and represents coordinates normal to the surface. In this case only the direction, not the magnitude of the vector is important. Periodicity of the system. This represents the number of dimensions (or coordinate axes) along periodic behaviour occurs and can be supported by symmetry operators or other transformations. Periodicity must never exceed dimensionality. A point group. No fixed semantics, though Schoenflies is recommended over Hermann-Mauguin. We may provide a controlled-extensible list in the future. 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. The power to which a dimension should be raised. Normally an integer. Must be included, even if unity. Is the dimension preserved during algebra. Experimental. The idea is to support concepts like volume/volume where alebraically these cancel out. preserve="yes" is intending to support preservation during derivation of new unitTypes. A ratio in the range 0 to 1. Currently used for ratios between brached reactions but re-usable for other concepts. Format of the reaction component. Indicates how the components of reactionScheme, reactionStepList, etc. should be processed. No controlled vocabulary. One example is format="cmlSnap" asserts that the processor can assume that the reactants and products can be rendered using the CMLSnap design. Note that the reaction can be interpreted without reference to the format, which is primarily a processing instruction. Role of the reaction. The sequence of steps in a reactionStepList. By default the reactions in a reactionStepList are assumed to take place in sequence (e.g. one or more products of reaction n are used in reaction n+1 or later. However there are cases where it is known that reactions take place in parallel (e.g. if there is no overlap of molecular identities). Alternatively there are points at which there are two or more competing reactions which may depend on conditions or concentrations. A small semi-controlled vocabulary is suggested. The semantic of these are not fully explored, but we suggest that consecutive and simultaneous should be the first to be supported Type of the reaction. Recommended unit. a facet on a numeric dictionary entry. A reference to an element of given type. ref modifies an element into a reference to an existing element of that type within the document. This is similar to a pointer and it can be thought of a strongly typed hyperlink. It may also be used for "subclassing" or "overriding" elements.
When referring to an element most of the "data" such as attribute values and element content will be on the full instantiated element. Therefore ref (and possibly id) will normally be the only attributes on the pointing element. However there may be some attributes (title, count, etc.) which have useful semantics, but these are element-specific
A list of regions creating a union. The union of a series of regions produces a larger region (possibly disjoint). Any point belonging to any of the referenced regions is a member of this region. Type of relatedEntry. Type represents a the type of relationship in a relatedEntry element. Role of the object. How the object functions or its position in the architecture. No controlled vocabulary. Number of rows. The sequence of steps in a reactionList. By default the reactions in a reactionStepList are assumed to take place in sequence (e.g. one or more products of reaction n are used in reaction n+1 or later. However there are cases where it is known that reactions take place in parallel (e.g. if there is no overlap of molecular identities). Alternatively there are points at which there are two or more competing reactions which may depend on conditions or concentrations. A small semi-controlled vocabulary is suggested. Serial number or other id. Currently only on module. Modules with the same _role_ attribute can be distinguished by _serial_. This is often an integer but other schemes may be used. The namespace for SI Units dictionary. Main use is on unitList to identify the dictionary holding the SI Units. Array of namespaces locating SI Units dictionaries. Main use is on unitList to identify the dictionaries holding the SI Units. The size of an array or matrix. A space group. No fixed semantics, though Hermann-Mauguin or Hall is recommended over Schoenflies. We may provide a controlled-extensible list in the future. 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. The spaceType of the lattice. Usually real or reciprocal. No default. The semantics of this are software-dependent (i.e. this Schema does not check for consistency for unitTypes, etc. The type of the spectrum. A sphere. Currently describes a region. Any point falling within the sphere or on its surface is within the region. The spin of a system. Supports fractional values. Currently the spin of a nucleus. The normal fraction representing the spin of the isotope. 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. The start time. The start time in any allowable XSD representation of date, time or dateTime. This will normally be a clock time or date. 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. The physical state of the substance. No fixed semantics or default. Type of the substanceList. Extension is allowed through the "other" value. A symbol. Currently only used on _atomicBasisFunction_. Is the molecule oriented to the symmetry No formal default, but a molecule is assumed to be oriented according to any _symmetry_ children. This is required for crystallographic data, but some systems for isolated molecules allow specification of arbitrary Cartesian or internal coordinates, which must be fitted or refined to a prescribed symmetry. In this case the attribute value is false. Indicates whether the structure is a tautomer. Currently used with IChI _identifier_ element. Semantics, vocabulary and usage are application-dependent. A term in a dictionary. The term should be a noun or nounal phrase, with a separate definition and further description. A title on an element. No controlled value. The target of one or more links. On link elements the value is the single id of an element within the document or context specified in map@toContext attributes. It must identify the element uniquely. The reserved value 'null' implies that no mapping has been provided for the object(s) in the 'from' attribute. This implies no semantics but may be used by software to keep count of which elements have been mapped. For multiple targets use 'toSet'. 2005-06-18: updated docs The context for the 'from' links in a map. A reference to the unique 'id' attribute of an element defining the context for links in a map. This may be required when id attributes may not be unique within a document. The id should either reference an element uniquely or should be taken as the first ancestor (of the map) with such an id. This is fairly horrid but may be required when documents are assembled without establishing unique ids (e.g. concatenation of files). As an example a map referencing linked atoms in two molecules might use the containing 'reaction' element as its uniquifying context. 2005-06-18: created A set of ids representing the base of a link. For a partial mapping where a number of 'to' elements are known to link to a number of 'from' elements it can be useful to aggregate these into a single attribute value. The primary use is to assert that n links exist between a set of n 'to' elements and n 'from' elements but that the precise links are unknown. The semantics of the reference are the same as for 'to' and all the elements must be of the same type (which can be specified with 'toType' either on the link or the containing map). No order information is implied. In general there will be the same number of idRefs in the 'fromSet' and all implicit links will share the same attributes (e.g. 'role'). In many cases the sets will be later split into discrete links thorugh further calculation or experiment (e.g. peak assignment). Sets should never be used as a lazy or concise alternative where the all the links are explicitly known. 2005-06-18: created total digits in a scalar. based on xsd:schema. The type of the base of a link. The local tagname of the referenced element (e.g. 'molecule' or 'peakGroup'). This acts as a partial check on the integrity of the link. Software can assume that the referenced element is of a given tytpe and can create an object supporting that type. This attribute can be attached to the 'map' attribute and requires all contained links to be of this type. This can be overridden by a 'toType' attribute on indivdual links, but it may also be useful to split the map into maps od different link types. 2005-06-18: created Type of the object. A qualifier which may affect the semantics of the object. A reference to the type of a unit. Needed to differentiate the rather unhappy polymorphism of unitList/unit and unitList/unitType. 2005-12-17 PMR: Added Scientific units on an element. These must be taken from a dictionary of units. There should be some mechanism for validating the type of the units against the possible values of the element. unitsRef attribute on CML1 elements. CML1-only - now deprecated. A reference to the type of a unit. Used in defining the unit and doing symbolic algebra on the dimensionality. Value of a scalar object. The value must be consistent with the dataType of the object. The version of the identifier. The IChI or other identifier may be dependent on the date of release and this attribute is highly recommended. Weight of the element. Currently the weight of the kPoint, derived from the symmetry such as the inverse of the multiplicity in real space. Thus a point at 0,0,0 in monoclinic space might be 0.25. The lowest value possible is probably 1/48.0 (in m3m). 2003-09-15 (added at suggestion of Jon Wakelin). Whitespace. Attached to entry. This may be obsolete. 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. 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. 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. An array of x3 coordinate. Normally used in CML2 array mode. Fractional x coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. Array of fractional x coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. Maximum yValue. Annotates x-axis data with a maximum value. This need not be algorithmically deducible from the data and is typically used for the extent of a _peak_ or _peakGroup_. It uses xUnits or the same units as the data. There may or may not be a _xMin_ attribute but if so xMax should be greater than or equals to it. Minimum yValue. Annotates x-axis data with a minimum value. This need not be algorithmically deducible from the data and is typically used for the extent of a _peak_ or _peakGroup_. It uses xUnits or the same units as the data. There may or may not be a _xMax_ attribute but if so xMin should be less than or equals to it. Units for x axis. All x-axis data must have unambiguous units. Ideally the data and _xMin_ or _xValue_ should share the same units but different xUnits can be used as long as it is clear.. Value along an x axis. Annotates x-axis data with a value. It is typically used for the location of a _peak_ or _peakGroup_. It uses xUnits or the same units as the data. An unsigned interval along an x axis. It is typically used for the width of a _peak_ or _peakGroup_ but could be used for any range. It uses xUnits or the same units as the data. 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. 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. 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. An array of y3 coordinate. Normally used in CML2 array mode. Fractional y coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. Array of fractional y coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. Yield of a reaction or reactionStep. Yields can be given on either element. They should lie in the range 0 to 1 inclusive (i.e. percentages will need to be converted). Software may use yield to calculate amounts of substances created during a reaction or series of reactions. Maximum yValue. Annotates y-axis data with a maximum value. This need not be algorithmically deducible from the data and is typically used for the extent of a _peak_ or _peakGroup_. It uses yUnits or the same units as the data. There may or may not be a _yMin_ attribute but if so yMax should be greater than or equals to it. Minimum yValue. Annotates y-axis data with a minimum value. This need not be algorithmically deducible from the data and is typically used for the extent of a _peak_ or _peakGroup_. It uses yUnits or the same units as the data. There may or may not be a _yMax_ attribute but if so yMin should be less than or equal to it. Units for y axis. All y-axis data must have unambiguous units. Ideally the data and _yMin_ or _yValue_ should share the same units but different yUnits can be used as long as it is clear. Value along a y axis. Annotates y-axis data with a value. It is typically used for the location of a _peak_ or _peakGroup_. It uses yUnits or the same units as the data. An unsigned interval along a y axis. It is typically used for the width of a _peak_ or _peakGroup_ but could be used for any range. It uses yUnits or the same units as the data. The number of molecules per cell. Molecules are defined as the _molecule_ which directly contains the _crystal_ element. 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. An array of z3 coordinate. Normally used in CML2 array mode. Fractional y coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. Array of fractional z coordinate. normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. The abundance of an isotope. The abundance of an isotope in an isotopeList. Values are expressed in percentages. An action which might occur in scientific data or narrative. An action which might occur in scientific data or narrative. The definition is deliberately vague, intending to collect examples of possible usage. Thus an action could be addition of materials, measurement, application of heat or radiation. The content model is unrestricted. _action_ iself is normally a child of _actionList_. The start, end and duration attributes should be interpreted as XSD dateTimes and XSD durations. This allows precise recording of time of day, etc, or duration after start of actionList. A convention="xsd" attribute should be used to enforce XSD. a numerical value, with a units attribute linked to a dictionary. a human-readable string (unlikely to be machine processable) startCondition and endCondition values are not constrained, which allows XSL-like test attribute values. The semantics of the conditions are yet to be defined and at present are simply human readable. The order of the action elements in the document may, but will not always, define the order that they actually occur in. A delay can be shown by an action with no content. Repeated actions or actionLists are indicated through the count attribute. Number of times the action should be repeated. A container for a group of actions. ActionList contains a series ofactions or nestedactionLists. An alternative name for an entry. At present a child of _entry_ which represents an alternative string that refers to the concept. There is a partial controlled vocabulary in _alternativeType_ with values such as : synonym acronym abbreviation The amount of a substance. The units attribute is mandatory and can be customised to support mass, volumes, moles, percentages, or rations (e.g. ppm). An angle between three atoms. It can be used for: Recording experimentally determined bond angles (e.g. in a crystallographic paper). Providing the angle component for internal coordinates (e.g. z-matrix). A documentation container similar to annotation in XML Schema. A documentation container similar to annotation in XML Schema. At present this is experimental and designed to be used for dictionaries, units, etc. One approach is to convert these into XML Schemas when the documentation and appinfo children will emerge in their correct position in the derived schema. It is possible that this may develop as a useful tool for annotating components of complex objects such as molecules. A container similar to appinfo in XML Schema. A container for machine processable documentation for an entry. This is likely to be platform and/or language specific. It is possible that XSLT, RDF or XBL will emerge as generic languages. See _annotation_ and _documentation_ for further information. An example in XSLT where an element _foo_ calls a bespoke template. Allows a processor to inspect the role of the appinfo and process accordingly. An argument for a function. Arguments can be typed and have explicit or free values. A homogenous 1 dimensional array of similar object. These can be encoded as strings (i.e. XSD-like datatypes) and are concatenated as string content. The size of the array should always be >= 1. The default delimiter is whitespace. The _normalize-space()_ function of XSLT could be used to normalize all whitespace to single spaces and this should not affect the value of the array elements. To extract the elements __java.lang.StringTokenizer__ could be used. If the elements themselves contain whitespace then a different delimiter must be used and is identified through the delimiter attribute. This method is mandatory if it is required to represent empty strings. If a delimiter is used it MUST start and end the array - leading and trailing whitespace is ignored. Thus size+1 occurrences of the delimiter character are required. If non-normalized whitespace is to be encoded (e.g. newlines, tabs, etc) you are recommended to translate it character-wise to XML character entities. Note that normal Schema validation tools cannot validate the elements of array (they are defined as string) However if the string is split, a temporary schema can be constructed from the type and used for validation. Also the type can be contained in a dictionary and software could decide to retrieve this and use it for validation. When the elements of the array are not simple scalars (e.g. scalars with a value and an error, the scalars should be used as the elements. Although this is verbose, it is simple to understand. If there is a demand for more compact representations, it will be possible to define the syntax in a later version. the size attribute is not mandatory but provides a useful validity check): Alternative to units Must be used in conjunction with unitType 2005-10-26: added Alternative to units Must be used in conjunction with unitType 2005-10-26: added Alternative to units Must be used in conjunction with multiplierToSI and/or constantToSI 2005-10-26: added An atom. Usually within an _atomArray_. The main content model of the atom. name can be used for atom labels, etc. More than one name can be used if required. scalar contains any scalar properties of the atom (examples are chemical shift, B-value, etc.) linked through dictRef (CmlDictRefType). array contains any properties of the atom describable by a homogeneous array linked through dictRef (CmlDictRefType). matrix contains any properties of the atom describable by a homogeneous matrix linked through dictRef (CmlDictRefType). An example is the polarizability tensor atomParity (CmlAtomParityElement) the required way of defining atom-based chirality electron a away of associating electron(s) with the atom Most useful in _formula_ but possibly useful in _atomArray_ where coordinates and connectivity is not defined. No formal default, but assumed to be 1. This can be used to describe the purpose of atoms whose _elementType_s are __dummy__ or __locant__. Vocabulary not controlled. 2005-11-27: Added PMR 2005-11-27: Added PMR A container for a list of atoms. A child of _molecule_ and contains _atom_ information. There are two strategies: Create individual _atom_ elements under _atomArray_ (in any order). This gives the greatest flexibility but is the most verbose. Create *Array attributes (e.g. of _elementTypeArrayType_ under _atomArray_. This requires all arrays to be of identical lengths with explicit values for all atoms in every array. This is NOT suitable for complexType atom children such as _atomParity_. It also cannot be checked as easily by schema- and schematron validation. The _atomIDArray_ attribute is mandatory. It is allowed (though not yet recommended) to add _*Array_ children such as _floatArray_ The attributes are directly related to the scalar attributes under _atom_ which should be consulted for more info. Example - these are exactly equivalent representations An atomicBasisFunction. An atomic atomicBasisFunction which can be linked to atoms, eigenvalues/vectors etc. Normally contained within _basisSet_ Normally these are atom-centered functions, but they can also serve as "ghost" functions which are centered on points. IN CCML these can be dummy atoms so that the atomRef mechanism can still be used. This information is required to interpret the eignevector components and map them onto the atom list. However this mapping is normally implicit in the program and so it may be necessary to generate basisSet information for some programs before XML technology can be automatically used to link the components of the CCML document. The atom owning this atomicBasisFunction. This reference is required to tie the reported eigenvector components to the list of atoms. The stereochemistry round an atom centre. It follows the convention of the MIF format, and uses 4 distinct atoms to define the chirality. These can be any atoms (though they are normally bonded to the current atom). There is no default order and the order is defined by the atoms in the atomRefs4 attribute. If there are only 3 ligands, the current atom should be included in the 4 atomRefs. The value of the parity is a signed number. (It can only be zero if two or more atoms are coincident or the configuration is planar). The sign is the sign of the chiral volume created by the four atoms (a1, a2, a3, a4): | 1 1 1 1 | | x1 x2 x3 x4 | | y1 y2 y3 y4 | | z1 z2 z3 z4 | Note that atomParity cannot be used with the *Array syntax for atoms. A set of references to atoms. An atomSet consists of a number of unique references to atoms throught their ids. atomSets need not be related to molecules (which are generally created by aggregation of explicit atoms). Two or more atomSets may reference the same atom, and atomSets may be empty. atomSets have many potential uses such as: identifying functional groups results of substructure matching identifying atoms with particular roles in a calculation The atomSet may be referenced from elsewhere in the document and you are encouraged to use locally unique id attributes on atomSets. An atomType. atomTypes are used in a wide variety of ways in computational chemistry. They are normally labels added to existing atoms (or dummy atoms) in the molecule and have a number of defined properties. These properties are usually in addition to those deducible from the elementType of the atom. AtomTypes usually depend on the chemical or geometrical environment of the atom and are frequently assigned by algorithms with chemical perception. However they are often frequently set or "tweaked" by humans initiating a program run. AtomTypes on an atom have no formal relation to its elementType, which only describe the number of protons in the nucleus. It is not unknown (though potentially misleading) to use an "incompatible" atomType to alter the computational properties of an atom (e.g. pretend this K+ is a Ca++ to increase its effective charge). atomTypes will also be required to describe pseudoAtoms such as "halogen" (generic) or "methyl group" (unified atom). Atoms in computations can therefore have an atomTypeRef attribute. An atomType contains numeric or other quantities associated with it (charges, masses, use in force-fields, etc.) and also description of any perception algorithms (chemical and/or geometrical) which could be used to compute or constrain it. This is still experimental. atomTypes are referred to by their mandatory name attribute. An atom referes to one or more atomTypes through atomType/@ref children examples not yet teste. The name will usually be namespaced as 'gulp:si', 'tripos:c.3', etc. It must occur except for atomType/@re. A container for one or more atomTypes. It can contain several atomTypes. A band or Brillouin zone. Not yet finalised. Band energies associated with this kpoint. The energy units must be given. A container for bands. Experimental. A container for one or more atomicBasisFunctions. This can contain several orbitals. A bond between atoms, or between atoms and bonds. _bond_ is a child of _bondArray_ and contains bond information. Bond must refer to at least two atoms (normally using _atomRefs2_) but may also refer to more for multicentre bonds. Bond is often EMPTY but may contain _electron_, _length_ or _bondStereo_ elements. Validate Bonds One or more electrons associated with the bond. The _bondRef_ on the _electron_ should point to the id on the bond. We may relax this later and allow reference by context. The stereo convention for the bond. only one convention allowed. This is designed for multicentre bonds (as in delocalised systems or electron-deficient centres. The semantics are experimental at this stage. As an example, a B-H-B bond might be described as <bond atomRefs="b1 h2 b2"/. This is designed for pi-bonds and other systems where formal valence bonds are not drawn to atoms. The semantics are experimental at this stage. As an example, a Pt-|| bond (as the Pt-ethene bond in Zeise's salt) might be described as <bond atomRefs="pt1" bondRefs="b32"/. A container for a number of bonds. _bondArray_ is a child of _molecule_ and contains _bond_ information. There are two strategies: Create individual bond elements under bondArray (in any order). This gives the greatest flexibility but is the most verbose. Create *Array attributes (e.g. of orderArrayType under bondArray. This requires all arrays to be of identical lengths with explicit values for all bonds in every array. This is NOT suitable for complexType bond children such as _bondStereo_ nor can IDs be added to bonds.. It also cannot be checked as easily by schema- and schematron validation. The _atomRef1Array_ and _atomRef2Array_ attributes are then mandatory. It is allowed (though not yet recommended) to add _*Array_ children such as _floatArray_ The attributes are directly related to the scalar attributes under _atom_ which should be consulted for more info. Example - these are exactly equivalent representations A set of references to bonds. An bondSet consists of a number of unique references to bonds throught their ids. bondSets need not be related to molecules (which are generally created by aggregation of explicit bonds). Two or more bondSets may reference the same bond, and bondSets may be empty. bondSets have many potential uses such as: identifying functional groups results of substructure matching identifying bonds with particular roles in a calculation The bondSet may be referenced from elsewhere in the document and you are encouraged to use locally unique id attributes on bondSets. A container supporting cis trans wedge hatch and other stereochemistry. An explict list of atomRefs must be given, or it must be a child of bond. There are no implicit conventions such as E/Z. This will be extended to other types of stereochemistry. At present the following are supported: No atomRefs attribute. Deprecated, but probably unavoidable. This must be a child of bond where it picks up the two atomRefs in the atomRefs2 attribute. Possible values are C/T (which only makes sense if there is exactly one ligand at each end of the bond) and W/H. The latter should be raplaced by atomParity wherever possible. Note that W/H makes no sense without 2D atom coordinates. atomRefs4 attribute. The 4 atoms represent a cis or trans configuration. This may or may not be a child of bond; if so the second and third atomRefs should be identical with the two atomRefs in the bond. This structure can be used to guide processors in processing stereochemistry and is recommended, since there is general agreement on the semantics. The semantics of bondStereo not related to bonds is less clear (e.g. cumulenes, substituted ring nuclei) etc.It is currently an error to have more than one bondStereo referring to the same ordered 4-atom list atomRefs attribute. There are other stereochemical conventions such as cis/trans for metal complexes which require a variable number of reference atoms. This allows users to create their own - at present we do not see CML creating exhaustive tables. For example cis/trans square-planar complexes might require 4 (or 5) atoms for their definition, octahedral 6 or 7, etc. In principle this is very powerful and could supplement or replace the use of cis-, mer-, etc. the atomRefs and atomRefs4 attributes cannot be used simultaneously. The type of a bond. Bond types are used to describe the behaviour of bonds in forcefields, functional groups, reactions and many other domains. They are not as well formalised as atomTypes and we provide less semantic support. BondTypes are referred to by their mandatory _name_ attribute. The bondType name. The name will usually be namespaced as 'gulp:si', 'tripos:c.3', etc. It must occur except when the ref attribute is give. A container for one or more bondTypes. _bondTypeList_ can contain several bondTypes. A general container for CML elements. Often the root of the CML (sub)document. Has no explicit function but can serve to hold the dictionary and namespace information, and is a useful tag to alert CML processors and search/XMLQuery tools that there is chemistry in the document. Can contain any content, but usually a list of molecules and other CML components. The fileId attribute can be used to preserve the origin of the information, though metadat should also be used. Can be nested. No specific restrictions.. A container for one or more experimental conditions. This can contain several conditions. These include (but are not limited to) intensive physical properties (temperature, pressure, etc.), apparatus (test-tube, rotary evaporator, etc.). Actions can be represented elsewhere by actionList and solvents or other substances by substanceList. A crystallographic cell. Required if fractional coordinates are provided for a molecule. There are precisely SIX child scalars to represent the cell lengths and angles in that order. There are no default values; the spacegroup is also included. All 6 cell parameters must be given, even where angles are fixed by symmetry. The order is fixed as a,b,c,alpha,gamma,beta and software can neglect any title or dictRef attributes. Error estimates can be given if required. Any units can be used, but the defaults are Angstrom (10^-10 m) and degrees. The definition for an entry. The definition should be a short nounal phrase defining the subject of the entry. Definitions should not include commentary, implementations, equations or formulae (unless the subject is one of these) or examples. The definition can be in any markup language, but normally XHTML will be used, perhaps with links to other XML namespaces such as CML for chemistry. From the IUPAC Dictionary of Medicinal Chemistry Descriptive information. This can occur in objects which require textual comment such as entry. Entries should have at least one separate definitions. description is then used for most of the other information, including examples. The class attribute has an uncontrolled vocabulary and can be used to clarify the purposes of the description elements. A dictionary. A dictionary is a container for _entry_ elements. Dictionaries can also contain unit-related information. The dictRef attribute on a dictionary element sets a namespace-like prefix allowing the dictionary to be referenced from within the document. In general dictionaries are referenced from an element using the __dictRef__ attribute. 2005-12-15. PMR. added namespace and dictionaryPrefix. A dimension supporting scientific unit. This will be primarily used within the definition of units. Documentation in the annotation of an entry. A container similar to documentation in XML Schema. This is NOT part of the textual content of an entry but is designed to support the transformation of dictionary entrys into schemas for validation. This is experimental and should only be used for dictionaries, units, etc. One approach is to convert these into XML Schemas when the documentation and appinfo children will emerge in their correct position in the derived schema. Do NOT confuse documentation with the description or the definition which are part of the content of the dictionary If will probably only be used when there is significant appinfo in the entry or where the entry defines an XSD-like datatype of an element in the document. An element to hold eigenstuff. Holds an array of eigenvalues and a matrix of eigenvector. An electron. Since there is very little use of electrons in current chemical information this is a fluid concept. I expect it to be used for electron counting, input and output of theochem operations, descriptions of orbitals, spin states, oxidation states, etc. Electrons can be associated with atoms, bonds and combinations of these. At present there is no hardcoded semantics. However, _atomRef_ and similar attributes can be used to associate electrons with atoms or bond. A dictionary entry. The original design for validation with attribute-based constraints is ponderous and fragile. In future constraints will be added through appinfo in annotation. We shall develop this further in the near future. 2003-03-30: added metadataList to content mode. An enumeration of value. An enumeration of string values. Used where a dictionary entry constrains the possible values in a document instance. The dataTypes (if any) must all be identical and are defined by the dataType of the containing element. An expression that can be evaluated. Experimental. This is essentially a mathematical function, expressed currently in reverse Polish notation but we expect to move to MathML. CML-1 dataType DEPRECATED. CML-1 dataType DEPRECATED. A molecular formula. It is defined by atomArrays each with a list of elementTypes and their counts (or default=1). All other information in the atomArray is ignored. formula are nestable so that aggregates (e.g. hydrates, salts, etc.) can be described. CML does not require that formula information is consistent with (say) crystallographic information; this allows for experimental variance. An alternative briefer representation is also available through the concise. This must include whitespace round all elements and their counts, which must be explicit. 2005-10-16. The semantics are now the following. A formula must have one or both: A concise attribute A single atomArray child, using array format. it must also have a formalCharge attribute if atomArray is used and the charge is non-zero. The concise, formalCharge and atomArrary information must always be consistent and software should throw an error if not. Until now there was no way of holding inline formula other than concise (although JUMBO5.0 is capable of reading them). We now extend formula.xsd to incorporate this through the attribute "inline" which requires the use of the "convention" attribute. The contents of inline are purely textual. It can be used with or without atomArray or concise but there is no guarantee that it can be interpreted as a meaningful chemical formula or that there is consistency. In some cases a document supplies several formula representations (e.g. the IUCr's CIF). In this case a molecule (or crystal) element might contain several formula children. The semantics of which to use are application dependent. Allows for fractional components. The charge on the formula. Mandatory if non-zero (i.e. cannot rely on concise) An inline representation of the formula. There are no controlled semantics and it need not be compatible with concise or atomArray. A gradient. A container for a quantity or quantities representing the gradient of other quantities. At present just takes a scalar child. A structured identifier. Supports compund identifiers such as IChI. At present uses the V0.9 IChI XML representation verbatim but will almost certainly change with future IChIs. The inclusion of elements from other namespaces causes problems with validation. The content model is deliberately LAX but the actual elements in IChI will fail the validation as they are not declared in CML. For simple scalar values the value attribute can be used with empty content. Where an identifier has several components a series of label elements can be used. 2003-07-10: Fixed count on identifier children.. 2003-03-12: Added isotopic and atoms.. CML-1 dataType DEPRECATED. CML-1 dataType DEPRECATED. A specific isotope. Defines an isotope in terms of exact mass and spin. Differentiate from isotopeList which defines a mixture of isotope. A container for one or more isotopes. Can contain several isotopes. These may be related in several ways. This allows the definition of natural abundance and averged enrichment. A text string qualifying an object. A label can be used to identify or distinguish elements, add keywords or classifications and similar processes. It is usually interpretable by domain-aware humans (e.g. C3'-endo, but not a34561). It is usually either built in a semantically rich fashion (e.g. C2'-alpha-H) or belongs to a controlled vocabulary. It is possibly accessed by software in a domain-specific manner. It differs from description which is free text. The distinction between titles, names and labels is fuzzy, but we think this is worth making. Labels may be necesssary to identify objects within programs, while names are more likely to be reserved for database searches. Titles are likely to be freer text and not recommended for precise object retrieval. Labels should not contain whitespace. Punctuation marks are often necessary, but should not be gratuitously used. Punctuation clashing with XML character entities should be avoided; if this is not possible it should be escaped. From IUPAC Dictionary of Medicinal Chemistry A lattice of dimension 3 or less. Lattice is a general approach to describing periodic systems. It can have variable dimensionality or periodicity, and could be finite. _lattice_ is more general than _crystal_ in cmlCore which is used primarily for reporting crystallographic experiments.`A lattice can be described by latticeVectors, cell axes and angles, or metric tensors, etc. (only axes/angles are allowed under crystal). The dimensionality is enforced through a _system_ parent element. All appropriate cell parameters must be given, even where angles are fixed by symmetry. The order is fixed as a,b,c,alpha,beta,gamma and software can neglect any title or dictRef attributes. Error estimates can be given if required. Any units can be used, but the defaults are Angstrom (10^-10 m) and degrees. To be developed for lower dimensionality. A vector3 representing a lattice axis. a lattice can be represented by 1-3 non-linearly dependent latticeVectors. If the dimensionality is less than 3 latticeVectors are the preferred method. Similarly, if the axes show a mixture of periodicity and non-periodicity latticeVectors can support this. The number of periodic vectors must correspond with the periodicity attribute on a system element. The vector must not be zero and units must be given. (Zero vectors must not be used to reduce dimensionality). A lattice vector defaults to periodic.. Any or all of the axes may be periodic or aperiodic. An example could be a surface where 2 periodic axes (not necessarily orthogonal) are used to describe the coordinates in the surface, perhaps representing lattice vectors of a 3D crystal or 2D layer. The third vector is orthogonal and represents coordinates normal to the surface. In this case only the direction, not the magnitude of the vector is important. A length between two atoms. This is either an experimental measurement or used to build up internal coordinates (as in a z-matrix) (only one allowed). We expect to move length as a child of _molecule_ and remove it from here. A line in 3-space. A line characterised by one or two endpoints. An internal or external link to other objects. Semantics are similar to XLink, but simpler and only a subset is implemented. This is intended to make the instances easy to create and read, and software relatively easy to implement. The architecture is: A single element (link) used for all linking purposes. The link types are determined by the type attribute and can be:. locator. This points to a single target and must carry either a ref or href attribute. locator links are usually children of an extended link. arc. This is a 1:1 link with both ends (from and to) defined. extended. This is usually a parent of several locator links and serves to create a grouping of link ends (i.e. a list of references in documents). Many-many links can be built up from arcs linking extended elements All links can have optional role attributes. The semantics of this are not defined; you are encouraged to use a URI as described in the XLink specification. There are two address spaces: The href attribute on locators behaves in the same way as href in HTML and is of type xsd:anyURI. Its primary use is to use XPointer to reference elements outside the document. The ref attribute on locators and the from and to attributes on arcs refer to IDs (without the '#' syntax). Note: several other specific linking mechanisms are defined elsewhere in STM. relatedEntry should be used in dictionaries, and dictRef should be used to link to dictionaries. There are no required uses of link in STMML but we have used it to map atoms, electrons and bonds in reactions in CML Relation to XLink. At present (2002) we are not aware of generic XLink processors from which we would benefit, so the complete implementation brings little extra value. Among the simplifications from Xlink are: type supports only extended, locator and arc label is not supported and ids are used as targets of links. show and actuate are not supported. xlink:title is not supported (all STM elements can have a title attribute). xlink:role supports any string (i.e. does not have to be a namespaced resource). This mechanism can, of course, still be used and we shall promote it where STM benefits from it The to and from attributes point to IDs rather than labels The xlink namespace is not used It is not intended to create independent linkbases, although some collections of links may have this property and stand outside the documents they link to The type of the object/element in the 'from' attributes. Requires the objects referenced by the 'from' attributes to have a given elementType. Can be overridden by 'from' attributes in individual links. 2005-06-18: created The type of the object/element in the 'to' attributes. Requires the objects referenced by the 'to' attributes to have a given elementType. Can be overridden by 'to' attributes in individual links. 2005-06-18: created The set of ids in the base of the link. 2005-06-18: created The set of ids in the target of the link. 2005-06-18: created The id of the ancestral element of objects referenced by 'from' attributes. Provides a context for uniquifying the references in the 'from' attributes. Thus atoms referenced by ids should be unique within a given molecule and the id of this could be the 'fromContext'. 2005-06-18: created The id of the ancestral element of objects referenced by 'to' attributes. Provides a context for uniquifying the references in the 'to' attributes. Thus atoms referenced by ids should be unique within a given molecule and the id of this could be the 'toContext'. 2005-06-18: created The role of the link. Xlink adds semantics through a URI; we shall not be this strict. We shall not normally use this mechanism and use dictionaries instead. The target of the (locator) link, outside the document. A generic container with no implied semantics. A generic container with no implied semantics. It just contains things and can have attributes which bind conventions to it. It could often act as the root element in an STM document. A container for links Usage is now standardized with map as the container and link as the individual links. The links are often effectively typed pointers to other parts of the document. The type can be set for all links by the 'fromType' and 'toType' attributes, either in the map, which then applied to all links by default, or in individual links, when it overrides the map setting. Since ids may not be unique within a document the refs can be given context with the 'fromRef' and 'toRef' attributes in the map element. If more than one context is used it may be better to use multiple maps. The role of map, and its relationship to RDF is still being developed. Currently (2005) map has primarily been used to map atoms between reactants and products, but we also expect shortly to extend it to peak assignments and several otherr areas. A map consists of a number of links, which can be directional, relating two elements through their ids. Reference is through the mandatory 'to' and 'from' attributes which must point to existing id attributes on elements. The type of the dereferenced element can be specified in 'toType' and 'fromType' which, while redundant, is an aid to software and acts as a check on referential type integrity. In principle any element can be linked to any other, with 1:1, 1:n, and n:m topology. We expect maps to be used for precise chemical concepts such as reactions, peak assignments, electron management, molecular superpositions, etc. and that these are supported by bespoke code. For other links, especially with complex topology, users should consider whether RDF may be more appropriate. In some cases partial mapping is known (e.g. one set of atoms maps to another set), but the precise links are unknown. (This is not the same as n:m mapping where n*m precise links would be expected). In some cases there may be objects such as atomSets or peakGroups which could be linked to support this. Alternatively the 'fromSet' and 'toSet' attributes can be used to hold a list of ids. Thus from='a1 a2' to='b3 b4' might imply that there were two precise links (either {a1=>b3, a2=>b4} or {a1=>b4, a2=>b3}). This is most likely to be used in intermediate documents where more precise semantics can be added later. The ids must all refer to elements of the same type. Note that a 'to' link referencing a single atomSet (toType='atomSet') is not the same as a 'toSet' of toType='atom' with multiple atomIds. The first would require an 'atomSet' element in the document; the second would not. The precise semantics such as the order of ids are application-dependent. If the order is known in both the toSet and fromSet then individual links should be used rather than adding the burden of deconstruction on the implementer. 2005-06-18: added typing and role and updated docs. The type of the object/element in the 'from' attributes. Requires the objects referenced by the 'from' attributes to have a given elementType. Can be overridden by 'from' attributes in individual links. 2005-06-18: created The type of the object/element in the 'to' attributes. Requires the objects referenced by the 'to' attributes to have a given elementType. Can be overridden by 'to' attributes in individual links. 2005-06-18: created The id of the ancestral element of objects referenced by 'from' attributes. Provides a context for uniquifying the references in the 'from' attributes. Thus atoms referenced by ids should be unique within a given molecule and the id of this could be the 'fromContext'. 2005-06-18: created The id of the ancestral element of objects referenced by 'to' attributes. Provides a context for uniquifying the references in the 'to' attributes. Thus atoms referenced by ids should be unique within a given molecule and the id of this could be the 'toContext'. 2005-06-18: created The role of the map. Semantics are undefined, and can be used to provide a small semi-controlled vocabulary for identifying maps of different types. 2005-06-18: created A rectangular matrix of any quantities. By default matrix represents a rectangular matrix of any quantities representable as XSD or STMML dataTypes. It consists of rows*columns elements, where columns is the fasting moving index. Assuming the elements are counted from 1 they are ordered V[1,1],V[1,2],...V[1,columns],V[2,1],V[2,2],...V[2,columns], ...V[rows,1],V[rows,2],...V[rows,columns] By default whitespace is used to separate matrix elements; see array for details. There are NO characters or markup delimiting the end of rows; authors must be careful!. The columns and rows attributes have no default values; a row vector requires a rows attribute of 1. matrix also supports many types of square matrix, but at present we require all elements to be given, even if the matrix is symmetric, antisymmetric or banded diagonal. The matrixType attribute allows software to validate and process the type of matrix. The mechanism of a reaction. In some cases this may be a simple textual description or reference within a controlled vocabulary. In others it may describe the complete progress of the reaction, including topological or cartesian movement of atoms, bonds and electrons and annotation with varying quantities (e.g. energies). For named reaction mechanisms ("Diels-Alder", "ping-pong", "Claisen rearrangement", etc.) the name element should be used. For classification (e.g. "hydrolysis"), the label may be more appropriate. In more detailed cases the mechanism refers to components of the reaction element. Thus bond23 might be cleaved while bond19 is transformed (mapped) to bond99. The mechanismComponent can be used to refer to components and add annotation. This is still experimental. IUPAC Compendium of Chemical Terminology 2nd Edition (1997) describes a mechanism as: A detailed description of the process leading from the reactants to the products of a reaction, including a characterization as complete as possible of the composition, structure, energy and other properties of reaction intermediates, products and transition states. An acceptable mechanism of a specified reaction (and there may be a number of such alternative mechanisms not excluded by the evidence) must be consistent with the reaction stoichiometry, the rate law and with all other available experimental data, such as the stereochemical course of the reaction. Inferences concerning the electronic motions which dynamically interconvert successive species along the reaction path (as represented by curved arrows, for example) are often included in the description of a mechanism. It should be noted that for many reactions all this information is not available and the suggested mechanism is based on incomplete experimental data. It is not appropriate to use the term mechanism to describe a statement of the probable sequence in a set of stepwise reactions. That should be referred to as a reaction sequence, and not a mechanism. CMLReact provides reactionScheme and annotions to describe the reaction sequence and both it and mechanism could co-occur within a reactionScheme container. An information component within a reaction mechanism. Information components can represent both physical constituents of the reaction or abstract concepts (types of bond cleavage, thermodynamics, etc.). There are several ways that components of the reaction can be annotated and/or quantified. One approach will be to refer to specific bonds and atoms through their ids and use mechanismComponent to describe their role, properties, etc. Another is to use mechanismComponent to identify types of bond formed/broken without reference to actual atoms and bonds (initially through the name element). Yet another will be to include information on the reaction profile. This is still experimental. A general container for metadata. A general container for metadata, including at least Dublin Core (DC) and CML-specific metadata In its simple form each element provides a name and content in a similar fashion to the meta element in HTML. metadata may have simpleContent (i.e. a string for adding further information - this is not controlled). A general container for metadata elements. MetadataLists can have local roles (e.g. a bibliographic reference could be a single meteadatList with, say, 3-6 components). The role attribute is used in an uncontrolled manner for this. MetadataLists can also be nested, but metadata and metadataList children should not occur on the same level of the hierarchy. A module in a calculation. Many programs are based on discrete modules which produce chunks of output. There are also conceptual chunks such as initialisation, calculation and summary/final which often have finer submodules such as cycle, iteration, snapshot, etc. There is no controlled vocabulary but a typical structure is shown in the example. One of the challenges of CCML is to find communality between different programs and to use agreed abstractions for the modules. The module can have a program-specific name through its title or dictRef (e.g. "MINIM", "l201") and a generic role ("dynamicsCalculation", "equilibration", etc.). In general role will be controlled by CCML. A container for atoms, bonds and submolecules. molecule is a container for atoms, bonds and submolecules along with properties such as crystal and non-builtin properties. It should either contain molecule or *Array for atoms and bonds. A molecule can be empty (e.g. we just know its name, id, etc.) "Molecule" need not represent a chemically meaningful molecule. It can contain atoms with bonds (as in the solid-sate) and it could simply carry a name (e.g. "taxol") without formal representation of the structure. It can contain "sub molecules", which are often discrete subcomponents (e.g. guest-host). Molecule can contain a <list> element to contain data related to the molecule. Within this can be string/float/integer and other nested lists Revised content model to allow any order of lengths, angles, torsions 2003-01-01.. Added role attribute 2003-03-19.. The float|integer|string children are for compatibility with CML-1 and are deprecated. scalar|array|matrix should be used instead. No formal semantics (yet). The role describes the purpose of the molecule element at this stage in the information. Examples can be "conformation", "dynamicsStep", "vibration", "valenceBondIsomer", etc. This attribute may be used by applications to determine how to present a set of molecule elements. A string identifying a object. name is used for chemical names (formal and trivial) for molecules and also for identifiers such as CAS registry and RTECS. It can also be used for labelling atoms. It should be used in preference to the title attribute because it is repeatable and can be linked to a dictionary. Constraining patterns can be described in the dictionary and used to validate names. An object which might occur in scientific data or narrative. Deliberately vague. Thus an instrument might be built from sub component objects, or a program could be composed of smaller modules (objects). object could be used to encapsulate graphical primitives (e.g. in reaction schemes, drawings of apparatus, etc.). Unrestricted content model. An observation or occurrence. A container for any events that need to be recorded, whether planned or not. They can include notes, measurements, conditions that may be referenced elsewhere, etc. There are no controlled semantics. An operator within an expression. Experimental. An operator acts on one or more arguments (at present the number is fixed by the type). The formulation is reverse Polish so the result (with its dataType) is put on a stack for further use. A parameter describing the computation. A parameter is a broad concept and can describe numeric quantities, objects, keywords, etc. The distinction between keywords and parameters is often fuzzy. ("MINIM" might mean "minimize", while "MINIM=3" might require three iterations to be run. It may help to think of control keywords as boolean parameters. Numeric parameters can describe values in molecules, forcefields or other objects. Often the parameters will be refined or otherwise varied during the calculation. Some parameters may be fixed at particular values or relaxed at different stages in the calculation. Parameters can have errors, gradients and other indications of uncertainty. String/character parameters are often abbreviated in program input, and this is supported through the regex and ignoreCase attributes. ????? Parameters will usually be defined separately from the objects and use the ref attribute to reference them. Parameters can be used to describe additional constraints. This will probably require the development of a microlanguage and until then may use program-specific mechanisms. A common approach will be to use an array of values (or objects) to represent different input values for (parts of) the calculation. Thus a conformational change could be specified by an array of several torsion angles. A parameter will frequently have a dictRef pointing to a dictionary which may have more information about how the parameter is to be used or the values it can take. The allowable content of parameters may be shown by a "template" in the appinfo; this is stil experimental. This is a shorthand for a single scalar value of the parameter. It should only be used with the ref attribute as it inherits all the dataTyping of the referenced element. It must not be used for defining new parameters as it has no mechanism for units and dataTyping. [This may change?]. Used to define concepts such as independent and dependent variables A container for one or more parameters. parameterList can contain several parameters. An object in space carrying a set of properties. particles have many of the characteristics of atoms but without an atomic nucleus. It does not have an elementType and cannot be involved in bonding, etc. It has coordinates, may carry charge and might have a mass. It represents some aspect of a computational model and should not be used for purely geometrical concepts such as centroid. Examples of particles are "shells" (e.g. in GULP) which are linked to atoms for modelling polarizability or lonepairs and approximations to multipoles. Properties such as charge, mass should be scalar/array/matrix children. Used in a similar manner to atomType. Examples might be "lonePair", "polarizable Oxygen", etc. A peak; annotated by human or machine. A peak can describe: A single point in a spectrum. Usually a maximum but could be a shoulder, inflexion or indeed any point of interest. A continuous range of values within a spectrum, defined by maximum and minimum values on either/both axes The finer structure of the peak can be given with one or more peakStructure children The units should always be given. (The raw spectral data may unfortunately use different units and no assumptions should be made). The content model includes atom, bond, molecule, but these are deprecated and should be replaced by atomRefs, etc. 2005-11-22: PMR. Added moleculeRefs Allows inter alia the provenance of the peak assignment to be recorde. 2005-11-9. DEPRECATED; use atomRefs 2005-11-9. DEPRECATED; use bondRefs 2005-11-9. DEPRECATED; use moleculeRefs when developed 2005-11-9. PMR, added Atoms contributing to this peak The primary set of atoms responsible for the peak such as an NMR peak. Coupling constants and similar splitting should not use this but peakStructure. At present there is no substructure to this attribute or concept and only one attribute is allowed. It may be combined with bondRefs. Even single atoms should use atomRefs, not atomRef. Bonds contributing to this peak The primary set of bonds responsible for the peak such as an IR frequency. At present there is no substructure to this attribute or concept and only one attribute is allowed. It may be combined with atomRefs. Molecule(s) contributing to this peak The molecule or molecule responsible for the peak. At present there is no substructure to this attribute or concept and only one attribute is allowed. This might, for example, be used to manage a mass spectrum or chromatogram A list of closely related peaks or peakGroups. Distinguish between peakList (primarily a navigational container) and peakGroup where the peaks (or groups) have some close relation not shared by all peaks. All descendants must use consistent units. 2005-11-22. added atomRefs, bondRefs and moleculeRefs and deprecated atom, bond, molecule children Allows inter alia the provenance of the peak assignment to be recorde. 2005-11-22. DEPRECATED; use atomRefs 2005-11-22. DEPRECATED; use bondRefs 2005-11-22. DEPRECATED; use moleculeRefs Atoms contributing to this peak The primary set of atoms responsible for the peak such as an NMR peak. Coupling constants and similar splitting should not use this but peakStructure. At present there is no substructure to this attribute or concept and only one attribute is allowed. It may be combined with bondRefs. Even single atoms should use atomRefs, not atomRef. Bonds contributing to this peak The primary set of bonds responsible for the peak such as an IR frequency. At present there is no substructure to this attribute or concept and only one attribute is allowed. It may be combined with atomRefs. Molecule(s) contributing to this peak The molecule or molecule responsible for the peak. At present there is no substructure to this attribute or concept and only one attribute is allowed. This might, for example, be used to manage a mass spectrum or chromatogram A list of peaks or peakGroups. Distinguish between peakList (primarily a navigational container) and peakGroup where the peaks (or groups) have some close relation not shared by all peaks. All peaks and peakGroups should use the same units. Allows inter alia the provenance of the peak assignment to be recorde. The structure of a peak. Primarily to record couplings and other fine structure. At present we have tested this on HNMR spectra, C13 NMR and simple IR. We believe that other types of spectroscopy (ESR, NQR, etc) can be represented to some extent, but there may be systems beyond the current expressive power. For molecules without symmetry we believe that most of the important types of NMR coupling can be represented. Thus an atom which gives rise to two couplings can have two child PeakStructures, and this is shown in example1. <cml xmlns="http://www.xml-cml.org/schema"> <!-- Ha ... Hb ... Hc1, Hc2 --> <molecule id="m1"> <atomArray> <atom id="a1" elementType="H"> <label value="Ha"/> </atom> <atom id="a2" elementType="H"> <label value="Hb"/> </atom> <atom id="a3" elementType="H"> <label value="Hc1"/> </atom> <atom id="a4" elementType="H"> <label value="Hc2"/> </atom> </atomArray> </molecule> <spectrum id="spectrum2" title="test peaks"> <peakList> <peak id="p1" title="Ha" atomRefs="a1" peakShape="sharp" xUnits="unit:ppm" xValue="6.0"> <peakStructure type="coupling" peakMultiplicity="doublet11" value="12" units="unit:hertz" atomRefs="a2"/> </peak> <peak id="p2" title="Hb" atomRefs="a2" peakShape="sharp" xUnits="unit:ppm" xValue="7.0"> <peakStructure type="coupling" peakMultiplicity="doublet11" value="12" units="unit:hertz" atomRefs="a1"/> <peakStructure type="coupling" peakMultiplicity="triplet121" value="15" units="unit:hertz" atomRefs="a3 a4"/> </peak> <peak id="p3" title="Hc" atomRefs="a3 a4" peakShape="sharp" xUnits="unit:ppm" xValue="8.0"> <peakStructure type="coupling" peakMultiplicity="doublet11" value="15" units="unit:hertz" atomRefs="a2"/> </peak> </peakList> </spectrum> </cml> Where a peak is due to symmetry-related atoms there are different couplings to symmetrical atoms. Thus in an AA'BB' system there can be two couplings to the A atoms and we need nested peakStructures to represent these. In this case the order of the atoms in the peak@atomRefs maps to the order of the grandchildren. See example2. <!-- AA'BB' where there are 2 Ha and 2 Hb with two couplings J1 Ha ... Hb and Ha' ... Hb' J2 Ha ... Hb' and Ha' ... Hb --> <molecule id="m1"> <atomArray> <atom id="a1" elementType="H"> <label value="Ha"/> </atom> <atom id="a2" elementType="H"> <label value="Ha'"/> </atom> <atom id="a3" elementType="H"> <label value="Hb"/> </atom> <atom id="a4" elementType="H"> <label value="Hb'"/> </atom> </atomArray> </molecule> <spectrum id="spectrum2" title="test peaks"> <peakList> <!-- the ORDER of a1 and a2 is linked to the ORDER of the grandchildren elements, i.e. a1 couples to atoms in ps11 and ps21 while a2 relates to atoms is ps21 and ps22 --> <peak id="p1" title="Ha" atomRefs="a1, a2" peakShape="sharp" xUnits="unit:ppm" xValue="6.0"> <peakStructure id="ps1" type="coupling" peakMultiplicity="doublet" value="10" units="unit:hertz"> <peakStructure id="ps11" atomRefs="a3"/> <peakStructure id="ps12" atomRefs="a4"/> </peakStructure> <peakStructure id="ps2" type="coupling" peakMultiplicity="doublet" value="2" units="unit:hertz"> <peakStructure id="ps21" atomRefs="a4"/> <peakStructure id="ps22" atomRefs="a3"/> </peakStructure> </peak> </peakList> </spectrum> </cml> Allows inter alia the provenance of the peakStructure assignment to be recorded. Allows identification of couplings in symmetric systems. May also be usable for other complicated systems. The atoms to which the peakStructure refers. Allows identification of the atoms to which the peak is coupled (not the atoms contributing to the primnary reference for which peak should be used). It may be combined with bondRefs. Even single atoms should use atomRefs, not atomRef. Bonds contributing to this peakStructure Even a single bond should use bondRefs, not bondRef A plane in 3-space. An oriented plane of indefinite extent. A point in 3-space. An explicit potential. This represents the actual function for the potential (i.e. with explicit values) rather than the functional form, which will normally be referenced from this. The functional form of a potential. This has generic arguments and parameters rather than explicit ones. It is essentially a mathematical function, expressed currently in reverse Polish notation. A container for explicit potentials. Experimental. A product within a productList. product describes a product species which is produced in a reaction. See reactant for discussion of catalysis and solvents. A product will normally be identified by name(s), formula, or molecule and at least one of these should normally be given. Amount(s) of product can be given after this identification and can describe mass, volume, percent yield, etc. but not stoichiometry A container for one or more products. productList can contain several products. These may be related in several ways, including single list of products grouping of products of parallel reactions . A productList can contain nested productLists. The semantics of this are currently undefined. The number of copies of the productList involved in the stoichiometric reaction. Probably not useful for simple reactions but could be used for parallel reactions. A container for a property. property can contain one or more children, usually scalar, array or matrix. The dictRef attribute is required, even if there is a single scalar child with the same dictRef. The property may have a different dictRef from the child, thus providing an extension mechanism. Properties may have a state attribute to distinguish the state of matter Semantics are not yet controlled but could include thermochemistry, kinetics or other common properties. A container for one or more properties. propertyList can contain several properties. These include (but are not limited to) observations, or numeric quantities. A reactant within a reactantList. reactant describes a reactant species which takes part in a reaction. Catalysts and supports are not normally classified as reactants, but this is subjective. Enzymes (or parts of enzymes) may well be reactants, as could be substances which underwent chemical change but were restored to their original state. reactant is a powerful concept as it can support stoichiometry (atom and molecule counting), mapping (for mechanisms), etc. Solvents are best contained within substanceList. A reactant will normally be identified by name(s), formula, or molecule and at least one of these should normally be given. Amount(s) of reactant can be given after this identification and can describe mass, volume, etc. but not stoichiometr. The role of the reactant within a reactantList. Semantics are not yet controlled but could be limiting, oxidant, etc. TODO: a reactant might have multiple roles so this may have to become an element. The number of copies of the reactant involved in the stoichiometric reaction. Could be non-integer but should not be used for actual ratios of materials added (for which amount should be used). A container for one or more reactants. reactantList can contain several reactants. These may be related in several ways, including lists of related reactants reactant schemes multi-step reactants parallel and/or coupled reactants . A reactantList can contain nested reactantLists. The semantics of this are currently undefined. A chemical reaction or reaction step. reaction is a container for reactants, products, conditions, properties and possibly other information relating to the reaction, often within a reactionList. Partial semantics exist: name the name(s) of the reaction reactantList (normally only one) the grouped reactants spectatorList substances with well-defined chemistry which are involved in the reaction but do not change. Examples are side groups in proteins, cofactors, etc. The division between specattor and substance is subjective. substance or substanceList substances present in the reaction but not classified as reactants. Examples might be enzymes, catalysts, solvents, supports, workup, etc. condition conditions of the reaction. These may be text strings, but ideally will have clearer semantics such as scalars for temperature, etc. productList the grouped products. This allows for parallel reactions or other semantics. property properties (often physical) associated with the reaction. Examples might be heat of formation, kinetics or equilibrium constant. Reaction normally refers to an overall reaction or a step within a reactionList. For a complex "reaction", such as in enzymes or chain reactions, it may be best to use reactionScheme to hold the overall reaction and a reactionList of the individual reaction steps. The semantics of the content model are metadataList for general metadata label for classifying or describing the reaction (e.g. "hydrolysis") identifier for unique identification. This could be a classification such as EC (enzyme commission) or an IChI-like string generated from the components. these are followed by the possible components of the reaction and/or a reactionList of further details. . This allows any objects to be attached to the reaction, but particularly graphical primitives such as lines, arrows, etc. These should be provided as elements where possible (e.g. SVG) and should have references to the chemical objects they interact with (i.e. not simply relying on geometry). Markers with IDs can be included as part of the graphics object and their ids linked to the chemical elements using link. The yield of the reaction. Note that this lies in the range 0-1. A container for one or more reactions or reactionSchemes with no interrelations. A reactionList aggregates reactions and reactionSchemes but implies no semantics. The most common uses are to create small collections of reactions (e.g. databases or publications). A container for two or more related reactions and their relationships. Where reactions are closely related (and often formally dependent on each other) they should be contained within the reactionStepList of a reactionScheme. The semantics which have informed this design include: Steps within an organic synthesis. Two or more individual (primitive) steps provding the detailed mechanism for an overall reaction. Coupled or sequential reactions within biochemical pathways. This design is general because "reaction" is used in several ways. A biochemical pathway (e.g. oxidation of glucose to CO2 and water) involves many coupled enzyme reactions proceeding both in parallel and in sequence. Each of these steps ("reactions" in their own right) is itself complex and can include several mechanistics steps which are themselves reactions with products, reactants, etc. reactionScheme can therefore include reactionStepLists (with more reactionScheme children) which provide a more detailed view of the individual components. Where a set of reactions are primitives... The semantics of the content model are metadataList for general metadata label for classifying or describing the reaction (e.g. "hydrolysis") identifier for unique identification. This could be a classification such as EC (enzyme commission) or an IChI-like string generated from the components. these are followed by the possible components of the reaction and/or a reactionList of further details. A child of reactionStepList and a container for reaction or reactionScheme. reactionStep is always contained within reactionStepList and is designed to manage "sub-reactions" which have close relationships. These will often involve reactions which, taken together, describe a higher level reaction or reaction type. Examples are: biochemical pathways synthetic reaction schemes multi-step reactions parallel and/or coupled reactions . A reactionStep normally contains a single reaction or reactionScheme. It can have attributes such as yield and ratio which can be used by the parent reactionStepList. The name applies to the overall schema of reactions. label is for additional textual information and classification. reactionStepList normally contains reactions but we make provision for nested reactionSchemes if required. The yield of the reactionStep. Note that this lies in the range 0-1. The ratio of this step to one or more sibling steps. Note that this lies in the range 0-1. It is meaningless to use this unless there are siblings, in which case it refers to the relative molar fluxes through each. The "percentage yields" will need to be transformed to this range. There is no requirement that the sum of fluxes through a group of siblings sum to 1.0, though they should not sum to more. A container for one or more related reactionSteps. reactionStepList is always contained within reactionScheme and is designed to manage "sub-reactions" which have close relationships. These will often involve reactions which, taken together, describe a higher level reaction or reaction type. Examples are: biochemical pathways synthetic reaction schemes multi-step reactions parallel and/or coupled reactions . A reactionStepList contains reactionSteps (each of which contains reactions and/or reactionSchemes (e.g. where part of the process is known in greater detail)). It may not directly contain child reactionStepLists. The child reactionSteps can have attributes such as yield and ratio which describe the relationship of the component steps. Guidance on use: reactionScheme describes a complex of reactions with metadata, one (or more) overall reactions and a reactionStepList with the overall component reactions. reactionStepList aggregates and structures the individual subreactions. reactionList is a container for reactions and reactionSchemes with no semantics (e.g. a book or database of selected reactions). The name applies to the overall schema of reactions. label is for additional textual information and classification. reactionStepList normally contains reactionSteps. The reactiveCentre in a reaction. This describes the set(s) of bonds and atoms involved in the reaction. The semantics are flexible, but a common usage would be to create atomSet(s) and bondSet(s) mapping to groups which undergo changes. A region of the system. Under development. A subdivision of the system to which special protocols or properties may be attached. Typical regions could be defined by the presence of atoms belonging to an atomSet or geometrical boundaries. A region element will not always contain other elements, but may have references from other elements. It may create a protocol, e.g. atoms within a region might be replaced by a continuum model or be subject to a field. Semantics yet to be determined. Regions can be created by the unions of two or more regions. This allows a region to be built from a series of (say) spheres or boxes filling space. An entry related in some way to a dictionary entry. The range of relationships is not restricted but should include parents, aggregation, seeAlso and so on. DataCategories from ISO12620 can be referenced through the namespaced mechanism. The related entry. An analytical or spectral sample. The sample should contain information on what things were in the sample and their roles. It can include molecule, substance and substanceList. Typical rolos include solvent, mulling agents, salt disks, molecular supports, etc. but should not cover apparatus or conditions. A molecular description. A substance in the sample. A list of substances in the sample. An element to hold scalar data. scalar holds scalar data under a single generic container. The semantics are usually resolved by linking to a dictionary. scalar defaults to a scalar string but has attributes which affect the type. scalar does not necessarily reflect a physical object (for which object should be used). It may reflect a property of an object such as temperature, size, etc. Note that normal Schema validation tools cannot validate the data type of scalar (it is defined as string), but that a temporary schema can be constructed from the type and used for validation. Also the type can be contained in a dictionary and software could decide to retrieve this and use it for validation. Alternative to units Must be used in conjunction with unitType 2005-10-26: added Alternative to units Must be used in conjunction with unitType 2005-10-26: added Alternative to units Must be used in conjunction with multiplierToSI and/or constantToSI 2005-10-26: added A spectator object in a reaction. Objects are often present during a reaction which are not formally involved in bond breaking/formation and which are not modified during the reaction. They may be catalysts, but may also be objects which in some way constrain or help the reaction to take place (surfaces, micelles, groups in enzyme active sites, etc.). In some cases molecules present in a reaction mixture may act as spectators in steps in which they are not transformed. No controlled vocabulary. Examples could be 'host', 'hydrophobic ligand', 'charge-stabilizer', etc.. A container for spectators in a reaction. A spectrum and relevant data or metadata. The spectrum construct can hold metadataList, sample (which can contain molecule), conditionList (mainly for physical/chemical conditions, not instrumental), spectrumData for the actual data and instrumental settings/procedure and peakList for the assigned peaks. This approach puts the spectrum as the primary object of interest. It could also be possible to make spectrum a child of molecule (although a reference using ref might be preferable). A (complete) description of the thing to which the spectrum relates. May contain molecule or substanceList. Solvents, mulls, etc should be described here. The conditions relating to the spectrum (complementary to substanceList. A list of peaks. This may occur independently of the xaxis/yaxis data. The molecule to which the spectrum refers. Although this may also be contained in the sample element it is useful to state it here. No default. Data for the spectrum. This is primarily to record the data in interchangeable format and machine and manufacturers settings and can include other MLs in this area (AniML, SpectroML, etc.). We recommend ASCII representations of data and this is the only format that CMLSpect implementers have to support, but we also allow for the carriage of JCAMP and other data (in ML wrappers such as AniML). All numeric data should carry units and dictionary references if possible to allow for semantic interoperability. The x-axis/es, usually including the list of points at which data are recorded. Mandatory if y-axis data are given. Multiple x-axes are initially reserved for multiple scales rather than different measurements (for which an additional spectrum should be used). The y-axis/es, usually including the list of points at which data are recorded. Mandatory if x-axis data are given. Multiple y-axes are initially reserved for multiple scales rather than different measurements (for which an additional spectrum should be used). A container for one or more spectra. spectrumList can contain several spectra. These may be related in several ways, including lists of related spectra bundle of common analytical spectra (NMR, IR, UV...) repeat measurements . A spectrumList can contain nested spectrumLists. metadataList contains metadata. list is for experimental and other data. spectrumList normally contains spectrums but we make provision for nested spectrumLists if required. The molecules can be a set of reference molecules which occur in the spectrums and can be referenced. This makes the spectrums more readable and normalizes data when molecules are used more than once. A sphere in 3-space. An element to hold stmml data. stmml holds stmml data under a single generic container. Other namespaces may be present as children. No semantics implied. CML-1 dataType (DEPRECATED). CML-1 dataType DEPRECATED. A chemical substance. substance represents a chemical substance which is deliberately very general. It can represent things that may or may not be molecules, can and cannot be stored in bottles and may or may not be microscopic. Solutions and mixtures can be described by _substanceList_s of substances. The type attribute can be used to give qualitative information characterising the substance ("granular", "90%", etc.) and _role_ to describe the role in process ("desiccant", "support", etc.). There is currently no controlled vocabulary. Note that reaction is likely to have more precise semantics. The amount of a substance is controlled by the optional _amount_ child. Added property as a child 2002-12-29 role depends on context, and indicates some purpose associated with the substance. It might indicate 'catalyst', 'solvent', 'antoxidant', etc. but is not limited to any vocabulary. A list of chemical substances. Deliberately very general - see substance. substanceList is designed to manage solutions, mixtures, etc. and there is a small enumerated controlled vocabulary, but this can be extended through dictionaries. substanceList can have an amount child. This can indicate the amount of a solution or mixture; this example describes 100 ml of 0.1M NaOH(aq). Although apparently longwinded it is precise and fully machine-interpretable Added role attribute, 2003-03-12. Molecular, crystallographic or other symmetry. symmetry provides a label and/or symmetry operations for molecules or crystals. Point and spacegroups can be specified by strings, though these are not enumerated, because of variability in syntax (spaces, case-sensitivity, etc.), potential high symmetries (e.g. TMV disk is D17) and non-standard spacegroup settings. Provision is made for explicit symmetry operations through <matrix> child elements. By default the axes of symmetry are defined by the symbol - thus C2v requires z to be the unique axis, while P21/c requires b/y. Spacegroups imply the semantics defined in International Tables for Crystallography, (Int Union for Cryst., Munksgaard). Point groups are also defined therein. The element may also be used to give a label for the symmetry species (irreducible representation) such as "A1u" for a vibration or orbital. The matrices should be 3x3 for point group operators and 3x4 for spacegroup operators. The use of crystallographic notation ("x,1/2+y,-z") is not supported - this would be <matrix>1 0 0 0.0 0 1 0 0.5 0 0 1 0.0<matrix>. The default convention for point group symmetry is Schoenflies and for spacegroups is "H-M". Other conventions (e.g. "Hall") must be specfied through the convention attribute. This element implies that the Cartesians or fractional coordinates in a molecule are oriented appropriately. In some cases it may be useful to specify the symmetry of an arbitarily oriented molecule and the <molecule> element has the attribute symmetryOriented for this purpose. It may be better to use transform3 to hold the symmetry as they have fixed shape and have better defined mathematical operators. 2005-11-03 PMR. Added transform3 as children. The rotational symmetry number. Used for calculation of entropy, etc. The complete system of components in a calculation. There is no controlled vocabulary. A rectangular table of any quantities. By default table represents a rectangular table of any quantities representable as XSD or STMML dataTypes. The default layout is columnwise, with columns columns, where each column is a (homogeneous) array of size rows data. This is the "normal" orientation of data tables but the table display could be transposed by XSLT transformation if required. Access is to columns, and thence to the data within them. DataTyping, delimiters, etc are delegated to the arrays, which must all be of the same size. For verification it is recommended that tables carry rows and columns attributes. An alternative is to use the standard HTML table layout (tr and td). The identities of the columns (dictRef), their dataTypes and their units are given by leading tr elements with the type attribute. This is harder to process and the column-wise approach should be used where possible if dataTypes, etc. are important A torsion angle ("dihedral") between 4 distinct atoms. The atoms need not be formally bonded. It can be used for: Recording experimentally determined torsion angles (e.g. in a crystallographic paper). Providing the torsion component for internal coordinates (e.g. z-matrix). Note that the order of atoms is important. A transform in 3-space. A 3-D transform. Conventionally a 4x4 matrix. The transition state in a reaction. This will normally contain a molecule which in its 2D representation will have partial bonds. These are yet to be formalized for the molecule element. Although spectators may stabilise or otherwise interact with the transitionState they are not contained within it. A propertyList is provided to capture transitionState properties. Still experimental. A scientific unit. A scientific unit. Units are of the following types: SI Units. These may be one of the seven fundamental types (e.g. meter) or may be derived (e.g. joule). An SI unit is identifiable because it has no parentSI attribute and will have a unitType attribute. 2005-122-17 - this may be obsolete; PMR nonSI Units. These will normally have a parent SI unit (e.g. calorie has joule as an SI parent). 2003:04-09 Description or parentSI attribute enhance. A container for several unit entries. Usually forms the complete units dictionary (along with metadata). 2005-12-15. PMR. added namespace and dictionaryPrefix. 2005-12-17. PMR. added siNamespace . Maps dictRef prefix to the location of a dictionary. This requires the prefix and the physical URI address to be contained within the same file. We can anticipate that better mechanisms will arise - perhaps through XMLCatalogs. At least it works at present. The type of a scientific unit. Mandatory for SI Units, optional for nonSI units since they should be able to obtain this from their parent. For complex derived units without parents it may be useful. Used within a unitList Distinguish carefully from unitsType which is primarily used for attributes describing the units that elements carry A vector in 3-space. The vector may have magnitude but is not rooted on any points (use line3). The x-axis. A container for all information relating to the x-axis (including scales, offsets, etc.) and the data themselves (in an array). Note: AniML uses "xValues" so avoid confusion with this. The x-data. These must match the y-data in number and order. There are tools to allow scaling and transformation (though unscaled data must be very carefully defined). The y-axis. A container for all information relating to the y-axis (including scales, offsets, etc.) and the data themselves (in an array). The y-data. These must match the x-data in number and order. There are tools to allow scaling and transformation (though unscaled data must be very carefully defined). A zMatrix. A container for length, angle and torsion, which must be arranged in the conventional zMatrix format.
cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/space1.xml000077500000000000000000000022231477224461000306250ustar00rootroot00000000000000 0.2 0.25 1.2 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/spectator1.xml000077500000000000000000000017431477224461000315440ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/spectatorList1.xml000077500000000000000000000021541477224461000323750ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/spectrum1.xml000077500000000000000000000111111477224461000313700ustar00rootroot00000000000000 78-92-2 1.2345 12345 450 454 458 462 466 470 474 478 482 486 490 494 498 502 506 510 514 518 522 526 530 534 538 542 546 550 554 558 562 566 570 574 578 582 586 590 594 598 602 606 610 614 618 622 626 630 634 638 642 646 650 654 658 662 666 670 674 678 682 686 690 694 698 702 706 710 714 718 722 726 730 734 738 742 746 750 754 758 762 766 770 774 778 782 786 790 794 798 802 806 810 814 818 822 826 830 834 838 842 846 850 854 858 862 866 870 874 878 882 886 890 894 898 902 906 910 914 918 922 926 930 934 938 942 946 950 954 958 962 966 970 974 978 982 986 990 994 998 1002 1006 1010 1014 1018 1022 1026 1030 1034 1038 1042 1046 1050 1054 1058 1062 1066 1070 1074 1078 1082 1086 1090 1094 1098 1102 1106 1110 1114 1118 1122 1126 1130 1134 1138 1142 1146 1150 1154 1158 1162 1166 1170 1174 1178 1182 1186 1190 1194 1198 1202 1206 1210 1214 1218 1222 1226 1230 1234 1238 1242 1246 1250 1254 1258 1262 1266 1270 1274 1278 1282 1286 1290 1294 1298 1302 1306 1310 1314 1318 1322 1326 1330 1334 1338 1342 331 179 99 148 146 150 187 165 249 206 189 224 253 230 267 236 167 137 96 109 51 77 28 64 50 68 82 51 103 37 133 111 124 119 144 1 120 93 89 119 109 133 89 126 119 89 47 97 57 89 81 77 86 52 51 114 77 87 63 57 70 69 60 44 61 39 44 57 24 55 50 42 37 43 67 66 92 112 128 148 162 160 162 178 178 154 155 167 176 170 179 195 210 216 190 173 158 146 135 121 109 101 105 108 133 162 206 288 417 579 792 1063 1377 1675 1797 1736 1700 1794 1780 1552 1198 878 648 524 492 516 599 730 896 1110 1360 1623 1889 2123 2282 2404 2451 2442 2396 2327 2185 2029 1915 1803 1691 1594 1520 1448 1382 1300 1230 1211 1264 1392 1518 1659 1758 1867 1968 2018 2005 1960 1969 2010 2063 2100 2175 2254 2344 2467 2557 3 1 15 1 1 17 10 9 1 7 35 2 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/spectrum2-local.xml000077500000000000000000000040301477224461000324630ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/spectrum2.xml000077500000000000000000000033321477224461000313770ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/spectrum3.xml000077500000000000000000000034151477224461000314020ustar00rootroot00000000000000 D.HENNEBERG, MAX-PLANCK INSTITUTE, MULHEIM, WEST GERMANY NIST Mass Spectrometry Data Center 109-99-9 24 25 26 27 29 30 31 33 34 35 37 38 39 40 41 42 43 44 45 46 49 50 51 53 54 55 68 69 70 71 72 73 4 30 171 1545 792 21 258 5 26 10 105 165 1182 906 4060 9999 1586 325 100 3 7 11 19 27 10 6 7 20 107 2557 2868 147 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/spectrum4.xml000077500000000000000000000572511477224461000314120ustar00rootroot00000000000000 INSTITUTE OF ENERGY PROBLEMS OF CHEMICAL PHYSICS, RAS INEP CP RAS, NIST OSRD 109-99-9 199.1212 199.1212 199.1164 199.1164 199.1107 199.1107 199.1030 199.0977 199.0964 199.0898 199.0895 199.0893 199.0891 199.0858 199.0855 199.0853 199.0851 199.0680 199.0665 198.8244 198.8009 198.7893 198.6686 198.6686 198.6383 198.6079 198.5775 198.5775 198.5734 198.5682 198.5612 198.5612 198.5086 198.3795 198.2234 198.0650 198.0160 197.9815 197.9798 197.9307 197.7450 197.6996 197.6814 197.6768 197.6721 197.5620 197.5489 197.5115 197.5115 197.4962 197.4584 197.4496 197.4416 197.4416 197.3958 197.2085 197.1864 197.1478 196.9264 196.8891 196.8776 196.8642 196.6951 196.6504 196.6483 196.6300 196.3837 196.3827 196.3715 196.2983 196.2669 196.2646 196.2427 196.2318 196.2189 196.1948 196.1948 196.1942 196.1904 196.1549 196.0903 196.0689 196.0579 196.0466 196.0238 196.0233 196.0228 196.0224 196.0224 196.0220 196.0125 196.0011 195.9888 195.9877 195.9515 195.9144 195.8027 195.7443 195.6989 195.6894 195.6780 195.6656 195.6272 195.6173 195.6095 195.6095 195.6056 195.5929 195.5290 195.4507 195.4162 195.3820 195.3115 195.2401 195.2065 195.1937 195.1888 195.1888 195.1809 195.1681 195.1576 195.1264 195.0952 195.0952 195.0728 195.0623 195.0486 195.0234 195.0035 194.9902 194.9448 194.9314 194.8861 194.8726 194.8525 194.8397 194.8346 194.8268 194.8139 194.8139 194.7552 194.7167 194.6858 194.6858 194.5864 194.5243 194.4464 194.4464 194.4137 194.4092 194.4037 194.3963 194.3279 194.2690 194.2311 194.2311 194.1704 194.1097 194.0492 194.0492 193.9125 193.7814 193.6788 193.6788 193.6586 193.6455 193.6383 193.6171 193.6112 193.5941 193.5751 193.5751 193.5565 193.5559 193.5553 193.5548 193.4188 193.3674 193.3650 193.3375 193.3086 193.3000 193.2995 193.2990 193.2986 193.2798 193.2510 193.2510 193.2474 193.2430 193.2381 193.2367 193.2334 193.2279 193.2205 193.2205 193.1975 193.1522 193.1462 193.1070 193.0720 193.0617 193.0617 193.0528 193.0420 193.0304 192.9978 192.9978 192.9574 192.9139 192.8977 192.8647 192.8307 192.8301 192.7970 192.7963 192.7957 192.7950 192.7950 192.7945 192.6492 192.5792 192.5425 192.5241 192.5241 192.5209 192.4974 192.4743 192.4729 192.4438 192.4068 192.4065 192.4065 192.3980 192.3874 192.3758 192.3431 192.3427 192.3422 192.3418 192.3418 192.3330 192.2967 192.2596 192.2507 192.2029 192.1862 192.1862 192.1385 192.0899 192.0395 192.0395 192.0074 191.9946 191.9858 191.9623 191.9498 191.9380 191.9050 191.9050 191.8129 191.7387 191.6574 191.6185 191.6126 191.5864 191.5777 191.5671 191.5670 191.5557 191.5195 191.5195 191.4217 191.3059 191.2282 191.1958 191.1949 191.1624 191.1623 191.1521 191.1401 191.1273 191.1273 191.1270 191.0737 191.0187 190.9629 190.9629 190.9302 190.9144 190.9014 190.8727 190.8651 190.8447 190.8440 190.8358 190.8251 190.8140 190.8140 190.8135 190.7080 190.6003 190.5216 190.4919 190.4894 190.4598 190.4563 190.4470 190.4412 190.4342 190.4215 190.4215 190.3881 190.3877 190.3872 190.3868 190.3860 190.3292 190.3107 190.3104 190.3101 190.3098 190.2748 190.2715 190.2398 190.2307 190.2194 190.1972 190.1866 190.1742 190.1425 190.1425 190.0412 189.9046 189.7854 189.7654 189.7559 189.7445 189.7241 189.7233 189.7226 189.7218 189.7218 189.7054 189.6017 189.5381 189.4780 189.4602 189.4602 189.4570 189.4343 189.4106 189.2668 189.1305 189.0452 189.0452 189.0260 189.0174 189.0070 188.9957 188.9638 188.9635 188.9632 188.9629 188.9614 188.8633 188.8521 188.8082 188.7531 188.6990 188.6986 188.6983 188.6980 188.6980 188.6816 188.6816 188.6668 188.6666 188.6664 188.6662 188.6142 188.5460 188.4973 188.4765 188.4761 188.4761 188.4540 188.4306 188.4214 188.3659 188.3091 188.3088 188.3088 188.2884 188.2660 188.2427 188.2116 188.1800 188.1476 188.1135 188.0281 187.8859 187.8458 187.8029 187.7815 187.7809 187.7703 187.7601 187.7591 187.7479 187.7173 187.7173 187.6880 187.6579 187.6262 187.5954 187.5944 187.5400 187.4856 187.4313 187.3584 187.2482 187.1707 187.1707 187.1394 187.1389 187.1384 187.1378 187.1242 187.1033 187.0842 187.0768 187.0643 187.0426 187.0278 187.0278 186.9671 186.9048 186.8417 186.8417 186.6281 186.4786 186.3124 186.3124 186.2816 186.2500 186.2167 186.2167 186.1491 186.1084 186.0598 186.0297 185.9986 185.9667 185.9331 185.9331 185.8911 185.8491 185.8071 185.8071 185.7770 185.7460 185.7142 185.7134 185.6659 185.6127 185.5517 185.5517 185.5060 185.4594 185.4112 185.4112 185.2922 185.1870 185.1073 185.1073 185.0375 184.9965 184.9491 184.9491 184.8922 184.8345 184.7752 184.7752 184.6749 184.6234 184.5764 184.5764 184.5345 184.4925 184.4506 184.4506 184.1962 184.0557 183.8944 183.8944 183.7707 183.5478 183.3678 183.3678 183.2839 183.1985 183.1124 183.1124 182.9905 182.9000 182.7297 182.7297 182.6207 182.5274 182.4729 182.4729 182.4395 182.3726 182.3587 182.2779 182.2708 182.1972 182.1683 182.1683 182.0670 181.9177 181.7480 181.7189 181.6901 181.6895 181.6593 181.6276 181.6183 181.5430 181.3997 181.3997 181.3343 181.2689 181.2036 181.2036 181.1269 181.0734 180.9974 180.9653 180.8603 180.7810 180.7096 180.7096 180.6447 180.6190 180.5938 180.5798 180.5686 180.5434 180.5150 180.5150 180.4554 180.4508 180.4285 180.4281 180.4277 180.4273 180.4016 180.3918 180.3821 180.3723 180.3446 180.3260 180.3169 180.3057 180.2846 180.2414 180.0083 179.8316 179.6953 179.6187 179.5900 179.5842 179.5833 179.5767 179.5676 179.5606 179.5578 179.5296 179.5296 179.5069 179.4620 179.4202 179.3872 179.3608 179.3526 179.3321 179.3310 179.3173 179.3173 179.3122 179.3100 179.3062 179.2918 179.2845 179.2712 179.2710 179.2708 179.2707 179.2707 179.1969 179.1445 179.1443 179.1441 179.1439 179.1086 179.0494 179.0193 179.0187 179.0105 179.0092 178.9991 178.9889 178.9715 178.9326 178.9326 178.8477 178.7628 178.7348 178.6959 178.6780 178.6562 178.6495 178.6380 178.6322 178.6264 178.6149 178.6149 178.5410 178.4090 178.1352 178.1066 178.0368 177.9780 177.9657 177.9375 177.9363 177.9087 177.9082 177.8995 177.8919 177.8893 177.8782 177.8782 177.8374 177.8104 177.8055 177.8050 177.8045 177.8041 177.7878 177.7878 177.6645 177.5797 177.5058 177.5058 177.4923 177.4745 177.4675 177.4551 177.4349 177.4292 177.4071 177.3960 177.3909 177.3909 177.3849 177.3738 177.2469 177.1596 177.0934 177.0429 177.0151 177.0129 176.9866 176.9821 176.9747 176.9658 176.9565 176.9565 176.9561 176.9203 176.8559 176.7086 176.7066 176.6892 176.6808 176.6723 176.6710 176.6649 176.6622 176.6514 176.6514 176.6068 176.5960 176.5924 176.5893 176.5801 176.5248 176.4251 176.4100 176.4100 176.4069 176.3872 176.3667 176.3659 176.3262 176.2571 176.2567 176.2567 176.2397 176.2247 176.2208 176.2012 176.1913 176.1738 176.1650 176.1571 176.1571 176.1547 176.1436 176.1260 176.0711 175.9974 175.9249 175.9095 175.9095 175.8976 175.8702 175.8494 175.8429 175.7893 175.7293 175.7293 175.7024 175.6882 175.6844 175.6649 175.6463 175.6446 175.6030 175.6030 175.4998 175.4996 175.4994 175.4992 175.4391 175.3489 175.3214 175.3055 175.3055 175.2941 175.2661 175.2576 175.2365 175.1918 175.1532 175.1260 175.0980 175.0685 175.0273 175.0273 174.9750 174.9532 174.9527 174.9521 174.9515 174.9042 174.8617 174.8453 174.8416 174.8372 174.8313 174.2959 174.2957 174.2955 174.2954 174.2319 174.2239 174.2145 174.2043 174.2026 174.2022 174.2018 174.2015 174.0597 173.9785 173.9082 173.8216 173.8082 173.7947 173.7943 173.7943 173.7813 173.7698 173.7452 173.7207 173.7207 173.6946 173.6770 173.6578 173.6389 173.6380 173.5777 173.4846 173.4846 173.4292 173.3297 173.1944 173.1866 173.1804 173.1804 173.1774 173.1675 173.1532 173.1252 173.0957 173.0957 173.0925 173.0885 173.0831 173.0831 173.0128 172.9666 172.9050 172.9050 172.8599 172.8094 172.7100 172.7100 172.6973 172.6709 172.6437 172.6189 172.6150 172.5651 172.5024 172.5024 172.5021 172.5018 172.5015 172.4758 172.4554 172.4335 172.4109 172.4109 172.3877 172.3645 172.3413 172.3413 172.2100 172.1203 172.0685 172.0422 172.0152 171.9871 171.9871 171.9868 171.9617 171.9356 171.9081 171.9081 171.8782 171.8550 171.8423 171.8065 171.8004 171.7707 171.7452 171.7452 171.7153 171.6841 171.6521 171.6521 171.5631 171.4800 171.3961 171.3704 171.3068 171.2588 171.2202 171.2012 171.1903 171.1781 171.1656 171.1656 171.0744 170.9832 170.8922 170.8911 170.8669 170.8650 170.8567 170.8466 170.8382 170.8365 170.8365 170.8099 170.7809 170.7238 170.6661 170.6661 170.6487 170.6476 170.6318 170.6300 170.6152 170.6105 170.6105 170.5972 170.5368 170.4854 170.4125 170.4125 170.4121 170.3951 170.3767 170.3701 170.3576 170.3283 170.2512 170.2512 170.2219 170.1706 170.1186 170.0653 170.0303 169.8136 169.8026 169.7412 169.6785 169.6151 169.5394 169.5394 169.5302 169.5209 169.5117 169.5117 169.4958 169.4791 169.4610 169.4610 169.4254 169.3376 169.2281 169.2281 169.1947 169.1288 169.1254 169.0777 169.0293 168.9796 168.9796 168.9765 168.9727 168.9676 168.9553 168.9553 168.9431 168.9301 168.9158 168.9147 168.9076 168.8991 168.8909 168.8907 168.8905 168.8903 168.8903 168.8899 168.7949 168.7859 168.7199 168.6981 168.6539 168.6008 168.6008 168.5880 168.3198 168.0845 168.0720 168.0596 168.0472 167.9732 167.9327 167.9039 167.8737 167.8428 167.7507 167.7507 167.7256 167.6791 167.6326 167.5862 167.4693 167.4322 167.3944 167.3851 167.3552 167.0609 167.0486 167.0363 167.0334 167.0240 166.8589 166.8466 166.8335 166.8191 166.6868 166.3366 166.3258 166.2256 166.1255 166.0255 165.9743 165.9743 165.9227 165.8894 165.8562 165.8230 165.8002 165.7237 165.6957 165.6662 165.6362 165.5502 165.3995 165.3995 165.3751 165.3629 165.3501 165.3359 165.2252 165.2042 165.1832 165.1623 165.1262 165.0999 165.0849 165.0692 165.0522 164.9011 164.6585 164.6585 164.5958 164.4964 164.3877 164.3877 164.3406 164.3286 164.3159 164.3020 164.1512 164.0958 164.0839 164.0712 164.0573 163.9988 163.9751 163.9508 163.9252 163.8753 163.8636 163.8518 163.8401 163.7787 163.7631 163.7500 163.7463 163.7287 163.4367 163.4367 163.4129 163.4011 163.3893 163.3776 163.3587 163.2932 163.2697 163.2543 163.2455 163.2200 163.1946 163.1946 163.1708 163.1473 163.1427 163.1232 163.0993 163.0977 163.0753 163.0753 163.0513 163.0431 163.0242 163.0110 162.9959 162.9788 162.9788 162.9703 162.9668 162.9618 162.9533 162.9533 162.9293 162.9181 162.8973 162.8823 162.8652 162.8453 162.8453 162.8332 162.8104 162.8018 162.7931 162.7844 162.7121 162.6802 162.6482 162.6391 162.6163 162.5935 162.5382 162.4822 162.4249 162.3758 162.3188 161.9523 2.101893 2.101893 2.103183 2.103183 2.104424 2.104424 2.105568 2.023428 2.029936 2.062438 2.063674 2.064814 2.065905 2.082156 2.083448 2.084692 2.085839 2.170344 2.177494 2.120816 2.128324 2.121665 2.179248 2.179248 2.178582 2.177917 2.177252 2.177252 2.175508 2.173716 2.171826 2.171826 2.172450 2.166318 2.229950 2.191451 2.183256 2.182372 2.190814 2.347641 2.284857 2.251575 2.256116 2.279518 2.302919 2.373074 2.379569 2.373049 2.373049 2.378892 2.380174 2.374744 2.378215 2.378215 2.490011 2.419046 2.406907 2.406888 2.457267 2.457248 2.465686 2.474074 2.581448 2.583030 2.593864 2.577386 2.507483 2.512683 2.519981 2.573967 2.559432 2.572216 2.568946 2.559414 2.565628 2.559395 2.559395 2.562212 2.555155 2.550755 2.550457 2.550446 2.542423 2.550435 2.543272 2.545655 2.548039 2.550422 2.550422 2.552156 2.551059 2.549914 2.548672 2.553872 2.564688 2.575504 2.584942 2.582753 2.579078 2.578198 2.577270 2.576244 2.578175 2.579036 2.582499 2.582499 2.579897 2.580757 2.593125 2.595203 2.596799 2.594943 2.594634 2.594228 2.594211 2.595071 2.598536 2.598536 2.595931 2.596792 2.607613 2.616642 2.625575 2.625575 2.626206 2.621874 2.626787 2.627272 2.621619 2.625521 2.621316 2.625491 2.620917 2.625460 2.620899 2.622410 2.627174 2.623920 2.625430 2.625430 2.648707 2.657114 2.659602 2.659602 2.651148 2.646902 2.643226 2.643226 2.639525 2.640815 2.642056 2.643200 2.660677 2.681819 2.699890 2.699890 2.712202 2.724466 2.736634 2.736634 2.725976 2.711325 2.697651 2.697651 2.695040 2.698003 2.691996 2.688951 2.698258 2.685905 2.698464 2.698464 2.687619 2.690652 2.693686 2.696719 2.758271 2.790236 2.782064 2.773968 2.773728 2.775682 2.778218 2.780657 2.783049 2.773440 2.773055 2.773055 2.769153 2.765250 2.754196 2.761346 2.756079 2.757866 2.759604 2.759604 2.772161 2.771912 2.760207 2.771615 2.760762 2.771222 2.771222 2.768553 2.765786 2.762971 2.761220 2.761220 2.752435 2.745670 2.746865 2.746848 2.746830 2.735128 2.735977 2.739653 2.743280 2.746811 2.746811 2.749411 2.802346 2.824501 2.824040 2.834865 2.834865 2.824028 2.824016 2.828924 2.824003 2.821885 2.805982 2.807715 2.807715 2.802943 2.799904 2.796864 2.796847 2.799230 2.801614 2.803997 2.803997 2.807179 2.803973 2.806546 2.803949 2.803923 2.805865 2.805865 2.798680 2.791447 2.784117 2.784117 2.781499 2.784462 2.781857 2.782118 2.784711 2.782329 2.784912 2.784912 2.802721 2.822513 2.848707 2.861255 2.848683 2.859504 2.856465 2.853426 2.848658 2.850386 2.848633 2.848633 2.828757 2.809545 2.805354 2.805336 2.789083 2.805318 2.790799 2.795714 2.800531 2.805299 2.805299 2.807033 2.826507 2.845981 2.865454 2.865454 2.868037 2.865428 2.871055 2.874073 2.865401 2.873408 2.877092 2.871662 2.869866 2.865374 2.865374 2.867974 2.845316 2.825161 2.817542 2.804957 2.817524 2.804940 2.817506 2.809203 2.819232 2.813369 2.817488 2.817488 2.824621 2.827004 2.829388 2.831771 2.851049 2.882817 2.875070 2.876803 2.878537 2.880270 2.896504 2.914488 2.912737 2.897130 2.908601 2.904415 2.897756 2.900133 2.898382 2.898382 2.877339 2.855748 2.845963 2.845953 2.833379 2.845941 2.833361 2.837631 2.841804 2.845929 2.845929 2.848520 2.891082 2.912283 2.919474 2.930299 2.930299 2.919462 2.919450 2.919437 2.899574 2.876008 2.862678 2.862678 2.859850 2.857462 2.855073 2.852683 2.854399 2.856285 2.858074 2.859816 2.863635 2.865179 2.865975 2.865148 2.865118 2.859671 2.861557 2.863346 2.865088 2.865088 2.868762 2.868762 2.863337 2.864573 2.865712 2.866804 2.892771 2.916731 2.910050 2.910039 2.940594 2.940594 2.910027 2.910014 2.916662 2.892634 2.866606 2.868557 2.868557 2.866370 2.866085 2.865703 2.864819 2.865443 2.866019 2.866498 2.876973 2.895000 2.900588 2.900564 2.911387 2.915071 2.908773 2.900540 2.906110 2.903351 2.900517 2.900517 2.889168 2.877722 2.866227 2.864476 2.869893 2.869863 2.869833 2.869802 2.872386 2.881956 2.896744 2.896744 2.898460 2.901486 2.904463 2.907344 2.896493 2.905591 2.903566 2.896194 2.901444 2.899273 2.895797 2.895797 2.882914 2.869933 2.856903 2.856903 2.855291 2.860792 2.870907 2.870907 2.870665 2.870375 2.869987 2.869987 2.857741 2.852156 2.848444 2.845610 2.847752 2.849844 2.851840 2.851840 2.851816 2.851792 2.851768 2.851768 2.848870 2.845875 2.838280 2.842830 2.843389 2.847677 2.853356 2.853356 2.853106 2.852806 2.852410 2.852410 2.829901 2.805811 2.791126 2.791126 2.796520 2.801160 2.809022 2.809022 2.809631 2.810192 2.810656 2.810656 2.794578 2.787582 2.783670 2.783670 2.786897 2.790123 2.793349 2.793349 2.788796 2.778241 2.759873 2.759873 2.762794 2.765996 2.767584 2.767584 2.752302 2.736922 2.721494 2.721494 2.726287 2.730953 2.732972 2.732972 2.724456 2.715806 2.704866 2.704866 2.706797 2.704583 2.706749 2.706702 2.704250 2.706654 2.703820 2.703820 2.689145 2.670540 2.658714 2.658696 2.655862 2.659048 2.659303 2.659509 2.658332 2.662725 2.672809 2.672809 2.672770 2.672731 2.672692 2.672692 2.665856 2.659756 2.649165 2.646545 2.651402 2.657045 2.663511 2.663511 2.663472 2.666057 2.666042 2.663433 2.666027 2.666012 2.663394 2.663394 2.643494 2.620160 2.642539 2.644922 2.647306 2.649689 2.631687 2.625397 2.619107 2.612817 2.606516 2.604490 2.600215 2.602367 2.600195 2.601036 2.624461 2.653934 2.684325 2.690589 2.690572 2.705087 2.710504 2.700957 2.696779 2.690554 2.692503 2.690535 2.690535 2.673322 2.651279 2.641928 2.641683 2.635607 2.641389 2.637323 2.643607 2.640998 2.640998 2.643595 2.638747 2.639699 2.643583 2.645529 2.640103 2.641339 2.642479 2.643570 2.643570 2.681448 2.699402 2.700638 2.701777 2.702869 2.717366 2.739000 2.749600 2.753283 2.738976 2.746712 2.743728 2.740696 2.738952 2.738928 2.738928 2.717856 2.696784 2.695467 2.695443 2.675712 2.695419 2.677428 2.683481 2.697137 2.689485 2.695393 2.695393 2.726825 2.753503 2.770726 2.774392 2.764742 2.754737 2.758052 2.758035 2.744599 2.758017 2.745448 2.749713 2.759740 2.753880 2.757998 2.757998 2.832052 2.859115 2.840733 2.843758 2.846735 2.849616 2.864125 2.864125 2.850116 2.834589 2.818009 2.818009 2.815401 2.811858 2.818355 2.808218 2.804530 2.818604 2.804513 2.808776 2.818805 2.818805 2.812942 2.817060 2.865505 2.892311 2.909339 2.912202 2.911960 2.926702 2.911669 2.924732 2.921196 2.917563 2.911281 2.911281 2.913881 2.905078 2.887060 2.841781 2.854349 2.854338 2.842847 2.846735 2.854326 2.856273 2.850573 2.854314 2.854314 2.880581 2.956238 2.930822 2.905517 2.981505 3.006364 3.021681 3.030556 3.030556 3.021670 3.021657 3.021644 3.025817 3.018095 2.998171 3.000771 3.000771 2.993112 3.001121 2.987956 2.982750 3.001372 2.982733 2.988514 3.001575 3.001575 2.994198 2.999833 3.026151 3.063064 3.098014 3.105878 3.116703 3.116703 3.105861 3.105843 3.107997 3.105826 3.099291 3.090585 3.090585 3.087751 3.090928 3.087515 3.087229 3.091174 3.086847 3.091371 3.091371 3.120127 3.121363 3.122502 3.123594 3.148412 3.175498 3.173971 3.188264 3.188264 3.173954 3.173936 3.177438 3.173917 3.170020 3.164763 3.164745 3.164727 3.164708 3.168366 3.168366 3.187587 3.188038 3.191714 3.195341 3.198872 3.218738 3.233053 3.251896 3.252913 3.253833 3.254704 3.277763 3.278999 3.280138 3.281230 3.322578 3.324459 3.326243 3.327978 3.338812 3.341195 3.343579 3.345962 3.374692 3.379551 3.381961 3.379955 3.380588 3.381174 3.383621 3.383621 3.381662 3.391406 3.399192 3.406977 3.406977 3.403276 3.403265 3.403252 3.404973 3.403239 3.404428 3.404873 3.404873 3.414091 3.417405 3.414652 3.415513 3.419193 3.419193 3.416374 3.417235 3.423445 3.427600 3.431706 3.431706 3.430557 3.429310 3.428014 3.428014 3.426138 3.425434 3.425297 3.425297 3.428622 3.434882 3.449439 3.449439 3.445747 3.445730 3.445712 3.448866 3.445693 3.449280 3.451036 3.451036 3.452922 3.454712 3.456453 3.452969 3.451214 3.449410 3.447509 3.447509 3.449010 3.450512 3.452014 3.452014 3.452858 3.454693 3.457901 3.457883 3.457865 3.456113 3.456113 3.457847 3.450181 3.444152 3.438075 3.438075 3.441739 3.437815 3.441490 3.441194 3.437506 3.440800 3.437100 3.437100 3.434198 3.431200 3.428153 3.428153 3.428021 3.427171 3.423431 3.421464 3.424720 3.425820 3.428731 3.429874 3.429867 3.428703 3.425878 3.425878 3.408697 3.391517 3.374336 3.381703 3.370852 3.382922 3.373871 3.376842 3.384044 3.379717 3.379717 3.385116 3.379182 3.378549 3.377868 3.377868 3.380016 3.394108 3.391714 3.382114 3.389319 3.384115 3.384115 3.386923 3.383704 3.381719 3.376830 3.376830 3.379431 3.379419 3.379407 3.377067 3.379394 3.378892 3.383872 3.383872 3.386670 3.386635 3.386600 3.386564 3.381002 3.373511 3.371866 3.371600 3.371284 3.370872 3.367136 3.367136 3.365115 3.362998 3.360833 3.360833 3.360822 3.360811 3.360798 3.360798 3.350862 3.337471 3.328351 3.328351 3.319066 3.315441 3.317445 3.318705 3.319916 3.321029 3.321029 3.319879 3.318633 3.317337 3.314728 3.314728 3.311461 3.308146 3.304733 3.311883 3.311011 3.310139 3.302765 3.304057 3.305301 3.306449 3.306449 3.309266 3.306752 3.310061 3.309791 3.306958 3.309472 3.307116 3.307116 3.309058 3.296031 3.284222 3.283988 3.283707 3.283329 3.280517 3.276965 3.276078 3.275191 3.274302 3.266003 3.266003 3.267936 3.267029 3.266074 3.265022 3.258656 3.257763 3.256870 3.254410 3.255976 3.240383 3.240150 3.239868 3.238093 3.239491 3.231356 3.231123 3.230841 3.230462 3.220166 3.203744 3.207576 3.203604 3.199633 3.195661 3.191940 3.191940 3.191037 3.189496 3.187956 3.186415 3.181599 3.180060 3.179173 3.178285 3.177397 3.173033 3.160108 3.160108 3.161824 3.161591 3.161309 3.160929 3.154565 3.153676 3.152738 3.151703 3.145979 3.145374 3.144272 3.143121 3.141872 3.123264 3.101932 3.101932 3.091766 3.078058 3.070314 3.070314 3.065729 3.065496 3.065214 3.064834 3.046691 3.047565 3.047332 3.047050 3.046670 3.040127 3.038376 3.036624 3.034872 3.031152 3.030276 3.029401 3.028526 3.021980 3.021102 3.017745 3.020222 3.019343 2.992908 2.992908 2.994841 2.994607 2.994326 2.993948 2.989199 2.985651 2.984767 2.982629 2.983883 2.982997 2.974744 2.974744 2.976677 2.975784 2.973028 2.974844 2.970789 2.973806 2.965771 2.965771 2.969437 2.964881 2.967900 2.963990 2.966363 2.963099 2.963099 2.960926 2.964824 2.958753 2.956580 2.956580 2.960246 2.955462 2.958705 2.954296 2.957165 2.953033 2.953033 2.955624 2.951056 2.950183 2.949310 2.948437 2.942099 2.940558 2.939018 2.933654 2.937477 2.932910 2.931504 2.930002 2.928450 2.925597 2.921545 2.915252 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/spectrum5.xml000077500000000000000000005472201477224461000314130ustar00rootroot00000000000000 |9.983196146941719|9.980751037924213|9.978305928906709|9.975860819889203|9.973415710871697|9.970970601854193|9.968525492836687|9.966080383819182|9.963635274801677|9.96119016578417|9.958745056766666|9.95629994774916|9.953854838731655|9.95140972971415|9.948964620696644|9.946519511679139|9.944074402661634|9.941629293644128|9.939184184626624|9.936739075609118|9.934293966591612|9.931848857574108|9.929403748556602|9.926958639539096|9.924513530521592|9.922068421504086|9.91962331248658|9.917178203469076|9.91473309445157|9.912287985434066|9.90984287641656|9.907397767399054|9.90495265838155|9.902507549364044|9.900062440346538|9.897617331329034|9.895172222311528|9.892727113294022|9.890282004276518|9.887836895259012|9.885391786241506|9.882946677224002|9.880501568206496|9.878056459188992|9.875611350171486|9.87316624115398|9.870721132136476|9.86827602311897|9.865830914101464|9.86338580508396|9.860940696066454|9.858495587048948|9.856050478031444|9.853605369013938|9.851160259996433|9.848715150978927|9.846270041961422|9.843824932943917|9.841379823926411|9.838934714908905|9.836489605891401|9.834044496873895|9.83159938785639|9.829154278838885|9.82670916982138|9.824264060803875|9.82181895178637|9.819373842768863|9.816928733751359|9.814483624733853|9.812038515716347|9.809593406698843|9.807148297681337|9.804703188663831|9.802258079646327|9.799812970628821|9.797367861611317|9.794922752593811|9.792477643576305|9.7900325345588|9.787587425541295|9.785142316523789|9.782697207506285|9.780252098488779|9.777806989471273|9.775361880453769|9.772916771436263|9.770471662418759|9.768026553401253|9.765581444383747|9.763136335366243|9.760691226348737|9.75824611733123|9.755801008313727|9.75335589929622|9.750910790278715|9.74846568126121|9.746020572243705|9.7435754632262|9.741130354208694|9.738685245191188|9.736240136173684|9.733795027156178|9.731349918138672|9.728904809121168|9.726459700103662|9.724014591086156|9.721569482068652|9.719124373051146|9.71667926403364|9.714234155016136|9.71178904599863|9.709343936981126|9.70689882796362|9.704453718946114|9.70200860992861|9.699563500911104|9.697118391893598|9.694673282876094|9.692228173858588|9.689783064841082|9.687337955823578|9.684892846806072|9.682447737788568|9.680002628771062|9.677557519753556|9.675112410736052|9.672667301718546|9.67022219270104|9.667777083683536|9.66533197466603|9.662886865648524|9.66044175663102|9.657996647613514|9.65555153859601|9.653106429578504|9.650661320560998|9.648216211543494|9.645771102525988|9.643325993508482|9.640880884490977|9.638435775473472|9.635990666455966|9.633545557438461|9.631100448420955|9.628655339403451|9.626210230385945|9.62376512136844|9.621320012350935|9.61887490333343|9.616429794315923|9.61398468529842|9.611539576280913|9.609094467263407|9.606649358245903|9.604204249228397|9.601759140210893|9.599314031193387|9.596868922175881|9.594423813158377|9.591978704140871|9.589533595123365|9.587088486105861|9.584643377088355|9.582198268070849|9.579753159053345|9.577308050035839|9.574862941018335|9.572417832000829|9.569972722983323|9.567527613965819|9.565082504948313|9.562637395930807|9.560192286913303|9.557747177895797|9.55530206887829|9.552856959860787|9.55041185084328|9.547966741825775|9.54552163280827|9.543076523790765|9.54063141477326|9.538186305755755|9.535741196738249|9.533296087720744|9.530850978703238|9.528405869685733|9.525960760668228|9.523515651650722|9.521070542633217|9.518625433615712|9.516180324598206|9.513735215580702|9.511290106563196|9.50884499754569|9.506399888528186|9.50395477951068|9.501509670493174|9.49906456147567|9.496619452458164|9.494174343440658|9.491729234423154|9.489284125405648|9.486839016388144|9.484393907370638|9.481948798353132|9.479503689335628|9.477058580318122|9.474613471300616|9.472168362283112|9.469723253265606|9.4672781442481|9.464833035230596|9.46238792621309|9.459942817195586|9.45749770817808|9.455052599160574|9.45260749014307|9.450162381125564|9.447717272108058|9.445272163090554|9.442827054073048|9.440381945055542|9.437936836038038|9.435491727020532|9.433046618003026|9.430601508985522|9.428156399968016|9.425711290950511|9.423266181933005|9.4208210729155|9.418375963897995|9.41593085488049|9.413485745862983|9.41104063684548|9.408595527827973|9.40615041881047|9.403705309792963|9.401260200775457|9.398815091757953|9.396369982740447|9.393924873722941|9.391479764705437|9.389034655687931|9.386589546670425|9.384144437652921|9.381699328635415|9.37925421961791|9.376809110600405|9.374364001582899|9.371918892565395|9.369473783547889|9.367028674530383|9.364583565512879|9.362138456495373|9.359693347477867|9.357248238460363|9.354803129442857|9.352358020425353|9.349912911407847|9.34746780239034|9.345022693372837|9.34257758435533|9.340132475337825|9.33768736632032|9.335242257302815|9.332797148285309|9.330352039267805|9.327906930250299|9.325461821232793|9.323016712215288|9.320571603197783|9.318126494180278|9.315681385162772|9.313236276145267|9.310791167127762|9.308346058110256|9.30590094909275|9.303455840075246|9.30101073105774|9.298565622040234|9.29612051302273|9.293675404005224|9.29123029498772|9.288785185970214|9.286340076952708|9.283894967935204|9.281449858917698|9.279004749900192|9.276559640882688|9.274114531865182|9.271669422847676|9.269224313830172|9.266779204812666|9.26433409579516|9.261888986777656|9.25944387776015|9.256998768742646|9.25455365972514|9.252108550707634|9.24966344169013|9.247218332672624|9.244773223655118|9.242328114637614|9.239883005620108|9.237437896602604|9.234992787585098|9.232547678567592|9.230102569550088|9.227657460532582|9.225212351515076|9.222767242497572|9.220322133480066|9.21787702446256|9.215431915445055|9.21298680642755|9.210541697410044|9.20809658839254|9.205651479375033|9.20320637035753|9.200761261340023|9.198316152322517|9.195871043305013|9.193425934287507|9.190980825270001|9.188535716252497|9.186090607234991|9.183645498217487|9.181200389199981|9.178755280182475|9.176310171164971|9.173865062147465|9.17141995312996|9.168974844112455|9.166529735094949|9.164084626077443|9.161639517059939|9.159194408042433|9.156749299024927|9.154304190007423|9.151859080989917|9.149413971972413|9.146968862954907|9.144523753937401|9.142078644919897|9.13963353590239|9.137188426884885|9.13474331786738|9.132298208849875|9.129853099832369|9.127407990814865|9.124962881797359|9.122517772779855|9.120072663762349|9.117627554744843|9.115182445727338|9.112737336709833|9.110292227692327|9.107847118674822|9.105402009657316|9.10295690063981|9.100511791622306|9.0980666826048|9.095621573587295|9.09317646456979|9.090731355552284|9.08828624653478|9.085841137517274|9.083396028499768|9.080950919482264|9.078505810464758|9.076060701447252|9.073615592429748|9.071170483412242|9.068725374394738|9.066280265377232|9.063835156359726|9.061390047342222|9.058944938324716|9.05649982930721|9.054054720289706|9.0516096112722|9.049164502254694|9.04671939323719|9.044274284219684|9.041829175202178|9.039384066184674|9.036938957167168|9.034493848149664|9.032048739132158|9.029603630114652|9.027158521097148|9.024713412079642|9.022268303062136|9.019823194044632|9.017378085027126|9.014932976009622|9.012487866992116|9.01004275797461|9.007597648957105|9.0051525399396|9.002707430922094|9.00026232190459|8.997817212887083|8.995372103869578|8.992926994852073|8.990481885834567|8.988036776817061|8.985591667799557|8.983146558782051|8.980701449764545|8.978256340747041|8.975811231729535|8.973366122712031|8.970921013694525|8.96847590467702|8.966030795659515|8.96358568664201|8.961140577624505|8.958695468606999|8.956250359589493|8.953805250571989|8.951360141554483|8.948915032536977|8.946469923519473|8.944024814501967|8.941579705484461|8.939134596466957|8.936689487449451|8.934244378431945|8.93179926941444|8.929354160396935|8.926909051379429|8.924463942361925|8.922018833344419|8.919573724326915|8.917128615309409|8.914683506291903|8.912238397274399|8.909793288256893|8.907348179239387|8.904903070221883|8.902457961204377|8.900012852186872|8.897567743169366|8.89512263415186|8.892677525134356|8.89023241611685|8.887787307099345|8.88534219808184|8.882897089064334|8.880451980046828|8.878006871029324|8.875561762011818|8.873116652994312|8.870671543976808|8.868226434959302|8.865781325941798|8.863336216924292|8.860891107906786|8.858445998889282|8.856000889871776|8.85355578085427|8.851110671836766|8.84866556281926|8.846220453801756|8.84377534478425|8.841330235766744|8.83888512674924|8.836440017731734|8.833994908714228|8.831549799696724|8.829104690679218|8.826659581661712|8.824214472644208|8.821769363626702|8.819324254609196|8.816879145591692|8.814434036574186|8.81198892755668|8.809543818539176|8.80709870952167|8.804653600504166|8.80220849148666|8.799763382469154|8.79731827345165|8.794873164434144|8.79242805541664|8.789982946399133|8.787537837381628|8.785092728364123|8.782647619346617|8.780202510329111|8.777757401311607|8.775312292294101|8.772867183276595|8.770422074259091|8.767976965241585|8.76553185622408|8.763086747206575|8.76064163818907|8.758196529171563|8.75575142015406|8.753306311136553|8.750861202119049|8.748416093101543|8.745970984084037|8.743525875066533|8.741080766049027|8.738635657031521|8.736190548014017|8.733745438996511|8.731300329979007|8.728855220961501|8.726410111943995|8.72396500292649|8.721519893908985|8.719074784891479|8.716629675873975|8.714184566856469|8.711739457838963|8.709294348821459|8.706849239803953|8.704404130786447|8.701959021768943|8.699513912751437|8.697068803733933|8.694623694716427|8.69217858569892|8.689733476681416|8.68728836766391|8.684843258646405|8.6823981496289|8.679953040611394|8.67750793159389|8.675062822576384|8.672617713558878|8.670172604541374|8.667727495523868|8.665282386506362|8.662837277488858|8.660392168471352|8.657947059453846|8.655501950436342|8.653056841418836|8.65061173240133|8.648166623383826|8.64572151436632|8.643276405348814|8.64083129633131|8.638386187313804|8.6359410782963|8.633495969278794|8.631050860261288|8.628605751243784|8.626160642226278|8.623715533208774|8.621270424191268|8.618825315173762|8.616380206156258|8.613935097138752|8.611489988121246|8.609044879103742|8.606599770086236|8.60415466106873|8.601709552051226|8.59926444303372|8.596819334016214|8.59437422499871|8.591929115981204|8.589484006963698|8.587038897946194|8.584593788928688|8.582148679911183|8.579703570893678|8.577258461876172|8.574813352858667|8.572368243841161|8.569923134823656|8.567478025806151|8.565032916788645|8.562587807771141|8.560142698753635|8.55769758973613|8.555252480718625|8.55280737170112|8.550362262683613|8.54791715366611|8.545472044648603|8.543026935631097|8.540581826613593|8.538136717596087|8.535691608578581|8.533246499561077|8.530801390543571|8.528356281526067|8.525911172508561|8.523466063491055|8.521020954473551|8.518575845456045|8.516130736438539|8.513685627421035|8.511240518403529|8.508795409386025|8.506350300368519|8.503905191351013|8.501460082333509|8.499014973316003|8.496569864298497|8.494124755280993|8.491679646263487|8.48923453724598|8.486789428228477|8.48434431921097|8.481899210193465|8.47945410117596|8.477008992158455|8.474563883140949|8.472118774123444|8.469673665105939|8.467228556088434|8.464783447070928|8.462338338053423|8.459893229035918|8.457448120018412|8.455003011000908|8.452557901983402|8.450112792965896|8.447667683948392|8.445222574930886|8.44277746591338|8.440332356895876|8.43788724787837|8.435442138860864|8.43299702984336|8.430551920825854|8.428106811808348|8.425661702790844|8.423216593773338|8.420771484755832|8.418326375738328|8.415881266720822|8.413436157703318|8.410991048685812|8.408545939668306|8.406100830650802|8.403655721633296|8.40121061261579|8.398765503598286|8.39632039458078|8.393875285563276|8.39143017654577|8.388985067528264|8.38653995851076|8.384094849493254|8.381649740475748|8.379204631458244|8.376759522440738|8.374314413423232|8.371869304405728|8.369424195388222|8.366979086370716|8.364533977353211|8.362088868335706|8.359643759318201|8.357198650300695|8.35475354128319|8.352308432265685|8.34986332324818|8.347418214230673|8.34497310521317|8.342527996195663|8.34008288717816|8.337637778160653|8.335192669143147|8.332747560125643|8.330302451108137|8.327857342090631|8.325412233073127|8.322967124055621|8.320522015038115|8.318076906020611|8.315631797003105|8.3131866879856|8.310741578968095|8.308296469950589|8.305851360933083|8.303406251915579|8.300961142898073|8.298516033880569|8.296070924863063|8.293625815845557|8.291180706828053|8.288735597810547|8.286290488793043|8.283845379775537|8.28140027075803|8.278955161740527|8.27651005272302|8.274064943705515|8.27161983468801|8.269174725670505|8.266729616652999|8.264284507635494|8.261839398617989|8.259394289600483|8.256949180582978|8.254504071565473|8.252058962547967|8.249613853530462|8.247168744512956|8.244723635495452|8.242278526477946|8.23983341746044|8.237388308442936|8.23494319942543|8.232498090407924|8.23005298139042|8.227607872372914|8.22516276335541|8.222717654337904|8.220272545320398|8.217827436302894|8.215382327285388|8.212937218267882|8.210492109250378|8.208047000232872|8.205601891215366|8.203156782197862|8.200711673180356|8.19826656416285|8.195821455145346|8.19337634612784|8.190931237110336|8.18848612809283|8.186041019075324|8.18359591005782|8.181150801040314|8.178705692022808|8.176260583005304|8.173815473987798|8.171370364970294|8.168925255952788|8.166480146935282|8.164035037917778|8.161589928900272|8.159144819882766|8.156699710865261|8.154254601847756|8.15180949283025|8.149364383812745|8.14691927479524|8.144474165777734|8.14202905676023|8.139583947742723|8.137138838725217|8.134693729707713|8.132248620690207|8.129803511672703|8.127358402655197|8.124913293637691|8.122468184620187|8.120023075602681|8.117577966585177|8.115132857567671|8.112687748550165|8.110242639532661|8.107797530515155|8.10535242149765|8.102907312480145|8.100462203462639|8.098017094445133|8.095571985427629|8.093126876410123|8.090681767392617|8.088236658375113|8.085791549357607|8.083346440340101|8.080901331322597|8.07845622230509|8.076011113287587|8.07356600427008|8.071120895252575|8.06867578623507|8.066230677217565|8.063785568200059|8.061340459182555|8.058895350165049|8.056450241147544|8.054005132130039|8.051560023112533|8.049114914095028|8.046669805077522|8.044224696060017|8.041779587042512|8.039334478025006|8.0368893690075|8.034444259989996|8.03199915097249|8.029554041954984|8.02710893293748|8.024663823919974|8.02221871490247|8.019773605884964|8.017328496867458|8.014883387849954|8.012438278832448|8.009993169814942|8.007548060797438|8.005102951779932|8.002657842762428|8.000212733744922|7.997767624727416|7.995322515709911|7.992877406692406|7.9904322976749|7.987987188657395|7.98554207963989|7.983096970622384|7.98065186160488|7.978206752587374|7.975761643569869|7.973316534552364|7.970871425534858|7.968426316517353|7.965981207499848|7.963536098482342|7.961090989464838|7.958645880447332|7.956200771429826|7.953755662412322|7.951310553394816|7.948865444377311|7.9464203353598055|7.9439752263423|7.9415301173247945|7.9390850083072895|7.9366398992897835|7.9341947902722785|7.931749681254773|7.9293045722372675|7.926859463219763|7.924414354202257|7.921969245184752|7.919524136167247|7.917079027149741|7.914633918132236|7.912188809114731|7.909743700097225|7.90729859107972|7.904853482062215|7.902408373044709|7.899963264027205|7.897518155009699|7.895073045992194|7.892627936974689|7.890182827957183|7.887737718939678|7.885292609922173|7.882847500904667|7.880402391887162|7.877957282869657|7.875512173852151|7.873067064834647|7.870621955817141|7.868176846799636|7.865731737782131|7.863286628764625|7.86084151974712|7.858396410729615|7.855951301712109|7.853506192694604|7.851061083677099|7.848615974659593|7.8461708656420885|7.843725756624583|7.8412806476070775|7.8388355385895725|7.8363904295720666|7.8339453205545615|7.831500211537056|7.8290551025195505|7.8266099935020454|7.82416488448454|7.8217197754670345|7.81927466644953|7.816829557432024|7.814384448414518|7.811939339397014|7.809494230379508|7.807049121362003|7.804604012344498|7.802158903326992|7.799713794309487|7.797268685291982|7.794823576274476|7.792378467256971|7.789933358239466|7.78748824922196|7.785043140204456|7.78259803118695|7.780152922169445|7.77770781315194|7.775262704134434|7.772817595116929|7.770372486099424|7.767927377081918|7.765482268064413|7.763037159046908|7.760592050029402|7.758146941011898|7.755701831994392|7.753256722976887|7.750811613959382|7.748366504941876|7.745921395924371|7.743476286906866|7.74103117788936|7.738586068871855|7.73614095985435|7.733695850836844|7.7312507418193395|7.7288056328018335|7.7263605237843285|7.723915414766823|7.7214703057493175|7.719025196731812|7.716580087714307|7.714134978696801|7.711689869679296|7.709244760661791|7.706799651644285|7.704354542626781|7.701909433609275|7.69946432459177|7.697019215574265|7.694574106556759|7.692128997539254|7.689683888521749|7.687238779504243|7.684793670486738|7.682348561469233|7.679903452451727|7.677458343434223|7.675013234416717|7.672568125399212|7.670123016381707|7.667677907364201|7.665232798346696|7.662787689329191|7.660342580311685|7.65789747129418|7.655452362276675|7.653007253259169|7.650562144241665|7.648117035224159|7.645671926206653|7.643226817189149|7.640781708171643|7.638336599154138|7.635891490136633|7.633446381119127|7.631001272101622|7.6285561630841165|7.626111054066611|7.6236659450491056|7.6212208360316005|7.618775727014095|7.61633061799659|7.6138855089790844|7.611440399961579|7.608995290944074|7.606550181926568|7.604105072909063|7.601659963891558|7.599214854874052|7.596769745856547|7.594324636839042|7.591879527821536|7.589434418804032|7.586989309786526|7.584544200769021|7.582099091751516|7.57965398273401|7.577208873716505|7.574763764699|7.572318655681494|7.569873546663989|7.567428437646484|7.564983328628978|7.562538219611474|7.560093110593968|7.557648001576463|7.555202892558958|7.552757783541452|7.550312674523947|7.547867565506442|7.545422456488936|7.542977347471431|7.540532238453926|7.53808712943642|7.535642020418916|7.53319691140141|7.530751802383905|7.5283066933664|7.525861584348894|7.523416475331389|7.5209713663138835|7.518526257296378|7.5160811482788725|7.5136360392613675|7.5111909302438615|7.508745821226357|7.506300712208851|7.503855603191346|7.501410494173841|7.498965385156335|7.49652027613883|7.494075167121325|7.491630058103819|7.489184949086314|7.486739840068809|7.484294731051303|7.481849622033799|7.479404513016293|7.476959403998787|7.474514294981283|7.472069185963777|7.469624076946272|7.467178967928767|7.464733858911261|7.462288749893756|7.459843640876251|7.457398531858745|7.45495342284124|7.452508313823735|7.450063204806229|7.447618095788725|7.445172986771219|7.442727877753714|7.440282768736209|7.437837659718703|7.435392550701198|7.432947441683693|7.430502332666187|7.428057223648682|7.425612114631177|7.423167005613671|7.4207218965961665|7.418276787578661|7.4158316785611555|7.4133865695436505|7.4109414605261446|7.4084963515086395|7.4060512424911344|7.4036061334736285|7.4011610244561234|7.398715915438618|7.3962708064211125|7.393825697403608|7.391380588386102|7.388935479368597|7.386490370351092|7.384045261333586|7.381600152316081|7.379155043298576|7.37670993428107|7.374264825263565|7.37181971624606|7.369374607228554|7.36692949821105|7.364484389193544|7.362039280176039|7.359594171158534|7.357149062141028|7.354703953123523|7.352258844106018|7.349813735088512|7.347368626071007|7.344923517053502|7.342478408035996|7.340033299018492|7.337588190000986|7.335143080983481|7.332697971965976|7.33025286294847|7.327807753930965|7.32536264491346|7.322917535895954|7.320472426878449|7.318027317860944|7.315582208843438|7.3131370998259335|7.310691990808428|7.308246881790922|7.3058017727734175|7.3033566637559115|7.3009115547384065|7.298466445720901|7.2960213367033955|7.29357622768589|7.291131118668385|7.288686009650879|7.286240900633374|7.283795791615869|7.281350682598363|7.278905573580859|7.276460464563353|7.274015355545848|7.271570246528343|7.269125137510837|7.266680028493332|7.264234919475827|7.261789810458321|7.259344701440816|7.256899592423311|7.254454483405805|7.252009374388301|7.249564265370795|7.24711915635329|7.244674047335785|7.242228938318279|7.239783829300774|7.237338720283269|7.234893611265763|7.232448502248258|7.230003393230753|7.227558284213247|7.225113175195743|7.222668066178237|7.220222957160732|7.217777848143227|7.215332739125721|7.212887630108216|7.210442521090711|7.207997412073205|7.2055523030557|7.2031071940381945|7.200662085020689|7.198216976003184|7.1957718669856785|7.1933267579681734|7.190881648950668|7.1884365399331625|7.185991430915657|7.183546321898152|7.181101212880646|7.178656103863141|7.176210994845636|7.17376588582813|7.171320776810626|7.16887566779312|7.166430558775615|7.16398544975811|7.161540340740604|7.159095231723099|7.156650122705594|7.154205013688088|7.151759904670583|7.149314795653078|7.146869686635572|7.144424577618068|7.141979468600562|7.139534359583056|7.137089250565552|7.134644141548046|7.132199032530541|7.129753923513036|7.12730881449553|7.124863705478025|7.12241859646052|7.119973487443014|7.117528378425509|7.115083269408004|7.112638160390498|7.110193051372994|7.107747942355488|7.105302833337983|7.102857724320478|7.100412615302972|7.097967506285467|7.0955223972679615|7.093077288250456|7.0906321792329505|7.0881870702154455|7.0857419611979395|7.083296852180435|7.080851743162929|7.078406634145424|7.075961525127919|7.073516416110413|7.071071307092908|7.068626198075403|7.066181089057897|7.063735980040392|7.061290871022887|7.058845762005381|7.056400652987877|7.053955543970371|7.051510434952866|7.049065325935361|7.046620216917855|7.04417510790035|7.041729998882845|7.039284889865339|7.036839780847834|7.034394671830329|7.031949562812823|7.029504453795319|7.027059344777813|7.024614235760308|7.022169126742803|7.019724017725297|7.017278908707792|7.014833799690287|7.012388690672781|7.009943581655276|7.007498472637771|7.005053363620265|7.002608254602761|7.000163145585255|6.997718036567749|6.9952729275502445|6.992827818532739|6.9903827095152336|6.9879376004977285|6.9854924914802226|6.9830473824627175|6.9806022734452124|6.9781571644277065|6.975712055410202|6.973266946392696|6.9708218373751905|6.968376728357686|6.96593161934018|6.963486510322675|6.96104140130517|6.958596292287664|6.956151183270159|6.953706074252654|6.951260965235148|6.948815856217643|6.946370747200138|6.943925638182632|6.941480529165128|6.939035420147622|6.936590311130117|6.934145202112612|6.931700093095106|6.929254984077601|6.926809875060096|6.92436476604259|6.921919657025085|6.91947454800758|6.917029438990074|6.91458432997257|6.912139220955064|6.909694111937559|6.907249002920054|6.904803893902548|6.902358784885043|6.899913675867538|6.897468566850032|6.895023457832527|6.892578348815022|6.890133239797516|6.8876881307800115|6.885243021762506|6.8827979127450005|6.8803528037274955|6.8779076947099895|6.8754625856924845|6.873017476674979|6.8705723676574735|6.868127258639968|6.865682149622463|6.863237040604957|6.860791931587453|6.858346822569947|6.855901713552442|6.853456604534937|6.851011495517431|6.848566386499926|6.846121277482421|6.843676168464915|6.84123105944741|6.838785950429905|6.836340841412399|6.833895732394895|6.831450623377389|6.829005514359883|6.826560405342379|6.824115296324873|6.821670187307368|6.819225078289863|6.816779969272357|6.814334860254852|6.811889751237347|6.809444642219841|6.806999533202337|6.804554424184831|6.802109315167325|6.799664206149821|6.797219097132315|6.79477398811481|6.792328879097305|6.789883770079799|6.787438661062294|6.784993552044789|6.782548443027283|6.780103334009778|6.7776582249922726|6.775213115974767|6.772768006957262|6.7703228979397565|6.7678777889222514|6.765432679904746|6.7629875708872405|6.760542461869735|6.75809735285223|6.755652243834724|6.753207134817219|6.750762025799714|6.748316916782208|6.745871807764704|6.743426698747198|6.740981589729693|6.738536480712188|6.736091371694682|6.733646262677177|6.731201153659672|6.728756044642166|6.726310935624661|6.723865826607156|6.72142071758965|6.718975608572146|6.71653049955464|6.714085390537135|6.71164028151963|6.709195172502124|6.706750063484619|6.704304954467114|6.701859845449608|6.699414736432103|6.696969627414598|6.694524518397092|6.692079409379588|6.689634300362082|6.687189191344577|6.684744082327072|6.682298973309566|6.679853864292061|6.677408755274556|6.67496364625705|6.672518537239545|6.6700734282220395|6.667628319204534|6.665183210187029|6.6627381011695235|6.6602929921520175|6.657847883134513|6.655402774117007|6.652957665099502|6.650512556081997|6.648067447064491|6.645622338046986|6.643177229029481|6.640732120011975|6.638287010994471|6.635841901976965|6.633396792959459|6.630951683941955|6.628506574924449|6.626061465906944|6.623616356889439|6.621171247871933|6.618726138854428|6.616281029836923|6.613835920819417|6.611390811801912|6.608945702784407|6.606500593766901|6.604055484749397|6.601610375731891|6.599165266714386|6.596720157696881|6.594275048679375|6.59182993966187|6.589384830644365|6.586939721626859|6.584494612609354|6.582049503591849|6.579604394574343|6.577159285556839|6.574714176539333|6.572269067521828|6.5698239585043225|6.567378849486817|6.5649337404693116|6.5624886314518065|6.5600435224343006|6.5575984134167955|6.5551533043992904|6.5527081953817845|6.55026308636428|6.547817977346774|6.545372868329269|6.542927759311764|6.540482650294258|6.538037541276753|6.535592432259248|6.533147323241742|6.530702214224237|6.528257105206732|6.525811996189226|6.523366887171722|6.520921778154216|6.518476669136711|6.516031560119206|6.5135864511017|6.511141342084195|6.50869623306669|6.506251124049184|6.503806015031679|6.501360906014174|6.498915796996668|6.496470687979164|6.494025578961658|6.491580469944152|6.489135360926648|6.486690251909142|6.484245142891637|6.481800033874132|6.479354924856626|6.476909815839121|6.474464706821616|6.47201959780411|6.469574488786606|6.4671293797691|6.464684270751594|6.4622391617340895|6.459794052716584|6.4573489436990785|6.4549038346815735|6.4524587256640675|6.4500136166465625|6.447568507629057|6.4451233986115515|6.442678289594046|6.440233180576541|6.437788071559035|6.435342962541531|6.432897853524025|6.43045274450652|6.428007635489015|6.425562526471509|6.423117417454004|6.420672308436499|6.418227199418993|6.415782090401488|6.413336981383983|6.410891872366477|6.408446763348973|6.406001654331467|6.403556545313962|6.401111436296457|6.398666327278951|6.396221218261446|6.393776109243941|6.391331000226435|6.38888589120893|6.386440782191425|6.383995673173919|6.381550564156415|6.379105455138909|6.376660346121404|6.374215237103899|6.371770128086393|6.369325019068888|6.366879910051383|6.364434801033877|6.361989692016372|6.359544582998867|6.357099473981361|6.3546543649638565|6.3522092559463506|6.3497641469288455|6.3473190379113404|6.3448739288938345|6.3424288198763294|6.339983710858824|6.3375386018413185|6.335093492823813|6.332648383806308|6.330203274788802|6.327758165771298|6.325313056753792|6.322867947736286|6.320422838718782|6.317977729701276|6.315532620683771|6.313087511666266|6.31064240264876|6.308197293631255|6.30575218461375|6.303307075596244|6.30086196657874|6.298416857561234|6.295971748543728|6.293526639526224|6.291081530508718|6.288636421491213|6.286191312473708|6.283746203456202|6.281301094438697|6.278855985421192|6.276410876403686|6.273965767386181|6.271520658368676|6.26907554935117|6.266630440333666|6.26418533131616|6.261740222298655|6.25929511328115|6.256850004263644|6.254404895246139|6.251959786228634|6.249514677211128|6.247069568193623|6.2446244591761175|6.242179350158612|6.239734241141107|6.2372891321236015|6.234844023106096|6.232398914088591|6.229953805071085|6.22750869605358|6.225063587036075|6.222618478018569|6.220173369001064|6.217728259983559|6.215283150966053|6.212838041948549|6.210392932931043|6.207947823913538|6.205502714896033|6.203057605878527|6.200612496861022|6.198167387843517|6.195722278826011|6.193277169808506|6.190832060791001|6.188386951773495|6.185941842755991|6.183496733738485|6.18105162472098|6.178606515703475|6.176161406685969|6.173716297668464|6.171271188650959|6.168826079633453|6.166380970615948|6.163935861598443|6.161490752580937|6.159045643563433|6.156600534545927|6.154155425528421|6.151710316510917|6.149265207493411|6.146820098475906|6.1443749894584005|6.141929880440895|6.1394847714233896|6.1370396624058845|6.134594553388379|6.132149444370874|6.1297043353533684|6.1272592263358625|6.124814117318358|6.122369008300852|6.119923899283347|6.117478790265842|6.115033681248336|6.112588572230831|6.110143463213326|6.10769835419582|6.105253245178315|6.10280813616081|6.100363027143304|6.0979179181258|6.095472809108294|6.093027700090789|6.090582591073284|6.088137482055778|6.085692373038273|6.083247264020768|6.080802155003262|6.078357045985757|6.075911936968252|6.073466827950746|6.071021718933242|6.068576609915736|6.066131500898231|6.063686391880726|6.06124128286322|6.058796173845715|6.05635106482821|6.053905955810704|6.051460846793199|6.049015737775694|6.046570628758188|6.044125519740684|6.041680410723178|6.039235301705673|6.0367901926881675|6.034345083670662|6.0318999746531565|6.0294548656356515|6.0270097566181455|6.0245646476006405|6.022119538583135|6.0196744295656295|6.017229320548125|6.014784211530619|6.012339102513114|6.009893993495609|6.007448884478103|6.005003775460598|6.002558666443093|6.000113557425587|5.997668448408082|5.995223339390577|5.992778230373071|5.990333121355567|5.987888012338061|5.985442903320555|5.98299779430305|5.980552685285545|5.97810757626804|5.975662467250535|5.973217358233029|5.970772249215524|5.968327140198019|5.965882031180514|5.963436922163008|5.960991813145503|5.958546704127998|5.956101595110492|5.953656486092987|5.951211377075482|5.948766268057977|5.946321159040471|5.943876050022966|5.941430941005461|5.938985831987956|5.93654072297045|5.934095613952945|5.9316505049354395|5.929205395917934|5.9267602869004286|5.9243151778829235|5.9218700688654184|5.9194249598479125|5.9169798508304075|5.914534741812902|5.9120896327953965|5.909644523777891|5.907199414760386|5.904754305742881|5.902309196725375|5.89986408770787|5.897418978690365|5.89497386967286|5.892528760655354|5.890083651637849|5.887638542620344|5.885193433602838|5.882748324585333|5.880303215567828|5.877858106550323|5.875412997532817|5.872967888515312|5.870522779497807|5.868077670480302|5.865632561462796|5.863187452445291|5.860742343427786|5.85829723441028|5.855852125392775|5.85340701637527|5.850961907357765|5.848516798340259|5.846071689322754|5.843626580305249|5.841181471287743|5.838736362270238|5.836291253252733|5.833846144235228|5.831401035217722|5.828955926200217|5.826510817182712|5.8240657081652065|5.821620599147701|5.8191754901301955|5.8167303811126905|5.8142852720951845|5.8118401630776795|5.809395054060174|5.806949945042669|5.804504836025163|5.802059727007658|5.799614617990153|5.797169508972648|5.794724399955142|5.792279290937637|5.789834181920132|5.787389072902626|5.784943963885121|5.782498854867616|5.780053745850111|5.777608636832605|5.7751635278151|5.772718418797595|5.77027330978009|5.767828200762584|5.765383091745079|5.762937982727574|5.760492873710068|5.758047764692563|5.755602655675058|5.753157546657553|5.750712437640047|5.748267328622542|5.745822219605037|5.743377110587531|5.740932001570026|5.738486892552521|5.736041783535016|5.73359667451751|5.731151565500005|5.7287064564825|5.726261347464995|5.723816238447489|5.721371129429984|5.7189260204124786|5.716480911394973|5.7140358023774676|5.7115906933599625|5.7091455843424574|5.7067004753249515|5.7042553663074465|5.701810257289941|5.699365148272436|5.69692003925493|5.694474930237425|5.69202982121992|5.689584712202414|5.687139603184909|5.684694494167404|5.682249385149899|5.679804276132393|5.677359167114888|5.674914058097383|5.672468949079877|5.670023840062372|5.667578731044867|5.665133622027362|5.662688513009856|5.660243403992351|5.657798294974846|5.655353185957341|5.652908076939835|5.65046296792233|5.648017858904825|5.645572749887319|5.643127640869814|5.640682531852309|5.638237422834804|5.635792313817298|5.633347204799793|5.630902095782288|5.628456986764783|5.626011877747277|5.623566768729772|5.621121659712267|5.618676550694761|5.616231441677256|5.613786332659751|5.6113412236422455|5.60889611462474|5.6064510056072345|5.6040058965897295|5.6015607875722235|5.5991156785547185|5.596670569537213|5.594225460519708|5.591780351502202|5.589335242484697|5.586890133467192|5.584445024449687|5.581999915432181|5.579554806414676|5.577109697397171|5.574664588379665|5.57221947936216|5.569774370344655|5.56732926132715|5.564884152309644|5.562439043292139|5.559993934274634|5.557548825257129|5.555103716239623|5.552658607222118|5.550213498204613|5.547768389187107|5.545323280169602|5.542878171152097|5.540433062134592|5.537987953117086|5.535542844099581|5.533097735082076|5.530652626064571|5.528207517047065|5.52576240802956|5.523317299012055|5.520872189994549|5.518427080977044|5.515981971959539|5.513536862942034|5.511091753924528|5.508646644907023|5.5062015358895176|5.503756426872012|5.5013113178545066|5.4988662088370015|5.4964210998194964|5.4939759908019905|5.4915308817844855|5.48908577276698|5.486640663749475|5.484195554731969|5.481750445714464|5.479305336696959|5.476860227679453|5.474415118661948|5.471970009644443|5.469524900626938|5.467079791609432|5.464634682591927|5.462189573574422|5.459744464556917|5.457299355539411|5.454854246521906|5.452409137504401|5.449964028486895|5.44751891946939|5.445073810451885|5.44262870143438|5.440183592416874|5.437738483399369|5.435293374381864|5.432848265364358|5.430403156346853|5.427958047329348|5.425512938311843|5.423067829294337|5.420622720276832|5.418177611259327|5.415732502241822|5.413287393224316|5.410842284206811|5.408397175189306|5.4059520661718|5.403506957154295|5.40106184813679|5.3986167391192845|5.396171630101779|5.3937265210842735|5.3912814120667685|5.388836303049263|5.3863911940317575|5.383946085014252|5.381500975996747|5.379055866979241|5.376610757961736|5.374165648944231|5.371720539926726|5.36927543090922|5.366830321891715|5.36438521287421|5.361940103856705|5.359494994839199|5.357049885821694|5.354604776804189|5.352159667786683|5.349714558769178|5.347269449751673|5.344824340734168|5.342379231716662|5.339934122699157|5.337489013681652|5.335043904664146|5.332598795646641|5.330153686629136|5.327708577611631|5.325263468594125|5.32281835957662|5.320373250559115|5.31792814154161|5.315483032524104|5.313037923506599|5.310592814489094|5.308147705471588|5.305702596454083|5.303257487436578|5.300812378419073|5.298367269401567|5.295922160384062|5.2934770513665566|5.2910319423490515|5.2885868333315456|5.2861417243140405|5.2836966152965354|5.2812515062790295|5.2788063972615245|5.276361288244019|5.273916179226514|5.271471070209008|5.269025961191503|5.266580852173998|5.264135743156492|5.261690634138987|5.259245525121482|5.256800416103977|5.254355307086471|5.251910198068966|5.249465089051461|5.247019980033956|5.24457487101645|5.242129761998945|5.23968465298144|5.237239543963934|5.234794434946429|5.232349325928924|5.229904216911419|5.227459107893913|5.225013998876408|5.222568889858903|5.220123780841398|5.217678671823892|5.215233562806387|5.212788453788882|5.210343344771376|5.207898235753871|5.205453126736366|5.203008017718861|5.200562908701355|5.19811779968385|5.195672690666345|5.19322758164884|5.190782472631334|5.188337363613829|5.1858922545963235|5.183447145578818|5.1810020365613125|5.1785569275438075|5.176111818526302|5.1736667095087965|5.171221600491291|5.168776491473786|5.16633138245628|5.163886273438775|5.16144116442127|5.158996055403765|5.156550946386259|5.154105837368754|5.151660728351249|5.149215619333744|5.146770510316238|5.144325401298733|5.141880292281228|5.139435183263722|5.136990074246217|5.134544965228712|5.132099856211207|5.129654747193701|5.127209638176196|5.124764529158691|5.122319420141186|5.11987431112368|5.117429202106175|5.11498409308867|5.112538984071164|5.110093875053659|5.107648766036154|5.105203657018649|5.102758548001143|5.100313438983638|5.097868329966133|5.095423220948627|5.092978111931122|5.090533002913617|5.088087893896112|5.085642784878606|5.083197675861101|5.0807525668435956|5.0783074578260905|5.075862348808585|5.0734172397910795|5.0709721307735744|5.0685270217560685|5.0660819127385635|5.063636803721058|5.061191694703553|5.058746585686047|5.056301476668542|5.053856367651037|5.051411258633532|5.048966149616026|5.046521040598521|5.044075931581016|5.04163082256351|5.039185713546005|5.0367406045285|5.034295495510995|5.031850386493489|5.029405277475984|5.026960168458479|5.024515059440974|5.022069950423468|5.019624841405963|5.017179732388458|5.014734623370952|5.012289514353447|5.009844405335942|5.007399296318437|5.004954187300931|5.002509078283426|5.000063969265921|4.997618860248415|4.99517375123091|4.992728642213405|4.9902835331959|4.987838424178394|4.985393315160889|4.982948206143384|4.980503097125879|4.978057988108373|4.975612879090868|4.9731677700733625|4.970722661055857|4.9682775520383515|4.9658324430208465|4.963387334003341|4.9609422249858355|4.95849711596833|4.956052006950825|4.95360689793332|4.951161788915814|4.948716679898309|4.946271570880804|4.943826461863298|4.941381352845793|4.938936243828288|4.936491134810783|4.934046025793277|4.931600916775772|4.929155807758267|4.926710698740761|4.924265589723256|4.921820480705751|4.919375371688246|4.91693026267074|4.914485153653235|4.91204004463573|4.909594935618225|4.907149826600719|4.904704717583214|4.902259608565709|4.899814499548203|4.897369390530698|4.894924281513193|4.892479172495688|4.890034063478182|4.887588954460677|4.885143845443172|4.882698736425667|4.880253627408161|4.877808518390656|4.875363409373151|4.872918300355645|4.87047319133814|4.8680280823206346|4.8655829733031295|4.863137864285624|4.8606927552681185|4.8582476462506134|4.855802537233108|4.8533574282156025|4.850912319198097|4.848467210180592|4.846022101163086|4.843576992145581|4.841131883128076|4.838686774110571|4.836241665093065|4.83379655607556|4.831351447058055|4.828906338040549|4.826461229023044|4.824016120005539|4.821571010988034|4.819125901970528|4.816680792953023|4.814235683935518|4.811790574918013|4.809345465900507|4.806900356883002|4.804455247865497|4.802010138847991|4.799565029830486|4.797119920812981|4.794674811795476|4.79222970277797|4.789784593760465|4.78733948474296|4.784894375725455|4.782449266707949|4.780004157690444|4.777559048672939|4.775113939655433|4.772668830637928|4.770223721620423|4.767778612602918|4.765333503585412|4.762888394567907|4.7604432855504015|4.757998176532896|4.7555530675153905|4.7531079584978855|4.75066284948038|4.7482177404628745|4.745772631445369|4.743327522427864|4.740882413410359|4.738437304392853|4.735992195375348|4.733547086357843|4.731101977340337|4.728656868322832|4.726211759305327|4.723766650287822|4.721321541270316|4.718876432252811|4.716431323235306|4.713986214217801|4.711541105200295|4.70909599618279|4.706650887165285|4.704205778147779|4.701760669130274|4.699315560112769|4.696870451095264|4.694425342077758|4.691980233060253|4.689535124042748|4.687090015025243|4.684644906007737|4.682199796990232|4.679754687972727|4.677309578955221|4.674864469937716|4.672419360920211|4.669974251902706|4.6675291428852|4.665084033867695|4.66263892485019|4.660193815832684|4.657748706815179|4.6553035977976736|4.6528584887801685|4.650413379762663|4.6479682707451575|4.6455231617276525|4.643078052710147|4.6406329436926415|4.638187834675136|4.635742725657631|4.633297616640125|4.63085250762262|4.628407398605115|4.62596228958761|4.623517180570104|4.621072071552599|4.618626962535094|4.616181853517589|4.613736744500083|4.611291635482578|4.608846526465073|4.606401417447567|4.603956308430062|4.601511199412557|4.599066090395052|4.596620981377546|4.594175872360041|4.591730763342536|4.58928565432503|4.586840545307525|4.58439543629002|4.581950327272515|4.579505218255009|4.577060109237504|4.574615000219999|4.572169891202494|4.569724782184988|4.567279673167483|4.564834564149978|4.562389455132472|4.559944346114967|4.557499237097462|4.555054128079957|4.552609019062451|4.550163910044946|4.5477188010274405|4.5452736920099355|4.5428285829924295|4.5403834739749245|4.537938364957419|4.5354932559399135|4.533048146922408|4.530603037904903|4.528157928887398|4.525712819869892|4.523267710852387|4.520822601834882|4.518377492817377|4.515932383799871|4.513487274782366|4.511042165764861|4.508597056747355|4.50615194772985|4.503706838712345|4.50126172969484|4.498816620677334|4.496371511659829|4.493926402642324|4.491481293624818|4.489036184607313|4.486591075589808|4.484145966572303|4.481700857554797|4.479255748537292|4.476810639519787|4.474365530502282|4.471920421484776|4.469475312467271|4.467030203449766|4.46458509443226|4.462139985414755|4.45969487639725|4.457249767379745|4.454804658362239|4.452359549344734|4.449914440327229|4.4474693313097236|4.445024222292218|4.4425791132747126|4.4401340042572075|4.437688895239702|4.4352437862221965|4.4327986772046915|4.430353568187186|4.4279084591696805|4.425463350152175|4.42301824113467|4.420573132117164|4.418128023099659|4.415682914082154|4.413237805064649|4.410792696047143|4.408347587029638|4.405902478012133|4.403457368994628|4.401012259977122|4.398567150959617|4.396122041942112|4.393676932924606|4.391231823907101|4.388786714889596|4.386341605872091|4.383896496854585|4.38145138783708|4.379006278819575|4.37656116980207|4.374116060784564|4.371670951767059|4.369225842749554|4.366780733732048|4.364335624714543|4.361890515697038|4.359445406679533|4.357000297662027|4.354555188644522|4.352110079627017|4.349664970609512|4.347219861592006|4.344774752574501|4.342329643556996|4.33988453453949|4.337439425521985|4.3349943165044795|4.3325492074869745|4.3301040984694685|4.3276589894519635|4.325213880434458|4.3227687714169525|4.320323662399447|4.317878553381942|4.315433444364437|4.312988335346931|4.310543226329426|4.308098117311921|4.305653008294416|4.30320789927691|4.300762790259405|4.2983176812419|4.295872572224394|4.293427463206889|4.290982354189384|4.288537245171879|4.286092136154373|4.283647027136868|4.281201918119363|4.278756809101858|4.276311700084352|4.273866591066847|4.271421482049342|4.268976373031836|4.266531264014331|4.264086154996826|4.261641045979321|4.259195936961815|4.25675082794431|4.254305718926805|4.251860609909299|4.249415500891794|4.246970391874289|4.244525282856784|4.242080173839278|4.239635064821773|4.237189955804268|4.2347448467867626|4.232299737769257|4.2298546287517516|4.2274095197342465|4.224964410716741|4.2225193016992355|4.2200741926817305|4.217629083664225|4.2151839746467195|4.212738865629214|4.210293756611709|4.207848647594204|4.205403538576698|4.202958429559193|4.200513320541688|4.198068211524182|4.195623102506677|4.193177993489172|4.190732884471667|4.188287775454161|4.185842666436656|4.183397557419151|4.180952448401645|4.17850733938414|4.176062230366635|4.17361712134913|4.171172012331624|4.168726903314119|4.166281794296614|4.163836685279109|4.161391576261603|4.158946467244098|4.156501358226593|4.154056249209087|4.151611140191582|4.149166031174077|4.146720922156572|4.144275813139066|4.141830704121561|4.139385595104056|4.136940486086551|4.134495377069045|4.13205026805154|4.129605159034035|4.127160050016529|4.124714940999024|4.1222698319815185|4.1198247229640135|4.1173796139465075|4.1149345049290025|4.112489395911497|4.110044286893992|4.107599177876486|4.105154068858981|4.102708959841476|4.10026385082397|4.097818741806465|4.09537363278896|4.092928523771455|4.090483414753949|4.088038305736444|4.085593196718939|4.083148087701433|4.080702978683928|4.078257869666423|4.075812760648918|4.073367651631412|4.070922542613907|4.068477433596402|4.066032324578897|4.063587215561391|4.061142106543886|4.058696997526381|4.056251888508875|4.05380677949137|4.051361670473865|4.04891656145636|4.046471452438854|4.044026343421349|4.041581234403844|4.039136125386339|4.036691016368833|4.034245907351328|4.031800798333823|4.029355689316317|4.026910580298812|4.024465471281307|4.0220203622638016|4.019575253246296|4.0171301442287906|4.0146850352112855|4.01223992619378|4.0097948171762745|4.0073497081587695|4.004904599141264|4.0024594901237585|4.000014381106253|3.9975692720887483|3.9951241630712433|3.9926790540537374|3.9902339450362323|3.9877888360187272|3.9853437270012213|3.9828986179837162|3.980453508966211|3.978008399948706|3.9755632909312|3.973118181913695|3.97067307289619|3.968227963878685|3.965782854861179|3.963337745843674|3.960892636826169|3.958447527808663|3.956002418791158|3.953557309773653|3.951112200756148|3.948667091738642|3.946221982721137|3.943776873703632|3.941331764686127|3.938886655668621|3.936441546651116|3.9339964376336107|3.931551328616105|3.9291062195985997|3.9266611105810947|3.9242160015635896|3.9217708925460837|3.9193257835285786|3.9168806745110736|3.9144355654935676|3.9119904564760626|3.9095453474585575|3.9071002384410525|3.9046551294235465|3.9022100204060415|3.8997649113885364|3.8973198023710314|3.8948746933535254|3.8924295843360204|3.8899844753185153|3.8875393663010094|3.8850942572835043|3.8826491482659993|3.880204039248494|3.8777589302309883|3.8753138212134832|3.872868712195978|3.870423603178473|3.867978494160967|3.865533385143462|3.863088276125957|3.860643167108451|3.858198058090946|3.855752949073441|3.853307840055936|3.85086273103843|3.848417622020925|3.84597251300342|3.843527403985914|3.841082294968409|3.838637185950904|3.836192076933399|3.833746967915893|3.831301858898388|3.8288567498808828|3.8264116408633777|3.8239665318458718|3.8215214228283667|3.8190763138108617|3.8166312047933557|3.8141860957758507|3.8117409867583456|3.8092958777408406|3.8068507687233346|3.8044056597058296|3.8019605506883245|3.7995154416708194|3.7970703326533135|3.7946252236358085|3.7921801146183034|3.7897350056007975|3.7872898965832924|3.7848447875657873|3.7823996785482823|3.7799545695307764|3.7775094605132713|3.7750643514957662|3.772619242478261|3.7701741334607553|3.76772902444325|3.765283915425745|3.762838806408239|3.760393697390734|3.757948588373229|3.755503479355724|3.753058370338218|3.750613261320713|3.748168152303208|3.745723043285702|3.743277934268197|3.740832825250692|3.738387716233187|3.735942607215681|3.733497498198176|3.731052389180671|3.728607280163166|3.72616217114566|3.723717062128155|3.7212719531106497|3.718826844093144|3.7163817350756387|3.7139366260581337|3.7114915170406286|3.7090464080231227|3.7066012990056176|3.7041561899881126|3.7017110809706075|3.6992659719531016|3.6968208629355965|3.6943757539180915|3.6919306449005855|3.6894855358830805|3.6870404268655754|3.6845953178480704|3.6821502088305644|3.6797050998130594|3.6772599907955543|3.6748148817780484|3.6723697727605433|3.6699246637430383|3.667479554725533|3.6650344457080273|3.6625893366905222|3.660144227673017|3.657699118655512|3.655254009638006|3.652808900620501|3.650363791602996|3.64791868258549|3.645473573567985|3.64302846455048|3.640583355532975|3.638138246515469|3.635693137497964|3.633248028480459|3.630802919462954|3.628357810445448|3.625912701427943|3.623467592410438|3.621022483392932|3.618577374375427|3.6161322653579218|3.6136871563404167|3.6112420473229108|3.6087969383054057|3.6063518292879007|3.6039067202703956|3.6014616112528897|3.5990165022353846|3.5965713932178796|3.5941262842003736|3.5916811751828686|3.5892360661653635|3.5867909571478584|3.5843458481303525|3.5819007391128475|3.5794556300953424|3.5770105210778365|3.5745654120603314|3.5721203030428264|3.5696751940253213|3.5672300850078154|3.5647849759903103|3.5623398669728052|3.5598947579553|3.5574496489377943|3.555004539920289|3.552559430902784|3.550114321885278|3.547669212867773|3.545224103850268|3.542778994832763|3.540333885815257|3.537888776797752|3.535443667780247|3.532998558762742|3.530553449745236|3.528108340727731|3.525663231710226|3.52321812269272|3.520773013675215|3.51832790465771|3.515882795640205|3.513437686622699|3.510992577605194|3.5085474685876887|3.506102359570183|3.5036572505526777|3.5012121415351727|3.4987670325176676|3.4963219235001617|3.4938768144826566|3.4914317054651516|3.4889865964476465|3.4865414874301406|3.4840963784126355|3.4816512693951305|3.4792061603776245|3.4767610513601195|3.4743159423426144|3.4718708333251094|3.4694257243076034|3.4669806152900984|3.4645355062725933|3.4620903972550883|3.4596452882375823|3.4572001792200773|3.454755070202572|3.4523099611850663|3.4498648521675612|3.447419743150056|3.444974634132551|3.442529525115045|3.44008441609754|3.437639307080035|3.43519419806253|3.432749089045024|3.430303980027519|3.427858871010014|3.425413761992508|3.422968652975003|3.420523543957498|3.418078434939993|3.415633325922487|3.413188216904982|3.410743107887477|3.408297998869971|3.405852889852466|3.4034077808349608|3.4009626718174557|3.3985175627999498|3.3960724537824447|3.3936273447649397|3.3911822357474346|3.3887371267299287|3.3862920177124236|3.3838469086949186|3.3814017996774126|3.3789566906599076|3.3765115816424025|3.3740664726248975|3.3716213636073915|3.3691762545898865|3.3667311455723814|3.3642860365548763|3.3618409275373704|3.3593958185198654|3.3569507095023603|3.3545056004848544|3.3520604914673493|3.3496153824498442|3.347170273432339|3.3447251644148333|3.342280055397328|3.339834946379823|3.337389837362317|3.334944728344812|3.332499619327307|3.330054510309802|3.327609401292296|3.325164292274791|3.322719183257286|3.320274074239781|3.317828965222275|3.31538385620477|3.312938747187265|3.310493638169759|3.308048529152254|3.305603420134749|3.303158311117244|3.300713202099738|3.298268093082233|3.2958229840647277|3.2933778750472227|3.2909327660297167|3.2884876570122117|3.2860425479947066|3.2835974389772007|3.2811523299596956|3.2787072209421906|3.2762621119246855|3.2738170029071796|3.2713718938896745|3.2689267848721695|3.2664816758546644|3.2640365668371585|3.2615914578196534|3.2591463488021484|3.2567012397846424|3.2542561307671374|3.2518110217496323|3.2493659127321273|3.2469208037146213|3.2444756946971163|3.242030585679611|3.2395854766621053|3.2371403676446002|3.234695258627095|3.23225014960959|3.229805040592084|3.227359931574579|3.224914822557074|3.222469713539569|3.220024604522063|3.217579495504558|3.215134386487053|3.212689277469547|3.210244168452042|3.207799059434537|3.205353950417032|3.202908841399526|3.200463732382021|3.198018623364516|3.1955735143470108|3.193128405329505|3.1906832963119998|3.1882381872944947|3.1857930782769888|3.1833479692594837|3.1809028602419787|3.1784577512244736|3.1760126422069677|3.1735675331894626|3.1711224241719576|3.1686773151544516|3.1662322061369466|3.1637870971194415|3.1613419881019365|3.1588968790844305|3.1564517700669255|3.1540066610494204|3.1515615520319153|3.1491164430144094|3.1466713339969044|3.1442262249793993|3.1417811159618934|3.1393360069443883|3.1368908979268832|3.134445788909378|3.1320006798918723|3.129555570874367|3.127110461856862|3.124665352839357|3.122220243821851|3.119775134804346|3.117330025786841|3.114884916769335|3.11243980775183|3.109994698734325|3.10754958971682|3.105104480699314|3.102659371681809|3.100214262664304|3.097769153646798|3.095324044629293|3.092878935611788|3.090433826594283|3.087988717576777|3.085543608559272|3.0830984995417667|3.0806533905242617|3.0782082815067557|3.0757631724892507|3.0733180634717456|3.0708729544542397|3.0684278454367346|3.0659827364192296|3.0635376274017245|3.0610925183842186|3.0586474093667135|3.0562023003492085|3.0537571913317034|3.0513120823141975|3.0488669732966924|3.0464218642791874|3.0439767552616814|3.0415316462441764|3.0390865372266713|3.0366414282091663|3.0341963191916603|3.0317512101741553|3.02930610115665|3.026860992139145|3.0244158831216392|3.021970774104134|3.019525665086629|3.017080556069123|3.014635447051618|3.012190338034113|3.009745229016608|3.007300119999102|3.004855010981597|3.002409901964092|2.999964792946586|2.997519683929081|2.995074574911576|2.992629465894071|2.990184356876565|2.98773924785906|2.985294138841555|2.9828490298240498|2.980403920806544|2.9779588117890388|2.9755137027715337|2.9730685937540278|2.9706234847365227|2.9681783757190177|2.9657332667015126|2.9632881576840067|2.9608430486665016|2.9583979396489966|2.9559528306314915|2.9535077216139856|2.9510626125964805|2.9486175035789755|2.9461723945614695|2.9437272855439645|2.9412821765264594|2.9388370675089543|2.9363919584914484|2.9339468494739434|2.9315017404564383|2.9290566314389324|2.9266115224214273|2.9241664134039222|2.921721304386417|2.9192761953689113|2.916831086351406|2.914385977333901|2.911940868316396|2.90949575929889|2.907050650281385|2.90460554126388|2.902160432246374|2.899715323228869|2.897270214211364|2.894825105193859|2.892379996176353|2.889934887158848|2.887489778141343|2.885044669123838|2.882599560106332|2.880154451088827|2.877709342071322|2.875264233053816|2.872819124036311|2.8703740150188057|2.8679289060013007|2.8654837969837947|2.8630386879662897|2.8605935789487846|2.8581484699312796|2.8557033609137736|2.8532582518962686|2.8508131428787635|2.8483680338612576|2.8459229248437525|2.8434778158262475|2.8410327068087424|2.8385875977912365|2.8361424887737314|2.8336973797562264|2.8312522707387204|2.8288071617212154|2.8263620527037103|2.8239169436862053|2.8214718346686993|2.8190267256511943|2.8165816166336892|2.814136507616184|2.8116913985986782|2.809246289581173|2.806801180563668|2.804356071546162|2.801910962528657|2.799465853511152|2.797020744493647|2.794575635476141|2.792130526458636|2.789685417441131|2.787240308423626|2.78479519940612|2.782350090388615|2.77990498137111|2.777459872353604|2.775014763336099|2.772569654318594|2.7701245453010888|2.767679436283583|2.7652343272660778|2.7627892182485727|2.7603441092310668|2.7578990002135617|2.7554538911960567|2.7530087821785516|2.7505636731610457|2.7481185641435406|2.7456734551260356|2.7432283461085305|2.7407832370910246|2.7383381280735195|2.7358930190560145|2.7334479100385085|2.7310028010210035|2.7285576920034984|2.7261125829859933|2.7236674739684874|2.7212223649509824|2.7187772559334773|2.7163321469159722|2.7138870378984663|2.7114419288809612|2.708996819863456|2.7065517108459503|2.704106601828445|2.70166149281094|2.699216383793435|2.696771274775929|2.694326165758424|2.691881056740919|2.689435947723414|2.686990838705908|2.684545729688403|2.682100620670898|2.679655511653392|2.677210402635887|2.674765293618382|2.672320184600877|2.669875075583371|2.667429966565866|2.664984857548361|2.662539748530855|2.66009463951335|2.6576495304958447|2.6552044214783397|2.6527593124608337|2.6503142034433287|2.6478690944258236|2.6454239854083186|2.6429788763908126|2.6405337673733076|2.6380886583558025|2.6356435493382966|2.6331984403207915|2.6307533313032865|2.6283082222857814|2.6258631132682755|2.6234180042507704|2.6209728952332654|2.6185277862157603|2.6160826771982544|2.6136375681807493|2.6111924591632443|2.6087473501457383|2.6063022411282333|2.6038571321107282|2.601412023093223|2.5989669140757172|2.596521805058212|2.594076696040707|2.591631587023201|2.589186478005696|2.586741368988191|2.584296259970686|2.58185115095318|2.579406041935675|2.57696093291817|2.574515823900665|2.572070714883159|2.569625605865654|2.567180496848149|2.564735387830643|2.562290278813138|2.559845169795633|2.5574000607781278|2.554954951760622|2.5525098427431168|2.5500647337256117|2.5476196247081067|2.5451745156906007|2.5427294066730957|2.5402842976555906|2.5378391886380847|2.5353940796205796|2.5329489706030746|2.5305038615855695|2.5280587525680636|2.5256136435505585|2.5231685345330535|2.5207234255155484|2.5182783164980425|2.5158332074805374|2.5133880984630323|2.5109429894455264|2.5084978804280214|2.5060527714105163|2.5036076623930112|2.5011625533755053|2.4987174443580003|2.496272335340495|2.4938272263229893|2.491382117305484|2.488937008287979|2.486491899270474|2.484046790252968|2.481601681235463|2.479156572217958|2.476711463200453|2.474266354182947|2.471821245165442|2.469376136147937|2.466931027130431|2.464485918112926|2.462040809095421|2.459595700077916|2.45715059106041|2.454705482042905|2.4522603730254|2.4498152640078947|2.447370154990389|2.4449250459728837|2.4424799369553787|2.4400348279378727|2.4375897189203677|2.4351446099028626|2.4326995008853576|2.4302543918678516|2.4278092828503466|2.4253641738328415|2.4229190648153356|2.4204739557978305|2.4180288467803255|2.4155837377628204|2.4131386287453145|2.4106935197278094|2.4082484107103044|2.4058033016927993|2.4033581926752934|2.4009130836577883|2.3984679746402833|2.3960228656227773|2.3935777566052723|2.3911326475877672|2.388687538570262|2.3862424295527562|2.383797320535251|2.381352211517746|2.378907102500241|2.376461993482735|2.37401688446523|2.371571775447725|2.369126666430219|2.366681557412714|2.364236448395209|2.361791339377704|2.359346230360198|2.356901121342693|2.354456012325188|2.352010903307683|2.349565794290177|2.347120685272672|2.3446755762551668|2.342230467237661|2.3397853582201558|2.3373402492026507|2.3348951401851457|2.3324500311676397|2.3300049221501347|2.3275598131326296|2.3251147041151237|2.3226695950976186|2.3202244860801136|2.3177793770626085|2.3153342680451026|2.3128891590275975|2.3104440500100925|2.3079989409925874|2.3055538319750815|2.3031087229575764|2.3006636139400714|2.2982185049225654|2.2957733959050604|2.2933282868875553|2.2908831778700502|2.2884380688525443|2.2859929598350393|2.283547850817534|2.281102741800029|2.278657632782523|2.276212523765018|2.273767414747513|2.271322305730007|2.268877196712502|2.266432087694997|2.263986978677492|2.261541869659986|2.259096760642481|2.256651651624976|2.25420654260747|2.251761433589965|2.24931632457246|2.246871215554955|2.244426106537449|2.241980997519944|2.239535888502439|2.2370907794849337|2.234645670467428|2.2322005614499227|2.2297554524324177|2.2273103434149117|2.2248652343974067|2.2224201253799016|2.2199750163623966|2.2175299073448906|2.2150847983273856|2.2126396893098805|2.2101945802923755|2.2077494712748695|2.2053043622573645|2.2028592532398594|2.2004141442223535|2.1979690352048484|2.1955239261873434|2.1930788171698383|2.1906337081523324|2.1881885991348273|2.1857434901173223|2.183298381099817|2.1808532720823113|2.1784081630648062|2.175963054047301|2.1735179450297952|2.17107283601229|2.168627726994785|2.16618261797728|2.163737508959774|2.161292399942269|2.158847290924764|2.156402181907258|2.153957072889753|2.151511963872248|2.149066854854743|2.146621745837237|2.144176636819732|2.141731527802227|2.139286418784722|2.136841309767216|2.134396200749711|2.1319510917322058|2.1295059827147|2.1270608736971948|2.1246157646796897|2.1221706556621847|2.1197255466446787|2.1172804376271737|2.1148353286096686|2.1123902195921636|2.1099451105746576|2.1075000015571526|2.1050548925396475|2.1026097835221416|2.1001646745046365|2.0977195654871315|2.0952744564696264|2.0928293474521205|2.0903842384346154|2.0879391294171104|2.0854940203996044|2.0830489113820994|2.0806038023645943|2.0781586933470892|2.0757135843295833|2.0732684753120783|2.070823366294573|2.068378257277068|2.065933148259562|2.063488039242057|2.061042930224552|2.058597821207046|2.056152712189541|2.053707603172036|2.051262494154531|2.048817385137025|2.04637227611952|2.043927167102015|2.04148205808451|2.039036949067004|2.036591840049499|2.034146731031994|2.031701622014488|2.029256512996983|2.026811403979478|2.0243662949619727|2.021921185944467|2.0194760769269617|2.0170309679094567|2.0145858588919516|2.0121407498744457|2.0096956408569406|2.0072505318394356|2.0048054228219296|2.0023603138044246|1.9999152047869195|1.9974700957694145|1.9950249867519085|1.9925798777344035|1.9901347687168984|1.9876896596993925|1.9852445506818874|1.9827994416643815|1.9803543326468773|1.9779092236293714|1.9754641146118672|1.9730190055943613|1.9705738965768553|1.9681287875593512|1.9656836785418452|1.9632385695243393|1.9607934605068351|1.9583483514893292|1.9559032424718232|1.953458133454319|1.9510130244368131|1.948567915419309|1.946122806401803|1.943677697384297|1.941232588366793|1.938787479349287|1.936342370331781|1.9338972613142769|1.931452152296771|1.929007043279265|1.9265619342617608|1.9241168252442549|1.9216717162267507|1.9192266072092448|1.9167814981917388|1.9143363891742347|1.9118912801567287|1.9094461711392228|1.9070010621217186|1.9045559531042127|1.9021108440867067|1.8996657350692026|1.8972206260516966|1.8947755170341924|1.8923304080166865|1.8898852989991806|1.8874401899816764|1.8849950809641705|1.8825499719466645|1.8801048629291603|1.8776597539116544|1.8752146448941485|1.8727695358766443|1.8703244268591384|1.8678793178416324|1.8654342088241282|1.8629890998066223|1.8605439907891181|1.8580988817716122|1.8556537727541063|1.853208663736602|1.8507635547190961|1.8483184457015902|1.845873336684086|1.84342822766658|1.8409831186490742|1.83853800963157|1.836092900614064|1.8336477915965599|1.831202682579054|1.828757573561548|1.8263124645440438|1.823867355526538|1.821422246509032|1.8189771374915278|1.8165320284740218|1.814086919456516|1.8116418104390117|1.8091967014215058|1.8067515924040016|1.8043064833864957|1.8018613743689897|1.7994162653514856|1.7969711563339796|1.7945260473164737|1.7920809382989695|1.7896358292814636|1.7871907202639576|1.7847456112464535|1.7823005022289475|1.7798553932114434|1.7774102841939374|1.7749651751764315|1.7725200661589273|1.7700749571414214|1.7676298481239154|1.7651847391064113|1.7627396300889053|1.7602945210713994|1.7578494120538952|1.7554043030363893|1.7529591940188851|1.7505140850013792|1.7480689759838732|1.745623866966369|1.7431787579488631|1.7407336489313572|1.738288539913853|1.735843430896347|1.7333983218788411|1.730953212861337|1.728508103843831|1.7260629948263269|1.723617885808821|1.721172776791315|1.7187276677738108|1.7162825587563049|1.713837449738799|1.7113923407212948|1.7089472317037888|1.7065021226862829|1.7040570136687787|1.7016119046512728|1.6991667956337668|1.6967216866162627|1.6942765775987567|1.6918314685812526|1.6893863595637466|1.6869412505462407|1.6844961415287365|1.6820510325112306|1.6796059234937246|1.6771608144762205|1.6747157054587145|1.6722705964412086|1.6698254874237044|1.6673803784061985|1.6649352693886943|1.6624901603711884|1.6600450513536824|1.6575999423361782|1.6551548333186723|1.6527097243011664|1.6502646152836622|1.6478195062661563|1.6453743972486503|1.6429292882311461|1.6404841792136402|1.638039070196136|1.63559396117863|1.6331488521611242|1.63070374314362|1.628258634126114|1.625813525108608|1.623368416091104|1.620923307073598|1.618478198056092|1.6160330890385879|1.613587980021082|1.6111428710035778|1.6086977619860718|1.606252652968566|1.6038075439510617|1.6013624349335558|1.5989173259160498|1.5964722168985457|1.5940271078810397|1.5915819988635338|1.5891368898460296|1.5866917808285237|1.5842466718110195|1.5818015627935136|1.5793564537760076|1.5769113447585035|1.5744662357409975|1.5720211267234916|1.5695760177059874|1.5671309086884815|1.5646857996709755|1.5622406906534714|1.5597955816359654|1.5573504726184613|1.5549053636009553|1.5524602545834494|1.5500151455659452|1.5475700365484393|1.5451249275309333|1.5426798185134292|1.5402347094959232|1.5377896004784173|1.5353444914609131|1.5328993824434072|1.5304542734259012|1.528009164408397|1.5255640553908911|1.523118946373387|1.520673837355881|1.518228728338375|1.515783619320871|1.513338510303365|1.510893401285859|1.5084482922683549|1.506003183250849|1.503558074233343|1.5011129652158388|1.4986678561983329|1.4962227471808287|1.4937776381633228|1.4913325291458168|1.4888874201283127|1.4864423111108067|1.4839972020933008|1.4815520930757966|1.4791069840582907|1.4766618750407847|1.4742167660232806|1.4717716570057746|1.4693265479882704|1.4668814389707645|1.4644363299532586|1.4619912209357544|1.4595461119182485|1.4571010029007425|1.4546558938832383|1.4522107848657324|1.4497656758482265|1.4473205668307223|1.4448754578132164|1.4424303487957122|1.4399852397782062|1.4375401307607003|1.4350950217431961|1.4326499127256902|1.4302048037081843|1.42775969469068|1.4253145856731742|1.4228694766556682|1.420424367638164|1.417979258620658|1.415534149603154|1.413089040585648|1.410643931568142|1.4081988225506379|1.405753713533132|1.403308604515626|1.4008634954981218|1.398418386480616|1.39597327746311|1.3935281684456058|1.3910830594280998|1.3886379504105957|1.3861928413930897|1.3837477323755838|1.3813026233580796|1.3788575143405737|1.3764124053230677|1.3739672963055636|1.3715221872880576|1.3690770782705517|1.3666319692530475|1.3641868602355416|1.3617417512180356|1.3592966422005315|1.3568515331830255|1.3544064241655214|1.3519613151480154|1.3495162061305095|1.3470710971130053|1.3446259880954994|1.3421808790779934|1.3397357700604893|1.3372906610429833|1.3348455520254774|1.3324004430079732|1.3299553339904673|1.3275102249729631|1.3250651159554572|1.3226200069379512|1.320174897920447|1.3177297889029411|1.3152846798854352|1.312839570867931|1.310394461850425|1.3079493528329191|1.305504243815415|1.303059134797909|1.3006140257804049|1.298168916762899|1.295723807745393|1.2932786987278888|1.2908335897103829|1.288388480692877|1.2859433716753728|1.2834982626578668|1.2810531536403609|1.2786080446228567|1.2761629356053508|1.2737178265878466|1.2712727175703407|1.2688276085528347|1.2663824995353306|1.2639373905178246|1.2614922815003187|1.2590471724828145|1.2566020634653086|1.2541569544478026|1.2517118454302985|1.2492667364127925|1.2468216273952883|1.2443765183777824|1.2419314093602765|1.2394863003427723|1.2370411913252664|1.2345960823077604|1.2321509732902562|1.2297058642727503|1.2272607552552444|1.2248156462377402|1.2223705372202343|1.2199254282027283|1.2174803191852241|1.2150352101677182|1.212590101150214|1.210144992132708|1.2076998831152022|1.205254774097698|1.202809665080192|1.200364556062686|1.197919447045182|1.195474338027676|1.19302922901017|1.190584119992666|1.18813901097516|1.1856939019576558|1.1832487929401498|1.180803683922644|1.1783585749051397|1.1759134658876338|1.1734683568701278|1.1710232478526237|1.1685781388351177|1.1661330298176118|1.1636879208001076|1.1612428117826017|1.1587977027650975|1.1563525937475916|1.1539074847300856|1.1514623757125815|1.1490172666950755|1.1465721576775696|1.1441270486600654|1.1416819396425595|1.1392368306250535|1.1367917216075494|1.1343466125900434|1.1319015035725393|1.1294563945550333|1.1270112855375274|1.1245661765200232|1.1221210675025173|1.1196759584850113|1.1172308494675072|1.1147857404500012|1.1123406314324953|1.1098955224149911|1.1074504133974852|1.105005304379981|1.102560195362475|1.1001150863449691|1.097669977327465|1.095224868309959|1.092779759292453|1.090334650274949|1.087889541257443|1.085444432239937|1.0829993232224329|1.080554214204927|1.0781091051874228|1.0756639961699168|1.0732188871524109|1.0707737781349067|1.0683286691174008|1.0658835600998948|1.0634384510823907|1.0609933420648847|1.0585482330473788|1.0561031240298746|1.0536580150123687|1.0512129059948627|1.0487677969773586|1.0463226879598526|1.0438775789423484|1.0414324699248425|1.0389873609073366|1.0365422518898324|1.0340971428723265|1.0316520338548205|1.0292069248373164|1.0267618158198104|1.0243167068023045|1.0218715977848003|1.0194264887672944|1.0169813797497902|1.0145362707322843|1.0120911617147783|1.0096460526972741|1.0072009436797682|1.0047558346622623|1.002310725644758|0.9998656166272522|0.9974205076097462|0.994975398592242|0.9925302895747361|0.9900851805572319|0.987640071539726|0.98519496252222|0.9827498535047159|0.98030474448721|0.977859635469704|0.9754145264521998|0.9729694174346939|0.970524308417188|0.9680791993996838|0.9656340903821778|0.9631889813646737|0.9607438723471677|0.9582987633296618|0.9558536543121576|0.9534085452946517|0.9509634362771457|0.9485183272596416|0.9460732182421356|0.9436281092246297|0.9411830002071255|0.9387378911896196|0.9362927821721154|0.9338476731546095|0.9314025641371035|0.9289574551195994|0.9265123461020934|0.9240672370845875|0.9216221280670833|0.9191770190495774|0.9167319100320714|0.9142868010145673|0.9118416919970613|0.9093965829795572|0.9069514739620512|0.9045063649445453|0.9020612559270411|0.8996161469095352|0.8971710378920292|0.8947259288745251|0.8922808198570191|0.8898357108395132|0.887390601822009|0.8849454928045031|0.8825003837869971|0.880055274769493|0.877610165751987|0.8751650567344829|0.8727199477169769|0.870274838699471|0.8678297296819668|0.8653846206644609|0.8629395116469549|0.8604944026294508|0.8580492936119448|0.8556041845944389|0.8531590755769347|0.8507139665594288|0.8482688575419246|0.8458237485244187|0.8433786395069127|0.8409335304894086|0.8384884214719026|0.8360433124543967|0.8335982034368925|0.8311530944193866|0.8287079854018806|0.8262628763843765|0.8238177673668705|0.8213726583493663|0.8189275493318604|0.8164824403143545|0.8140373312968503|0.8115922222793444|0.8091471132618384|0.8067020042443342|0.8042568952268283|0.8018117862093224|0.7993666771918182|0.7969215681743123|0.7944764591568081|0.7920313501393021|0.7895862411217962|0.787141132104292|0.7846960230867861|0.7822509140692802|0.779805805051776|0.77736069603427|0.7749155870167641|0.7724704779992599|0.770025368981754|0.7675802599642498|0.7651351509467439|0.762690041929238|0.7602449329117338|0.7577998238942278|0.7553547148767219|0.7529096058592177|0.7504644968417118|0.7480193878242059|0.7455742788067017|0.7431291697891957|0.7406840607716916|0.7382389517541856|0.7357938427366797|0.7333487337191755|0.7309036247016696|0.7284585156841636|0.7260134066666595|0.7235682976491535|0.7211231886316476|0.7186780796141434|0.7162329705966375|0.7137878615791315|0.7113427525616274|0.7088976435441214|0.7064525345266173|0.7040074255091113|0.7015623164916054|0.6991172074741012|0.6966720984565953|0.6942269894390893|0.6917818804215852|0.6893367714040792|0.6868916623865733|0.6844465533690691|0.6820014443515632|0.679556335334059|0.6771112263165531|0.6746661172990471|0.672221008281543|0.669775899264037|0.6673307902465311|0.6648856812290269|0.662440572211521|0.659995463194015|0.6575503541765109|0.6551052451590049|0.6526601361415008|0.6502150271239948|0.6477699181064889|0.6453248090889847|0.6428797000714788|0.6404345910539728|0.6379894820364687|0.6355443730189627|0.6330992640014568|0.6306541549839526|0.6282090459664467|0.6257639369489425|0.6233188279314366|0.6208737189139306|0.6184286098964265|0.6159835008789205|0.6135383918614146|0.6110932828439104|0.6086481738264045|0.6062030648088985|0.6037579557913944|0.6013128467738884|0.5988677377563842|0.5964226287388783|0.5939775197213724|0.5915324107038682|0.5890873016863623|0.5866421926688563|0.5841970836513521|0.5817519746338462|0.5793068656163403|0.5768617565988361|0.5744166475813302|0.571971538563826|0.56952642954632|0.5670813205288141|0.5646362115113099|0.562191102493804|0.559745993476298|0.5573008844587939|0.554855775441288|0.552410666423782|0.5499655574062778|0.5475204483887719|0.545075339371266|0.5426302303537618|0.5401851213362558|0.5377400123187517|0.5352949033012457|0.5328497942837398|0.5304046852662356|0.5279595762487297|0.5255144672312237|0.5230693582137196|0.5206242491962136|0.5181791401787077|0.5157340311612035|0.5132889221436976|0.5108438131261934|0.5083987041086875|0.5059535950911815|0.5035084860736774|0.5010633770561714|0.4986182680386655|0.4961731590211613|0.4937280500036554|0.49128294098614944|0.4888378319686453|0.48639272295113933|0.48394761393363517|0.4815025049161292|0.4790573958986233|0.4766122868811191|0.4741671778636132|0.47172206884610723|0.46927695982860307|0.4668318508110971|0.4643867417935912|0.461941632776087|0.4594965237585811|0.4570514147410769|0.45460630572357097|0.452161196706065|0.44971608768856086|0.4472709786710549|0.444825869653549|0.4423807606360448|0.43993565161853887|0.43749054260103293|0.43504543358352876|0.4326003245660228|0.43015521554851865|0.4277101065310127|0.42526499751350677|0.4228198884960026|0.42037477947849666|0.4179296704609907|0.41548456144348656|0.4130394524259806|0.41059434340847467|0.4081492343909705|0.40570412537346456|0.4032590163559604|0.40081390733845446|0.3983687983209485|0.39592368930344435|0.3934785802859384|0.39103347126843246|0.3885883622509283|0.38614325323342236|0.3836981442159164|0.38125303519841225|0.3788079261809063|0.37636281716340036|0.3739177081458962|0.37147259912839026|0.3690274901108861|0.36658238109338015|0.3641372720758742|0.36169216305837004|0.3592470540408641|0.35680194502335816|0.354356836005854|0.35191172698834805|0.3494666179708421|0.34702150895333794|0.344576399935832|0.34213129091832784|0.3396861819008219|0.33724107288331595|0.3347959638658118|0.33235085484830584|0.3299057458307999|0.32746063681329574|0.3250155277957898|0.32257041877828385|0.3201253097607797|0.31768020074327374|0.3152350917257696|0.31278998270826364|0.3103448736907577|0.30789976467325353|0.3054546556557476|0.30300954663824164|0.3005644376207375|0.29811932860323154|0.2956742195857256|0.29322911056822143|0.2907840015507155|0.2883388925332113|0.2858937835157054|0.28344867449819944|0.28100356548069527|0.27855845646318933|0.2761133474456834|0.2736682384281792|0.2712231294106733|0.26877802039316734|0.2663329113756632|0.26388780235815723|0.26144269334065307|0.2589975843231471|0.2565524753056412|0.254107366288137|0.2516622572706311|0.24921714825312513|0.24677203923562097|0.24432693021811502|0.24188182120060908|0.23943671218310492|0.23699160316559897|0.2345464941480948|0.23210138513058887|0.22965627611308292|0.22721116709557876|0.22476605807807282|0.22232094906056687|0.2198758400430627|0.21743073102555677|0.21498562200805083|0.21254051299054666|0.21009540397304072|0.20765029495553478|0.2052051859380306|0.20276007692052467|0.2003149679030205|0.19786985888551456|0.19542474986800862|0.19297964085050445|0.1905345318329985|0.18808942281549257|0.1856443137979884|0.18319920478048246|0.18075409576297652|0.17830898674547235|0.1758638777279664|0.17341876871046225|0.1709736596929563|0.16852855067545036|0.1660834416579462|0.16363833264044025|0.1611932236229343|0.15874811460543015|0.1563030055879242|0.15385789657041826|0.1514127875529141|0.14896767853540815|0.146522569517904|0.14407746050039805|0.1416323514828921|0.13918724246538794|0.136742133447882|0.13429702443037606|0.1318519154128719|0.12940680639536595|0.12696169737786|0.12451658836035584|0.1220714793428499|0.11962637032534573|0.11718126130783979|0.11473615229033385|0.11229104327282968|0.10984593425532374|0.1074008252378178|0.10495571622031363|0.10251060720280769|0.10006549818530175|0.09762038916779758|0.09517528015029164|0.09273017113278748|0.09028506211528153|0.08783995309777559|0.08539484408027143|0.08294973506276548|0.08050462604525954|0.07805951702775538|0.07561440801024943|0.07316929899274349|0.07072418997523933|0.06827908095773338|0.06583397194022922|0.06338886292272328|0.060943753905217335|0.05849864488771317|0.05605353587020723|0.053608426852701285|0.05116331783519712|0.04871820881769118|0.046273099800185236|0.04382799078268107|0.04138288176517513|0.038937772747669186|0.03649266373016502|0.03404755471265908|0.03160244569515491|0.02915733667764897|0.02671222766014303|0.024267118642638863|0.02182200962513292|0.01937690060762698|0.016931791590122813|0.014486682572616871|0.01204157355511093|0.009596464537606764|0.007151355520100822|0.004706246502596656|0.002261137485090714|-1.83971532415228E-4|-0.0026290805499193937|-0.005074189567425336|-0.007519298584931278|-0.009964407602435443|-0.012409516619941385|-0.014854625637447327|-0.017299734654951493|-0.019744843672457435|-0.0221899526899616|-0.024635061707467543|-0.027080170724973485|-0.02952527974247765| |-0.004036283417140468|-0.004343061239674385|-0.004790913397364101|-0.00472915942010078|-0.004499890988384168|-0.0035714081689441476|-0.0028884924848972746|-0.003147641873354203|-0.0031239182046694665|-0.003358438440904073|-0.0031992544349965677|-0.002532637454626231|-0.0019228848404162547|-0.0021173827042895886|-0.001758992320113306|-0.0016059656022613814|-8.828464491457187E-4|-7.953767394149737E-4|-5.23912774846885E-4|-2.4230739465784035E-4|-4.692215691767297E-4|-1.792857404418998E-4|6.530347273065563E-4|3.7740553846557495E-4|1.376334977129736E-5|9.580015827653031E-5|3.125729171744637E-4|0.0010163147225857997|0.0010523529673816968|-1.5375110468199288E-4|-0.0019687023074180738|-0.002969261616449888|-0.0023966338272809113|-0.001520306859605807|-0.0013203760945069611|-0.0011644518293347633|-3.3484781219906336E-4|-5.945404907785425E-4|-6.376415071676053E-4|-4.2974248693800835E-4|-1.579163289548855E-4|1.4705052650386126E-4|8.78319031457792E-5|-7.434019843575745E-4|-0.0011716956976354463|-5.00551299577183E-4|-5.755253364892501E-4|-2.1025327742731886E-4|-2.462915222232159E-5|1.6298703676536346E-6|5.867533323553085E-5|-1.2314576111160794E-4|-3.784921187106774E-5|0.0016057845055538643|0.0030275747562703847|0.002773314978916418|0.003248693836148728|0.002231473630025343|0.0011030600454864765|-2.7780234933118616E-4|-8.183760212696416E-4|-4.3825403219131066E-5|8.929878647666748E-4|9.93677634146166E-4|5.487230237767236E-4|-9.659698378960541E-4|-0.0016604757112240196|-0.001551274396591226|-0.0010748089591138136|1.6298703676536347E-5|2.339769461120551E-4|-3.900823079917699E-4|7.875895809917396E-4|0.0020677622064299113|0.0015496445262235723|0.001427766442064584|0.002377980866406653|0.0010291725888195117|-8.855628997584748E-5|-0.001410200061435428|-0.002234190080638099|-0.002555274543065865|-0.0029574903304612787|-0.0021713495231296754|-0.0016653653223269805|-6.783882663589461E-4|-1.6787664786832435E-4|2.0663134327697746E-4|-7.1152896383457E-4|-0.0011025167553639253|-5.275347089972265E-4|0.0010816906339994623|6.606407890222733E-4|-5.090628448304852E-4|-0.0015530853636663967|-0.0013468162138044533|-2.7490480201091305E-4|-1.363658207603541E-4|-1.2061040720636896E-4|1.253189216018128E-4|5.874777191853767E-4|0.001188899884849568|3.328557484163756E-4|-7.233002498231797E-4|-0.0013837599421379358|-9.645210642359176E-4|-9.112786322258989E-4|-0.0015702895508805184|-0.002822935476776095|-0.0026287998063177958|-0.001851170544239495|-0.001032794522969853|-6.57381048286966E-5|-2.8939253861227866E-4|-3.8048418249336514E-4|-6.24059254103825E-4|-5.976191348063327E-6|-2.499134563735573E-4|-4.797251782127198E-4|-2.812431867740105E-4|3.058723389963321E-4|8.455405273972023E-4|0.0010103385312377365|4.1000294581864765E-4|-5.2916457936488E-4|-4.80268468335271E-4|2.124264379175237E-4|5.347785772979092E-4|-4.916775609088464E-4|-0.0012106314897516164|-2.3307146257446975E-4|4.0149140056534535E-4|-1.9015154289292405E-5|7.359770193493746E-4|9.572771959352347E-4|5.561479887849235E-4|0.002216080409886392|0.0026751605634421655|0.0010568803850696236|2.7092067444553747E-4|6.159099022655569E-4|9.407973955511813E-4|0.0011796639527661974|5.168500032537192E-4|-0.0010900210825452474|-0.0015054569295894073|-0.00147376500577392|-0.0010664785105680282|-5.094250382455194E-4|-2.3922875063005016E-4|-4.114517194787842E-4|-4.7121363295941747E-4|3.0062053447833705E-5|4.766465341849296E-4|0.001305163971075527|0.0017368985217962234|0.0012540946995557134|4.958427851817391E-4|9.804575744974198E-4|5.585022459826455E-4|9.779222205921808E-6|-6.639005297575805E-4|-0.001317478547186688|-0.00230644766693741|-7.52456819733428E-4|9.063890211229379E-4|3.7595676480543837E-4|-4.0692430179085746E-4|1.2151589074395431E-4|-3.7324031419268234E-4|-4.1290049313892077E-4|2.7345602835077646E-5|-3.1927349535259533E-4|-8.212735685899148E-4|-5.199286472815094E-4|-4.2014436143960357E-4|-3.2778504060589764E-4|-1.1952382696126653E-5|6.865376181972143E-4|3.80121989078331E-4|8.415563998318266E-4|9.800953810823855E-4|0.0015168660221629826|0.002465450576137398|0.0031295322026024955|0.003672822325153707|0.0031521692910421294|0.0027215213205665357|0.0016863725403989606|8.009907373480029E-4|-2.812431867740105E-4|-0.0011189965557479788|-5.184798736213729E-4|1.3220059648746148E-5|-3.893579211617016E-4|-2.493701662510061E-4|9.24317595167128E-4|6.217049969061031E-4|6.236970606887909E-4|9.101920519807964E-4|7.468428218003988E-4|1.9250580009064596E-4|-9.962129880514048E-4|5.613997933029186E-5|5.31518836562602E-4|0.0017700392192718472|0.0017676849620741253|4.971104621343586E-4|0.0014710485551611638|0.0017760154106199106|0.001202301041205831|4.924019477389147E-4|-8.073291221111004E-4|-7.957389328300078E-4|6.718687848883315E-5|5.498096040218261E-4|0.0011550348005438756|6.262324145940298E-4|6.392713775352589E-4|0.0013680045285839506|0.0012484807016226842|3.7034276687240923E-4|0.0010561559982395553|0.0011928840124149434|8.736105170623482E-4|0.0010460145826185993|0.0013598551767456824|0.002192900031324207|0.002095107809264989|0.0018899252396481479|0.0021487124346900414|0.0017265760094677502|2.218434667084114E-4|-1.222402775740226E-4|6.62632852804961E-4|0.0011941516893675629|9.266718523648498E-4|8.082346056486857E-4|6.521292437689709E-4|0.0011847346605766754|0.002223143181479558|0.0028162348985979638|0.002727316415207082|9.802764777899027E-4|-3.7450799114530184E-4|-6.691523342755755E-4|-1.3310608002504683E-4|-3.629178018642093E-4|-0.0016890889910117167|-0.0015835096105292646|7.225758629931114E-5|4.26301649495184E-4|1.633492301803976E-4|8.158406673644026E-4|9.907800868258927E-4|-9.407973955511813E-4|-0.001135295259424515|-0.0011758609219083389|-0.0010498176134764578|-0.001001102599154366|-9.025859902650795E-4|-9.388053317684936E-4|-0.0012258436131830502|-0.0018815947911023625|-0.0015693840673429332|-1.0829583109520816E-4|0.0013232736418272342|0.0015088977670322315|9.330102371279473E-4|0.0012904951377666445|0.0018116914620007734|9.565528091051665E-4|0.0013799569112800773|0.0017338198777684332|7.435830810650915E-4|-2.519055201562451E-4|5.074329744628315E-4|0.0013747051067620822|3.243442031630733E-4|3.4372155086739983E-4|7.982742867352468E-4|-1.3419266027014926E-4|-0.002491166308604822|-0.004975813135739029|-0.0026824044317428483|-3.281472340209318E-4|4.3825403219131066E-4|3.772244417580579E-4|6.809236202641851E-5|3.357532957366487E-4|4.196010713170524E-4|9.45143716531591E-4|0.0018040854002850564|0.0015029215756841682|4.7248130991203697E-4|-7.716530707302375E-4|-0.0014080269009452233|-9.01499410019977E-4|-5.03448846897456E-4|-3.368398759817512E-5|2.0228502229656777E-4|0.0015121575077675388|0.0011691603437302073|2.2148127329337723E-4|-2.6548777322002535E-4|1.6570348737811953E-4|5.36770641080597E-4|6.039575195694301E-4|0.0011168233952577739|4.132626865539549E-4|0.0010101574345302193|0.001132759905519276|2.7979441311387393E-4|-7.604250748641791E-4|-9.960318913438878E-6|0.0011287757779539006|5.918240401657864E-4|-0.0011419958376026466|-0.0015519987834212944|-6.67884657322956E-4|-7.915737085571152E-4|1.1535860268837391E-4|6.057684866446008E-4|-3.5730380393118015E-4|-5.871155257703427E-4|-6.8309678075439E-4|-8.446350438596168E-4|1.3220059648746146E-4|0.0012211350987876065|0.0016633732585442926|9.101920519807964E-4|7.13883221032292E-4|-3.498788389229802E-4|-0.0014504035305042177|-4.6541853831887125E-4|8.03888284668276E-4|0.002414381304617584|0.0030366295916462384|0.002643106446211644|0.0028238409603136803|0.002080620072663623|0.0018294389393374464|0.0020871395541342376|0.002150161208350178|0.0022714960023866157|0.0011807505330112998|7.182295420127017E-4|0.001304439584245459|0.0017171589806768625|0.0011916163354623239|9.045780540477672E-4|0.002088045037671823|0.002193805514861792|0.0011573890577415977|7.464806283853647E-4|8.24352212617705E-4|4.4386803012433986E-4|0.0010815095372919451|0.002293951994118732|0.0021807665519205633|0.0011179099755028762|0.0017861568262408664|0.0018779728569520212|0.001600532701035869|0.002320935403538776|0.0024160111749852377|0.0015058191230044413|5.441956060887969E-4|0.0013828544586003504|0.0026268077425351077|0.0017064742749333555|0.0015840529006518158|0.001707741951885975|0.0017419692296067014|0.002830360441784295|0.004054936378014726|0.00239609053715836|2.316226889143332E-4|-0.0010711870249634722|-7.117100605420871E-4|-1.6932542152846094E-4|-7.437641777726086E-4|-9.637966774058492E-4|-6.57562144994483E-4|-3.5042212904553145E-4|2.8540841104690313E-4|4.5835576672570547E-4|3.4335935745236567E-4|4.563637029430177E-5|-3.8845243762411627E-4|-0.0014605449461251737|-8.008096406404858E-4|1.4107433515579793E-4|2.2274895024599673E-4|1.707741951885975E-4|0.0013699965923666384|0.0017061120815183213|1.4831820345648076E-4|-5.557857953698895E-4|3.044235653361955E-4|3.6708302613710196E-4|4.6487524819632E-4|6.300354454518883E-4|5.717223056313916E-4|6.700578178131609E-5|-5.9943010188150344E-5|8.158406673644026E-4|0.001394444647881443|0.0015855016743119524|0.0018013689496723005|0.0015021971888541|0.0018759807931693336|0.0022459613666267085|0.0013026286171702883|9.150816630837573E-4|5.503528941443773E-4|5.420224455985921E-4|5.260859353370898E-4|1.6226264993529518E-4|3.9660178946238446E-5|-2.524488102787963E-4|-3.8283843969108707E-4|2.627713226072693E-4|0.0012803537221456884|0.0025663214422244063|0.0020585262743465405|0.0021874671300986946|0.0024620097386945736|0.0031936404370635383|0.0032251512641715088|0.0019869930748772978|0.001258259923828606|0.001014322658803112|0.0019065861367397183|0.0016007137977433862|5.575967624450602E-4|6.168153858031422E-4|5.364084476655629E-4|4.08373075450994E-4|7.778103587858179E-4|-4.3282113096579854E-5|-2.6367680614485466E-4|-0.0010626754797101697|-7.202216057953894E-4|-3.3919413317947306E-4|2.0282831241911898E-4|6.832778774619071E-4|-1.394444647881443E-4|-8.953421219643966E-4|-0.0010092519509926339|1.4216091540090035E-4|8.850196096359236E-4|4.5708808977308596E-4|-4.0692430179085746E-4|-3.6327999527924345E-4|5.215585176491631E-5|5.099683283680705E-4|9.136328894236207E-4|0.0011472476421206417|8.147540871193003E-4|2.457482321006647E-4|0.0010130549818504924|0.002073195107655423|0.0016755067379479365|0.0011677115700700707|7.021119350436824E-4|3.938853388496284E-4|4.945751082291196E-4|-4.851580794382319E-4|-0.00163077585119122|-0.0013245413187798537|2.1333192145510905E-4|0.001216969874514714|0.0019498682498362981|0.0013116834525461417|0.001836320614223095|0.0016124850837319958|0.0012805348188532056|0.0015299049851042116|0.0017551892892554474|0.0016550428099985075|0.0024879065678695147|0.0014190738001037646|6.696956243981267E-4|-2.6802312712526435E-5|2.1097766425738716E-4|-5.54880311832304E-4|-7.587952044965254E-5|6.836400708769412E-4|1.1572079610340806E-4|6.684279474455072E-4|0.0015807931599165085|0.0016535940363383709|0.001016858012708351|4.0565662483823796E-4|-2.817864768965617E-4|-4.2539616595759866E-4|-9.924099571935465E-4|-9.81363058035005E-4|-9.110975355183817E-4|-5.373139312031482E-4|-1.633492301803976E-4|-2.5661403455168894E-4|-8.087778957712369E-4|-9.621668070381957E-4|-0.0010836826977821499|-0.0010190311731985559|-0.001345367440144317|-8.736105170623482E-4|-2.806998966514593E-5|4.8370930577809536E-4|-1.5574316846468066E-5|3.641854788168288E-4|4.833471123630612E-4|2.0771792352207989E-4|-4.2575835937263277E-4|-4.016724972728624E-4|-5.384005114482507E-4|-7.642281057220375E-5|1.8888386594030456E-4|-4.306479704755937E-4|-0.0010691949611807844|-9.0131831331246E-4|-6.801992334341168E-4|-0.0011590189281092513|-5.1612561642365096E-5|0.0011262404240486616|2.529921004013475E-4|5.744387562441476E-4|0.0016970572461424678|0.0029652774888845124|0.001982103463774337|0.0016501531988955464|7.073637395616774E-4|-5.190231637439241E-4|-0.0010317079427247507|-8.513356220377485E-4|-0.0011689792470226902|-0.0012655037921292887|-6.700578178131609E-4|-3.793976022482627E-4|-9.947642143912684E-4|-1.2169698745147139E-4|3.0062053447833705E-4|1.1282324878313494E-4|3.138405941270832E-4|0.0015570694912317724|0.0015940132195652547|9.873392493830685E-4|-2.0663134327697746E-4|-3.053290488737809E-4|-7.939279657548371E-4|-0.0020766359450982478|-0.0023243762409816|-0.001846462029844051|-0.001772212379762052|-0.0014607260428326908|-0.001985182107802127|-0.0020789902022959697|-3.813896660309505E-4|0.001019936656736141|0.001014865948925663|-9.647021609434346E-4|-0.001998039974035839|-0.001152861640053671|-5.356840608354945E-4|-3.924365651894918E-4|3.862792771339114E-4|7.200405090878724E-4|9.208767577243036E-4|7.314496016614478E-4|4.5237957537764216E-4|8.382966590965194E-4|6.977656140632727E-4|7.783536489083691E-4|4.67410602101559E-4|0.0011452555783379539|0.0019114757478426792|0.0011845535638691583|3.017071147234395E-4|2.8468402421683486E-4|3.8157076273846757E-4|8.073291221111004E-4|4.617966041685298E-4|9.174359202814793E-4|5.233694847243338E-4|1.0648486402003746E-4|0.001171333504220412|0.0019498682498362981|6.619084659748927E-4|-4.364430651161399E-4|-2.3126049549929904E-4|0.0016264295302108104|0.0012004900741306604|-0.0012320009012386306|-0.001831431003120134|-6.926949062527947E-4|1.0068976937949121E-4|4.8606356297581723E-4|-2.0409598937173846E-4|-8.178327311470905E-4|-6.85813231367146E-4|-6.610029824373073E-4|-9.737569963192881E-4|-5.711790155088404E-4|6.130123549452837E-4|0.0010621321895876185|1.0413060682231555E-4|-5.970758446837814E-4|-0.0018633040236431385|-0.0015836907072367817|-4.54552735867847E-5|0.0017291113633729892|0.002241977239061333|0.00186692595779348|8.080535089411686E-4|7.861408073316031E-4|9.80638671204937E-4|0.0014810088740746026|0.0010112440147753217|3.810274726159164E-4|-8.373911755589341E-4|-6.159099022655569E-4|-3.7505128126785303E-4|3.803030857858481E-6|5.34054190467841E-4|-1.9214360667561183E-4|-0.0013290687364677805|-0.0016508775857256147|-1.3763349771297358E-4|7.004820646760287E-4|0.0014607260428326908|0.0013095102920559368|0.0014694186847935102|0.001304439584245459|7.877706776992568E-5|-1.2948414587470543E-4|3.2488749328562453E-4|5.248182583844703E-4|7.066393527316091E-4|2.2455991732116745E-4|-0.001071005928255955|-0.001258259923828606|-0.0016952462790672971|-6.845455544145265E-4|-4.235851988824279E-4|-2.627713226072693E-4|-0.0012830701727584446|-7.390556633771648E-4|8.52965492405402E-5|0.0016778609951456584|0.0021983329325497188|0.0013066127447356637|0.00108676134180994|0.0015907534788299474|0.002123358895637652|0.0022734880661693033|0.0025750140841852257|0.002427058074143779|0.0019422621881205813|8.636501981489093E-4|4.54552735867847E-5|-1.4161762527834914E-4|-5.492663138992749E-4|-1.3183840307242733E-4|-0.001055612708117004|-0.0021450905005397|-0.0017417881328991843|-0.002308258634012581|-0.002596202398964723|-0.00227801548385723|-0.0025713921500348843|-0.002398988084478633|-0.002326549401471805|-0.0020148819678349264|-0.001861855249983002|-0.0016246185631356397|-0.0015556207175716358|-8.538709759429875E-4|-6.380037005826394E-4|6.31665315819542E-4|9.141761795461719E-4|-2.1079656754987008E-4|-8.665477454691824E-4|7.225758629931114E-5|-2.720072546906399E-4|-0.0011552158972513928|-9.386242350609764E-4|-0.0013225492549971659|-0.001196868139980319|-7.901249348969786E-4|4.866068530983685E-4|9.149005663762402E-4|0.0015295427916891776|0.001962907212777527|7.62598235354384E-4|0.0013326906706181219|0.0019022398157593086|0.001597635153715596|7.385123732546136E-4|-5.988868117589522E-4|-5.691869517261526E-4|0.0015313537587643483|0.001338304668551151|0.0017253083325151307|0.0014257743782818961|2.9066021556489817E-4|-4.320967441357302E-4|-6.44704278760771E-4|-6.955924535730679E-4|-9.905989901183756E-4|-0.0011492397059033295|-0.0011774907922759924|-0.0014911502896955587|-0.0020074570028267265|-5.492663138992749E-4|7.808890028136081E-4|0.0010641242533703063|0.0012137101337794066|0.0012475752180850987|9.777411238846637E-4|2.5462197076900117E-4|-3.10761950099293E-4|-5.038110403124902E-4|-8.96428702209499E-5|-4.762843407698955E-4|-0.0014775680366317784|-0.0020980053565852618|-0.003487741490071261|-0.0028549895940066165|-0.0015351567896222068|-8.982396692846698E-4|-5.103305217831047E-4|7.213081860404919E-4|7.750939081730618E-4|-1.4542065613620762E-4|1.6679006762322196E-4|8.674532290067677E-5|-5.065274909252462E-4|-9.623479037457127E-4|3.174625282774246E-4|5.336919970528068E-4|6.543024042591758E-4|0.0012606141810263278|1.8091561080955343E-4|-8.917201878140552E-4|-0.0016756878346554534|-7.294575378787601E-4|4.985592357944951E-4|-4.0058591702776E-4|-0.0012100881996290652|-0.0012580788271210888|-0.0016396495898595563|-0.0015903912854149133|-8.384777558040365E-4|-8.337692414085926E-4|-4.925830444464318E-4|-4.346320980409692E-5|1.1662627964099342E-4|0.0010619510928801014|0.003077014157422545|0.003915491913226581|0.0021487124346900414|8.250765994477732E-4|-1.2169698745147139E-4|-8.761458709675872E-4|-0.001049998710183975|-6.979467107707897E-4|1.0413060682231555E-4|-2.3723668684736238E-5|-2.969986003279956E-4|-2.062691498619433E-4|-0.001322368158289649|-0.0023457456524686145|-0.003055463649228014|-0.002082793233153828|-0.0014498602403816665|-0.0011390982902823735|-7.070015461466433E-4|-5.769741101493866E-4|-0.0014038616766723305|-0.0010845881813197353|1.7656928982914374E-4|0.0011430824178477491|0.0017455911637570428|0.0015614158122121819|0.001209544909506514|8.292418237206659E-4|-4.0149140056534535E-4|-6.209806100760348E-4|-1.9449786387333373E-4|7.109856737120188E-4|9.250419819971962E-4|7.624171386468668E-4|7.316306983689649E-4|0.0011561213807889782|0.0014685132012559248|0.002532275261211197|0.001921436066756118|5.518016678045138E-4|5.684625648960844E-4|8.506112352076802E-4|-2.7544809213346424E-4|-0.001417625026443628|-0.001338304668551151|-3.18549108522527E-4|2.2944952842412835E-4|-7.501025625357061E-4|-0.0023223841771989125|-0.0017075608551784579|-5.324243201001873E-5|-2.555274543065865E-4|-2.3126049549929904E-4|-6.664358836628194E-5|-3.227143327954197E-4|-8.075102188186174E-4|-0.0016666329992796|-0.0010154092390482143|-6.182641594632787E-4|-0.0012439532839347573|-7.16418574937531E-4|5.215585176491631E-5|-3.4607580806512176E-4|2.9373885959268836E-4|5.376761246181824E-4|-1.66971164330739E-4|-9.346401074956009E-4|-0.001026999428329307|3.6219341503414103E-7|1.2477563147926158E-4|-4.4006499926648135E-4|-7.783536489083691E-4|-1.41255431863315E-5|-7.696610069475497E-4|-9.455059099466251E-4|-4.1742791082684754E-4|-1.756638062915584E-4|5.637540505006405E-4|-2.5407868064644993E-4|3.844683100587407E-4|8.482569780099583E-4|-2.9391995630020544E-4|-1.1101228170796422E-4|4.3028577706055954E-4|1.0503609035990089E-4|1.4632613967379297E-4|0.0010190311731985559|8.417374965393438E-4|-2.6802312712526435E-5|-5.34054190467841E-4|-1.3473595039270047E-4|-5.391248982783189E-4|-9.288450128550547E-4|-4.2702603632525227E-4|1.2187808415898845E-4|-4.5437163916032993E-4|-0.002123721089052686|-0.001967253533757937|-7.854164205015348E-4|-2.9518763325282493E-5|-7.714719740227204E-5|-3.145649809571515E-4|-5.454632830414164E-4|-6.725931717183999E-4|-4.576313798956372E-4|2.383232670924648E-4|6.635383363425463E-4|8.55319749603124E-4|8.781379347502749E-4|0.0011984980103479726|1.983008947311922E-4|3.1528936778721974E-4|4.7700872759996374E-4|7.048283856564384E-4|-9.398919120135959E-5|-2.38866557215016E-4|-6.017843590792253E-4|-4.1416817009154027E-4|-8.234467290801197E-4|-0.0012292844506258747|-9.149005663762402E-4|-2.8395963738676655E-4|-6.157288055580397E-4|-0.0015132440880126412|-0.0011510506729785002|-6.716876881808145E-4|-8.221790521275002E-4|-7.75637198295613E-4|3.8845243762411627E-4|0.001628240497285981|0.002805187999439422|0.0024678048333351198|6.117446779926642E-4|-5.637540505006405E-4|-8.929878647666748E-4|-9.179792104040304E-4|1.8508083508244607E-4|2.462915222232159E-4|-0.0017242217522700283|-0.002933042274946474|-0.002455128063808925|-0.001199041300470524|-0.001633311205096459|-0.002099091936830364|-0.0019763083691337903|-0.002084966393644033|-0.0018200219105465587|-0.0010595968356823795|-0.001389373940070965|-0.0014286719256021692|-0.0019150976819930206|-0.0017399771658240136|-5.478175402391383E-4|1.0775254097265695E-4|0.0012591654073661914|0.0018350529372704754|0.001948962766298713|0.0013940824544664088|5.412980587685237E-4|0.001042935938590809|9.741191897343223E-4|-0.0017867001163634176|-0.0027153640325109554|-0.002131146054060886|-0.0020210392558905068|-0.0019484194761761617|-0.0017761965073274275|-0.0018296200360449634|-0.0019275933548116985|-0.002070659753750184|-0.0018939093672135235|-0.0020333538320016675|-2.7218835139815697E-4|-3.49335548800429E-4|-6.271378981316152E-4|-5.478175402391383E-4|-9.105542453958306E-4|-0.002396452730573394|-0.0035065755476530363|-0.002560164154168826|-0.0021383899223615687|-0.00236765835407818|-0.0025397002262193967|-0.0026586807630581124|-0.0026418387692590246|-0.00209999742036795|-0.00157699012905865|-0.001256267860045918|-0.0011668060865324852|-0.0022097420251232943|-0.00325720538140203|-0.002929239244088616|-0.0026177529071592545|-0.002747599246448994|-0.003435947831721379|-0.003880540248675787|-0.0031012811162298326|-0.0035402595352512114|-0.0030449600401920235|-0.00322569455429406|-0.003915673009934098|-0.0033687609532325456|-0.0016528696495083026|-3.554928368560094E-4|-7.968255130751102E-6|5.592266328127137E-4|5.364084476655629E-4|1.2821646892208593E-4|-4.232230054673938E-4|-9.972995682965074E-4|-9.237743050445767E-4|-4.250339725425645E-4|-0.0018881142725729772|-0.0021610270108012026|-0.001613028373854547|-0.0017023090506604627|-0.0016650031289119464|-0.00262481567875242|-0.0028310848286143635|-0.002023031319673195|-0.0011340275824718955|-6.37098217045054E-4|-0.0019623639226549762|-0.0018482729969192216|-5.295267727799142E-4|-6.635383363425463E-4|-7.901249348969786E-4|-2.7381822176581063E-4|-0.001666270805864566|-0.0028109830940799686|-0.002505835141913705|-0.0025239448126654117|-0.00324362312833825|-0.0032217104267286845|-0.0011255160372185932|-0.0011338464857643786|-0.002316589082558366|-0.0024160111749852377|-0.00245730122429913|-0.0019409945111679618|-0.001317659643894205|-0.0010280860085744093|-6.91065035885141E-4|-3.1909239864507825E-4|5.105116184906217E-4|0.002618839487404357|0.0069816402681981025|0.016495374700899883|0.024435922035400875|0.01376262538446729|0.005512945970234661|0.0012703934032322498|-7.825188731812617E-4|-0.0015873126413871231|-0.0020431330542075897|-0.0019172708424832255|-0.0012673147592044594|-0.0010840448911971841|-0.0015673920035602453|-0.001540770787555236|-0.0022995659920517614|-0.003025220499072663|-0.0021972463523046164|-0.001954395667524225|-0.0022483156238244303|-0.0015043703493443047|-0.0028310848286143635|-0.003767354806477618|-0.0036331621462074686|-0.004465482613955925|-0.004493190410206037|-0.003567061847963738|-0.0030007724435578585|-0.00339755532972776|-0.003382524303003843|-0.0031038164701350716|-0.003739647010227506|-0.0035245041216972264|-0.0030275747562703847|-0.0032447097085833523|-0.003525590701942329|-0.0038919493412493626|-0.0038079204689614415|-0.0031757118630193486|-0.0032427176448006647|-0.0036460200124411807|-0.003441924023069442|-0.0033973742330202427|-0.002770779625011179|-0.003202695272439392|-0.003343588510887673|-0.0029899066411068344|-0.0032758583422762885|-0.0040058591702776|-0.00458880947177505|-0.005221742464547211|-0.004986860034897571|-0.0036099817676452837|-0.003926357715677606|-0.003695640510300858|-0.003204506239514563|-0.0035067566443605534|-0.004689680337862058|-0.005338730937603239|-0.004460049712730413|-0.0035355510208557677|-0.00369799476749858|-0.004483411188000115|-0.0045381023936702704|-0.005411350717317584|-0.0064464994974851595|-0.004811558422021046|-0.003514905996198822|-0.0036914752860279653|-0.0032677089904380205|-0.0020096301633169317|-0.002797038647601154|-0.004717931424234721|-0.005167594548999607|-0.004469104548106266|-0.003544786952939138|-0.004064172310098096|-0.004742017286334491|-0.0038977444358899087|-0.003376910305070814|-0.003098021375494525|-0.002945356851057635|-0.002550203835255387|-0.001720962011534721|-0.0012904951377666445|-9.060268277079038E-4|-7.973688031976615E-4|-8.133053134591636E-4|-3.551306434409753E-4|7.848731303789836E-4|9.159871466213426E-4|0.002012889904052239|0.003554928368560094|0.0050895418680597495|0.0075292767117297234|0.00934694436507856|0.012135471467426412|0.01587874041180426|0.021669126537955073|0.03038060255635623|0.04393768317779165|0.06448401012914089|0.09691716276849559|0.1527384118935574|0.2490170276713478|0.42299102058506444|0.7643396612938681|1.5114307666802729|3.12841519811053|4.309661211713597|2.6578948033474883|1.3584594644208485|0.786998843531819|0.5136081910924561|0.36439500770742606|0.27319977650963984|0.21530189143947975|0.1723272805522639|0.14101692749951503|0.11856673086203882|0.10054507311018507|0.08707292684457515|0.07503271224530272|0.06464699716590624|0.05675878677987769|0.050395953961265415|0.04505975837756742|0.04086827508208482|0.0376684773569657|0.034757347783628795|0.03268650693317109|0.03023481970680499|0.027817359758159615|0.025371648723141578|0.023201023586841972|0.022298256499869374|0.020750422940720974|0.019415196916197613|0.01838656761750065|0.01748977672187612|0.017606765194932147|0.017723210377865624|0.016335104114747277|0.014795963197559695|0.014297041768350166|0.013986642011665907|0.013092386469946612|0.011959626564427337|0.011967232626143054|0.013292136138337941|0.013015782562666892|0.0121300385662009|0.011623329978568136|0.011078591082356789|0.00908978704040432|0.008193539434902338|0.007542315674670953|0.007608234876207166|0.007812149768871388|0.0067393328735402625|0.00615402831484509|0.006191696430008641|0.0059137129839699374|0.006550267910892441|0.006167067277786319|0.005263937997398689|0.005273536122897093|0.005083022386589135|0.005465498632865188|0.006010237529076536|0.006140627158488827|0.0061902476563485045|0.006472034133245066|0.0067594346080746565|0.00637967481241136|0.005874052805023699|0.006595360991064191|0.007820299120709657|0.007562598505912865|0.0071598394283949|0.007043756438876458|0.006949586150967581|0.005405374525969521|0.003906255981143211|0.002942459303737362|0.0029267038901833768|0.0030422435895792674|0.0027178993864161944|0.0029442702708125323|0.003687310061755073|0.0043524782684652725|0.004018717036511312|0.00371592334154277|0.0031815069576598947|0.0032957789801031662|0.003684774707849834|0.004797976168957266|0.005510229519621905|0.004493733700328587|0.003316424004760112|0.002871650491098187|0.0035944074507988154|0.0026595862465956977|0.002365123000172941|0.0029487976885004593|0.0026465472836544684|0.0012879597838614055|0.0015288184048591093|0.001355871049180307|0.0022048524140203334|0.0027774802031893106|0.0030043943777082|0.003477962267865339|0.003715742244835253|0.005443585931255623|0.009719641389148692|0.02007239686777706|0.027403372684775593|0.01670399810795955|0.008630706886848546|0.005401571495111663|0.005210514468681153|0.005644241083184537|0.0046351702288994195|0.0029515141391132154|0.0029341288551915767|0.0024594743847893346|0.001898074591486416|0.0026206504544795273|0.003338336706369678|0.0039928202073363705|0.0047450959303622815|0.0035121895455860657|0.0029236252461555864|0.0032910704657077225|0.0032778504060589765|0.0021847506794859385|0.0016666329992796|0.0014196170902263158|8.087778957712369E-4|8.547764594805729E-5|5.610375998878845E-4|0.0013440997631916974|0.001014322658803112|6.182641594632787E-4|6.555700812117953E-4|5.179365834988217E-4|-2.9319556947013717E-4|-3.480678718478095E-4|-6.88348585272385E-4|-7.290953444637259E-4|-2.424884913653574E-4|0.0017236784621474772|0.0024685292201651883|0.0025328185513337482|0.002565778152101855|0.0021114065129415253|0.0016503342956030636|0.0019451597354408544|0.0019790248197465465|0.002748142536571545|0.003061077647161043|0.0029205466021277964|0.0017097340156686626|0.0010097952411151853|0.0011054143026841983|0.0012030254280358994|1.705930984810804E-4|5.59951019642782E-4|0.0023658473870030094|0.00271753719300116|0.0024352074259820474|0.0011856401441142606|4.114517194787842E-4|9.232310149220255E-4|0.0010769821196040183|0.0011186343623329445|0.0015648566496550063|0.0020501958258007554|0.0015518176867137772|0.0020550854369037162|0.0029209087955428302|0.0014650723638131005|-4.407893860965496E-4|-3.592958677138679E-4|1.4306639893848571E-5|8.051559616208955E-4|5.988868117589522E-4|5.972569413912986E-4|-6.591920153621367E-5|-5.132280691033779E-4|2.5353539052389875E-4|-3.797597956632969E-4|-0.001014503755510629|-0.001383941038845453|-0.0013196517076768928|-1.9612773424098736E-4|0.0010081653707475315|9.369943646933229E-4|6.88348585272385E-4|3.3502890890658044E-5|-8.185571179771587E-5|9.819063481575562E-4|0.002140019792729222|0.0017727556698846033|9.455059099466251E-4|0.0014598205592951054|0.002758646145607535|0.0021632001712914074|0.0016986871165101214|0.0010183067863684875|9.672375148486736E-4|0.0010029135662295366|-4.762843407698955E-5|-0.0022253163419697626|-0.002234371177345616|-8.978774758696356E-4|-6.919705194227265E-4|-7.167807683525651E-4|-0.0011242483602659737|-9.121841157634842E-4|-0.001433199343290096|-0.0010650297369078918|-6.29129961914303E-4|-0.001017401302830902|-0.0010559749015320381|-2.444805551480452E-4|-4.192388779020182E-4|-5.7950946405462565E-6|6.64987110002683E-4|9.225066280919572E-4|2.3542571977219166E-6|-0.0010128738851429755|-0.0010358731669976435|-0.0015078111867871291|-0.0027394498946107255|-0.0018270846821397244|-7.980931900277297E-4|-5.824070113748988E-4|-8.06423638573515E-4|2.1459959840772856E-4|6.238781573963079E-4|4.502064148874373E-4|2.9500653654530786E-4|-2.930144727626201E-4|-3.9406643555714546E-4|-9.203334676017523E-4|-0.0014341048268276815|-0.0022513942678522207|-0.0020585262743465405|-0.001862036346690519|-9.503955210495861E-4|8.852007063434407E-4|0.001276369594580313|0.0011488775124882953|9.688673852163273E-5|3.72334830655097E-4|3.1619485132480514E-4|2.9210898922503475E-4|0.0013450052467292826|0.0028493755960735875|0.003056188036058082|0.0018547924783898363|5.297078694874313E-4|-2.1478069511524564E-4|2.1423740499269443E-4|3.0424246862867847E-5|8.156595706568856E-4|0.002369469321153351|0.0019839144308495074|0.002453136000026237|0.002454946967101408|0.002033897122124219|6.673413672004049E-4|5.306133530250166E-5|4.355375815785546E-4|3.114863369293613E-5|1.66971164330739E-4|3.9605849933983323E-4|0.001320194997799444|0.0020098112600244484|0.001672065900505112|0.00168456157332379|0.0020869584574267205|0.0018989800750240013|7.752750048805789E-4|2.1948920951068946E-4|-5.157634230086169E-4|-3.609257380815215E-4|-2.126075346250408E-4|8.946177351343283E-5|7.318117950764819E-4|0.0020226691262581606|0.0022608112966431082|0.002712104291775648|0.002576100664430328|9.357266877407034E-4|-1.5194013760682216E-4|-1.584596190774367E-4|6.447042787607711E-5|-7.671256530423107E-4|-4.2593945608014985E-4|2.660310633425766E-4|0.001255724569923367|0.0020813444594936915|0.0016246185631356397|3.270606537758294E-4|-0.0010726357986236086|1.4686942979634418E-4|0.0010079842740400144|9.884258296281709E-4|5.686436616036014E-5|3.8356282652115533E-4|0.0012845189464185812|6.106580977475618E-4|-1.756638062915584E-5|-1.050360903599009E-5|-2.0373379595670432E-4|-5.117792954432412E-4|-6.233348672737567E-4|-4.5672589635805186E-4|-3.5766599734621425E-4|-0.001227654580258221|-9.474979737293129E-4|8.348558216536951E-4|7.223947662855942E-4|-4.0076701373527703E-4|-1.160829895184422E-4|7.1152896383457E-4|6.336573796022297E-4|9.275773359024352E-4|0.001509803250569817|0.0012539136028481962|6.247836409338933E-5|-2.0808011693711402E-4|-3.285094274359659E-4|-0.0012899518476440933|-0.0018729021491415432|-9.0131831331246E-4|-1.2133479403643725E-5|-3.882713409165992E-4|-5.7588752990428424E-5|1.6244374664281226E-4|-4.5708808977308596E-4|2.2274895024599672E-5|2.459293288081818E-4|-3.026125982610248E-4|-6.610029824373073E-5|-1.4523955942869054E-4|-1.5085355736171974E-4|1.0720925085010574E-4|2.6621216005009367E-4|0.0010000160189092633|0.001728568073250438|0.0015380543369424798|0.0015836907072367817|0.0014469626930613934|6.16453192388108E-4|-8.223601488350172E-4|-0.0013694533022440873|-0.0015405896908477189|-0.0017327332975233306|-7.689366201174814E-4|-9.223255313844401E-4|9.905989901183758E-5|0.001232544191361182|0.0016686250630622878|7.455751448477793E-4|-1.2568111501684695E-4|-3.9297985531204304E-4|9.225066280919572E-4|0.0013875629729957943|-5.144957460559974E-4|-7.98636480150281E-4|-0.0012321819979461478|-0.002306628763644927|-0.0031117847252658225|-0.0018835868548850504|-6.695145276906097E-4|-3.058723389963321E-4|-6.153666121430056E-4|-3.685317997972385E-4|-5.796905607621427E-4|-4.679538922241102E-4|1.9739541119360686E-4|3.507843224605656E-4|8.363045953138316E-4|2.3669339672481116E-4|-8.594849738760167E-4|-0.001209726006214031|1.633492301803976E-4|4.6107221733846155E-4|-3.1800581839997583E-4|-0.0012128046502418212|-0.0022459613666267085|-0.0023153214056057464|-0.001643271524009898|-0.0018046286904076078|-0.001230371030870977|-0.0016186423717875762|-0.0011727822778805487|-6.745852355010877E-4|-0.0016003516043283522|-0.0020072759061192094|-0.0020170551283251316|-8.670910355917336E-4|-1.0014647925694E-4|-9.145383729612061E-5|5.13590262518412E-4|5.722655957539428E-4|9.70678352291498E-5|-0.0014858984851775635|-0.001882862468054982|-0.0013940824544664088|-0.0010257317513766874|-0.0018220139743292463|-0.0027186237732462625|-0.0018522571244845973|-0.0016300514643611517|-0.0022812752245925374|-0.002174609263864983|-0.0011517750598085685|-0.0014371834708554717|-0.0011870889177743973|-0.0011057764960992326|-2.770779625011179E-5|9.37356558108357E-4|0.0013949879380039942|8.790434182878603E-4|1.9793870131615808E-4|9.120030190559671E-4|-7.06277159316575E-6|-0.0018212895874991782|-0.003349202508820702|-0.0033973742330202427|-0.002105973611716013|-0.0011110283006172275|-0.0012930304916718835|-0.0020070948094116927|-0.0016517830692632002|-0.0010461956793261164|-3.857359870113602E-5|8.314149842108707E-4|0.0015239287937561484|0.0011438068046778175|-2.31079398791782E-4|-0.0014179872198586622|-0.0014549309481921445|-0.001859863186200314|-0.0028962796433205087|-0.0026849397856480873|-7.886761612368421E-4|-2.4411836173301104E-4|-0.0011959626564427336|-0.0016191856619101274|-2.730938349357423E-4|6.660736902477854E-4|5.184798736213729E-4|1.4650723638131005E-4|4.978348489644268E-4|-5.1612561642365096E-5|-1.1083118500044715E-4|3.1492717437218564E-4|1.492236869940661E-4|0.001356052145887824|0.0014114677383880476|0.0021818531321656657|0.002838147600207529|0.0024158300782777206|0.002280007547639918|0.0023480999096663364|0.0021139418668467643|9.255852721197475E-4|-2.4140191112025498E-4|-7.736451345129252E-4|-9.170737268664451E-4|-3.5331967636580456E-4|5.020000732373195E-4|4.6976485929928094E-4|-7.88313967821808E-4|-9.753868666869418E-4|-5.704546286787721E-5|9.714027391215663E-4|6.930570996678289E-4|-4.895044004186416E-4|-5.412980587685237E-4|-9.435138461639374E-5|4.4622228732206173E-4|-1.6733335774577314E-4|-0.0010150470456331802|-0.002218796860499148|-0.003543338179279002|-0.004381272644960487|-0.008348920409951985|-0.015315891844841204|-0.01654137326460922|-0.009880817458838884|-0.0057699221982013835|-0.003017614437356946|-0.0017838025690431445|-0.0014455139194012568|-0.0013808623948176626|-0.0012642361151766692|-0.001237795995879177|-0.001148334222365744|-0.0014652534605206174|-0.002011260033684585|-0.002576100664430328|-0.0029935285752571757|-0.0022425205291838842|-0.001476300359679159|-9.710405457065321E-4|-5.244560649694362E-4|-0.0013009987468026345|-0.0012857866233712007|-7.865030007466373E-4|-5.990679084664693E-4|-8.846574162208894E-4|-0.0016606568079315367|-0.0012600708909037766|-0.0011233428767283885|-8.790434182878603E-4|-5.510772809744456E-4|5.221018077717143E-4|0.0010979893376759984|0.0015945565096878059|0.0015788010961338206|0.0017213242049497553|5.08519554707934E-4|-0.0013768782672522871|-0.0015981784438381472|-0.0017133559498190042|-9.509388111721373E-4|-4.8570136956078313E-4|-3.667208327220678E-4|-2.984473739881322E-4|6.881674885648679E-5|-4.9801594567194395E-5|0.0010934619199880718|0.002144547210417149|0.0016811207358809657|0.0021304216672308174|0.0032267811345391625|0.00334684825162298|0.0010407627781006043|5.539748282947187E-4|2.957309233753762E-4|5.432901225512116E-7|2.604170654095474E-4|3.085887896090882E-4|-6.465152458359418E-5|7.035607087038189E-4|0.0026695465655091366|0.00343033383378835|0.0029947962522097952|0.001119720942578047|-1.1463421585830564E-4|8.149351838268173E-6|-4.891422070036074E-4|-0.0016394684931520394|-0.0018872087890353917|-0.0017454100670495256|-0.001314762096573932|-0.0019161842622381232|-0.0014580095922199347|-4.5980454038584205E-4|8.797678051179285E-4|0.0024877254711619975|0.003729324497899033|0.003816432014214744|0.00182056520066911|3.7360250760771644E-4|-7.213081860404919E-4|-0.001707741951885975|-0.0017631575443861985|-8.031638978382077E-4|-3.3738316610430237E-4|8.746970973074505E-5|1.4831820345648076E-4|-1.8634851203506555E-4|-2.1514288853027977E-4|-0.0011659006029949|-0.0017834403756281105|-0.0014563797218522811|-9.58001582765303E-4|-7.944712558773883E-4|-8.96247605501982E-4|-4.965671720118073E-4|3.95515209217282E-4|4.373485486537253E-4|-0.0011282324878313494|-0.0013111401624235906|-3.5295748295077046E-4|9.393486218910447E-4|0.0023149592121907126|0.0036925618662730676|0.0023790674466517554|8.01352930763037E-4|-3.169192381548734E-5|3.496977422154632E-4|4.368052585311741E-4|6.05949583352118E-4|-7.765426818331984E-4|-0.0017930385011265151|-4.646941514888029E-4|4.509308017175056E-4|0.0011870889177743973|0.0023178567595109854|0.002120823541732413|0.0014657967506431688|0.0011110283006172275|-9.670564181411565E-5|2.571573246742401E-4|3.496977422154632E-4|2.3126049549929904E-4|-6.671602704928878E-4|-0.0013080615183958004|-9.32466947005396E-4|4.7574105064734424E-4|-1.1390982902823736E-4|-3.7052386357992625E-4|6.946869700354825E-4|0.001551093299883709|0.002275661226659508|0.002413656917787516|0.001666270805864566|0.0012140723271944407|6.229726738587226E-5|-5.630296636705722E-4|-1.8019122397948517E-4|-1.542943948045441E-4|3.0659672582640036E-4|1.8598631862003142E-4|-2.2329224036854794E-4|-0.0015690218739278989|-0.0012819835925133422|-1.484993001639978E-4|-3.7360250760771644E-4|2.9790408386558097E-4|1.829076745922412E-5|-0.0019969533937907367|-0.0033012118813286785|-0.002614674263131464|-0.0015311726620568311|-6.541213075516587E-4|-4.505686083024714E-4|3.218088492578343E-4|9.100109552732794E-4|0.001338123571843634|0.0017039389210281165|0.0010279049118668922|0.0012573544402910207|0.0011191776524554957|4.3843512889882774E-4|2.2383553049109916E-4|1.9667102436353857E-4|-5.686436616036014E-5|-3.8283843969108707E-4|2.3542571977219166E-6|3.174625282774246E-4|-7.21670379455526E-4|-0.001312770032791244|-8.886415437862651E-4|-0.0012037498148659677|-0.0023633120330977704|-0.001910751361012611|-6.859943280746631E-4|6.287677684992688E-4|0.0010950917903557254|0.0010355109735826092|0.001651239779140649|0.002059975048006677|0.0025496605451328356|0.0022970306381465224|0.0017883299867310714|0.0011380117100372711|0.0010235585908864825|0.001335407121230878|0.0013055261644905614|0.001189262078264602|0.001373799623224497|0.0016715226103825608|0.001330698606835434|3.611068347890386E-4|-4.762843407698955E-5|0.0010697382513033355|0.0023486431997888873|0.0015989028306682156|8.299662105507342E-4|8.734294203548311E-4|1.7928574044189982E-5|-3.6708302613710196E-4|8.462649142272705E-4|0.0019409945111679618|0.0022256785353847964|0.0017472210341246963|9.761112535170101E-4|6.42168924855532E-4|-2.2999281854667956E-5|3.8320063310612123E-4|0.0010440225188359114|0.0014007830326445403|8.598471672910508E-4|0.0010831394076595987|0.0015891236084622938|6.629950462199952E-4|8.779568380427579E-4|0.0023361475269702094|0.0027524888575519548|0.001821108490791661|9.998349222017464E-4|0.0018013689496723005|0.002688199526383395|0.0034944420682493926|0.0028267385076339536|0.0011128392676923982|9.074756013680404E-4|0.0018727210524340262|0.0023247384343966344|0.0033037472352339175|0.004047330316299009|0.004021795680539102|0.004176090075343646|0.0032048684329295967|0.0027568351785323643|0.0028334390858120854|0.002521771652175207|0.0038617061910940116|0.004213033803677128|0.003320045938910454|0.002781102137339652|0.0022863459324030154|0.0024236172367009547|0.0025438654504922895|0.002996245025869932|0.0038591708371887726|0.003803755244688549|0.002925074019815723|0.002591856077984313|0.0029439080773974984|0.0019411756078754787|0.0019333884494522448|0.0030366295916462384|0.0032680711838530543|0.0031988922415815335|0.0033557219902913167|0.004246174501152752|0.004044251672271218|0.004585549731039742|0.004774976887102598|0.004403185346570053|0.003670468067955985|0.0035129139324161338|0.0036204853766812735|0.003935050357638425|0.004085541721585111|0.0038481239380302313|0.003151082710797027|0.0029388373695870204|0.0023977204075260137|0.0018877520791579431|0.002418727625597994|0.0026494448309747416|0.0025741086006476404|0.002444624454772935|0.002797038647601154|0.003990828143553683|0.004704168074463424|0.004292535258277122|0.004488481895810592|0.004995371580150873|0.004783488432355901|0.0038106369195741977|0.004114698291495359|0.0036787985165017702|0.003957868542785576|0.0046592560909991905|0.005178641448158148|0.005993757728692483|0.005035031759097111|0.004855927115362728|0.004650201255623336|0.004371312326047048|0.004571424187853411|0.004873131302576851|0.005372596021908931|0.005706176157155375|0.005586833426901625|0.005919508078610484|0.006454829946030944|0.00613302109677311|0.006820826391922944|0.006112557168823681|0.005591179747882035|0.005860651648667436|0.0061031401400327935|0.006660736902477853|0.006529441789527977|0.006617273692673757|0.005956270710236449|0.005706357253862892|0.0049962770636884585|0.004243639147247513|0.0056817281016405706|0.006554795328580367|0.005852321200121651|0.006410099059274228|0.007285882736826781|0.007638296929655|0.006783882663589462|0.00599267114844738|0.004619958105467986|0.0052070736312383285|0.005748733883421887|0.005899225247368572|0.006402492997558511|0.00586536016306288|0.005444129221378173|0.005394508723518496|0.0062040110061198014|0.006170508115229144|0.0063997765469457546|0.006110384008333476|0.0060323313273936184|0.00581592076191072|0.006507529087918412|0.007086857455265521|0.006888918753949362|0.007030717475935228|0.007611675713649991|0.007434382036990779|0.006901233330060523|0.006804527688246407|0.007279725448771201|0.0075368827734454405|0.007444523452611734|0.007624171386468669|0.008330448545785244|0.010390061400376887|0.00999545167469719|0.008433854765777491|0.008880982536637138|0.0102162085611605|0.011244656763149943|0.010851495811130383|0.010627479183931766|0.009550859257742782|0.009232672342635289|0.009666761150553708|0.01084733058685749|0.010290820404657532|0.011081126436262028|0.011421226052979086|0.010830307496350885|0.011108109845682071|0.012285781734665581|0.013709201855749755|0.01323418519193248|0.012375424604886531|0.012601252199160317|0.012740334470533427|0.013179856179677358|0.013168084893688748|0.013250664992316533|0.01300908198448876|0.013299923296761176|0.013899172301935162|0.01379486059840533|0.014876189038989757|0.015237114777071278|0.014575568504511421|0.0154113298097027|0.01653213733252585|0.016806498844414212|0.015734406335913154|0.01612974044842292|0.0169495652433527|0.01715782645699733|0.0178842053508483|0.019396000665200804|0.020624922922411644|0.022475731273236106|0.025919104069965684|0.03023862273766285|0.03915998984007629|0.05219895278130537|0.07758219169372804|0.13166744778053122|0.2329638911302046|0.27150362474703493|0.16247471417979767|0.09246906543846131|0.061953002544882306|0.0470721049914971|0.038291450030824424|0.0336678699912061|0.03146627731792107|0.02973915801833077|0.02876992843969941|0.027780778223241168|0.0271509238744968|0.02698920451468405|0.026815170578760147|0.02728728969525715|0.027703631025838896|0.027896136825929542|0.027994472338111313|0.027839272459769183|0.027824784723167816|0.027945576227081704|0.028602413985246117|0.028171403821355488|0.02614601824448457|0.023682921925544897|0.02294712600290304|0.026694016881431228|0.028202009164925875|0.02979221935363327|0.03202477956390372|0.03411391118182064|0.03650438772104597|0.037829653426655896|0.038692941431389766|0.04039778583595547|0.041583425980069734|0.04201950685177084|0.04224642102628973|0.042514263056707476|0.04387303165320806|0.04568725846911407|0.04781985329683509|0.050796720975000695|0.053895828930740325|0.054994180461831355|0.05447660607174757|0.05502315593503409|0.05532685511354021|0.05559016972627003|0.055128373122101504|0.0529354730907773|0.04682400250219872|0.027936340294998332|-0.0250005815694391|-0.07292166792577623|0.04842308642957445|0.10171260358354763|0.11954284211555583|0.13054229393672767|0.1407673762365565|0.15135754949873975|0.1631869675304623|0.17462213802992022|0.18857219850666768|0.20659802148279433|0.22816410399417217|0.2532277072178272|0.28207949136932436|0.3156705763565432|0.3584132023614297|0.4115830145917341|0.4768187571537783|0.5614289498728289|0.6743901943470918|0.8272399807157722|1.0438758305028226|1.3674375147927147|1.8714256676851566|2.693458393672983|4.115059036136733|6.712947083255025|11.877432926173395|22.71211644336472|41.2842775807268|41.595181148451374|22.196150192043685|11.397295028564242|6.5628130231122705|4.213614037528013|2.9242368097368714|2.1380192174012813|1.6226035000710972|1.26904332727771|1.013811966087914|0.8221511632345425|0.673331140801532|0.554269834831264|0.46085200374212076|0.388587535767924|0.33053408862600675|0.2835034547805311|0.24546807549413577|0.21356698498146623|0.18706656048037074|0.16469459762054192|0.1468973186893018|0.13165477101100503|0.11900824463496544|0.10822248692866375|0.09930999356491864|0.09127835458653658|0.08319781949712488|0.0766736295121149|0.07165290439291164|0.06636071530914028|0.06044609684163276|0.05422107861744098|0.04889882748022179|0.04504327857718336|0.04259865412241043|0.04072285442594861|0.03756217358965318|0.034228183204263914|0.03245307327718159|0.031358343680240895|0.029131759661318514|0.026335807593962462|0.024473590150564425|0.023033871325803715|0.02186634085244116|0.020731951076554234|0.02057258597393921|0.019583254660773455|0.018146976673455568|0.016761767957657495|0.015853205776044352|0.015936510261502206|0.016162881145898544|0.014183313036029446|0.012471405859870579|0.010483688398163212|0.008930240841081781|0.008708216277665853|0.007464262993731095|0.00692495699874526|0.007435830810650915|0.00631230683721501|0.005942326263757635|0.006899060169570318|0.006456097622983564|0.005652028241607771|0.005079219355731276|0.005578140784940806|0.006189342172810919|0.005493387525822817|0.005003520931989141|0.004178082139126334|0.00387728050794048|0.004202892388056173|0.0049406803744807175|0.0050859199339094085|0.005942145167050118|0.007869738521861817|0.009432059817611584|0.011289206553199142|0.016991579679496657|0.02926015722694812|0.05577959688233289|0.11280930433665612|0.21994557321363248|0.25081060946259687|0.14128839146408312|0.07416906204715382|0.043922471054360215|0.028187340331616993|0.019988911285611692|0.014158683883807125|0.009750608926134111|0.0075028365924322315|0.007507364010120158|0.005394508723518496|0.0026854830757706387|0.0023640364199278385|0.0013785081376199407|-1.6298703676536348E-4|-8.703507763270409E-4|-0.0015650377463625235|-0.0016639165486668438|-4.7954408150520275E-4|-1.812778042245876E-4|-5.215585176491631E-5|-0.0011593811215242853|-0.0026407521890139223|-0.00330791245950681|-0.0021833019058258023|-0.0016970572461424678|-0.001350438147954795|-8.567685232632606E-4|-0.001515598345210363|-0.002618839487404357|-0.0029194600218826936|-0.002750496793769267|-0.0023019202492494833|-0.0011811127264263338|-7.035607087038189E-4|-0.0010677461875206477|-0.001042573745175775|-8.325015644559732E-4|-0.0011448933849229198|-0.0011146502347675691|-0.0012291033539183576|-9.06751214537972E-4|-8.583983936309142E-4|-0.0013862952960431748|-8.819409656081334E-4|-2.0373379595670432E-4|-0.001579525482963889|-0.0032294975851519187|-0.00397489163329218|-0.004060912569362789|-0.003911145592246172|-0.00398919827318603|-0.002815148318352861|-0.0026592240531806634|-0.002696711071636697|-0.00208514749035155|-0.0018261791986021391|-0.0018100615916331198|-0.0035762977800471085|-0.004122123256503559|-0.004203073484763689|-0.004454435714797383|-0.0033655012124972385|-0.0021666410087342316|-0.001838674871420817|-0.002124445475882754|-0.0019422621881205813|-0.0015970918635930449|-0.001397342195201716|0.0011517750598085685|0.0058369279799827|0.00849325448584309|0.0038191484648275|-4.5908015355577373E-4|-0.002000756424648595|-0.0023642175166353556|-0.0027983063245537736|-0.003376910305070814|-0.0031809636675373437|-0.002803739225779286|-0.0026776959173474045|-0.0016403739766896247|-0.0013928147775137893|-0.0013372180883060487|-0.0018913740133082845|-0.0017794562480627349|-0.0011289568746614175|-0.0017752910237898423|-0.0029127594437045622|-0.0032323951324721915|-0.0022772910970271618|-0.0011371062264996857|-0.0016222643059379176|-0.0024904419217747537|-0.003673003421861224|-0.0036451145289035955|-0.00275774066206995|-0.0025464008043975285|-0.0026360436746184785|-0.003205230626344631|-0.003104721953672657|-0.003192010566695885|-0.003056369132765599|-0.00334992689565077|-0.0031556101284849537|-0.0027731338822089007|-0.002825289733973817|-0.003148185163476754|-0.0028548084972990994|-0.0034989694859373192|-0.004648571385255683|-0.005307220110495269|-0.004443388815638842|-0.003194364823893607|-0.002517425331194797|-0.0025746518907701914|-0.0031954514041387092|-0.0028932009992927187|-0.0010871235352249743|1.2133479403643724E-4|-7.736451345129252E-4|-0.001933569546159762|-0.002286527029110532|-0.0017957549517392713|-0.0011184532656254274|-0.0011577512511566318|-0.001992788169517844|-0.0029035235116211915|-0.0019355616099424496|-4.98197042379461E-4|-2.6458228968244E-4|9.308370766377425E-5|-9.980239551265757E-4|-0.002252118654682289|-0.0022501265908996012|-0.0014045860635023989|1.350981438077346E-4|-6.863565214896972E-5|4.943940115216025E-5|5.364084476655629E-4|5.891075895530304E-4|5.749820463666989E-4|-4.0149140056534535E-4|-4.8298491894802704E-4|-3.685317997972385E-4|0.001525196470708768|0.002431404395124189|0.00230336902290962|0.0019607340522873225|0.0023482810063738535|0.002647814960607088|0.002920727698835313|0.004277866424968239|0.005508780745961768|0.006075975633905233|0.004123209836748662|0.004176271172051163|0.004697286399577775|0.0048233297080096564|0.0046636024119796|0.0039049883041905914|0.0043050309310958|0.004514922015108085|0.004229875797476216|0.004029582838962336|0.002942459303737362|0.0026362247713259956|0.003225875651001577|0.0026326028371756543|0.001589666898584845|8.229034389575684E-4|4.704892461293492E-4|4.232230054673938E-4|5.999733920040546E-4|5.157634230086169E-4|7.850542270865006E-4|0.0017173400773843796|0.0013748862034695993|0.0011715146009279292|0.0015375110468199287|0.0028700206207305334|0.004047330316299009|0.004523795753776421|0.004399744509127228|0.004665051185639736|0.004519449432796012|0.004080108820359599|0.0036996246378662337|0.003943199709476693|0.0033423208339350536|0.0034727104633473444|0.004026685291642063|0.0037101282469022235|0.003146736389816617|0.003976340406952317|0.0040849984314625595|0.004239111729559587|0.004387429933016067|0.004470915515181437|0.003933963777393323|0.004661067058074361|0.005728994342302526|0.005643516696354468|0.004160334661789661|0.0038459507775400266|0.00529291347060142|0.006577251320312484|0.006579062287387655|0.005940334199974947|0.005820810373013681|0.005709254801183165|0.006374060814478331|0.006749836482576252|0.007526922454532002|0.007240065269824962|0.00730073266684318|0.007026733348369853|0.007002466389562566|0.007002466389562566|0.007417721139899208|0.008447799212256305|0.008139934809477285|0.008057173614141985|0.007680673559213994|0.0071254310539666564|0.008514804994037622|0.010447831250074832|0.011700658272677926|0.011471752034376349|0.011143966993770451|0.011402391995397311|0.011440060110560861|0.011310213771271121|0.011318000929694356|0.01216897435831707|0.012234893559853284|0.011689973566934419|0.012749751499324315|0.013441722018747042|0.01412681086328412|0.015638606177636624|0.016394503834812876|0.01653467268643109|0.017299081888860642|0.01934366371672837|0.023315295609285244|0.028265574109264367|0.03599731693999817|0.051968959962758694|0.08424799930401637|0.1295009878685045|0.12876193220512733|0.09105850318361085|0.07669137698945157|0.08657943831659114|0.12532073256888795|0.2012522277735979|0.2772994437744113|0.23263320854227845|0.14894027064680188|0.10283449768661587|0.09046323830600224|0.1048727411297205|0.15258900710985582|0.1904704541948616|0.13801543066912708|0.0855669266248632|0.06083110844181405|0.05026393446148547|0.045915440320585574|0.04248365771313709|0.04121561856710256|0.040100787235627475|0.04050879811766343|0.040182280754010154|0.03984779513522613|0.041203666184406434|0.04174623192012758|0.04160244113435902|0.04114752620507614|0.04144054067783876|0.04392591189180304|0.04540456650867992|0.04727131136976588|0.05002814654829825|0.052729203940915355|0.05512565667148875|0.05710160284720751|0.057756267444881715|0.05983091132619727|0.0639463340045227|0.0682768995713784|0.07087400745388071|0.07396569044461214|0.07730964114891485|0.08082183069450091|0.0861080435869242|0.09155488925891514|0.09661201481632933|0.10328397971467324|0.11036341220493057|0.1175087638967241|0.12601197870148062|0.1348679698924804|0.14389147553793347|0.1532972763329551|0.16442005501194604|0.17865425622278777|0.19456468855840753|0.21208054320616612|0.23168715934220926|0.25332223969915113|0.27916546424866717|0.3088468524173|0.3447648489994057|0.38872625584588205|0.44073034856989907|0.5036091174836086|0.5817217414336542|0.6792258386312126|0.7988355054318422|0.9568541540264749|1.1741370623494838|1.4789326003229195|1.9172420481067303|2.573993966431782|3.5387872190190977|5.028024403096446|7.510632805690841|12.062231793682235|21.091690087911395|40.56667553880565|79.04079021244083|95.23462277771782|54.41309672409828|27.553624276681525|15.725879397439714|10.094513746869518|7.082750906325863|5.283889421665845|4.060608145797453|3.175076213575964|2.509026246996863|2.032723796556216|1.6772166530603125|1.395825691372968|1.1744702802913152|1.0013954325304208|0.8647746276058828|0.754313785372308|0.6657821245486829|0.5924359659404866|0.5315219152066297|0.47855004167764154|0.43279414755637846|0.3917650585980185|0.3567623247757041|0.32819069723073585|0.3032312246139031|0.2807707054640985|0.26061264985366583|0.24272717682586492|0.22660685340623288|0.2131933824738585|0.2004988654703269|0.18922432775043663|0.1799094375025886|0.17095203215537927|0.16160472559688566|0.15183944783744266|0.14286411391618914|0.1360773337052794|0.13015293601556596|0.12383646395407806|0.1179470179289154|0.11329844654365973|0.10763917443375128|0.10324468172914204|0.09833406340810916|0.09312373003613551|0.09007116393422777|0.0862661410125866|0.08351111680112941|0.08161648304708582|0.07978613862421079|0.0762141871651441|0.07256979702307056|0.06981966242271634|0.0680286159853725|0.06666568216459903|0.06631308687506329|0.06565045402225833|0.06350210378098332|0.062312117315888656|0.061417861774169365|0.06050368559462319|0.05924198483335176|0.0586249883508411|0.05964909023185014|0.06361384044952136|0.07257794637490883|0.09077997644744959|0.1298128363988489|0.1923353880888724|0.18852330239563805|0.12973079959034367|0.1038691031766609|0.10625976081259374|0.1348489547381911|0.2065871556803433|0.28277037530850196|0.24707295451615205|0.151503332348291|0.10433633268205494|0.08843857711596138|0.09470977500057003|0.12550019940603738|0.14762967377450084|0.10967162278221536|0.07069544610026889|0.05155515398608219|0.04142569074782236|0.0350215678798962|0.03062816175553207|0.02827281797756505|0.02721756746286308|0.026317697923210755|0.024705031742771243|0.023096892980019657|0.022525713964510814|0.021098490812568784|0.02019065301778571|0.01971762841775112|0.018894543882086036|0.017671054526100707|0.01647762722356321|0.01536750440648357|0.015042979106612979|0.015343056350968765|0.016074505952630214|0.015366598922945984|0.014559813090957436|0.015158880999423904|0.015439943089490397|0.01466647905168499|0.014388676702353803|0.01415705401343947|0.014020144902556564|0.01329539587907325|0.012714980931481037|0.013136936259995811|0.012532978740426382|0.011984617910064693|0.011546182781165865|0.011273994429767708|0.011589464894262444|0.012661376306055985|0.011866180663348528|0.00941250137319974|0.008786631152020745|0.008115848947377515|0.008335157060180688|0.007930949209002586|0.007947972299509191|0.007765970108454535|0.008066590642932872|0.008595574125590234|0.007661115114802151|0.006810141686179437|0.006882580369186265|0.007943444881821264|0.007791323647506925|0.007902517025922406|0.007556079024442251|0.008358699632157907|0.009337165142872639|0.008424437736986604|0.007808165641306012|0.006819377618262807|0.006090282273799081|0.006425492279413179|0.006265040596553055|0.005956995097066518|0.0060614878973038674|0.006382391263024116|0.006322991542958517|0.005868619903798187|0.005376580149474307|0.0054077287831672425|0.005179909125110768|0.004895044004186416|0.004129367124804242|0.004065258890343199|0.005647319727212327|0.00702691444507737|0.007137021243247749|0.006142800318979032|0.0039010041766252158|0.0036583345885523415|0.0037535914567063205|0.004182971750229295|0.0045759516055413375|0.003770071257090374|0.002915656991024835|0.0026525234750025316|0.0024180032387679253|0.0019397268342153423|0.002642925349504127|0.0030496685545874673|0.002545133127444909|0.0025177875246098313|0.0027238755777642576|0.0034122241630366425|0.003824581366053012|0.003462931241141422|0.0026054383310480933|0.001964537083145181|0.0013696343989516044|0.0012808970122682398|0.002945719044472669|0.004527779881341797|0.00325720538140203|0.0016671762894021511|0.001022109817226346|0.0012535514094331622|0.0012370716090491086|0.0028041014191943197|0.003993363497458922|0.003490095747268983|0.0021123119964791106|0.0010364164571201946|2.640389995598888E-4|2.339769461120551E-4|6.13917838482869E-4|0.002345021265638546|0.0021972463523046164|-9.960318913438879E-5|-0.0019511359267889176|-0.0019187196161433622|-0.0013495326644172095|-4.299235836455254E-4|5.894697829680645E-4|8.082346056486857E-4|8.174705377320563E-4|5.838557850350353E-4|-2.488268761284549E-4|9.616235169156444E-5|4.958427851817391E-4|1.3401156356263217E-5|-1.9793870131615808E-4|1.4107433515579793E-4|-7.926602888022176E-4|-0.001533345822547036|-0.0025360782920690553|-0.0018287145525073781|-0.0014268609585269985|-0.0015548963307415674|-0.0023432102985633755|-0.002387760088612575|-0.001718426657629482|-9.319236568828449E-4|-0.0013134944196213124|-0.0021199180581948276|-0.0017064742749333555|-0.0016787664786832436|-0.0017070175650559067|-0.0011666249898249683|-5.470931534090701E-4|-2.0608805315442625E-4|-5.615808900104357E-4|-1.5864071578495378E-4|-1.640736170104659E-4|-2.7236944810567405E-4|-7.338038588591698E-4|-8.888226404937821E-4|-0.001997858877328322|-0.0019714187580308295|-0.001685104863446341|-0.0020043783587989365|-0.0013113212591311077|-2.720072546906399E-4|-6.398146676578102E-4|-0.0019917015892727415|-0.0032416310645555623|-0.002974332324260366|-0.003330006257823893|-0.003623382924001547|-0.0026905537835811167|-0.0014129165120481842|-9.547418420299958E-4|1.6570348737811953E-4|2.8486512092435194E-4|-3.1221072375942955E-4|-6.358305400924345E-4|-0.0011041466257315788|-0.002059250661176609|-0.0017895976636836909|-0.0016711604169675268|-0.001478835713584398|-0.0019580176016745663|-0.0031572399988526074|-0.004083006367679872|-0.003290527175585171|-0.0022452369797966404|-0.0028819730034266603|-0.003782929123324086|-0.002341942621610756|-0.0020458495048203454|-0.003526315088772397|-0.004258851270678947|-0.0027416230551009307|-0.0017631575443861985|-0.002129153990278198|-0.0013774215573748383|4.904098839562269E-4|1.5501878163461235E-4|-4.353564848710375E-4|-0.0013915471005611698|-0.0016573970671962294|-0.0016861914436914435|-0.0027664333040307693|-0.0028307226351993293|-0.001800101272719681|-0.0014444273391561544|-6.974034206482385E-4|-4.420570630491691E-4|-1.6298703676536347E-5|-9.91142280240927E-4|-0.002308983020842649|-0.0030927695709765304|-0.003459490403698598|-0.0020092679699018974|-0.002044219634452692|-0.0019112946511351623|-0.002290692253383425|-0.0028383286969150463|-0.002649807024389776|-3.18549108522527E-4|8.880982536637138E-4|0.0010824150208295304|0.0012463075411324792|0.0012158832942696114|3.592958677138679E-4|-7.198594123803553E-4|-9.346401074956009E-4|-3.587525775913167E-4|-7.832432600113299E-4|-0.002044762924575243|-0.0014342859235351984|-8.062425418659979E-4|-6.740419453785364E-4|-0.0012912195245967128|-0.0019404512210454106|-0.002197970739134685|-0.002858249334741924|-0.0029991425731902047|-0.002845391468508212|-0.003195270307431192|-0.003890681664296743|-0.00303717288176879|-8.873738668336456E-4|-1.3672801417538824E-4|-7.037418054113361E-4|-0.0015074489933720949|-9.252230787047133E-4|-0.0011946949794901143|-0.0023946417634982233|-0.0028819730034266603|-0.003567061847963738|-0.002609422458613469|-0.0016354843655866638|-0.001993693653055429|-0.0023229274673214634|-0.0022381742082034743|-0.002615398649961532|-0.0013337772508632243|-8.841141260983382E-4|-8.984207659921868E-4|1.2676769526194937E-4|0.001376334977129736|3.1166743363687837E-4|-3.7921650554074564E-4|-5.313377398550849E-4|-1.2550001830932987E-4|-5.235505814318508E-4|-0.0013853898125055894|-0.0027613625962202913|-0.0031161310462462324|-0.002689286106628497|-0.0023127860517005074|-0.002128791796863164|-3.708860569949604E-4|3.1094304680681005E-4|-9.898746032883075E-4|-0.0018383126780057827|-0.001933931739574796|-7.67668943164862E-4|-1.6298703676536348E-4|-2.3289036586695268E-4|-5.760686266118013E-4|1.810967075170705E-6|8.274308566454952E-4|-2.0717463339952867E-4|-0.0010766199261889842|-0.0013276199628076439|-0.002316589082558366|-0.0024951504361701974|-0.0018317931965351683|-0.0024493329691683786|-0.0037709767406279592|-0.004231867861258904|-0.003169011284841217|-0.0012287411605033235|-6.782071696514291E-4|-5.956270710236449E-4|1.7964793385693396E-4|7.808890028136081E-4|6.680657540304732E-4|9.699539654614296E-4|2.352446230646746E-4|-0.0011745932449557194|-0.0019667102436353857|-0.0023323444961123514|-0.0023750833190863798|-0.001782534892090525|-0.002698884232126902|-0.0034448215703897153|-0.0016367520425392833|-0.0010012836958618828|-0.001188899884849568|-0.0011405470639425101|-0.0015157794419178802|-0.0020259288669934677|-0.0013862952960431748|-7.388745666696477E-4|-0.0012263869033056014|-0.001743961293389389|-0.0014770247465092272|-0.00154113298097027|-0.002432128781954257|-0.002270771615556547|-0.0021095955458663544|-0.0026653813412362438|-0.002649807024389776|-0.002209017638293226|-0.002837966503500012|-0.003929979649827948|-0.002904791188573811|-0.002408948403392072|-0.0018919173034308357|-5.13590262518412E-4|0.0017676849620741253|0.004074675919134086|0.0018982556881939332|8.576740068008459E-4|3.694372833348239E-5|-0.0010338811032149556|-9.257663688272645E-4|-8.006285439329687E-4|-6.765772992837754E-4|-2.493701662510061E-4|-0.0013605795635757507|-0.002283267288375225|-0.0017814483118454227|-6.188074495858299E-4|-3.9732617629245273E-4|-6.611840791448245E-4|-7.334416654441356E-5|-6.184452561707959E-4|-0.0011946949794901143|-0.001032070136139785|-0.0015018349954390659|-0.001682026219418551|-0.0012988255863124298|-0.0015121575077675388|-0.002186199453146075|-0.001450765723919252|-2.0970998730476765E-4|0.0010672028973980965|0.0012785427550705177|5.483608303616895E-4|-2.9210898922503475E-4|7.696610069475496E-5|-3.712482504099945E-5|-0.0012910384278891956|-0.0023289036586695267|-0.002447522002093208|-0.003506394450945519|-0.0036098006709377665|-0.0033685798565250284|-0.0037947004093126955|-0.0032189939761159284|-6.888918753949362E-4|1.8019122397948517E-4|-8.899092207388846E-4|-0.0010920131463279352|-0.0010025513728145023|9.254041754122304E-5|6.42168924855532E-4|4.907720773712611E-4|-4.607100239234274E-4|-0.00110161127182634|-6.351061532623663E-4|-5.396681884008701E-4|-9.86252669137966E-4|-7.102612868819506E-4|-1.8471864166741192E-4|-7.740073279279594E-4|-6.131934516528007E-4|-9.616235169156444E-4|-7.977309966126957E-4|-9.933154407311318E-4|-8.497057516700948E-4|-7.995419636878663E-4|-5.668326945284307E-4|-0.0013192895142618588|-0.0017608032871884766|-0.0013325095739106048|-9.902367967033416E-4|-0.0011984980103479726|-8.303284039657684E-4|-0.001035329876875092|-0.00145583643172973|-7.508269493657744E-4|-5.916429434582694E-4|-7.912115151420811E-4|-4.7266240661955405E-4|2.9935285752571755E-4|-7.053716757789896E-4|-0.0010201177534436582|-0.002039692216764765|-0.0019111135544276452|-0.001232906384776216|-6.635383363425463E-4|1.068470574350716E-5|1.0702815414258867E-4|9.873392493830685E-4|0.0023506352635715754|0.0020690298833825308|0.0015686596805128648|0.0013009987468026345|8.643745849789776E-4|7.868651941616714E-4|0.0012966524258222248|0.001158294541279183|0.0020994541302453984|0.0022752990332444737|0.0014257743782818961|7.348904391042721E-4|0.0012013955576682459|0.0015815175467465768|0.0012895896542290592|1.72041872141217E-4|-8.355802084837634E-4|-0.0015400464007251677|-0.0013245413187798537|-9.123652124710012E-4|-8.080535089411686E-4|-0.002295762961193903|-0.0036505474301291073|-0.0029958828324548976|-9.764734469320442E-4|5.251804517995045E-4|0.0014585528823424859|0.0010987137245060668|9.523875848322738E-4|6.863565214896972E-5|-2.401342341676355E-4|6.31846412527059E-4|0.001478835713584398|0.0020683054965524622|0.002323470757444015|0.0015250153740012508|0.0010764388294814671|0.0013015420369251857|0.0011856401441142606|5.914618467507524E-4|0.0010979893376759984|0.0012032065247434165|1.7276625897128526E-4|8.946177351343283E-5|7.280087642186234E-4|8.317771776259049E-4|6.859943280746631E-4|-8.536898792354704E-4|-2.064502465694604E-5|0.001525377567416285|0.0010251884612541362|4.5672589635805186E-4|0.0012448587674723428|0.0015903912854149133|-5.740765628291136E-4|-0.0015248342772937336|-8.040693813757931E-4|-3.9895604666010634E-4|4.809928551653393E-4|0.0019344750296973472|0.0017479454209547646|7.37063599594477E-4|-3.113052402218442E-4|-4.690404724692126E-4|-6.577432417020001E-4|-5.581400525676113E-4|2.573384213817572E-4|9.670564181411566E-4|4.549149292828811E-4|-8.393832393416218E-4|-0.0011821993066714364|-0.0010212043336887606|-9.652454510659859E-4|-0.0012361661255115234|-9.384431383534594E-4|-0.001656310486951127|-0.001581698643454094|-9.163493400363768E-4|-0.0012669525657894253|-5.67557081358499E-4|0.0013060694546131125|0.002293227607288664|0.0022868892225255664|0.0021048870314709107|9.440571362864886E-4|-5.974380380988156E-4|-0.0011465232552905734|-8.227223422500513E-4|-1.8834057581775332E-5|5.978002315138498E-4|0.0021925378379091726|0.0019140111017479182|0.0011740499548331682|0.001546022592073231|0.0010235585908864825|5.681003714810502E-4|0.0010315268460172338|0.0017247650423925795|0.001538235433649997|2.77259059208635E-4|2.365123000172941E-4|4.992836226245634E-4|4.26301649495184E-4|0.0014159951560759744|0.002583887822853562|0.001738709488871394|7.779914554933349E-4|2.6983409420043504E-4|-4.7266240661955405E-4|-4.85339176145749E-5|0.0022847160620353617|0.002873280361465841|0.0025842500162685965|0.0019422621881205813|9.480412638518641E-4|0.0012051985885261044|7.589763012040426E-4|6.019654557867424E-4|7.223947662855942E-4|6.197129331234153E-4|9.386242350609764E-4|0.0014938667403083146|0.0012314576111160794|-8.891848339088162E-4|-0.0011686170536076561|-5.208341308190948E-4|5.697302418487039E-4|8.163839574869538E-4|8.52603298990368E-4|8.976963791621185E-4|0.0011905297552172215|0.0014473248864764275|0.0016776798984381412|0.002435569619397081|0.0025389758393893286|0.0018482729969192216|0.0023845003478772673|0.003936861324713596|0.004007489040645253|0.0026485393474371564|0.0021688141692244364|0.0019428054782431325|0.0016041546351862107|6.218860936136201E-4|8.788623215803432E-4|0.002435388522689564|0.0027782045900193787|0.0015682974870978306|0.001199222397178041|0.0024158300782777206|0.0031889319226680946|0.00202393680321078|8.786812248728262E-4|0.0010509041937215601|0.0017320089106932625|0.001717702270799414|0.0018252737150645537|0.0026249967754599372|0.002485914504086827|0.002002205198308732|0.003122650527716847|0.0027546620180421595|0.0017852513427032812|0.0014145463824158377|0.0018779728569520212|0.0015217556332659434|0.0018232816512818658|0.002499134563735573|0.0034844817493359537|0.0033885004943519062|0.001918357422728328|0.0013042584875379419|0.00119433278607508|0.0014286719256021692|0.0016166503080048884|0.001014322658803112|0.0014710485551611638|0.0024719700576080125|0.0029564037502161763|0.0042577646904338445|0.004180436396324056|0.003405885778273545|0.003094761634759218|0.0033555408935837996|0.004604745982036552|0.00513155630420371|0.005111816763084349|0.004410429214870735|0.004944845598753611|0.004759583666963647|0.00556492072529206|0.0071292340848245145|0.009200618225404767|0.013940824544664087|0.023177118821449717|0.039875321834768725|0.05930102236000233|0.040577433769812404|0.020289894013505064|0.011875054402016865|0.00830600049027044|0.007068204494391262|0.00566941352552941|0.005014930024562716|0.005046984141793238|0.004633178165116732|0.0048133693890962176|0.005155461069595964|0.004318975377574615|0.0036826015473596287|0.003557282625757816|0.0038455885841249923|0.003634610919867605|0.0024308611050016375|0.00134084002245639|0.0022586381361529035|0.0034453648605122667|0.004115603775032945|0.00474582031719235|0.005457530377734437|0.005081030322806448|0.004859005759390519|0.005345069322366336|0.005680098231272916|0.005097691219898018|0.004442664428808774|0.003801763180905861|0.003973623956339561|0.006396154612795414|0.008936941419259914|0.009955067108920882|0.011923950513046474|0.014386322445156082|0.011295182744547204|0.008742081361971545|0.007039229021188531|0.00729892169976801|0.008249860510940147|0.008095566116135603|0.00827068663230461|0.008205672914305982|0.00768900400775978|0.007516418845496011|0.0069903329101589215|0.005835841399737598|0.005535764155381812|0.005194759055127168|0.005669594622236927|0.0044080749576730135|0.003233843906132328|0.0037501506192634962|0.005118879534677515|0.0045027885357044415|0.004314629056594205|0.005191137120976826|0.0059857894735617315|0.006556787392363055|0.005384186211190024|0.005476364435316212|0.006447223884315227|0.007180484453051846|0.006967333628304254|0.006523284501472397|0.006220852999918889|0.005966412125857405|0.0044863087353203875|0.004190034521822461|0.005391611176198224|0.005648225210749912|0.006263772919600435|0.0069526647949953715|0.007028182122029989|0.006625966334634576|0.006437987952231857|0.007742246439769798|0.0070182218031165505|0.0059303738810615085|0.007219420245168016|0.007308700921973932|0.007814685122776627|0.007666185822612629|0.008147540871193003|0.008152430482295964|0.0077855285528663784|0.008435303539437628|0.00800918298664996|0.008233742903971128|0.007580345983249538|0.007707838065341555|0.008106794112001662|0.007226845210176216|0.006091731047459218|0.006154209411552607|0.006137005224338485|0.006309771483309771|0.007778827974688247|0.00787752568028505|0.007982923964059986|0.008127258039951091|0.008523135442583407|0.008752041680884984|0.010178902639411982|0.012418525621275593|0.013312418969579853|0.013290144074555255|0.01271733518867876|0.012739610083703359|0.012597811361717493|0.01269886332451202|0.01185114963662461|0.011309308287733537|0.011045269288173648|0.010776521774218315|0.011665344414712097|0.01185368499052985|0.011570087546558118|0.010585464747787805|0.010344243933375068|0.010330118390188736|0.010766742552012393|0.011212421549211904|0.01195328817966424|0.012613385678563961|0.012976846770550722|0.013098543758002193|0.0127209571228291|0.012584953495483782|0.01271479983477352|0.012838669982715198|0.013615212664548395|0.014189289227377508|0.013428683055805813|0.012846638237845948|0.011669690735692507|0.011924131609753991|0.013958572022000761|0.01397287866189461|0.015057829036629378|0.015681345000610653|0.015431431544237095|0.01694377014871215|0.017555333729997298|0.016847064506898036|0.017017476508671598|0.01753776734936814|0.01688183507474131|0.01724674494038821|0.01793346365529294|0.017713612252367218|0.017960990354835536|0.018468423329298368|0.01870276246882546|0.01749032001199867|0.016101670458757773|0.017618536480920755|0.020168559219468626|0.021067885468998397|0.020906709399308207|0.02094618848154693|0.02224483297115184|0.023032603648851097|0.022855853262314436|0.022458527086021984|0.023147781154831952|0.023505447152178168|0.023429386535020996|0.02540750587122996|0.02802489658497418|0.02841914411723884|0.02816705750037508|0.028341091436298985|0.029032156472184125|0.030164191990873335|0.030759275771774428|0.03074297706809789|0.03154650315935113|0.03262982366371825|0.034101777702417|0.03427907137907621|0.035212081616204156|0.03666773695122637|0.038162328078364754|0.03950878209875417|0.04094306802228937|0.042348016279206806|0.04451846031879889|0.04708043544004289|0.049078837607493764|0.050444125685464955|0.0525991765049181|0.054816162398342076|0.05693010426518884|0.059651625585755375|0.06201167787811784|0.06515479233378411|0.06865955691436197|0.07236606322711386|0.07604286967983294|0.08207737416771677|0.08965391712010845|0.09646822403056078|0.10312352803181311|0.11136288493371728|0.12184385688126773|0.13429624758684902|0.1484194365159828|0.16418879451644675|0.18362735290791407|0.206987379403956|0.23606806979375472|0.2738464728521833|0.3236344851663139|0.3916122129768741|0.48440127629751806|0.6171498714219262|0.8202351600690119|1.1464343368071825|1.6959695793171203|2.6868047195420983|4.622843519308855|8.275752450503985|11.475286136623545|8.635368316100037|4.646714419616803|2.5616084004112745|1.565235866160547|1.0419819211356092|0.7371190151869772|0.5451753392764642|0.41764902990672587|0.3304402805315129|0.27223235789808364|0.23475801621157624|0.20708010091820475|0.1790383623394315|0.14739207489423845|0.11358856346910207|0.08691464832220523|0.06919270562129223|0.05664994765865993|0.0475547277170301|0.04018318623754774|0.03312639083573005|0.027861728451501297|0.023886293528086567|0.020153709289452225|0.016380378291626547|0.014602914107346498|0.013957666538463176|0.012501649010025928|0.010787206479961823|0.007974231322099167|0.005028874471041531|0.004786929269798725|0.004214482577337265|0.002894649772952855|0.0015373299501124115|6.483262129111124E-4|1.9087592972299232E-4|-4.047511413006526E-4|-0.0014502224337967007|-0.001014322658803112|-4.8715014322091966E-4|-4.3137235730566196E-4|0.0012397880596618648|0.0013524302117374825|7.033796119963019E-4|6.91065035885141E-4|2.3796107367743066E-4|-9.163493400363768E-4|-0.002176058037525119|-0.003081903768525506|-0.0026150364565464984|-0.0025214094587601727|-0.0016622866782991903|-0.00207772252534335|-0.002316770179265883|-0.002129335086985715|-0.002719710353491365|-0.0030708568693669645|-0.003280566856671732|-0.003256299897864445|-0.004433790690140438|-0.003990647046846166|-0.00391621630005665|-0.003956600865832957|-0.0048296680927727535|-0.004770087275999637|-0.004126288480776451|-0.0038823512157509575|-0.004083549657802423|-0.004098037394403789|-0.0032166397189182065|-0.0030659672582640037|-0.004527236591219246|-0.004565085803090314|-0.004150012149461188|-0.004397209155221989|-0.0023098885043802346|-3.13297304004532E-5|0.0015136062814276755|9.04215860632733E-4|-5.699113385562209E-4|-7.173240584751163E-4|-1.5755413553985135E-5|5.362273509580458E-4|7.573464308363889E-4|0.0019688834041255905|0.002284897158742879|0.0011208075228231495|-3.1166743363687837E-4|-9.455059099466251E-4|-0.0014965831909210707|-0.002228757179412587|-0.003241449967848045|-0.0032749528587387032|-0.002221513311111904|4.2593945608014985E-4|0.0016012570878659374|0.001556164007694187|5.822259146673817E-4|0.0010858558582723548|4.730246000345882E-4|-1.3527924051525168E-4|5.9037526650564986E-5|-5.298889661949483E-4|-8.055181550359297E-4|-7.573464308363889E-4|-2.4900797283597197E-4|-5.34235287175358E-4|-3.9460972567969665E-4|8.995073462372893E-4|0.0014594583658800713|5.93272813825923E-4|2.1532398523779685E-4|3.6219341503414103E-7|1.8960825277037282E-4|8.929878647666748E-4|0.001458371785634969|0.0013256278990249563|0.0017517484518126231|0.0016470745548677562|0.0019589230852121516|0.0017492130979073841|0.0013790514277424919|0.0019205305832185329|0.0028365177298398754|0.0031452876161564805|0.003700530121403819|0.004051495540571902|0.004435058367093057|0.004100391651601511|0.0038944846951546016|0.004289275517541815|0.004664870088932219|0.005710341381428267|0.007698602133258185|0.008885509954325065|0.009235932083370596|0.00970424816900974|0.011362007429621004|0.014330906852655858|0.016249083178676668|0.017497382783591836|0.0186618346129266|0.02188064749233501|0.026154348693030356|0.030973513176767123|0.03855548903038431|0.051112734729617984|0.06944171359412821|0.09275990675073373|0.11941589332358636|0.1342576739881479|0.11324973152933764|0.07518465238290954|0.0504466610393702|0.036507285268366246|0.02926721999854128|0.02470322077569607|0.02153022536328948|0.019370647126148412|0.018866111699005855|0.017896882120374494|0.017780436937441017|0.017694053807955374|0.017506799812382724|0.016136441026601053|0.013727854816624013|0.013102890078982602|0.012342827197533457|0.012219500339714333|0.010457429375573236|0.009771797240913607|0.009522064881247568|0.008924445746441235|0.007694255812277775|0.006049716611315257|0.005346518096026473|0.004871501432209197|0.004002237236127258|0.004117595838815632|0.004019260326633863|0.00430937725207621|0.004498080021308998|0.004235127601994211|0.0032182695892858603|0.002840682954112768|7.90849321727047E-4|3.089509830241223E-4|0.0010438414221283945|8.839330293908212E-4|0.0012189619382974015|0.0018393992582508851|0.0020393300233497312|9.471357803142788E-4|6.271378981316152E-4|7.327172786140673E-4|7.515513361958426E-4|0.001040038391270536|0.0012488428950377182|0.0021338625046736417|0.002780921040632135|0.0029940718653797267|0.00213458689150371|0.0018556979619274215|0.002629524193147864|0.004701270527143151|0.00590429595517905|0.006978561624170312|0.006860124377454148|0.00691753203373706|0.008840235777445797|0.012794482386081031|0.015162321836866728|0.015093686184717759|0.012426312779698828|0.009722901129883998|0.007214168440650021|0.007089211712463243|0.0064843487093562266|0.0063027087117166055|0.006334400635532093|0.005177373771205529|0.003705963022629331|0.0035085676114357243|0.0029185545383451084|0.0018269035854322074|0.0013721697528568434|8.053370583284126E-4|0.0012693068229871472|0.0013158486768190343|9.036725705101819E-4|-0.001446238306231325|-0.003359162827734141|-0.0021766013276476705|-0.0010463767760336335|-0.001397161098494199|-0.0014393566313456764|-0.0021179259944121395|-0.0022151749263488066|-0.0017276625897128528|-8.138486035817149E-4|-7.841487435489153E-5|-5.329676102227385E-4|-0.0015981784438381472|-0.0016200911454477128|-0.0021617513976312707|-0.0013864763927506918|-0.0010782497965566378|-0.0012591654073661914|-0.0011124770742773642|-0.001153042736761188|-2.021039255890507E-4|3.2488749328562453E-4|-5.983435216364009E-4|-0.0015241098904636655|-0.0012417801234445526|4.962049785967732E-5|1.5936510261502205E-4|0.0012450398641798597|0.002573565310525089|0.003253764543959206|0.002637854641693649|0.0026668301148963804|0.002961293361319137|0.0030206930813847363|0.002778928976849447|0.0020384245398121456|0.002680774561375195|0.003870579929762348|0.003412767453159194|0.002807723353344661|0.0021708062330071244|0.0022360010477132696|0.0014752137794340563|0.0013824922651853163|0.0029553171699710735|0.0033470293483304973|0.003320589229033005|0.00456780225370307|0.0044535302312597985|0.004056747345089896|0.003575211199802006|0.0020530933731210286|4.67410602101559E-4|6.39452474242776E-4|0.0011626408622595927|0.0017897787603912078|0.0034734348501774125|0.00403736999738557|0.003566880751256221|0.004309558348783727|0.0056436977930619855|0.005333841326500278|0.004704711364585975|0.006737884099880125|0.008851101579896822|0.010069158034656637|0.011100503783966355|0.011577150318151284|0.012149959204027777|0.013209556039710158|0.013961831762736068|0.015590434453437083|0.018039948519312978|0.01927013845347644|0.018419346121561243|0.01669403778904611|0.014805199129643065|0.013981028013732877|0.013157581284652758|0.013674069094491443|0.014779845590590675|0.01380663188439394|0.013839772581869563|0.01250961726515668|0.01249295636806511|0.013024294107920194|0.011464689262783182|0.01012403033703431|0.009705696942669878|0.009746986991983769|0.01135476356132032|0.013109771753868252|0.012768585556906091|0.011118432358010544|0.009613699815251205|0.007722144705235404|0.006788047887862354|0.006591920153621367|0.006288220975115239|0.006007158885048746|0.0059126264037248355|0.005349234546639229|0.003936136937883528|0.003989560466601064|0.004022338970661653|0.0033118965870721855|0.003246339578951006|0.003940664355571454|0.004710687555934038|0.00382965207386349|0.003036086301523687|0.002095107809264989|0.0023328877862349023|0.0022019548667000606|7.486537888755695E-4|1.0521718706741797E-4|4.7936298479768567E-4|6.066739701821862E-4|7.124344473721555E-4|0.0010856747615648377|0.0015016538987315487|0.0016010759911584205|0.001373980719932014|0.0017325522008158137|0.0021231777989301347|0.002683309915280434|0.003783472413446637|0.0038901383741741916|0.003300668591206127|0.002795227680525983|0.002051644599460892|0.0021847506794859385|0.002652342378295015|0.0028805242297665237|0.0021130363833091787|0.001181474919841368|3.41548390377195E-4|5.320621266851532E-4|0.0011695225371452414|0.0015596048451370112|0.0023289036586695267|0.002267330778113723|0.002082612136446311|9.730326094892199E-4|-3.739647010227506E-4|-5.954459743161279E-4|-0.0011054143026841983|-6.876241984423168E-4|4.435058367093057E-4|4.561826062355006E-4|-0.0013105968723010394|-0.0014828198411497733|-0.00194914386300623|-0.0013087859052258687|-0.001784889149288247|-0.00232002992000119|-0.0011572079610340806|-0.0010335189097999214|-0.0019245147107839083|-0.0020992730335378813|-0.001843926675938812|-0.001988622945244951|-0.002196340868767031|-0.0021822153255806995|-0.0022041280271902653|-0.0020201337723529215|-0.001293935975209469|-2.685664172478156E-4|-6.195318364158982E-4|-0.0016773177050231072|-0.0020891316179169252|-0.0024006179548462865|-0.0013350449278158438|-5.201097439890265E-4|-9.574582926427518E-4|-0.0017329143942308477|-0.0023073531504749956|-0.0015545341373265334|-0.00196272611607001|-0.001954214570816708|-0.0017801806348928032|-0.0018011878529647833|-0.001805534173945193|-0.0013310608002504683|-0.0018272657788472415|-0.003216096428795655|-0.0026905537835811167|-0.00218529396960849|-0.0016496099087729952|-0.0018640284104732069|-0.002041322087132419|-0.002412208144127379|-0.002525031392910514|-0.001944435348610786|-0.0019120190379652304|-0.0021842073893633875|-0.0019275933548116985|-0.0024078618231469697|-0.0019998509411110095|-0.0016354843655866638|-0.0025978322693323767|-0.0026793257877150583|-0.00281460502823031|-0.0034725293666398272|-0.0027964953574786027|-0.002441545810745145|-0.002431404395124189|-0.002036251379321941|-0.002791605746375642|-0.0029035235116211915|-0.0019100269741825428|-0.0016371142359543173|-0.0018426589989861924|-0.0020954700026800228|-0.002925798406645791|-0.003028118046392936|-0.0030934939578065985|-0.004129729318219276|-0.005449743219311203|-0.004679720018948619|-0.0014802844872445343|-7.13883221032292E-4|-1.6479800384053416E-4|-4.346320980409692E-5|-8.0117183405552E-4|-0.0018625796368130702|-0.0034987883892298025|-0.0039026340469928695|-0.003101643309644867|-0.0026420198659665418|-0.0021814909387506314|-0.002112674189894145|-0.001756638062915584|-0.0012003089774231433|-0.0012037498148659677|-0.0014886149357903197|-0.002039692216764765|-0.002026291060408502|-0.0016456257812076198|-0.0011695225371452414|-5.715412089238746E-4|-0.001305163971075527|-0.002049109245555653|-0.002714277452265853|-0.0021474447577374224|-0.0012705744999397667|-0.0012517404423579915|-3.978694664150039E-4|-0.0016032491516486252|-0.0024848279238417247|-0.0019781193362089613|-7.577086242514231E-4|7.098990934669164E-5|-1.3654691746787116E-4|-6.309409289894736E-4|-0.0010072598872099463|-0.00134826498746459|-0.0016561293902436099|-0.002678963594300024|-0.0021327759244285393|-0.001407302514115155|-8.446350438596168E-4|-8.310527907958366E-4|-7.692988135325155E-4|-1.628059400578464E-4|4.074675919134087E-5|-3.777677318806091E-4|-3.9750727299996976E-4|-7.765426818331984E-4|-6.206184166610007E-4|-3.3321794183140976E-4|-0.0010311646526021995|-0.001412735415340667|-0.0016068710857989666|-0.002036432476029458|-0.0014158140593684572|-5.508961842669285E-4|-3.513276125831168E-4|-0.0012057418786486555|-0.0015404085941402017|-6.664358836628195E-4|-6.727742684259169E-4|-0.0010795174735092573|-1.0920131463279352E-4|0.0010177634962459364|0.0014246877980367938|0.0012870543003238202|0.0018741698260941627|0.0012129857469493383|3.540440631958729E-4|-1.1572079610340806E-4|5.355029641279775E-4|4.733867934496223E-4|-2.90116925442347E-4|-1.9015154289292405E-5|-4.3825403219131066E-4|-0.0015679352936827965|-0.0017778263776950813|-9.657887411885371E-4|-7.890383546518763E-4|-5.429279291361774E-4|4.962049785967733E-4|6.954113568655507E-4|4.110895260637501E-5|-8.076913155261345E-4|-0.0010543450311643846|-4.7447337369472474E-4|2.973607937430298E-4|-3.145649809571515E-4|-0.0014728595222363344|-0.002381059510434443|-0.0018069829476053297|-5.594077295202308E-4|-1.2151589074395431E-4|-1.3256278990249562E-4|-1.1771285988609584E-5|5.157634230086169E-4|6.273189948391323E-4|0.0015318970488868995|5.713601122163574E-4|-2.6204693577720105E-4|-1.0413060682231555E-4|0.0012245759362304307|0.001471591845283715|1.8960825277037282E-4|-6.773016861138437E-5|0.0011333031956418272|0.0010264561382067557|-9.779222205921808E-6|2.0844231035214815E-4|0.00104040058468557|0.001674420157702834|0.0010159525291707657|4.7936298479768567E-4|-1.7584490299907548E-4|-5.278969024122605E-4|-6.9360038979038E-5|3.451703245275364E-4|2.910224089799323E-4|-9.344590107880838E-5|-5.181176802063388E-4|-0.001176223115323373|-4.93126334568983E-4|-2.1043437413483594E-4|3.8030308578584806E-4|0.0010096141444076682|6.115635812851472E-4|-4.0855417215851107E-4|-0.0010465578727411504|-0.001037865230780331|3.496977422154632E-4|9.857093790154147E-4|0.0011995845905930752|3.413672936696779E-4|2.1514288853027977E-4|0.0013745240100545653|0.0015337080159620702|0.002293589800703698|0.0026436497363341955|0.0015241098904636655|7.495592724131549E-4|8.975152824546015E-4|0.0011686170536076561|0.00209257245535975|0.002835431149594773|0.002228938276120104|0.0010161336258782826|2.973607937430298E-4|7.551732703461841E-5|7.334416654441356E-5|3.113052402218442E-4|0.0012057418786486555|0.002351902940524195|0.0020795334924185206|0.0011639085392122122|8.623825211962898E-4|0.001204293104988519|0.0017564569662080669|0.0015885803183397426|9.63072290575781E-4|8.355802084837634E-4|0.001446057209523808|0.001525739760831319|0.0013526113084449997|0.0026130443927638103|0.0025480306747651823|0.002655783215737839|0.003241449967848045|0.0033213136158630734|0.0028667608799952263|0.003579376424074899|0.004174098011560958|0.0038178807878748804|0.0031114225318507886|0.002396996020695945|0.0018573278322950753|0.0011365629363771345|8.995073462372893E-4|0.0011831047902090216|0.0011135636545224665|8.37210078851417E-4|0.00153062937193428|0.002068124399844945|0.001805896367360227|0.0013881062631183455|0.0012578977304135719|7.064582560240921E-4|5.610375998878845E-4|7.367014061794428E-4|0.00117640421203089|0.0015501878163461237|0.0014947722238459|5.224640011867484E-4|-6.217049969061031E-4|-0.0013268955759775756|-0.0012182375514673334|-0.0014750326827265394|-0.0011649951194573145|-4.08373075450994E-4|-3.98050563122521E-4|-0.0013247224154873708|-0.0019303098054244546|-8.815787721930992E-4|-2.95368729960342E-4|-5.550614085398211E-4|-7.511891427808085E-4|-7.118911572496042E-4|-0.0011189965557479788|-0.001150326286148432|-0.0012872353970313371|-0.0019909772024426734|-0.002265157617623518|-0.0028875870013596893|-0.0025087326892339777|-0.002214088346103704|-0.002657231989397976|-0.003559455786248021|-0.0034986072925222854|-0.0024871821810394466|-0.002648177154022122|-0.003940121065448903|-0.004554220000639289| cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/spectrum6.xml000077500000000000000000000043021477224461000314010ustar00rootroot00000000000000 CDCl3 400.0 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/spectrumData1.xml000077500000000000000000000061371477224461000321760ustar00rootroot00000000000000 450 454 458 462 466 470 474 478 482 486 490 494 498 502 506 510 514 518 522 526 530 534 538 542 546 550 554 558 562 566 570 574 578 582 586 590 594 598 602 606 610 614 618 622 626 630 634 638 642 646 650 654 658 662 666 670 674 678 682 686 690 694 698 702 706 710 714 718 722 726 730 734 738 742 746 750 754 758 762 766 770 774 778 782 786 790 794 798 802 806 810 814 818 822 826 830 834 838 842 846 850 854 858 862 866 870 874 878 882 886 890 894 898 902 906 910 914 918 922 926 930 934 938 942 946 950 954 958 962 966 970 974 978 982 986 990 994 998 1002 1006 1010 1014 1018 1022 1026 1030 1034 1038 1042 1046 1050 1054 1058 1062 1066 1070 1074 1078 1082 1086 1090 1094 1098 1102 1106 1110 1114 1118 1122 1126 1130 1134 1138 1142 1146 1150 1154 1158 1162 1166 1170 1174 1178 1182 1186 1190 1194 1198 1202 1206 1210 1214 1218 1222 1226 1230 1234 1238 1242 1246 1250 1254 1258 1262 1266 1270 1274 1278 1282 1286 1290 1294 1298 1302 1306 1310 1314 1318 1322 1326 1330 1334 1338 1342 331 179 99 148 146 150 187 165 249 206 189 224 253 230 267 236 167 137 96 109 51 77 28 64 50 68 82 51 103 37 133 111 124 119 144 1 120 93 89 119 109 133 89 126 119 89 47 97 57 89 81 77 86 52 51 114 77 87 63 57 70 69 60 44 61 39 44 57 24 55 50 42 37 43 67 66 92 112 128 148 162 160 162 178 178 154 155 167 176 170 179 195 210 216 190 173 158 146 135 121 109 101 105 108 133 162 206 288 417 579 792 1063 1377 1675 1797 1736 1700 1794 1780 1552 1198 878 648 524 492 516 599 730 896 1110 1360 1623 1889 2123 2282 2404 2451 2442 2396 2327 2185 2029 1915 1803 1691 1594 1520 1448 1382 1300 1230 1211 1264 1392 1518 1659 1758 1867 1968 2018 2005 1960 1969 2010 2063 2100 2175 2254 2344 2467 2557 3 1 15 1 1 17 10 9 1 7 35 2 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/spectrumList1.xml000077500000000000000000000020011477224461000322220ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/sphere31.xml000077500000000000000000000016171477224461000311110ustar00rootroot00000000000000 1 2 3 4 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/spin1.xml000077500000000000000000000016611477224461000305100ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/stateType1.xml000077500000000000000000000020451477224461000315160ustar00rootroot00000000000000 21.3 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/stmml1.xml000077500000000000000000000031571477224461000306750ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/substance1.xml000077500000000000000000000020031477224461000315150ustar00rootroot00000000000000 1.2 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/substanceList1.xml000077500000000000000000000026111477224461000323560ustar00rootroot00000000000000 100 1 0.1 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/substanceList2.xml000077500000000000000000000025431477224461000323630ustar00rootroot00000000000000 100 1 0.1 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/symmetry1.xml000077500000000000000000000027251477224461000314320ustar00rootroot00000000000000 1 0 0 0 1 0 0 0 1 -1 0 0 0 -1 0 0 0 1 -1 0 0 0 1 0 0 0 1 1 0 0 0 -1 0 0 0 1 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/symmetry2.xml000077500000000000000000000023741477224461000314330ustar00rootroot00000000000000 1 0 0 0 0 1 0 0 0 0 1 0 -1 0 0 0 0 -1 0 0 0 0 1 0.5 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/system1.xml000077500000000000000000000017551477224461000310670ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/table1.xml000077500000000000000000000020671477224461000306270ustar00rootroot00000000000000 3 5 7Sue Fred Sandy
cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/table4.xml000077500000000000000000000023331477224461000306260ustar00rootroot00000000000000 |C 123|C 127|D 437|E 999|P 333| 2.35 12.3 1.3E-03 2.7E+03 3.45 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/table5.xml000077500000000000000000000031331477224461000306260ustar00rootroot00000000000000 C1232.35 C12712.3 D4371.3E-03 E9992.7E+03 P3333.45 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/table6.xml000077500000000000000000000032151477224461000306300ustar00rootroot00000000000000 C123 26 C124 28 C125 46 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/table7.xml000077500000000000000000000024311477224461000306300ustar00rootroot00000000000000 C123 2.35 C127 12.3 D437 1.3E-03 E999 2.7E+03 P333 3.45 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/title1.xml000077500000000000000000000017451477224461000306630ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/torsion1.xml000077500000000000000000000020631477224461000312310ustar00rootroot00000000000000 123 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/transitionState1.xml000077500000000000000000000027221477224461000327310ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/unitList1.xml000077500000000000000000000016211477224461000313460ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/unitType1.xml000077500000000000000000000025741477224461000313640ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/unitType2.xml000077500000000000000000000024541477224461000313620ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/vector31.xml000077500000000000000000000016421477224461000311230ustar00rootroot00000000000000 2.0 3.0 4.0 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/xaxis.xml000077500000000000000000000016701477224461000306120ustar00rootroot00000000000000 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/xaxis1.xml000077500000000000000000000017061477224461000306730ustar00rootroot00000000000000 1 2 3 4 5 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/yaxis.xml000077500000000000000000000017341477224461000306140ustar00rootroot00000000000000 22 55 11 99 33 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/yaxis1.xml000077500000000000000000000017141477224461000306730ustar00rootroot00000000000000 22 55 11 99 33 cmlxom-cmlxom-4.11/src/test/resources/org/xmlcml/cml/element/examples/xsd/zMatrix1.xml000077500000000000000000000027761477224461000312050ustar00rootroot00000000000000 1.42450 1.42450 120.00000 1.42450 120.00000 0.00000