Skip to content

Commit 1c76462

Browse files
committed
tabs to spaces
1 parent 8b50c12 commit 1c76462

File tree

10 files changed

+434
-434
lines changed

10 files changed

+434
-434
lines changed

src/main/java/net/sargue/time/jsptags/FormatSupport.java

Lines changed: 112 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -37,127 +37,127 @@
3737
*/
3838
public abstract class FormatSupport extends TagSupport {
3939

40-
private static final long serialVersionUID = 1L;
41-
42-
/** The value attribute. */
43-
protected Object value;
44-
/** The pattern attribute. */
45-
protected String pattern;
46-
/** The style attribute. */
47-
protected String style;
48-
/** The zoneId attribute. */
49-
protected ZoneId zoneId;
50-
/** The locale attribute. */
51-
protected Locale locale;
52-
/** The var attribute. */
53-
private String var;
54-
/** The scope attribute. */
55-
private int scope;
56-
57-
/**
58-
* Constructor.
59-
*/
60-
public FormatSupport() {
61-
super();
62-
init();
63-
}
64-
65-
private void init() {
66-
var = null;
67-
value = null;
68-
pattern = null;
69-
style = null;
70-
zoneId = null;
71-
locale = null;
72-
scope = PageContext.PAGE_SCOPE;
73-
}
40+
private static final long serialVersionUID = 1L;
41+
42+
/** The value attribute. */
43+
protected Object value;
44+
/** The pattern attribute. */
45+
protected String pattern;
46+
/** The style attribute. */
47+
protected String style;
48+
/** The zoneId attribute. */
49+
protected ZoneId zoneId;
50+
/** The locale attribute. */
51+
protected Locale locale;
52+
/** The var attribute. */
53+
private String var;
54+
/** The scope attribute. */
55+
private int scope;
56+
57+
/**
58+
* Constructor.
59+
*/
60+
public FormatSupport() {
61+
super();
62+
init();
63+
}
64+
65+
private void init() {
66+
var = null;
67+
value = null;
68+
pattern = null;
69+
style = null;
70+
zoneId = null;
71+
locale = null;
72+
scope = PageContext.PAGE_SCOPE;
73+
}
7474

7575
@SuppressWarnings("UnusedDeclaration")
76-
public void setVar(String var) {
77-
this.var = var;
78-
}
76+
public void setVar(String var) {
77+
this.var = var;
78+
}
7979

8080
@SuppressWarnings("UnusedDeclaration")
81-
public void setScope(String scope) {
82-
this.scope = Util.getScope(scope);
83-
}
84-
85-
/*
86-
* Formats the given instant or partial.
87-
*/
88-
public int doEndTag() throws JspException {
89-
if (value == null) {
90-
if (var != null) {
91-
pageContext.removeAttribute(var, scope);
92-
}
93-
return EVAL_PAGE;
94-
}
95-
96-
// Create formatter
97-
DateTimeFormatter formatter;
98-
if (pattern != null) {
99-
formatter = DateTimeFormatter.ofPattern(pattern);
100-
} else if (style != null) {
101-
formatter = Util.createFormatterForStyle(style);
102-
} else {
103-
// use a medium date (no time) style by default; same as jstl
104-
formatter = Util.createFormatterForStyle("M-");
105-
}
106-
107-
// set formatter locale
108-
Locale locale = this.locale;
109-
if (locale == null) {
110-
locale = Util.getFormattingLocale(pageContext, true,
81+
public void setScope(String scope) {
82+
this.scope = Util.getScope(scope);
83+
}
84+
85+
/*
86+
* Formats the given instant or partial.
87+
*/
88+
public int doEndTag() throws JspException {
89+
if (value == null) {
90+
if (var != null) {
91+
pageContext.removeAttribute(var, scope);
92+
}
93+
return EVAL_PAGE;
94+
}
95+
96+
// Create formatter
97+
DateTimeFormatter formatter;
98+
if (pattern != null) {
99+
formatter = DateTimeFormatter.ofPattern(pattern);
100+
} else if (style != null) {
101+
formatter = Util.createFormatterForStyle(style);
102+
} else {
103+
// use a medium date (no time) style by default; same as jstl
104+
formatter = Util.createFormatterForStyle("M-");
105+
}
106+
107+
// set formatter locale
108+
Locale locale = this.locale;
109+
if (locale == null) {
110+
locale = Util.getFormattingLocale(pageContext, true,
111111
DateFormat.getAvailableLocales());
112-
}
113-
if (locale != null) {
114-
formatter = formatter.withLocale(locale);
115-
}
116-
117-
// set formatter timezone
118-
ZoneId zoneId = this.zoneId;
119-
if (zoneId == null) {
120-
zoneId = ZoneIdSupport.getZoneId(pageContext, this);
121-
}
122-
if (zoneId != null) {
123-
formatter = formatter.withZone(zoneId);
124-
} else {
125-
if (value instanceof Instant ||
112+
}
113+
if (locale != null) {
114+
formatter = formatter.withLocale(locale);
115+
}
116+
117+
// set formatter timezone
118+
ZoneId zoneId = this.zoneId;
119+
if (zoneId == null) {
120+
zoneId = ZoneIdSupport.getZoneId(pageContext, this);
121+
}
122+
if (zoneId != null) {
123+
formatter = formatter.withZone(zoneId);
124+
} else {
125+
if (value instanceof Instant ||
126126
value instanceof LocalDateTime ||
127127
value instanceof OffsetDateTime ||
128128
value instanceof OffsetTime ||
129129
value instanceof LocalTime)
130-
// these time objects may need a zone to resolve some patterns
131-
// and/or styles, and as there is no zone we revert to the
132-
// system default zone
133-
formatter = formatter.withZone(ZoneId.systemDefault());
134-
}
135-
136-
// format value
137-
String formatted;
138-
if (value instanceof TemporalAccessor) {
139-
formatted = formatter.format((TemporalAccessor) value);
140-
} else {
141-
throw new JspException(
130+
// these time objects may need a zone to resolve some patterns
131+
// and/or styles, and as there is no zone we revert to the
132+
// system default zone
133+
formatter = formatter.withZone(ZoneId.systemDefault());
134+
}
135+
136+
// format value
137+
String formatted;
138+
if (value instanceof TemporalAccessor) {
139+
formatted = formatter.format((TemporalAccessor) value);
140+
} else {
141+
throw new JspException(
142142
"value attribute of format tag must be a TemporalAccessor," +
143143
" was: " + value.getClass().getName());
144-
}
145-
146-
if (var != null) {
147-
pageContext.setAttribute(var, formatted, scope);
148-
} else {
149-
try {
150-
pageContext.getOut().print(formatted);
151-
} catch (IOException ioe) {
152-
throw new JspTagException(ioe.toString(), ioe);
153-
}
154-
}
155-
156-
return EVAL_PAGE;
157-
}
158-
159-
// Releases any resources we may have (or inherit)
160-
public void release() {
161-
init();
162-
}
144+
}
145+
146+
if (var != null) {
147+
pageContext.setAttribute(var, formatted, scope);
148+
} else {
149+
try {
150+
pageContext.getOut().print(formatted);
151+
} catch (IOException ioe) {
152+
throw new JspTagException(ioe.toString(), ioe);
153+
}
154+
}
155+
156+
return EVAL_PAGE;
157+
}
158+
159+
// Releases any resources we may have (or inherit)
160+
public void release() {
161+
init();
162+
}
163163
}

src/main/java/net/sargue/time/jsptags/FormatTag.java

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -33,71 +33,71 @@
3333
@SuppressWarnings("UnusedDeclaration")
3434
public class FormatTag extends FormatSupport {
3535

36-
private static final long serialVersionUID = 1L;
36+
private static final long serialVersionUID = 1L;
3737

38-
/**
39-
* Sets the value attribute.
40-
*
41-
* @param value the value
42-
*/
43-
public void setValue(Object value) {
44-
this.value = value;
45-
}
38+
/**
39+
* Sets the value attribute.
40+
*
41+
* @param value the value
42+
*/
43+
public void setValue(Object value) {
44+
this.value = value;
45+
}
4646

47-
/**
48-
* Sets the style attribute.
49-
*
50-
* @param style the style
51-
*/
52-
public void setStyle(String style) {
53-
this.style = style;
54-
}
47+
/**
48+
* Sets the style attribute.
49+
*
50+
* @param style the style
51+
*/
52+
public void setStyle(String style) {
53+
this.style = style;
54+
}
5555

56-
/**
57-
* Sets the pattern attribute.
58-
*
59-
* @param pattern the pattern
60-
*/
61-
public void setPattern(String pattern) {
62-
this.pattern = pattern;
63-
}
56+
/**
57+
* Sets the pattern attribute.
58+
*
59+
* @param pattern the pattern
60+
*/
61+
public void setPattern(String pattern) {
62+
this.pattern = pattern;
63+
}
6464

65-
/**
66-
* Sets the zone attribute.
67-
*
68-
* @param dtz the zone
69-
* @throws JspTagException incorrect zone or dtz parameter
70-
*/
71-
public void setZoneId(Object dtz) throws JspTagException {
72-
if (dtz == null || (dtz instanceof String && ((String) dtz).isEmpty())) {
73-
this.zoneId = null;
74-
} else if (dtz instanceof ZoneId) {
75-
this.zoneId = (ZoneId) dtz;
76-
} else if (dtz instanceof String) {
77-
try {
78-
this.zoneId = ZoneId.of((String) dtz);
79-
} catch (IllegalArgumentException iae) {
80-
throw new JspTagException("Incorrect Zone: " + dtz);
81-
}
82-
} else
83-
throw new JspTagException("Can only accept ZoneId or String objects.");
84-
}
65+
/**
66+
* Sets the zone attribute.
67+
*
68+
* @param dtz the zone
69+
* @throws JspTagException incorrect zone or dtz parameter
70+
*/
71+
public void setZoneId(Object dtz) throws JspTagException {
72+
if (dtz == null || (dtz instanceof String && ((String) dtz).isEmpty())) {
73+
this.zoneId = null;
74+
} else if (dtz instanceof ZoneId) {
75+
this.zoneId = (ZoneId) dtz;
76+
} else if (dtz instanceof String) {
77+
try {
78+
this.zoneId = ZoneId.of((String) dtz);
79+
} catch (IllegalArgumentException iae) {
80+
throw new JspTagException("Incorrect Zone: " + dtz);
81+
}
82+
} else
83+
throw new JspTagException("Can only accept ZoneId or String objects.");
84+
}
8585

86-
/**
87-
* Sets the style attribute.
88-
*
89-
* @param loc the locale
90-
* @throws JspTagException parameter not a Locale or String
91-
*/
92-
public void setLocale(Object loc) throws JspTagException {
93-
if (loc == null) {
94-
this.locale = null;
95-
} else if (loc instanceof Locale) {
96-
this.locale = (Locale) loc;
97-
} else if (loc instanceof String) {
98-
this.locale = Util.parseLocale((String) loc);
99-
} else
100-
throw new JspTagException("Can only accept Locale or String objects.");
101-
}
86+
/**
87+
* Sets the style attribute.
88+
*
89+
* @param loc the locale
90+
* @throws JspTagException parameter not a Locale or String
91+
*/
92+
public void setLocale(Object loc) throws JspTagException {
93+
if (loc == null) {
94+
this.locale = null;
95+
} else if (loc instanceof Locale) {
96+
this.locale = (Locale) loc;
97+
} else if (loc instanceof String) {
98+
this.locale = Util.parseLocale((String) loc);
99+
} else
100+
throw new JspTagException("Can only accept Locale or String objects.");
101+
}
102102

103103
}

src/main/java/net/sargue/time/jsptags/ParseInstantTag.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232

3333
public class ParseInstantTag extends ParseSupport {
3434

35-
private static final long serialVersionUID = 1L;
35+
private static final long serialVersionUID = 1L;
3636

37-
@Override
38-
protected TemporalQuery<TemporalAccessor> temporalQuery() {
39-
return Instant::from;
40-
}
37+
@Override
38+
protected TemporalQuery<TemporalAccessor> temporalQuery() {
39+
return Instant::from;
40+
}
4141
}

0 commit comments

Comments
 (0)