Package org.jibx.runtime

Examples of org.jibx.runtime.IBindingFactory


public class ParserTest {

  @Test
  public void testRead() throws JiBXException {
    IBindingFactory bfact = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class);
    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
    Object object = uctx.unmarshalDocument(getClass().getResourceAsStream("samples/example-sld.xml"), null);
    StyledLayerDescriptorInfo sld = (StyledLayerDescriptorInfo) object;
    for (ChoiceInfo choice : sld.getChoiceList()) {
      if (choice.ifNamedLayer()) {
        NamedLayerInfo layer = choice.getNamedLayer();
        Assert.assertEquals("OCEANSEA_1M:Foundation", layer.getName());
      }
    }
    IMarshallingContext ctx = bfact.createMarshallingContext();
    StringWriter sw = new StringWriter();
    ctx.setOutput(sw);
    ctx.marshalDocument(sld);
  }
View Full Code Here


    ctx.marshalDocument(sld);
  }

  @Test
  public void testCrosses() throws JiBXException {
    IBindingFactory bfact = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class);
    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
    Object object = uctx.unmarshalDocument(getClass().getResourceAsStream("samples/polygon_crosses.xml"), null);
    StyledLayerDescriptorInfo sld = (StyledLayerDescriptorInfo) object;
    for (ChoiceInfo choice : sld.getChoiceList()) {
      if (choice.ifNamedLayer()) {
        NamedLayerInfo layer = choice.getNamedLayer();
View Full Code Here

  @Test
  public void testDtoToGeotools() throws JiBXException, IOException, SAXException, ParserConfigurationException,
      InterruptedException {
    // read dto
    IBindingFactory bfact = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class);
    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
    StyledLayerDescriptorInfo sld = (StyledLayerDescriptorInfo) uctx.unmarshalDocument(getClass()
        .getResourceAsStream("samples/example-sld.xml"), null);

    // pipe to geotools parser
    StyleFactory factory = CommonFactoryFinder.getStyleFactory(null);
    PipedOutputStream pos = new PipedOutputStream();
    PipedInputStream pii = new PipedInputStream(pos);

    final SLDParser parser = new SLDParser(factory, pii);

    IMarshallingContext mctx = bfact.createMarshallingContext();
    mctx.setOutput(new PrintWriter(pos));

    CountDownLatch countDown = new CountDownLatch(2);
    ArrayList<Style> styles = new ArrayList<Style>();
    new Thread(new Parser(countDown, parser, styles)).start();
View Full Code Here

public class FilterTest {

  @Test
  public void testRead() throws JiBXException {
    IBindingFactory bfact = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class);
    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
    Object object = uctx.unmarshalDocument(getClass().getResourceAsStream("samples/filter/property_is_equal.xml"), null);
    FilterTypeInfo filter = (FilterTypeInfo) object;
    Assert.assertTrue(filter.ifComparisonOps());
    Assert.assertTrue(filter.getComparisonOps() instanceof PropertyIsEqualToInfo);
    PropertyIsEqualToInfo p = (PropertyIsEqualToInfo) filter.getComparisonOps();
View Full Code Here

public class SymbolizerTest {

  @Test
  public void testOverlap() throws JiBXException {
    IBindingFactory bfact = BindingDirectory.getFactory(RasterSymbolizerInfo.class);
    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
    Object object = uctx.unmarshalDocument(getClass()
        .getResourceAsStream("samples/symbolizer/rastersymbolizer.xml"), null);
    RasterSymbolizerInfo rasterSymbolizerInfo = (RasterSymbolizerInfo) object;
    Assert.assertEquals(OverlapBehaviorInfoInner.AVERAGE, rasterSymbolizerInfo.getOverlapBehavior()
        .getOverlapBehavior());
View Full Code Here

              public boolean accept(File dir, String name) {
                return name.endsWith(".sld") || name.endsWith(".xml");
              }
            });
            for (File file : sldFiles) {
              IBindingFactory bfact = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class);
              IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
              Object object = uctx.unmarshalDocument(new FileReader(file));
              StyledLayerDescriptorInfo sld = (StyledLayerDescriptorInfo) object;
              String fileName = StringUtils.stripFilenameExtension(file.getName());
              if (sld.getName() == null) {
                  sld.setName(fileName);
View Full Code Here

      }
    }
  }

  public void validate(Object obj) throws SldException {
    IBindingFactory bfact;
    try {
      bfact = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class);
      IMarshallingContext mctx = bfact.createMarshallingContext();
      StringWriter writer = new StringWriter();
      mctx.setOutput(writer);
      mctx.marshalDocument(obj);
      if (log.isDebugEnabled()) {
        log.debug(writer.toString());
View Full Code Here

      // apply defaults to all styles
      for (NamedStyleInfo namedStyle : info.getNamedStyleInfos()) {
        // check sld location
        if (namedStyle.getSldLocation() != null) {
          Resource resource = applicationContext.getResource(namedStyle.getSldLocation());
          IBindingFactory bindingFactory;
          try {
            bindingFactory = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class);
            IUnmarshallingContext unmarshallingContext = bindingFactory.createUnmarshallingContext();
            StyledLayerDescriptorInfo sld = (StyledLayerDescriptorInfo) unmarshallingContext
                .unmarshalDocument(new InputStreamReader(resource.getInputStream()));
            namedStyle.setStyledLayerInfo(sld);
          } catch (JiBXException e) {
            throw new LayerException(e, ExceptionCode.INVALID_SLD, namedStyle.getSldLocation(),
View Full Code Here

      return toByteArray("UTF-8");
   }

   public byte[] toByteArray(String encoding) throws Exception
   {
      IBindingFactory bfact = getBindingFactoryInPriviledgedMode(XMLObject.class);
      IMarshallingContext mctx = bfact.createMarshallingContext();
      mctx.setIndent(2);
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      mctx.marshalDocument(this, encoding, null, os);
      return os.toByteArray();
   }
View Full Code Here

      return os.toByteArray();
   }

   static public XMLObject getXMLObject(InputStream is) throws Exception
   {
      IBindingFactory bfact = getBindingFactoryInPriviledgedMode(XMLObject.class);
      IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
      XMLObject xmlobject = (XMLObject)uctx.unmarshalDocument(is, "UTF-8");
      return xmlobject;
   }
View Full Code Here

TOP

Related Classes of org.jibx.runtime.IBindingFactory

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.