modules/graphics/src/main/java/javafx/css/SimpleSelector.java

Print this page
rev 9240 : 8076423: JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization

@@ -21,14 +21,12 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
-package com.sun.javafx.css;
+package javafx.css;
 
-import javafx.css.PseudoClass;
-import javafx.css.Styleable;
 import javafx.geometry.NodeOrientation;
 import javafx.scene.Node;
 
 import java.io.DataInputStream;
 import java.io.DataOutputStream;

@@ -37,17 +35,21 @@
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
+import com.sun.javafx.css.PseudoClassState;
+import com.sun.javafx.css.StyleClassSet;
+
 import static javafx.geometry.NodeOrientation.INHERIT;
 import static javafx.geometry.NodeOrientation.LEFT_TO_RIGHT;
 import static javafx.geometry.NodeOrientation.RIGHT_TO_LEFT;
 
 /**
  * A simple selector which behaves according to the CSS standard.
  *
+ * @since 9
  */
 final public class SimpleSelector extends Selector {
     
     /**
      * If specified in the CSS file, the name of the java class to which

@@ -78,11 +80,11 @@
         }
         
         return Collections.unmodifiableList(names);
     }
 
-    Set<StyleClass> getStyleClassSet() {
+    public Set<StyleClass> getStyleClassSet() {
         return styleClassSet;
     }
     
     /** styleClasses converted to a set of bit masks */
     final private StyleClassSet styleClassSet;

@@ -103,11 +105,11 @@
     }
 
     /**
      * @return Immutable List&lt;String&gt; of pseudo-classes of the selector
      */
-    public List<String> getPseudoclasses() {
+    List<String> getPseudoclasses() {
         
         final List<String> names = new ArrayList<String>();
         
         Iterator<PseudoClass> iter = pseudoClassState.iterator();
         while (iter.hasNext()) {

@@ -135,16 +137,16 @@
     // dir(ltr) or dir(rtl), otherwise inherit
     final private NodeOrientation nodeOrientation;
     
     // Used in Match. If nodeOrientation is ltr or rtl, 
     // then count it as a pseudoclass
-    NodeOrientation getNodeOrientation() {
+    public NodeOrientation getNodeOrientation() {
         return nodeOrientation;
     }
     
     // TODO: The parser passes styleClasses as a List. Should be array?
-    public SimpleSelector(final String name, final List<String> styleClasses,
+    SimpleSelector(final String name, final List<String> styleClasses,
             final List<String> pseudoClasses, final String id)
     {
         this.name = name == null ? "*" : name;
         // if name is not null and not empty or wildcard, 
         // then match needs to check name

@@ -190,18 +192,17 @@
         // if id is not null and not empty, then match needs to check id
         this.matchOnId = (id != null && !("".equals(id)));
 
     }
 
-    Match createMatch() {
+    @Override public Match createMatch() {
         final int idCount = (matchOnId) ? 1 : 0;
         int styleClassCount = styleClassSet.size();
         return new Match(this, pseudoClassState, idCount, styleClassCount);
     }
 
-    @Override 
-    public boolean applies(Styleable styleable) {
+    @Override public boolean applies(Styleable styleable) {
         
         // handle functional pseudo-class :dir()
         // INHERIT applies to both :dir(rtl) and :dir(ltr)
         if (nodeOrientation != INHERIT && styleable instanceof Node) {
             final Node node = (Node)styleable;

@@ -251,12 +252,11 @@
         }
         
         return true;
     }
     
-    @Override 
-    boolean applies(Styleable styleable, Set<PseudoClass>[] pseudoClasses, int depth) {
+    @Override public boolean applies(Styleable styleable, Set<PseudoClass>[] pseudoClasses, int depth) {
 
         
         final boolean applies = applies(styleable);
         
         //

@@ -272,12 +272,11 @@
             
         }
         return applies;
     }
 
-    @Override
-    public boolean stateMatches(final Styleable styleable, Set<PseudoClass> states) {
+    @Override public boolean stateMatches(final Styleable styleable, Set<PseudoClass> states) {
         // [foo bar] matches [foo bar bang], 
         // but [foo bar bang] doesn't match [foo bar]
         return states != null ? states.containsAll(pseudoClassState) : false;
     }
 

@@ -294,12 +293,11 @@
     // match for class="pastoral blue".
     private boolean matchStyleClasses(StyleClassSet otherStyleClasses) {
         return otherStyleClasses.containsAll(styleClassSet);
     }
 
-    @Override
-    public boolean equals(Object obj) {
+    @Override public boolean equals(Object obj) {
         if (obj == null) {
             return false;
         }
         if (getClass() != obj.getClass()) {
             return false;

@@ -355,11 +353,11 @@
         }
             
         return sbuf.toString();
     }
 
-    public final void writeBinary(final DataOutputStream os, final StringStore stringStore)
+    @Override protected final void writeBinary(final DataOutputStream os, final StyleConverter.StringStore stringStore)
         throws IOException
     {
         super.writeBinary(os, stringStore);
         os.writeShort(stringStore.addString(name));
         os.writeShort(styleClassSet.size());