API java : InternetHeaders


javax.mail.internet
Class InternetHeaders

java.lang.Object
  extended by javax.mail.internet.InternetHeaders

public class InternetHeaders
extends Object

InternetHeaders is a utility class that manages RFC822 style headers. Given an RFC822 format message stream, it reads lines until the blank line that indicates end of header. The input stream is positioned at the start of the body. The lines are stored within the object and can be extracted as either Strings or Header objects.

This class is mostly intended for service providers. MimeMessage and MimeBody use this class for holding their headers.


A note on RFC822 and MIME headers

RFC822 and MIME header fields must contain only US-ASCII characters. If a header contains non US-ASCII characters, it must be encoded as per the rules in RFC 2047. The MimeUtility class provided in this package can be used to to achieve this. Callers of the setHeader, addHeader, and addHeaderLine methods are responsible for enforcing the MIME requirements for the specified headers. In addition, these header fields must be folded (wrapped) before being sent if they exceed the line length limitation for the transport (1000 bytes for SMTP). Received headers may have been folded. The application is responsible for folding and unfolding headers as appropriate.

Author:
John Mani, Bill Shannon
See Also:
MimeUtility

Nested Class Summary
protected static class InternetHeaders.InternetHeader
          An individual internet header.
 
Field Summary
protected  List headers
          The actual list of Headers, including placeholder entries.
 
Constructor Summary
InternetHeaders()
          Create an empty InternetHeaders object.
InternetHeaders(InputStream is)
          Read and parse the given RFC822 message stream till the blank line separating the header from the body.
 
Method Summary
 void addHeader(String name, String value)
          Add a header with the specified name and value to the header list.
 void addHeaderLine(String line)
          Add an RFC822 header line to the header store.
 Enumeration getAllHeaderLines()
          Return all the header lines as an Enumeration of Strings.
 Enumeration getAllHeaders()
          Return all the headers as an Enumeration of Header objects.
 String[] getHeader(String name)
          Return all the values for the specified header.
 String getHeader(String name, String delimiter)
          Get all the headers for this header name, returned as a single String, with headers separated by the delimiter.
 Enumeration getMatchingHeaderLines(String[] names)
          Return all matching header lines as an Enumeration of Strings.
 Enumeration getMatchingHeaders(String[] names)
          Return all matching Header objects.
 Enumeration getNonMatchingHeaderLines(String[] names)
          Return all non-matching header lines
 Enumeration getNonMatchingHeaders(String[] names)
          Return all non-matching Header objects.
 void load(InputStream is)
          Read and parse the given RFC822 message stream till the blank line separating the header from the body.
 void removeHeader(String name)
          Remove all header entries that match the given name
 void setHeader(String name, String value)
          Change the first header line that matches name to have value, adding a new header if no existing header matches.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

headers

protected List headers
The actual list of Headers, including placeholder entries. Placeholder entries are Headers with a null value and are never seen by clients of the InternetHeaders class. Placeholder entries are used to keep track of the preferred order of headers. Headers are never actually removed from the list, they're converted into placeholder entries. New headers are added after existing headers of the same name (or before in the case of Received and Return-Path headers). If no existing header or placeholder for the header is found, new headers are added after the special placeholder with the name ":".

Since:
JavaMail 1.4
Constructor Detail

InternetHeaders

public InternetHeaders()
Create an empty InternetHeaders object. Placeholder entries are inserted to indicate the preferred order of headers.


InternetHeaders

public InternetHeaders(InputStream is)
                throws MessagingException
Read and parse the given RFC822 message stream till the blank line separating the header from the body. The input stream is left positioned at the start of the body. The header lines are stored internally.

For efficiency, wrap a BufferedInputStream around the actual input stream and pass it as the parameter.

No placeholder entries are inserted; the original order of the headers is preserved.

Parameters:
is - RFC822 input stream
Throws:
MessagingException
Method Detail

load

public void load(InputStream is)
          throws MessagingException
Read and parse the given RFC822 message stream till the blank line separating the header from the body. Store the header lines inside this InternetHeaders object. The order of header lines is preserved.

Note that the header lines are added into this InternetHeaders object, so any existing headers in this object will not be affected. Headers are added to the end of the existing list of headers, in order.

Parameters:
is - RFC822 input stream
Throws:
MessagingException

getHeader

public String[] getHeader(String name)
Return all the values for the specified header. The values are String objects. Returns null if no headers with the specified name exist.

Parameters:
name - header name
Returns:
array of header values, or null if none

getHeader

public String getHeader(String name,
                        String delimiter)
Get all the headers for this header name, returned as a single String, with headers separated by the delimiter. If the delimiter is null, only the first header is returned. Returns null if no headers with the specified name exist.

Parameters:
name - header name
delimiter - delimiter
Returns:
the value fields for all headers with this name, or null if none

setHeader

public void setHeader(String name,
                      String value)
Change the first header line that matches name to have value, adding a new header if no existing header matches. Remove all matching headers but the first.

Note that RFC822 headers can only contain US-ASCII characters

Parameters:
name - header name
value - header value

addHeader

public void addHeader(String name,
                      String value)
Add a header with the specified name and value to the header list.

The current implementation knows about the preferred order of most well-known headers and will insert headers in that order. In addition, it knows that Received headers should be inserted in reverse order (newest before oldest), and that they should appear at the beginning of the headers, preceeded only by a possible Return-Path header.

Note that RFC822 headers can only contain US-ASCII characters.

Parameters:
name - header name
value - header value

removeHeader

public void removeHeader(String name)
Remove all header entries that match the given name

Parameters:
name - header name

getAllHeaders

public Enumeration getAllHeaders()
Return all the headers as an Enumeration of Header objects.

Returns:
Header objects

getMatchingHeaders

public Enumeration getMatchingHeaders(String[] names)
Return all matching Header objects.

Returns:
matching Header objects

getNonMatchingHeaders

public Enumeration getNonMatchingHeaders(String[] names)
Return all non-matching Header objects.

Returns:
non-matching Header objects

addHeaderLine

public void addHeaderLine(String line)
Add an RFC822 header line to the header store. If the line starts with a space or tab (a continuation line), add it to the last header line in the list. Otherwise, append the new header line to the list.

Note that RFC822 headers can only contain US-ASCII characters

Parameters:
line - raw RFC822 header line

getAllHeaderLines

public Enumeration getAllHeaderLines()
Return all the header lines as an Enumeration of Strings.


getMatchingHeaderLines

public Enumeration getMatchingHeaderLines(String[] names)
Return all matching header lines as an Enumeration of Strings.


getNonMatchingHeaderLines

public Enumeration getNonMatchingHeaderLines(String[] names)
Return all non-matching header lines


Ces informations proviennent du site de http://java.sun.com

Remarques

Contenu

Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :

Quels sont les motivations de cette démarche?

Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.

Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.

Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.

Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.

Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

7 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-13060
Document créé le 19/04/08 22:15, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-javaee-rf-javax/mail/internet/InternetHeaders.html Document affiché 1 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,44 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Celui qui n'a pas peur n'est pas normal ; ça n'a rien à voir avec le courage.

Jean-Paul Sartre
 
l'infobrol
Nous sommes le Vendredi 01 Juin 2012, 09:59, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)