API java : CoderResult


java.nio.charset
Class CoderResult

java.lang.Object
  extended by java.nio.charset.CoderResult

public class CoderResult
extends Object

A description of the result state of a coder.

A charset coder, that is, either a decoder or an encoder, consumes bytes (or characters) from an input buffer, translates them, and writes the resulting characters (or bytes) to an output buffer. A coding process terminates for one of four categories of reasons, which are described by instances of this class:

  • Underflow is reported when there is no more input to be processed, or there is insufficient input and additional input is required. This condition is represented by the unique result object UNDERFLOW, whose isUnderflow method returns true.

  • Overflow is reported when there is insufficient room remaining in the output buffer. This condition is represented by the unique result object OVERFLOW, whose isOverflow method returns true.

  • A malformed-input error is reported when a sequence of input units is not well-formed. Such errors are described by instances of this class whose isMalformed method returns true and whose length method returns the length of the malformed sequence. There is one unique instance of this class for all malformed-input errors of a given length.

  • An unmappable-character error is reported when a sequence of input units denotes a character that cannot be represented in the output charset. Such errors are described by instances of this class whose isUnmappable method returns true and whose length method returns the length of the input sequence denoting the unmappable character. There is one unique instance of this class for all unmappable-character errors of a given length.

For convenience, the isError method returns true for result objects that describe malformed-input and unmappable-character errors but false for those that describe underflow or overflow conditions.

Since:
1.4

Field Summary
static CoderResult OVERFLOW
          Result object indicating overflow, meaning that there is insufficient room in the output buffer.
static CoderResult UNDERFLOW
          Result object indicating underflow, meaning that either the input buffer has been completely consumed or, if the input buffer is not yet empty, that additional input is required.
 
Method Summary
 boolean isError()
          Tells whether or not this object describes an error condition.
 boolean isMalformed()
          Tells whether or not this object describes a malformed-input error.
 boolean isOverflow()
          Tells whether or not this object describes an overflow condition.
 boolean isUnderflow()
          Tells whether or not this object describes an underflow condition.
 boolean isUnmappable()
          Tells whether or not this object describes an unmappable-character error.
 int length()
          Returns the length of the erroneous input described by this object  (optional operation).
static CoderResult malformedForLength(int length)
          Static factory method that returns the unique object describing a malformed-input error of the given length.
 void throwException()
          Throws an exception appropriate to the result described by this object.
 String toString()
          Returns a string describing this coder result.
static CoderResult unmappableForLength(int length)
          Static factory method that returns the unique result object describing an unmappable-character error of the given length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNDERFLOW

public static final CoderResult UNDERFLOW
Result object indicating underflow, meaning that either the input buffer has been completely consumed or, if the input buffer is not yet empty, that additional input is required.


OVERFLOW

public static final CoderResult OVERFLOW
Result object indicating overflow, meaning that there is insufficient room in the output buffer.

Method Detail

toString

public String toString()
Returns a string describing this coder result.

Overrides:
toString in class Object
Returns:
A descriptive string

isUnderflow

public boolean isUnderflow()
Tells whether or not this object describes an underflow condition.

Returns:
true if, and only if, this object denotes underflow

isOverflow

public boolean isOverflow()
Tells whether or not this object describes an overflow condition.

Returns:
true if, and only if, this object denotes overflow

isError

public boolean isError()
Tells whether or not this object describes an error condition.

Returns:
true if, and only if, this object denotes either a malformed-input error or an unmappable-character error

isMalformed

public boolean isMalformed()
Tells whether or not this object describes a malformed-input error.

Returns:
true if, and only if, this object denotes a malformed-input error

isUnmappable

public boolean isUnmappable()
Tells whether or not this object describes an unmappable-character error.

Returns:
true if, and only if, this object denotes an unmappable-character error

length

public int length()
Returns the length of the erroneous input described by this object  (optional operation).

Returns:
The length of the erroneous input, a positive integer
Throws:
UnsupportedOperationException - If this object does not describe an error condition, that is, if the isError does not return true

malformedForLength

public static CoderResult malformedForLength(int length)
Static factory method that returns the unique object describing a malformed-input error of the given length.

Returns:
The requested coder-result object

unmappableForLength

public static CoderResult unmappableForLength(int length)
Static factory method that returns the unique result object describing an unmappable-character error of the given length.

Returns:
The requested coder-result object

throwException

public void throwException()
                    throws CharacterCodingException
Throws an exception appropriate to the result described by this object.

Throws:
BufferUnderflowException - If this object is UNDERFLOW
BufferOverflowException - If this object is OVERFLOW
MalformedInputException - If this object represents a malformed-input error; the exception's length value will be that of this object
UnmappableCharacterException - If this object represents an unmappable-character error; the exceptions length value will be that of this object
CharacterCodingException

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-1728
Document créé le 30/08/06 21:11, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-java/nio/charset/CoderResult.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,36 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Quand on a peur dans la vie, c'est parce qu'on se sait pas quelle décision prendre.

Bernard Werber [Les Thanatonautes]
 
l'infobrol
Nous sommes le Vendredi 01 Juin 2012, 21:43, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)