Tabnine Logo
SmooksContentHandler
Code IndexAdd Tabnine to your IDE (free)

How to use
SmooksContentHandler
in
org.milyn.delivery

Best Java code snippets using org.milyn.delivery.SmooksContentHandler (Showing top 20 results out of 315)

origin: smooks/smooks

public SmooksContentHandler(ExecutionContext executionContext, SmooksContentHandler parentContentHandler) {
  this.executionContext = executionContext;
  this.parentContentHandler = parentContentHandler;
  attachHandler();
  if(parentContentHandler != null) {
    parentContentHandler.nestedContentHandler = this;
  }
}
origin: org.milyn/milyn-smooks-all

@Override
public final void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
  getNamespaceDeclarationStack().pushNamespaces(qName, uri, attributes);
  startEvent.set(uri, localName, qName, attributes);
  lastEvent = startEvent;
  depth++;
  startElement(startEvent);
  if(nestedContentHandler != null) {
    // Replay the start element event from the parent handler onto the nested handler...
    replay(nestedContentHandler);
  }
}
origin: smooks/smooks

public void startDocument() throws SAXException {
  super.startDocument();
  if(ownerDocument == null) {
    // Parsing a new ownerDocument from scratch - create the DOM Document
    // instance and set it as the startNode.
    ownerDocument = documentBuilder.newDocument();
    // Initialise the stack with the Document node.
    nodeStack.push(ownerDocument);
  }
}
origin: org.milyn/milyn-smooks-all

@Override
public final void endElement(String uri, String localName, String qName) throws SAXException {
  try {
    endEvent.set(uri, localName, qName);
    lastEvent = endEvent;
    endElement(endEvent);
    depth--;
  } finally {
    if(!endReplayed && depth == 0 && parentContentHandler != null) {
      endReplayed = true;
      // Replay the last sax event from this handler onto the parent handler ...
      replay(parentContentHandler);
      // Reinstate the parent handler on the XMLReader so all events are
      // forwarded to it again ...
      XMLReader xmlReader = AbstractParser.getXMLReader(executionContext);
      xmlReader.setContentHandler(parentContentHandler);
      // Remove the nested handler (this handler) form the parent handler...
      parentContentHandler.resetNestedContentHandler();
    }
  }
  getNamespaceDeclarationStack().popNamespaces();
}
origin: smooks/smooks

public static void addDynamicVisitor(SAXVisitor visitor, ExecutionContext executionContext) {
  SmooksContentHandler contentHandler = SmooksContentHandler.getHandler(executionContext);
  SmooksContentHandler nestedContentHandler = contentHandler.getNestedContentHandler();
  if(nestedContentHandler == null) {
    DynamicSAXElementVisitorList list = getList(executionContext);
    if(visitor instanceof SAXVisitBefore) {
      list.visitBefores.add((SAXVisitBefore) visitor);
    }
    if(visitor instanceof SAXVisitChildren) {
      list.childVisitors.add((SAXVisitChildren) visitor);
    }
    if(visitor instanceof SAXVisitAfter) {
      list.visitAfters.add((SAXVisitAfter) visitor);
    }
  } else {
    addDynamicVisitor(visitor, nestedContentHandler.getExecutionContext());
  }
}
origin: smooks/smooks

