本文整理汇总了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();
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}