Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/accessibility/AccessibleRelation.java
38829 views
/*1* Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.accessibility;2627import java.util.Vector;28import java.util.Locale;29import java.util.MissingResourceException;30import java.util.ResourceBundle;3132/**33* <P>Class AccessibleRelation describes a relation between the34* object that implements the AccessibleRelation and one or more other35* objects. The actual relations that an object has with other36* objects are defined as an AccessibleRelationSet, which is a composed37* set of AccessibleRelations.38* <p>The toDisplayString method allows you to obtain the localized string39* for a locale independent key from a predefined ResourceBundle for the40* keys defined in this class.41* <p>The constants in this class present a strongly typed enumeration42* of common object roles. If the constants in this class are not sufficient43* to describe the role of an object, a subclass should be generated44* from this class and it should provide constants in a similar manner.45*46* @author Lynn Monsanto47* @since 1.348*/49public class AccessibleRelation extends AccessibleBundle {5051/*52* The group of objects that participate in the relation.53* The relation may be one-to-one or one-to-many. For54* example, in the case of a LABEL_FOR relation, the target55* vector would contain a list of objects labeled by the object56* that implements this AccessibleRelation. In the case of a57* MEMBER_OF relation, the target vector would contain all58* of the components that are members of the same group as the59* object that implements this AccessibleRelation.60*/61private Object [] target = new Object[0];6263/**64* Indicates an object is a label for one or more target objects.65*66* @see #getTarget67* @see #CONTROLLER_FOR68* @see #CONTROLLED_BY69* @see #LABELED_BY70* @see #MEMBER_OF71*/72public static final String LABEL_FOR = new String("labelFor");7374/**75* Indicates an object is labeled by one or more target objects.76*77* @see #getTarget78* @see #CONTROLLER_FOR79* @see #CONTROLLED_BY80* @see #LABEL_FOR81* @see #MEMBER_OF82*/83public static final String LABELED_BY = new String("labeledBy");8485/**86* Indicates an object is a member of a group of one or more87* target objects.88*89* @see #getTarget90* @see #CONTROLLER_FOR91* @see #CONTROLLED_BY92* @see #LABEL_FOR93* @see #LABELED_BY94*/95public static final String MEMBER_OF = new String("memberOf");9697/**98* Indicates an object is a controller for one or more target99* objects.100*101* @see #getTarget102* @see #CONTROLLED_BY103* @see #LABEL_FOR104* @see #LABELED_BY105* @see #MEMBER_OF106*/107public static final String CONTROLLER_FOR = new String("controllerFor");108109/**110* Indicates an object is controlled by one or more target111* objects.112*113* @see #getTarget114* @see #CONTROLLER_FOR115* @see #LABEL_FOR116* @see #LABELED_BY117* @see #MEMBER_OF118*/119public static final String CONTROLLED_BY = new String("controlledBy");120121/**122* Indicates an object is logically contiguous with a second123* object where the second object occurs after the object.124* An example is a paragraph of text that runs to the end of125* a page and continues on the next page with an intervening126* text footer and/or text header. The two parts of127* the paragraph are separate text elements but are related128* in that the second element is a continuation129* of the first130* element. In other words, the first element "flows to"131* the second element.132*133* @since 1.5134*/135public static final String FLOWS_TO = "flowsTo";136137/**138* Indicates an object is logically contiguous with a second139* object where the second object occurs before the object.140* An example is a paragraph of text that runs to the end of141* a page and continues on the next page with an intervening142* text footer and/or text header. The two parts of143* the paragraph are separate text elements but are related144* in that the second element is a continuation of the first145* element. In other words, the second element "flows from"146* the second element.147*148* @since 1.5149*/150public static final String FLOWS_FROM = "flowsFrom";151152/**153* Indicates that an object is a subwindow of one or more154* objects.155*156* @since 1.5157*/158public static final String SUBWINDOW_OF = "subwindowOf";159160/**161* Indicates that an object is a parent window of one or more162* objects.163*164* @since 1.5165*/166public static final String PARENT_WINDOW_OF = "parentWindowOf";167168/**169* Indicates that an object has one or more objects170* embedded in it.171*172* @since 1.5173*/174public static final String EMBEDS = "embeds";175176/**177* Indicates that an object is embedded in one or more178* objects.179*180* @since 1.5181*/182public static final String EMBEDDED_BY = "embeddedBy";183184/**185* Indicates that an object is a child node of one186* or more objects.187*188* @since 1.5189*/190public static final String CHILD_NODE_OF = "childNodeOf";191192/**193* Identifies that the target group for a label has changed194*/195public static final String LABEL_FOR_PROPERTY = "labelForProperty";196197/**198* Identifies that the objects that are doing the labeling have changed199*/200public static final String LABELED_BY_PROPERTY = "labeledByProperty";201202/**203* Identifies that group membership has changed.204*/205public static final String MEMBER_OF_PROPERTY = "memberOfProperty";206207/**208* Identifies that the controller for the target object has changed209*/210public static final String CONTROLLER_FOR_PROPERTY = "controllerForProperty";211212/**213* Identifies that the target object that is doing the controlling has214* changed215*/216public static final String CONTROLLED_BY_PROPERTY = "controlledByProperty";217218/**219* Indicates the FLOWS_TO relation between two objects220* has changed.221*222* @since 1.5223*/224public static final String FLOWS_TO_PROPERTY = "flowsToProperty";225226/**227* Indicates the FLOWS_FROM relation between two objects228* has changed.229*230* @since 1.5231*/232public static final String FLOWS_FROM_PROPERTY = "flowsFromProperty";233234/**235* Indicates the SUBWINDOW_OF relation between two or more objects236* has changed.237*238* @since 1.5239*/240public static final String SUBWINDOW_OF_PROPERTY = "subwindowOfProperty";241242/**243* Indicates the PARENT_WINDOW_OF relation between two or more objects244* has changed.245*246* @since 1.5247*/248public static final String PARENT_WINDOW_OF_PROPERTY = "parentWindowOfProperty";249250/**251* Indicates the EMBEDS relation between two or more objects252* has changed.253*254* @since 1.5255*/256public static final String EMBEDS_PROPERTY = "embedsProperty";257258/**259* Indicates the EMBEDDED_BY relation between two or more objects260* has changed.261*262* @since 1.5263*/264public static final String EMBEDDED_BY_PROPERTY = "embeddedByProperty";265266/**267* Indicates the CHILD_NODE_OF relation between two or more objects268* has changed.269*270* @since 1.5271*/272public static final String CHILD_NODE_OF_PROPERTY = "childNodeOfProperty";273274/**275* Create a new AccessibleRelation using the given locale independent key.276* The key String should be a locale independent key for the relation.277* It is not intended to be used as the actual String to display278* to the user. To get the localized string, use toDisplayString.279*280* @param key the locale independent name of the relation.281* @see AccessibleBundle#toDisplayString282*/283public AccessibleRelation(String key) {284this.key = key;285this.target = null;286}287288/**289* Creates a new AccessibleRelation using the given locale independent key.290* The key String should be a locale independent key for the relation.291* It is not intended to be used as the actual String to display292* to the user. To get the localized string, use toDisplayString.293*294* @param key the locale independent name of the relation.295* @param target the target object for this relation296* @see AccessibleBundle#toDisplayString297*/298public AccessibleRelation(String key, Object target) {299this.key = key;300this.target = new Object[1];301this.target[0] = target;302}303304/**305* Creates a new AccessibleRelation using the given locale independent key.306* The key String should be a locale independent key for the relation.307* It is not intended to be used as the actual String to display308* to the user. To get the localized string, use toDisplayString.309*310* @param key the locale independent name of the relation.311* @param target the target object(s) for this relation312* @see AccessibleBundle#toDisplayString313*/314public AccessibleRelation(String key, Object [] target) {315this.key = key;316this.target = target;317}318319/**320* Returns the key for this relation321*322* @return the key for this relation323*324* @see #CONTROLLER_FOR325* @see #CONTROLLED_BY326* @see #LABEL_FOR327* @see #LABELED_BY328* @see #MEMBER_OF329*/330public String getKey() {331return this.key;332}333334/**335* Returns the target objects for this relation336*337* @return an array containing the target objects for this relation338*/339public Object [] getTarget() {340if (target == null) {341target = new Object[0];342}343Object [] retval = new Object[target.length];344for (int i = 0; i < target.length; i++) {345retval[i] = target[i];346}347return retval;348}349350/**351* Sets the target object for this relation352*353* @param target the target object for this relation354*/355public void setTarget(Object target) {356this.target = new Object[1];357this.target[0] = target;358}359360/**361* Sets the target objects for this relation362*363* @param target an array containing the target objects for this relation364*/365public void setTarget(Object [] target) {366this.target = target;367}368}369370371