diff options
| author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-14 23:12:35 +0000 |
|---|---|---|
| committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-14 23:12:35 +0000 |
| commit | ffde862e033a0825e1e9972a89c0f1f80b261a8e (patch) | |
| tree | 97037d2c09c8384d80531f67ec36a01205df6bdb /libjava/classpath/javax/swing/text/TabSet.java | |
| parent | b415ff10527e977c3758234fd930e2c027bfa17d (diff) | |
| download | gcc-ffde862e033a0825e1e9972a89c0f1f80b261a8e.tar.gz | |
2006-08-14 Mark Wielaard <mark@klomp.org>
Imported GNU Classpath 0.92
* HACKING: Add more importing hints. Update automake version
requirement.
* configure.ac (gconf-peer): New enable AC argument.
Add --disable-gconf-peer and --enable-default-preferences-peer
to classpath configure when gconf is disabled.
* scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and
gnu/java/awt/dnd/peer/gtk to bc. Classify
gnu/java/security/Configuration.java as generated source file.
* gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java,
gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java,
gnu/java/lang/management/VMClassLoadingMXBeanImpl.java,
gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java,
gnu/java/lang/management/VMThreadMXBeanImpl.java,
gnu/java/lang/management/VMMemoryMXBeanImpl.java,
gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub
classes.
* java/lang/management/VMManagementFactory.java: Likewise.
* java/net/VMURLConnection.java: Likewise.
* gnu/java/nio/VMChannel.java: Likewise.
* java/lang/Thread.java (getState): Add stub implementation.
* java/lang/Class.java (isEnum): Likewise.
* java/lang/Class.h (isEnum): Likewise.
* gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed.
* javax/naming/spi/NamingManager.java: New override for StackWalker
functionality.
* configure, sources.am, Makefile.in, gcj/Makefile.in,
include/Makefile.in, testsuite/Makefile.in: Regenerated.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116139 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/javax/swing/text/TabSet.java')
| -rw-r--r-- | libjava/classpath/javax/swing/text/TabSet.java | 121 |
1 files changed, 112 insertions, 9 deletions
diff --git a/libjava/classpath/javax/swing/text/TabSet.java b/libjava/classpath/javax/swing/text/TabSet.java index ecad9444ea5..0f2c8c7c1ee 100644 --- a/libjava/classpath/javax/swing/text/TabSet.java +++ b/libjava/classpath/javax/swing/text/TabSet.java @@ -1,5 +1,5 @@ /* TabSet.java -- - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,23 +39,54 @@ package javax.swing.text; import java.io.Serializable; +/** + * A set of tab stops. Instances of this class are immutable. + */ public class TabSet implements Serializable { /** The serialization UID (compatible with JDK1.5). */ private static final long serialVersionUID = 2367703481999080593L; + /** Storage for the tab stops. */ TabStop[] tabs; + /** + * Creates a new <code>TabSet</code> containing the specified tab stops. + * + * @param t the tab stops (<code>null</code> permitted). + */ public TabSet(TabStop[] t) { - tabs = t; + if (t != null) + tabs = (TabStop[]) t.clone(); + else + tabs = new TabStop[0]; } + /** + * Returns the tab stop with the specified index. + * + * @param i the index. + * + * @return The tab stop. + * + * @throws IllegalArgumentException if <code>i</code> is not in the range + * <code>0</code> to <code>getTabCount() - 1</code>. + */ public TabStop getTab(int i) { + if (i < 0 || i >= tabs.length) + throw new IllegalArgumentException("Index out of bounds."); return tabs[i]; } + /** + * Returns the tab following the specified location. + * + * @param location the location. + * + * @return The tab following the specified location (or <code>null</code>). + */ public TabStop getTabAfter(float location) { int idx = getTabIndexAfter(location); @@ -65,11 +96,23 @@ public class TabSet implements Serializable return tabs[idx]; } + /** + * Returns the number of tab stops in this tab set. + * + * @return The number of tab stops in this tab set. + */ public int getTabCount() { return tabs.length; } + /** + * Returns the index of the specified tab, or -1 if the tab is not found. + * + * @param tab the tab (<code>null</code> permitted). + * + * @return The index of the specified tab, or -1. + */ public int getTabIndex(TabStop tab) { for (int i = 0; i < tabs.length; ++i) @@ -78,28 +121,88 @@ public class TabSet implements Serializable return -1; } + /** + * Returns the index of the tab at or after the specified location. + * + * @param location the tab location. + * + * @return The index of the tab stop, or -1. + */ public int getTabIndexAfter(float location) { - int idx = -1; - for (int i = 0; i < tabs.length; ++i) + for (int i = 0; i < tabs.length; i++) + { + if (location <= tabs[i].getPosition()) + return i; + } + return -1; + } + + /** + * Tests this <code>TabSet</code> for equality with an arbitrary object. + * + * @param obj the object (<code>null</code> permitted). + * + * @return <code>true</code> if this <code>TabSet</code> is equal to + * <code>obj</code>, and <code>false</code> otherwise. + * + * @since 1.5 + */ + public boolean equals(Object obj) + { + if (obj == this) + return true; + if (!(obj instanceof TabSet)) + return false; + TabSet that = (TabSet) obj; + int tabCount = getTabCount(); + if (tabCount != that.getTabCount()) + return false; + for (int i = 0; i < tabCount; i++) + { + if (!this.getTab(i).equals(that.getTab(i))) + return false; + } + return true; + } + + /** + * Returns a hash code for this <code>TabSet</code>. + * + * @return A hash code. + * + * @since 1.5 + */ + public int hashCode() + { + // this hash code won't match Sun's, but that shouldn't matter... + int result = 193; + int tabs = getTabCount(); + for (int i = 0; i < tabs; i++) { - if (location < tabs[i].getPosition()) - idx = i; + TabStop t = getTab(i); + if (t != null) + result = 37 * result + t.hashCode(); } - return idx; + return result; } + /** + * Returns a string representation of this <code>TabSet</code>. + * + * @return A string representation of this <code>TabSet</code>. + */ public String toString() { StringBuffer sb = new StringBuffer(); - sb.append("["); + sb.append("[ "); for (int i = 0; i < tabs.length; ++i) { if (i != 0) sb.append(" - "); sb.append(tabs[i].toString()); } - sb.append("]"); + sb.append(" ]"); return sb.toString(); } } |
