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


Java Serializer類代碼示例

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


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

示例1: performPreFinishOperations

import org.simpleframework.xml.Serializer; //導入依賴的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.Serializer; //導入依賴的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.Serializer; //導入依賴的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.Serializer; //導入依賴的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.Serializer; //導入依賴的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.Serializer; //導入依賴的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.Serializer; //導入依賴的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.Serializer; //導入依賴的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: parseRequestToXml

import org.simpleframework.xml.Serializer; //導入依賴的package包/類
@Test
public void parseRequestToXml() throws Exception {
    WinstromRequest request = WinstromRequest.builder()
            .issuedInvoice(IssuedInvoice.builder()
                    .company("code:ABCFIRM1#")
                    .documentType("code:FAKTURA")
                    .withoutItems(true)
                    .sumWithoutVat(BigDecimal.valueOf(1000))
                    .build()).build();

    ByteArrayOutputStream result = new ByteArrayOutputStream();
    Serializer serializer = Factory.persister();
    serializer.write(request, result);

    String xml = "<winstrom version=\"1.0\">\n" +
            "  <faktura-vydana>\n" +
            "    <typDokl>code:FAKTURA</typDokl>\n" +
            "    <firma>code:ABCFIRM1#</firma>\n" +
            "    <bezPolozek>true</bezPolozek>\n" +
            "    <sumDphZakl>1000</sumDphZakl>\n" +
            "  </faktura-vydana>\n" +
            "</winstrom>";
    assertThat(result.toString()).isXmlEqualTo(xml);
}
 
開發者ID:adleritech,項目名稱:flexibee,代碼行數:25,代碼來源:WinstromRequestTest.java

示例10: LocalDateIsParsed

import org.simpleframework.xml.Serializer; //導入依賴的package包/類
@Test
public void LocalDateIsParsed() throws Exception {
    WinstromRequest envelope = WinstromRequest.builder()
            .issuedInvoice(IssuedInvoice.builder()
                    .issued(LocalDate.of(2017, 4, 2))
                    .build()).build();

    ByteArrayOutputStream result = new ByteArrayOutputStream();
    Serializer serializer = Factory.persister();
    serializer.write(envelope, result);

    String xml = "<winstrom version=\"1.0\">\n" +
            "    <faktura-vydana>\n" +
            "        <datVyst>2017-04-02</datVyst>\n" +
            "    </faktura-vydana>\n" +
            "</winstrom>";
    assertThat(result.toString()).isXmlEqualTo(xml);
}
 
開發者ID:adleritech,項目名稱:flexibee,代碼行數:19,代碼來源:IssuedInvoiceTest.java

示例11: paymentStatusIsParsedCorrectly

import org.simpleframework.xml.Serializer; //導入依賴的package包/類
@Test
public void paymentStatusIsParsedCorrectly() throws Exception {
    String xml = "<winstrom version=\"1.0\">\n" +
            "    <faktura-vydana>\n" +
            "        <stavUhrK>stavUhr.uhrazenoRucne</stavUhrK>\n" +
            "    </faktura-vydana>\n" +
            "</winstrom>\n";

    WinstromRequest envelope = WinstromRequest.builder()
            .issuedInvoice(
                    IssuedInvoice.builder()
                            .paymentStatus(PaymentStatus.MANUALLY)
                            .build()
            ).build();

    ByteArrayOutputStream result = new ByteArrayOutputStream();
    Serializer serializer = Factory.persister();
    serializer.write(envelope, result);

    assertThat(result.toString()).isXmlEqualTo(xml);
}
 
開發者ID:adleritech,項目名稱:flexibee,代碼行數:22,代碼來源:IssuedInvoiceTest.java

示例12: parseFromXmlToObject

import org.simpleframework.xml.Serializer; //導入依賴的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

示例13: validate

import org.simpleframework.xml.Serializer; //導入依賴的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

示例14: getReadSerializer

import org.simpleframework.xml.Serializer; //導入依賴的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

示例15: decode

import org.simpleframework.xml.Serializer; //導入依賴的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


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