|
From: Peter Murray-R. <pe...@us...> - 2006-12-13 22:40:10
|
Update of /cvsroot/cml/jumbo53/src/org/xmlcml/cml/element In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv31396/src/org/xmlcml/cml/element Modified Files: CMLBuilder.java CMLFragmentList.java Log Message: latest examples Index: CMLFragmentList.java =================================================================== RCS file: /cvsroot/cml/jumbo53/src/org/xmlcml/cml/element/CMLFragmentList.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CMLFragmentList.java 7 Dec 2006 11:24:42 -0000 1.3 --- CMLFragmentList.java 13 Dec 2006 22:39:35 -0000 1.4 *************** *** 2,5 **** --- 2,8 ---- package org.xmlcml.cml.element; + import java.util.ArrayList; + import java.util.List; + import nu.xom.Element; import nu.xom.Elements; *************** *** 98,101 **** --- 101,111 ---- /** clone content of element with CountExpression and append. * clones the element content and appends to original element content + * significant children can only be join-fragment-join-fragment...join + * if FragmentLIst occurs only once (either explicitly or after application of + * countExpression its contents are interpreted as + * [J*1-F1-J12-F2-J23-F3] and any trailing join is ignored + * if count is greater that one + * syntax should be [JP1-F1-J12-F2-J21]n + * * @param element to process * @throws CMLRuntimeException null element or bad attribute *************** *** 106,113 **** int count = cea.calculateCountExpression(); int nChild = this.getChildCount(); for (int i = 1; i < count; i++) { for (int j = 0; j < nChild; j++) { Node newChild = this.getChild(j).copy(); ! if (newChild instanceof CMLJoin) { CMLJoin join = (CMLJoin) newChild; String[] att = join.getMoleculeRefs2(); --- 116,149 ---- int count = cea.calculateCountExpression(); int nChild = this.getChildCount(); + if (nChild %2 != 1) { + throw new CMLRuntimeException("Must have odd number of join-frag-join children"); + } + List<CMLJoin> joinList = new ArrayList<CMLJoin>(); + List<CMLFragment> fragList = new ArrayList<CMLFragment>(); + // make lists of Join and Fragment children; check they alternate JFJF...J + int nsig = 0; + for (int j = 0; j < nChild; j++) { + Node newChild = this.getChild(j).copy(); + if (newChild instanceof CMLJoin) { + if (nsig %2 != 0) { + throw new CMLRuntimeException("unexpected JOIN after: "+nsig+" significant children"); + } + joinList.add((CMLJoin) newChild); + nsig++; + } else if (newChild instanceof CMLFragment) { + if (nsig %2 != 1) { + throw new CMLRuntimeException("unexpected FRAG after: "+nsig+" significant children"); + } + fragList.add((CMLFragment) newChild); + nsig++; + } + } for (int i = 1; i < count; i++) { for (int j = 0; j < nChild; j++) { Node newChild = this.getChild(j).copy(); ! if (nsig %2 == 0) { ! if (!(newChild instanceof CMLJoin)) { ! throw new CMLRuntimeException("expected JOIN found: "+newChild); ! } CMLJoin join = (CMLJoin) newChild; String[] att = join.getMoleculeRefs2(); Index: CMLBuilder.java =================================================================== RCS file: /cvsroot/cml/jumbo53/src/org/xmlcml/cml/element/CMLBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CMLBuilder.java 7 Dec 2006 22:21:51 -0000 1.2 --- CMLBuilder.java 13 Dec 2006 22:39:35 -0000 1.3 *************** *** 1,5 **** package org.xmlcml.cml.element; - import java.io.File; import java.io.IOException; import java.io.StringReader; --- 1,4 ---- |