Package org.jibx.runtime

Examples of org.jibx.runtime.IUnmarshallingContext


  URL oUrl = new URL("http://boss.yahooapis.com/ysearch/web/v1/"+Gadgets.URLEncode(sQuery)+
                   "?appid="+sKey+"&format=xml&type=html&style=raw"+
                  (sSites==null ? "" : "&sites="+sSites));
  try {
    IBindingFactory oIbf = BindingDirectory.getFactory(YSearchResponse.class);
    IUnmarshallingContext oUmc = oIbf.createUnmarshallingContext();

    ByteArrayOutputStream oOst = new ByteArrayOutputStream();
    DataHandler oHnd = new DataHandler(oUrl);
    oHnd.writeTo(oOst);
    ByteArrayInputStream oIst = new ByteArrayInputStream(oOst.toByteArray());
    oYsr = (YSearchResponse) oUmc.unmarshalDocument (oIst, "UTF8");   
    oIst.close();
    oOst.close();
  } catch (JiBXException jibxe) {
    throw new IOException(jibxe.getMessage(), jibxe);
  }
View Full Code Here


  private FeatureInfo featureInfo;

  @Test
  public void testSingleStyle() throws JiBXException, LayerException {
    IBindingFactory bfact = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class);
    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
    Object object = uctx.unmarshalDocument(getClass().getResourceAsStream("/org/geomajas/testdata/sld/single_layer_no_stylename.sld"), null);
    StyledLayerDescriptorInfo sld = (StyledLayerDescriptorInfo) object;
    NamedStyleInfo info = styleConverterService.convert(sld, featureInfo, "layer", "style");
    Assert.assertNotNull(info);
    Assert.assertEquals("Some title", info.getName());
  }
View Full Code Here

  }
 
  @Test
  public void testPickStyle() throws JiBXException, LayerException {
    IBindingFactory bfact = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class);
    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
    Object object = uctx.unmarshalDocument(getClass().getResourceAsStream("/org/geomajas/testdata/sld/multiple_layer_stylename.sld"), null);
    StyledLayerDescriptorInfo sld = (StyledLayerDescriptorInfo) object;
    NamedStyleInfo info1 = styleConverterService.convert(sld, featureInfo, "Layer1", "Style1");
    Assert.assertNotNull(info1);
    Assert.assertEquals("Style1", info1.getName());
    Assert.assertEquals(1, info1.getFeatureStyles().size());
View Full Code Here

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());
View Full Code Here

  }

  @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();
        for (org.geomajas.sld.NamedLayerInfo.ChoiceInfo choice2 : layer.getChoiceList()) {
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();
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();
    Assert.assertEquals(2, p.getExpressionList().size());
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

                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

        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(),
                layer.getId());
View Full Code Here

TOP

Related Classes of org.jibx.runtime.IUnmarshallingContext

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.