当前位置: 首页>>代码示例>>Java>>正文


Java Persister类代码示例

本文整理汇总了Java中org.simpleframework.xml.core.Persister的典型用法代码示例。如果您正苦于以下问题:Java Persister类的具体用法?Java Persister怎么用?Java Persister使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Persister类属于org.simpleframework.xml.core包,在下文中一共展示了Persister类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: performPreFinishOperations

import org.simpleframework.xml.core.Persister; //导入依赖的package包/类
@Override
protected void performPreFinishOperations() {
    Serializer serializer = new Persister();
    String choiceXml = getIntent().getExtras().getString(IntentUtil.EXTRA_CHOICE_XML);
    try {
        mChoice = serializer.read(Choice.class, choiceXml);
    } catch (Exception e) {
        Log.d(TAG, e.toString());
        return;
    }
    Settings settings = new Settings(this);
    mNotificationPriority = settings.notificationPriority();
    mGoHomeNewScenario = settings.goHomeNewScenario();
    mExpandNotificationsNewScenario = settings.expandNotificationsNewScenario();
    setAchievements();
    maybeAdjustProgress();
    showScenarioNotification();
    disableExistingShortcuts();
    addChoiceShortcuts();
    goHomeToHideShortcuts();
    expandNotificationsPanelDelayed();
}
 
开发者ID:nicholasrout,项目名称:shortstories,代码行数:23,代码来源:ChoiceActivity.java

示例2: addShowScenarioShortcut

import org.simpleframework.xml.core.Persister; //导入依赖的package包/类
public static Intent addShowScenarioShortcut(Context context, Choice choice) {
    Intent addShowScenarioShortcutIntent = new Intent(context, AddShowScenarioShortcutActivity.class);
    addShowScenarioShortcutIntent = IntentCompat.makeRestartActivityTask(addShowScenarioShortcutIntent.getComponent());
    addShowScenarioShortcutIntent.setAction(Intent.ACTION_VIEW);
    addShowScenarioShortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    Serializer serializer = new Persister();
    ByteArrayOutputStream choiceOutputStream = new ByteArrayOutputStream();
    try {
        serializer.write(choice, choiceOutputStream);
    } catch (Exception e) {
        Log.d(TAG, e.toString());
    }
    String choiceXml = choiceOutputStream.toString();
    addShowScenarioShortcutIntent.putExtra(EXTRA_CHOICE_XML, choiceXml);
    return addShowScenarioShortcutIntent;
}
 
开发者ID:nicholasrout,项目名称:shortstories,代码行数:17,代码来源:IntentUtil.java

示例3: init

import org.simpleframework.xml.core.Persister; //导入依赖的package包/类
public void init() {
    InputStream is = this.getClass().getResourceAsStream("/notification.config.xml");
    if (is == null) {
        logger.warn("Notification config file not found!");
        return;
    }
    Serializer serializer = new Persister();
    try {
        this.ruleList = serializer.read(NotificationRuleList.class, is);
        is.close();
    } catch (Exception e) {
        logger.error("Read configuration file error!");
        e.printStackTrace();
    }
    if (ruleList != null && ruleList.getRules() != null) {
        ruleMap = new HashMap<>();
        for (NotificationRule rule : ruleList.getRules()) {
            EventSource source = rule.getSource();
            if (!ruleMap.containsKey(source)) {
                ruleMap.put(source, new ArrayList<>());
            }
            ruleMap.get(source).add(rule);
        }
        configured = true;
    }
}
 
开发者ID:oneops,项目名称:oneops,代码行数:27,代码来源:NotificationConfigurator.java

示例4: onRenameConfiguration

