Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.apache.maven.settings.v4.SettingsStaxReader Maven / Gradle / Ivy
// =================== DO NOT EDIT THIS FILE ====================
// Generated by Modello Velocity from reader-stax.vm
// template, any modifications will be overwritten.
// ==============================================================
package org.apache.maven.settings.v4;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.maven.api.annotations.Generated;
import org.apache.maven.api.settings.InputSource;
import org.apache.maven.api.settings.InputLocation;
import org.apache.maven.api.settings.TrackableBase;
import org.apache.maven.api.settings.IdentifiableBase;
import org.apache.maven.api.settings.Settings;
import org.apache.maven.api.settings.Proxy;
import org.apache.maven.api.settings.Server;
import org.apache.maven.api.settings.Mirror;
import org.apache.maven.api.settings.Profile;
import org.apache.maven.api.settings.Activation;
import org.apache.maven.api.settings.RepositoryBase;
import org.apache.maven.api.settings.Repository;
import org.apache.maven.api.settings.RepositoryPolicy;
import org.apache.maven.api.settings.ActivationProperty;
import org.apache.maven.api.settings.ActivationOS;
import org.apache.maven.api.settings.ActivationFile;
import org.apache.maven.api.settings.InputLocation;
import org.apache.maven.api.settings.InputSource;
import org.apache.maven.internal.xml.XmlNodeStaxBuilder;
import org.apache.maven.api.xml.XmlNode;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.stream.StreamSource;
import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
import static javax.xml.XMLConstants.XML_NS_URI;
@Generated
public class SettingsStaxReader {
private static final Map DEFAULT_ENTITIES;
static {
Map entities = new HashMap<>();
entities.put("nbsp", "\u00a0");
entities.put("iexcl", "\u00a1");
entities.put("cent", "\u00a2");
entities.put("pound", "\u00a3");
entities.put("curren", "\u00a4");
entities.put("yen", "\u00a5");
entities.put("brvbar", "\u00a6");
entities.put("sect", "\u00a7");
entities.put("uml", "\u00a8");
entities.put("copy", "\u00a9");
entities.put("ordf", "\u00aa");
entities.put("laquo", "\u00ab");
entities.put("not", "\u00ac");
entities.put("shy", "\u00ad");
entities.put("reg", "\u00ae");
entities.put("macr", "\u00af");
entities.put("deg", "\u00b0");
entities.put("plusmn", "\u00b1");
entities.put("sup2", "\u00b2");
entities.put("sup3", "\u00b3");
entities.put("acute", "\u00b4");
entities.put("micro", "\u00b5");
entities.put("para", "\u00b6");
entities.put("middot", "\u00b7");
entities.put("cedil", "\u00b8");
entities.put("sup1", "\u00b9");
entities.put("ordm", "\u00ba");
entities.put("raquo", "\u00bb");
entities.put("frac14", "\u00bc");
entities.put("frac12", "\u00bd");
entities.put("frac34", "\u00be");
entities.put("iquest", "\u00bf");
entities.put("Agrave", "\u00c0");
entities.put("Aacute", "\u00c1");
entities.put("Acirc", "\u00c2");
entities.put("Atilde", "\u00c3");
entities.put("Auml", "\u00c4");
entities.put("Aring", "\u00c5");
entities.put("AElig", "\u00c6");
entities.put("Ccedil", "\u00c7");
entities.put("Egrave", "\u00c8");
entities.put("Eacute", "\u00c9");
entities.put("Ecirc", "\u00ca");
entities.put("Euml", "\u00cb");
entities.put("Igrave", "\u00cc");
entities.put("Iacute", "\u00cd");
entities.put("Icirc", "\u00ce");
entities.put("Iuml", "\u00cf");
entities.put("ETH", "\u00d0");
entities.put("Ntilde", "\u00d1");
entities.put("Ograve", "\u00d2");
entities.put("Oacute", "\u00d3");
entities.put("Ocirc", "\u00d4");
entities.put("Otilde", "\u00d5");
entities.put("Ouml", "\u00d6");
entities.put("times", "\u00d7");
entities.put("Oslash", "\u00d8");
entities.put("Ugrave", "\u00d9");
entities.put("Uacute", "\u00da");
entities.put("Ucirc", "\u00db");
entities.put("Uuml", "\u00dc");
entities.put("Yacute", "\u00dd");
entities.put("THORN", "\u00de");
entities.put("szlig", "\u00df");
entities.put("agrave", "\u00e0");
entities.put("aacute", "\u00e1");
entities.put("acirc", "\u00e2");
entities.put("atilde", "\u00e3");
entities.put("auml", "\u00e4");
entities.put("aring", "\u00e5");
entities.put("aelig", "\u00e6");
entities.put("ccedil", "\u00e7");
entities.put("egrave", "\u00e8");
entities.put("eacute", "\u00e9");
entities.put("ecirc", "\u00ea");
entities.put("euml", "\u00eb");
entities.put("igrave", "\u00ec");
entities.put("iacute", "\u00ed");
entities.put("icirc", "\u00ee");
entities.put("iuml", "\u00ef");
entities.put("eth", "\u00f0");
entities.put("ntilde", "\u00f1");
entities.put("ograve", "\u00f2");
entities.put("oacute", "\u00f3");
entities.put("ocirc", "\u00f4");
entities.put("otilde", "\u00f5");
entities.put("ouml", "\u00f6");
entities.put("divide", "\u00f7");
entities.put("oslash", "\u00f8");
entities.put("ugrave", "\u00f9");
entities.put("uacute", "\u00fa");
entities.put("ucirc", "\u00fb");
entities.put("uuml", "\u00fc");
entities.put("yacute", "\u00fd");
entities.put("thorn", "\u00fe");
entities.put("yuml", "\u00ff");
// ----------------------------------------------------------------------
// Special entities
// ----------------------------------------------------------------------
entities.put("OElig", "\u0152");
entities.put("oelig", "\u0153");
entities.put("Scaron", "\u0160");
entities.put("scaron", "\u0161");
entities.put("Yuml", "\u0178");
entities.put("circ", "\u02c6");
entities.put("tilde", "\u02dc");
entities.put("ensp", "\u2002");
entities.put("emsp", "\u2003");
entities.put("thinsp", "\u2009");
entities.put("zwnj", "\u200c");
entities.put("zwj", "\u200d");
entities.put("lrm", "\u200e");
entities.put("rlm", "\u200f");
entities.put("ndash", "\u2013");
entities.put("mdash", "\u2014");
entities.put("lsquo", "\u2018");
entities.put("rsquo", "\u2019");
entities.put("sbquo", "\u201a");
entities.put("ldquo", "\u201c");
entities.put("rdquo", "\u201d");
entities.put("bdquo", "\u201e");
entities.put("dagger", "\u2020");
entities.put("Dagger", "\u2021");
entities.put("permil", "\u2030");
entities.put("lsaquo", "\u2039");
entities.put("rsaquo", "\u203a");
entities.put("euro", "\u20ac");
// ----------------------------------------------------------------------
// Symbol entities
// ----------------------------------------------------------------------
entities.put("fnof", "\u0192");
entities.put("Alpha", "\u0391");
entities.put("Beta", "\u0392");
entities.put("Gamma", "\u0393");
entities.put("Delta", "\u0394");
entities.put("Epsilon", "\u0395");
entities.put("Zeta", "\u0396");
entities.put("Eta", "\u0397");
entities.put("Theta", "\u0398");
entities.put("Iota", "\u0399");
entities.put("Kappa", "\u039a");
entities.put("Lambda", "\u039b");
entities.put("Mu", "\u039c");
entities.put("Nu", "\u039d");
entities.put("Xi", "\u039e");
entities.put("Omicron", "\u039f");
entities.put("Pi", "\u03a0");
entities.put("Rho", "\u03a1");
entities.put("Sigma", "\u03a3");
entities.put("Tau", "\u03a4");
entities.put("Upsilon", "\u03a5");
entities.put("Phi", "\u03a6");
entities.put("Chi", "\u03a7");
entities.put("Psi", "\u03a8");
entities.put("Omega", "\u03a9");
entities.put("alpha", "\u03b1");
entities.put("beta", "\u03b2");
entities.put("gamma", "\u03b3");
entities.put("delta", "\u03b4");
entities.put("epsilon", "\u03b5");
entities.put("zeta", "\u03b6");
entities.put("eta", "\u03b7");
entities.put("theta", "\u03b8");
entities.put("iota", "\u03b9");
entities.put("kappa", "\u03ba");
entities.put("lambda", "\u03bb");
entities.put("mu", "\u03bc");
entities.put("nu", "\u03bd");
entities.put("xi", "\u03be");
entities.put("omicron", "\u03bf");
entities.put("pi", "\u03c0");
entities.put("rho", "\u03c1");
entities.put("sigmaf", "\u03c2");
entities.put("sigma", "\u03c3");
entities.put("tau", "\u03c4");
entities.put("upsilon", "\u03c5");
entities.put("phi", "\u03c6");
entities.put("chi", "\u03c7");
entities.put("psi", "\u03c8");
entities.put("omega", "\u03c9");
entities.put("thetasym", "\u03d1");
entities.put("upsih", "\u03d2");
entities.put("piv", "\u03d6");
entities.put("bull", "\u2022");
entities.put("hellip", "\u2026");
entities.put("prime", "\u2032");
entities.put("Prime", "\u2033");
entities.put("oline", "\u203e");
entities.put("frasl", "\u2044");
entities.put("weierp", "\u2118");
entities.put("image", "\u2111");
entities.put("real", "\u211c");
entities.put("trade", "\u2122");
entities.put("alefsym", "\u2135");
entities.put("larr", "\u2190");
entities.put("uarr", "\u2191");
entities.put("rarr", "\u2192");
entities.put("darr", "\u2193");
entities.put("harr", "\u2194");
entities.put("crarr", "\u21b5");
entities.put("lArr", "\u21d0");
entities.put("uArr", "\u21d1");
entities.put("rArr", "\u21d2");
entities.put("dArr", "\u21d3");
entities.put("hArr", "\u21d4");
entities.put("forall", "\u2200");
entities.put("part", "\u2202");
entities.put("exist", "\u2203");
entities.put("empty", "\u2205");
entities.put("nabla", "\u2207");
entities.put("isin", "\u2208");
entities.put("notin", "\u2209");
entities.put("ni", "\u220b");
entities.put("prod", "\u220f");
entities.put("sum", "\u2211");
entities.put("minus", "\u2212");
entities.put("lowast", "\u2217");
entities.put("radic", "\u221a");
entities.put("prop", "\u221d");
entities.put("infin", "\u221e");
entities.put("ang", "\u2220");
entities.put("and", "\u2227");
entities.put("or", "\u2228");
entities.put("cap", "\u2229");
entities.put("cup", "\u222a");
entities.put("int", "\u222b");
entities.put("there4", "\u2234");
entities.put("sim", "\u223c");
entities.put("cong", "\u2245");
entities.put("asymp", "\u2248");
entities.put("ne", "\u2260");
entities.put("equiv", "\u2261");
entities.put("le", "\u2264");
entities.put("ge", "\u2265");
entities.put("sub", "\u2282");
entities.put("sup", "\u2283");
entities.put("nsub", "\u2284");
entities.put("sube", "\u2286");
entities.put("supe", "\u2287");
entities.put("oplus", "\u2295");
entities.put("otimes", "\u2297");
entities.put("perp", "\u22a5");
entities.put("sdot", "\u22c5");
entities.put("lceil", "\u2308");
entities.put("rceil", "\u2309");
entities.put("lfloor", "\u230a");
entities.put("rfloor", "\u230b");
entities.put("lang", "\u2329");
entities.put("rang", "\u232a");
entities.put("loz", "\u25ca");
entities.put("spades", "\u2660");
entities.put("clubs", "\u2663");
entities.put("hearts", "\u2665");
entities.put("diams", "\u2666");
DEFAULT_ENTITIES = Collections.unmodifiableMap(entities);
}
static class InputFactoryHolder {
static XMLInputFactory XML_INPUT_FACTORY;
static {
XMLInputFactory factory = XMLInputFactory.newFactory();
factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);
XML_INPUT_FACTORY = factory;
}
}
private boolean addDefaultEntities = true;
private boolean addLocationInformation = true;
private final ContentTransformer contentTransformer;
public SettingsStaxReader() {
this((s, f) -> s);
}
public SettingsStaxReader(ContentTransformer contentTransformer) {
this.contentTransformer = contentTransformer;
}
/**
* Returns the {@link XMLInputFactory} used by this reader.
*
* @return the {@link XMLInputFactory} used by this reader.
*/
public XMLInputFactory getXMLInputFactory() {
return InputFactoryHolder.XML_INPUT_FACTORY;
}
/**
* Returns the state of the "add default entities" flag.
*
* @return boolean
*/
public boolean getAddDefaultEntities() {
return addDefaultEntities;
} //-- boolean getAddDefaultEntities()
/**
* Sets the state of the "add default entities" flag.
*
* @param addDefaultEntities a addDefaultEntities object.
*/
public void setAddDefaultEntities(boolean addDefaultEntities) {
this.addDefaultEntities = addDefaultEntities;
} //-- void setAddDefaultEntities(boolean)
/**
* Returns the state of the "add location information" flag.
*
* @return boolean
*/
public boolean getAddLocationInformation() {
return addLocationInformation;
} //-- boolean getAddLocationInformation()
/**
* Sets the state of the "add location information" flag.
*
* @param addLocationInformation a addLocationInformation object.
*/
public void setAddLocationInformation(boolean addLocationInformation) {
this.addLocationInformation = addLocationInformation;
} //-- void setAddLocationInformation(boolean)
public Settings read(Reader reader) throws XMLStreamException {
return read(reader, true, null);
}
/**
* @param reader a reader object.
* @param strict a strict object.
* @throws XMLStreamException XMLStreamException if
* any.
* @return Settings
*/
public Settings read(Reader reader, boolean strict, InputSource source) throws XMLStreamException {
StreamSource streamSource = new StreamSource(reader, source != null ? source.getLocation() : null);
XMLInputFactory factory = getXMLInputFactory();
XMLStreamReader parser = factory.createXMLStreamReader(streamSource);
return read(parser, strict, source);
} //-- Settings read(Reader, boolean)
public Settings read(InputStream in) throws XMLStreamException {
return read(in, true, null);
}
/**
* Method read.
*
* @param in a in object.
* @param strict a strict object.
* @throws XMLStreamException XMLStreamException if
* any.
* @return Settings
*/
public Settings read(InputStream in, boolean strict, InputSource source) throws XMLStreamException {
StreamSource streamSource = new StreamSource(in, source != null ? source.getLocation() : null);
XMLInputFactory factory = getXMLInputFactory();
XMLStreamReader parser = factory.createXMLStreamReader(streamSource);
return read(parser, strict, source);
} //-- Settings read(InputStream, boolean)
/**
* Method read.
*
* @param parser a parser object.
* @param strict a strict object.
* @throws XMLStreamException XMLStreamException if
* any.
* @return Settings
*/
public Settings read(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
Settings settings = null;
int eventType = parser.getEventType();
boolean parsed = false;
while (eventType != XMLStreamReader.END_DOCUMENT) {
if (eventType == XMLStreamReader.START_ELEMENT) {
if (strict && ! "settings".equals(parser.getLocalName())) {
throw new XMLStreamException("Expected root element 'settings' but found '" + parser.getName() + "'", parser.getLocation(), null);
} else if (parsed) {
// fallback, already expected a XMLStreamException due to invalid XML
throw new XMLStreamException("Duplicated tag: 'settings'", parser.getLocation(), null);
}
settings = parseSettings(parser, strict, source);
parsed = true;
}
eventType = parser.next();
}
if (parsed) {
return settings;
}
throw new XMLStreamException("Expected root element 'settings' but found no element at all: invalid XML document", parser.getLocation(), null);
} //-- Settings read(XMLStreamReader, boolean)
private TrackableBase parseTrackableBase(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
String tagName = parser.getLocalName();
TrackableBase.Builder trackableBase = TrackableBase.newBuilder(true);
if (addLocationInformation) {
trackableBase.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
String name = parser.getAttributeLocalName(i);
String ns = parser.getAttributeNamespace(i);
String value = parser.getAttributeValue(i);
if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
// just ignore attributes with non-default namespace (for example: xsi and xml)
} else {
checkUnknownAttribute(parser, name, tagName, strict);
}
}
Set parsed = new HashSet<>();
while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
Map locations = null;
switch (childName) {
default: {
checkUnknownElement(parser, strict);
break;
}
}
if (addLocationInformation) {
trackableBase.location(childName, new InputLocation(line, column, source, locations));
}
}
return trackableBase.build();
}
private IdentifiableBase parseIdentifiableBase(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
String tagName = parser.getLocalName();
IdentifiableBase.Builder identifiableBase = IdentifiableBase.newBuilder(true);
if (addLocationInformation) {
identifiableBase.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
String name = parser.getAttributeLocalName(i);
String ns = parser.getAttributeNamespace(i);
String value = parser.getAttributeValue(i);
if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
// just ignore attributes with non-default namespace (for example: xsi and xml)
} else {
checkUnknownAttribute(parser, name, tagName, strict);
}
}
Set parsed = new HashSet<>();
while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
Map locations = null;
switch (childName) {
case "id": {
identifiableBase.id(interpolatedTrimmed(nextText(parser, strict), "id"));
break;
}
default: {
checkUnknownElement(parser, strict);
break;
}
}
if (addLocationInformation) {
identifiableBase.location(childName, new InputLocation(line, column, source, locations));
}
}
return identifiableBase.build();
}
private Settings parseSettings(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
String tagName = parser.getLocalName();
Settings.Builder settings = Settings.newBuilder(true);
if (addLocationInformation) {
settings.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
String name = parser.getAttributeLocalName(i);
String ns = parser.getAttributeNamespace(i);
String value = parser.getAttributeValue(i);
if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
// just ignore attributes with non-default namespace (for example: xsi and xml)
} else if ("xmlns".equals(name)) {
// ignore xmlns attribute in root class, which is a reserved attribute name
} else {
checkUnknownAttribute(parser, name, tagName, strict);
}
}
Set parsed = new HashSet<>();
while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
Map locations = null;
switch (childName) {
case "localRepository": {
settings.localRepository(interpolatedTrimmed(nextText(parser, strict), "localRepository"));
break;
}
case "interactiveMode": {
settings.interactiveMode(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "interactiveMode"), "interactiveMode", parser, true));
break;
}
case "usePluginRegistry": {
settings.usePluginRegistry(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "usePluginRegistry"), "usePluginRegistry", parser, false));
break;
}
case "offline": {
settings.offline(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "offline"), "offline", parser, false));
break;
}
case "proxies": {
List proxies = new ArrayList<>();
while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
if ("proxy".equals(parser.getLocalName())) {
proxies.add(parseProxy(parser, strict, source));
} else {
checkUnknownElement(parser, strict);
}
}
settings.proxies(proxies);
break;
}
case "servers": {
List servers = new ArrayList<>();
while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
if ("server".equals(parser.getLocalName())) {
servers.add(parseServer(parser, strict, source));
} else {
checkUnknownElement(parser, strict);
}
}
settings.servers(servers);
break;
}
case "mirrors": {
List mirrors = new ArrayList<>();
while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
if ("mirror".equals(parser.getLocalName())) {
mirrors.add(parseMirror(parser, strict, source));
} else {
checkUnknownElement(parser, strict);
}
}
settings.mirrors(mirrors);
break;
}
case "repositories": {
List repositories = new ArrayList<>();
while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
if ("repository".equals(parser.getLocalName())) {
repositories.add(parseRepository(parser, strict, source));
} else {
checkUnknownElement(parser, strict);
}
}
settings.repositories(repositories);
break;
}
case "pluginRepositories": {
List pluginRepositories = new ArrayList<>();
while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
if ("pluginRepository".equals(parser.getLocalName())) {
pluginRepositories.add(parseRepository(parser, strict, source));
} else {
checkUnknownElement(parser, strict);
}
}
settings.pluginRepositories(pluginRepositories);
break;
}
case "profiles": {
List profiles = new ArrayList<>();
while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
if ("profile".equals(parser.getLocalName())) {
profiles.add(parseProfile(parser, strict, source));
} else {
checkUnknownElement(parser, strict);
}
}
settings.profiles(profiles);
break;
}
case "activeProfiles": {
List activeProfiles = new ArrayList<>();
locations = new HashMap<>();
while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
if ("activeProfile".equals(parser.getLocalName())) {
if (addLocationInformation) {
locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
activeProfiles.add(interpolatedTrimmed(nextText(parser, strict), "activeProfiles"));
} else {
checkUnknownElement(parser, strict);
}
}
settings.activeProfiles(activeProfiles);
break;
}
case "pluginGroups": {
List pluginGroups = new ArrayList<>();
locations = new HashMap<>();
while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
if ("pluginGroup".equals(parser.getLocalName())) {
if (addLocationInformation) {
locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
pluginGroups.add(interpolatedTrimmed(nextText(parser, strict), "pluginGroups"));
} else {
checkUnknownElement(parser, strict);
}
}
settings.pluginGroups(pluginGroups);
break;
}
default: {
checkUnknownElement(parser, strict);
break;
}
}
if (addLocationInformation) {
settings.location(childName, new InputLocation(line, column, source, locations));
}
}
settings.namespaceUri(parser.getNamespaceURI());
settings.modelEncoding(parser.getEncoding());
return settings.build();
}
private Proxy parseProxy(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
String tagName = parser.getLocalName();
Proxy.Builder proxy = Proxy.newBuilder(true);
if (addLocationInformation) {
proxy.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
String name = parser.getAttributeLocalName(i);
String ns = parser.getAttributeNamespace(i);
String value = parser.getAttributeValue(i);
if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
// just ignore attributes with non-default namespace (for example: xsi and xml)
} else {
checkUnknownAttribute(parser, name, tagName, strict);
}
}
Set parsed = new HashSet<>();
while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
Map locations = null;
switch (childName) {
case "active": {
proxy.activeString(interpolatedTrimmed(nextText(parser, strict), "active"));
break;
}
case "protocol": {
proxy.protocol(interpolatedTrimmed(nextText(parser, strict), "protocol"));
break;
}
case "username": {
proxy.username(interpolatedTrimmed(nextText(parser, strict), "username"));
break;
}
case "password": {
proxy.password(interpolatedTrimmed(nextText(parser, strict), "password"));
break;
}
case "port": {
proxy.portString(interpolatedTrimmed(nextText(parser, strict), "port"));
break;
}
case "host": {
proxy.host(interpolatedTrimmed(nextText(parser, strict), "host"));
break;
}
case "nonProxyHosts": {
proxy.nonProxyHosts(interpolatedTrimmed(nextText(parser, strict), "nonProxyHosts"));
break;
}
case "id": {
proxy.id(interpolatedTrimmed(nextText(parser, strict), "id"));
break;
}
default: {
checkUnknownElement(parser, strict);
break;
}
}
if (addLocationInformation) {
proxy.location(childName, new InputLocation(line, column, source, locations));
}
}
return proxy.build();
}
private Server parseServer(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
String tagName = parser.getLocalName();
Server.Builder server = Server.newBuilder(true);
if (addLocationInformation) {
server.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
String name = parser.getAttributeLocalName(i);
String ns = parser.getAttributeNamespace(i);
String value = parser.getAttributeValue(i);
if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
// just ignore attributes with non-default namespace (for example: xsi and xml)
} else {
checkUnknownAttribute(parser, name, tagName, strict);
}
}
Set parsed = new HashSet<>();
while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
Map locations = null;
switch (childName) {
case "username": {
server.username(interpolatedTrimmed(nextText(parser, strict), "username"));
break;
}
case "password": {
server.password(interpolatedTrimmed(nextText(parser, strict), "password"));
break;
}
case "privateKey": {
server.privateKey(interpolatedTrimmed(nextText(parser, strict), "privateKey"));
break;
}
case "passphrase": {
server.passphrase(interpolatedTrimmed(nextText(parser, strict), "passphrase"));
break;
}
case "filePermissions": {
server.filePermissions(interpolatedTrimmed(nextText(parser, strict), "filePermissions"));
break;
}
case "directoryPermissions": {
server.directoryPermissions(interpolatedTrimmed(nextText(parser, strict), "directoryPermissions"));
break;
}
case "configuration": {
server.configuration(buildXmlNode(parser, source));
break;
}
case "id": {
server.id(interpolatedTrimmed(nextText(parser, strict), "id"));
break;
}
default: {
checkUnknownElement(parser, strict);
break;
}
}
if (addLocationInformation) {
server.location(childName, new InputLocation(line, column, source, locations));
}
}
return server.build();
}
private Mirror parseMirror(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
String tagName = parser.getLocalName();
Mirror.Builder mirror = Mirror.newBuilder(true);
if (addLocationInformation) {
mirror.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
String name = parser.getAttributeLocalName(i);
String ns = parser.getAttributeNamespace(i);
String value = parser.getAttributeValue(i);
if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
// just ignore attributes with non-default namespace (for example: xsi and xml)
} else {
checkUnknownAttribute(parser, name, tagName, strict);
}
}
Set parsed = new HashSet<>();
while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
Map locations = null;
switch (childName) {
case "mirrorOf": {
mirror.mirrorOf(interpolatedTrimmed(nextText(parser, strict), "mirrorOf"));
break;
}
case "name": {
mirror.name(interpolatedTrimmed(nextText(parser, strict), "name"));
break;
}
case "url": {
mirror.url(interpolatedTrimmed(nextText(parser, strict), "url"));
break;
}
case "layout": {
mirror.layout(interpolatedTrimmed(nextText(parser, strict), "layout"));
break;
}
case "mirrorOfLayouts": {
mirror.mirrorOfLayouts(interpolatedTrimmed(nextText(parser, strict), "mirrorOfLayouts"));
break;
}
case "blocked": {
mirror.blocked(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "blocked"), "blocked", parser, false));
break;
}
case "id": {
mirror.id(interpolatedTrimmed(nextText(parser, strict), "id"));
break;
}
default: {
checkUnknownElement(parser, strict);
break;
}
}
if (addLocationInformation) {
mirror.location(childName, new InputLocation(line, column, source, locations));
}
}
return mirror.build();
}
private Profile parseProfile(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
String tagName = parser.getLocalName();
Profile.Builder profile = Profile.newBuilder(true);
if (addLocationInformation) {
profile.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
String name = parser.getAttributeLocalName(i);
String ns = parser.getAttributeNamespace(i);
String value = parser.getAttributeValue(i);
if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
// just ignore attributes with non-default namespace (for example: xsi and xml)
} else {
checkUnknownAttribute(parser, name, tagName, strict);
}
}
Set parsed = new HashSet<>();
while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
Map locations = null;
switch (childName) {
case "activation": {
profile.activation(parseActivation(parser, strict, source));
break;
}
case "properties": {
Map properties = new LinkedHashMap<>();
locations = new HashMap<>();
while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
String key = parser.getLocalName();
String value = nextText(parser, strict).trim();
if (addLocationInformation) {
locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
properties.put(key, value);
}
profile.properties(properties);
break;
}
case "repositories": {
List repositories = new ArrayList<>();
while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
if ("repository".equals(parser.getLocalName())) {
repositories.add(parseRepository(parser, strict, source));
} else {
checkUnknownElement(parser, strict);
}
}
profile.repositories(repositories);
break;
}
case "pluginRepositories": {
List pluginRepositories = new ArrayList<>();
while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
if ("pluginRepository".equals(parser.getLocalName())) {
pluginRepositories.add(parseRepository(parser, strict, source));
} else {
checkUnknownElement(parser, strict);
}
}
profile.pluginRepositories(pluginRepositories);
break;
}
case "id": {
profile.id(interpolatedTrimmed(nextText(parser, strict), "id"));
break;
}
default: {
checkUnknownElement(parser, strict);
break;
}
}
if (addLocationInformation) {
profile.location(childName, new InputLocation(line, column, source, locations));
}
}
return profile.build();
}
private Activation parseActivation(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
String tagName = parser.getLocalName();
Activation.Builder activation = Activation.newBuilder(true);
if (addLocationInformation) {
activation.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
String name = parser.getAttributeLocalName(i);
String ns = parser.getAttributeNamespace(i);
String value = parser.getAttributeValue(i);
if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
// just ignore attributes with non-default namespace (for example: xsi and xml)
} else {
checkUnknownAttribute(parser, name, tagName, strict);
}
}
Set parsed = new HashSet<>();
while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
Map locations = null;
switch (childName) {
case "activeByDefault": {
activation.activeByDefault(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "activeByDefault"), "activeByDefault", parser, false));
break;
}
case "jdk": {
activation.jdk(interpolatedTrimmed(nextText(parser, strict), "jdk"));
break;
}
case "os": {
activation.os(parseActivationOS(parser, strict, source));
break;
}
case "property": {
activation.property(parseActivationProperty(parser, strict, source));
break;
}
case "file": {
activation.file(parseActivationFile(parser, strict, source));
break;
}
case "packaging": {
activation.packaging(interpolatedTrimmed(nextText(parser, strict), "packaging"));
break;
}
case "condition": {
activation.condition(interpolatedTrimmed(nextText(parser, strict), "condition"));
break;
}
default: {
checkUnknownElement(parser, strict);
break;
}
}
if (addLocationInformation) {
activation.location(childName, new InputLocation(line, column, source, locations));
}
}
return activation.build();
}
private RepositoryBase parseRepositoryBase(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
String tagName = parser.getLocalName();
RepositoryBase.Builder repositoryBase = RepositoryBase.newBuilder(true);
if (addLocationInformation) {
repositoryBase.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
String name = parser.getAttributeLocalName(i);
String ns = parser.getAttributeNamespace(i);
String value = parser.getAttributeValue(i);
if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
// just ignore attributes with non-default namespace (for example: xsi and xml)
} else {
checkUnknownAttribute(parser, name, tagName, strict);
}
}
Set parsed = new HashSet<>();
while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
Map locations = null;
switch (childName) {
case "name": {
repositoryBase.name(interpolatedTrimmed(nextText(parser, strict), "name"));
break;
}
case "url": {
repositoryBase.url(interpolatedTrimmed(nextText(parser, strict), "url"));
break;
}
case "layout": {
repositoryBase.layout(interpolatedTrimmed(nextText(parser, strict), "layout"));
break;
}
case "id": {
repositoryBase.id(interpolatedTrimmed(nextText(parser, strict), "id"));
break;
}
default: {
checkUnknownElement(parser, strict);
break;
}
}
if (addLocationInformation) {
repositoryBase.location(childName, new InputLocation(line, column, source, locations));
}
}
return repositoryBase.build();
}
private Repository parseRepository(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
String tagName = parser.getLocalName();
Repository.Builder repository = Repository.newBuilder(true);
if (addLocationInformation) {
repository.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
String name = parser.getAttributeLocalName(i);
String ns = parser.getAttributeNamespace(i);
String value = parser.getAttributeValue(i);
if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
// just ignore attributes with non-default namespace (for example: xsi and xml)
} else {
checkUnknownAttribute(parser, name, tagName, strict);
}
}
Set parsed = new HashSet<>();
while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
Map locations = null;
switch (childName) {
case "releases": {
repository.releases(parseRepositoryPolicy(parser, strict, source));
break;
}
case "snapshots": {
repository.snapshots(parseRepositoryPolicy(parser, strict, source));
break;
}
case "name": {
repository.name(interpolatedTrimmed(nextText(parser, strict), "name"));
break;
}
case "url": {
repository.url(interpolatedTrimmed(nextText(parser, strict), "url"));
break;
}
case "layout": {
repository.layout(interpolatedTrimmed(nextText(parser, strict), "layout"));
break;
}
case "id": {
repository.id(interpolatedTrimmed(nextText(parser, strict), "id"));
break;
}
default: {
checkUnknownElement(parser, strict);
break;
}
}
if (addLocationInformation) {
repository.location(childName, new InputLocation(line, column, source, locations));
}
}
return repository.build();
}
private RepositoryPolicy parseRepositoryPolicy(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
String tagName = parser.getLocalName();
RepositoryPolicy.Builder repositoryPolicy = RepositoryPolicy.newBuilder(true);
if (addLocationInformation) {
repositoryPolicy.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
String name = parser.getAttributeLocalName(i);
String ns = parser.getAttributeNamespace(i);
String value = parser.getAttributeValue(i);
if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
// just ignore attributes with non-default namespace (for example: xsi and xml)
} else {
checkUnknownAttribute(parser, name, tagName, strict);
}
}
Set parsed = new HashSet<>();
while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
Map locations = null;
switch (childName) {
case "enabled": {
repositoryPolicy.enabled(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "enabled"), "enabled", parser, true));
break;
}
case "updatePolicy": {
repositoryPolicy.updatePolicy(interpolatedTrimmed(nextText(parser, strict), "updatePolicy"));
break;
}
case "checksumPolicy": {
repositoryPolicy.checksumPolicy(interpolatedTrimmed(nextText(parser, strict), "checksumPolicy"));
break;
}
default: {
checkUnknownElement(parser, strict);
break;
}
}
if (addLocationInformation) {
repositoryPolicy.location(childName, new InputLocation(line, column, source, locations));
}
}
return repositoryPolicy.build();
}
private ActivationProperty parseActivationProperty(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
String tagName = parser.getLocalName();
ActivationProperty.Builder activationProperty = ActivationProperty.newBuilder(true);
if (addLocationInformation) {
activationProperty.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
String name = parser.getAttributeLocalName(i);
String ns = parser.getAttributeNamespace(i);
String value = parser.getAttributeValue(i);
if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
// just ignore attributes with non-default namespace (for example: xsi and xml)
} else {
checkUnknownAttribute(parser, name, tagName, strict);
}
}
Set parsed = new HashSet<>();
while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
Map locations = null;
switch (childName) {
case "name": {
activationProperty.name(interpolatedTrimmed(nextText(parser, strict), "name"));
break;
}
case "value": {
activationProperty.value(interpolatedTrimmed(nextText(parser, strict), "value"));
break;
}
default: {
checkUnknownElement(parser, strict);
break;
}
}
if (addLocationInformation) {
activationProperty.location(childName, new InputLocation(line, column, source, locations));
}
}
return activationProperty.build();
}
private ActivationOS parseActivationOS(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
String tagName = parser.getLocalName();
ActivationOS.Builder activationOS = ActivationOS.newBuilder(true);
if (addLocationInformation) {
activationOS.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
String name = parser.getAttributeLocalName(i);
String ns = parser.getAttributeNamespace(i);
String value = parser.getAttributeValue(i);
if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
// just ignore attributes with non-default namespace (for example: xsi and xml)
} else {
checkUnknownAttribute(parser, name, tagName, strict);
}
}
Set parsed = new HashSet<>();
while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
Map locations = null;
switch (childName) {
case "name": {
activationOS.name(interpolatedTrimmed(nextText(parser, strict), "name"));
break;
}
case "family": {
activationOS.family(interpolatedTrimmed(nextText(parser, strict), "family"));
break;
}
case "arch": {
activationOS.arch(interpolatedTrimmed(nextText(parser, strict), "arch"));
break;
}
case "version": {
activationOS.version(interpolatedTrimmed(nextText(parser, strict), "version"));
break;
}
default: {
checkUnknownElement(parser, strict);
break;
}
}
if (addLocationInformation) {
activationOS.location(childName, new InputLocation(line, column, source, locations));
}
}
return activationOS.build();
}
private ActivationFile parseActivationFile(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
String tagName = parser.getLocalName();
ActivationFile.Builder activationFile = ActivationFile.newBuilder(true);
if (addLocationInformation) {
activationFile.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
}
for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
String name = parser.getAttributeLocalName(i);
String ns = parser.getAttributeNamespace(i);
String value = parser.getAttributeValue(i);
if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
// just ignore attributes with non-default namespace (for example: xsi and xml)
} else {
checkUnknownAttribute(parser, name, tagName, strict);
}
}
Set parsed = new HashSet<>();
while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
Map locations = null;
switch (childName) {
case "missing": {
activationFile.missing(interpolatedTrimmed(nextText(parser, strict), "missing"));
break;
}
case "exists": {
activationFile.exists(interpolatedTrimmed(nextText(parser, strict), "exists"));
break;
}
default: {
checkUnknownElement(parser, strict);
break;
}
}
if (addLocationInformation) {
activationFile.location(childName, new InputLocation(line, column, source, locations));
}
}
return activationFile.build();
}
private String checkDuplicate(String tagName, XMLStreamReader parser, Set parsed) throws XMLStreamException {
if (!parsed.add(tagName)) {
throw new XMLStreamException("Duplicated tag: '" + tagName + "'", parser.getLocation(), null);
}
return tagName;
}
/**
* Method checkUnknownAttribute.
*
* @param parser a parser object.
* @param strict a strict object.
* @param tagName a tagName object.
* @param attribute a attribute object.
* @throws XMLStreamException XMLStreamException if
* any.
* @throws IOException IOException if any.
*/
private void checkUnknownAttribute(XMLStreamReader parser, String attribute, String tagName, boolean strict) throws XMLStreamException {
// strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too
if (strict) {
throw new XMLStreamException("Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser.getLocation(), null);
}
} //-- void checkUnknownAttribute(XMLStreamReader, String, String, boolean)
/**
* Method checkUnknownElement.
*
* @param parser a parser object.
* @param strict a strict object.
* @throws XMLStreamException XMLStreamException if
* any.
* @throws IOException IOException if any.
*/
private void checkUnknownElement(XMLStreamReader parser, boolean strict) throws XMLStreamException {
if (strict) {
throw new XMLStreamException("Unrecognised tag: '" + parser.getName() + "'", parser.getLocation(), null);
}
for (int unrecognizedTagCount = 1; unrecognizedTagCount > 0;) {
int eventType = nextTag(parser);
if (eventType == XMLStreamReader.START_ELEMENT) {
unrecognizedTagCount++;
} else if (eventType == XMLStreamReader.END_ELEMENT) {
unrecognizedTagCount--;
}
}
} //-- void checkUnknownElement(XMLStreamReader, boolean)
/**
* Method getTrimmedValue.
*
* @param s a s object.
* @return String
*/
private String getTrimmedValue(String s) {
if (s != null) {
s = s.trim();
}
return s;
} //-- String getTrimmedValue(String)
/**
* Method interpolatedTrimmed.
*
* @param value a value object.
* @param context a context object.
* @return String
*/
private String interpolatedTrimmed(String value, String context) {
return getTrimmedValue(contentTransformer.transform(value, context));
} //-- String interpolatedTrimmed(String, String)
/**
* Method nextTag.
*
* @param parser a parser object.
* @throws IOException IOException if any.
* @throws XMLStreamException XMLStreamException if
* any.
* @return int
*/
private int nextTag(XMLStreamReader parser) throws XMLStreamException {
while (true) {
int next = parser.next();
switch (next) {
case XMLStreamReader.SPACE:
case XMLStreamReader.COMMENT:
case XMLStreamReader.PROCESSING_INSTRUCTION:
case XMLStreamReader.CDATA:
case XMLStreamReader.CHARACTERS:
continue;
case XMLStreamReader.START_ELEMENT:
case XMLStreamReader.END_ELEMENT:
return next;
}
}
} //-- int nextTag(XMLStreamReader)
private String nextText(XMLStreamReader parser, boolean strict) throws XMLStreamException {
int eventType = parser.getEventType();
if (eventType != XMLStreamReader.START_ELEMENT) {
throw new XMLStreamException("parser must be on START_ELEMENT to read next text", parser.getLocation(), null);
}
eventType = parser.next();
StringBuilder result = new StringBuilder();
while (true) {
if (eventType == XMLStreamReader.CHARACTERS || eventType == XMLStreamReader.CDATA) {
result.append(parser.getText());
} else if (eventType == XMLStreamReader.ENTITY_REFERENCE) {
String val = null;
if (strict) {
throw new XMLStreamException("Entities are not supported in strict mode", parser.getLocation(), null);
} else if (addDefaultEntities) {
val = DEFAULT_ENTITIES.get(parser.getLocalName());
}
if (val != null) {
result.append(val);
} else {
result.append("&").append(parser.getLocalName()).append(";");
}
} else if (eventType != XMLStreamReader.COMMENT) {
break;
}
eventType = parser.next();
}
if (eventType != XMLStreamReader.END_ELEMENT) {
throw new XMLStreamException(
"TEXT must be immediately followed by END_ELEMENT and not " + eventType /*TODO: TYPES[eventType]*/, parser.getLocation(), null);
}
return result.toString();
}
private XmlNode buildXmlNode(XMLStreamReader parser, InputSource source) throws XMLStreamException {
return XmlNodeStaxBuilder.build(parser,
addLocationInformation
? p -> new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source)
: null);
}
/**
* Method getBooleanValue.
*
* @param s a s object.
* @param defaultValue a defaultValue object.
* @param parser a parser object.
* @param attribute a attribute object.
* @throws XMLStreamException XMLStreamException if
* any.
* @return boolean
*/
private boolean getBooleanValue(String s, String attribute, XMLStreamReader parser, boolean defaultValue) throws XMLStreamException {
if (s != null && s.length() != 0) {
return Boolean.valueOf(s).booleanValue();
}
return defaultValue;
} //-- boolean getBooleanValue(String, String, XMLStreamReader, String)
public static interface ContentTransformer {
/**
* Interpolate the value read from the xpp3 document
* @param source The source value
* @param fieldName A description of the field being interpolated. The implementation may use this to
* log stuff.
* @return The interpolated value.
*/
String transform(String source, String fieldName);
}
}