當前位置: 首頁>>代碼示例>>Java>>正文


Java DomDriver類代碼示例

本文整理匯總了Java中com.thoughtworks.xstream.io.xml.DomDriver的典型用法代碼示例。如果您正苦於以下問題:Java DomDriver類的具體用法?Java DomDriver怎麽用?Java DomDriver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DomDriver類屬於com.thoughtworks.xstream.io.xml包,在下文中一共展示了DomDriver類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: DriverEndToEndTestSuite

import com.thoughtworks.xstream.io.xml.DomDriver; //導入依賴的package包/類
public DriverEndToEndTestSuite() {
    super(DriverEndToEndTestSuite.class.getName());
    addDriverTest(new BEAStaxDriver());
    addDriverTest(new BinaryStreamDriver());
    addDriverTest(new Dom4JDriver());
    addDriverTest(new DomDriver());
    addDriverTest(new JDomDriver());
    addDriverTest(new JDom2Driver());
    addDriverTest(new KXml2DomDriver());
    addDriverTest(new KXml2Driver());
    addDriverTest(new StaxDriver());
    addDriverTest(new StandardStaxDriver());
    addDriverTest(new WstxDriver());
    addDriverTest(new XomDriver());
    addDriverTest(new Xpp3DomDriver());
    addDriverTest(new Xpp3Driver());
    addDriverTest(new XppDomDriver());
    addDriverTest(new XppDriver());
    addDriverTest(new JettisonMappedXmlDriver());
}
 
開發者ID:x-stream,項目名稱:xstream,代碼行數:21,代碼來源:DriverEndToEndTestSuite.java

示例2: readXMLObject

import com.thoughtworks.xstream.io.xml.DomDriver; //導入依賴的package包/類
/**
 *
 * @param filename
 * @param doValidate
 * @return
 */
public default Object readXMLObject(String filename, boolean doValidate) {

    String xmlContents = null;
    Object myModelClassInstance = null;

    try {
        xmlContents = new String(Files.readAllBytes(Paths.get(filename)));
        XStream xstream = new XStream(new DomDriver());
        customizeXstream(xstream);
        myModelClassInstance = xstream.fromXML(xmlContents);
    } catch (IOException iOException) {
        // do nothing for now
    }

    return myModelClassInstance;
}
 
開發者ID:CIRDLES,項目名稱:Squid,代碼行數:23,代碼來源:XMLSerializerInterface.java

示例3: loadXML

