javax.mail

Class Flags

  • All Implemented Interfaces:
    Serializable, Cloneable

    public class Flags
    extends Object
    implements Cloneable, Serializable
    The Flags class represents the set of flags on a Message. Flags are composed of predefined system flags, and user defined flags.

    A System flag is represented by the Flags.Flag inner class. A User defined flag is represented as a String. User flags are case-independent.

    A set of standard system flags are predefined. Most folder implementations are expected to support these flags. Some implementations may also support arbitrary user-defined flags. The getPermanentFlags method on a Folder returns a Flags object that holds all the flags that are supported by that folder implementation.

    A Flags object is serializable so that (for example) the use of Flags objects in search terms can be serialized along with the search terms.

    Warning: Serialized objects of this class may not be compatible with future JavaMail API releases. The current serialization support is appropriate for short term storage.

    The below code sample illustrates how to set, examine, and get the flags for a message.

    
     Message m = folder.getMessage(1);
     m.setFlag(Flags.Flag.DELETED, true); // set the DELETED flag
    
     // Check if DELETED flag is set on 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
    • 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(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(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(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(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(Object obj)
        Check whether the two Flags objects are equal.
        Overrides:
        equals in class Object
        Returns:
        true if they're equal
      • hashCode

        public int hashCode()
        Compute a hash code for this Flags object.
        Overrides:
        hashCode in class 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 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 Object clone()
        Returns a clone of this Flags object.
        Overrides:
        clone in class Object

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 11/06/2005, zuletzt geändert 18/08/2025
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-javaee-rf-javax/mail/Flags.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:fr Manuel PHP : https://docs.oracle.com, Flags (Java(TM) EE 7 Specification APIs)

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.