Skip to content

Commit 684fd40

Browse files
authored
Merge pull request #507 from syjer/remove-unused-utils-2
remove more unused utils/misc cleanup
2 parents 77bc108 + b29fed6 commit 684fd40

File tree

15 files changed

+15
-1475
lines changed

15 files changed

+15
-1475
lines changed

openhtmltopdf-core/src/main/java/com/openhtmltopdf/css/constants/ValueConstants.java

Lines changed: 0 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -48,63 +48,6 @@ public final class ValueConstants {
4848
*/
4949
private final static Map<Short, String> sacTypesStrings;
5050

51-
/**
52-
* A text representation of the CSS type for this value.
53-
*
54-
* @param cssType PARAM
55-
* @param primitiveValueType PARAM
56-
* @return Returns
57-
*/
58-
public static String cssType(int cssType, int primitiveValueType) {
59-
String desc = null;
60-
if (cssType == CSSValue.CSS_PRIMITIVE_VALUE) {
61-
if (primitiveValueType >= TYPE_DESCRIPTIONS.size()) {
62-
desc = "{unknown: " + primitiveValueType + "}";
63-
} else {
64-
desc = TYPE_DESCRIPTIONS.get(primitiveValueType);
65-
if (desc == null) {
66-
desc = "{UNKNOWN VALUE TYPE}";
67-
}
68-
}
69-
} else {
70-
desc = "{value list}";
71-
}
72-
return desc;
73-
}
74-
75-
/**
76-
* Description of the Method
77-
*
78-
* @param type PARAM
79-
* @return Returns
80-
*/
81-
public static short sacPrimitiveTypeForString(String type) {
82-
if ("em".equals(type)) {
83-
return CSSPrimitiveValue.CSS_EMS;
84-
} else if ("ex".equals(type)) {
85-
return CSSPrimitiveValue.CSS_EXS;
86-
} else if ("px".equals(type)) {
87-
return CSSPrimitiveValue.CSS_PX;
88-
} else if ("%".equals(type)) {
89-
return CSSPrimitiveValue.CSS_PERCENTAGE;
90-
} else if ("in".equals(type)) {
91-
return CSSPrimitiveValue.CSS_IN;
92-
} else if ("cm".equals(type)) {
93-
return CSSPrimitiveValue.CSS_CM;
94-
} else if ("mm".equals(type)) {
95-
return CSSPrimitiveValue.CSS_MM;
96-
} else if ("pt".equals(type)) {
97-
return CSSPrimitiveValue.CSS_PT;
98-
} else if ("pc".equals(type)) {
99-
return CSSPrimitiveValue.CSS_PC;
100-
} else if (type == null) {
101-
//this is only valid if length is 0
102-
return CSSPrimitiveValue.CSS_PX;
103-
} else {
104-
throw new XRRuntimeException("Unknown type on CSS value: " + type);
105-
}
106-
}
107-
10851
/**
10952
* Description of the Method
11053
*
@@ -115,22 +58,6 @@ public static String stringForSACPrimitiveType(short type) {
11558
return sacTypesStrings.get(new Short(type));
11659
}
11760

118-
/**
119-
* Returns true if the specified value was absolute (even if we have a
120-
* computed value for it), meaning that either the value can be used
121-
* directly (e.g. pixels) or there is a fixed context-independent conversion
122-
* for it (e.g. inches). Proportional types (e.g. %) return false.
123-
*
124-
* @param primitive The CSSValue instance to check.
125-
* @return See desc.
126-
*/
127-
//TODO: method may be unnecessary (tobe)
128-
public static boolean isAbsoluteUnit(CSSPrimitiveValue primitive) {
129-
short type = 0;
130-
type = primitive.getPrimitiveType();
131-
return isAbsoluteUnit(type);
132-
}
133-
13461
/**
13562
* Returns true if the specified type absolute (even if we have a computed
13663
* value for it), meaning that either the value can be used directly (e.g.
@@ -202,27 +129,6 @@ public static boolean isAbsoluteUnit(short type) {
202129
}
203130
}
204131

205-
/**
206-
* Gets the cssValueTypeDesc attribute of the {@link CSSValue} object
207-
*
208-
* @param cssValue PARAM
209-
* @return The cssValueTypeDesc value
210-
*/
211-
public static String getCssValueTypeDesc(CSSValue cssValue) {
212-
switch (cssValue.getCssValueType()) {
213-
case CSSValue.CSS_CUSTOM:
214-
return "CSS_CUSTOM";
215-
case CSSValue.CSS_INHERIT:
216-
return "CSS_INHERIT";
217-
case CSSValue.CSS_PRIMITIVE_VALUE:
218-
return "CSS_PRIMITIVE_VALUE";
219-
case CSSValue.CSS_VALUE_LIST:
220-
return "CSS_VALUE_LIST";
221-
default:
222-
return "UNKNOWN";
223-
}
224-
}
225-
226132
/**
227133
* Returns true if the SAC primitive value type is a number unit--a unit
228134
* that can only contain a numeric value. This is a shorthand way of saying,
@@ -306,53 +212,6 @@ public static boolean isNumber(short cssPrimitiveType) {
306212
sacTypesStrings.put(new Short(CSSPrimitiveValue.CSS_PC), "pc");
307213
}
308214

309-
/**
310-
* Incomplete routine to try and determine the
311-
* CSSPrimitiveValue short code for a given value,
312-
* e.g. 14pt is CSS_PT.
313-
*
314-
* @param value PARAM
315-
* @return Returns
316-
*/
317-
public static short guessType(String value) {
318-
short type = CSSPrimitiveValue.CSS_STRING;
319-
if (value != null && value.length() > 1) {
320-
if (value.endsWith("%")) {
321-
type = CSSPrimitiveValue.CSS_PERCENTAGE;
322-
} else if (value.startsWith("rgb") || value.startsWith("#")) {
323-
type = CSSPrimitiveValue.CSS_RGBCOLOR;
324-
} else {
325-
String hmm = value.substring(value.length() - 2);
326-
if ("pt".equals(hmm)) {
327-
type = CSSPrimitiveValue.CSS_PT;
328-
} else if ("px".equals(hmm)) {
329-
type = CSSPrimitiveValue.CSS_PX;
330-
} else if ("em".equals(hmm)) {
331-
type = CSSPrimitiveValue.CSS_EMS;
332-
} else if ("ex".equals(hmm)) {
333-
type = CSSPrimitiveValue.CSS_EXS;
334-
} else if ("in".equals(hmm)) {
335-
type = CSSPrimitiveValue.CSS_IN;
336-
} else if ("cm".equals(hmm)) {
337-
type = CSSPrimitiveValue.CSS_CM;
338-
} else if ("mm".equals(hmm)) {
339-
type = CSSPrimitiveValue.CSS_MM;
340-
} else {
341-
if (Character.isDigit(value.charAt(value.length() - 1))) {
342-
try {
343-
new Float(value);
344-
type = CSSPrimitiveValue.CSS_NUMBER;
345-
} catch (NumberFormatException ex) {
346-
type = CSSPrimitiveValue.CSS_STRING;
347-
}
348-
} else {
349-
type = CSSPrimitiveValue.CSS_STRING;
350-
}
351-
}
352-
}
353-
}
354-
return type;
355-
}
356215
}// end class
357216

358217
/*

openhtmltopdf-core/src/main/java/com/openhtmltopdf/css/newmatch/Matcher.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import com.openhtmltopdf.css.extend.StylesheetFactory;
3535
import com.openhtmltopdf.css.extend.TreeResolver;
3636
import com.openhtmltopdf.css.sheet.*;
37-
import com.openhtmltopdf.util.Util;
3837
import com.openhtmltopdf.util.XRLog;
3938

4039

@@ -220,14 +219,18 @@ private Mapper getMapper(Object e) {
220219
return m;
221220
}
222221

222+
private static boolean isNullOrEmpty(String str) {
223+
return str == null || str.length() == 0;
224+
}
225+
223226
private com.openhtmltopdf.css.sheet.Ruleset getElementStyle(Object e) {
224227
//synchronized (e) {
225228
if (_attRes == null || _styleFactory == null) {
226229
return null;
227230
}
228231

229232
String style = _attRes.getElementStyling(e);
230-
if (Util.isNullOrEmpty(style)) {
233+
if (isNullOrEmpty(style)) {
231234
return null;
232235
}
233236

@@ -241,7 +244,7 @@ private com.openhtmltopdf.css.sheet.Ruleset getNonCssStyle(Object e) {
241244
return null;
242245
}
243246
String style = _attRes.getNonCssStyling(e);
244-
if (Util.isNullOrEmpty(style)) {
247+
if (isNullOrEmpty(style)) {
245248
return null;
246249
}
247250
return _styleFactory.parseStyleDeclaration(com.openhtmltopdf.css.sheet.StylesheetInfo.AUTHOR, style);

openhtmltopdf-core/src/main/java/com/openhtmltopdf/css/parser/CSSParser.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
import java.io.IOException;
3232
import java.io.Reader;
3333
import java.io.StringReader;
34-
import java.net.URI;
35-
import java.net.URISyntaxException;
3634
import java.util.*;
3735
import java.util.logging.Level;
3836

@@ -1974,14 +1972,6 @@ private String getTokenValue(Token t, boolean literal) {
19741972
}
19751973
}
19761974

1977-
private boolean isRelativeURI(String uri) {
1978-
try {
1979-
return uri.length() > 0 && (uri.charAt(0) != '/' && ! new URI(uri).isAbsolute());
1980-
} catch (URISyntaxException e) {
1981-
return false;
1982-
}
1983-
}
1984-
19851975
private int getCurrentLine() {
19861976
return _lexer.yyline();
19871977
}

openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/BlockBoxing.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,6 @@ public void setChildOffset(int childOffset) {
432432

433433
private static class RelayoutData {
434434
private LayoutState _layoutState;
435-
private int _listIndex;
436435

437436
private boolean _startsRun;
438437
private boolean _endsRun;
@@ -482,14 +481,6 @@ public int getChildOffset() {
482481
public void setChildOffset(int childOffset) {
483482
_childOffset = childOffset;
484483
}
485-
486-
public int getListIndex() {
487-
return _listIndex;
488-
}
489-
490-
public void setListIndex(int listIndex) {
491-
_listIndex = listIndex;
492-
}
493484
}
494485
}
495486

openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/VerticalAlignContext.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -196,34 +196,18 @@ public void setInitialMeasurements(InlineBoxMeasurements measurements) {
196196
}
197197

198198
private static final class ChildContextData {
199-
private Box _root;
200-
private VerticalAlignContext _verticalAlignContext;
201-
202-
203-
public ChildContextData() {
204-
}
199+
private final Box _root;
200+
private final VerticalAlignContext _verticalAlignContext;
205201

206202
public ChildContextData(Box root, VerticalAlignContext vaContext) {
207203
_root = root;
208204
_verticalAlignContext = vaContext;
209205
}
210206

211-
public Box getRoot() {
212-
return _root;
213-
}
214-
215-
public void setRoot(Box root) {
216-
_root = root;
217-
}
218-
219207
public VerticalAlignContext getVerticalAlignContext() {
220208
return _verticalAlignContext;
221209
}
222210

223-
public void setVerticalAlignContext(VerticalAlignContext verticalAlignContext) {
224-
_verticalAlignContext = verticalAlignContext;
225-
}
226-
227211
private void moveContextContents(int ty) {
228212
moveInlineContents(_root, ty);
229213
}

openhtmltopdf-core/src/main/java/com/openhtmltopdf/render/AbstractOutputDevice.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import com.openhtmltopdf.extend.FSImage;
3939
import com.openhtmltopdf.extend.OutputDevice;
4040
import com.openhtmltopdf.util.Configuration;
41-
import com.openhtmltopdf.util.Uu;
41+
import com.openhtmltopdf.util.XRLog;
4242

4343
import java.awt.*;
4444
import java.awt.geom.Area;
@@ -50,14 +50,6 @@
5050
* implementations for many <code>OutputDevice</code> methods.
5151
*/
5252
public abstract class AbstractOutputDevice implements OutputDevice {
53-
54-
public static class ClipInfo {
55-
public final List<Object> _ops;
56-
57-
public ClipInfo(List<Object> ops) {
58-
this._ops = ops;
59-
}
60-
}
6153

6254
private FontSpecification _fontSpec;
6355

@@ -210,8 +202,7 @@ private FSImage getBackgroundImage(RenderingContext c, CalculatedStyle style) {
210202
try {
211203
return c.getUac().getImageResource(uri).getImage();
212204
} catch (Exception ex) {
213-
ex.printStackTrace();
214-
Uu.p(ex);
205+
XRLog.exception("Failed to load background image at uri " + uri, ex);
215206
}
216207
}
217208
return null;

openhtmltopdf-core/src/main/java/com/openhtmltopdf/resource/AbstractResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* @author Patrick Wright
3232
*/
3333
public abstract class AbstractResource implements Resource {
34-
private static enum StreamType { READER, STREAM, INPUT_SOURCE; }
34+
private enum StreamType { READER, STREAM, INPUT_SOURCE; }
3535
private final StreamType streamType;
3636

3737
private InputSource inputSource;

openhtmltopdf-core/src/main/java/com/openhtmltopdf/simple/extend/URLUTF8Encoder.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,6 @@ public static String encode( String s ) {
9898
return sbuf.toString();
9999
}
100100

101-
/**
102-
* Description of the Method
103-
*
104-
* @param chars PARAM
105-
* @return Returns
106-
*/
107-
public static String encode( char[] chars ) {
108-
StringBuilder sbuf = new StringBuilder();
109-
int len = chars.length;
110-
for ( int i = 0; i < len; i++ ) {
111-
int ch = chars[i];
112-
append( sbuf, ch );
113-
}
114-
return sbuf.toString();
115-
}
116-
117101
/**
118102
* Description of the Method
119103
*

openhtmltopdf-core/src/main/java/com/openhtmltopdf/simple/xhtml/controls/AbstractControl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public abstract class AbstractControl implements FormControl {
4343
private boolean _successful;
4444
private boolean _enabled;
4545

46-
private List _listeners = new ArrayList();
46+
private List<FormControlListener> _listeners = new ArrayList<>();
4747

4848
public AbstractControl(XhtmlForm form, Element e) {
4949
_form = form;

openhtmltopdf-core/src/main/java/com/openhtmltopdf/simple/xhtml/controls/ButtonControl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class ButtonControl extends AbstractControl {
3131

3232
private String _type, _label;
3333
private boolean _extended;
34-
private List _listeners = new ArrayList();
34+
private List<ButtonControlListener> _listeners = new ArrayList<>();
3535

3636
public ButtonControl(XhtmlForm form, Element e) {
3737
super(form, e);
@@ -75,8 +75,8 @@ public void removeButtonControlListener(ButtonControlListener listener) {
7575
}
7676

7777
public boolean press() {
78-
for (Iterator iter = _listeners.iterator(); iter.hasNext();) {
79-
if(!((ButtonControlListener) iter.next()).pressed(this))
78+
for (Iterator<ButtonControlListener> iter = _listeners.iterator(); iter.hasNext();) {
79+
if(!(iter.next()).pressed(this))
8080
return false;
8181
}
8282
return true;

openhtmltopdf-core/src/main/java/com/openhtmltopdf/util/ArrayUtil.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ public class ArrayUtil {
2626
public static String[] cloneOrEmpty(String[] source){
2727
return source == null ? Constants.EMPTY_STR_ARR : (String[]) source.clone();
2828
}
29-
public static byte[] cloneOrEmpty(byte[] source){
30-
return source == null ? Constants.EMPTY_BYTE_ARR : (byte[]) source.clone();
31-
}
3229

3330
public static int[] cloneOrEmpty(int[] source) {
3431
return source == null ? Constants.EMPTY_INT_ARR : (int[]) source.clone();

0 commit comments

Comments
 (0)