本文整理汇总了Java中javax.xml.stream.events.ProcessingInstruction类的典型用法代码示例。如果您正苦于以下问题:Java ProcessingInstruction类的具体用法?Java ProcessingInstruction怎么用?Java ProcessingInstruction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProcessingInstruction类属于javax.xml.stream.events包,在下文中一共展示了ProcessingInstruction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
/**
* Parses an {@link ProcessingInstruction XML event} of a
* processing instruction.
* @param pi the event to parse
* @return the data from the processing instruction or <code>null</code>
* if the event is {@link #isIgnoredPI(ProcessingInstruction) ignored}
* by this parser
*/
public TocPIData parse(ProcessingInstruction pi) throws JAXBException
{
if (isIgnoredPI(pi))
return null;
String rawData = pi.getData();
rawData = null == rawData ? "" : rawData.trim();
boolean closing = rawData.endsWith("/");
if (closing)
rawData = rawData.substring(0, rawData.length() - 1).trim();
TocPIData data;
if (0 < rawData.length())
data = parseAttrs(rawData);
else if (closing)
data = new TocPIData();
else
throw new JAXBException("Processing instruction contains no data");
data.setClosing(closing);
return data;
}
示例2: handlePI
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
private void handlePI(ProcessingInstruction event)
throws XMLStreamException {
try {
_sax.processingInstruction(
event.getTarget(),
event.getData());
} catch (SAXException e) {
throw new XMLStreamException(e);
}
}
示例3: getPITarget
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
@Override
public String getPITarget() {
if (this.event.isProcessingInstruction()) {
return ((ProcessingInstruction) this.event).getTarget();
}
else {
throw new IllegalStateException();
}
}
示例4: getPIData
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
@Override
public String getPIData() {
if (this.event.isProcessingInstruction()) {
return ((ProcessingInstruction) this.event).getData();
}
else {
throw new IllegalStateException();
}
}
示例5: getPITarget
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
@Override
public String getPITarget() {
XMLSecEvent xmlSecEvent = getCurrentEvent();
if (xmlSecEvent.getEventType() != PROCESSING_INSTRUCTION) {
throw new IllegalStateException(ERR_STATE_NOT_PI);
}
return ((ProcessingInstruction) xmlSecEvent).getTarget();
}
示例6: getPIData
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
@Override
public String getPIData() {
XMLSecEvent xmlSecEvent = getCurrentEvent();
if (xmlSecEvent.getEventType() != PROCESSING_INSTRUCTION) {
throw new IllegalStateException(ERR_STATE_NOT_PI);
}
return ((ProcessingInstruction) xmlSecEvent).getData();
}
示例7: getPITarget
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
public String getPITarget() {
if (event.isProcessingInstruction()) {
return ((ProcessingInstruction) event).getTarget();
}
else {
throw new IllegalStateException();
}
}
示例8: getPIData
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
public String getPIData() {
if (event.isProcessingInstruction()) {
return ((ProcessingInstruction) event).getData();
}
else {
throw new IllegalStateException();
}
}
示例9: processEvent
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
private void processEvent(XmlParserContext ctx, XMLEvent xmlEvent) throws BagriException {
if (ctx.getDocRoot() == null) {
ctx.firstEvents.add(xmlEvent);
if (xmlEvent.getEventType() == XMLStreamConstants.START_ELEMENT) {
String root = "/" + xmlEvent.asStartElement().getName();
ctx.addDocument(root);
for (XMLEvent event: ctx.firstEvents) {
processEvent(ctx, event);
}
}
} else {
switch (xmlEvent.getEventType()) {
case XMLStreamConstants.START_ELEMENT:
startElement(ctx, xmlEvent.asStartElement());
break;
case XMLStreamConstants.CHARACTERS:
if (!xmlEvent.asCharacters().isWhiteSpace()) {
ctx.addCharacters(xmlEvent.asCharacters().getData());
}
break;
case XMLStreamConstants.END_ELEMENT:
ctx.endElement();
break;
case XMLStreamConstants.ATTRIBUTE:
ctx.addAttribute(((Attribute) xmlEvent).getName(), ((Attribute) xmlEvent).getValue());
break;
case XMLStreamConstants.COMMENT:
ctx.addComment(((Comment) xmlEvent).getText());
break;
case XMLStreamConstants.PROCESSING_INSTRUCTION:
ctx.addProcessingInstruction(((ProcessingInstruction) xmlEvent).getTarget(), ((ProcessingInstruction) xmlEvent).getData());
break;
default:
break;
}
}
}
示例10: getPITarget
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
public String getPITarget() {
if (this.event.isProcessingInstruction()) {
return ((ProcessingInstruction) this.event).getTarget();
}
else {
throw new IllegalStateException();
}
}
示例11: getPIData
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
public String getPIData() {
if (this.event.isProcessingInstruction()) {
return ((ProcessingInstruction) this.event).getData();
}
else {
throw new IllegalStateException();
}
}
示例12: processingInstruction
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
public void processingInstruction(ProcessingInstruction event)
throws XMLStreamException {
String data = event.getData();
if (data != null && data.length() > 0) {
fStreamWriter.writeProcessingInstruction(event.getTarget(), data);
}
else {
fStreamWriter.writeProcessingInstruction(event.getTarget());
}
}
示例13: add
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
@Override
public void add(XMLEvent event) throws XMLStreamException
{
if (event instanceof ProcessingInstruction)
{
if (null == piData)
piData = parsePIEvent((ProcessingInstruction)event);
}
else
piData = null;
if (null != piData)
{
if (piData.isOpening())
{
formatter = TocFormatter.forPI(piData, event.getLocation());
formatter.setXMLEventFactory(getXMLEventFactory());
}
if (piData.isClosing())
super.add(getXMLEventFactory().createCharacters("\n"));
}
else if (state == State.INDEXED)
index(event);
else if (state == State.ROOT)
{
addDTD((StartElement)event);
super.add(event);
state = State.PASSTHROUGH;
}
}
示例14: trackContext
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
protected void trackContext(XMLEvent event)
{
switch (event.getEventType())
{
case START_ELEMENT:
context.add(0, (StartElement)event);
break;
case END_DOCUMENT:
case END_ELEMENT:
if (!context.isEmpty())
{
StartElement open = context.remove(0);
EndElement close = event instanceof EndElement ? (EndElement)event : null;
if (null == close || !open.getName().equals(close.getName()))
throw new IllegalStateException("Unclosed " + describeEvent(open) + ' '
+ describeLocation(open.getLocation()));
}
else
throw new IllegalStateException("Unclosed " + describeEvent(origin) + ' '
+ describeLocation(origin.getLocation()));
break;
case PROCESSING_INSTRUCTION:
if (!TocPIParser.isIgnoredPI((ProcessingInstruction)event))
throw new IllegalStateException("Processing instructions <?" + TocPIParser.PI_TARGET
+ "?> are not allowed within the context of " + describeEvent(origin));
break;
}
}
示例15: parsePIEvent
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
protected TocPIData parsePIEvent(ProcessingInstruction event)
throws XMLStreamException
{
try
{
return piParser().parse(event);
}
catch (JAXBException pierr)
{
throw new XMLStreamException("Error parsing " + describeEvent(event),
event.getLocation(), pierr);
}
}