javax.xml.stream.Location Java Examples
The following examples show how to use
javax.xml.stream.Location.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StreamBootstrapper.java From woodstox with Apache License 2.0 | 6 votes |
@Override protected Location getLocation() { /* Ok; for fixed-size multi-byte encodings, need to divide numbers * to get character locations. For variable-length encodings the * good thing is that xml declaration only uses shortest codepoints, * ie. char count == byte count. */ int total = mInputProcessed + mInputPtr; int col = mInputPtr - mInputRowStart; if (mBytesPerChar > 1) { total /= mBytesPerChar; col /= mBytesPerChar; } return new WstxInputLocation(null, mPublicId, mSystemId, total - 1, // 0-based mInputRow, col); }
Example #2
Source File: WstxSAXParser.java From woodstox with Apache License 2.0 | 5 votes |
@Override public String getSystemId() { if (mScanner != null) { Location loc = mScanner.getLocation(); return loc.getSystemId(); } return null; }
Example #3
Source File: TestTreatCharRefAsEnts.java From woodstox with Apache License 2.0 | 5 votes |
public void testReturnEntityForCharReference() throws Exception { String XML = "<root>text & more</root>"; BasicStreamReader sr = getReader(XML, true, true, 1); assertTokenType(START_ELEMENT, sr.next()); assertEquals("root", sr.getLocalName()); assertTokenType(CHARACTERS, sr.next()); assertEquals("text ", sr.getText()); assertTokenType(ENTITY_REFERENCE, sr.next()); assertEquals("amp", sr.getLocalName()); EntityDecl ed = sr.getCurrentEntityDecl(); assertNotNull(ed); assertEquals("amp", ed.getName()); assertEquals("&", ed.getReplacementText()); // The pure stax way: assertEquals("&", sr.getText()); // Finally, let's see that location info is about right? Location loc = sr.getCurrentLocation(); assertNotNull(loc); assertEquals(16, loc.getCharacterOffset()); }
Example #4
Source File: WstxSAXParser.java From woodstox with Apache License 2.0 | 5 votes |
@Override public int getColumnNumber() { if (mScanner != null) { Location loc = mScanner.getLocation(); return loc.getColumnNumber(); } return -1; }
Example #5
Source File: EdFiParserProcessorTest.java From secure-data-service with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Test public void testReferenceMap() throws Exception { init(); //helper.setMapFile( "deleteHelper/referenceExceptionMap.json" ); ActionVerb action = ActionVerb.DELETE; RecordMetaImpl meta = new RecordMetaImpl("GradeReference", "GradeReference", false, action); Location loc = Mockito.mock(Location.class); Mockito.when(loc.getLineNumber()).thenReturn(1); Mockito.when(loc.getColumnNumber()).thenReturn(1); meta.setSourceStartLocation(loc); meta.setSourceEndLocation(loc); /* * building GradeReference */ Map<String, Object> att = new HashMap<String, Object>(); att.put("StudentReference",new HashMap<String, Object>()); (( Map<String,Object>)att.get("StudentReference")).put( "StudentIdenity", new HashMap<String, Object>()); (( Map<String,Object>)(( Map<String,Object>)att.get("StudentReference")).get("StudentIdenity")). put("StudentUniqueStateId", "G-800000025"); att.put("SectionReference",new HashMap<String, Object>()); (( Map<String,Object>)att.get("SectionReference")).put( "EducationalOrgIdentity", new HashMap<String, Object>()); (( Map<String,Object>)(( Map<String,Object>)att.get("SectionReference")).get("EducationalOrgIdentity")). put("StateOrganizationId", "Daybreak Central High"); att.put("SchoolYear", "2011-2012"); Assert.assertFalse(att.containsKey("StudentSectionAssociationReference")); helper.mapAttributes(att, "GradeReference"); Assert.assertTrue(att.containsKey("StudentSectionAssociationReference")); Assert.assertTrue(att.get("StudentSectionAssociationReference") instanceof Map ); Assert.assertTrue( ((Map<String,Object>)att.get("StudentSectionAssociationReference")). containsKey("StudentSectionAssociationIdentity")); }
Example #6
Source File: FailureLocation.java From cxf with Apache License 2.0 | 5 votes |
public FailureLocation(Location loc, String docURI) { this.location = loc; this.documentURI = docURI; if (documentURI == null) { documentURI = loc.getSystemId(); } }
Example #7
Source File: InputElementStack.java From woodstox with Apache License 2.0 | 5 votes |
/** * Method called to construct a non-transient NamespaceContext instance; * generally needed when creating events to return from event-based * iterators. */ public BaseNsContext createNonTransientNsContext(Location loc) { // Have an instance we can reuse? Great! if (mLastNsContext != null) { return mLastNsContext; } // No namespaces declared at this point? Easy, as well: int totalNsSize = mNamespaces.size(); if (totalNsSize < 1) { return (mLastNsContext = EmptyNamespaceContext.getInstance()); } // Otherwise, we need to create a new non-empty context: int localCount = getCurrentNsCount() << 1; BaseNsContext nsCtxt = new CompactNsContext (loc, /*getDefaultNsURI(),*/ mNamespaces.asArray(), totalNsSize, totalNsSize - localCount); /* And it can be shared if there are no new ('local', ie. included * within this start element) bindings -- if there are, underlying * array might be shareable, but offsets wouldn't be) */ if (localCount == 0) { mLastNsContext = nsCtxt; } return nsCtxt; }
Example #8
Source File: WSDLParserExtensionFacade.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private Locator getLocator(XMLStreamReader reader) { Location location = reader.getLocation(); LocatorImpl loc = new LocatorImpl(); loc.setSystemId(location.getSystemId()); loc.setLineNumber(location.getLineNumber()); return loc; }
Example #9
Source File: LocatableWebServiceException.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static Locator toLocation(XMLStreamReader xsr) { LocatorImpl loc = new LocatorImpl(); Location in = xsr.getLocation(); loc.setSystemId(in.getSystemId()); loc.setPublicId(in.getPublicId()); loc.setLineNumber(in.getLineNumber()); loc.setColumnNumber(in.getColumnNumber()); return loc; }
Example #10
Source File: JBossAllXMLElementReader.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void readElement(final XMLExtendedStreamReader xmlExtendedStreamReader, final JBossAllXmlParseContext jBossXmlParseContext) throws XMLStreamException { final Location nsLocation = xmlExtendedStreamReader.getLocation(); final QName elementName = xmlExtendedStreamReader.getName(); final Object result = parserDescription.getParser().parse(xmlExtendedStreamReader, jBossXmlParseContext.getDeploymentUnit()); jBossXmlParseContext.addResult(elementName, result, nsLocation); }
Example #11
Source File: StartDocumentEvent.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
protected void init(String encoding, String version, boolean standalone,Location loc) { setEventType(XMLStreamConstants.START_DOCUMENT); this.fEncodingScheam = encoding; this.fVersion = version; this.fStandalone = standalone; if (encoding != null && !encoding.equals("")) this.fEncodingSchemeSet = true; else { this.fEncodingSchemeSet = false; this.fEncodingScheam = "UTF-8"; } this.fLocation = loc; }
Example #12
Source File: WSDLParserExtensionFacade.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private Locator getLocator(XMLStreamReader reader) { Location location = reader.getLocation(); LocatorImpl loc = new LocatorImpl(); loc.setSystemId(location.getSystemId()); loc.setLineNumber(location.getLineNumber()); return loc; }
Example #13
Source File: CompactNsContext.java From woodstox with Apache License 2.0 | 5 votes |
public CompactNsContext(Location loc, String[] namespaces, int nsLen, int firstLocal) { mLocation = loc; mNamespaces = namespaces; mNsLength = nsLen; mFirstLocalNs = firstLocal; }
Example #14
Source File: DummyEvent.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
void setLocation(Location loc){ if (loc == null) { fLocation = nowhere; } else { fLocation = loc; } }
Example #15
Source File: SAX2StAXBaseWriter.java From JDKSourceCode1.8 with MIT License | 5 votes |
public Location getCurrentLocation() { if (docLocator != null) { return new SAXLocation(docLocator); } else { return null; } }
Example #16
Source File: StandaloneDeploymentUnicityTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testIncorrectDeployments() throws Exception { try { createKernelServicesBuilder(TestModelType.STANDALONE) .setXmlResource("standalone_duplicate.xml") .createContentRepositoryContent("12345678901234567890") .build(); } catch (XMLStreamException ex) { String expectedMessage = ControllerLogger.ROOT_LOGGER.duplicateNamedElement("abc.war", new Location() { public int getLineNumber() { return 287; } public int getColumnNumber() { return 1; } public int getCharacterOffset() { return 1; } public String getPublicId() { return ""; } public String getSystemId() { return ""; } }).getMessage(); expectedMessage = expectedMessage.substring(expectedMessage.indexOf("WFLYCTL0073:")); Assert.assertThat(ex.getMessage(), containsString(expectedMessage)); } }
Example #17
Source File: XMLStreamException2.java From hottub with GNU General Public License v2.0 | 4 votes |
public XMLStreamException2(String msg, Location location) { super(msg, location); }
Example #18
Source File: StAXLocationWrapper.java From JDKSourceCode1.8 with MIT License | 4 votes |
public void setLocation(Location location) { fLocation = location; }
Example #19
Source File: XMLReaderComposite.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Override public Location getLocation() { switch (state) { case StartTag: case EndTag: return new Location() { @Override public int getLineNumber() { // TODO Auto-generated method stub return 0; } @Override public int getColumnNumber() { // TODO Auto-generated method stub return 0; } @Override public int getCharacterOffset() { // TODO Auto-generated method stub return 0; } @Override public String getPublicId() { // TODO Auto-generated method stub return null; } @Override public String getSystemId() { // TODO Auto-generated method stub return null; } }; case Payload: default: return payloadReader.getLocation(); } }
Example #20
Source File: BpmnXMLUtil.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public static void addXMLLocation(BaseElement element, XMLStreamReader xtr) { Location location = xtr.getLocation(); element.setXmlRowNumber(location.getLineNumber()); element.setXmlColumnNumber(location.getColumnNumber()); }
Example #21
Source File: StreamReaderDelegate.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public Location getLocation() { return reader.getLocation(); }
Example #22
Source File: StartDocumentEvent.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public StartDocumentEvent(String encoding, String version, boolean standalone,Location loc){ this.fStandaloneSet = true; init(encoding, version, standalone, loc); }
Example #23
Source File: StaxXmlPullParser.java From Smack with Apache License 2.0 | 4 votes |
@Override public int getColumnNumber() { Location location = xmlStreamReader.getLocation(); return location.getColumnNumber(); }
Example #24
Source File: DTDValidatorBase.java From woodstox with Apache License 2.0 | 4 votes |
Location getLocation() { return mContext.getValidationLocation(); }
Example #25
Source File: StaEDISchemaReadException.java From staedi with Apache License 2.0 | 4 votes |
public StaEDISchemaReadException(String message, Location location, Throwable cause) { super(message, cause); this.location = location; }
Example #26
Source File: DataReader.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Reads a bean from the given xml stream reader. * * @param xmlReader The reader */ private void readBean(XMLStreamReader xmlReader) throws XMLStreamException, DdlUtilsXMLException { QName elemQName = xmlReader.getName(); Location location = xmlReader.getLocation(); Map attributes = new HashMap(); String tableName = null; for (int idx = 0; idx < xmlReader.getAttributeCount(); idx++) { QName attrQName = xmlReader.getAttributeName(idx); attributes.put(isCaseSensitive() ? attrQName.getLocalPart() : attrQName.getLocalPart().toLowerCase(), xmlReader.getAttributeValue(idx)); } readColumnSubElements(xmlReader, attributes); if ("table".equals(elemQName.getLocalPart())) { tableName = (String)attributes.get("table-name"); } else { tableName = elemQName.getLocalPart(); } Table table = _model.findTable(tableName, isCaseSensitive()); if (table == null) { _log.warn("Data XML contains an element " + elemQName + " at location " + location + " but there is no table defined with this name. This element will be ignored."); } else { DynaBean bean = _model.createDynaBeanFor(table); for (int idx = 0; idx < table.getColumnCount(); idx++) { Column column = table.getColumn(idx); String value = (String)attributes.get(isCaseSensitive() ? column.getName() : column.getName().toLowerCase()); if (value != null) { setColumnValue(bean, table, column, value); } } getSink().addBean(bean); consumeRestOfElement(xmlReader); } }
Example #27
Source File: DummyEvent.java From Bytecoder with Apache License 2.0 | 4 votes |
public Location getLocation(){ return fLocation; }
Example #28
Source File: ThreadsLogger.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Message(id = 27, value = "%s must be greater than or equal to zero") XMLStreamException countMustBePositive(Attribute count, @Param Location location);
Example #29
Source File: ControllerLogger.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Message(id = 377, value = "Unexpected element '%s' encountered. Valid elements are: '%s'") XMLStreamException unexpectedElement(QName name, StringBuilder possible, @Param Location location);
Example #30
Source File: EdFiEntity.java From secure-data-service with Apache License 2.0 | 4 votes |
public EdFiEntity(Location location, Object entity) { this.lineNumber = location.getLineNumber(); this.columnNumber = location.getColumnNumber(); this.entity = entity; }