本文整理匯總了Java中org.xml.sax.helpers.LocatorImpl類的典型用法代碼示例。如果您正苦於以下問題:Java LocatorImpl類的具體用法?Java LocatorImpl怎麽用?Java LocatorImpl使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LocatorImpl類屬於org.xml.sax.helpers包,在下文中一共展示了LocatorImpl類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testSetDocumentLocator
import org.xml.sax.helpers.LocatorImpl; //導入依賴的package包/類
@TestTargetNew(
level = TestLevel.COMPLETE,
method = "setDocumentLocator",
args = { Locator.class }
)
public void testSetDocumentLocator() {
Locator l = new LocatorImpl();
adapter.setDocumentLocator(l);
assertEquals(logger.size(), 1);
assertEquals("setDocumentLocator", logger.getMethod());
assertEquals(new Object[] { l }, logger.getArgs());
adapter.setDocumentLocator(null);
assertEquals(logger.size(), 2);
assertEquals("setDocumentLocator", logger.getMethod());
assertEquals(new Object[] { null }, logger.getArgs());
}
示例2: testSetSystemIdGetSystemId
import org.xml.sax.helpers.LocatorImpl; //導入依賴的package包/類
@TestTargets({
@TestTargetNew(
level = TestLevel.COMPLETE,
method = "setSystemId",
args = { String.class }
),
@TestTargetNew(
level = TestLevel.COMPLETE,
method = "getSystemId",
args = { }
)
})
public void testSetSystemIdGetSystemId() {
LocatorImpl l = new LocatorImpl();
l.setSystemId(SYS);
assertEquals(SYS, l.getSystemId());
l.setSystemId(null);
assertEquals(null, l.getSystemId());
}
示例3: createInstance
import org.xml.sax.helpers.LocatorImpl; //導入依賴的package包/類
public BeanT createInstance(UnmarshallingContext context) throws IllegalAccessException, InvocationTargetException, InstantiationException, SAXException {
BeanT bean = null;
if (factoryMethod == null){
bean = ClassFactory.create0(jaxbType);
}else {
Object o = ClassFactory.create(factoryMethod);
if( jaxbType.isInstance(o) ){
bean = (BeanT)o;
} else {
throw new InstantiationException("The factory method didn't return a correct object");
}
}
if(xmlLocatorField!=null)
// need to copy because Locator is mutable
try {
xmlLocatorField.set(bean,new LocatorImpl(context.getLocator()));
} catch (AccessorException e) {
context.handleError(e);
}
return bean;
}
示例4: parseBindings
import org.xml.sax.helpers.LocatorImpl; //導入依賴的package包/類
/**
* Exposing it as a public method to allow external tools such as NB to read from wsdl model and work on it.
* TODO: WSDL model needs to be exposed - basically at tool time we need to use the runtimw wsdl model
*
* Binding files could be jaxws or jaxb. This method identifies jaxws and jaxb binding files and keeps them separately. jaxb binding files are given separately
* to JAXB in {@link com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder}
*
* @param receiver {@link ErrorReceiver}
*/
public final void parseBindings(ErrorReceiver receiver){
for (InputSource is : bindingFiles) {
XMLStreamReader reader =
XMLStreamReaderFactory.create(is,true);
XMLStreamReaderUtil.nextElementContent(reader);
if (reader.getName().equals(JAXWSBindingsConstants.JAXWS_BINDINGS)) {
jaxwsCustomBindings.add(new RereadInputSource(is));
} else if (reader.getName().equals(JAXWSBindingsConstants.JAXB_BINDINGS) ||
reader.getName().equals(new QName(SchemaConstants.NS_XSD, "schema"))) {
jaxbCustomBindings.add(new RereadInputSource(is));
} else {
LocatorImpl locator = new LocatorImpl();
locator.setSystemId(reader.getLocation().getSystemId());
locator.setPublicId(reader.getLocation().getPublicId());
locator.setLineNumber(reader.getLocation().getLineNumber());
locator.setColumnNumber(reader.getLocation().getColumnNumber());
receiver.warning(locator, ConfigurationMessages.CONFIGURATION_NOT_BINDING_FILE(is.getSystemId()));
}
}
}
示例5: parseSchema
import org.xml.sax.helpers.LocatorImpl; //導入依賴的package包/類
public void parseSchema( String systemId, Element element ) {
checkAbsoluteness(systemId);
try {
DOMScanner scanner = new DOMScanner();
// use a locator that sets the system ID correctly
// so that we can resolve relative URLs in most of the case.
// it still doesn't handle xml:base and XInclude and all those things
// correctly. There's just no way to make all those things work with DOM!
LocatorImpl loc = new LocatorImpl();
loc.setSystemId(systemId);
scanner.setLocator(loc);
scanner.setContentHandler(getParserHandler(systemId));
scanner.scan(element);
} catch (SAXException e) {
// since parsing DOM shouldn't cause a SAX exception
// and our handler will never throw it, it's not clear
// if this will ever happen.
fatalError(new SAXParseException2(
e.getMessage(), null, systemId,-1,-1, e));
}
}
示例6: ResultImpl
import org.xml.sax.helpers.LocatorImpl; //導入依賴的package包/類
ResultImpl() {
try {
DocumentBuilderFactory factory = XmlFactory.createDocumentBuilderFactory(false); // safe - only used for BI
s2d = new SAX2DOMEx(factory);
} catch (ParserConfigurationException e) {
throw new AssertionError(e); // impossible
}
XMLFilterImpl f = new XMLFilterImpl() {
@Override
public void setDocumentLocator(Locator locator) {
super.setDocumentLocator(locator);
location = new LocatorImpl(locator);
}
};
f.setContentHandler(s2d);
setHandler(f);
}
示例7: convertToSAXParseException
import org.xml.sax.helpers.LocatorImpl; //導入依賴的package包/類
static void convertToSAXParseException(XMLParseException e) throws SAXException {
Exception ex = e.getException();
if (ex == null) {
// must be a parser exception; mine it for locator info and throw
// a SAXParseException
LocatorImpl locatorImpl = new LocatorImpl();
locatorImpl.setPublicId(e.getPublicId());
locatorImpl.setSystemId(e.getExpandedSystemId());
locatorImpl.setLineNumber(e.getLineNumber());
locatorImpl.setColumnNumber(e.getColumnNumber());
throw new SAXParseException(e.getMessage(), locatorImpl);
}
if (ex instanceof SAXException) {
// why did we create an XMLParseException?
throw (SAXException) ex;
}
throw new SAXException(ex);
}
示例8: toLocation
import org.xml.sax.helpers.LocatorImpl; //導入依賴的package包/類
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;
}
示例9: startTagPairs
import org.xml.sax.helpers.LocatorImpl; //導入依賴的package包/類
@DataProvider(name = "startTagPairs")
Object[][] startTagPairs() {
final Name foo = new Name("", "foo");
final Name bar = new Name("", "bar");
Set<Name> nameSet = new HashSet<Name>();
nameSet.add(foo);
nameSet.add(bar);
final NormalizedNameClass foobarNNC = new NormalizedNsNameClass(nameSet, EMPTY_MAP);
final Locator loc = new LocatorImpl();
return new Object[][] {
{ rootMatcher(makeChoice(makeElement(new SimpleNameClass(foo), makeEmpty(), loc),
makeElement(new SimpleNameClass(bar), makeEmpty(), loc))),
foobarNNC }
};
}
示例10: attributePairs
import org.xml.sax.helpers.LocatorImpl; //導入依賴的package包/類
@DataProvider(name = "attributePairs")
Object[][] attributePairs() {
final Name foo = new Name("", "foo");
final Name bar = new Name("", "bar");
Set<Name> nameSet = new HashSet<Name>();
nameSet.add(foo);
nameSet.add(bar);
final NormalizedNameClass foobarNNC = new NormalizedNsNameClass(nameSet, EMPTY_MAP);
final Locator loc = new LocatorImpl();
return new Object[][] {
{ rootAttributeMatcher(makeElement(new SimpleNameClass(root),
makeGroup(makeAttribute(new SimpleNameClass(foo), makeText(), loc),
makeAttribute(new SimpleNameClass(bar), makeText(), loc)),
loc)),
foobarNNC }
};
}
示例11: hasTextField
import org.xml.sax.helpers.LocatorImpl; //導入依賴的package包/類
private int hasTextField(LocatorImpl locator, String[] parts, int partIndex, NonTextAttributeTreatment nonTextAttributeTreatment) {
while (partIndex < parts.length) {
String field = parts[partIndex];
if (field.length() == 0) {
return -1;
} else {
int[] delims = countTextAttributeDelimiters(field);
if (inTextAttribute) {
if ((delims[1] > 0) && (delims[0] < delims[1]))
inTextAttribute = false;
return partIndex;
} else if (isTextField(locator, field, partIndex, nonTextAttributeTreatment)) {
return partIndex;
} else if ((delims[0] > 0) && (delims[0] > delims[1])) {
inTextAttribute = true;
return partIndex;
} else
return -1;
}
}
return -1;
}
示例12: createInstance
import org.xml.sax.helpers.LocatorImpl; //導入依賴的package包/類
public BeanT createInstance(UnmarshallingContext context) throws IllegalAccessException, InvocationTargetException, InstantiationException, SAXException {
BeanT bean = null;
if (factoryMethod == null){
bean = ClassFactory.create0(jaxbType);
}else {
Object o = ClassFactory.create(factoryMethod);
if( jaxbType.isInstance(o) ){
bean = (BeanT)o;
} else {
throw new InstantiationException("The factory method didn't return a correct object");
}
}
if(xmlLocatorField!=null)
// need to copy because Locator is mutable
try {
xmlLocatorField.set(bean,new LocatorImpl(context.getLocator()));
} catch (AccessorException e) {
context.handleError(e);
}
return bean;
}
示例13: testSetDocumentLocator
import org.xml.sax.helpers.LocatorImpl; //導入依賴的package包/類
@TestTargetNew(
level = TestLevel.COMPLETE,
method = "setDocumentLocator",
args = { Locator.class }
)
public void testSetDocumentLocator() {
Locator l = new LocatorImpl();
child.setDocumentLocator(l);
assertEquals(logger.size(), 1);
assertEquals("setDocumentLocator", logger.getMethod());
assertEquals(new Object[] { l }, logger.getArgs());
child.setDocumentLocator(null);
assertEquals(logger.size(), 2);
assertEquals("setDocumentLocator", logger.getMethod());
assertEquals(new Object[] { null }, logger.getArgs());
}
示例14: testSetPublicIdGetPublicId
import org.xml.sax.helpers.LocatorImpl; //導入依賴的package包/類
@TestTargets({
@TestTargetNew(
level = TestLevel.COMPLETE,
method = "setPublicId",
args = { String.class }
),
@TestTargetNew(
level = TestLevel.COMPLETE,
method = "getPublicId",
args = { }
)
})
public void testSetPublicIdGetPublicId() {
LocatorImpl l = new LocatorImpl();
l.setPublicId(PUB);
assertEquals(PUB, l.getPublicId());
l.setPublicId(null);
assertEquals(null, l.getPublicId());
}
示例15: testSetLineNumberGetLineNumber
import org.xml.sax.helpers.LocatorImpl; //導入依賴的package包/類
@TestTargets({
@TestTargetNew(
level = TestLevel.COMPLETE,
method = "setLineNumber",
args = { int.class }
),
@TestTargetNew(
level = TestLevel.COMPLETE,
method = "getLineNumber",
args = { }
)
})
public void testSetLineNumberGetLineNumber() {
LocatorImpl l = new LocatorImpl();
l.setLineNumber(ROW);
assertEquals(ROW, l.getLineNumber());
l.setLineNumber(0);
assertEquals(0, l.getLineNumber());
}