java fieldposition_FieldPosition.html

FieldPosition (Java Platform SE 7 )

if (location.href.indexOf('is-external=true') == -1) {

parent.document.title="FieldPosition (Java Platform SE 7 )";

}

//-->

JavaScript is disabled on your browser.
Java™ Platform
Standard Ed. 7
java.text

Class FieldPosition


  • public class FieldPosition

    extends Object

    FieldPosition is a simple class used by Format

    and its subclasses to identify fields in formatted output. Fields can

    be identified in two ways:

    • By an integer constant, whose names typically end with

      _FIELD. The constants are defined in the various

      subclasses of Format.

    • By a Format.Field constant, see ERA_FIELD

      and its friends in DateFormat for an example.

    FieldPosition 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.

    One version of the format method in the various

    Format classes requires a FieldPosition

    object as an argument. You use this format method

    to perform partial formatting or to get information about the

    formatted output (such as the position of a field).

    If you are interested in the positions of all attributes in the

    formatted string use the Format method

    formatToCharacterIterator.

    See Also:
    Format
    • Constructor Detail

      • FieldPosition
        public FieldPosition(Format.Field attribute)
        Creates a FieldPosition object for the given field constant. Fields are

        identified by constants defined in the various Format

        subclasses. This is equivalent to calling

        new FieldPosition(attribute, -1).

        Parameters:
        attribute - Format.Field constant identifying a field
        Since:
        1.4

      • FieldPosition
        public FieldPosition(Format.Field attribute,

        int fieldID)

        Creates a FieldPosition object for the given field.

        The field is identified by an attribute constant from one of the

        Field subclasses as well as an integer field ID

        defined by the Format subclasses. Format

        subclasses that are aware of Field should give precedence

        to attribute and ignore fieldID if

        attribute is not null. However, older Format

        subclasses may not be aware of Field and rely on

        fieldID. If the field has no corresponding integer

        constant, fieldID should be -1.

        Parameters:
        attribute - Format.Field constant identifying a field
        fieldID - integer constantce identifying a field
        Since:
        1.4
    • Method Detail

      • getFieldAttribute
        public Format.Field getFieldAttribute()
        Returns the field identifier as an attribute constant

        from one of the Field subclasses. May return null if

        the field is specified only by an integer field ID.

        Returns:
        Identifier for the field
        Since:
        1.4

      • getField
        public int getField()
        Retrieves the field identifier.

      • getBeginIndex
        public int getBeginIndex()
        Retrieves the index of the first character in the requested field.

      • getEndIndex
        public int getEndIndex()
        Retrieves the index of the character following the last character in the

        requested field.

      • setBeginIndex
        public void setBeginIndex(int bi)
        Sets the begin index. For use by subclasses of Format.
        Since:
        1.2

      • setEndIndex
        public void setEndIndex(int ei)
        Sets the end index. For use by subclasses of Format.
        Since:
        1.2

      • equals
        public boolean equals(Object obj)
        Overrides equals
        Overrides:
        equals in class  Object
        Parameters:
        obj - the reference object with which to compare.
        Returns:
        true if this object is the same as the obj

        argument; false otherwise.

        See Also:
        Object.hashCode(),

        HashMap

      • toString
        public String toString()
        Return a string representation of this FieldPosition.
        Overrides:
        toString in class  Object
        Returns:
        a string representation of this object
Java™ Platform
Standard Ed. 7

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值