import com.thoughtworks.xstream.io.xml.DomDriver; //導入依賴的package包/類
public static SPStoryWorldData loadXML(File xmlFile) throws FileNotFoundException {
	
	
	FileReader reader = new FileReader(xmlFile);
	XStream xstream = new XStream(new DomDriver());
	xstream.autodetectAnnotations(true);
	xstream.alias(SPStoryWorldData.class.getAnnotation(XStreamAlias.class).value(), SPStoryWorldData.class);
	Object obj = xstream.fromXML(reader);
	try {
		reader.close();
	} catch (IOException e) {
	}
	if (!(obj instanceof SPStoryWorldData)) throw new RuntimeException("file " + xmlFile.getAbsolutePath() + " doesn't contain a xml with SPStoryWorldData");
	SPStoryWorldData data = (SPStoryWorldData) obj;
	data.file = xmlFile.getAbsolutePath();
	return data;
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:18,代碼來源:SPStoryWorldData.java

示例4: readFile

import com.thoughtworks.xstream.io.xml.DomDriver; //導入依賴的package包/類
/**
 * Reads in an XML file describing a fully serialized game.
 */
@Override
public IGame readFile (File xmlFile) throws LoadErrorException {
    XStream xstream = new XStream(new DomDriver());
    FXConverters.configure(xstream);
    xstream.setMode(XStream.SINGLE_NODE_XPATH_RELATIVE_REFERENCES);
    try {
        String xml = fileToXMLString(xmlFile);
        return (IGame) xstream.fromXML(xml);
    }
    catch (IOException | UnknownFieldException e) {
        // TODO throw a checked error here to make front-end deal with an error if the file is
        // corrupted
        throw new LoadErrorException("Could not deserialize file: " + xmlFile.getPath());
    }
}
 
開發者ID:tomrom95,項目名稱:GameAuthoringEnvironment,代碼行數:19,代碼來源:GameReader.java

示例5: loadRules

import com.thoughtworks.xstream.io.xml.DomDriver; //導入依賴的package包/類
/**
 * 
 * 加載配置文件
 * @return
 * @throws Exception
 */
@SuppressWarnings("unchecked")
protected Map<String, Rule> loadRules() throws Exception {

	final Map<String, Rule> routerMap = new HashMap<String, Rule>();
	if (getRuleConfige() != null) {
		final XStream xstream = new XStream(new DomDriver());
		xstream.alias("rules", List.class);
		xstream.alias("rule", Entity.class);
		List<Entity> rules = new ArrayList<Entity>();
		rules = (List<Entity>) xstream.fromXML(getRuleConfige().getInputStream());

		for (final Entity entity : rules) {
			final Rule router = new Rule();
			final Class<?> clazz = Class.forName(entity.strategy);
			final IStrategy instance = (IStrategy) clazz.newInstance();
			instance.initStrategy(entity.tables.split(","));
			router.setShardStrategy(instance);
			router.setXmlTableParam(entity.tableParam);
			router.setFieldParam(entity.field);
			makeRouterMap(entity, router, routerMap);

		}
	}
	return routerMap;
}
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:32,代碼來源:ShardTableRuleFactoryBean.java

示例6: main

import com.thoughtworks.xstream.io.xml.DomDriver; //導入依賴的package包/類
public static void main (String[] args){
    Sprite a = new Sprite("bricks.jpg","DA", null, null);
    Sprite b = new Sprite("bricks.jpg","eA", null, null);
    List<Sprite> sprites = new ArrayList<Sprite>();
    sprites.add(a);
    sprites.add(b);
    
    XStream mySerializer = new XStream(new DomDriver());
    try {
        mySerializer.toXML(sprites,new FileOutputStream(new File("game_data/ExampleData.xml")));
    }
    catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    
    
}
 
開發者ID:sjain28,項目名稱:Game-Engine-Vooga,代碼行數:19,代碼來源:SpriteDataUseCase.java

示例7: main

import com.thoughtworks.xstream.io.xml.DomDriver; //導入依賴的package包/類
public static void main (String[] args){
   
    Rectangle r1 = new Rectangle(3,5);
    Line l2 = new Line(3,5,6,9);
    Rectangle r2 = new Rectangle(7,19);
    Rectangle r3 = new Rectangle(3,9);
    List<Node> sprites = new ArrayList<Node>();
    
    sprites.add(r1);
    sprites.add(l2);
    sprites.add(r2);
    sprites.add(r3);
    		
    
    XStream mySerializer = new XStream(new DomDriver());
    try {
        mySerializer.toXML(sprites,new FileOutputStream(new File("game_data/ExampleData.xml")));
    }
    catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    
    
}
 
開發者ID:sjain28,項目名稱:Game-Engine-Vooga,代碼行數:26,代碼來源:TestAddSpritesUseCase.java

示例8: toBean

import com.thoughtworks.xstream.io.xml.DomDriver; //導入依賴的package包/類
/**
 * 將一個xml流轉換為bean實體類
 *
 * @param type
 * @param is
 * @return
 */
@SuppressWarnings("unchecked")
public synchronized static <T> T toBean(Class<T> type, InputStream is) {
    XStream xmStream = new XStream(new DomDriver());
    // 設置可忽略為在javabean類中定義的界麵屬性
    xmStream.ignoreUnknownElements();
    xmStream.processAnnotations(type);
    T obj = null;
    try {
        obj = (T) xmStream.fromXML(is);
    } catch (Exception e) {
        Logger.log("===解析xml發生異常:" + e.getMessage());
    } finally {
        FileUtils.closeIO(is);
    }
    return obj;
}
 
開發者ID:kymjs,項目名稱:CoreModule,代碼行數:24,代碼來源:XmlUtil.java

示例9: getSpec

import com.thoughtworks.xstream.io.xml.DomDriver; //導入依賴的package包/類
private <T> T getSpec(URL file) {
    try {
        XStream xstream = new XStream(new DomDriver());
        xstream.autodetectAnnotations(true);
        xstream.processAnnotations(Bit.class);
        xstream.processAnnotations(BitField.class);
        xstream.processAnnotations(Characteristic.class);
        xstream.processAnnotations(Enumeration.class);
        xstream.processAnnotations(Enumerations.class);
        xstream.processAnnotations(Field.class);
        xstream.processAnnotations(InformativeText.class);
        xstream.processAnnotations(Service.class);
        xstream.processAnnotations(Value.class);
        xstream.processAnnotations(Reserved.class);
        xstream.processAnnotations(Examples.class);
        xstream.processAnnotations(CharacteristicAccess.class);
        xstream.processAnnotations(Characteristics.class);
        xstream.processAnnotations(Properties.class);
        xstream.ignoreUnknownElements();
        xstream.setClassLoader(Characteristic.class.getClassLoader());
        return (T) xstream.fromXML(file);
    } catch (Exception e) {
        logger.error("Could not read file: " + file, e);
    }
    return null;
}
 
開發者ID:sputnikdev,項目名稱:bluetooth-gatt-parser,代碼行數:27,代碼來源:BluetoothGattSpecificationReader.java

示例10: storeData

import com.thoughtworks.xstream.io.xml.DomDriver; //導入依賴的package包/類
private final void storeData(String topic, String message)
{
	//AbstractDriver
	System.out.println("message received "+ topic);
	XStream dataStreamer = new XStream(new DomDriver() );// DomDriver());
	@SuppressWarnings("unchecked")
	Map<String, Object> data = (Map<String, Object>)dataStreamer.fromXML(message);
	ArrayList<FollowedVariable> dts=this.receivedData.get(topic);
	System.out.println("message received "+ topic+" "+data);
	
	if(dts==null)
		{
			//dts = new FollowedVariable(topic);
			//this.receivedData.put(topic,dts);
			return;
		}
	for(FollowedVariable dt:dts)
		dt.pushNewData(data);
}
 
開發者ID:gnoubi,項目名稱:MarrakAir,代碼行數:20,代碼來源:MQTTConnector.java

示例11: getEmail

import com.thoughtworks.xstream.io.xml.DomDriver; //導入依賴的package包/類
private Email getEmail() {
    try {
        StringBuilder xml = new StringBuilder();
        Scanner scanner = new Scanner(new FileReader("email.xml"));
        while (scanner.hasNext()) {
            xml.append(scanner.next());
        }

        XStream xStream = new XStream(new DomDriver());
        Email email = (Email) xStream.fromXML(xml.toString());

        return email;

    } catch (FileNotFoundException ex) {
        JOptionPane.showMessageDialog(null,
                "Arquivo email.xml não encontrado.",
                "Erro",
                JOptionPane.ERROR_MESSAGE);
    }
    return null;
}
 
開發者ID:douglasgusson,項目名稱:pitanga-system,代碼行數:22,代碼來源:FrmConfiguraEmail.java

示例12: getDatabase

import com.thoughtworks.xstream.io.xml.DomDriver; //導入依賴的package包/類
/**
 * @return O objeto Database.
 */
public static Database getDatabase() {
    try {
        StringBuilder xml = new StringBuilder();
        Scanner scanner = new Scanner(new FileReader("database.xml"));
        while (scanner.hasNext()) {
            xml.append(scanner.next());
        }

        XStream xStream = new XStream(new DomDriver());
        Database banco = (Database) xStream.fromXML(xml.toString());

        return banco;

    } catch (FileNotFoundException ex) {
        JOptionPane.showMessageDialog(null,
                "Não foi possível estabelecer conexão com o banco.\n\n"
                + "ERRO: Arquivo database.xml não encontrado.",
                "Erro de conexão",
                JOptionPane.ERROR_MESSAGE);
        FrmConfiguraBanco configuraBanco = new FrmConfiguraBanco(null, true);
        configuraBanco.setVisible(true);
    }
    return null;
}
 
開發者ID:douglasgusson,項目名稱:pitanga-system,代碼行數:28,代碼來源:PostgreSQLDAOFactory.java

示例13: getDatabase

import com.thoughtworks.xstream.io.xml.DomDriver; //導入依賴的package包/類
/**
 * @return O objeto Database.
 */
public static Database getDatabase() {
    try {
        StringBuilder xml = new StringBuilder();
        Scanner scanner = new Scanner(new FileReader("database.xml"));
        while (scanner.hasNext()) {
            xml.append(scanner.next());
        }

        XStream xStream = new XStream(new DomDriver());
        Database banco = (Database) xStream.fromXML(xml.toString());

        return banco;

    } catch (FileNotFoundException ex) {
        JOptionPane.showMessageDialog(null,
                "Não foi possível estabelecer conexão com o banco de dados.\n\n"
                + "ERRO: Arquivo database.xml não encontrado.",
                "Erro de conexão",
                JOptionPane.ERROR_MESSAGE);
        FrmConfiguraBanco configuraBanco = new FrmConfiguraBanco(null, true);
        configuraBanco.setVisible(true);
    }
    return null;
}
 
開發者ID:douglasgusson,項目名稱:pitanga-system,代碼行數:28,代碼來源:MySQLDAOFactory.java

示例14: loadXStream

import com.thoughtworks.xstream.io.xml.DomDriver; //導入依賴的package包/類
private static XStream loadXStream() {
  XStream xstream = new XStream(new DomDriver("UTF-8")) {
    @Override
    protected MapperWrapper wrapMapper(MapperWrapper next) {
      return new MapperWrapper(next) {
        @Override
        public boolean shouldSerializeMember(@SuppressWarnings("rawtypes") Class definedIn,
            String fieldName) {
          if (definedIn == Object.class) {
            return false;
          }
          return super.shouldSerializeMember(definedIn, fieldName);
        }
      };
    }
  };
  xstream.setMode(XStream.NO_REFERENCES);
  return xstream;
}
 
開發者ID:rquast,項目名稱:swingsane,代碼行數:20,代碼來源:XStreamUtility.java

示例15: getXStream

import com.thoughtworks.xstream.io.xml.DomDriver; //導入依賴的package包/類
public static XStream getXStream() {
		if (xstream == null) {
			xstream = new XStream(new DomDriver());

			xstream.alias("ActionMessage", ActionMessage.class);
			xstream.alias("MessageHeader", MessageHeader.class);
			xstream.alias("MessageBody", MessageBody.class);
			xstream.alias("RemotingMessage", RemotingMessage.class);
			xstream.alias("CommandMessage", CommandMessage.class);
			xstream.alias("AcknowledgeMessage", AcknowledgeMessage.class);
			xstream.alias("ErrorMessage", ErrorMessage.class);
			xstream.alias("ASObject", ASObject.class);
			xstream.alias("AsyncMessage", AsyncMessage.class);
			xstream.alias("DSC", CommandMessageExt.class);
//			xstream.alias("DSK", AcknowledgeMessageExt.class);

			// Better ASObject Converter
			Mapper mapper = xstream.getMapper();
		xstream.registerConverter(new ASObjectConverter(mapper));
	}

		return xstream;
	}
 
開發者ID:nccgroup,項目名稱:AMFDSer-ngng,代碼行數:24,代碼來源:AmfXmlConverter.java


注:本文中的com.thoughtworks.xstream.io.xml.DomDriver類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。