72 /** 73 * Returns a StyleAssociation that can be used to determine if 74 * a particular string matches the returned association. 75 */ 76 public static StyleAssociation createStyleAssociation( 77 String text, SynthStyle style, int id) 78 throws PatternSyntaxException { 79 return new StyleAssociation(text, style, id); 80 } 81 82 83 private StyleAssociation(String text, SynthStyle style, int id) 84 throws PatternSyntaxException { 85 _style = style; 86 _pattern = Pattern.compile(text); 87 _id = id; 88 } 89 90 /** 91 * Returns the developer specified identifier for this association, will 92 * be <code>0</code> if an identifier was not specified when this 93 * <code>StyleAssociation</code> was created. 94 */ 95 public int getID() { 96 return _id; 97 } 98 99 /** 100 * Returns true if this <code>StyleAssociation</code> matches the 101 * passed in CharSequence. 102 * 103 * @return true if this <code>StyleAssociation</code> matches the 104 * passed in CharSequence.if this StyleAssociation. 105 */ 106 public synchronized boolean matches(CharSequence path) { 107 if (_matcher == null) { 108 _matcher = _pattern.matcher(path); 109 } 110 else { 111 _matcher.reset(path); 112 } 113 return _matcher.matches(); 114 } 115 116 /** 117 * Returns the text used in matching the string. 118 * 119 * @return the text used in matching the string. 120 */ 121 public String getText() { 122 return _pattern.pattern(); 123 } | 72 /** 73 * Returns a StyleAssociation that can be used to determine if 74 * a particular string matches the returned association. 75 */ 76 public static StyleAssociation createStyleAssociation( 77 String text, SynthStyle style, int id) 78 throws PatternSyntaxException { 79 return new StyleAssociation(text, style, id); 80 } 81 82 83 private StyleAssociation(String text, SynthStyle style, int id) 84 throws PatternSyntaxException { 85 _style = style; 86 _pattern = Pattern.compile(text); 87 _id = id; 88 } 89 90 /** 91 * Returns the developer specified identifier for this association, will 92 * be {@code 0} if an identifier was not specified when this 93 * {@code StyleAssociation} was created. 94 */ 95 public int getID() { 96 return _id; 97 } 98 99 /** 100 * Returns true if this {@code StyleAssociation} matches the 101 * passed in CharSequence. 102 * 103 * @return true if this {@code StyleAssociation} matches the 104 * passed in CharSequence.if this StyleAssociation. 105 */ 106 public synchronized boolean matches(CharSequence path) { 107 if (_matcher == null) { 108 _matcher = _pattern.matcher(path); 109 } 110 else { 111 _matcher.reset(path); 112 } 113 return _matcher.matches(); 114 } 115 116 /** 117 * Returns the text used in matching the string. 118 * 119 * @return the text used in matching the string. 120 */ 121 public String getText() { 122 return _pattern.pattern(); 123 } |