import org.simpleframework.xml.core.Persister; //导入依赖的package包/类
@Override
public void onRenameConfiguration(final String newName) {
	final boolean exists = mDatabaseHelper.configurationExists(newName);
	if (exists) {
		Toast.makeText(this, R.string.uart_configuration_name_already_taken, Toast.LENGTH_LONG).show();
		return;
	}

	final String oldName = mConfiguration.getName();
	mConfiguration.setName(newName);

	try {
		final Format format = new Format(new HyphenStyle());
		final Strategy strategy = new VisitorStrategy(new CommentVisitor());
		final Serializer serializer = new Persister(strategy, format);
		final StringWriter writer = new StringWriter();
		serializer.write(mConfiguration, writer);
		final String xml = writer.toString();

		mDatabaseHelper.renameConfiguration(oldName, newName, xml);
		mWearableSynchronizer.onConfigurationAddedOrEdited(mPreferences.getLong(PREFS_CONFIGURATION, 0), mConfiguration);
		refreshConfigurations();
	} catch (final Exception e) {
		Log.e(TAG, "Error while renaming configuration", e);
	}
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:27,代码来源:UARTActivity.java

示例5: saveConfiguration

import org.simpleframework.xml.core.Persister; //导入依赖的package包/类
/**
 * Saves the given configuration in the database.
 */
private void saveConfiguration() {
	final UartConfiguration configuration = mConfiguration;
	try {
		final Format format = new Format(new HyphenStyle());
		final Strategy strategy = new VisitorStrategy(new CommentVisitor());
		final Serializer serializer = new Persister(strategy, format);
		final StringWriter writer = new StringWriter();
		serializer.write(configuration, writer);
		final String xml = writer.toString();

		mDatabaseHelper.updateConfiguration(configuration.getName(), xml);
		mWearableSynchronizer.onConfigurationAddedOrEdited(mPreferences.getLong(PREFS_CONFIGURATION, 0), configuration);
	} catch (final Exception e) {
		Log.e(TAG, "Error while creating a new configuration", e);
	}
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:20,代码来源:UARTActivity.java

示例6: obtenerInfoEscenarioSimulacion

import org.simpleframework.xml.core.Persister; //导入依赖的package包/类
public EscenarioSimulacionRobtsVictms obtenerInfoEscenarioSimulacion(String identFicheroInfoPersistencia){
         try {
              File ficheroEscenario = this.obtenerFicheroEscenario(identFicheroInfoPersistencia);
             
                if(ficheroEscenario== null){
//                    dirFicherosPersistencia.mkdir();
//                    rutaFicheroInfoPersistencia= dirFicherosPersistencia.getAbsolutePath()+"\\";
                System.out.println("El fichero   : "+ identFicheroInfoPersistencia+ " No existe " );
             
                }else {
                   Serializer serializer = new Persister();
//                 EscenarioSimulacionRobtsVictms escenario = serializer.read(EscenarioSimulacionRobtsVictms.class,ficheroEscenario, false);
                return serializer.read(EscenarioSimulacionRobtsVictms.class,ficheroEscenario, false);
//                        serializer.read(EscenarioSimulacionRobtsVictms.class,ficheroEscenario, false);
                    
                }   
                }catch (Exception e) { // catches ANY exception
        e.printStackTrace();
        }
         return null;
     }
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:22,代码来源:RecursoPersistenciaEntornosSimulacionImp1.java

示例7: obtenerInfoCasoSimulacion

import org.simpleframework.xml.core.Persister; //导入依赖的package包/类
public   InfoCasoSimulacion obtenerInfoCasoSimulacion(String identFicheroCaso) {
       try {
              File ficheroEscenario = this.obtenerFicheroCasoSimulacion(identFicheroCaso);
             
                if(ficheroEscenario== null){
//                    dirFicherosPersistencia.mkdir();
//                    rutaFicheroInfoPersistencia= dirFicherosPersistencia.getAbsolutePath()+"\\";
                System.out.println("El fichero   : "+ identFicheroCaso+ " No existe " );
             
                }else {
                   Serializer serializer = new Persister();
//                 EscenarioSimulacionRobtsVictms escenario = serializer.read(EscenarioSimulacionRobtsVictms.class,ficheroEscenario, false);
                return serializer.read(InfoCasoSimulacion.class,ficheroEscenario, false);

                    
                }   
                }catch (Exception e) { // catches ANY exception
        e.printStackTrace();
    }
         return null;
     }
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:22,代码来源:RecursoPersistenciaEntornosSimulacionImp1.java

示例8: obtenerInfoEscenarioSimulacion

import org.simpleframework.xml.core.Persister; //导入依赖的package包/类
public EscenarioSimulacionRobtsVictms obtenerInfoEscenarioSimulacion(String rutaFicheroInfoPersistencia){
         try {
              File ficheroEscenario = new File(rutaFicheroInfoPersistencia);
                if(!ficheroEscenario.exists()){
//                    dirFicherosPersistencia.mkdir();
//                    rutaFicheroInfoPersistencia= dirFicherosPersistencia.getAbsolutePath()+"\\";
                System.out.println("El fichero   : "+ rutaFicheroInfoPersistencia+ " No existe " );
             
                }else {
                   Serializer serializer = new Persister();
                return   serializer.read(EscenarioSimulacionRobtsVictms.class,ficheroEscenario, false);
                    
                }   
                }catch (Exception e) { // catches ANY exception
        e.printStackTrace();
    }
         return null;
     }
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:19,代码来源:PersistenciaVisualizadorEscenarios.java

示例9: parseFromXmlToObject

import org.simpleframework.xml.core.Persister; //导入依赖的package包/类
@Test
public void parseFromXmlToObject() throws Exception {
    String xml = "<winstrom version=\"1.0\">\n" +
        "    <interni-doklad>\n" +
        "        <typDokl>code:ID</typDokl>\n" +
        "        <datVyst>2011-01-01+01:00</datVyst>\n" +
        "        <varSym>123</varSym><!-- účet MD -->\n" +
        "    </interni-doklad>\n" +
        "</winstrom>";


    Serializer serializer = new Persister(Factory.matchers());

    WinstromRequest example = serializer.read(WinstromRequest.class, xml);

    assertThat(example.getInternalDocument()).isNotNull();
    assertThat(example.getInternalDocument().getIssued()).isEqualTo("2011-01-01");
    assertThat(example.getInternalDocument().getVariableSymbol()).isEqualTo("123");
}
 
开发者ID:adleritech,项目名称:flexibee,代码行数:20,代码来源:InternalDocumentTest.java

示例10: validate

import org.simpleframework.xml.core.Persister; //导入依赖的package包/类
public boolean validate(@NonNull final String question) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "validate");
    }

    final Serializer serializer = new Persister();

    try {

        final ValidateQueryResult result = serializer.read(ValidateQueryResult.class, question, false);
        return result.passedValidation();

    } catch (final Exception e) {
        if (DEBUG) {
            MyLog.w(CLS_NAME, "Exception");
            e.printStackTrace();
        }
    }

    return false;
}
 
