⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 castorpreferences.java

📁 java windows mda and reveus
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
  /**   * Sets the language of this <tt>JwmaPreferences</tt>.   *   * @param str the language locale as <tt>String</tt>.   */  public void setLanguage(String str) {    m_Locale = new Locale(str, "");  }//setLanguage  public Locale getLocale() {    return m_Locale;  }//getLocale  public void setLocale(Locale locale) {    m_Locale = locale;    m_DateFormat =        (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, m_Locale);  }//setLocale  public String getContactDatabaseID() {    return m_ContactDatabase;  }//getContactDatabaseID  public void setContactDatabaseID(String dbid) {    m_ContactDatabase = dbid;  }//setContactDatabaseID  public void setMessageProcessorName(String name) {    //fetch the processor or pipe from the kernel    m_MessageProcessor =        JwmaKernel.getReference().getMessageProcessor(name);  }//setMessageProcessorName  public String getMessageProcessorName() {    if (m_MessageProcessor == null) {      return "";    } else {      return m_MessageProcessor.getName();    }  }//getMessageProcessorName  public Processor getMessageProcessor() {    return m_MessageProcessor;  }//getMessageProcessor  public void setMessageProcessor(Processor processor) {    if (processor != null) {      m_MessageProcessor = processor;    }  }//getMessageProcessor  public DateFormat getDateFormat() {    return m_DateFormat;  }//getDateFormat  public void setDateFormat(SimpleDateFormat dateformat) {    m_DateFormat = dateformat;  }//setDateFormat  public String getDateFormatPattern() {    return m_DateFormat.toPattern();  }//getDateFormatPattern  public void setDateFormatPattern(String pattern) {    try {      m_DateFormat.applyPattern(pattern);    } catch (Exception ex) {      //stick with the default    }  }//setDateFormatPattern  public void setDefaultMailIdentity(String uid) {    m_DefaultMailIdentity = uid;    //log.debug("Set default mail identity="+uid);  }//setDefaultMailIdentity  public String getDefaultMailIdentity() {    //log.debug("Get default mail identity="+m_DefaultMailIdentity);    return m_DefaultMailIdentity;  }//getDefaultMailIdentity  public JwmaMailIdentity getMailIdentity() {    return getMailIdentity(m_DefaultMailIdentity);  }//getMailIdentity  public Collection getMailIdentityCollection() {    //log.debug("Getting mail identities.");    return m_MailIdentities;  }//getMailIdentityCollection  public void setMailIdentityCollection(Collection collection) {    //log.debug("Setting mail identities.");    m_MailIdentities = Collections.synchronizedList(        new ArrayList(collection));    //ensure order    //Collections.sort(m_MailIdentities,SortingUtil.INDEX_INCREASING);  }//setMailIdentityCollection  public List getMailIdentities() {    return m_MailIdentities;  }//getMailIdentities  public JwmaMailIdentity[] listMailIdentities() {    JwmaMailIdentity[] addr = new JwmaMailIdentity[m_MailIdentities.size()];    return (JwmaMailIdentity[]) m_MailIdentities.toArray(addr);  }//listMailIdentities  public boolean existsMailIdentity(String uid) {    for (Iterator iter = m_MailIdentities.iterator(); iter.hasNext();) {      CastorMailIdentity mid = (CastorMailIdentity) iter.next();      if (mid.equals(uid)) {        return true;      }    }    return false;  }//existsMailIdentity  public JwmaMailIdentity getMailIdentity(String uid) {    for (Iterator iter = m_MailIdentities.iterator(); iter.hasNext();) {      CastorMailIdentity mid = (CastorMailIdentity) iter.next();      if (mid.equals(uid)) {        return mid;      }    }    return getMailIdentity(m_DefaultMailIdentity);  }//getMailIdentity  public void addMailIdentity(JwmaMailIdentity identity) {    m_MailIdentities.add(identity);    ((CastorMailIdentity) identity).setAssociatorUID(this.getUID());  }//addMailIdentity  public void removeMailIdentity(String uid) {    for (Iterator iter = m_MailIdentities.iterator(); iter.hasNext();) {      CastorMailIdentity mid = (CastorMailIdentity) iter.next();      if (mid.equals(uid)) {        iter.remove();        mid.resetAssociatorUID();        m_RemovedAssociations.add(mid);      }    }  }//removeMailIdentity  public int getMailIdentityCount() {    return m_MailIdentities.size();  }//getMailIdentityCount  public boolean isExpert() {    return m_Expert;  }//isExpert  public void setExpert(boolean b) {    m_Expert = b;  }//setExpert  public void setStyle(String style) {    m_Style = style;  }//setStyle  public String getStyle() {    return m_Style;  }//getStyle  public boolean isDisplayingInlined() {    return m_DisplayingInlined;  }//isDisplayingInlined  public void setDisplayingInlined(boolean b) {    m_DisplayingInlined = b;  }//setDisplayingInlined  public int getMessageSortCriteria() {    return m_MessageSortCriteria;  }//getMessageSortCriteria  public void setMessageSortCriteria(int messageSortCriteria) {    m_MessageSortCriteria = messageSortCriteria;  }//setMessageSortCriteria  public JwmaMailIdentityImpl createMailIdentity() {    return new CastorMailIdentity();  }//createMailIdentity  /**   * Returns a clone of this preferences.   *   * @return the clone, or null if the cloning process failed.   */  public JwmaPreferencesImpl getClone() {    try {      CastorPreferences pref = (CastorPreferences) this.clone();      //assign it it's own unique identifier      pref.setUID("");      //clear the mail identities      m_MailIdentities.clear();      //add up a default mail identity      CastorMailIdentity mid = new CastorMailIdentity();      //with some sense making values      mid.setName("Default");      mid.setFrom(getUserIdentity());      pref.addMailIdentity(mid);      pref.setDefaultMailIdentity(mid.getUID());      //FIX: ensures a set message processor      pref.setMessageProcessorName(pref.getMessageProcessorName());      return pref;    } catch (Exception ex) {      return null;    }  }//getClone  public List getRemovedAssociations() {    return m_RemovedAssociations;  }//getRemovedAssociations  public void updatePreferences(Database db)      throws PersistenceException {    m_Update = true;    try {      persistPreferences(db);    } finally {      m_Update = false;    }  }//updateDatabase  public void persistPreferences(Database db)      throws PersistenceException {    //1. store this    storeObject(db, this);    //3. iterate over identities, ensure order by indexing    int i = 0;    for (Iterator iter = m_MailIdentities.listIterator(); iter.hasNext(); i++) {      //Object next=iter.next();      //((Indexable)next).setIndex(i);      storeObject(db, iter.next());    }  }//persistPreferences  private void storeObject(Database db, Object o)      throws PersistenceException {    if (db == null || o == null) {      return;    } else if (db.isPersistent(o) || m_Update) {      log.debug(JwmaKernel.getReference().getLogMessage("jwma.plugin.castor.objupdate") + o.toString());      if (o instanceof Associator) {        cleanupAssociations(db, ((Associator) o).getRemovedAssociations());      }      db.update(o);    } else {      log.debug(JwmaKernel.getReference().getLogMessage("jwma.plugin.castor.objcreate") + o.toString());      db.create(o);    }  }//storeObject  private void cleanupAssociations(Database db, List l)      throws PersistenceException {    Object o = null;    for (Iterator iter = l.iterator(); iter.hasNext();) {      AssociatedAbstractIdentifiable assoc =          (AssociatedAbstractIdentifiable) iter.next();      //check if object has an association      if (!assoc.isAssociated()) {        log.debug(            JwmaKernel.getReference().getLogMessage("jwma.plugin.castor.objremove") +            assoc.getClass() +            " " +            assoc.toString()        );        //needs to be loaded in this transaction :( hack but works        try {          o = db.load(assoc.getClass(), assoc.getUID());        } catch (PersistenceException pex) {          /*more hack, required to work*/        }        db.remove(o);      }    }    //and definately, remove the references    l.clear();  }//cleanupAssociations  public long jdoGetTimeStamp() {    return m_Timestamp;  }//jdoGetTimeStamp  public void jdoSetTimeStamp(long timeStamp) {    m_Timestamp = timeStamp;  }//jdoSetTimeStamp}//class JwmaPreferencesImpl

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -