@@ -55,7 +55,7 @@ public RGBColorImpl(final String function, final LexicalUnit lu) throws DOMExcep
5555 throw new DOMException (DOMException .SYNTAX_ERR , "'" + function_ + "' requires at least three values." );
5656 }
5757
58- red_ = getPart (next );
58+ getNumberPercentagePart (next , this :: setRed );
5959
6060 next = next .getNextLexicalUnit ();
6161 if (next == null ) {
@@ -78,7 +78,7 @@ public RGBColorImpl(final String function, final LexicalUnit lu) throws DOMExcep
7878 throw new DOMException (DOMException .SYNTAX_ERR ,
7979 "'" + function_ + "' has to use blank as separator if none is used." );
8080 }
81- green_ = getPart (next );
81+ getNumberPercentagePart (next , this :: setGreen );
8282
8383 next = next .getNextLexicalUnit ();
8484 if (next == null ) {
@@ -99,7 +99,7 @@ public RGBColorImpl(final String function, final LexicalUnit lu) throws DOMExcep
9999 throw new DOMException (DOMException .SYNTAX_ERR ,
100100 "'" + function_ + "' has to use blank as separator if none is used." );
101101 }
102- blue_ = getPart (next );
102+ getNumberPercentagePart (next , this :: setBlue );
103103
104104 next = next .getNextLexicalUnit ();
105105 if (next == null ) {
@@ -130,7 +130,7 @@ public RGBColorImpl(final String function, final LexicalUnit lu) throws DOMExcep
130130 return ;
131131 }
132132
133- green_ = getPart (next );
133+ getNumberPercentagePart (next , this :: setGreen );
134134 next = next .getNextLexicalUnit ();
135135 if (next == null ) {
136136 throw new DOMException (DOMException .SYNTAX_ERR , "'" + function_ + "' requires at least three values." );
@@ -140,7 +140,7 @@ public RGBColorImpl(final String function, final LexicalUnit lu) throws DOMExcep
140140 "'" + function_ + "' requires consitent separators (blank or comma)." );
141141 }
142142
143- blue_ = getPart (next );
143+ getNumberPercentagePart (next , this :: setBlue );
144144 next = next .getNextLexicalUnit ();
145145 if (next == null ) {
146146 return ;
@@ -163,17 +163,6 @@ public RGBColorImpl(final String function, final LexicalUnit lu) throws DOMExcep
163163 }
164164 }
165165
166- private static CSSValueImpl getPart (final LexicalUnit next ) {
167- if (LexicalUnitType .PERCENTAGE == next .getLexicalUnitType ()
168- || LexicalUnitType .INTEGER == next .getLexicalUnitType ()
169- || LexicalUnitType .REAL == next .getLexicalUnitType ()
170- || LexicalUnitType .NONE == next .getLexicalUnitType ()) {
171- return new CSSValueImpl (next , true );
172- }
173-
174- throw new DOMException (DOMException .SYNTAX_ERR , "Color part has to be numeric or percentage." );
175- }
176-
177166 /**
178167 * <p>getRed.</p>
179168 *
0 commit comments