开发者ID:brandall76,项目名称:Saiy-PS,代码行数:22,代码来源:ResolveWolframAlpha.java

示例11: getReadSerializer

import org.simpleframework.xml.core.Persister; //导入依赖的package包/类
private static Serializer getReadSerializer() throws Exception {
	if (readSerializer == null) {
	Log.d("hv", "Begin Creating Serializer");
       RegistryMatcher matcher = new RegistryMatcher();
       matcher.bind(Date.class, new DateFormatTransformer());

       Registry registry = new Registry();
       registry.bind(String.class, SimpleXMLStringConverter.class);
       Strategy strategy = new RegistryStrategy(registry);

       Serializer s = new Persister(strategy, matcher);
	Log.d("hv", "Done Creating Serializer");
	
	readSerializer = s;
	}
       return readSerializer;
}
 
开发者ID:Microsoft,项目名称:healthvault-java-sdk,代码行数:18,代码来源:XmlSerializer.java

示例12: decode

import org.simpleframework.xml.core.Persister; //导入依赖的package包/类
@Override
public POJO decode(Body body) throws Exception {
    Serializer serializer = new Persister();
    InputStream is =null;
    RawBody rawBody = (RawBody)body;
    POJO obj = null;
    try {
        is= new ByteArrayInputStream(rawBody.getContent());
        BufferedReader bfReader = new BufferedReader(new InputStreamReader(is));
        obj = (POJO) serializer.read(clazz,bfReader);
        Log.i("asd", "asd");
    } finally {
        if(is != null) is.close();
    }
    return obj;
}
 
开发者ID:PacktPublishing,项目名称:Asynchronous-Android-Programming,代码行数:17,代码来源:XMLConverter.java

示例13: fromXml

import org.simpleframework.xml.core.Persister; //导入依赖的package包/类
public static TagConfigImpl fromXml(final String xml) throws Exception {

    TagConfigImpl conf = null;
    StringReader sr = null;
    Serializer serializer = new Persister(new AnnotationStrategy());

    try {
      sr = new StringReader(xml);
      conf = serializer.read(TagConfigImpl.class, new StringReader(xml), false);
    } finally {

      if (sr != null) {
        sr.close();
      }
    }

    return conf;
  }
 
开发者ID:c2mon,项目名称:c2mon,代码行数:19,代码来源:TagConfigImpl.java

示例14: fromXml

import org.simpleframework.xml.core.Persister; //导入依赖的package包/类
public static AlarmValueImpl fromXml(final String xml) throws Exception {

      AlarmValueImpl alarmVal = null;
      StringReader sr = null;
      Serializer serializer = new Persister(new AnnotationStrategy());

      try {
          sr = new StringReader(xml);
          alarmVal = serializer.read(AlarmValueImpl.class, new StringReader(xml), false);
      } finally {

          if (sr != null) {
              sr.close();
          }
      }

      return alarmVal;
  }
 
开发者ID:c2mon,项目名称:c2mon,代码行数:19,代码来源:AlarmValueImpl.java

示例15: fromXml

import org.simpleframework.xml.core.Persister; //导入依赖的package包/类
public static CommandTagImpl fromXml(final String xml) throws Exception {

    CommandTagImpl commandTag = null;
    StringReader sr = null;
    Serializer serializer = new Persister(new AnnotationStrategy());

    try {
      sr = new StringReader(xml);
      commandTag = serializer.read(CommandTagImpl.class, new StringReader(xml), false);
    } finally {

      if (sr != null) {
        sr.close();
      }
    }

    return commandTag;
  }
 
开发者ID:c2mon,项目名称:c2mon,代码行数:19,代码来源:CommandTagImpl.java


注:本文中的org.simpleframework.xml.core.Persister类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。