Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
Woodstox 6.4.0 - Source Code Files
Woodstox 6.4.0 Source Code Files are provided at the Woodstox GitHub Website.
You can download them from the "src/main/java" folder.
You can also browse Woodstox Source Code files below:
✍: FYIcenter
⏎ com/ctc/wstx/dtd/SeqContentSpec.java
package com.ctc.wstx.dtd; import java.util.*; import com.ctc.wstx.util.PrefixedName; /** * Content specification that defines model that has sequence of one or more * elements that have to come in the specified order. */ public class SeqContentSpec extends ContentSpec { final boolean mNsAware; final ContentSpec[] mContentSpecs; /* /////////////////////////////////////////////////// // Life-cycle /////////////////////////////////////////////////// */ public SeqContentSpec(boolean nsAware, char arity, ContentSpec[] subSpecs) { super(arity); mNsAware = nsAware; mContentSpecs = subSpecs; } public static SeqContentSpec construct(boolean nsAware, char arity, Collection<ContentSpec> subSpecs) { ContentSpec[] specs = new ContentSpec[subSpecs.size()]; subSpecs.toArray(specs); return new SeqContentSpec(nsAware, arity, specs); } /* /////////////////////////////////////////////////// // Public API /////////////////////////////////////////////////// */ @Override public StructValidator getSimpleValidator() { /* Can we create a simple validator? Yes, if the sub-specs are * all simple (leaves == element tokens with no arity modifier) */ ContentSpec[] specs = mContentSpecs; int i = 0; int len = specs.length; for (; i < len; ++i) { if (!specs[i].isLeaf()) { break; } } if (i == len) { // all leaves, kewl PrefixedName[] set = new PrefixedName[len]; for (i = 0; i < len; ++i) { TokenContentSpec ss = (TokenContentSpec) specs[i]; set[i] = ss.getName(); } return new Validator(mArity, set); } // Nope, need a DFA: return null; } @Override public ModelNode rewrite() { /* First, need to create a tree of sub-models, consisting of * binary concat nodes (as opposed to n-ary list). Can do that * recursively (note that we'll always have at least 2 child * nodes!) */ ModelNode model = rewrite(mContentSpecs, 0, mContentSpecs.length); // and then resolve arity modifiers, if necessary: if (mArity == '*') { return new StarModel(model); } if (mArity == '?') { return new OptionalModel(model); } if (mArity == '+') { return new ConcatModel(model, new StarModel(model.cloneModel())); } return model; } private ModelNode rewrite(ContentSpec[] specs, int first, int last) { // 3 or less, can convert and create; 4 or more, need to recurse: int count = last - first; if (count > 3) { int mid = (last + first + 1) >> 1; return new ConcatModel(rewrite(specs, first, mid), rewrite(specs, mid, last)); } ConcatModel model = new ConcatModel(specs[first].rewrite(), specs[first+1].rewrite()); if (count == 3) { model = new ConcatModel(model, specs[first+2].rewrite()); } return model; } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append('('); for (int i = 0; i < mContentSpecs.length; ++i) { if (i > 0) { sb.append(", "); } sb.append(mContentSpecs[i].toString()); } sb.append(')'); if (mArity != ' ') { sb.append(mArity); } return sb.toString(); } /* /////////////////////////////////////////////////// // Validator class that can be used for simple // choices (including mixed content) /////////////////////////////////////////////////// */ /** * Simple validator that can be used if all components of a sequence * are leaf nodes, ie. elements with no explicit arity modifiers. */ final static class Validator extends StructValidator { final char mArity; final PrefixedName[] mNames; /** * Number of full repetitions done over the sequence */ int mRounds = 0; /** * Expected next element in the sequence */ int mStep = 0; public Validator(char arity, PrefixedName[] names) { mArity = arity; mNames = names; } /** * Sequence content specification is always stateful; can not * use a shared instance... so let's create new instance: */ @Override public StructValidator newInstance() { return new Validator(mArity, mNames); } @Override public String tryToValidate(PrefixedName elemName) { // First; have we already done that max. 1 sequence? if (mStep == 0 && mRounds == 1) { if (mArity == '?' || mArity == ' ') { return "was not expecting any more elements in the sequence (" +concatNames(mNames)+")"; } } PrefixedName next = mNames[mStep]; if (!elemName.equals(next)) { return expElem(mStep); } if (++mStep == mNames.length) { ++mRounds; mStep = 0; } return null; } @Override public String fullyValid() { if (mStep != 0) { return expElem(mStep)+"; got end element"; } switch (mArity) { case '*': case '?': return null; case '+': // need at least one (and multiples checked earlier) case ' ': if (mRounds > 0) { return null; } return "Expected sequence ("+concatNames(mNames)+"); got end element"; } // should never happen: throw new IllegalStateException("Internal error"); } private String expElem(int step) { return "expected element <"+mNames[step]+"> in sequence (" +concatNames(mNames)+")"; } final static String concatNames(PrefixedName[] names) { StringBuilder sb = new StringBuilder(); for (int i = 0, len = names.length; i < len; ++i) { if (i > 0) { sb.append(", "); } sb.append(names[i].toString()); } return sb.toString(); } } }
⏎ com/ctc/wstx/dtd/SeqContentSpec.java
Or download all of them as a single archive file:
File name: woodstox-core-6.4.0-fyi.zip File size: 552992 bytes Release date: 2022-10-25 Download
⇒ woodstox-core-6.4.0.jar - Woodstox Core 6.4.0
⇐ What Is Woodstox XML Processing
2023-01-29, 3212👍, 0💬
Popular Posts:
maven-model-builder-3.8. 6.jaris the JAR file for Apache Maven 3.8.6 Model Builder module. Apache Ma...
The Apache FontBox library is an open source Java tool to obtain low level information from font fil...
How to read XML document with DTD validation from socket connections with the socket\DelayedInput.ja.. .
Apache Log4j SLF4J Binding allows applications coded to the SLF4J API to use Log4j 2 as the implemen...
XMLSchema, Release 1.4.2, is a lightweight Java object model that can be used to manipulate and gene...