public void visitBefore(SAXElement element, ExecutionContext executionContext) throws SmooksException, IOException {
  Smooks smooks = getSmooksInstance();
  ExecutionContext nestedExecutionContext = smooks.createExecutionContext();
  // In case there's an attached event listener...
  nestedExecutionContext.setEventListener(executionContext.getEventListener());
  // Copy over the XMLReader stack...
  AbstractParser.setReaders(AbstractParser.getReaders(executionContext), nestedExecutionContext);
  // Attach the NamespaceDeclarationStack to the nested execution context...
  NamespaceDeclarationStack nsStack = NamespaceMappings.getNamespaceDeclarationStack(executionContext);
  NamespaceMappings.setNamespaceDeclarationStack(nsStack, nestedExecutionContext);
  SmooksContentHandler parentContentHandler = SmooksContentHandler.getHandler(executionContext);
  if(parentContentHandler.getNestedContentHandler() != null) {
    throw new SmooksException("Illegal use of more than one nested content handler fired on the same element.");
  }
  SmooksContentHandler nestedContentHandler = new SAXHandler(nestedExecutionContext, element.getWriter(this), parentContentHandler);
  DynamicSAXElementVisitorList.propogateDynamicVisitors(executionContext, nestedExecutionContext);
  // Attach the XMLReader instance to the nested ExecutionContext and then swap the content handler on
  // the XMLReader to be the nested handler created here.  All events wll be forwarded to the ..
  XMLReader xmlReader = AbstractParser.getXMLReader(executionContext);
  AbstractParser.attachXMLReader(xmlReader, nestedExecutionContext);
  xmlReader.setContentHandler(nestedContentHandler);
  executionContext.setAttribute(NestedExecutionVisitor.class, nestedExecutionContext);
  // Note we do not execute the Smooks filterSource methods for a nested instance... we just install
  // the content handler and redirect the reader events to it...
}
origin: smooks/smooks

public void replayStartElement() {
  // Replay the last sax event from the parent handler on this sax handler...
  parentContentHandler.replay(this);
}
origin: org.virtuslab/milyn-smooks-core

@Override
public final void endElement(String uri, String localName, String qName) throws SAXException {
  try {
    endEvent.set(uri, localName, qName);
    lastEvent = endEvent;
    endElement(endEvent);
    depth--;
  } finally {
    if(!endReplayed && depth == 0 && parentContentHandler != null) {
      endReplayed = true;
      // Replay the last sax event from this handler onto the parent handler ...
      replay(parentContentHandler);
      // Reinstate the parent handler on the XMLReader so all events are
      // forwarded to it again ...
      XMLReader xmlReader = AbstractParser.getXMLReader(executionContext);
      xmlReader.setContentHandler(parentContentHandler);
      // Remove the nested handler (this handler) form the parent handler...
      parentContentHandler.resetNestedContentHandler();
    }
  }
  getNamespaceDeclarationStack().popNamespaces();
}
origin: org.virtuslab/milyn-smooks-core

public static void addDynamicVisitor(SAXVisitor visitor, ExecutionContext executionContext) {
  SmooksContentHandler contentHandler = SmooksContentHandler.getHandler(executionContext);
  SmooksContentHandler nestedContentHandler = contentHandler.getNestedContentHandler();
  if(nestedContentHandler == null) {
    DynamicSAXElementVisitorList list = getList(executionContext);
    if(visitor instanceof SAXVisitBefore) {
      list.visitBefores.add((SAXVisitBefore) visitor);
    }
    if(visitor instanceof SAXVisitChildren) {
      list.childVisitors.add((SAXVisitChildren) visitor);
    }
    if(visitor instanceof SAXVisitAfter) {
      list.visitAfters.add((SAXVisitAfter) visitor);
    }
  } else {
    addDynamicVisitor(visitor, nestedContentHandler.getExecutionContext());
  }
}
origin: org.virtuslab/milyn-smooks-core

