Spec-Zone .ru
спецификации, руководства, описания, API


javax.mail
Флаги класса

java.lang.Object
  расширенный javax.mail.Flags
Все Реализованные Интерфейсы:
java.io. Сериализуемый, java.lang. Cloneable

public class Flags
расширяет java.lang. Объект
реализации java.lang. Cloneable, java.io. Сериализуемый

Флаги class представляют набор флагов на сообщении. Флаги составляются из предопределенных системных флагов, и определяемых пользователем флагов.

Системный флаг представляется Flags.Flag внутренний class. Определяемый пользователем флаг представляется как Строка. Пользовательские флаги независимы от случая.

Ряд стандартных системных флагов предопределяется. Большинство реализаций папки, как ожидают, будет поддерживать эти флаги. Некоторые реализации могут также поддерживать произвольные определяемые пользователем флаги. getPermanentFlags метод на Папке возвращает объект Флагов, который содержит все флаги, которые поддерживаются той реализацией папки.

Объект Флагов сериализуем так, чтобы (например) использование объектов Флагов в критериях поиска могло быть сериализировано наряду с критериями поиска.

Предупреждение: Сериализированные объекты этого class, возможно, не являются совместимыми с будущими выпусками API JavaMail. Текущая поддержка сериализации является подходящей для краткосрочного хранения.

Ниже примера кода иллюстрирует, как установить, исследовать и получить флаги для сообщения.


 Message m = folder.getMessage(1);
 m.setFlag(Flags.Flag.DELETED, true); // set the DELETED flag

 // Check if DELETED flag is set of this message
 if (m.isSet(Flags.Flag.DELETED))
        System.out.println("DELETED message");

 // Examine ALL system flags for this message
 Flags flags = m.getFlags();
 Flags.Flag[] sf = flags.getSystemFlags();
 for (int i = 0; i < sf.length; i++) {
        if (sf[i] == Flags.Flag.DELETED)
            System.out.println("DELETED message");
        else if (sf[i] == Flags.Flag.SEEN)
            System.out.println("SEEN message");
      ......
      ......
 }
 

Author:
John Mani, Bill Shannon
See Also:
Folder#getPermanentFlags, Serialized Form

Nested Class Summary
static class Флаги. Флаг
          This inner class represents an individual system flag.
 
Constructor Summary
Flags()
          Construct an empty Flags object.
Flags(Flags.Flag flag)
          Construct a Flags object initialized with the given system flag.
Flags(Flags flags)
          Construct a Flags object initialized with the given flags.
Flags(java.lang.String flag)
          Construct a Flags object initialized with the given user flag.
 
Method Summary
 void add(Flags.Flag flag)
          Add the specified system flag to this Flags object.
 void add(Flags f)
          Add all the flags in the given Flags object to this Flags object.
 void add(java.lang.String flag)
          Add the specified user flag to this Flags object.
 java.lang.Object clone()
          Returns a clone of this Flags object.
 boolean contains(Flags.Flag flag)
          Check whether the specified system flag is present in this Flags object.
 boolean contains(Flags f)
          Check whether all the flags in the specified Flags object are present in this Flags object.
 boolean contains(java.lang.String flag)
          Check whether the specified user flag is present in this Flags object.
 boolean equals(java.lang.Object obj)
          Check whether the two Flags objects are equal.
 Флаги. Флаг[] getSystemFlags()
          Return all the system flags in this Flags object.
 java.lang.String[] getUserFlags()
          Return all the user flags in this Flags object.
 int hashCode()
          Compute a hash code for this Flags object.
 void remove(Flags.Flag flag)
          Remove the specified system flag from this Flags object.
 void remove(Flags f)
          Remove all flags in the given Flags object from this Flags object.
 void remove(java.lang.String flag)
          Remove the specified user flag from this Flags object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Flags

public Flags()
Construct an empty Flags object.


Flags

public Flags(Flags flags)
Construct a Flags object initialized with the given flags.

Parameters:
flags - the flags for initialization

Flags

public Flags(Flags.Flag flag)
Construct a Flags object initialized with the given system flag.

Parameters:
flag - the flag for initialization

Flags

public Flags(java.lang.String flag)
Construct a Flags object initialized with the given user flag.

Parameters:
flag - the flag for initialization
Method Detail

add

public void add(Flags.Flag flag)
Add the specified system flag to this Flags object.

Parameters:
flag - the flag to add

add

public void add(java.lang.String flag)
Add the specified user flag to this Flags object.

Parameters:
flag - the flag to add

add

public void add(Flags f)
Add all the flags in the given Flags object to this Flags object.

Parameters:
f - Flags object

remove

public void remove(Flags.Flag flag)
Remove the specified system flag from this Flags object.

Parameters:
flag - the flag to be removed

remove

public void remove(java.lang.String flag)
Remove the specified user flag from this Flags object.

Parameters:
flag - the flag to be removed

remove

public void remove(Flags f)
Remove all flags in the given Flags object from this Flags object.

Parameters:
f - the flag to be removed

contains

public boolean contains(Flags.Flag flag)
Check whether the specified system flag is present in this Flags object.

Returns:
true of the given flag is present, otherwise false.

contains

public boolean contains(java.lang.String flag)
Check whether the specified user flag is present in this Flags object.

Returns:
true of the given flag is present, otherwise false.

contains

public boolean contains(Flags f)
Check whether all the flags in the specified Flags object are present in this Flags object.

Returns:
true if all flags in the given Flags object are present, otherwise false.

equals

public boolean equals(java.lang.Object obj)
Check whether the two Flags objects are equal.

Overrides:
equals in class java.lang.Object
Returns:
true if they're equal

hashCode

public int hashCode()
Compute a hash code for this Flags object.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code

getSystemFlags

public Flags.Flag[] getSystemFlags()
Return all the system flags in this Flags object. Returns an array of size zero if no flags are set.

Returns:
array of Flags.Flag objects representing system flags

getUserFlags

public java.lang.String[] getUserFlags()
Return all the user flags in this Flags object. Returns an array of size zero if no flags are set.

Returns:
array of Strings, each String represents a flag.

clone

public java.lang.Object clone()
Returns a clone of this Flags object.

Overrides:
clone in class java.lang.Object


Представьте ошибку или функцию

Copyright © 2009-2011, Oracle Corporation and/or its affiliates. All Rights Reserved. Use is subject to license terms.

Generated on 10-February-2011 12:41

free hit counter