pax_global_header 0000666 0000000 0000000 00000000064 13337777503 0014531 g ustar 00root root 0000000 0000000 52 comment=53c774d2df1d1fd74fa5333b8975cebcada74839
wildfly-client-config-1.0.1.Final/ 0000775 0000000 0000000 00000000000 13337777503 0016751 5 ustar 00root root 0000000 0000000 wildfly-client-config-1.0.1.Final/.gitignore 0000664 0000000 0000000 00000001177 13337777503 0020747 0 ustar 00root root 0000000 0000000 # ignore .svn metadata files
.svn
# ignore Maven generated target folders
~
target
# ignore eclipse files
.project
.checkstyle
.classpath
.settings
.metadata
# ignore m2e annotation processing files
.factorypath
# ignore IDEA files
*.iml
*.ipr
*.iws
.idea
# ignore NetBeans files
nbactions.xml
nb-configuration.xml
catalog.xml
#
maven-ant-tasks.jar
test-output
transaction.log
# vim files
*.swp
/.gitk-tmp.*
atlassian-ide-plugin.xml
# temp files
*~
# maven versions plugin
pom.xml.versionsBackup
# hprof dumps
/*.hprof
# ignore 'randomly' strewn around logs
server.log
# ignore java crashes
hs_err_pid*.log
# ignore mvn-rpmbuild repo
/.m2
wildfly-client-config-1.0.1.Final/LICENSE.txt 0000664 0000000 0000000 00000026136 13337777503 0020604 0 ustar 00root root 0000000 0000000
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
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.
wildfly-client-config-1.0.1.Final/pom.xml 0000664 0000000 0000000 00000015777 13337777503 0020307 0 ustar 00root root 0000000 0000000
4.0.0org.jbossjboss-parent23Apache License 2.0http://repository.jboss.org/licenses/apache-2.0.txtrepoorg.wildfly.clientwildfly-client-config1.0.1.FinalWildFly Client ConfigurationLibrary for supporting WildFly common client configuration2.9.13.3.1.Final2.1.0.Final2.0.7.Final1.0.5.Final1.2.0.Finalorg.apache.maven.pluginsmaven-surefire-plugin2.11truejava.util.logging.managerorg.jboss.logmanager.LogManageralwaysmaven-javadoc-pluginorg.wildfly.client.config._privateorg.apache.maven.pluginsmaven-checkstyle-plugin${version.checkstyle.plugin}wildfly-checkstyle/checkstyle.xmltruetruefalseorg.wildfly.checkstylewildfly-checkstyle-config${version.org.wildfly.checkstyle-config}check-stylecompilecheckstylemaven-compiler-pluginorg.apache.felixmaven-bundle-plugin
org.wildfly.client.config;version=${project.version}
*
manifestmanifestmaven-jar-pluginjava/**${project.build.outputDirectory}/META-INF/MANIFEST.MForg.jboss.loggingjboss-logging${version.org.jboss.logging.jboss-logging}org.jboss.loggingjboss-logging-processor${version.org.jboss.logging.jboss-logging-processor}providedorg.jboss.logmanagerjboss-logmanager${version.org.jboss.logmanager}testorg.wildfly.commonwildfly-common${version.org.wildfly.common}junitjunit4.12test
wildfly-client-config-1.0.1.Final/src/ 0000775 0000000 0000000 00000000000 13337777503 0017540 5 ustar 00root root 0000000 0000000 wildfly-client-config-1.0.1.Final/src/main/ 0000775 0000000 0000000 00000000000 13337777503 0020464 5 ustar 00root root 0000000 0000000 wildfly-client-config-1.0.1.Final/src/main/java/ 0000775 0000000 0000000 00000000000 13337777503 0021405 5 ustar 00root root 0000000 0000000 wildfly-client-config-1.0.1.Final/src/main/java/org/ 0000775 0000000 0000000 00000000000 13337777503 0022174 5 ustar 00root root 0000000 0000000 wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/ 0000775 0000000 0000000 00000000000 13337777503 0023646 5 ustar 00root root 0000000 0000000 wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/ 0000775 0000000 0000000 00000000000 13337777503 0025124 5 ustar 00root root 0000000 0000000 wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config/ 0000775 0000000 0000000 00000000000 13337777503 0026371 5 ustar 00root root 0000000 0000000 AbstractDelegatingXMLStreamReader.java 0000664 0000000 0000000 00000016065 13337777503 0035574 0 ustar 00root root 0000000 0000000 wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config /*
* JBoss, Home of Professional Open Source.
* Copyright 2015 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.client.config;
import java.net.URI;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
/**
* @author David M. Lloyd
*/
abstract class AbstractDelegatingXMLStreamReader implements ConfigurationXMLStreamReader {
private final boolean closeDelegate;
private final ConfigurationXMLStreamReader delegate;
AbstractDelegatingXMLStreamReader(final boolean closeDelegate, final ConfigurationXMLStreamReader delegate) {
this.closeDelegate = closeDelegate;
this.delegate = delegate;
}
protected ConfigurationXMLStreamReader getDelegate() {
return delegate;
}
public URI getUri() {
return getDelegate().getUri();
}
public XMLInputFactory getXmlInputFactory() {
return getDelegate().getXmlInputFactory();
}
public XMLLocation getIncludedFrom() {
return getDelegate().getIncludedFrom();
}
public boolean hasNext() throws ConfigXMLParseException {
return getDelegate().hasNext();
}
public int next() throws ConfigXMLParseException {
return getDelegate().next();
}
public int nextTag() throws ConfigXMLParseException {
int eventType = next();
while (eventType == XMLStreamConstants.CHARACTERS && isWhiteSpace()
|| eventType == XMLStreamConstants.CDATA && isWhiteSpace()
|| eventType == XMLStreamConstants.SPACE
|| eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
|| eventType == XMLStreamConstants.COMMENT) {
eventType = next();
}
if (eventType != XMLStreamConstants.START_ELEMENT && eventType != XMLStreamConstants.END_ELEMENT) {
throw unexpectedContent();
}
return eventType;
}
public String getElementText() throws ConfigXMLParseException {
return getDelegate().getElementText();
}
public void require(final int type, final String namespaceURI, final String localName) throws ConfigXMLParseException {
getDelegate().require(type, namespaceURI, localName);
}
public boolean isStartElement() {
return getDelegate().isStartElement();
}
public boolean isEndElement() {
return getDelegate().isEndElement();
}
public boolean isCharacters() {
return getDelegate().isCharacters();
}
public boolean isWhiteSpace() {
return getDelegate().isWhiteSpace();
}
public static String eventToString(final int type) {
return ConfigurationXMLStreamReader.eventToString(type);
}
public Object getProperty(final String name) throws IllegalArgumentException {
return getDelegate().getProperty(name);
}
public boolean hasText() {
return getDelegate().hasText();
}
public boolean isStandalone() {
return getDelegate().isStandalone();
}
public boolean standaloneSet() {
return getDelegate().standaloneSet();
}
public boolean hasName() {
return getDelegate().hasName();
}
public XMLLocation getLocation() {
return getDelegate().getLocation();
}
public int getTextCharacters(final int sourceStart, final char[] target, final int targetStart, final int length) throws ConfigXMLParseException {
return getDelegate().getTextCharacters(sourceStart, target, targetStart, length);
}
public void close() throws ConfigXMLParseException {
if (closeDelegate) getDelegate().close();
}
public String getNamespaceURI(final String prefix) {
return getDelegate().getNamespaceURI(prefix);
}
public String getAttributeValue(final String namespaceURI, final String localName) {
return getDelegate().getAttributeValue(namespaceURI, localName);
}
public int getAttributeCount() {
return getDelegate().getAttributeCount();
}
public QName getAttributeName(final int index) {
return getDelegate().getAttributeName(index);
}
public String getAttributeNamespace(final int index) {
return getDelegate().getAttributeNamespace(index);
}
public String getAttributeLocalName(final int index) {
return getDelegate().getAttributeLocalName(index);
}
public String getAttributePrefix(final int index) {
return getDelegate().getAttributePrefix(index);
}
public String getAttributeType(final int index) {
return getDelegate().getAttributeType(index);
}
public String getAttributeValue(final int index) {
return getDelegate().getAttributeValue(index);
}
public boolean isAttributeSpecified(final int index) {
return getDelegate().isAttributeSpecified(index);
}
public int getNamespaceCount() {
return getDelegate().getNamespaceCount();
}
public String getNamespacePrefix(final int index) {
return getDelegate().getNamespacePrefix(index);
}
public String getNamespaceURI(final int index) {
return getDelegate().getNamespaceURI(index);
}
public NamespaceContext getNamespaceContext() {
return getDelegate().getNamespaceContext();
}
public int getEventType() {
return getDelegate().getEventType();
}
public String getText() {
return getDelegate().getText();
}
public char[] getTextCharacters() {
return getDelegate().getTextCharacters();
}
public int getTextStart() {
return getDelegate().getTextStart();
}
public int getTextLength() {
return getDelegate().getTextLength();
}
public String getEncoding() {
return getDelegate().getEncoding();
}
public QName getName() {
return getDelegate().getName();
}
public String getLocalName() {
return getDelegate().getLocalName();
}
public String getNamespaceURI() {
return getDelegate().getNamespaceURI();
}
public String getPrefix() {
return getDelegate().getPrefix();
}
public String getVersion() {
return getDelegate().getVersion();
}
public String getCharacterEncodingScheme() {
return getDelegate().getCharacterEncodingScheme();
}
public String getPITarget() {
return getDelegate().getPITarget();
}
public String getPIData() {
return getDelegate().getPIData();
}
}
wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config/BasicXMLStreamReader.java 0000664 0000000 0000000 00000017341 13337777503 0033143 0 ustar 00root root 0000000 0000000 /*
* JBoss, Home of Professional Open Source.
* Copyright 2015 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.client.config;
import java.io.Closeable;
import java.io.IOException;
import java.net.URI;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
/**
* @author David M. Lloyd
*/
final class BasicXMLStreamReader implements ConfigurationXMLStreamReader {
private final XMLLocation includedFrom;
private final XMLStreamReader xmlStreamReader;
private final URI uri;
private final XMLInputFactory inputFactory;
private final Closeable underlying;
BasicXMLStreamReader(final XMLLocation includedFrom, final XMLStreamReader xmlStreamReader, final URI uri, final XMLInputFactory inputFactory, final Closeable underlying) {
this.includedFrom = includedFrom;
this.xmlStreamReader = xmlStreamReader;
this.uri = uri;
this.inputFactory = inputFactory;
this.underlying = underlying;
}
public URI getUri() {
return uri;
}
public XMLInputFactory getXmlInputFactory() {
return inputFactory;
}
public XMLLocation getIncludedFrom() {
return includedFrom;
}
public boolean hasNext() throws ConfigXMLParseException {
try {
return xmlStreamReader.hasNext();
} catch (XMLStreamException e) {
throw ConfigXMLParseException.from(e, uri, includedFrom);
}
}
public int next() throws ConfigXMLParseException {
try {
return xmlStreamReader.next();
} catch (XMLStreamException e) {
throw ConfigXMLParseException.from(e, uri, includedFrom);
}
}
public void require(final int type, final String namespaceURI, final String localName) throws ConfigXMLParseException {
try {
xmlStreamReader.require(type, namespaceURI, localName);
} catch (XMLStreamException e) {
throw ConfigXMLParseException.from(e, uri, includedFrom);
}
}
public String getElementText() throws ConfigXMLParseException {
try {
return xmlStreamReader.getElementText();
} catch (XMLStreamException e) {
throw ConfigXMLParseException.from(e, uri, includedFrom);
}
}
public int nextTag() throws ConfigXMLParseException {
try {
return xmlStreamReader.nextTag();
} catch (XMLStreamException e) {
throw ConfigXMLParseException.from(e, uri, includedFrom);
}
}
public XMLLocation getLocation() {
return new XMLLocation(includedFrom, uri, xmlStreamReader.getLocation());
}
public QName getName() {
return xmlStreamReader.getName();
}
public String getLocalName() {
return xmlStreamReader.getLocalName();
}
public boolean hasName() {
return xmlStreamReader.hasName();
}
public String getNamespaceURI() {
return xmlStreamReader.getNamespaceURI();
}
public String getPrefix() {
return xmlStreamReader.getPrefix();
}
public String getVersion() {
return xmlStreamReader.getVersion();
}
public boolean isStandalone() {
return xmlStreamReader.isStandalone();
}
public boolean standaloneSet() {
return xmlStreamReader.standaloneSet();
}
public String getCharacterEncodingScheme() {
return xmlStreamReader.getCharacterEncodingScheme();
}
public String getPITarget() {
return xmlStreamReader.getPITarget();
}
public String getPIData() {
return xmlStreamReader.getPIData();
}
public int getTextCharacters(final int sourceStart, final char[] target, final int targetStart, final int length) throws ConfigXMLParseException {
try {
return xmlStreamReader.getTextCharacters(sourceStart, target, targetStart, length);
} catch (XMLStreamException e) {
throw ConfigXMLParseException.from(e, uri, includedFrom);
}
}
public int getTextStart() {
return xmlStreamReader.getTextStart();
}
public int getTextLength() {
return xmlStreamReader.getTextLength();
}
public String getEncoding() {
return xmlStreamReader.getEncoding();
}
public boolean hasText() {
return xmlStreamReader.hasText();
}
public void close() throws ConfigXMLParseException {
// use try-with-resources because it has nice suppressed exception behavior in this case
try (Closeable underlying = this.underlying) {
try {
xmlStreamReader.close();
} catch (XMLStreamException e) {
throw ConfigXMLParseException.from(e, uri, includedFrom);
}
} catch (IOException e) {
throw ConfigXMLParseException.from(e, uri, includedFrom);
}
}
public String getNamespaceURI(final String prefix) {
return xmlStreamReader.getNamespaceURI(prefix);
}
public boolean isWhiteSpace() {
// delegate impl may be more efficient
return xmlStreamReader.isWhiteSpace();
}
public String getAttributeValue(final String namespaceURI, final String localName) {
return xmlStreamReader.getAttributeValue(namespaceURI, localName);
}
public int getAttributeCount() {
return xmlStreamReader.getAttributeCount();
}
public QName getAttributeName(final int index) {
return xmlStreamReader.getAttributeName(index);
}
public String getAttributeNamespace(final int index) {
return xmlStreamReader.getAttributeNamespace(index);
}
public String getAttributeLocalName(final int index) {
return xmlStreamReader.getAttributeLocalName(index);
}
public String getAttributePrefix(final int index) {
return xmlStreamReader.getAttributePrefix(index);
}
public String getAttributeType(final int index) {
return xmlStreamReader.getAttributeType(index);
}
public String getAttributeValue(final int index) {
return xmlStreamReader.getAttributeValue(index);
}
public boolean isAttributeSpecified(final int index) {
return xmlStreamReader.isAttributeSpecified(index);
}
public int getNamespaceCount() {
return xmlStreamReader.getNamespaceCount();
}
public String getNamespacePrefix(final int index) {
return xmlStreamReader.getNamespacePrefix(index);
}
public String getNamespaceURI(final int index) {
return xmlStreamReader.getNamespaceURI(index);
}
public NamespaceContext getNamespaceContext() {
return xmlStreamReader.getNamespaceContext();
}
public int getEventType() {
return xmlStreamReader.getEventType();
}
public String getText() {
return xmlStreamReader.getText();
}
public char[] getTextCharacters() {
return xmlStreamReader.getTextCharacters();
}
public Object getProperty(final String name) throws IllegalArgumentException {
return xmlStreamReader.getProperty(name);
}
}
wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config/ClientConfiguration.java 0000664 0000000 0000000 00000030561 13337777503 0033207 0 ustar 00root root 0000000 0000000 /*
* JBoss, Home of Professional Open Source.
* Copyright 2015 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.client.config;
import static java.lang.Boolean.FALSE;
import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
import static org.wildfly.client.config.ConfigurationXMLStreamReader.eventToString;
import static org.wildfly.client.config._private.ConfigMessages.msg;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Paths;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Set;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import org.wildfly.common.Assert;
import org.wildfly.common.function.ExceptionSupplier;
/**
* The entry point for generic client configuration.
*
* @author David M. Lloyd
*/
public class ClientConfiguration {
private static final String WILDFLY_CLIENT_1_0 = "urn:wildfly:client:1.0";
private final XMLInputFactory xmlInputFactory;
private final URI configurationUri;
private final ExceptionSupplier streamSupplier;
ClientConfiguration(final XMLInputFactory xmlInputFactory, final URI configurationUri, final ExceptionSupplier streamSupplier) {
this.xmlInputFactory = xmlInputFactory;
this.configurationUri = configurationUri;
this.streamSupplier = streamSupplier;
}
ClientConfiguration(final XMLInputFactory xmlInputFactory, final URI configurationUri) {
this.xmlInputFactory = xmlInputFactory;
this.configurationUri = configurationUri;
this.streamSupplier = this::streamOpener;
}
private InputStream streamOpener() throws IOException {
final URL url = configurationUri.toURL();
final URLConnection connection = url.openConnection();
connection.setRequestProperty("Accept", "application/xml,text/xml,application/xhtml+xml");
return connection.getInputStream();
}
XMLInputFactory getXmlInputFactory() {
return xmlInputFactory;
}
/**
* Get the URI from which the configuration is being read.
*
* @return the URI from which the configuration is being read
*/
public URI getConfigurationUri() {
return configurationUri;
}
static ConfigurationXMLStreamReader openUri(final URI uri, final XMLInputFactory xmlInputFactory) throws ConfigXMLParseException {
try {
final URL url = uri.toURL();
final URLConnection connection = url.openConnection();
connection.setRequestProperty("Accept", "application/xml,text/xml,application/xhtml+xml");
final InputStream inputStream = connection.getInputStream();
try {
return openUri(uri, xmlInputFactory, inputStream);
} catch (final Throwable t) {
try {
inputStream.close();
} catch (Throwable t2) {
t.addSuppressed(t2);
}
throw t;
}
} catch (MalformedURLException e) {
throw msg.invalidUrl(new XMLLocation(uri), e);
} catch (IOException e) {
throw msg.failedToReadInput(new XMLLocation(uri), e);
}
}
static ConfigurationXMLStreamReader openUri(final URI uri, final XMLInputFactory xmlInputFactory, final InputStream inputStream) throws ConfigXMLParseException {
try {
return new BasicXMLStreamReader(null, xmlInputFactory.createXMLStreamReader(inputStream), uri, xmlInputFactory, inputStream);
} catch (XMLStreamException e) {
throw ConfigXMLParseException.from(e, uri, null);
}
}
/**
* Get a stream reader over a configuration. The configuration returned will be the first element within the root
* {@code configuration} element which has a namespace corresponding to one of the given namespaces.
*
* @param recognizedNamespaces the recognized namespaces
* @return a reader which returns the first matching element
* @throws ConfigXMLParseException if a read error occurs
*/
public ConfigurationXMLStreamReader readConfiguration(Set recognizedNamespaces) throws ConfigXMLParseException {
final URI uri = this.configurationUri;
final InputStream inputStream;
try {
inputStream = streamSupplier.get();
} catch (MalformedURLException e) {
throw msg.invalidUrl(new XMLLocation(uri), e);
} catch (IOException e) {
throw msg.failedToReadInput(new XMLLocation(uri), e);
}
final ConfigurationXMLStreamReader reader = new XIncludeXMLStreamReader(openUri(uri, xmlInputFactory, inputStream));
try {
if (reader.hasNext()) {
switch (reader.nextTag()) {
case START_ELEMENT: {
final String namespaceURI = reader.getNamespaceURI();
final String localName = reader.getLocalName();
if (reader.hasNamespace() && ! reader.namespaceURIEquals(WILDFLY_CLIENT_1_0)) {
throw msg.unexpectedElement(localName, namespaceURI, reader.getLocation());
}
if (reader.getAttributeCount() > 0) {
throw msg.unexpectedAttribute(reader.getAttributeName(0), reader.getLocation());
}
if (! "configuration".equals(localName)) {
if (namespaceURI == null) {
throw msg.unexpectedElement(localName, reader.getLocation());
} else {
throw msg.unexpectedElement(localName, namespaceURI, reader.getLocation());
}
}
return new SelectingXMLStreamReader(true, reader, recognizedNamespaces);
}
default: {
throw msg.unexpectedContent(eventToString(reader.getEventType()), reader.getLocation());
}
}
}
// no config found
reader.close();
return null;
} catch (Throwable t) {
try {
reader.close();
} catch (Throwable t2) {
t.addSuppressed(t2);
}
throw t;
}
}
/**
* Get a client configuration instance for a certain URI.
*
* @param configurationUri the configuration URI
* @return the client configuration instance
*/
public static ClientConfiguration getInstance(URI configurationUri) {
Assert.checkNotNullParam("configurationUri", configurationUri);
return new ClientConfiguration(createXmlInputFactory(), configurationUri);
}
/**
* Get a client configuration instance for a certain URI, with streams provided by the given supplier.
*
* @param configurationUri the configuration URI
* @return the client configuration instance
*/
public static ClientConfiguration getInstance(URI configurationUri, ExceptionSupplier streamSupplier) {
Assert.checkNotNullParam("configurationUri", configurationUri);
return new ClientConfiguration(createXmlInputFactory(), configurationUri, streamSupplier);
}
private static XMLInputFactory createXmlInputFactory() {
final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory();
xmlInputFactory.setProperty(XMLInputFactory.IS_VALIDATING, FALSE);
xmlInputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, FALSE);
xmlInputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, FALSE);
return xmlInputFactory;
}
/**
* Get a client configuration instance from the current environment. First, the system property
* {@code wildfly.config.url} is checked. If present, the configuration file is taken from that URL (which is resolved
* against the current working directory if it is a relative URL or a bare path). If the property is not given,
* the current thread's context class loader is consulted for a file called {@code wildfly-config.xml}, either in the
* root of the class loader or within the {@code META-INF} folder. If no such resource is found, the same search
* is done against the class loader of this library. Finally, if no configurations are found or are loadable, {@code null}
* is returned.
*
* @return the client configuration instance, or {@code null} if no configuration is found
*/
public static ClientConfiguration getInstance() {
// specified URL overrides all
final String wildFlyConfig = System.getProperty("wildfly.config.url");
if (wildFlyConfig != null) {
return getInstance(propertyUrlToUri(wildFlyConfig));
}
ClassLoader classLoader;
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
classLoader = AccessController.doPrivileged((PrivilegedAction) ClientConfiguration::getContextClassLoader);
} else {
classLoader = getContextClassLoader();
}
if (classLoader == null) {
// no priv block needed since it's our class loader
classLoader = ClientConfiguration.class.getClassLoader();
}
return getInstance(classLoader);
}
/**
* Get a client configuration instance loaded from a file called {@code wildfly-config.xml}, either from the
* root of the specified class loader or within the {@code META-INF} folder.
* If no configurations are found or are loadable, {@code null} is returned.
*
* @param classLoader the class loader from which to load the configuration resource
* @return the client configuration instance, or {@code null} if no configuration is found
*/
public static ClientConfiguration getInstance(ClassLoader classLoader) {
URL resource = classLoader.getResource("wildfly-config.xml");
if (resource == null) {
resource = classLoader.getResource("META-INF/wildfly-config.xml");
if (resource == null) {
return null;
}
}
try {
return new ClientConfiguration(XMLInputFactory.newFactory(), resource.toURI(), resource::openStream);
} catch (URISyntaxException e) {
return null;
}
}
static URI propertyUrlToUri(String wildFlyConfig) {
if (File.separator.equals("\\") && wildFlyConfig.contains("\\")) { // we are on the windows and path is for windows
File f = new File(wildFlyConfig);
return f.toPath().toUri();
} else {
try {
URI uri = new URI(wildFlyConfig);
if (!uri.isAbsolute()) { // URI does not include schema
if (uri.getPath().charAt(0) != File.separatorChar && uri.getPath().charAt(0) != '/') { // relative path
String userDir = System.getProperty("user.dir").replace(File.separatorChar, '/');
return Paths.get(userDir, uri.getPath()).toUri();
} else { // absolute path
return Paths.get(uri.getPath()).toUri();
}
}
return uri;
} catch (URISyntaxException e) {
// no config file there
return null;
}
}
}
private static ClassLoader getContextClassLoader() {
return Thread.currentThread().getContextClassLoader();
}
}
ConfigXMLParseException.java 0000664 0000000 0000000 00000027256 13337777503 0033631 0 ustar 00root root 0000000 0000000 wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config /*
* JBoss, Home of Professional Open Source.
* Copyright 2015 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.client.config;
import static org.wildfly.client.config._private.ConfigMessages.msg;
import java.net.URI;
import javax.xml.stream.Location;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
/**
* @author David M. Lloyd
*/
public class ConfigXMLParseException extends XMLStreamException {
private static final long serialVersionUID = -1880381457871462141L;
/**
* Constructs a new {@code ConfigXMLParseException} instance. The message is left blank ({@code null}), and no
* cause is specified.
*/
public ConfigXMLParseException() {
}
/**
* Constructs a new {@code ConfigXMLParseException} instance with an initial message. No cause is specified.
*
* @param msg the message
*/
public ConfigXMLParseException(final String msg) {
super(msg);
}
/**
* Constructs a new {@code ConfigXMLParseException} instance with an initial cause. If a non-{@code null} cause is
* specified, its message is used to initialize the message of this {@code ConfigXMLParseException}; otherwise the
* message is left blank ({@code null}).
*
* @param cause the cause
*/
public ConfigXMLParseException(final Throwable cause) {
super(cause);
}
/**
* Constructs a new {@code ConfigXMLParseException} instance with an initial message and cause.
*
* @param msg the message
* @param cause the cause
*/
public ConfigXMLParseException(final String msg, final Throwable cause) {
super(msg, cause);
}
/**
* Constructs a new {@code ConfigXMLParseException} instance. The message is left blank ({@code null}), and no
* cause is specified.
*
* @param location the location of the exception
*/
public ConfigXMLParseException(final Location location) {
this(msg.parseError(), XMLLocation.toXMLLocation(location), 0);
}
/**
* Constructs a new {@code ConfigXMLParseException} instance with an initial message. No cause is specified.
*
* @param msg the message
* @param location the location of the exception
*/
public ConfigXMLParseException(final String msg, final Location location) {
this(msg, XMLLocation.toXMLLocation(location), 0);
}
/**
* Constructs a new {@code ConfigXMLParseException} instance with an initial cause. If a non-{@code null} cause is
* specified, its message is used to initialize the message of this {@code ConfigXMLParseException}; otherwise the
* message is left blank ({@code null}).
*
* @param cause the cause
* @param location the location of the exception
*/
public ConfigXMLParseException(final Throwable cause, final Location location) {
this(msg.parseError(), XMLLocation.toXMLLocation(location), cause, 0);
}
/**
* Constructs a new {@code ConfigXMLParseException} instance with an initial message and cause.
* @param msg the message
* @param location the location of the exception
* @param cause the cause
*/
public ConfigXMLParseException(final String msg, final Location location, final Throwable cause) {
this(msg, XMLLocation.toXMLLocation(location), cause, 0);
}
/**
* Constructs a new {@code ConfigXMLParseException} instance. The message is left blank ({@code null}), and no
* cause is specified.
*
* @param reader an XML reader at the position of the problem
*/
public ConfigXMLParseException(final XMLStreamReader reader) {
this(msg.parseError(), XMLLocation.toXMLLocation(reader.getLocation()), 0);
}
/**
* Constructs a new {@code ConfigXMLParseException} instance with an initial message. No cause is specified.
*
* @param msg the message
* @param reader an XML reader at the position of the problem
*/
public ConfigXMLParseException(final String msg, final XMLStreamReader reader) {
this(msg, XMLLocation.toXMLLocation(reader.getLocation()), 0);
}
/**
* Constructs a new {@code ConfigXMLParseException} instance with an initial cause. If a non-{@code null} cause is
* specified, its message is used to initialize the message of this {@code ConfigXMLParseException}; otherwise the
* message is left blank ({@code null}).
*
* @param cause the cause
* @param reader an XML reader at the position of the problem
*/
public ConfigXMLParseException(final Throwable cause, final XMLStreamReader reader) {
this(msg.parseError(), XMLLocation.toXMLLocation(reader.getLocation()), cause, 0);
}
/**
* Constructs a new {@code ConfigXMLParseException} instance with an initial message and cause.
*
* @param msg the message
* @param reader an XML reader at the position of the problem
* @param cause the cause
*/
public ConfigXMLParseException(final String msg, final XMLStreamReader reader, final Throwable cause) {
this(msg, XMLLocation.toXMLLocation(reader.getLocation()), cause, 0);
}
/**
* Get the location of this exception.
*
* @return the location of this exception
*/
public XMLLocation getLocation() {
return XMLLocation.toXMLLocation(super.getLocation());
}
/**
* Set the location of this exception.
*
* @param location the location of this exception
*/
protected void setLocation(XMLLocation location) {
this.location = location;
}
static ConfigXMLParseException from(final XMLStreamException exception) {
if (exception instanceof ConfigXMLParseException) return (ConfigXMLParseException) exception;
final StackTraceElement[] stackTrace = exception.getStackTrace();
final Throwable cause = exception.getCause();
final ConfigXMLParseException parseException;
if (cause != null) {
parseException = new ConfigXMLParseException(clean(exception.getMessage()), exception.getLocation(), cause);
} else {
parseException = new ConfigXMLParseException(clean(exception.getMessage()), exception.getLocation());
}
parseException.setStackTrace(stackTrace);
return parseException;
}
static ConfigXMLParseException from(final XMLStreamException exception, final URI uri) {
if (exception instanceof ConfigXMLParseException) return (ConfigXMLParseException) exception;
final StackTraceElement[] stackTrace = exception.getStackTrace();
final Throwable cause = exception.getCause();
final ConfigXMLParseException parseException;
if (cause != null) {
parseException = new ConfigXMLParseException(clean(exception.getMessage()), XMLLocation.toXMLLocation(uri, exception.getLocation()), cause);
} else {
parseException = new ConfigXMLParseException(clean(exception.getMessage()), XMLLocation.toXMLLocation(uri, exception.getLocation()));
}
parseException.setStackTrace(stackTrace);
return parseException;
}
static ConfigXMLParseException from(final XMLStreamException exception, final URI uri, final XMLLocation includedFrom) {
if (exception instanceof ConfigXMLParseException) return (ConfigXMLParseException) exception;
final StackTraceElement[] stackTrace = exception.getStackTrace();
final Throwable cause = exception.getCause();
final ConfigXMLParseException parseException;
if (cause != null) {
parseException = new ConfigXMLParseException(clean(exception.getMessage()), XMLLocation.toXMLLocation(includedFrom, uri, exception.getLocation()), cause);
} else {
parseException = new ConfigXMLParseException(clean(exception.getMessage()), XMLLocation.toXMLLocation(includedFrom, uri, exception.getLocation()));
}
parseException.setStackTrace(stackTrace);
return parseException;
}
static ConfigXMLParseException from(final Exception exception) {
if (exception instanceof XMLStreamException) {
return from((XMLStreamException) exception);
}
final StackTraceElement[] stackTrace = exception.getStackTrace();
final Throwable cause = exception.getCause();
final ConfigXMLParseException parseException;
if (cause != null) {
parseException = new ConfigXMLParseException(clean(exception.getMessage()), XMLLocation.UNKNOWN, cause);
} else {
parseException = new ConfigXMLParseException(clean(exception.getMessage()), XMLLocation.UNKNOWN);
}
parseException.setStackTrace(stackTrace);
return parseException;
}
static ConfigXMLParseException from(final Exception exception, final URI uri) {
if (exception instanceof XMLStreamException) {
return from((XMLStreamException) exception, uri);
}
final StackTraceElement[] stackTrace = exception.getStackTrace();
final Throwable cause = exception.getCause();
final ConfigXMLParseException parseException;
if (cause != null) {
parseException = new ConfigXMLParseException(clean(exception.getMessage()), XMLLocation.toXMLLocation(uri, new XMLLocation(uri)), cause);
} else {
parseException = new ConfigXMLParseException(clean(exception.getMessage()), XMLLocation.toXMLLocation(uri, new XMLLocation(uri)));
}
parseException.setStackTrace(stackTrace);
return parseException;
}
static ConfigXMLParseException from(final Exception exception, final URI uri, final XMLLocation includedFrom) {
if (exception instanceof XMLStreamException) {
return from((XMLStreamException) exception, uri, includedFrom);
}
final StackTraceElement[] stackTrace = exception.getStackTrace();
final Throwable cause = exception.getCause();
final ConfigXMLParseException parseException;
if (cause != null) {
parseException = new ConfigXMLParseException(clean(exception.getMessage()), XMLLocation.toXMLLocation(includedFrom, uri, new XMLLocation(uri)), cause);
} else {
parseException = new ConfigXMLParseException(clean(exception.getMessage()), XMLLocation.toXMLLocation(includedFrom, uri, new XMLLocation(uri)));
}
parseException.setStackTrace(stackTrace);
return parseException;
}
private static String clean(String original) {
if (original.startsWith("ParseError at [row,col]:[")) {
final int idx = original.indexOf("Message: ");
return idx == -1 ? original : original.substring(idx + 9);
} else {
return original;
}
}
private ConfigXMLParseException(final String msg, final XMLLocation location, @SuppressWarnings("unused") int ignored) {
super(msg + location);
this.location = location;
}
private ConfigXMLParseException(final String msg, final XMLLocation location, final Throwable cause, @SuppressWarnings("unused") int ignored) {
super(msg + location, cause);
this.location = location;
}
}
ConfigurationXMLStreamReader.java 0000664 0000000 0000000 00000071306 13337777503 0034653 0 ustar 00root root 0000000 0000000 wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config /*
* JBoss, Home of Professional Open Source.
* Copyright 2015 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.client.config;
import static org.wildfly.client.config._private.ConfigMessages.msg;
import java.net.InetAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import org.wildfly.common.expression.Expression;
import org.wildfly.common.net.CidrAddress;
import org.wildfly.common.net.Inet;
/**
* @author David M. Lloyd
*/
public interface ConfigurationXMLStreamReader extends XMLStreamReader, AutoCloseable {
char[] EMPTY_CHARS = new char[0];
URI getUri();
XMLInputFactory getXmlInputFactory();
XMLLocation getIncludedFrom();
boolean hasNext() throws ConfigXMLParseException;
int next() throws ConfigXMLParseException;
/**
* Determine whether the current element has a non-empty namespace URI.
*
* @return {@code true} if the element has a non-empty namespace URI, {@code false} otherwise
*/
default boolean hasNamespace() {
final String namespaceURI = getNamespaceURI();
return namespaceURI != null && ! namespaceURI.isEmpty();
}
/**
* Determine whether the current element has a namespace URI equal to the given value. If the given
* value is {@code null} or empty, this method returns {@code true} only if the current element has no namespace.
*
* @param uri the namespace URI to test
* @return {@code true} if the element has a namespace URI equal to the argument, or the argument is {@code null} or empty
* and the element has no namespace, or {@code false} otherwise
*/
default boolean namespaceURIEquals(String uri) {
return uri == null || uri.isEmpty() ? ! hasNamespace() : uri.equals(getNamespaceURI());
}
/**
* Determine whether the current element has an attribute at the given index with a non-empty namespace URI.
*
* @param idx the attribute index
* @return {@code true} if the attribute has a non-empty namespace URI, {@code false} otherwise
*/
default boolean hasAttributeNamespace(int idx) {
final String attributeNamespace = getAttributeNamespace(idx);
return attributeNamespace != null && ! attributeNamespace.isEmpty();
}
/**
* Determine whether the current element has an attribute at the given index with a namespace URI equal to the given value. If the given
* value is {@code null} or empty, this method returns {@code true} only if the attribute has no namespace.
*
* @param idx the attribute index
* @param uri the namespace URI to test
* @return {@code true} if the attribute has a namespace URI equal to the argument, or the argument is {@code null} or empty
* and the element has no namespace, or {@code false} otherwise
*/
default boolean attributeNamespaceEquals(int idx, String uri) {
return uri == null || uri.isEmpty() ? ! hasAttributeNamespace(idx) : uri.equals(getAttributeNamespace(idx));
}
default int nextTag() throws ConfigXMLParseException {
int eventType;
for (;;) {
eventType = next();
switch (eventType) {
case SPACE:
case PROCESSING_INSTRUCTION:
case COMMENT: {
break;
}
case START_ELEMENT:
case END_ELEMENT: {
return eventType;
}
case CHARACTERS:
case CDATA: {
if (isWhiteSpace()) {
break;
}
// fall thru
}
default: {
throw msg.expectedStartOrEndElement(eventToString(eventType), getLocation());
}
}
}
}
default String getElementText() throws ConfigXMLParseException {
int eventType = getEventType();
if (eventType != START_ELEMENT) {
throw msg.expectedStartElement(eventToString(eventType), getLocation());
}
final StringBuilder sb = new StringBuilder();
for (;;) {
eventType = next();
switch (eventType) {
case END_ELEMENT: {
return sb.toString();
}
case CHARACTERS:
case CDATA:
case SPACE:
case ENTITY_REFERENCE: {
sb.append(getText());
break;
}
case PROCESSING_INSTRUCTION:
case COMMENT: {
// skip
break;
}
case END_DOCUMENT: {
throw msg.unexpectedDocumentEnd(getLocation());
}
case START_ELEMENT: {
throw msg.textCannotContainElements(getLocation());
}
default: {
throw msg.unexpectedContent(eventToString(eventType), getLocation());
}
}
}
}
/**
* Get the element text content as an expression.
*
* @param flags the expression compilation flags
* @return the expression (not {@code null})
* @throws ConfigXMLParseException if the value is not a valid expression by the given flags
*/
default Expression getElementExpression(Expression.Flag... flags) throws ConfigXMLParseException {
try {
return Expression.compile(getElementText(), flags);
} catch (IllegalArgumentException ex) {
throw msg.expressionTextParseException(ex, getLocation());
}
}
default void require(final int type, final String namespaceURI, final String localName) throws ConfigXMLParseException {
if (getEventType() != type) {
throw msg.expectedEventType(eventToString(type), eventToString(getEventType()), getLocation());
} else if (namespaceURI != null && !namespaceURI.equals(getNamespaceURI())) {
throw msg.expectedNamespace(namespaceURI, getNamespaceURI(), getLocation());
} else if (localName != null && !localName.equals(getLocalName())) {
throw msg.expectedLocalName(localName, getLocalName(), getLocation());
}
}
default boolean isStartElement() {
return getEventType() == START_ELEMENT;
}
default boolean isEndElement() {
return getEventType() == END_ELEMENT;
}
default boolean isCharacters() {
return getEventType() == CHARACTERS;
}
default boolean isWhiteSpace() {
return getEventType() == SPACE || getEventType() == CHARACTERS && getText().trim().isEmpty();
}
static String eventToString(final int type) {
switch (type) {
case START_DOCUMENT: return "document start";
case END_DOCUMENT: return "document end";
case START_ELEMENT: return "start element";
case END_ELEMENT: return "end element";
case CDATA: return "cdata";
case CHARACTERS: return "characters";
case ATTRIBUTE: return "attribute";
case DTD: return "dtd";
case ENTITY_DECLARATION: return "entity declaration";
case ENTITY_REFERENCE: return "entity reference";
case NAMESPACE: return "namespace";
case NOTATION_DECLARATION: return "notation declaration";
case PROCESSING_INSTRUCTION: return "processing instruction";
case SPACE: return "white space";
default: return "unknown";
}
}
default Object getProperty(final String name) throws IllegalArgumentException {
return null;
}
default boolean hasText() {
switch (getEventType()) {
case CHARACTERS:
case DTD:
case ENTITY_REFERENCE:
case COMMENT:
case SPACE: {
return true;
}
default: {
return false;
}
}
}
default boolean isStandalone() {
return false;
}
default boolean standaloneSet() {
return false;
}
default boolean hasName() {
final int eventType = getEventType();
return eventType == START_ELEMENT || eventType == END_ELEMENT;
}
XMLLocation getLocation();
int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws ConfigXMLParseException;
void close() throws ConfigXMLParseException;
default void skipContent() throws ConfigXMLParseException {
while (hasNext()) {
switch (next()) {
case START_ELEMENT: {
skipContent();
break;
}
case END_ELEMENT: {
return;
}
}
}
}
// ===== exceptions =====
/**
* Return a throwable exception explaining that the element at the current position was not expected.
*
* @return the exception
*/
default ConfigXMLParseException unexpectedElement() {
final String namespaceURI = getNamespaceURI();
final String localName = getLocalName();
if (namespaceURI == null) {
return msg.unexpectedElement(localName, getLocation());
} else {
return msg.unexpectedElement(localName, namespaceURI, getLocation());
}
}
/**
* Return a throwable exception explaining that the attribute at the current position with the given index was not
* expected.
*
* @param i the attribute index
* @return the exception
*/
default ConfigXMLParseException unexpectedAttribute(int i) {
return msg.unexpectedAttribute(getAttributeName(i), getLocation());
}
/**
* Return a throwable exception explaining that the document end was reached unexpectedly.
*
* @return the exception
*/
default ConfigXMLParseException unexpectedDocumentEnd() {
return msg.unexpectedDocumentEnd(getLocation());
}
/**
* Return a throwable exception explaining that some unexpected content was encountered.
*
* @return the exception
*/
default ConfigXMLParseException unexpectedContent() {
return msg.unexpectedContent(eventToString(getEventType()), getLocation());
}
/**
* Return a throwable exception explaining that a required element with the given namespace and local name was missing.
*
* @param namespaceUri the namespace URI
* @param localName the local element name
* @return the exception
*/
default ConfigXMLParseException missingRequiredElement(String namespaceUri, String localName) {
return msg.missingRequiredElement(namespaceUri, localName, getLocation());
}
/**
* Return a throwable exception explaining that a required attribute with the given namespace and local name was missing.
*
* @param namespaceUri the namespace URI (or {@code null} if it is a local name)
* @param localName the local attribute name
* @return the exception
*/
default ConfigXMLParseException missingRequiredAttribute(String namespaceUri, String localName) {
return msg.missingRequiredAttribute(namespaceUri, localName, getLocation());
}
/**
* Return a throwable exception explaining that a numeric attribute at the given index was out of its required range.
*
* @param index the attribute index
* @param minValue the minimum attribute value
* @param maxValue the maximum attribute value
* @return the exception
*/
default ConfigXMLParseException numericAttributeValueOutOfRange(int index, long minValue, long maxValue) {
return msg.numericAttributeValueOutOfRange(getAttributeName(index), getAttributeValue(index), minValue, maxValue, getLocation());
}
// ===== attribute helpers =====
/**
* Get the value of an attribute.
*
* @param index the index of the attribute
* @return the attribute value
*/
String getAttributeValue(int index);
/**
* Get the value of an attribute with expressions resolved.
*
* @param index the index of the attribute
* @return the attribute value
* @throws ConfigXMLParseException if an error occurs
*/
default String getAttributeValueResolved(int index) throws ConfigXMLParseException {
final Expression expression = getExpressionAttributeValue(index, Expression.Flag.ESCAPES);
return expression.evaluateWithPropertiesAndEnvironment(false);
}
/**
* Get the value of an attribute as an integer.
*
* @param index the index of the attribute
*
* @return the integer value
*
* @throws ConfigXMLParseException if an error occurs
*/
default int getIntAttributeValue(int index) throws ConfigXMLParseException {
try {
return Integer.parseInt(getAttributeValue(index));
} catch (NumberFormatException e) {
throw msg.intParseException(e, getAttributeName(index), getLocation());
}
}
/**
* Get the value of an attribute as an integer with expressions resolved.
*
* @param index the index of the attribute
*
* @return the integer value
*
* @throws ConfigXMLParseException if an error occurs
*/
default int getIntAttributeValueResolved(int index) throws ConfigXMLParseException {
try {
return Integer.parseInt(getAttributeValueResolved(index));
} catch (NumberFormatException e) {
throw msg.intParseException(e, getAttributeName(index), getLocation());
}
}
/**
* Get the value of an attribute as an integer.
*
* @param index the index of the attribute
* @param minValue the minimum allowed value
* @param maxValue the maximum allowed value
*
* @return the integer value
*
* @throws ConfigXMLParseException if an error occurs
*/
default int getIntAttributeValue(int index, int minValue, int maxValue) throws ConfigXMLParseException {
final int value = getIntAttributeValue(index);
if (value < minValue || value > maxValue) {
throw numericAttributeValueOutOfRange(index, minValue, maxValue);
}
return value;
}
/**
* Get the value of an attribute as an integer with expressions resolved.
*
* @param index the index of the attribute
* @param minValue the minimum allowed value
* @param maxValue the maximum allowed value
*
* @return the integer value
*
* @throws ConfigXMLParseException if an error occurs
*/
default int getIntAttributeValueResolved(int index, int minValue, int maxValue) throws ConfigXMLParseException {
final int value = getIntAttributeValueResolved(index);
if (value < minValue || value > maxValue) {
throw numericAttributeValueOutOfRange(index, minValue, maxValue);
}
return value;
}
/**
* Get the value of an attribute as an integer list.
*
* @param index the index of the attribute
*
* @return the integer values
*
* @throws ConfigXMLParseException if an error occurs
*/
default int[] getIntListAttributeValue(int index) throws ConfigXMLParseException {
try {
return new Delimiterator(getAttributeValue(index), ' ').toIntArray();
} catch (NumberFormatException e) {
throw msg.intParseException(e, getAttributeName(index), getLocation());
}
}
/**
* Get the value of an attribute as an integer list with expressions resolved.
*
* @param index the index of the attribute
*
* @return the integer values
*
* @throws ConfigXMLParseException if an error occurs
*/
default int[] getIntListAttributeValueResolved(int index) throws ConfigXMLParseException {
try {
return new Delimiterator(getAttributeValueResolved(index), ' ').toIntArray();
} catch (NumberFormatException e) {
throw msg.intParseException(e, getAttributeName(index), getLocation());
}
}
/**
* Get the value of an attribute as a space-delimited string list, as an iterator.
*
* @param index the index of the attribute
* @return the values
* @throws ConfigXMLParseException if an error occurs
*/
default Iterator getListAttributeValueAsIterator(int index) throws ConfigXMLParseException {
return new Delimiterator(getAttributeValue(index), ' ');
}
/**
/**
* Get the value of an attribute as a space-delimited string list with expressions resolved, as an iterator.
*
* @param index the index of the attribute
* @return the values
* @throws ConfigXMLParseException if an error occurs
*/
default Iterator getListAttributeValueAsIteratorResolved(int index) throws ConfigXMLParseException {
return new Delimiterator(getAttributeValueResolved(index), ' ');
}
/**
* Get the value of an attribute as a space-delimited string list.
*
* @param index the index of the attribute
* @return the values
* @throws ConfigXMLParseException if an error occurs
*/
default List getListAttributeValue(int index) throws ConfigXMLParseException {
return Arrays.asList(getListAttributeValueAsArray(index));
}
/**
* Get the value of an attribute as a space-delimited string list with expressions resolved.
*
* @param index the index of the attribute
* @return the values
* @throws ConfigXMLParseException if an error occurs
*/
default List getListAttributeValueResolved(int index) throws ConfigXMLParseException {
return Arrays.asList(getListAttributeValueAsArrayResolved(index));
}
/**
* Get the value of an attribute as a space-delimited string list, as an array.
*
* @param index the index of the attribute
*
* @return the values
*
* @throws ConfigXMLParseException if an error occurs
*/
default String[] getListAttributeValueAsArray(int index) throws ConfigXMLParseException {
return new Delimiterator(getAttributeValue(index), ' ').toStringArray();
}
/**
* Get the value of an attribute as a space-delimited string list with expressions resolved, as an array.
*
* @param index the index of the attribute
*
* @return the values
*
* @throws ConfigXMLParseException if an error occurs
*/
default String[] getListAttributeValueAsArrayResolved(int index) throws ConfigXMLParseException {
return new Delimiterator(getAttributeValueResolved(index), ' ').toStringArray();
}
/**
* Get the value of an attribute as a long.
*
* @param index the index of the attribute
*
* @return the long value
*
* @throws ConfigXMLParseException if an error occurs
*/
default long getLongAttributeValue(int index) throws ConfigXMLParseException {
try {
return Long.parseLong(getAttributeValue(index));
} catch (NumberFormatException e) {
throw msg.intParseException(e, getAttributeName(index), getLocation());
}
}
/**
* Get the value of an attribute as a long with expressions resolved.
*
* @param index the index of the attribute
*
* @return the long value
*
* @throws ConfigXMLParseException if an error occurs
*/
default long getLongAttributeValueResolved(int index) throws ConfigXMLParseException {
try {
return Long.parseLong(getAttributeValueResolved(index));
} catch (NumberFormatException e) {
throw msg.intParseException(e, getAttributeName(index), getLocation());
}
}
/**
* Get the value of an attribute as a long.
*
* @param index the index of the attribute
* @param minValue the minimum allowed value
* @param maxValue the maximum allowed value
*
* @return the long value
*
* @throws ConfigXMLParseException if an error occurs
*/
default long getLongAttributeValue(int index, long minValue, long maxValue) throws ConfigXMLParseException {
final long value = getLongAttributeValue(index);
if (value < minValue || value > maxValue) {
throw numericAttributeValueOutOfRange(index, minValue, maxValue);
}
return value;
}
/**
* Get the value of an attribute as a long with expressions resolved.
*
* @param index the index of the attribute
* @param minValue the minimum allowed value
* @param maxValue the maximum allowed value
*
* @return the long value
*
* @throws ConfigXMLParseException if an error occurs
*/
default long getLongAttributeValueResolved(int index, long minValue, long maxValue) throws ConfigXMLParseException {
final long value = getLongAttributeValueResolved(index);
if (value < minValue || value > maxValue) {
throw numericAttributeValueOutOfRange(index, minValue, maxValue);
}
return value;
}
/**
* Get the value of an attribute as a long integer list.
*
* @param index the index of the attribute
*
* @return the long values
*
* @throws ConfigXMLParseException if an error occurs
*/
default long[] getLongListAttributeValue(int index) throws ConfigXMLParseException {
try {
return new Delimiterator(getAttributeValue(index), ' ').toLongArray();
} catch (NumberFormatException e) {
throw msg.intParseException(e, getAttributeName(index), getLocation());
}
}
/**
* Get the value of an attribute as a long integer list with expressions resolved.
*
* @param index the index of the attribute
*
* @return the long values
*
* @throws ConfigXMLParseException if an error occurs
*/
default long[] getLongListAttributeValueResolved(int index) throws ConfigXMLParseException {
try {
return new Delimiterator(getAttributeValueResolved(index), ' ').toLongArray();
} catch (NumberFormatException e) {
throw msg.intParseException(e, getAttributeName(index), getLocation());
}
}
/**
* Get an attribute value as a {@code boolean}. Only the string {@code "true"} (case-insensitive) is recognized as
* a {@code true} value; all other strings are considered {@code false}.
*
* @param index the attribute index
* @return the attribute value
*/
default boolean getBooleanAttributeValue(int index) {
return Boolean.parseBoolean(getAttributeValue(index));
}
/**
* Get an attribute value as a {@code boolean} with expressions resolved. Only the string {@code "true"} (case-insensitive) is recognized as
* a {@code true} value; all other strings are considered {@code false}.
*
* @param index the attribute index
* @return the attribute value
* @throws ConfigXMLParseException if an error occurs
*/
default boolean getBooleanAttributeValueResolved(int index) throws ConfigXMLParseException {
return Boolean.parseBoolean(getAttributeValueResolved(index));
}
/**
* Get an attribute value as a {@link URI}.
*
* @param index the attribute index
* @return the attribute value
* @throws ConfigXMLParseException if the value is not a valid URI
*/
default URI getURIAttributeValue(int index) throws ConfigXMLParseException {
try {
return new URI(getAttributeValue(index));
} catch (URISyntaxException e) {
throw msg.uriParseException(e, getAttributeName(index), getLocation());
}
}
/**
* Get an attribute value as a {@link URI} with expressions resolved.
*
* @param index the attribute index
* @return the attribute value
* @throws ConfigXMLParseException if the value is not a valid URI
*/
default URI getURIAttributeValueResolved(int index) throws ConfigXMLParseException {
try {
return new URI(getAttributeValueResolved(index));
} catch (URISyntaxException e) {
throw msg.uriParseException(e, getAttributeName(index), getLocation());
}
}
/**
* Get an attribute value as a compiled {@link Expression}.
*
* @param index the attribute index
* @param flags the expression compilation flags
* @return the expression, or {@code null} if the attribute is not present
* @throws ConfigXMLParseException if the value is not a valid expression by the given flags
*/
default Expression getExpressionAttributeValue(int index, Expression.Flag... flags) throws ConfigXMLParseException {
final String attributeValue = getAttributeValue(index);
if (attributeValue == null) {
return null;
} else try {
return Expression.compile(attributeValue, flags);
} catch (IllegalArgumentException ex) {
throw msg.expressionParseException(ex, getAttributeName(index), getLocation());
}
}
/**
* Get an attribute value as a {@link InetAddress}.
*
* @param index the attribute index
* @return the attribute value
* @throws ConfigXMLParseException if the value is not a valid IP address
*/
default InetAddress getInetAddressAttributeValue(int index) throws ConfigXMLParseException {
final String attributeValue = getAttributeValue(index);
if (attributeValue == null) {
return null;
} else {
final InetAddress inetAddress = Inet.parseInetAddress(attributeValue);
if (inetAddress == null) {
throw msg.inetAddressParseException(getAttributeName(index), attributeValue, getLocation());
}
return inetAddress;
}
}
/**
* Get an attribute value as a {@link InetAddress} with expressions resolved.
*
* @param index the attribute index
* @return the attribute value
* @throws ConfigXMLParseException if the value is not a valid IP address
*/
default InetAddress getInetAddressAttributeValueResolved(int index) throws ConfigXMLParseException {
final String attributeValue = getAttributeValueResolved(index);
if (attributeValue == null) {
return null;
} else {
final InetAddress inetAddress = Inet.parseInetAddress(attributeValue);
if (inetAddress == null) {
throw msg.inetAddressParseException(getAttributeName(index), attributeValue, getLocation());
}
return inetAddress;
}
}
/**
* Get an attribute value as a {@link CidrAddress}.
*
* @param index the attribute index
* @return the attribute value
* @throws ConfigXMLParseException if the value is not a valid IP address
*/
default CidrAddress getCidrAddressAttributeValue(int index) throws ConfigXMLParseException {
final String attributeValue = getAttributeValue(index);
if (attributeValue == null) {
return null;
} else {
final CidrAddress cidrAddress = Inet.parseCidrAddress(attributeValue);
if (cidrAddress == null) {
throw msg.cidrAddressParseException(getAttributeName(index), attributeValue, getLocation());
}
return cidrAddress;
}
}
/**
* Get an attribute value as a {@link CidrAddress} with expressions resolved.
*
* @param index the attribute index
* @return the attribute value
* @throws ConfigXMLParseException if the value is not a valid IP address
*/
default CidrAddress getCidrAddressAttributeValueResolved(int index) throws ConfigXMLParseException {
final String attributeValue = getAttributeValueResolved(index);
if (attributeValue == null) {
return null;
} else {
final CidrAddress cidrAddress = Inet.parseCidrAddress(attributeValue);
if (cidrAddress == null) {
throw msg.cidrAddressParseException(getAttributeName(index), attributeValue, getLocation());
}
return cidrAddress;
}
}
}
wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config/CountingReader.java 0000664 0000000 0000000 00000005047 13337777503 0032153 0 ustar 00root root 0000000 0000000 /*
* JBoss, Home of Professional Open Source.
* Copyright 2015 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.client.config;
import java.io.IOException;
import java.io.Reader;
/**
* @author David M. Lloyd
*/
final class CountingReader extends Reader {
private int lineNumber = 1;
private int columnNumber = 1;
private int characterOffset = 0;
private final Reader reader;
CountingReader(final Reader reader) {
this.reader = reader;
}
public int read() throws IOException {
int ch = reader.read();
if (ch == -1) return -1;
processChar(ch);
return ch;
}
private void processChar(final int ch) {
switch (ch) {
case '\n': {
characterOffset++;
lineNumber++;
columnNumber = 1;
break;
}
default: {
if (! Character.isLowSurrogate((char) ch)) {
characterOffset++;
columnNumber++;
}
break;
}
}
}
public int read(final char[] cbuf) throws IOException {
int cnt = reader.read(cbuf);
if (cnt > 0) {
for (int i = 0; i < cnt; i ++) {
processChar(cbuf[i]);
}
}
return cnt;
}
public int read(final char[] cbuf, final int off, final int len) throws IOException {
int cnt = reader.read(cbuf, off, len);
if (cnt > 0) {
for (int i = 0; i < cnt; i ++) {
processChar(cbuf[i + off]);
}
}
return cnt;
}
public void close() throws IOException {
reader.close();
}
public int getLineNumber() {
return lineNumber;
}
public int getColumnNumber() {
return columnNumber;
}
public int getCharacterOffset() {
return characterOffset;
}
}
wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config/Delimiterator.java 0000664 0000000 0000000 00000006253 13337777503 0032046 0 ustar 00root root 0000000 0000000 /*
* JBoss, Home of Professional Open Source.
* Copyright 2015 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.client.config;
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
* @author David M. Lloyd
*/
final class Delimiterator implements Iterator {
private final String subject;
private final char delimiter;
private int i;
private static final int[] NO_INTS = new int[0];
private static final long[] NO_LONGS = new long[0];
private static final String[] NO_STRINGS = new String[0];
Delimiterator(final String subject, final char delimiter) {
this.subject = subject;
this.delimiter = delimiter;
i = 0;
}
static Delimiterator over(String subject, char delimiter) {
return new Delimiterator(subject, delimiter);
}
public boolean hasNext() {
return i != -1;
}
public String next() {
final int i = this.i;
if (i == -1) {
throw new NoSuchElementException();
}
int n = subject.indexOf(delimiter, i);
try {
return n == -1 ? subject.substring(i) : subject.substring(i, n);
} finally {
this.i = n == -1 ? -1 : n + 1;
}
}
public void remove() {
throw new UnsupportedOperationException();
}
public String[] toStringArray() {
return toStringArray(0);
}
String[] toStringArray(int count) {
if (hasNext()) {
final String next = next();
final String[] strings = toStringArray(count + 1);
strings[count] = next;
return strings;
} else {
return count == 0 ? NO_STRINGS : new String[count];
}
}
public int[] toIntArray() throws NumberFormatException {
return toIntArray(0);
}
int[] toIntArray(int count) {
if (hasNext()) {
final String next = next();
final int[] ints = toIntArray(count + 1);
ints[count] = Integer.parseInt(next);
return ints;
} else {
return count == 0 ? NO_INTS : new int[count];
}
}
public long[] toLongArray() throws NumberFormatException {
return toLongArray(0);
}
long[] toLongArray(int count) {
if (hasNext()) {
final String next = next();
final long[] longs = toLongArray(count + 1);
longs[count] = Long.parseLong(next);
return longs;
} else {
return count == 0 ? NO_LONGS : new long[count];
}
}
} DrainingXMLStreamReader.java 0000664 0000000 0000000 00000002634 13337777503 0033575 0 ustar 00root root 0000000 0000000 wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config /*
* JBoss, Home of Professional Open Source.
* Copyright 2015 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.client.config;
/**
* @author David M. Lloyd
*/
final class DrainingXMLStreamReader extends AbstractDelegatingXMLStreamReader {
DrainingXMLStreamReader(final boolean closeDelegate, final ConfigurationXMLStreamReader delegate) {
super(closeDelegate, delegate);
}
public void close() throws ConfigXMLParseException {
try {
while (hasNext()) {
next();
}
super.close();
} catch (final Throwable t) {
try {
super.close();
} catch (Throwable t2) {
t.addSuppressed(t2);
}
throw t;
}
}
}
wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config/EmptyXMLStreamReader.java 0000664 0000000 0000000 00000010642 13337777503 0033215 0 ustar 00root root 0000000 0000000 /*
* JBoss, Home of Professional Open Source.
* Copyright 2015 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.client.config;
import java.net.URI;
import java.util.NoSuchElementException;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
/**
* @author David M. Lloyd
*/
final class EmptyXMLStreamReader implements ConfigurationXMLStreamReader {
private final URI uri;
private final XMLLocation includedFrom;
EmptyXMLStreamReader(final URI uri, final XMLLocation includedFrom) {
this.uri = uri;
this.includedFrom = includedFrom;
}
public URI getUri() {
return uri;
}
public XMLInputFactory getXmlInputFactory() {
throw new UnsupportedOperationException();
}
public XMLLocation getIncludedFrom() {
return includedFrom;
}
public boolean hasNext() throws ConfigXMLParseException {
return false;
}
public int next() throws ConfigXMLParseException {
throw new NoSuchElementException();
}
public XMLLocation getLocation() {
return XMLLocation.UNKNOWN;
}
public int getTextCharacters(final int sourceStart, final char[] target, final int targetStart, final int length) throws ConfigXMLParseException {
throw new UnsupportedOperationException();
}
public void close() {
}
public String getNamespaceURI(final String prefix) {
return null;
}
public String getAttributeValue(final String namespaceURI, final String localName) {
throw new IllegalStateException();
}
public int getAttributeCount() {
throw new IllegalStateException();
}
public QName getAttributeName(final int index) {
throw new IllegalStateException();
}
public String getAttributeNamespace(final int index) {
throw new IllegalStateException();
}
public String getAttributeLocalName(final int index) {
throw new IllegalStateException();
}
public String getAttributePrefix(final int index) {
throw new IllegalStateException();
}
public String getAttributeType(final int index) {
throw new IllegalStateException();
}
public String getAttributeValue(final int index) {
throw new IllegalStateException();
}
public boolean isAttributeSpecified(final int index) {
throw new IllegalStateException();
}
public int getNamespaceCount() {
return 0;
}
public String getNamespacePrefix(final int index) {
return null;
}
public String getNamespaceURI(final int index) {
return null;
}
public NamespaceContext getNamespaceContext() {
throw new UnsupportedOperationException();
}
public int getEventType() {
return END_DOCUMENT;
}
public String getText() {
throw new IllegalStateException();
}
public char[] getTextCharacters() {
throw new IllegalStateException();
}
public int getTextStart() {
throw new IllegalStateException();
}
public int getTextLength() {
throw new IllegalStateException();
}
public String getEncoding() {
return null;
}
public QName getName() {
throw new IllegalStateException();
}
public String getLocalName() {
throw new IllegalStateException();
}
public String getNamespaceURI() {
throw new IllegalStateException();
}
public String getPrefix() {
throw new IllegalStateException();
}
public String getVersion() {
return null;
}
public String getCharacterEncodingScheme() {
return null;
}
public String getPITarget() {
return null;
}
public String getPIData() {
return null;
}
}
wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config/ScopedXMLStreamReader.java0000664 0000000 0000000 00000003673 13337777503 0033342 0 ustar 00root root 0000000 0000000 /*
* JBoss, Home of Professional Open Source.
* Copyright 2015 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.client.config;
import java.util.NoSuchElementException;
import javax.xml.stream.XMLStreamException;
/**
* @author David M. Lloyd
*/
final class ScopedXMLStreamReader extends AbstractDelegatingXMLStreamReader {
private int level;
ScopedXMLStreamReader(final boolean closeDelegate, final ConfigurationXMLStreamReader delegate) {
super(closeDelegate, delegate);
}
public boolean hasNext() throws ConfigXMLParseException {
try {
return level >= 0 && getDelegate().hasNext();
} catch (XMLStreamException e) {
throw ConfigXMLParseException.from(e);
}
}
public int next() throws ConfigXMLParseException {
if (! hasNext()) {
throw new NoSuchElementException();
}
final int next;
try {
next = getDelegate().next();
} catch (XMLStreamException e) {
throw ConfigXMLParseException.from(e);
}
switch (next) {
case START_ELEMENT: {
level ++;
break;
}
case END_ELEMENT: {
level --;
break;
}
}
return next;
}
}
SelectingXMLStreamReader.java 0000664 0000000 0000000 00000006747 13337777503 0033770 0 ustar 00root root 0000000 0000000 wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config /*
* JBoss, Home of Professional Open Source.
* Copyright 2015 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.client.config;
import java.util.NoSuchElementException;
import java.util.Set;
/**
* @author David M. Lloyd
*/
class SelectingXMLStreamReader extends AbstractDelegatingXMLStreamReader {
private final Set namespaces;
private int state;
private int level;
private static final int ST_SEEKING = 0;
private static final int ST_FOUND_PRE = 1;
private static final int ST_FOUND = 2;
private static final int ST_DONE = 3;
SelectingXMLStreamReader(final boolean closeDelegate, final ConfigurationXMLStreamReader delegate, final Set namespaces) {
super(closeDelegate, delegate);
this.namespaces = namespaces;
}
public boolean hasNext() throws ConfigXMLParseException {
switch (state) {
case ST_SEEKING: {
while (super.hasNext()) {
final int next = super.next();
switch (next) {
case START_ELEMENT: {
if (namespaces.contains(super.getNamespaceURI())) {
state = ST_FOUND_PRE;
return true;
} else {
getDelegate().skipContent();
}
break;
}
case END_ELEMENT: {
state = ST_DONE;
return false;
}
}
}
return false;
}
case ST_FOUND_PRE: {
return true;
}
case ST_FOUND: {
return super.hasNext();
}
case ST_DONE: {
return false;
}
default: {
throw new IllegalStateException();
}
}
}
public int next() throws ConfigXMLParseException {
if (! hasNext()) throw new NoSuchElementException();
switch (state) {
case ST_FOUND_PRE: {
state = ST_FOUND;
return super.getEventType();
}
case ST_FOUND: {
int next = super.next();
switch (next) {
case START_ELEMENT: {
level ++;
break;
}
case END_ELEMENT: {
if (level-- == 0) {
state = ST_DONE;
}
break;
}
}
return next;
}
default: {
throw new IllegalStateException();
}
}
}
}
wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config/TextXMLStreamReader.java 0000664 0000000 0000000 00000015644 13337777503 0033052 0 ustar 00root root 0000000 0000000 /*
* JBoss, Home of Professional Open Source.
* Copyright 2015 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.client.config;
import static java.lang.Math.min;
import static org.wildfly.client.config._private.ConfigMessages.msg;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.NoSuchElementException;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
class TextXMLStreamReader implements ConfigurationXMLStreamReader {
private final String charsetName;
private final CountingReader reader;
private final ConfigurationXMLStreamReader parent;
private final URI uri;
private final XMLLocation includedFrom;
private char[] current = new char[512];
private int len;
private char[] next = new char[512];
private int nextLen;
TextXMLStreamReader(final String charsetName, final InputStream inputStream, final ConfigurationXMLStreamReader parent, final URI uri) throws UnsupportedEncodingException {
this(charsetName, new InputStreamReader(inputStream, charsetName), parent, uri);
}
TextXMLStreamReader(final Charset charset, final InputStream inputStream, final ConfigurationXMLStreamReader parent, final URI uri) {
this(charset.name(), new InputStreamReader(inputStream, charset), parent, uri);
}
TextXMLStreamReader(final String charsetName, final Reader reader, final ConfigurationXMLStreamReader parent, final URI uri) {
this(charsetName, reader instanceof CountingReader ? (CountingReader) reader : new CountingReader(reader), parent, uri);
}
TextXMLStreamReader(final String charsetName, final CountingReader reader, final ConfigurationXMLStreamReader parent, final URI uri) {
this.charsetName = charsetName;
this.reader = reader;
this.parent = parent;
this.uri = uri;
includedFrom = this.parent.getLocation();
}
public XMLLocation getIncludedFrom() {
return includedFrom;
}
public int next() throws ConfigXMLParseException {
if (! hasNext()) {
throw new NoSuchElementException();
}
// swap buffers
char[] old = current;
current = next;
len = nextLen;
next = old;
nextLen = 0;
return CHARACTERS;
}
public URI getUri() {
return uri;
}
public XMLInputFactory getXmlInputFactory() {
throw new UnsupportedOperationException();
}
public boolean hasNext() throws ConfigXMLParseException {
if (nextLen == 0) {
int res;
try {
res = reader.read(next);
} catch (IOException e) {
throw msg.failedToReadInput(getLocation(), e);
}
if (res == -1) {
return false;
}
nextLen = res;
}
return true;
}
public void close() throws ConfigXMLParseException {
try {
reader.close();
} catch (IOException e) {
throw msg.failedToCloseInput(getLocation(), e);
}
}
public String getNamespaceURI(final String prefix) {
return null;
}
public String getAttributeValue(final String namespaceURI, final String localName) {
throw new IllegalStateException();
}
public int getAttributeCount() {
throw new IllegalStateException();
}
public QName getAttributeName(final int index) {
throw new IllegalStateException();
}
public String getAttributeNamespace(final int index) {
throw new IllegalStateException();
}
public String getAttributeLocalName(final int index) {
throw new IllegalStateException();
}
public String getAttributePrefix(final int index) {
throw new IllegalStateException();
}
public String getAttributeType(final int index) {
throw new IllegalStateException();
}
public String getAttributeValue(final int index) {
throw new IllegalStateException();
}
public boolean isAttributeSpecified(final int index) {
throw new IllegalStateException();
}
public int getNamespaceCount() {
throw new IllegalStateException();
}
public String getNamespacePrefix(final int index) {
throw new IllegalStateException();
}
public String getNamespaceURI(final int index) {
throw new IllegalStateException();
}
public NamespaceContext getNamespaceContext() {
throw new IllegalStateException();
}
public int getEventType() {
return len == 0 ? START_DOCUMENT : CHARACTERS;
}
public String getText() {
if (len == 0) throw new IllegalStateException();
return new String(current, 0, len);
}
public char[] getTextCharacters() {
return Arrays.copyOf(current, len);
}
public int getTextCharacters(final int sourceStart, final char[] target, final int targetStart, final int length) {
if (sourceStart > len || targetStart > length) return 0;
int realLen = min(len - sourceStart, length);
System.arraycopy(current, sourceStart, target, targetStart, realLen);
return realLen;
}
public int getTextStart() {
return 0;
}
public int getTextLength() {
if (len == 0) throw new IllegalStateException();
return len;
}
public String getEncoding() {
return charsetName;
}
public XMLLocation getLocation() {
return new XMLLocation(includedFrom, uri, reader.getLineNumber(), reader.getColumnNumber(), reader.getCharacterOffset());
}
public QName getName() {
throw new IllegalStateException();
}
public String getLocalName() {
throw new IllegalStateException();
}
public String getNamespaceURI() {
throw new IllegalStateException();
}
public String getPrefix() {
throw new IllegalStateException();
}
public String getVersion() {
return null;
}
public String getCharacterEncodingScheme() {
return null;
}
public String getPITarget() {
return null;
}
public String getPIData() {
return null;
}
}
XIncludeXMLStreamReader.java 0000664 0000000 0000000 00000026753 13337777503 0033565 0 ustar 00root root 0000000 0000000 wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config /*
* JBoss, Home of Professional Open Source.
* Copyright 2015 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.client.config;
import static org.wildfly.client.config._private.ConfigMessages.msg;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException;
import java.util.NoSuchElementException;
import javax.xml.stream.XMLStreamException;
/**
* @author David M. Lloyd
*/
final class XIncludeXMLStreamReader extends AbstractDelegatingXMLStreamReader {
static final String XINCLUDE_NS = "http://www.w3.org/2001/XInclude";
private ConfigurationXMLStreamReader child;
XIncludeXMLStreamReader(final ConfigurationXMLStreamReader delegate) {
super(true, delegate);
}
private ConfigurationXMLStreamReader getRawDelegate() {
return super.getDelegate();
}
protected ConfigurationXMLStreamReader getDelegate() {
final ConfigurationXMLStreamReader child = this.child;
return child != null ? child : getRawDelegate();
}
public void skipContent() throws ConfigXMLParseException {
while (getDelegate().hasNext()) {
switch (getDelegate().next()) {
case START_ELEMENT: {
skipContent();
break;
}
case END_ELEMENT: {
return;
}
}
}
}
public int next() throws ConfigXMLParseException {
final ConfigurationXMLStreamReader child = this.child;
if (child != null) {
if (child.hasNext()) {
final int next = child.next();
if (next != END_DOCUMENT) {
return next;
} else {
child.close();
}
}
this.child = null;
}
final ConfigurationXMLStreamReader delegate = this.getDelegate();
if (! delegate.hasNext()) {
throw new NoSuchElementException();
}
int res;
for (;;) {
res = delegate.next();
if (res == START_ELEMENT) {
final String namespaceURI = delegate.getNamespaceURI();
if (XINCLUDE_NS.equals(namespaceURI)) {
switch (delegate.getLocalName()) {
case "include": {
ConfigurationXMLStreamReader nested = processInclude();
boolean ok = false;
try {
if (nested != null && nested.hasNext()) {
int eventType = nested.next();
if (eventType == START_DOCUMENT) {
if (! nested.hasNext()) {
// close nested and keep going
continue;
}
eventType = nested.next();
}
this.child = new XIncludeXMLStreamReader(nested);
ok = true;
return eventType;
} else {
// fallback to empty, discard nested content
ok = true;
continue;
}
} finally {
if (!ok) try {
nested.close();
} catch (ConfigXMLParseException ignored) {
}
}
}
default: {
throw msg.unexpectedElement(delegate.getLocalName(), namespaceURI, getLocation());
}
}
} else {
// some other boring element!
return res;
}
}
return res;
}
}
private ConfigurationXMLStreamReader processInclude() throws ConfigXMLParseException {
// save this for later
final ScopedXMLStreamReader includeElement = new ScopedXMLStreamReader(false, getRawDelegate());
final ConfigurationXMLStreamReader delegate = this.getDelegate();
final int attributeCount = delegate.getAttributeCount();
URI href = null;
Charset textCharset = StandardCharsets.UTF_8;
boolean fallback = false;
String accept = null;
String acceptLanguage = null;
boolean parseAsText = false;
for (int i = 0; i < attributeCount; i ++) {
if (delegate.getAttributeNamespace(i) == null) {
switch (delegate.getAttributeLocalName(i)) {
case "href": {
try {
href = new URI(delegate.getAttributeValue(i));
} catch (URISyntaxException e) {
throw new ConfigXMLParseException("Invalid include URI", getLocation(), e);
}
if (href.getFragment() != null) {
throw new ConfigXMLParseException("Invalid include URI: must not contain fragment identifier", getLocation());
}
fallback |= href.isOpaque();
break;
}
case "parse": {
switch (delegate.getAttributeValue(i)) {
case "xml": parseAsText = false; break;
case "text": parseAsText = true; break;
default: throw new ConfigXMLParseException("Invalid include directive: unknown parse type (must be \"text\" or \"xml\")", getLocation());
}
break;
}
case "xpointer": {
// no xpointer support
fallback = true;
break;
}
case "encoding": {
try {
textCharset = Charset.forName(delegate.getAttributeValue(i));
} catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
// bad charset
fallback = true;
break;
}
break;
}
case "accept": {
accept = delegate.getAttributeValue(i);
break;
}
case "accept-language": {
acceptLanguage = delegate.getAttributeValue(i);
break;
}
// ignore others
}
}
}
if (! fallback) {
if (href == null) {
throw delegate.missingRequiredAttribute(null, "href");
}
final URL url;
final InputStream inputStream;
ConfigurationXMLStreamReader child;
try {
if (! href.isAbsolute()) {
href = getRawDelegate().getUri().resolve(href);
}
url = href.toURL();
final URLConnection connection = url.openConnection();
connection.addRequestProperty("Accept", accept != null ? accept : parseAsText ? "text/plain,text/*" : "application/xml,text/xml,application/*+xml,text/*+xml");
if (acceptLanguage != null) connection.addRequestProperty("Accept-Language", acceptLanguage);
inputStream = connection.getInputStream();
try {
if (parseAsText) {
child = new TextXMLStreamReader(textCharset, inputStream, this, href);
} else {
child = new XIncludeXMLStreamReader(new BasicXMLStreamReader(getLocation(), getXmlInputFactory().createXMLStreamReader(inputStream), href, getXmlInputFactory(), inputStream));
}
} catch (XMLStreamException e) {
try {
inputStream.close();
} catch (Throwable e1) {
e.addSuppressed(e1);
}
throw ConfigXMLParseException.from(e, getUri(), getIncludedFrom());
} catch (Throwable t) {
try {
inputStream.close();
} catch (Throwable e1) {
t.addSuppressed(e1);
}
throw t;
}
} catch (IOException e) {
throw ConfigXMLParseException.from(e, getUri(), getIncludedFrom());
}
try {
// consume remaining content
getRawDelegate().skipContent();
return child;
} catch (Throwable t) {
try {
child.close();
} catch (Throwable t2) {
t.addSuppressed(t2);
}
throw t;
}
}
// fallback
// first, seek to first fallback element
while (super.hasNext()) {
switch (super.next()) {
case START_ELEMENT: {
if (XINCLUDE_NS.equals(super.getNamespaceURI()) && "fallback".equals(super.getLocalName())) {
return child = new ScopedXMLStreamReader(true, new DrainingXMLStreamReader(false, includeElement));
} else {
int level = 0;
out: while (super.hasNext()) {
switch (super.next()) {
case START_ELEMENT: {
level ++;
break;
}
case END_ELEMENT: {
if (level -- == 0) {
break out;
} else {
break;
}
}
}
}
}
break;
}
case END_ELEMENT: {
return null;
}
}
}
return null;
}
}
wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config/XMLLocation.java 0000664 0000000 0000000 00000027004 13337777503 0031370 0 ustar 00root root 0000000 0000000 /*
* JBoss, Home of Professional Open Source.
* Copyright 2015 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.client.config;
import static java.lang.Integer.signum;
import java.net.URI;
import javax.xml.stream.Location;
/**
* An XML location which is readable by humans and which understands XInclude.
*
* @author David M. Lloyd
*/
public final class XMLLocation implements Location, Comparable {
/**
* An unknown location.
*/
public static final XMLLocation UNKNOWN = new XMLLocation(null, -1, -1, -1);
private final XMLLocation includedFrom;
private final URI uri;
private final int lineNumber;
private final int columnNumber;
private final int characterOffset;
private final String publicId;
private final String systemId;
private int hashCode;
/**
* Construct a new instance.
*
* @param includedFrom the source location that this location was included from
* @param uri the source location (may be {@code null} if not known)
* @param lineNumber the line number (may be {@code -1} if not known)
* @param columnNumber the column number (may be {@code -1} if not known)
* @param characterOffset the character offset (may be {@code -1} if not known)
* @param publicId the XML public ID (may be {@code null})
* @param systemId the XML system ID (may be {@code null})
*/
public XMLLocation(final XMLLocation includedFrom, final URI uri, final int lineNumber, final int columnNumber, final int characterOffset, final String publicId, final String systemId) {
this.includedFrom = includedFrom;
this.uri = uri;
this.lineNumber = lineNumber;
this.columnNumber = columnNumber;
this.characterOffset = characterOffset;
this.publicId = publicId;
this.systemId = systemId;
}
/**
* Construct a new instance.
*
* @param uri the source location (may be {@code null} if not known)
* @param lineNumber the line number (may be {@code -1} if not known)
* @param columnNumber the column number (may be {@code -1} if not known)
* @param characterOffset the character offset (may be {@code -1} if not known)
* @param publicId the XML public ID (may be {@code null})
* @param systemId the XML system ID (may be {@code null})
*/
public XMLLocation(final URI uri, final int lineNumber, final int columnNumber, final int characterOffset, final String publicId, final String systemId) {
this(null, uri, lineNumber, columnNumber, characterOffset, null, null);
}
/**
* Construct a new instance.
*
* @param includedFrom the source location that this location was included from
* @param uri the source location (may be {@code null} if not known)
* @param lineNumber the line number (may be {@code -1} if not known)
* @param columnNumber the column number (may be {@code -1} if not known)
* @param characterOffset the character offset (may be {@code -1} if not known)
*/
public XMLLocation(final XMLLocation includedFrom, final URI uri, final int lineNumber, final int columnNumber, final int characterOffset) {
this(includedFrom, uri, lineNumber, columnNumber, characterOffset, null, null);
}
/**
* Construct a new instance.
*
* @param uri the source location (may be {@code null} if not known)
* @param lineNumber the line number (may be {@code -1} if not known)
* @param columnNumber the column number (may be {@code -1} if not known)
* @param characterOffset the character offset (may be {@code -1} if not known)
*/
public XMLLocation(final URI uri, final int lineNumber, final int columnNumber, final int characterOffset) {
this(uri, lineNumber, columnNumber, characterOffset, null, null);
}
/**
* Construct a new instance.
*
* @param uri the file name (may be {@code null} if this location does not correspond to a file)
*/
public XMLLocation(final URI uri) {
this(uri, -1, -1, -1);
}
/**
* Construct a new instance.
*
* @param uri the file name (may be {@code null} if this location does not correspond to a file)
* @param original the location to copy the remainder of the information from
*/
XMLLocation(final XMLLocation includedFrom, final URI uri, final Location original) {
this(includedFrom, uri, original.getLineNumber(), original.getColumnNumber(), original.getCharacterOffset(), original.getPublicId(), original.getSystemId());
}
/**
* Construct a new instance.
*
* @param uri the file name (may be {@code null} if this location does not correspond to a file)
* @param original the location to copy the remainder of the information from
*/
XMLLocation(final URI uri, final Location original) {
this(uri, original.getLineNumber(), original.getColumnNumber(), original.getCharacterOffset(), original.getPublicId(), original.getSystemId());
}
/**
* Construct a new instance.
*
* @param original the location to copy the remainder of the information from
*/
XMLLocation(final Location original) {
this(original instanceof XMLLocation ? ((XMLLocation)original).getUri() : null, original.getLineNumber(), original.getColumnNumber(), original.getCharacterOffset(), original.getPublicId(), original.getSystemId());
}
/**
* Get the file name. May be {@code null} if this location does not correspond to a file.
*
* @return the file name
*/
public URI getUri() {
return uri;
}
/**
* Get the line number where the corresponding event ends. Returns -1 if not known.
*
* @return the line number where the corresponding event ends
*/
public int getLineNumber() {
return lineNumber;
}
/**
* Get the column number where the corresponding event ends. Returns -1 if not known.
*
* @return the column number where the corresponding event ends
*/
public int getColumnNumber() {
return columnNumber;
}
/**
* Get the absolute character offset of this event. Returns -1 if not known.
*
* @return the absolute character offset of this event
*/
public int getCharacterOffset() {
return characterOffset;
}
/**
* Get the public ID of the XML. Returns {@code null} if not known.
*
* @return the public ID of the XML
*/
public String getPublicId() {
return publicId;
}
/**
* Get the system ID of the XML. Returns {@code null} if not known.
*
* @return the system ID of the XML
*/
public String getSystemId() {
return systemId;
}
/**
* Get the location that this location was included from. Returns {@code null} if this was the root document.
*
* @return the location that this location was included from, or {@code null}
*/
public XMLLocation getIncludedFrom() {
return includedFrom;
}
public static XMLLocation toXMLLocation(final Location location) {
return toXMLLocation((URI) null, location);
}
public static XMLLocation toXMLLocation(final URI uri, final Location location) {
if (location instanceof XMLLocation) {
return (XMLLocation) location;
} else if (location == null) {
return UNKNOWN;
} else {
return new XMLLocation(uri, location);
}
}
public static XMLLocation toXMLLocation(final XMLLocation includedFrom, final Location location) {
return toXMLLocation(includedFrom, null, location);
}
public static XMLLocation toXMLLocation(final XMLLocation includedFrom, final URI uri, final Location location) {
if (location instanceof XMLLocation) {
return (XMLLocation) location;
} else if (location == null) {
return UNKNOWN;
} else {
return new XMLLocation(includedFrom, uri, location);
}
}
public int hashCode() {
int result = hashCode;
if (result == 0) {
if (includedFrom != null) result = includedFrom.hashCode;
result = 31 * result + (uri != null ? uri.hashCode() : 0);
result = 31 * result + lineNumber;
result = 31 * result + columnNumber;
result = 31 * result + characterOffset;
result = 31 * result + (publicId != null ? publicId.hashCode() : 0);
result = 31 * result + (systemId != null ? systemId.hashCode() : 0);
if (result == 0) result = -1;
hashCode = result;
}
return result;
}
/**
* Determine whether this object is equal to another.
*
* @param other the other object
* @return {@code true} if they are equal, {@code false} otherwise
*/
public boolean equals(Object other) {
return other instanceof XMLLocation && equals((XMLLocation)other);
}
private static boolean equals(Object a, Object b) {
return a == b || a == null ? b == null : a.equals(b);
}
/**
* Determine whether this object is equal to another.
*
* @param other the other object
* @return {@code true} if they are equal, {@code false} otherwise
*/
public boolean equals(XMLLocation other) {
return this == other || other != null && equals(includedFrom, other.includedFrom) && equals(uri, other.uri) && lineNumber == other.lineNumber && columnNumber == other.columnNumber && characterOffset == other.characterOffset && equals(publicId, other.publicId) && equals(systemId, other.systemId);
}
/**
* Get the location as a string. The string will be suitable for immediately prefixing an error message.
*
* @return the location as a string
*/
public String toString() {
final StringBuilder b = new StringBuilder();
toString(b);
return b.toString();
}
private void toString(final StringBuilder b) {
b.append("\n\tat ").append(uri == null ? "" : uri);
if (lineNumber > 0) {
b.append(':').append(lineNumber);
if (columnNumber > 0) {
b.append(':').append(columnNumber);
}
}
if (includedFrom != null) {
includedFrom.toString(b);
}
}
private int compareUri(URI a, URI b) {
return a == null ? b == null ? 0 : 1 : b == null ? -1 : a.compareTo(b);
}
/**
* Compare for sort.
*
* @param o the other location
* @return the sort result (-1, 0, or 1)
*/
public int compareTo(final XMLLocation o) {
int c;
c = compareUri(uri, o.uri);
if (c == 0) {
c = signum(lineNumber - o.lineNumber);
if (c == 0) {
c = signum(columnNumber - o.columnNumber);
if (c == 0) {
c = signum(characterOffset - o.characterOffset);
}
}
}
return c;
}
}
wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config/_private/ 0000775 0000000 0000000 00000000000 13337777503 0030202 5 ustar 00root root 0000000 0000000 ConfigMessages.java 0000664 0000000 0000000 00000014760 13337777503 0033673 0 ustar 00root root 0000000 0000000 wildfly-client-config-1.0.1.Final/src/main/java/org/wildfly/client/config/_private /*
* JBoss, Home of Professional Open Source.
* Copyright 2015 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.client.config._private;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import javax.xml.namespace.QName;
import javax.xml.stream.Location;
import org.jboss.logging.Messages;
import org.jboss.logging.annotations.Cause;
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageBundle;
import org.jboss.logging.annotations.Param;
import org.wildfly.client.config.ConfigXMLParseException;
import org.wildfly.client.config.XMLLocation;
/**
* @author David M. Lloyd
*/
@MessageBundle(projectCode = "CONF", length = 4)
public interface ConfigMessages {
ConfigMessages msg = Messages.getBundle(ConfigMessages.class);
@Message(id = 1, value = "An unspecified XML parse error occurred")
String parseError();
@Message(id = 2, value = "Calling close() on XMLConfigurationReader is not supported")
UnsupportedOperationException closeNotSupported();
@Message(id = 3, value = "Unexpected end of document")
ConfigXMLParseException unexpectedDocumentEnd(@Param(Location.class) XMLLocation location);
@Message(id = 4, value = "Unexpected content of type \"%s\"")
ConfigXMLParseException unexpectedContent(String eventType, @Param(Location.class) XMLLocation location);
@Message(id = 5, value = "Unexpected element \"%s\" in namespace \"%s\" encountered")
ConfigXMLParseException unexpectedElement(String localName, String namespaceUri, @Param(Location.class) XMLLocation location);
@Message(id = 5, value = "Unexpected element \"%s\" (no namespace) encountered")
ConfigXMLParseException unexpectedElement(String localName, @Param(Location.class) XMLLocation location);
@Message(id = 6, value = "Expected start or end element, found \"%s\"")
ConfigXMLParseException expectedStartOrEndElement(String eventTypeName, @Param(Location.class) XMLLocation location);
@Message(id = 7, value = "Expected start element, found \"%s\"")
ConfigXMLParseException expectedStartElement(String eventTypeName, @Param(Location.class) XMLLocation location);
@Message(id = 8, value = "Text content cannot contain elements")
ConfigXMLParseException textCannotContainElements(@Param(Location.class) XMLLocation location);
@Message(id = 9, value = "Expected event type \"%s\", found \"%s\"")
ConfigXMLParseException expectedEventType(String expectedEventTypeName, String eventTypeName, @Param(Location.class) XMLLocation location);
@Message(id = 10, value = "Expected namespace URI \"%s\", found \"%s\"")
ConfigXMLParseException expectedNamespace(String expectedNamespaceURI, String actualNamespaceURI, @Param(Location.class) XMLLocation location);
@Message(id = 11, value = "Expected local name \"%s\", found \"%s\"")
ConfigXMLParseException expectedLocalName(String expectedLocalName, String actualLocalName, @Param(Location.class) XMLLocation location);
@Message(id = 12, value = "Failed to read from input source")
ConfigXMLParseException failedToReadInput(@Param(Location.class) XMLLocation location, @Cause IOException cause);
@Message(id = 13, value = "Failed to close input source")
ConfigXMLParseException failedToCloseInput(@Param(Location.class) XMLLocation location, @Cause IOException cause);
@Message(id = 14, value = "Invalid configuration file URL")
ConfigXMLParseException invalidUrl(@Param(Location.class) XMLLocation location, @Cause MalformedURLException e);
@Message(id = 15, value = "Unexpected attribute \"%s\" encountered")
ConfigXMLParseException unexpectedAttribute(QName name, @Param(Location.class) XMLLocation location);
@Message(id = 16, value = "Missing required element \"%2$s\" from namespace \"%s\"")
ConfigXMLParseException missingRequiredElement(String namespaceUri, String localName, @Param(Location.class) XMLLocation location);
@Message(id = 17, value = "Missing required attribute \"%2$s\" from namespace \"%s\"")
ConfigXMLParseException missingRequiredAttribute(String namespaceUri, String localName, @Param(Location.class) XMLLocation location);
@Message(id = 18, value = "Failed to parse integer value of attribute \"%s\"")
ConfigXMLParseException intParseException(@Cause NumberFormatException e, QName attributeName, @Param(Location.class) XMLLocation location);
@Message(id = 19, value = "Failed to parse URI value of attribute \"%s\"")
ConfigXMLParseException uriParseException(@Cause URISyntaxException e, QName attributeName, @Param(Location.class) XMLLocation location);
@Message(id = 20, value = "Failed to parse expression value of attribute \"%s\"")
ConfigXMLParseException expressionParseException(@Cause IllegalArgumentException ex, QName attributeName, @Param(Location.class) XMLLocation location);
@Message(id = 21, value = "Failed to parse expression text")
ConfigXMLParseException expressionTextParseException(@Cause IllegalArgumentException ex, @Param(Location.class) XMLLocation location);
@Message(id = 22, value = "Numeric value of attribute \"%s\" is out of range; actual value is \"%s\" but the value must not be less than %d or more than %d")
ConfigXMLParseException numericAttributeValueOutOfRange(QName attributeName, String actualValue, long minValue, long maxValue, @Param(Location.class) XMLLocation location);
@Message(id = 23, value = "Failed to parse IP address value of attribute \"%s\": \"%s\" is not a valid IP address")
ConfigXMLParseException inetAddressParseException(QName attributeName, String address, @Param(Location.class) XMLLocation location);
@Message(id = 24, value = "Failed to parse CIDR address value of attribute \"%s\": \"%s\" is not a valid CIDR address")
ConfigXMLParseException cidrAddressParseException(QName attributeName, String address, @Param(Location.class) XMLLocation location);
}
wildfly-client-config-1.0.1.Final/src/main/resources/ 0000775 0000000 0000000 00000000000 13337777503 0022476 5 ustar 00root root 0000000 0000000 wildfly-client-config-1.0.1.Final/src/main/resources/schema/ 0000775 0000000 0000000 00000000000 13337777503 0023736 5 ustar 00root root 0000000 0000000 wildfly-client-config-1.0.1.Final/src/main/resources/schema/wildfly-client_1_0.xsd 0000664 0000000 0000000 00000002371 13337777503 0030046 0 ustar 00root root 0000000 0000000