Package org.exolab.castor.xml

Examples of org.exolab.castor.xml.Unmarshaller


    marshaller.marshal(itemSimple);
    return writer.toString().replaceFirst("\n", "") + System.getProperty("line.separator");
  }

  public ItemSimple fromImport(String input) throws Exception {
    Unmarshaller unmarshaller = xmlContext.createUnmarshaller();
    unmarshaller.setClass(ItemSimple.class);
    StringReader reader = new StringReader(input);
    ItemSimple itemSimple = (ItemSimple) unmarshaller.unmarshal(reader);
    return itemSimple;
  }
View Full Code Here


    context.addMapping(mapping);
   
    InputStream stream = getClass().getResourceAsStream("/com/jada/xml/databaseUpgrade/DatabaseUpgradeQuery.xml");
      BufferedReader reader = new BufferedReader(new InputStreamReader(stream));

      Unmarshaller unmarshaller = context.createUnmarshaller();
      unmarshaller.setClass(DatabaseUpgradeQueries.class);
     
      databaseUpgradeQueries = (DatabaseUpgradeQueries) unmarshaller.unmarshal(reader);
  }
View Full Code Here

    private char[] dateTimeBuff = new char[32];
    private int c = 0;
    private boolean appendZ = false;

    public GpxHandler() {
        this.unmarshaller = new Unmarshaller(Gpx.class);
        this.gpx = new Gpx();
        unmarshaller.setObject(gpx);
        super.setContentHandler(unmarshaller.createHandler());
    }
