Package javax.xml.stream

Examples of javax.xml.stream.Location


    public Location getStreamLocation()
    {
        // Let's try to get actual exact location via Stax2 first:
        LocationInfo li = mStreamReader.getLocationInfo();
        if (li != null) {
            Location loc = li.getCurrentLocation();
            if (loc != null) {
                return loc;
            }
        }
        // If not, fall back to regular method
View Full Code Here


    }
    private static boolean addLocation(Document doc, Node node,
                                    XMLStreamReader reader,
                                    boolean recordLoc) {
        if (recordLoc) {
            Location loc = reader.getLocation();
            if (loc != null && (loc.getColumnNumber() != 0 || loc.getLineNumber() != 0)) {
                try {
                    final int charOffset = loc.getCharacterOffset();
                    final int colNum = loc.getColumnNumber();
                    final int linNum = loc.getLineNumber();
                    final String pubId = loc.getPublicId() == null ? doc.getDocumentURI() : loc.getPublicId();
                    final String sysId = loc.getSystemId() == null ? doc.getDocumentURI() : loc.getSystemId();
                    Location loc2 = new Location() {
                        public int getCharacterOffset() {
                            return charOffset;
                        }
                        public int getColumnNumber() {
                            return colNum;
View Full Code Here

            this.systemId = systemId;
        }

        @Override
        public Location getLocation() {
            final Location parentLocation = getParent().getLocation();
            return new Location() {
                public int getLineNumber() {
                    return parentLocation != null ? parentLocation.getLineNumber() : -1;
                }

                public int getColumnNumber() {
                    return parentLocation != null ? parentLocation.getColumnNumber() : -1;
                }

                public int getCharacterOffset() {
                    return parentLocation != null ? parentLocation.getLineNumber() : -1;
                }

                public String getPublicId() {
                    return parentLocation != null ? parentLocation.getPublicId() : null;
                }

                public String getSystemId() {
                    return systemId;
                }
View Full Code Here

            }
            return resource;
        }
        catch (Exception e)
        {
            Location loc = reader.getLocation();
            if (loc != null) {
                throw new Exception("Error while parsing resource " + resource.getId() + " at line " + loc.getLineNumber() + " and column " + loc.getColumnNumber(), e);
            }
            else
            {
                throw new Exception("Error while parsing resource " + resource.getId(), e);
            }
View Full Code Here

        return currentEvent == CHARACTERS || currentEvent == DTD || currentEvent == ENTITY_REFERENCE
                || currentEvent == COMMENT || currentEvent == SPACE;
    }

    public Location getLocation() {
        return new Location() {

            public int getCharacterOffset() {
                return 0;
            }
View Full Code Here

        while (reader.nextTag() != END_ELEMENT) {
            final Element element = Element.forName(reader.getLocalName());
            if (!encountered.add(element)) {
                throw unexpectedElement(reader);
            }
            final Location location = reader.getLocation();
            requiredElem.remove(element);
            switch (element) {
                case LEVEL: {
                    LEVEL.parseAndSetParameter(readStringAttributeElement(reader, "name"), node, location);
                    break;
View Full Code Here

            final Element element = Element.forName(reader.getLocalName());
            if (!encountered.add(element)) {
                throw unexpectedElement(reader);
            }
            requiredElem.remove(element);
            final Location location = reader.getLocation();
            switch (element) {
                case LEVEL: {
                    LEVEL.parseAndSetParameter(readStringAttributeElement(reader, "name"), node, location);
                    break;
                }
View Full Code Here

        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            switch (Namespace.forUri(reader.getNamespaceURI())) {
                case LOGGING_1_0:
                case LOGGING_1_1: {
                    final Element element = Element.forName(reader.getLocalName());
                    final Location location = reader.getLocation();
                    switch (element) {
                        case ACCEPT: {
                            ACCEPT.parseAndSetParameter(Boolean.TRUE.toString(), node, location);
                            requireNoContent(reader);
                            break;
View Full Code Here

        node.get(OP_ADDR).set(address).add(LOGGER, name);

        // Element
        final EnumSet<Element> encountered = EnumSet.noneOf(Element.class);
        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            final Location location = reader.getLocation();
            switch (Namespace.forUri(reader.getNamespaceURI())) {
                case LOGGING_1_0:
                case LOGGING_1_1: {
                    final Element element = Element.forName(reader.getLocalName());
                    if (!encountered.add(element)) {
View Full Code Here

        while (reader.nextTag() != END_ELEMENT) {
            final Element element = Element.forName(reader.getLocalName());
            if (!encountered.add(element)) {
                throw unexpectedElement(reader);
            }
            final Location location = reader.getLocation();
            switch (element) {
                case LEVEL: {
                    LEVEL.parseAndSetParameter(readStringAttributeElement(reader, "name"), node, location);
                    break;
                }
View Full Code Here

TOP

Related Classes of javax.xml.stream.Location

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.