APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.text

pack-priv Class SegmentCache

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Arrays, .List

SegmentCache caches Segments to avoid continually creating and destroying of Segments. A common use of this class would be:
  Segment segment = segmentCache.getSegment();
  // do something with segment
  ...
  segmentCache.releaseSegment(segment);

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
SegmentCache.CachedSegment

CachedSegment is used as a tagging interface to determine if a Segment can successfully be shared.

Field Summary

Modifier and TypeField and Description
private List<Segment>
segments

A list of the currently unused Segments.

private static SegmentCache
sharedCache

A global cache.

Constructor Summary

AccessConstructor and Description
public
SegmentCache()

Creates and returns a SegmentCache.

Method Summary

Modifier and TypeMethod and Description
public Segment
getSegment()

Returns a Segment.

public static SegmentCache
getSharedInstance()

Returns the shared SegmentCache.

public static Segment
getSharedSegment()

A convenience method to get a Segment from the shared SegmentCache.

public void
releaseSegment(Segment segment)

Releases a Segment.

public static void
releaseSharedSegment(Segment segment)

A convenience method to release a Segment to the shared SegmentCache.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

segmentsback to summary
private List<Segment> segments

A list of the currently unused Segments.

sharedCacheback to summary
private static SegmentCache sharedCache

A global cache.

Constructor Detail

SegmentCacheback to summary
public SegmentCache()

Creates and returns a SegmentCache.

Method Detail

getSegmentback to summary
public Segment getSegment()

Returns a Segment. When done, the Segment should be recycled by invoking releaseSegment.

getSharedInstanceback to summary
public static SegmentCache getSharedInstance()

Returns the shared SegmentCache.

getSharedSegmentback to summary
public static Segment getSharedSegment()

A convenience method to get a Segment from the shared SegmentCache.

releaseSegmentback to summary
public void releaseSegment(Segment segment)

Releases a Segment. You should not use a Segment after you release it, and you should NEVER release the same Segment more than once, eg:

  segmentCache.releaseSegment(segment);
  segmentCache.releaseSegment(segment);
Will likely result in very bad things happening!
releaseSharedSegmentback to summary
public static void releaseSharedSegment(Segment segment)

A convenience method to release a Segment to the shared SegmentCache.

javax.swing.text back to summary

private Class SegmentCache.CachedSegment

extends Segment
Class Inheritance

CachedSegment is used as a tagging interface to determine if a Segment can successfully be shared.

Field Summary

Inherited from javax.swing.text.Segment:
arraycopycountoffset

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from javax.swing.text.Segment:
charAtclonecurrentfirstgetBeginIndexgetEndIndexgetIndexisPartialReturnlastlengthnextprevioussetIndexsetPartialReturnsubSequencetoString

Constructor Detail

CachedSegmentback to summary
private CachedSegment()