Examples of XStream


Examples of com.thoughtworks.xstream.XStream

  /**
   * Factory to create a fresh XStream instance. Use this when reading and
   * writing to a configured XML mapping
   */
  public static XStream createXStreamInstance() {
    return new XStream();
  }
View Full Code Here

Examples of com.thoughtworks.xstream.XStream

   * @see org.olat.core.commons.modules.glossary.morphService.FlexionServiceClient#getFlexions(java.lang.String,
   *      java.lang.String)
   */
  public ArrayList<String> getFlexions(String partOfSpeech, String word) {
    InputStream xmlReplyStream = retreiveXMLReply(partOfSpeech, word);
    XStream xstream = XStreamHelper.createXStreamInstance();
    xstream.alias("xml", FlexionReply.class);
    xstream.alias("wordform", String.class);
    ArrayList<String> stemWithWordforms;
    try {
      Object msReply = XStreamHelper.readObject(xstream, xmlReplyStream);
      FlexionReply flexionReply = (FlexionReply) msReply;
      // set reply status to remind it
View Full Code Here

Examples of com.thoughtworks.xstream.XStream

   
  /**
   * @see org.olat.core.commons.modules.glossary.morphService.FlexionServiceClient#getFlexions(java.lang.String, java.lang.String)
   */
  public ArrayList<String> getFlexions(String partOfSpeech, String word) {
    XStream xstream = XStreamHelper.createXStreamInstance();
    File replyFile = new File(PATH_TO_MS_REPLY_XML);
    xstream.alias("msreply",FlexionReply.class);
    xstream.alias("wordform", String.class);
    Object msReply = XStreamHelper.readObject(xstream,replyFile);
    FlexionReply flexionReply = (FlexionReply) msReply;
    ArrayList<String> stemWithWordforms = flexionReply.getStem();
    return stemWithWordforms;
  }
View Full Code Here

Examples of com.thoughtworks.xstream.XStream

   * @param glossaryFile
   * @param glossaryItemArr
   */
  private void saveToFile(VFSLeaf glossaryFile, ArrayList<GlossaryItem> glossaryItemArr) {
    // cdata-tags should be used instead of strings, overwrite writer.
    XStream xstream = new XStream(new XppDriver() {
      public HierarchicalStreamWriter createWriter(Writer out) {
        return new PrettyPrintWriter(out) {
          protected void writeText(QuickWriter writer, String text) {
            if (text.contains("<")||text.contains(">")||text.contains("&")){
              writer.write("<![CDATA[");
              writer.write(text);
              writer.write("]]>");
            } else {
              writer.write(text);
            }
          }
        };
      }
    });

    xstream.alias(XML_GLOSSARY_ITEM_NAME, GlossaryItem.class);
    glossaryItemArr = removeEmptyGlossaryItems(glossaryItemArr);
    XStreamHelper.writeObject(xstream, glossaryFile, glossaryItemArr);
  }
View Full Code Here

Examples of com.thoughtworks.xstream.XStream

   */
  @SuppressWarnings("unchecked")
  private ArrayList<GlossaryItem> loadGlossaryItemListFromFile(VFSLeaf glossaryFile) {
    ArrayList<GlossaryItem> glossaryItemList = new ArrayList<GlossaryItem>();
    if (glossaryFile == null) { return new ArrayList<GlossaryItem>(); }
    XStream xstream = XStreamHelper.createXStreamInstance();
    xstream.alias(XML_GLOSSARY_ITEM_NAME, GlossaryItem.class);
    Object glossObj = XStreamHelper.readObject(xstream, glossaryFile.getInputStream());
    if (glossObj instanceof ArrayList) {
      ArrayList<GlossaryItem> glossItemsFromFile = (ArrayList<GlossaryItem>) glossObj;
      glossaryItemList.addAll(glossItemsFromFile);
    } else {
View Full Code Here

Examples of com.thoughtworks.xstream.XStream

    deleteChecklistKeyConf(course.getCourseEnvironment().getCoursePropertyManager());
  }
 
  @Override
  public void exportNode(File exportDirectory, ICourse course) {
    XStream xstream = new XStream();
    ChecklistManager cm = ChecklistManager.getInstance();
    Checklist checklist = loadOrCreateChecklist(course.getCourseEnvironment().getCoursePropertyManager());
    Checklist copy = cm.copyChecklistInRAM(checklist);
    String exportContent = xstream.toXML(copy);
    ExportUtil.writeContentToFile(getExportFilename(), exportContent, exportDirectory, WebappHelper.getDefaultCharset());
  }
View Full Code Here

Examples of com.thoughtworks.xstream.XStream

    String importContent = FileUtils.load(importFile, WebappHelper.getDefaultCharset());
    if(importContent == null || importContent.isEmpty()) {
      return null;
    }
   
    XStream xstream = new XStream();
    Checklist checklist = (Checklist) xstream.fromXML(importContent);
    if(checklist != null) {
      checklist = ChecklistManager.getInstance().copyChecklist(checklist);
      setChecklistKey(cpm, checklist.getKey());
    }
   
View Full Code Here

Examples of com.thoughtworks.xstream.XStream

    return null;
  }
 
  @Override
  public void archiveNodeData(Locale locale, ICourse course, File exportDirectory, String charset) {
    XStream xstream = new XStream();
    Checklist checklist = loadOrCreateChecklist(course.getCourseEnvironment().getCoursePropertyManager());
    String exportContent = xstream.toXML(checklist);
    String exportFilename = ExportUtil.createFileNameWithTimeStamp("checklist_"+this.getIdent(), "xml");
    ExportUtil.writeContentToFile(exportFilename, exportContent, exportDirectory, WebappHelper.getDefaultCharset());
  }
View Full Code Here

Examples of com.thoughtworks.xstream.XStream

  private static Identity findIdentInChangingEmailWorkflow(String login){
    RegistrationManager rm = RegistrationManager.getInstance();
    List<TemporaryKey> tk = rm.loadTemporaryKeyByAction(RegistrationManager.EMAIL_CHANGE);
    if (tk != null) {
      for (TemporaryKey temporaryKey : tk) {
        XStream xml = new XStream();
        HashMap<String, String> mails = (HashMap<String, String>) xml.fromXML(temporaryKey.getEmailAddress());
        if (login.equals(mails.get("changedEMail"))) {
          return ManagerFactory.getManager().findIdentityByName(mails.get("currentEMail"));
        }
      }
    }
View Full Code Here

Examples of com.thoughtworks.xstream.XStream

      if (userPropertyHandler.getName().equals("email")) {
        RegistrationManager rm = RegistrationManager.getInstance();
        String key = this.identity.getUser().getProperty("emchangeKey", null);
        TemporaryKeyImpl tempKey = rm.loadTemporaryKeyByRegistrationKey(key);
        if (tempKey != null) {
          XStream xml = new XStream();
          HashMap<String, String> mails = (HashMap<String, String>) xml.fromXML(tempKey.getEmailAddress());
          formItem.setExampleKey("email.change.form.info", new String[] {mails.get("changedEMail")});
        }
      }
    }
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.