home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Main.bin
/
FieldPosition.java
< prev
next >
Wrap
Text File
|
1998-09-22
|
4KB
|
129 lines
/*
* @(#)FieldPosition.java 1.8 97/01/29
*
* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
* (C) Copyright IBM Corp. 1996 - All Rights Reserved
*
* Portions copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved.
*
* The original version of this source code and documentation is copyrighted
* and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These
* materials are provided under terms of a License Agreement between Taligent
* and Sun. This technology is protected by multiple US and International
* patents. This notice and attribution to Taligent may not be removed.
* Taligent is a registered trademark of Taligent, Inc.
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for NON-COMMERCIAL purposes and without
* fee is hereby granted provided that this copyright notice
* appears in all copies. Please refer to the file "copyright.html"
* for further important copyright and licensing information.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
* THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*
*/
package java.text;
/**
* <code>FieldPosition</code> is a simple class used by <code>Format</code>
* and its subclasses to identify fields in formatted output. Fields are
* identified by constants, whose names typically end with <code>_FIELD</code>,
* defined in the various subclasses of <code>Format</code>. See
* <code>ERA_FIELD</code> and its friends in <code>DateFormat</code> for
* an example.
*
* <p>
* <code>FieldPosition</code> keeps track of the position of the
* field within the formatted output with two indices: the index
* of the first character of the field and the index of the last
* character of the field.
*
* <p>
* One version of the <code>format</code> method in the various
* <code>Format</code> classes requires a <code>FieldPosition</code>
* object as an argument. You use this <code>format</code> method
* to perform partial formatting or to get information about the
* formatted output (such as the position of a field).
*
* @version 1.8 01/29/97
* @author Mark Davis
* @see java.util.Format
*/
public class FieldPosition {
/**
* Input: Desired field to determine start and end offsets for.
* The meaning depends on the subclass of Format.
*/
int field = 0;
/**
* Output: End offset of field in text.
* If the field does not occur in the text, 0 is returned.
*/
int endIndex = 0;
/**
* Output: Start offset of field in text.
* If the field does not occur in the text, 0 is returned.
*/
int beginIndex = 0;
/**
* Creates a FieldPosition object for the given field. Fields are
* identified by constants, whose names typically end with _FIELD,
* in the various subclasses of Format.
*
* @see java.text.NumberFormat#INTEGER_FIELD
* @see java.text.NumberFormat#FRACTION_FIELD
* @see java.text.DateFormat#YEAR_FIELD
* @see java.text.DateFormat#MONTH_FIELD
*/
public FieldPosition(int field) {
this.field = field;
}
/**
* Retrieve the field identifier.
*/
public int getField() {
return field;
}
/**
* Retrieve the index of the first character in the requested field.
*/
public int getBeginIndex() {
return beginIndex;
}
/**
* Retrieve the index of the character following the last character in the
* requested field.
*/
public int getEndIndex() {
return endIndex;
}
/**
* Set the begin index. For use by subclasses of Format.
*/
void setBeginIndex(int bi) {
beginIndex = bi;
}
/**
* Set the end index. For use by subclasses of Format.
*/
void setEndIndex(int ei) {
endIndex = ei;
}
}