public void visitBefore(SAXElement element, ExecutionContext executionContext) throws SmooksException, IOException {
  Smooks smooks = getSmooksInstance();
  ExecutionContext nestedExecutionContext = smooks.createExecutionContext();
  // In case there's an attached event listener...
  nestedExecutionContext.setEventListener(executionContext.getEventListener());
  // Copy over the XMLReader stack...
  AbstractParser.setReaders(AbstractParser.getReaders(executionContext), nestedExecutionContext);
  // Attach the NamespaceDeclarationStack to the nested execution context...
  NamespaceDeclarationStack nsStack = NamespaceMappings.getNamespaceDeclarationStack(executionContext);
  NamespaceMappings.setNamespaceDeclarationStack(nsStack, nestedExecutionContext);
  SmooksContentHandler parentContentHandler = SmooksContentHandler.getHandler(executionContext);
  if(parentContentHandler.getNestedContentHandler() != null) {
    throw new SmooksException("Illegal use of more than one nested content handler fired on the same element.");
  }
  SmooksContentHandler nestedContentHandler = new SAXHandler(nestedExecutionContext, element.getWriter(this), parentContentHandler);
  DynamicSAXElementVisitorList.propogateDynamicVisitors(executionContext, nestedExecutionContext);
  // Attach the XMLReader instance to the nested ExecutionContext and then swap the content handler on
  // the XMLReader to be the nested handler created here.  All events wll be forwarded to the ..
  XMLReader xmlReader = AbstractParser.getXMLReader(executionContext);
  AbstractParser.attachXMLReader(xmlReader, nestedExecutionContext);
  xmlReader.setContentHandler(nestedContentHandler);
  executionContext.setAttribute(NestedExecutionVisitor.class, nestedExecutionContext);
  // Note we do not execute the Smooks filterSource methods for a nested instance... we just install
  // the content handler and redirect the reader events to it...
}
origin: org.milyn/milyn-smooks-core

public void replayStartElement() {
  // Replay the last sax event from the parent handler on this sax handler...
  parentContentHandler.replay(this);
}
origin: smooks/smooks

@Override
public final void endElement(String uri, String localName, String qName) throws SAXException {
  try {
    endEvent.set(uri, localName, qName);
    lastEvent = endEvent;
    endElement(endEvent);
    depth--;
  } finally {
    if(!endReplayed && depth == 0 && parentContentHandler != null) {
      endReplayed = true;
      // Replay the last sax event from this handler onto the parent handler ...
      replay(parentContentHandler);
      // Reinstate the parent handler on the XMLReader so all events are
      // forwarded to it again ...
      XMLReader xmlReader = AbstractParser.getXMLReader(executionContext);
      xmlReader.setContentHandler(parentContentHandler);
      // Remove the nested handler (this handler) form the parent handler...
      parentContentHandler.resetNestedContentHandler();
    }
  }
  getNamespaceDeclarationStack().popNamespaces();
}
origin: org.virtuslab/milyn-smooks-core

@Override
public final void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
  getNamespaceDeclarationStack().pushNamespaces(qName, uri, attributes);
  startEvent.set(uri, localName, qName, attributes);
  lastEvent = startEvent;
  depth++;
  startElement(startEvent);
  if(nestedContentHandler != null) {
    // Replay the start element event from the parent handler onto the nested handler...
    replay(nestedContentHandler);
  }
}
origin: org.milyn/milyn-smooks-core

public static void addDynamicVisitor(SAXVisitor visitor, ExecutionContext executionContext) {
  SmooksContentHandler contentHandler = SmooksContentHandler.getHandler(executionContext);
  SmooksContentHandler nestedContentHandler = contentHandler.getNestedContentHandler();
  if(nestedContentHandler == null) {
    DynamicSAXElementVisitorList list = getList(executionContext);
    if(visitor instanceof SAXVisitBefore) {
      list.visitBefores.add((SAXVisitBefore) visitor);
    }
    if(visitor instanceof SAXVisitChildren) {
      list.childVisitors.add((SAXVisitChildren) visitor);
    }
    if(visitor instanceof SAXVisitAfter) {
      list.visitAfters.add((SAXVisitAfter) visitor);
    }
  } else {
    addDynamicVisitor(visitor, nestedContentHandler.getExecutionContext());
  }
}
origin: org.milyn/milyn-smooks-all

