Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
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 (322)
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/TokenContentSpec.java
package com.ctc.wstx.dtd;
import com.ctc.wstx.cfg.ErrorConsts;
import com.ctc.wstx.util.PrefixedName;
/**
* Content specification that defines content model consisting of just
* one allowed element. In addition to the allowed element, spec can have
* optional arity ("*", "+", "?") marker.
*/
public class TokenContentSpec
extends ContentSpec
{
final static TokenContentSpec sDummy = new TokenContentSpec
(' ', new PrefixedName("*", "*"));
final PrefixedName mElemName;
/*
///////////////////////////////////////////////////
// Life-cycle
///////////////////////////////////////////////////
*/
public TokenContentSpec(char arity, PrefixedName elemName)
{
super(arity);
mElemName = elemName;
}
public static TokenContentSpec construct(char arity, PrefixedName elemName)
{
return new TokenContentSpec(arity, elemName);
}
public static TokenContentSpec getDummySpec() {
return sDummy;
}
/*
///////////////////////////////////////////////////
// Public API
///////////////////////////////////////////////////
*/
@Override
public boolean isLeaf() {
return mArity == ' ';
}
public PrefixedName getName() {
return mElemName;
}
@Override
public StructValidator getSimpleValidator() {
return new Validator(mArity, mElemName);
}
@Override
public ModelNode rewrite() {
TokenModel model = new TokenModel(mElemName);
if (mArity == '*') {
return new StarModel(model);
}
if (mArity == '?') {
return new OptionalModel(model);
}
if (mArity == '+') {
return new ConcatModel(model,
new StarModel(new TokenModel(mElemName)));
}
return model;
}
@Override
public String toString() {
return (mArity == ' ') ? mElemName.toString()
: (mElemName.toString() + mArity);
}
/*
///////////////////////////////////////////////////
// Validator class:
///////////////////////////////////////////////////
*/
final static class Validator
extends StructValidator
{
final char mArity;
final PrefixedName mElemName;
int mCount = 0;
public Validator(char arity, PrefixedName elemName)
{
mArity = arity;
mElemName = elemName;
}
/**
* Rules for reuse are simple: if we can have any number of
* repetitions, we can just use a shared root instance. Although
* its count variable will get updated this doesn't really
* matter as it won't be used. Otherwise a new instance has to
* be created always, to keep track of instance counts.
*/
@Override
public StructValidator newInstance() {
return (mArity == '*') ? this : new Validator(mArity, mElemName);
}
@Override
public String tryToValidate(PrefixedName elemName)
{
if (!elemName.equals(mElemName)) {
return "Expected element <"+mElemName+">";
}
if (++mCount > 1 && (mArity == '?' || mArity == ' ')) {
return "More than one instance of element <"+mElemName+">";
}
return null;
}
@Override
public String fullyValid()
{
switch (mArity) {
case '*':
case '?':
return null;
case '+': // need at least one (and multiples checked earlier)
case ' ':
if (mCount > 0) {
return null;
}
return "Expected "+(mArity == '+' ? "at least one" : "")
+" element <"+mElemName+">";
}
// should never happen:
throw new IllegalStateException(ErrorConsts.ERR_INTERNAL);
}
}
}
⏎ com/ctc/wstx/dtd/TokenContentSpec.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, ≈46🔥, 0💬
Popular Posts:
jlGui is a music player for the Java platform. It is based on Java Sound 1.0 (i.e. JDK 1.3+). It sup...
What Is mail.jar of JavaMail 1.3? I got the JAR file from javamail-1_3.zip. mail.jar in javamail-1_3...
How to perform XML Schema validation with dom\Writer.java provided in the Apache Xerces package? You...
What Is jsse.jar (JDK 6) Java Secure Socket Extension? jsse.jar, Java Secure Socket Extension, is Ja...
Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java"....