View Full Code Here

                portletXml.getSystemId() +
                    ", " +
                    webXml.getSystemId());
            }

        Unmarshaller unmarshaller = new Unmarshaller(portletXMLMapping);
        unmarshaller.setIgnoreExtraElements(true);
        unmarshaller.setEntityResolver(this.resolver);
        unmarshaller.setValidation(false);
        PortletApplicationDefinitionImpl portletApp =
            (PortletApplicationDefinitionImpl) unmarshaller.unmarshal(portletXml);

        WebApplicationDefinitionImpl webApp = null;

        if (webXml.getByteStream() != null) {
            unmarshaller = new Unmarshaller(webXMLMapping);
            unmarshaller.setIgnoreExtraElements(true);
            unmarshaller.setEntityResolver(this.resolver);
            unmarshaller.setValidation(false);
            webApp = (WebApplicationDefinitionImpl) unmarshaller.unmarshal(webXml);

            Vector structure = new Vector();
            structure.add(portletApp);
            structure.add("/" + webModule);
View Full Code Here

    private boolean defaultSuppressXSIType;
   
    public Object getObject(InputStream stream, Map parameters) throws ConverterException {
        try {
            ReferenceFieldHandler.setObjectMap((Map)parameters.get(ProfileLS.PARAMETER_OBJECTMAP));
            Unmarshaller unmarshaller = new Unmarshaller((Mapping)this.mappings.get(parameters.get(ProfileLS.PARAMETER_PROFILETYPE)));
            Object result = unmarshaller.unmarshal(new InputSource(stream));
            stream.close();
            return result;
        } catch (MappingException e) {
            throw new ConverterException("Can't create Unmarshaller", e);
        } catch (Exception e) {
View Full Code Here

   }

   protected void startService() throws Exception
   {
      org.exolab.castor.jdo.conf.Database database;
      Unmarshaller unm;
      int pos;
      Method m;

      boolean debug = log.isDebugEnabled();

      // Bind in JNDI
      bind(new InitialContext(), "java:/" + _jndiName, this);

    // Determine complete URL to _dbConf file.  It is likely a relative path.
    URL    confUrl = Thread.currentThread().getContextClassLoader().getResource( _dbConf );

    if ( null == confUrl )
      {
      FileNotFoundException e = new FileNotFoundException(
        "CastorJDOImpl.startService(): Unable to resolve Configuration attribute to URL = "
        + _dbConf );
      log.error( "CastorJDOImpl.startService(): Unable to find " + _dbConf + " file.", e );
      }

    _dbUrl = confUrl.toString();
 
      _jdo.setTransactionManager("java:/TransactionManager");
      _jdo.setConfiguration( _dbUrl );
      unm = new Unmarshaller(org.exolab.castor.jdo.conf.Database.class);
      database = (org.exolab.castor.jdo.conf.Database) unm.unmarshal(new InputSource( _dbUrl ));
      _jdo.setDatabaseName(database.getName());
      if (database.getJndi() != null) {
         _dataSourceName = database.getJndi().getName();
      }
      // Older Castor versions older don't have these methods,
View Full Code Here

     * Sets the database options from a JDO database mapping file.
     *
     * @param databaseURL URL string for JDO database mapping file.
     */
    public void setDatabase(final String databaseURL) throws DTXException {
        Unmarshaller unm = new Unmarshaller(Database.class);

        unm.setEntityResolver(new DTDResolver());

        try {
            _database = (Database) unm.unmarshal(
                    new InputSource(new URL(databaseURL).openStream()));
        } catch (Exception except) {
            throw new DTXException(except);
        }

        if (_database.getEngine() == null) {
            _factory = PersistenceFactoryRegistry.getPersistenceFactory("generic");
        } else {
            _factory = PersistenceFactoryRegistry.getPersistenceFactory(_database.getEngine());
        }

        if (_factory == null) {
            throw new DTXException("no engine");
        }

        // Class mappings

        _classMappings = new HashMap();

        // Load the specificed mapping source

        Unmarshaller munm = new Unmarshaller(MappingRoot.class);

        Mapping[] mappings = _database.getMapping();

        for (int i = 0; i < mappings.length; ++i) {
            try {
            URL mappingURL = new URL(new URL(databaseURL), mappings[i].getHref());
            MappingRoot mr = (MappingRoot) munm.unmarshal(new InputSource(mappingURL.openStream()));
            ClassMapping[] classMaps = mr.getClassMapping();

            for (int j = 0; j < classMaps.length; j++) {
                _classMappings.put(classMaps[j].getName(), classMaps[j]);
            }
View Full Code Here

            }
        }

        private void loadHistory() {
            try {
                Unmarshaller unmarshaller = new Unmarshaller(
                        Class.forName("org.exolab.castor.gui.QueryHistory"));
                ClassLoader cl = ClassLoader.getSystemClassLoader();
                _mapping.loadMapping(cl.getResource("org/exolab/castor/gui/Queryanlyser.xml"));
                unmarshaller.setMapping(_mapping);

                FileReader reader = new FileReader("queryhistory.xml");
                _qhistory = (QueryHistory) unmarshaller.unmarshal(reader);
            } catch (Exception e) {
                e.printStackTrace();
                // if there is no file, it's ok also
                // then we have an empty History
            }
View Full Code Here

     */
    public void testUnmarshalSimpleBean() throws Exception {
        Mapping mapping = new Mapping();
        mapping.loadMapping(getClass().getResource(MAPPING_FILE).toExternalForm());
       
        Unmarshaller unmarshaller = new Unmarshaller(Bean.class);
        unmarshaller.setMapping(mapping);
       
        String input
            = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<bean attribute=\"999\">"
            + "<element>element of 999</element>"
            + "</bean>";
   
        Bean bean = (Bean) unmarshaller.unmarshal(new StringReader(input));
        assertNotNull(bean);
        assertEquals(999, bean.getAttribute().intValue());
        assertEquals("element of 999", bean.getElement());
        assertNull(bean.getReference());
    }
View Full Code Here

     */
    public void testUnmarshalReferingBean() throws Exception {
        Mapping mapping = new Mapping();
        mapping.loadMapping(getClass().getResource(MAPPING_FILE).toExternalForm());
       
        Unmarshaller unmarshaller = new Unmarshaller(Bean.class);
        unmarshaller.setMapping(mapping);
       
        String input
            = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<bean attribute=\"100\">"
            + "<element>element of 100</element>"
            + "<reference attribute=\"999\">"
            + "<element>element of 999</element>"
            + "</reference>"
            + "</bean>";
   
        Bean referer = (Bean) unmarshaller.unmarshal(new StringReader(input));
        assertNotNull(referer);
        assertEquals(100, referer.getAttribute().intValue());
        assertEquals("element of 100", referer.getElement());
        assertNotNull(referer.getReference());

View Full Code Here

TOP

Related Classes of org.exolab.castor.xml.Unmarshaller

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.