public void visitBefore(SAXElement element, ExecutionContext executionContext) throws SmooksException, IOException {
  Smooks smooks = getSmooksInstance();
  ExecutionContext nestedExecutionContext = smooks.createExecutionContext();
  // In case there's an attached event listener...
  nestedExecutionContext.setEventListener(executionContext.getEventListener());
  // Copy over the XMLReader stack...
  AbstractParser.setReaders(AbstractParser.getReaders(executionContext), nestedExecutionContext);
  // Attach the NamespaceDeclarationStack to the nested execution context...
  NamespaceDeclarationStack nsStack = NamespaceMappings.getNamespaceDeclarationStack(executionContext);
  NamespaceMappings.setNamespaceDeclarationStack(nsStack, nestedExecutionContext);
  SmooksContentHandler parentContentHandler = SmooksContentHandler.getHandler(executionContext);
  if(parentContentHandler.getNestedContentHandler() != null) {
    throw new SmooksException("Illegal use of more than one nested content handler fired on the same element.");
  }
  SmooksContentHandler nestedContentHandler = new SAXHandler(nestedExecutionContext, element.getWriter(this), parentContentHandler);
  DynamicSAXElementVisitorList.propogateDynamicVisitors(executionContext, nestedExecutionContext);
  // Attach the XMLReader instance to the nested ExecutionContext and then swap the content handler on
  // the XMLReader to be the nested handler created here.  All events wll be forwarded to the ..
  XMLReader xmlReader = AbstractParser.getXMLReader(executionContext);
  AbstractParser.attachXMLReader(xmlReader, nestedExecutionContext);
  xmlReader.setContentHandler(nestedContentHandler);
  executionContext.setAttribute(NestedExecutionVisitor.class, nestedExecutionContext);
  // Note we do not execute the Smooks filterSource methods for a nested instance... we just install
  // the content handler and redirect the reader events to it...
}
origin: org.milyn/milyn-smooks-core

public SmooksContentHandler(ExecutionContext executionContext, SmooksContentHandler parentContentHandler) {
  this.executionContext = executionContext;
  this.parentContentHandler = parentContentHandler;
  attachHandler();
  if(parentContentHandler != null) {
    parentContentHandler.nestedContentHandler = this;
  }
}
origin: org.virtuslab/milyn-smooks-core

public void replayStartElement() {
  // Replay the last sax event from the parent handler on this sax handler...
  parentContentHandler.replay(this);
}
origin: org.milyn/milyn-smooks-core

public void startDocument() throws SAXException {
  super.startDocument();
  if(ownerDocument == null) {
    // Parsing a new ownerDocument from scratch - create the DOM Document
    // instance and set it as the startNode.
    ownerDocument = documentBuilder.newDocument();
    // Initialise the stack with the Document node.
    nodeStack.push(ownerDocument);
  }
}
origin: org.milyn/milyn-smooks-core

@Override
public final void endElement(String uri, String localName, String qName) throws SAXException {
  try {
    endEvent.set(uri, localName, qName);
    lastEvent = endEvent;
    endElement(endEvent);
    depth--;
  } finally {
    if(!endReplayed && depth == 0 && parentContentHandler != null) {
      endReplayed = true;
      // Replay the last sax event from this handler onto the parent handler ...
      replay(parentContentHandler);
      // Reinstate the parent handler on the XMLReader so all events are
      // forwarded to it again ...
      XMLReader xmlReader = AbstractParser.getXMLReader(executionContext);
      xmlReader.setContentHandler(parentContentHandler);
      // Remove the nested handler (this handler) form the parent handler...
      parentContentHandler.resetNestedContentHandler();
    }
  }
  getNamespaceDeclarationStack().popNamespaces();
}
origin: smooks/smooks

@Override
public final void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
  getNamespaceDeclarationStack().pushNamespaces(qName, uri, attributes);
  startEvent.set(uri, localName, qName, attributes);
  lastEvent = startEvent;
  depth++;
  startElement(startEvent);
  if(nestedContentHandler != null) {
    // Replay the start element event from the parent handler onto the nested handler...
    replay(nestedContentHandler);
  }
}
org.milyn.deliverySmooksContentHandler

Javadoc

Abstract SAX Content Handler.

Most used methods

  • attachHandler
  • endElement
  • getExecutionContext
  • getHandler
  • getNamespaceDeclarationStack
  • getNestedContentHandler
  • replay
  • resetNestedContentHandler
  • startDocument
  • startElement

Popular in Java

  • Creating JSON documents from java classes using gson
  • onRequestPermissionsResult (Fragment)
  • requestLocationUpdates (LocationManager)
  • getSystemService (Context)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now