home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1998 November
/
Chip_1998-11_cd.bin
/
tema
/
Cafe
/
jfc.bin
/
Segment.java
< prev
next >
Wrap
Text File
|
1998-02-26
|
2KB
|
85 lines
/*
* @(#)Segment.java 1.6 97/12/09
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* 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 com.sun.java.swing.text;
/**
* A segment of a character array representing a fragment
* of text. It should be treated as immutable even though
* the array is directly accessable. This gives fast access
* to fragments of text without the overhead of copying
* around characters. This is effectively an unprotected
* String.
*/
public class Segment {
/**
* This is the array containing the text of
* interest. This array should never be modified;
* it is available only for efficiency.
*/
public char[] array;
/**
* This is the offset into the array that
* the desired text begins.
*/
public int offset;
/**
* This is the number of array elements that
* make up the text of interest.
*/
public int count;
/**
* Creates a new segment.
*/
public Segment() {
array = null;
offset = 0;
count = 0;
}
/**
* Creates a new segment referring to an existing array.
*
* @param array the array to refer to
* @param offset the offset into the array
* @param count the number of characters
*/
public Segment(char[] array, int offset, int count) {
this.array = array;
this.offset = offset;
this.count = count;
}
/**
* Converts a segment into a String.
*
* @return the string
*/
public String toString() {
return new String(array, offset, count);
}
}