mirror of
https://github.com/ethauvin/rife2.git
synced 2025-04-30 18:48:13 -07:00
Code cleanups
This commit is contained in:
parent
2d05db7e46
commit
0f599eadd3
37 changed files with 535 additions and 553 deletions
|
@ -17,7 +17,7 @@ import java.net.UnknownHostException;
|
|||
public class NameSelectorHostname implements NameSelector {
|
||||
public String getActiveName() {
|
||||
try {
|
||||
InetAddress address = InetAddress.getLocalHost();
|
||||
var address = InetAddress.getLocalHost();
|
||||
return address.getHostName().toLowerCase();
|
||||
} catch (UnknownHostException e) {
|
||||
// do nothing
|
||||
|
|
|
@ -41,7 +41,7 @@ public class Server {
|
|||
rife_filter.site(site);
|
||||
var filter_holder = new FilterHolder(rife_filter);
|
||||
|
||||
ServletContextHandler ctx = new ServletContextHandler();
|
||||
var ctx = new ServletContextHandler();
|
||||
ctx.setContextPath("/");
|
||||
|
||||
var default_servlet = new DefaultServlet();
|
||||
|
|
|
@ -43,7 +43,7 @@ public class HttpRequest implements Request {
|
|||
|
||||
public void init() {
|
||||
if (MultipartRequest.isValidContentType(request_.getContentType())) {
|
||||
MultipartRequest multipart_request = new MultipartRequest(request_);
|
||||
var multipart_request = new MultipartRequest(request_);
|
||||
parameters_ = multipart_request.getParameterMap();
|
||||
files_ = multipart_request.getFileMap();
|
||||
} else {
|
||||
|
@ -65,7 +65,7 @@ public class HttpRequest implements Request {
|
|||
}
|
||||
|
||||
parameter_values = request_.getParameterValues(parameter_name);
|
||||
for (int i = 0; i < parameter_values.length; i++) {
|
||||
for (var i = 0; i < parameter_values.length; i++) {
|
||||
if (StringUtils.doesUrlValueNeedDecoding(parameter_values[i])) {
|
||||
parameter_values[i] = StringUtils.decodeUrlValue(parameter_values[i]);
|
||||
}
|
||||
|
@ -126,13 +126,13 @@ public class HttpRequest implements Request {
|
|||
return false;
|
||||
}
|
||||
|
||||
UploadedFile[] uploaded_files = getFiles().get(name);
|
||||
var uploaded_files = getFiles().get(name);
|
||||
|
||||
if (0 == uploaded_files.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (UploadedFile uploaded_file : uploaded_files) {
|
||||
for (var uploaded_file : uploaded_files) {
|
||||
if (uploaded_file != null &&
|
||||
uploaded_file.getName() != null) {
|
||||
return true;
|
||||
|
@ -151,7 +151,7 @@ public class HttpRequest implements Request {
|
|||
return null;
|
||||
}
|
||||
|
||||
UploadedFile[] files = getFiles().get(name);
|
||||
var files = getFiles().get(name);
|
||||
if (null == files) {
|
||||
return null;
|
||||
}
|
||||
|
@ -176,13 +176,13 @@ public class HttpRequest implements Request {
|
|||
assert name != null;
|
||||
assert name.length() > 0;
|
||||
|
||||
Cookie[] cookies = request_.getCookies();
|
||||
var cookies = request_.getCookies();
|
||||
|
||||
if (null == cookies) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Cookie cookie : cookies) {
|
||||
for (var cookie : cookies) {
|
||||
if (cookie.getName().equals(name)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -196,13 +196,13 @@ public class HttpRequest implements Request {
|
|||
assert name != null;
|
||||
assert name.length() > 0;
|
||||
|
||||
Cookie[] cookies = request_.getCookies();
|
||||
var cookies = request_.getCookies();
|
||||
|
||||
if (null == cookies) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (Cookie cookie : cookies) {
|
||||
for (var cookie : cookies) {
|
||||
if (cookie.getName().equals(name)) {
|
||||
return cookie;
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ class MultipartRequest {
|
|||
while (null != line &&
|
||||
line.length() > 0) {
|
||||
String next_line = null;
|
||||
boolean obtain_next_line = true;
|
||||
var obtain_next_line = true;
|
||||
while (obtain_next_line) {
|
||||
next_line = readLine();
|
||||
|
||||
|
@ -262,11 +262,11 @@ class MultipartRequest {
|
|||
|
||||
String fieldname = null;
|
||||
String filename = null;
|
||||
String content_type = "text/plain"; // rfc1867 says this is the default
|
||||
var content_type = "text/plain"; // rfc1867 says this is the default
|
||||
|
||||
String[] disposition_info = null;
|
||||
|
||||
for (String headerline : headers) {
|
||||
for (var headerline : headers) {
|
||||
if (headerline.toLowerCase().startsWith(CONTENT_DISPOSITION_PREFIX)) {
|
||||
// Parse the content-disposition line
|
||||
disposition_info = extractDispositionInfo(headerline);
|
||||
|
@ -275,7 +275,7 @@ class MultipartRequest {
|
|||
filename = disposition_info[1];
|
||||
} else if (headerline.toLowerCase().startsWith(CONTENT_TYPE_HEADER)) {
|
||||
// Get the content type, or null if none specified
|
||||
String type = extractContentType(headerline);
|
||||
var type = extractContentType(headerline);
|
||||
if (type != null) {
|
||||
content_type = type;
|
||||
}
|
||||
|
@ -328,8 +328,8 @@ class MultipartRequest {
|
|||
String filename_full = null;
|
||||
|
||||
// Get the content disposition, should be "form-data"
|
||||
int start = lowcase_line.indexOf(CONTENT_DISPOSITION_PREFIX);
|
||||
int end = lowcase_line.indexOf(";");
|
||||
var start = lowcase_line.indexOf(CONTENT_DISPOSITION_PREFIX);
|
||||
var end = lowcase_line.indexOf(";");
|
||||
if (-1 == start ||
|
||||
-1 == end) {
|
||||
throw new MultipartCorruptContentDispositionException(dispositionLine);
|
||||
|
@ -357,7 +357,7 @@ class MultipartRequest {
|
|||
filename = filename_full;
|
||||
|
||||
// The filename may contain a full path. Cut to just the filename.
|
||||
int last_slash = Math.max(filename.lastIndexOf('/'), filename.lastIndexOf('\\'));
|
||||
var last_slash = Math.max(filename.lastIndexOf('/'), filename.lastIndexOf('\\'));
|
||||
if (last_slash > -1) {
|
||||
// only take the filename (after the last slash)
|
||||
filename = filename.substring(last_slash + 1);
|
||||
|
@ -379,7 +379,7 @@ class MultipartRequest {
|
|||
|
||||
// Get the content type, if any
|
||||
if (lowcase_line.startsWith(CONTENT_TYPE_HEADER)) {
|
||||
int seperator_location = lowcase_line.indexOf(" ");
|
||||
var seperator_location = lowcase_line.indexOf(" ");
|
||||
if (-1 == seperator_location) {
|
||||
throw new MultipartCorruptContentTypeException(contentTypeLine);
|
||||
}
|
||||
|
@ -434,9 +434,9 @@ class MultipartRequest {
|
|||
output = new BufferedOutputStream(output_stream, 8 * 1024); // 8K
|
||||
|
||||
long downloaded_size = 0;
|
||||
int result = -1;
|
||||
var result = -1;
|
||||
String line = null;
|
||||
int line_length = 0;
|
||||
var line_length = 0;
|
||||
|
||||
// ServletInputStream.readLine() has the annoying habit of
|
||||
// adding a \r\n to the end of the last line.
|
||||
|
|
|
@ -46,15 +46,15 @@ public class RifeFilter implements Filter {
|
|||
if (request instanceof HttpServletRequest http_servlet_request &&
|
||||
response instanceof HttpServletResponse http_servlet_response) {
|
||||
try {
|
||||
String request_uri = http_servlet_request.getRequestURI();
|
||||
String extension = FileUtils.getExtension(request_uri);
|
||||
var request_uri = http_servlet_request.getRequestURI();
|
||||
var extension = FileUtils.getExtension(request_uri);
|
||||
|
||||
// check if the url matches one of the pass-through suffixes
|
||||
boolean passthrough = extension != null &&
|
||||
var pass_through = extension != null &&
|
||||
RifeConfig.engine().getPassThroughSuffixes().contains(extension);
|
||||
|
||||
// if not passed through, handle the request
|
||||
if (!passthrough) {
|
||||
if (!pass_through) {
|
||||
// create the servlet path
|
||||
if (null == gateUrl_) {
|
||||
var context_path = http_servlet_request.getContextPath();
|
||||
|
|
|
@ -29,17 +29,17 @@ public abstract class AbstractBeanHandler implements BeanHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
Constrained constrained = ConstrainedUtils.makeConstrainedInstance(bean);
|
||||
var constrained = ConstrainedUtils.makeConstrainedInstance(bean);
|
||||
|
||||
try {
|
||||
Map<String, Object> property_values = getPropertyValues(template, bean, prefix);
|
||||
var property_values = getPropertyValues(template, bean, prefix);
|
||||
Object property_value = null;
|
||||
String[] property_value_strings = null;
|
||||
String[] property_values_encoded = null;
|
||||
TemplateEncoder encoder = template.getEncoder();
|
||||
var encoder = template.getEncoder();
|
||||
|
||||
ConstrainedProperty constrained_property = null;
|
||||
for (String property_name : property_values.keySet()) {
|
||||
for (var property_name : property_values.keySet()) {
|
||||
property_value = property_values.get(property_name);
|
||||
property_values_encoded = null;
|
||||
|
||||
|
@ -62,7 +62,7 @@ public abstract class AbstractBeanHandler implements BeanHandler {
|
|||
property_value_strings.length > 0) {
|
||||
// encode the value if that's necessary
|
||||
property_values_encoded = new String[property_value_strings.length];
|
||||
for (int i = 0; i < property_values_encoded.length; i++) {
|
||||
for (var i = 0; i < property_values_encoded.length; i++) {
|
||||
if (null == encoder ||
|
||||
!encode) { // TODO : cmf ||
|
||||
// (constrained_property != null && constrained_property.isDisplayedRaw())) {
|
||||
|
@ -110,13 +110,13 @@ public abstract class AbstractBeanHandler implements BeanHandler {
|
|||
}
|
||||
|
||||
try {
|
||||
Constrained constrained = ConstrainedUtils.makeConstrainedInstance(bean);
|
||||
var constrained = ConstrainedUtils.makeConstrainedInstance(bean);
|
||||
ConstrainedProperty constrained_property = null;
|
||||
|
||||
Map<String, Object> property_values = getPropertyValues(template, bean, prefix);
|
||||
var property_values = getPropertyValues(template, bean, prefix);
|
||||
Object property_value = null;
|
||||
String[] property_value_strings = null;
|
||||
for (String property_name : property_values.keySet()) {
|
||||
for (var property_name : property_values.keySet()) {
|
||||
property_value = property_values.get(property_name);
|
||||
|
||||
if (property_name != null) {
|
||||
|
|
|
@ -45,7 +45,7 @@ public abstract class AbstractTemplate implements Template {
|
|||
}
|
||||
|
||||
if (fixedValues_.containsKey(valueId)) {
|
||||
InternalValue constructed_value = new InternalValue(this);
|
||||
var constructed_value = new InternalValue(this);
|
||||
constructed_value.appendText(fixedValues_.get(valueId));
|
||||
if (!appendBlockInternalForm(blockId, constructed_value)) {
|
||||
throw new BlockUnknownException(blockId);
|
||||
|
@ -57,7 +57,7 @@ public abstract class AbstractTemplate implements Template {
|
|||
throw new BlockUnknownException(blockId);
|
||||
}
|
||||
} else {
|
||||
InternalValue constructed_value = new InternalValue(this);
|
||||
var constructed_value = new InternalValue(this);
|
||||
if (!appendBlockInternalForm(blockId, constructed_value)) {
|
||||
throw new BlockUnknownException(blockId);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public abstract class AbstractTemplate implements Template {
|
|||
|
||||
fixedValues_.remove(valueId);
|
||||
|
||||
InternalValue constructed_value = new InternalValue(this);
|
||||
var constructed_value = new InternalValue(this);
|
||||
if (!appendBlockInternalForm(blockId, constructed_value)) {
|
||||
throw new BlockUnknownException(blockId);
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public abstract class AbstractTemplate implements Template {
|
|||
throw new BlockUnknownException(id);
|
||||
}
|
||||
|
||||
ExternalValue result = new ExternalValue();
|
||||
var result = new ExternalValue();
|
||||
|
||||
if (!appendBlockExternalForm(id, result)) {
|
||||
throw new BlockUnknownException(id);
|
||||
|
@ -108,14 +108,14 @@ public abstract class AbstractTemplate implements Template {
|
|||
|
||||
public final String getContent()
|
||||
throws TemplateException {
|
||||
List<String> set_values = processLateTags();
|
||||
var set_values = processLateTags();
|
||||
|
||||
ExternalValue result = new ExternalValue();
|
||||
var result = new ExternalValue();
|
||||
|
||||
if (!appendBlockExternalForm("", result)) {
|
||||
throw new BlockUnknownException("");
|
||||
}
|
||||
String content = result.toString();
|
||||
var content = result.toString();
|
||||
removeValues(set_values);
|
||||
return content;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public abstract class AbstractTemplate implements Template {
|
|||
throw new BlockUnknownException(id);
|
||||
}
|
||||
|
||||
ExternalValue result = new ExternalValue();
|
||||
var result = new ExternalValue();
|
||||
|
||||
if (!appendBlockExternalForm(id, result)) {
|
||||
throw new BlockUnknownException(id);
|
||||
|
@ -155,7 +155,7 @@ public abstract class AbstractTemplate implements Template {
|
|||
return;
|
||||
}
|
||||
|
||||
ExternalValue result = new ExternalValue();
|
||||
var result = new ExternalValue();
|
||||
|
||||
if (!appendBlockExternalForm("", result)) {
|
||||
throw new BlockUnknownException("");
|
||||
|
@ -176,7 +176,7 @@ public abstract class AbstractTemplate implements Template {
|
|||
throw new BlockUnknownException(id);
|
||||
}
|
||||
|
||||
ExternalValue result = new ExternalValue();
|
||||
var result = new ExternalValue();
|
||||
|
||||
if (!appendBlockExternalForm(id, result)) {
|
||||
throw new BlockUnknownException(id);
|
||||
|
@ -187,9 +187,9 @@ public abstract class AbstractTemplate implements Template {
|
|||
|
||||
public final List<CharSequence> getDeferredContent()
|
||||
throws TemplateException {
|
||||
List<String> set_values = processLateTags();
|
||||
var set_values = processLateTags();
|
||||
|
||||
ExternalValue result = new ExternalValue();
|
||||
var result = new ExternalValue();
|
||||
|
||||
if (!appendBlockExternalForm("", result)) {
|
||||
throw new BlockUnknownException("");
|
||||
|
@ -228,12 +228,12 @@ public abstract class AbstractTemplate implements Template {
|
|||
private void _evaluateRenderTags(List<String> setValues)
|
||||
throws TemplateException {
|
||||
if (hasFilteredValues(TemplateFactoryFilters.TAG_RENDER)) {
|
||||
List<String[]> render_tags = getFilteredValues(TemplateFactoryFilters.TAG_RENDER);
|
||||
for (String[] captured_groups : render_tags) {
|
||||
var render_tags = getFilteredValues(TemplateFactoryFilters.TAG_RENDER);
|
||||
for (var captured_groups : render_tags) {
|
||||
// only execute the renderer if the value hasn't been set in the
|
||||
// template yet
|
||||
if (!isValueSet(captured_groups[0])) {
|
||||
String classname = captured_groups[1];
|
||||
var classname = captured_groups[1];
|
||||
try {
|
||||
Class klass = Class.forName(classname);
|
||||
if (!ValueRenderer.class.isAssignableFrom(klass)) {
|
||||
|
@ -266,12 +266,12 @@ public abstract class AbstractTemplate implements Template {
|
|||
}
|
||||
|
||||
private void _evaluateConfigTags(List<String> setValues) {
|
||||
List<String[]> config_tags = getFilteredValues(TemplateFactoryFilters.TAG_CONFIG);
|
||||
var config_tags = getFilteredValues(TemplateFactoryFilters.TAG_CONFIG);
|
||||
if (config_tags != null) {
|
||||
String config_key = null;
|
||||
String config_value = null;
|
||||
|
||||
for (String[] captured_groups : config_tags) {
|
||||
for (var captured_groups : config_tags) {
|
||||
// only set the config value if the value hasn't been set in the
|
||||
// template yet
|
||||
if (!isValueSet(captured_groups[0])) {
|
||||
|
@ -320,7 +320,7 @@ public abstract class AbstractTemplate implements Template {
|
|||
if (hasResourceBundles()) {
|
||||
l10n_key = captured_groups[1];
|
||||
|
||||
for (ResourceBundle bundle : resourceBundles_) {
|
||||
for (var bundle : resourceBundles_) {
|
||||
// obtain the configuration value
|
||||
try {
|
||||
l10n_value = bundle.getString(l10n_key);
|
||||
|
@ -680,7 +680,7 @@ public abstract class AbstractTemplate implements Template {
|
|||
return fixedValues_.get(id).toString();
|
||||
}
|
||||
if (constructedValues_.containsKey(id)) {
|
||||
ExternalValue result = new ExternalValue();
|
||||
var result = new ExternalValue();
|
||||
constructedValues_.get(id).appendExternalForm(result);
|
||||
return result.toString();
|
||||
}
|
||||
|
@ -712,7 +712,7 @@ public abstract class AbstractTemplate implements Template {
|
|||
return false;
|
||||
}
|
||||
|
||||
ExternalValue temp_value = new ExternalValue();
|
||||
var temp_value = new ExternalValue();
|
||||
|
||||
return appendBlockExternalForm(id, temp_value);
|
||||
}
|
||||
|
@ -747,7 +747,7 @@ public abstract class AbstractTemplate implements Template {
|
|||
return;
|
||||
}
|
||||
|
||||
for (String id : ids) {
|
||||
for (var id : ids) {
|
||||
removeValue(id);
|
||||
}
|
||||
}
|
||||
|
@ -804,7 +804,7 @@ public abstract class AbstractTemplate implements Template {
|
|||
return;
|
||||
}
|
||||
|
||||
InternalValue constructed_value = constructedValues_.get(id);
|
||||
var constructed_value = constructedValues_.get(id);
|
||||
if (constructed_value != null) {
|
||||
constructed_value.appendExternalForm(result);
|
||||
return;
|
||||
|
@ -824,7 +824,7 @@ public abstract class AbstractTemplate implements Template {
|
|||
return;
|
||||
}
|
||||
|
||||
InternalValue constructed_value = constructedValues_.get(id);
|
||||
var constructed_value = constructedValues_.get(id);
|
||||
if (constructed_value != null) {
|
||||
result.appendConstructedValue(constructed_value);
|
||||
return;
|
||||
|
@ -1012,13 +1012,13 @@ public abstract class AbstractTemplate implements Template {
|
|||
|
||||
new_template.fixedValues_ = new HashMap<>();
|
||||
|
||||
for (String value_id : fixedValues_.keySet()) {
|
||||
for (var value_id : fixedValues_.keySet()) {
|
||||
new_template.fixedValues_.put(value_id, fixedValues_.get(value_id));
|
||||
}
|
||||
|
||||
new_template.constructedValues_ = new HashMap<>();
|
||||
|
||||
for (String constructed_value_id : constructedValues_.keySet()) {
|
||||
for (var constructed_value_id : constructedValues_.keySet()) {
|
||||
new_template.constructedValues_.put(constructed_value_id, constructedValues_.get(constructed_value_id));
|
||||
}
|
||||
|
||||
|
|
|
@ -12,12 +12,12 @@ import rife.tools.exceptions.BeanUtilsException;
|
|||
import java.util.Map;
|
||||
|
||||
public class BeanHandlerHtml extends AbstractBeanHandler {
|
||||
private FormBuilder formBuilder_ = new FormBuilderHtml();
|
||||
private final FormBuilder formBuilder_ = new FormBuilderHtml();
|
||||
|
||||
BeanHandlerHtml() {
|
||||
}
|
||||
|
||||
public static BeanHandlerHtml getInstance() {
|
||||
public static BeanHandlerHtml instance() {
|
||||
return BeanHandlerHtmlSingleton.INSTANCE;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ public class BeanHandlerPlain extends AbstractBeanHandler {
|
|||
BeanHandlerPlain() {
|
||||
}
|
||||
|
||||
public static BeanHandlerPlain getInstance() {
|
||||
public static BeanHandlerPlain instance() {
|
||||
return BeanHandlerPlainSingleton.INSTANCE;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,12 +12,12 @@ import rife.tools.exceptions.BeanUtilsException;
|
|||
import java.util.Map;
|
||||
|
||||
public class BeanHandlerXml extends AbstractBeanHandler {
|
||||
private FormBuilder formBuilder_ = new FormBuilderXml();
|
||||
private final FormBuilder formBuilder_ = new FormBuilderXml();
|
||||
|
||||
BeanHandlerXml() {
|
||||
}
|
||||
|
||||
public static BeanHandlerXml getInstance() {
|
||||
public static BeanHandlerXml instance() {
|
||||
return BeanHandlerXmlSingleton.INSTANCE;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public class FilteredTagsMap extends HashMap<String, FilteredTags> {
|
|||
assert filter.length() > 0;
|
||||
assert capturedGroups != null;
|
||||
|
||||
FilteredTags filtered_values = getFilteredTag(filter);
|
||||
var filtered_values = getFilteredTag(filter);
|
||||
if (null == filtered_values) {
|
||||
filtered_values = new FilteredTags();
|
||||
put(filter, filtered_values);
|
||||
|
|
|
@ -12,12 +12,12 @@ import java.lang.ref.SoftReference;
|
|||
public class InternalString implements CharSequence {
|
||||
private CharSequence stringValue_;
|
||||
|
||||
private transient SoftReference<byte[]> mBytesValue_US_ASCII = null;
|
||||
private transient SoftReference<byte[]> mBytesValue_ISO_8859_1 = null;
|
||||
private transient SoftReference<byte[]> mBytesValue_UTF_8 = null;
|
||||
private transient SoftReference<byte[]> mBytesValue_UTF_16 = null;
|
||||
private transient SoftReference<byte[]> mBytesValue_UTF_16BE = null;
|
||||
private transient SoftReference<byte[]> mBytesValue_UTF_16LE = null;
|
||||
private transient SoftReference<byte[]> bytesValue_US_ASCII_ = null;
|
||||
private transient SoftReference<byte[]> bytesValue_ISO_8859_1_ = null;
|
||||
private transient SoftReference<byte[]> bytesValue_UTF_8_ = null;
|
||||
private transient SoftReference<byte[]> bytesValue_UTF_16_ = null;
|
||||
private transient SoftReference<byte[]> bytesValue_UTF_16BE_ = null;
|
||||
private transient SoftReference<byte[]> bytesValue_UTF_16LE_ = null;
|
||||
|
||||
public InternalString(String value) {
|
||||
stringValue_ = value;
|
||||
|
@ -36,63 +36,63 @@ public class InternalString implements CharSequence {
|
|||
byte[] bytes = null;
|
||||
|
||||
if (StringUtils.ENCODING_ISO_8859_1.equals(charsetName)) {
|
||||
if (mBytesValue_ISO_8859_1 != null) {
|
||||
bytes = mBytesValue_ISO_8859_1.get();
|
||||
if (bytesValue_ISO_8859_1_ != null) {
|
||||
bytes = bytesValue_ISO_8859_1_.get();
|
||||
}
|
||||
if (null == bytes) {
|
||||
bytes = toString().getBytes(charsetName);
|
||||
if (null == mBytesValue_ISO_8859_1) {
|
||||
mBytesValue_ISO_8859_1 = new SoftReference<>(bytes);
|
||||
if (null == bytesValue_ISO_8859_1_) {
|
||||
bytesValue_ISO_8859_1_ = new SoftReference<>(bytes);
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.ENCODING_UTF_8.equals(charsetName)) {
|
||||
if (mBytesValue_UTF_8 != null) {
|
||||
bytes = mBytesValue_UTF_8.get();
|
||||
if (bytesValue_UTF_8_ != null) {
|
||||
bytes = bytesValue_UTF_8_.get();
|
||||
}
|
||||
if (null == bytes) {
|
||||
bytes = toString().getBytes(charsetName);
|
||||
if (null == mBytesValue_UTF_8) {
|
||||
mBytesValue_UTF_8 = new SoftReference<>(bytes);
|
||||
if (null == bytesValue_UTF_8_) {
|
||||
bytesValue_UTF_8_ = new SoftReference<>(bytes);
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.ENCODING_US_ASCII.equals(charsetName)) {
|
||||
if (mBytesValue_US_ASCII != null) {
|
||||
bytes = mBytesValue_US_ASCII.get();
|
||||
if (bytesValue_US_ASCII_ != null) {
|
||||
bytes = bytesValue_US_ASCII_.get();
|
||||
}
|
||||
if (null == bytes) {
|
||||
bytes = toString().getBytes(charsetName);
|
||||
if (null == mBytesValue_US_ASCII) {
|
||||
mBytesValue_US_ASCII = new SoftReference<>(bytes);
|
||||
if (null == bytesValue_US_ASCII_) {
|
||||
bytesValue_US_ASCII_ = new SoftReference<>(bytes);
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.ENCODING_UTF_16.equals(charsetName)) {
|
||||
if (mBytesValue_UTF_16 != null) {
|
||||
bytes = mBytesValue_UTF_16.get();
|
||||
if (bytesValue_UTF_16_ != null) {
|
||||
bytes = bytesValue_UTF_16_.get();
|
||||
}
|
||||
if (null == bytes) {
|
||||
bytes = toString().getBytes(charsetName);
|
||||
if (null == mBytesValue_UTF_16) {
|
||||
mBytesValue_UTF_16 = new SoftReference<>(bytes);
|
||||
if (null == bytesValue_UTF_16_) {
|
||||
bytesValue_UTF_16_ = new SoftReference<>(bytes);
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.ENCODING_UTF_16BE.equals(charsetName)) {
|
||||
if (mBytesValue_UTF_16BE != null) {
|
||||
bytes = mBytesValue_UTF_16BE.get();
|
||||
if (bytesValue_UTF_16BE_ != null) {
|
||||
bytes = bytesValue_UTF_16BE_.get();
|
||||
}
|
||||
if (null == bytes) {
|
||||
bytes = toString().getBytes(charsetName);
|
||||
if (null == mBytesValue_UTF_16BE) {
|
||||
mBytesValue_UTF_16BE = new SoftReference<>(bytes);
|
||||
if (null == bytesValue_UTF_16BE_) {
|
||||
bytesValue_UTF_16BE_ = new SoftReference<>(bytes);
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.ENCODING_UTF_16LE.equals(charsetName)) {
|
||||
if (mBytesValue_UTF_16LE != null) {
|
||||
bytes = mBytesValue_UTF_16LE.get();
|
||||
if (bytesValue_UTF_16LE_ != null) {
|
||||
bytes = bytesValue_UTF_16LE_.get();
|
||||
}
|
||||
if (null == bytes) {
|
||||
bytes = toString().getBytes(charsetName);
|
||||
if (null == mBytesValue_UTF_16LE) {
|
||||
mBytesValue_UTF_16LE = new SoftReference<>(bytes);
|
||||
if (null == bytesValue_UTF_16LE_) {
|
||||
bytesValue_UTF_16LE_ = new SoftReference<>(bytes);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -108,29 +108,29 @@ public class InternalString implements CharSequence {
|
|||
|
||||
public void append(String value) {
|
||||
stringValue_ = stringValue_ + value;
|
||||
if (mBytesValue_ISO_8859_1 != null) {
|
||||
SoftReference<byte[]> reference = mBytesValue_ISO_8859_1;
|
||||
mBytesValue_ISO_8859_1 = null;
|
||||
if (bytesValue_ISO_8859_1_ != null) {
|
||||
SoftReference<byte[]> reference = bytesValue_ISO_8859_1_;
|
||||
bytesValue_ISO_8859_1_ = null;
|
||||
reference.clear();
|
||||
}
|
||||
if (mBytesValue_UTF_8 != null) {
|
||||
SoftReference<byte[]> reference = mBytesValue_UTF_8;
|
||||
mBytesValue_UTF_8 = null;
|
||||
if (bytesValue_UTF_8_ != null) {
|
||||
SoftReference<byte[]> reference = bytesValue_UTF_8_;
|
||||
bytesValue_UTF_8_ = null;
|
||||
reference.clear();
|
||||
}
|
||||
if (mBytesValue_UTF_16 != null) {
|
||||
SoftReference<byte[]> reference = mBytesValue_UTF_16;
|
||||
mBytesValue_UTF_16 = null;
|
||||
if (bytesValue_UTF_16_ != null) {
|
||||
SoftReference<byte[]> reference = bytesValue_UTF_16_;
|
||||
bytesValue_UTF_16_ = null;
|
||||
reference.clear();
|
||||
}
|
||||
if (mBytesValue_UTF_16BE != null) {
|
||||
SoftReference<byte[]> reference = mBytesValue_UTF_16BE;
|
||||
mBytesValue_UTF_16BE = null;
|
||||
if (bytesValue_UTF_16BE_ != null) {
|
||||
SoftReference<byte[]> reference = bytesValue_UTF_16BE_;
|
||||
bytesValue_UTF_16BE_ = null;
|
||||
reference.clear();
|
||||
}
|
||||
if (mBytesValue_UTF_16LE != null) {
|
||||
SoftReference<byte[]> reference = mBytesValue_UTF_16LE;
|
||||
mBytesValue_UTF_16LE = null;
|
||||
if (bytesValue_UTF_16LE_ != null) {
|
||||
SoftReference<byte[]> reference = bytesValue_UTF_16LE_;
|
||||
bytesValue_UTF_16LE_ = null;
|
||||
reference.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.text.NumberFormat;
|
|||
* @since 1.0
|
||||
*/
|
||||
public class InternalValue {
|
||||
private AbstractTemplate template_;
|
||||
private final AbstractTemplate template_;
|
||||
private ArrayList<CharSequence> construction_ = new ArrayList<>();
|
||||
private ArrayList<CharSequence> valueIds_ = new ArrayList<>();
|
||||
private ArrayList<CharSequence> valueTags_ = new ArrayList<>();
|
||||
|
@ -269,17 +269,9 @@ public class InternalValue {
|
|||
increasePartsCapacity(constructedValue.partsSize());
|
||||
increaseValuesCapacity(constructedValue.valuesSize());
|
||||
|
||||
for (CharSequence charsequence : constructedValue.construction_) {
|
||||
construction_.add(charsequence);
|
||||
}
|
||||
|
||||
for (CharSequence charsequence : constructedValue.valueIds_) {
|
||||
valueIds_.add(charsequence);
|
||||
}
|
||||
|
||||
for (CharSequence charsequence : constructedValue.valueTags_) {
|
||||
valueTags_.add(charsequence);
|
||||
}
|
||||
construction_.addAll(constructedValue.construction_);
|
||||
valueIds_.addAll(constructedValue.valueIds_);
|
||||
valueTags_.addAll(constructedValue.valueTags_);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,7 +42,7 @@ final class Parsed implements Opcodes {
|
|||
Map<Integer, ArrayList<String>> hashcode_keys_mapping = new HashMap<>();
|
||||
int hashcode;
|
||||
ArrayList<String> keys;
|
||||
for (String key : stringCollection) {
|
||||
for (var key : stringCollection) {
|
||||
hashcode = key.hashCode();
|
||||
keys = hashcode_keys_mapping.computeIfAbsent(hashcode, k -> new ArrayList<>());
|
||||
keys.add(key);
|
||||
|
@ -125,10 +125,10 @@ method.visitMaxs (0, 0);
|
|||
hashcode_keys_mapping = getHashcodeKeysMapping(blocks_.keySet());
|
||||
blockparts_order = new LinkedHashMap<>();
|
||||
{
|
||||
Set<Integer> hashcodes_set = hashcode_keys_mapping.keySet();
|
||||
var hashcodes_set = hashcode_keys_mapping.keySet();
|
||||
hashcodes = new int[hashcodes_set.size()];
|
||||
int hashcode_index = 0;
|
||||
for (Integer i : hashcodes_set) {
|
||||
var hashcode_index = 0;
|
||||
for (var i : hashcodes_set) {
|
||||
hashcodes[hashcode_index++] = i;
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ method.visitMethodInsn (INVOKEVIRTUAL, "java/lang/String", "hashCode", "
|
|||
var external_default = new Label();
|
||||
var external_found = new Label();
|
||||
var external_labels = new Label[hashcodes.length];
|
||||
for (int i = 0; i < external_labels.length; i++) {
|
||||
for (var i = 0; i < external_labels.length; i++) {
|
||||
external_labels[i] = new Label();
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ method.visitLookupSwitchInsn (external_default, hashcodes, external_labels);
|
|||
var blockdata_static_prefix = "sBlockPart";
|
||||
var blockdata_static_counter = 0L;
|
||||
String static_identifier;
|
||||
for (int i = 0; i < hashcodes.length; i++) {
|
||||
for (var i = 0; i < hashcodes.length; i++) {
|
||||
method.visitLabel (external_labels[i]);
|
||||
|
||||
keys = hashcode_keys_mapping.get(hashcodes[i]);
|
||||
|
@ -169,7 +169,7 @@ method.visitLabel (external_labels[i]);
|
|||
block_part.visitByteCodeExternalForm(method, full_classname, static_identifier);
|
||||
}
|
||||
} else {
|
||||
for (String key : keys) {
|
||||
for (var key : keys) {
|
||||
var after_key_label = new Label();
|
||||
method.visitVarInsn (ALOAD, 1);
|
||||
method.visitLdcInsn (key);
|
||||
|
@ -178,7 +178,7 @@ method.visitJumpInsn (IFEQ, after_key_label);
|
|||
|
||||
block_data = blocks_.get(key);
|
||||
|
||||
for (ParsedBlockPart block_part : block_data) {
|
||||
for (var block_part : block_data) {
|
||||
static_identifier = blockdata_static_prefix + (blockdata_static_counter++);
|
||||
|
||||
blockparts_order.put(static_identifier, block_part);
|
||||
|
@ -210,14 +210,14 @@ method.visitMethodInsn (INVOKEVIRTUAL, "java/lang/String", "hashCode", "
|
|||
var internal_default = new Label();
|
||||
var internal_found = new Label();
|
||||
var internal_labels = new Label[hashcodes.length];
|
||||
for (int i = 0; i < internal_labels.length; i++) {
|
||||
for (var i = 0; i < internal_labels.length; i++) {
|
||||
internal_labels[i] = new Label();
|
||||
}
|
||||
|
||||
method.visitLookupSwitchInsn (internal_default, hashcodes, internal_labels);
|
||||
String static_identifier = null;
|
||||
var static_identifiers_it = blockparts_order.keySet().iterator();
|
||||
for (int i = 0; i < hashcodes.length; i++) {
|
||||
for (var i = 0; i < hashcodes.length; i++) {
|
||||
method.visitLabel (internal_labels[i]);
|
||||
|
||||
var text_count = 0;
|
||||
|
@ -265,7 +265,7 @@ method.visitMethodInsn (INVOKEVIRTUAL, full_classname, "increaseValuesCa
|
|||
}
|
||||
method.visitJumpInsn (GOTO, internal_found);
|
||||
} else {
|
||||
for (String key : keys) {
|
||||
for (var key : keys) {
|
||||
var after_key_label = new Label();
|
||||
method.visitVarInsn (ALOAD, 1);
|
||||
method.visitLdcInsn (key);
|
||||
|
@ -569,7 +569,7 @@ method.visitTypeInsn (CHECKCAST, "java/util/List");
|
|||
method.visitVarInsn (ASTORE, 2);
|
||||
method.visitInsn (ACONST_NULL);
|
||||
method.visitVarInsn (ALOAD, 2);
|
||||
Label list_null_check = new Label();
|
||||
var list_null_check = new Label();
|
||||
method.visitJumpInsn (IF_ACMPNE, list_null_check);
|
||||
method.visitFieldInsn (GETSTATIC, "java/util/Collections", "EMPTY_LIST", "Ljava/util/List;");
|
||||
method.visitVarInsn (ASTORE, 2);
|
||||
|
@ -807,7 +807,7 @@ method.visitTypeInsn (NEW, "java/util/HashMap");
|
|||
method.visitInsn (DUP);
|
||||
method.visitMethodInsn (INVOKESPECIAL, "java/util/HashMap", "<init>", "()V", false);
|
||||
method.visitFieldInsn (PUTSTATIC, full_classname, "sDefaultValues", "Ljava/util/HashMap;");
|
||||
for (String key : defaultValues_.keySet()) {
|
||||
for (var key : defaultValues_.keySet()) {
|
||||
method.visitFieldInsn (GETSTATIC, full_classname, "sDefaultValues", "Ljava/util/HashMap;");
|
||||
method.visitLdcInsn (key);
|
||||
method.visitLdcInsn (defaultValues_.get(key));
|
||||
|
@ -874,7 +874,7 @@ method.visitVarInsn (ASTORE, 1);
|
|||
method.visitVarInsn (ALOAD, 1);
|
||||
addIntegerConst(method, captured_groups.length);
|
||||
method.visitTypeInsn (ANEWARRAY, "java/lang/String");
|
||||
for (int i = 0; i < captured_groups.length; i++) {
|
||||
for (var i = 0; i < captured_groups.length; i++) {
|
||||
method.visitInsn (DUP);
|
||||
addIntegerConst(method, i);
|
||||
method.visitLdcInsn (captured_groups[i]);
|
||||
|
|
|
@ -132,7 +132,7 @@ public class Parser implements Cloneable {
|
|||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < other_parser.blockFilters_.length; i++) {
|
||||
for (var i = 0; i < other_parser.blockFilters_.length; i++) {
|
||||
if (!other_parser.blockFilters_[i].pattern().equals(this.blockFilters_[i].pattern())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ public class Parser implements Cloneable {
|
|||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < other_parser.valueFilters_.length; i++) {
|
||||
for (var i = 0; i < other_parser.valueFilters_.length; i++) {
|
||||
if (!other_parser.valueFilters_[i].pattern().equals(this.valueFilters_[i].pattern())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ public class Parser implements Cloneable {
|
|||
throws TemplateException {
|
||||
if (null == name) throw new IllegalArgumentException("name can't be null.");
|
||||
|
||||
URL resource = resolve(name);
|
||||
var resource = resolve(name);
|
||||
if (null == resource) {
|
||||
throw new TemplateNotFoundException(name, null);
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ public class Parser implements Cloneable {
|
|||
|
||||
var name_chars = name.toCharArray();
|
||||
int char_code;
|
||||
for (int i = 0; i < name_chars.length; i++) {
|
||||
for (var i = 0; i < name_chars.length; i++) {
|
||||
char_code = name_chars[i];
|
||||
if ((char_code >= 48 && char_code <= 57) ||
|
||||
(char_code >= 65 && char_code <= 90) ||
|
||||
|
@ -234,7 +234,7 @@ public class Parser implements Cloneable {
|
|||
|
||||
var class_name = template_name;
|
||||
var subpackage = "";
|
||||
int package_separator = template_name.lastIndexOf(".");
|
||||
var package_separator = template_name.lastIndexOf(".");
|
||||
if (package_separator != -1) {
|
||||
subpackage = "." + template_name.substring(0, package_separator);
|
||||
class_name = template_name.substring(package_separator + 1);
|
||||
|
@ -253,13 +253,13 @@ public class Parser implements Cloneable {
|
|||
assert parsed != null;
|
||||
|
||||
// get the resource of the template file
|
||||
URL resource = parsed.getResource();
|
||||
var resource = parsed.getResource();
|
||||
|
||||
// obtain the content of the template file
|
||||
String content = getContent(parsed.getTemplateName(), parsed, resource, encoding, transformer);
|
||||
var content = getContent(parsed.getTemplateName(), parsed, resource, encoding, transformer);
|
||||
|
||||
// replace the included templates
|
||||
Stack<String> previous_includes = new Stack<>();
|
||||
var previous_includes = new Stack<String>();
|
||||
previous_includes.push(parsed.getFullClassName());
|
||||
content = replaceIncludeTags(parsed, content, previous_includes, encoding, transformer);
|
||||
previous_includes.pop();
|
||||
|
@ -315,16 +315,16 @@ public class Parser implements Cloneable {
|
|||
encoding = RifeConfig.template().getDefaultEncoding();
|
||||
}
|
||||
|
||||
ByteArrayOutputStream result = new ByteArrayOutputStream();
|
||||
var result = new ByteArrayOutputStream();
|
||||
|
||||
// transform the content
|
||||
transformer.setResourceFinder(templateFactory_.getResourceFinder());
|
||||
Collection<URL> dependencies = transformer.transform(templateName, resource, result, encoding);
|
||||
var dependencies = transformer.transform(templateName, resource, result, encoding);
|
||||
// get the dependencies and their modification times
|
||||
if (dependencies != null &&
|
||||
dependencies.size() > 0) {
|
||||
long modification_time = 0;
|
||||
for (URL dependency_resource : dependencies) {
|
||||
for (var dependency_resource : dependencies) {
|
||||
try {
|
||||
modification_time = transformer.getResourceFinder().getModificationTime(dependency_resource);
|
||||
} catch (ResourceFinderErrorException e) {
|
||||
|
@ -441,31 +441,31 @@ public class Parser implements Cloneable {
|
|||
name = ctx.CTagName();
|
||||
}
|
||||
|
||||
String included_template_name = name.getText();
|
||||
var included_template_name = name.getText();
|
||||
// obtain the parser that will be used to get the included content
|
||||
Parser include_parser = Parser.this;
|
||||
var include_parser = Parser.this;
|
||||
|
||||
// check if the included template references another template type
|
||||
int doublecolon_index = included_template_name.indexOf(':');
|
||||
var doublecolon_index = included_template_name.indexOf(':');
|
||||
if (doublecolon_index != -1)
|
||||
{
|
||||
String template_type = included_template_name.substring(0, doublecolon_index);
|
||||
var template_type = included_template_name.substring(0, doublecolon_index);
|
||||
if (!template_type.equals(templateFactory_.toString()))
|
||||
{
|
||||
TemplateFactory factory = TemplateFactory.getFactory(template_type);
|
||||
var factory = TemplateFactory.getFactory(template_type);
|
||||
include_parser = factory.getParser();
|
||||
included_template_name = included_template_name.substring(doublecolon_index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
URL included_template_resource = include_parser.resolve(included_template_name);
|
||||
var included_template_resource = include_parser.resolve(included_template_name);
|
||||
|
||||
if (null == included_template_resource) {
|
||||
// TODO : this should return the line itself
|
||||
var position = new DocumentPosition(ctx.getStart().getText(), ctx.getStart().getLine(), ctx.getStart().getCharPositionInLine());
|
||||
throw new IncludeNotFoundException(parsed_.getClassName(), position, included_template_name);
|
||||
}
|
||||
Parsed included_template_parsed = include_parser.prepare(included_template_name, included_template_resource);
|
||||
var included_template_parsed = include_parser.prepare(included_template_name, included_template_resource);
|
||||
|
||||
// check for circular references
|
||||
if (previousIncludes_.contains(included_template_parsed.getFullClassName())) {
|
||||
|
@ -475,17 +475,17 @@ public class Parser implements Cloneable {
|
|||
}
|
||||
|
||||
// parse the included template's include tags too
|
||||
String included_template_content = include_parser.getContent(included_template_name, parsed_, included_template_parsed.getResource(), encoding_, transformer_);
|
||||
var included_template_content = include_parser.getContent(included_template_name, parsed_, included_template_parsed.getResource(), encoding_, transformer_);
|
||||
previousIncludes_.push(included_template_parsed.getFullClassName());
|
||||
String replaced_content = replaceIncludeTags(included_template_parsed, included_template_content, previousIncludes_, encoding_, transformer_);
|
||||
var replaced_content = replaceIncludeTags(included_template_parsed, included_template_content, previousIncludes_, encoding_, transformer_);
|
||||
previousIncludes_.pop();
|
||||
|
||||
// retain the link to this include file for optional later modification time checking
|
||||
parsed_.addDependency(included_template_parsed);
|
||||
|
||||
// add the dependencies of the included template too
|
||||
Map<URL, Long> included_dependencies = included_template_parsed.getDependencies();
|
||||
for (Map.Entry<URL, Long> included_dependency : included_dependencies.entrySet()) {
|
||||
var included_dependencies = included_template_parsed.getDependencies();
|
||||
for (var included_dependency : included_dependencies.entrySet()) {
|
||||
parsed_.addDependency(included_dependency.getKey(), included_dependency.getValue());
|
||||
}
|
||||
|
||||
|
@ -535,7 +535,7 @@ public class Parser implements Cloneable {
|
|||
tag = ctx.TSTART_V() + " " + value_id + ctx.TSTERM();
|
||||
}
|
||||
|
||||
String block_id = blockIds_.peek();
|
||||
var block_id = blockIds_.peek();
|
||||
if (block_id != null) {
|
||||
parsed_.addValue(value_id);
|
||||
blocks_.get(block_id).add(new ParsedBlockValue(value_id, tag));
|
||||
|
@ -562,7 +562,7 @@ public class Parser implements Cloneable {
|
|||
tag = ctx.TSTART_V() + " " + value_id + ctx.TENDI() + ctx.TCLOSE_V();
|
||||
}
|
||||
|
||||
String block_id = blockIds_.peek();
|
||||
var block_id = blockIds_.peek();
|
||||
if (block_id != null) {
|
||||
parsed_.addValue(value_id);
|
||||
parsed_.setDefaultValue(value_id, currentValueData_.toString());
|
||||
|
@ -578,7 +578,7 @@ public class Parser implements Cloneable {
|
|||
if (name == null) {
|
||||
name = ctx.CTagName();
|
||||
}
|
||||
final String block_id = name.getText();
|
||||
final var block_id = name.getText();
|
||||
blockIds_.push(block_id);
|
||||
blocks_.put(block_id, new ParsedBlockData());
|
||||
}
|
||||
|
@ -594,7 +594,7 @@ public class Parser implements Cloneable {
|
|||
if (name == null) {
|
||||
name = ctx.CTagName();
|
||||
}
|
||||
final String block_id = name.getText();
|
||||
final var block_id = name.getText();
|
||||
parsed_.setBlockvalue(block_id);
|
||||
blockIds_.push(block_id);
|
||||
blocks_.put(block_id, new ParsedBlockData());
|
||||
|
@ -611,7 +611,7 @@ public class Parser implements Cloneable {
|
|||
if (name == null) {
|
||||
name = ctx.CTagName();
|
||||
}
|
||||
final String block_id = name.getText();
|
||||
final var block_id = name.getText();
|
||||
parsed_.setBlockvalue(block_id);
|
||||
blockIds_.push(block_id);
|
||||
|
||||
|
@ -629,7 +629,7 @@ public class Parser implements Cloneable {
|
|||
|
||||
@Override
|
||||
public void exitBlockData(TemplateMainParser.BlockDataContext ctx) {
|
||||
String block_id = blockIds_.peek();
|
||||
var block_id = blockIds_.peek();
|
||||
if (block_id != null) {
|
||||
var data = blocks_.get(block_id);
|
||||
var last = data.getLastPart();
|
||||
|
@ -681,12 +681,12 @@ public class Parser implements Cloneable {
|
|||
String pattern = null;
|
||||
String[] captured_groups_array = null;
|
||||
|
||||
ArrayList<String> filtered_tags = new ArrayList<String>();
|
||||
var filtered_tags = new ArrayList<String>();
|
||||
|
||||
// iterate over the tag filters
|
||||
for (Pattern filter_pattern : filters) {
|
||||
for (var filter_pattern : filters) {
|
||||
// go over all the tags and try to match them against the current filter
|
||||
for (String tag : tags) {
|
||||
for (var tag : tags) {
|
||||
// skip over tags that have already been filtered
|
||||
if (filtered_tags.contains(tag)) {
|
||||
continue;
|
||||
|
@ -705,7 +705,7 @@ public class Parser implements Cloneable {
|
|||
|
||||
if (filter_matcher.groupCount() > 0) {
|
||||
// store the captured groups
|
||||
for (int j = 1; j <= filter_matcher.groupCount(); j++) {
|
||||
for (var j = 1; j <= filter_matcher.groupCount(); j++) {
|
||||
captured_groups.add(filter_matcher.group(j));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -972,8 +972,7 @@ public interface Template extends Cloneable {
|
|||
* identifiers each time these features are used, RIFE filters them out at
|
||||
* template compilation and keeps them available in a separate collection.
|
||||
* <p>This method is mainly used by the framework itself, the supported
|
||||
* filter regular expressions are available from {@link TemplateFactory}
|
||||
* and {@link TemplateFactoryEngineTypes}.
|
||||
* filter regular expressions are available from {@link TemplateFactory}.
|
||||
*
|
||||
* @param filter a template factory regular expression
|
||||
* @return a list of captured groups for matching block ID's
|
||||
|
@ -1001,8 +1000,7 @@ public interface Template extends Cloneable {
|
|||
* RIFE filters them out at template compilation and keeps them available
|
||||
* in a separate collection.
|
||||
* <p>This method is mainly used by the framework itself, the supported
|
||||
* filter regular expressions are available from {@link TemplateFactory}
|
||||
* and {@link TemplateFactoryEngineTypes}.
|
||||
* filter regular expressions are available from {@link TemplateFactory}.
|
||||
*
|
||||
* @param filter a template factory regular expression
|
||||
* @return a list of captured groups for matching value ID's
|
||||
|
@ -1023,7 +1021,7 @@ public interface Template extends Cloneable {
|
|||
boolean hasFilteredValues(String filter);
|
||||
|
||||
/**
|
||||
* Fills all values in this template which match "<code>L10N:<em>key</em></code>",
|
||||
* Fills all values in this template which match "<code>l10n:<em>key</em></code>",
|
||||
* where "<code>key</code>" is a {@linkplain
|
||||
* ResourceBundle#getObject(String) key} in a {@linkplain
|
||||
* #addResourceBundle(ResourceBundle) resource bundle} registered for this
|
||||
|
@ -1039,10 +1037,10 @@ public interface Template extends Cloneable {
|
|||
List<String> evaluateL10nTags();
|
||||
|
||||
/**
|
||||
* Fills all values in this template which match "<code>CONFIG:<em>key</em></code>",
|
||||
* Fills all values in this template which match "<code>config:<em>key</em></code>",
|
||||
* where "<code>key</code>" is a configuration value name in the {@link
|
||||
* Config} instance returned by {@link Config#getRepInstance()}. Each
|
||||
* valuev will be filled with the value of the configuration option with
|
||||
* rife.config.Config} instance returned by {@link rife.config.Config#instance()}. Each
|
||||
* value will be filled with the value of the configuration option with
|
||||
* the corresponding key.
|
||||
* <p>This method is normally called automatically during template
|
||||
* initialization. You should call it if you wish to re-evaluate the tags
|
||||
|
@ -1054,8 +1052,8 @@ public interface Template extends Cloneable {
|
|||
List<String> evaluateConfigTags();
|
||||
|
||||
/**
|
||||
* Fills the value "<code>LANG:<em>id</em></code>" with the value of the
|
||||
* block "<code>LANG:<em>id</em>:<em>langid</em></code>", where "<code>id</code>"
|
||||
* Fills the value "<code>lang:<em>id</em></code>" with the value of the
|
||||
* block "<code>lang:<em>id</em>:<em>langid</em></code>", where "<code>id</code>"
|
||||
* is the given ID, and "<code>langid</code>" is this template's
|
||||
* {@linkplain #getLanguage() current language ID}.
|
||||
* <p>If no matching block for the current language is found, the content
|
||||
|
|
|
@ -43,7 +43,7 @@ class TemplateClassLoader extends ClassLoader {
|
|||
// if the template was modified, don't use the cached class
|
||||
// otherwise, just take the previous template class
|
||||
if (isTemplateModified(c, transformer)) {
|
||||
TemplateClassLoader new_classloader = new TemplateClassLoader(templateFactory_, this.getParent());
|
||||
var new_classloader = new TemplateClassLoader(templateFactory_, this.getParent());
|
||||
// register the new classloader as the default templatefactory's
|
||||
// classloader
|
||||
templateFactory_.setClassLoader(new_classloader);
|
||||
|
@ -54,7 +54,7 @@ class TemplateClassLoader extends ClassLoader {
|
|||
// try to obtain the class in another way
|
||||
else {
|
||||
// try to obtain it from the parent classloader or from the system classloader
|
||||
ClassLoader parent = getParent();
|
||||
var parent = getParent();
|
||||
if (parent != null) {
|
||||
try {
|
||||
// the parent is never a TemplateClassLoader, it's always the
|
||||
|
@ -67,7 +67,7 @@ class TemplateClassLoader extends ClassLoader {
|
|||
// file, make sure it's returned immediately and don't try to recompile it
|
||||
if (c != null &&
|
||||
RifeConfig.template().getAutoReload()) {
|
||||
URL resource = parent.getResource(classname.replace('.', '/') + ".class");
|
||||
var resource = parent.getResource(classname.replace('.', '/') + ".class");
|
||||
if (resource != null &&
|
||||
resource.getPath().indexOf('!') != -1) {
|
||||
// resolve the class if it's needed
|
||||
|
@ -96,6 +96,7 @@ class TemplateClassLoader extends ClassLoader {
|
|||
!classname.startsWith("java.") &&
|
||||
!classname.startsWith("javax.") &&
|
||||
!classname.startsWith("sun.") &&
|
||||
!classname.startsWith("jakarta.") &&
|
||||
Template.class.isAssignableFrom(c)) {
|
||||
// verify if the template in the classpath has been updated
|
||||
if (RifeConfig.template().getAutoReload() &&
|
||||
|
@ -117,7 +118,7 @@ class TemplateClassLoader extends ClassLoader {
|
|||
// reuse the existing class if it has already been defined
|
||||
c = findLoadedClass(classname);
|
||||
if (null == c) {
|
||||
byte[] raw = compileTemplate(classname, encoding, transformer);
|
||||
var raw = compileTemplate(classname, encoding, transformer);
|
||||
|
||||
// define the bytes of the class for this classloader
|
||||
c = defineClass(classname, raw, 0, raw.length);
|
||||
|
@ -141,14 +142,14 @@ class TemplateClassLoader extends ClassLoader {
|
|||
assert classname != null;
|
||||
|
||||
// try to resolve the classname as a template name by resolving the template
|
||||
URL template_url = templateFactory_.getParser().resolve(classname);
|
||||
var template_url = templateFactory_.getParser().resolve(classname);
|
||||
if (null == template_url) {
|
||||
throw new ClassNotFoundException("Couldn't resolve template: '" + classname + "'.");
|
||||
}
|
||||
|
||||
// prepare the template with all the information that's needed to be able to identify
|
||||
// this template uniquely
|
||||
Parsed template_parsed = templateFactory_.getParser().prepare(classname, template_url);
|
||||
var template_parsed = templateFactory_.getParser().prepare(classname, template_url);
|
||||
|
||||
// parse the template
|
||||
try {
|
||||
|
@ -157,20 +158,20 @@ class TemplateClassLoader extends ClassLoader {
|
|||
throw new ClassNotFoundException("Error while parsing template: '" + classname + "'.", e);
|
||||
}
|
||||
|
||||
byte[] byte_code = template_parsed.getByteCode();
|
||||
var byte_code = template_parsed.getByteCode();
|
||||
if (RifeConfig.template().getGenerateClasses()) {
|
||||
// get the package and the short classname of the template
|
||||
String template_package = template_parsed.getPackage();
|
||||
var template_package = template_parsed.getPackage();
|
||||
template_package = template_package.replace('.', File.separatorChar);
|
||||
String template_classname = template_parsed.getClassName();
|
||||
var template_classname = template_parsed.getClassName();
|
||||
|
||||
// setup everything to perform the conversion of the template to java sources
|
||||
// and to compile it into a java class
|
||||
String generation_path = RifeConfig.template().getGenerationPath() + File.separatorChar;
|
||||
String packagedir = generation_path + template_package;
|
||||
String filename_class = packagedir + File.separator + template_classname + ".class";
|
||||
File file_packagedir = new File(packagedir);
|
||||
File file_class = new File(filename_class);
|
||||
var generation_path = RifeConfig.template().getGenerationPath() + File.separatorChar;
|
||||
var packagedir = generation_path + template_package;
|
||||
var filename_class = packagedir + File.separator + template_classname + ".class";
|
||||
var file_packagedir = new File(packagedir);
|
||||
var file_class = new File(filename_class);
|
||||
|
||||
// prepare the package directory
|
||||
if (!file_packagedir.exists()) {
|
||||
|
@ -195,7 +196,7 @@ class TemplateClassLoader extends ClassLoader {
|
|||
private boolean isTemplateModified(Class c, TemplateTransformer transformer) {
|
||||
assert c != null;
|
||||
|
||||
boolean is_modified = true;
|
||||
var is_modified = true;
|
||||
Method is_modified_method = null;
|
||||
String modification_state = null;
|
||||
if (transformer != null) {
|
||||
|
|
|
@ -6,5 +6,4 @@ package rife.template;
|
|||
|
||||
public enum TemplateConfig {
|
||||
XML, TXT
|
||||
|
||||
}
|
|
@ -65,7 +65,7 @@ public class TemplateDeployer {
|
|||
String classname;
|
||||
|
||||
for (var directory : directories_) {
|
||||
ResourceFinderGroup group = new ResourceFinderGroup()
|
||||
var group = new ResourceFinderGroup()
|
||||
.add(new ResourceFinderDirectories(new File[]{directory}))
|
||||
.add(ResourceFinderClasspath.instance());
|
||||
templateFactory_.setResourceFinder(group);
|
||||
|
@ -73,7 +73,7 @@ public class TemplateDeployer {
|
|||
Pattern.compile(".*\\" + templateFactory_.getParser().getExtension() + "$"),
|
||||
Pattern.compile(".*(SCCS|CVS|\\.svn|\\.git).*"));
|
||||
|
||||
for (String file : files) {
|
||||
for (var file : files) {
|
||||
if (!StringUtils.filter(file, include_, exclude_)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public class TemplateDeployer {
|
|||
if (arguments.length < 1) {
|
||||
valid_arguments = false;
|
||||
} else {
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
if (arguments[i].startsWith("-")) {
|
||||
if (arguments[i].equals("-t")) {
|
||||
i++;
|
||||
|
@ -145,8 +145,8 @@ public class TemplateDeployer {
|
|||
if (arguments[i].startsWith("-")) {
|
||||
valid_arguments = false;
|
||||
} else {
|
||||
List<String> class_names = StringUtils.split(arguments[i], ":");
|
||||
for (String class_name : class_names) {
|
||||
var class_names = StringUtils.split(arguments[i], ":");
|
||||
for (var class_name : class_names) {
|
||||
try {
|
||||
Class.forName(class_name);
|
||||
} catch (ClassNotFoundException e) {
|
||||
|
@ -213,7 +213,7 @@ public class TemplateDeployer {
|
|||
}
|
||||
|
||||
RifeConfig.template().setGenerateClasses(true);
|
||||
TemplateDeployer deployer = new TemplateDeployer(verbose, directory_paths, factory, include, exclude);
|
||||
var deployer = new TemplateDeployer(verbose, directory_paths, factory, include, exclude);
|
||||
deployer.execute();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public interface TemplateEncoder {
|
|||
* @return an encoded version of the given string
|
||||
* @since 1.0
|
||||
*/
|
||||
public String encode(String value);
|
||||
String encode(String value);
|
||||
|
||||
/**
|
||||
* Encodes the given value in a looser fashion than {@link #encode}'s,
|
||||
|
@ -42,7 +42,7 @@ public interface TemplateEncoder {
|
|||
* @return a loosely encoded version of the given <code>value</code>
|
||||
* @since 1.0
|
||||
*/
|
||||
public String encodeDefensive(String value);
|
||||
String encodeDefensive(String value);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public class TemplateFactory extends EnumClass<String> {
|
|||
TemplateFactoryFilters.TAG_RENDER,
|
||||
TemplateFactoryFilters.TAG_ROUTE
|
||||
},
|
||||
BeanHandlerHtml.getInstance(),
|
||||
BeanHandlerHtml.instance(),
|
||||
EncoderHtmlSingleton.INSTANCE,
|
||||
null);
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class TemplateFactory extends EnumClass<String> {
|
|||
TemplateFactoryFilters.TAG_L10N,
|
||||
TemplateFactoryFilters.TAG_RENDER
|
||||
},
|
||||
BeanHandlerXml.getInstance(),
|
||||
BeanHandlerXml.instance(),
|
||||
EncoderXmlSingleton.INSTANCE,
|
||||
null);
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class TemplateFactory extends EnumClass<String> {
|
|||
TemplateFactoryFilters.TAG_L10N,
|
||||
TemplateFactoryFilters.TAG_RENDER
|
||||
},
|
||||
BeanHandlerPlain.getInstance(),
|
||||
BeanHandlerPlain.instance(),
|
||||
null,
|
||||
null);
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class TemplateFactory extends EnumClass<String> {
|
|||
TemplateFactoryFilters.TAG_L10N,
|
||||
TemplateFactoryFilters.TAG_RENDER
|
||||
},
|
||||
BeanHandlerPlain.getInstance(),
|
||||
BeanHandlerPlain.instance(),
|
||||
EncoderHtmlSingleton.INSTANCE,
|
||||
null);
|
||||
|
||||
|
@ -108,7 +108,7 @@ public class TemplateFactory extends EnumClass<String> {
|
|||
TemplateFactoryFilters.TAG_L10N,
|
||||
TemplateFactoryFilters.TAG_RENDER
|
||||
},
|
||||
BeanHandlerPlain.getInstance(),
|
||||
BeanHandlerPlain.instance(),
|
||||
EncoderJsonSingleton.INSTANCE,
|
||||
null);
|
||||
|
||||
|
@ -159,9 +159,9 @@ public class TemplateFactory extends EnumClass<String> {
|
|||
private Pattern[] compileFilters(String[] filters)
|
||||
throws PatternSyntaxException {
|
||||
if (filters != null) {
|
||||
Pattern[] patterns = new Pattern[filters.length];
|
||||
var patterns = new Pattern[filters.length];
|
||||
|
||||
for (int i = 0; i < filters.length; i++) {
|
||||
for (var i = 0; i < filters.length; i++) {
|
||||
patterns[i] = Pattern.compile(filters[i]);
|
||||
}
|
||||
|
||||
|
@ -227,12 +227,12 @@ public class TemplateFactory extends EnumClass<String> {
|
|||
template.setInitializer(initializer_);
|
||||
template.setDefaultContentType(defaultContentType_);
|
||||
|
||||
Collection<String> default_resource_bundles = RifeConfig.template().getDefaultResourceBundles(this);
|
||||
var default_resource_bundles = RifeConfig.template().getDefaultResourceBundles(this);
|
||||
if (default_resource_bundles != null) {
|
||||
var default_bundles = new ArrayList<ResourceBundle>();
|
||||
for (String bundle_name : default_resource_bundles) {
|
||||
for (var bundle_name : default_resource_bundles) {
|
||||
// try to look it up as a filename in the classpath
|
||||
ResourceBundle bundle = Localization.getResourceBundle(bundle_name);
|
||||
var bundle = Localization.getResourceBundle(bundle_name);
|
||||
if (bundle != null) {
|
||||
default_bundles.add(bundle);
|
||||
continue;
|
||||
|
|
|
@ -32,7 +32,7 @@ public interface ValueRenderer {
|
|||
* @return the rendered text
|
||||
* @since 1.0
|
||||
*/
|
||||
public String render(Template template, String valueId, String differentiator);
|
||||
String render(Template template, String valueId, String differentiator);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -111,19 +111,19 @@ public class MockFileUpload {
|
|||
}
|
||||
|
||||
private void guessContentType() {
|
||||
String extension = getExtension(getFileName());
|
||||
var extension = getExtension(getFileName());
|
||||
if (null == extension) {
|
||||
return;
|
||||
}
|
||||
|
||||
String content_type = RifeConfig.Mime.getMimeType(extension);
|
||||
var content_type = RifeConfig.Mime.getMimeType(extension);
|
||||
if (content_type != null) {
|
||||
contentType_ = content_type;
|
||||
}
|
||||
}
|
||||
|
||||
private String getExtension(String fileName) {
|
||||
int last_dot_index = fileName.lastIndexOf('.');
|
||||
var last_dot_index = fileName.lastIndexOf('.');
|
||||
if (-1 == last_dot_index) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -488,7 +488,7 @@ public class MockRequest implements Request {
|
|||
checkUploadDirectory();
|
||||
|
||||
if (null == files_) {
|
||||
files_ = new HashMap<String, UploadedFile[]>();
|
||||
files_ = new HashMap<>();
|
||||
}
|
||||
|
||||
var uploaded_files = new UploadedFile[files.length];
|
||||
|
@ -677,7 +677,7 @@ public class MockRequest implements Request {
|
|||
if (0 == name.length()) throw new IllegalArgumentException("name can't be empty");
|
||||
|
||||
if (null == attributes_) {
|
||||
attributes_ = new HashMap<String, Object>();
|
||||
attributes_ = new HashMap<>();
|
||||
}
|
||||
|
||||
attributes_.put(name, object);
|
||||
|
@ -967,7 +967,7 @@ public class MockRequest implements Request {
|
|||
}
|
||||
|
||||
if (null == locales_) {
|
||||
locales_ = new ArrayList<Locale>();
|
||||
locales_ = new ArrayList<>();
|
||||
}
|
||||
|
||||
locales_.add(locale);
|
||||
|
|
|
@ -6,7 +6,6 @@ package rife.test;
|
|||
|
||||
import jakarta.servlet.http.Cookie;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import rife.engine.*;
|
||||
|
||||
import java.io.*;
|
||||
|
@ -17,10 +16,8 @@ import rife.template.Template;
|
|||
import rife.tools.ExceptionUtils;
|
||||
import rife.tools.StringUtils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
@ -101,7 +98,7 @@ public class MockResponse extends AbstractResponse {
|
|||
* @since 1.1
|
||||
*/
|
||||
public String getText() {
|
||||
String charset = characterEncoding_;
|
||||
var charset = characterEncoding_;
|
||||
if (null == charset) {
|
||||
charset = StringUtils.ENCODING_ISO_8859_1;
|
||||
}
|
||||
|
@ -219,13 +216,13 @@ public class MockResponse extends AbstractResponse {
|
|||
|
||||
private Object xpath(String expression, QName returnType)
|
||||
throws XPathExpressionException {
|
||||
Matcher matcher = STRIP_XHTML_XMLNS.matcher(getText());
|
||||
String text = matcher.replaceAll("html xmlns=\"\"");
|
||||
var matcher = STRIP_XHTML_XMLNS.matcher(getText());
|
||||
var text = matcher.replaceAll("html xmlns=\"\"");
|
||||
Reader reader = new StringReader(text);
|
||||
|
||||
InputSource inputsource = new InputSource(reader);
|
||||
XPath xpath = XPathFactory.newInstance().newXPath();
|
||||
return xpath.evaluate(expression, inputsource, returnType);
|
||||
var input_source = new InputSource(reader);
|
||||
var xpath = XPathFactory.newInstance().newXPath();
|
||||
return xpath.evaluate(expression, input_source, returnType);
|
||||
}
|
||||
|
||||
|
||||
|
@ -319,7 +316,7 @@ public class MockResponse extends AbstractResponse {
|
|||
|
||||
private Object xpath(String expression, Object context, QName returnType)
|
||||
throws XPathExpressionException {
|
||||
XPath xpath = XPathFactory.newInstance().newXPath();
|
||||
var xpath = XPathFactory.newInstance().newXPath();
|
||||
return xpath.evaluate(expression, context, returnType);
|
||||
}
|
||||
|
||||
|
@ -338,17 +335,17 @@ public class MockResponse extends AbstractResponse {
|
|||
}
|
||||
} else {
|
||||
// Look for encoding in contentType
|
||||
int i0 = contentType.indexOf(';');
|
||||
var i0 = contentType.indexOf(';');
|
||||
|
||||
if (i0 > 0) {
|
||||
// Strip params off mimetype
|
||||
contentType_ = contentType.substring(0, i0).trim();
|
||||
|
||||
// Look for charset
|
||||
int i1 = contentType.indexOf("charset=", i0);
|
||||
var i1 = contentType.indexOf("charset=", i0);
|
||||
if (i1 >= 0) {
|
||||
i1 += 8;
|
||||
int i2 = contentType.indexOf(' ', i1);
|
||||
var i2 = contentType.indexOf(' ', i1);
|
||||
characterEncoding_ = (0 < i2)
|
||||
? contentType.substring(i1, i2)
|
||||
: contentType.substring(i1);
|
||||
|
@ -412,8 +409,8 @@ public class MockResponse extends AbstractResponse {
|
|||
* @since 1.1
|
||||
*/
|
||||
public List<String> getNewCookieNames() {
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
for (Cookie cookie : newCookies_.values()) {
|
||||
var names = new ArrayList<String>();
|
||||
for (var cookie : newCookies_.values()) {
|
||||
if (!names.contains(cookie.getName())) {
|
||||
names.add(cookie.getName());
|
||||
}
|
||||
|
@ -591,7 +588,7 @@ public class MockResponse extends AbstractResponse {
|
|||
}
|
||||
|
||||
public String encodeURL(String url) {
|
||||
MockRequest request = (MockRequest) getRequest();
|
||||
var request = (MockRequest) getRequest();
|
||||
|
||||
// should not encode if cookies in evidence
|
||||
if (null == request ||
|
||||
|
@ -600,7 +597,7 @@ public class MockResponse extends AbstractResponse {
|
|||
}
|
||||
|
||||
// get session
|
||||
HttpSession session = getRequest().getSession(false);
|
||||
var session = getRequest().getSession(false);
|
||||
|
||||
// no session or no url
|
||||
if (null == session || null == url) {
|
||||
|
@ -608,15 +605,15 @@ public class MockResponse extends AbstractResponse {
|
|||
}
|
||||
|
||||
// invalid session
|
||||
String id = session.getId();
|
||||
var id = session.getId();
|
||||
if (null == id) {
|
||||
return url;
|
||||
}
|
||||
|
||||
// Already encoded
|
||||
int prefix = url.indexOf(MockConversation.SESSION_URL_PREFIX);
|
||||
var prefix = url.indexOf(MockConversation.SESSION_URL_PREFIX);
|
||||
if (prefix != -1) {
|
||||
int suffix = url.indexOf("?", prefix);
|
||||
var suffix = url.indexOf("?", prefix);
|
||||
if (suffix < 0) {
|
||||
suffix = url.indexOf("#", prefix);
|
||||
}
|
||||
|
@ -629,7 +626,7 @@ public class MockResponse extends AbstractResponse {
|
|||
}
|
||||
|
||||
// edit the session
|
||||
int suffix = url.indexOf('?');
|
||||
var suffix = url.indexOf('?');
|
||||
if (suffix < 0) {
|
||||
suffix = url.indexOf('#');
|
||||
}
|
||||
|
@ -665,7 +662,7 @@ public class MockResponse extends AbstractResponse {
|
|||
/* if there is no writer yet */
|
||||
if (mockWriter_ == null) {
|
||||
/* get encoding from Content-Type header */
|
||||
String encoding = getCharacterEncoding();
|
||||
var encoding = getCharacterEncoding();
|
||||
|
||||
if (encoding == null) {
|
||||
encoding = StringUtils.ENCODING_ISO_8859_1;
|
||||
|
@ -785,10 +782,10 @@ public class MockResponse extends AbstractResponse {
|
|||
|
||||
_lastStart = _i;
|
||||
|
||||
int state = 0;
|
||||
boolean escape = false;
|
||||
var state = 0;
|
||||
var escape = false;
|
||||
while (_i < _string.length()) {
|
||||
char c = _string.charAt(_i++);
|
||||
var c = _string.charAt(_i++);
|
||||
|
||||
switch (state) {
|
||||
case 0: // Start
|
||||
|
@ -876,7 +873,7 @@ public class MockResponse extends AbstractResponse {
|
|||
throws NoSuchElementException {
|
||||
if (!hasMoreTokens() || _token == null)
|
||||
throw new NoSuchElementException();
|
||||
String t = _token.toString();
|
||||
var t = _token.toString();
|
||||
_token.setLength(0);
|
||||
_hasToken = false;
|
||||
return t;
|
||||
|
@ -929,13 +926,13 @@ public class MockResponse extends AbstractResponse {
|
|||
return "\"\"";
|
||||
|
||||
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
for (var i = 0; i < s.length(); i++) {
|
||||
var c = s.charAt(i);
|
||||
if (c == '"' ||
|
||||
c == '\\' ||
|
||||
c == '\'' ||
|
||||
delim.indexOf(c) >= 0) {
|
||||
StringBuilder b = new StringBuilder(s.length() + 8);
|
||||
var b = new StringBuilder(s.length() + 8);
|
||||
quote(b, s);
|
||||
return b.toString();
|
||||
}
|
||||
|
@ -954,8 +951,8 @@ public class MockResponse extends AbstractResponse {
|
|||
*/
|
||||
public static void quote(StringBuilder buf, String s) {
|
||||
buf.append('"');
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
for (var i = 0; i < s.length(); i++) {
|
||||
var c = s.charAt(i);
|
||||
if (c == '"') {
|
||||
buf.append("\\\"");
|
||||
continue;
|
||||
|
@ -984,15 +981,15 @@ public class MockResponse extends AbstractResponse {
|
|||
if (s.length() < 2)
|
||||
return s;
|
||||
|
||||
char first = s.charAt(0);
|
||||
char last = s.charAt(s.length() - 1);
|
||||
var first = s.charAt(0);
|
||||
var last = s.charAt(s.length() - 1);
|
||||
if (first != last || (first != '"' && first != '\''))
|
||||
return s;
|
||||
|
||||
StringBuilder b = new StringBuilder(s.length() - 2);
|
||||
boolean quote = false;
|
||||
for (int i = 1; i < s.length() - 1; i++) {
|
||||
char c = s.charAt(i);
|
||||
var b = new StringBuilder(s.length() - 2);
|
||||
var quote = false;
|
||||
for (var i = 1; i < s.length() - 1; i++) {
|
||||
var c = s.charAt(i);
|
||||
|
||||
if (c == '\\' && !quote) {
|
||||
quote = true;
|
||||
|
|
|
@ -34,7 +34,7 @@ public class ArrayUtils {
|
|||
|
||||
// check if it's an array
|
||||
if ('[' == classname.charAt(0)) {
|
||||
for (int position = 1; position < classname.length(); position++) {
|
||||
for (var position = 1; position < classname.length(); position++) {
|
||||
if ('[' == classname.charAt(position)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public class ArrayUtils {
|
|||
|
||||
String[] result = null;
|
||||
|
||||
ArrayType type = getArrayType(source);
|
||||
var type = getArrayType(source);
|
||||
|
||||
if (type == ArrayType.NO_ARRAY) {
|
||||
result = new String[]{BeanUtils.formatPropertyValue(source, constrainedProperty)};
|
||||
|
@ -126,7 +126,7 @@ public class ArrayUtils {
|
|||
|
||||
var new_array = new String[array.length];
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
new_array[i] = String.valueOf(array[i]);
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ public class ArrayUtils {
|
|||
|
||||
var new_array = new String[array.length];
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
new_array[i] = String.valueOf(array[i]);
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ public class ArrayUtils {
|
|||
|
||||
var new_array = new String[array.length];
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
new_array[i] = String.valueOf(array[i]);
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ public class ArrayUtils {
|
|||
|
||||
var new_array = new String[array.length];
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
new_array[i] = String.valueOf(array[i]);
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ public class ArrayUtils {
|
|||
|
||||
var new_array = new String[array.length];
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
new_array[i] = String.valueOf(array[i]);
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ public class ArrayUtils {
|
|||
|
||||
var new_array = new String[array.length];
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
new_array[i] = String.valueOf(array[i]);
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ public class ArrayUtils {
|
|||
|
||||
var new_array = new String[array.length];
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
new_array[i] = String.valueOf(array[i]);
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ public class ArrayUtils {
|
|||
|
||||
var new_array = new String[array.length];
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
new_array[i] = String.valueOf(array[i]);
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ public class ArrayUtils {
|
|||
|
||||
var new_array = new String[array.length];
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
new_array[i] = String.valueOf(array[i]);
|
||||
}
|
||||
|
||||
|
@ -252,8 +252,8 @@ public class ArrayUtils {
|
|||
|
||||
var new_array = new boolean[0];
|
||||
|
||||
boolean converted_boolean = false;
|
||||
for (Object element : array) {
|
||||
var converted_boolean = false;
|
||||
for (var element : array) {
|
||||
if (element != null) {
|
||||
converted_boolean = Boolean.parseBoolean(String.valueOf(element));
|
||||
new_array = join(new_array, converted_boolean);
|
||||
|
@ -271,7 +271,7 @@ public class ArrayUtils {
|
|||
var new_array = new byte[0];
|
||||
|
||||
byte converted_byte = -1;
|
||||
for (Object element : array) {
|
||||
for (var element : array) {
|
||||
try {
|
||||
if (element != null) {
|
||||
converted_byte = Byte.parseByte(String.valueOf(element));
|
||||
|
@ -292,10 +292,10 @@ public class ArrayUtils {
|
|||
|
||||
var new_array = new char[0];
|
||||
|
||||
char converted_char = '\u0000';
|
||||
for (Object element : array) {
|
||||
var converted_char = '\u0000';
|
||||
for (var element : array) {
|
||||
if (element != null) {
|
||||
String string_value = String.valueOf(element);
|
||||
var string_value = String.valueOf(element);
|
||||
if (string_value.length() != 1) {
|
||||
continue;
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ public class ArrayUtils {
|
|||
var new_array = new short[0];
|
||||
|
||||
short converted_short = -1;
|
||||
for (Object element : array) {
|
||||
for (var element : array) {
|
||||
try {
|
||||
if (element != null) {
|
||||
converted_short = Short.parseShort(String.valueOf(element));
|
||||
|
@ -336,8 +336,8 @@ public class ArrayUtils {
|
|||
|
||||
var new_array = new int[0];
|
||||
|
||||
int converted_int = -1;
|
||||
for (Object element : array) {
|
||||
var converted_int = -1;
|
||||
for (var element : array) {
|
||||
try {
|
||||
if (element != null) {
|
||||
converted_int = Integer.parseInt(String.valueOf(element));
|
||||
|
@ -359,7 +359,7 @@ public class ArrayUtils {
|
|||
var new_array = new long[0];
|
||||
|
||||
long converted_long = -1;
|
||||
for (Object element : array) {
|
||||
for (var element : array) {
|
||||
try {
|
||||
if (element != null) {
|
||||
converted_long = Long.parseLong(String.valueOf(element));
|
||||
|
@ -381,7 +381,7 @@ public class ArrayUtils {
|
|||
var new_array = new float[0];
|
||||
|
||||
float converted_float = -1;
|
||||
for (Object element : array) {
|
||||
for (var element : array) {
|
||||
try {
|
||||
if (element != null) {
|
||||
converted_float = Float.parseFloat(String.valueOf(element));
|
||||
|
@ -403,7 +403,7 @@ public class ArrayUtils {
|
|||
var new_array = new double[0];
|
||||
|
||||
double converted_double = -1;
|
||||
for (Object element : array) {
|
||||
for (var element : array) {
|
||||
try {
|
||||
if (element != null) {
|
||||
converted_double = Double.parseDouble(String.valueOf(element));
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.beans.PropertyDescriptor;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public interface BeanPropertyProcessor {
|
||||
public boolean gotProperty(String name, PropertyDescriptor descriptor)
|
||||
boolean gotProperty(String name, PropertyDescriptor descriptor)
|
||||
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.beans.PropertyDescriptor;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public interface BeanPropertyValueProcessor {
|
||||
public void gotProperty(String name, PropertyDescriptor descriptor, Object value)
|
||||
void gotProperty(String name, PropertyDescriptor descriptor, Object value)
|
||||
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public abstract class BeanUtils {
|
|||
}
|
||||
|
||||
public static DateFormat getConcisePreciseDateFormat() {
|
||||
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmssSSSZ", Localization.getLocale());
|
||||
var sf = new SimpleDateFormat("yyyyMMddHHmmssSSSZ", Localization.getLocale());
|
||||
sf.setTimeZone(RifeConfig.tools().getDefaultTimeZone());
|
||||
return sf;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public abstract class BeanUtils {
|
|||
throws BeanUtilsException {
|
||||
if (null == beanClass) return Collections.emptySet();
|
||||
|
||||
final LinkedHashSet<String> property_names = new LinkedHashSet<String>();
|
||||
final var property_names = new LinkedHashSet<String>();
|
||||
|
||||
processProperties(accessors, beanClass, includedProperties, excludedProperties, prefix, new BeanPropertyProcessor() {
|
||||
public boolean gotProperty(String name, PropertyDescriptor descriptor)
|
||||
|
@ -118,10 +118,10 @@ public abstract class BeanUtils {
|
|||
if (null == processor) return;
|
||||
|
||||
// obtain the BeanInfo class
|
||||
BeanInfo bean_info = getBeanInfo(beanClass);
|
||||
var bean_info = getBeanInfo(beanClass);
|
||||
|
||||
// process the properties of the bean
|
||||
PropertyDescriptor[] bean_properties = bean_info.getPropertyDescriptors();
|
||||
var bean_properties = bean_info.getPropertyDescriptors();
|
||||
if (bean_properties.length > 0) {
|
||||
String property_name = null;
|
||||
Collection<String> included_properties = null;
|
||||
|
@ -136,7 +136,7 @@ public abstract class BeanUtils {
|
|||
}
|
||||
|
||||
// iterate over the properties of the bean
|
||||
for (PropertyDescriptor bean_property : bean_properties) {
|
||||
for (var bean_property : bean_properties) {
|
||||
property_name = validateProperty(accessors, bean_property, included_properties, excluded_properties, prefix);
|
||||
|
||||
// process the property if it was valid
|
||||
|
@ -172,7 +172,7 @@ public abstract class BeanUtils {
|
|||
public boolean gotProperty(String name, PropertyDescriptor descriptor)
|
||||
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||
// obtain the value of the property
|
||||
Method property_read_method = descriptor.getReadMethod();
|
||||
var property_read_method = descriptor.getReadMethod();
|
||||
if (property_read_method != null) {
|
||||
// handle the property value
|
||||
processor.gotProperty(name, descriptor, property_read_method.invoke(bean, (Object[]) null));
|
||||
|
@ -192,7 +192,7 @@ public abstract class BeanUtils {
|
|||
throws BeanUtilsException {
|
||||
if (null == beanClass) return 0;
|
||||
|
||||
final int[] result = new int[]{0};
|
||||
final var result = new int[]{0};
|
||||
|
||||
processProperties(accessors, beanClass, includedProperties, excludedProperties, prefix, new BeanPropertyProcessor() {
|
||||
public boolean gotProperty(String name, PropertyDescriptor descriptor)
|
||||
|
@ -215,16 +215,16 @@ public abstract class BeanUtils {
|
|||
|
||||
// obtain the BeanInfo class
|
||||
Class bean_class = bean.getClass();
|
||||
BeanInfo bean_info = getBeanInfo(bean_class);
|
||||
var bean_info = getBeanInfo(bean_class);
|
||||
|
||||
// process the properties of the bean
|
||||
PropertyDescriptor[] bean_properties = bean_info.getPropertyDescriptors();
|
||||
var bean_properties = bean_info.getPropertyDescriptors();
|
||||
if (bean_properties.length > 0) {
|
||||
String property_name = null;
|
||||
Method property_read_method = null;
|
||||
|
||||
// iterate over the properties of the bean
|
||||
for (PropertyDescriptor bean_property : bean_properties) {
|
||||
for (var bean_property : bean_properties) {
|
||||
property_name = bean_property.getName();
|
||||
|
||||
// process the property if it was valid
|
||||
|
@ -261,16 +261,16 @@ public abstract class BeanUtils {
|
|||
|
||||
// obtain the BeanInfo class
|
||||
Class bean_class = bean.getClass();
|
||||
BeanInfo bean_info = getBeanInfo(bean_class);
|
||||
var bean_info = getBeanInfo(bean_class);
|
||||
|
||||
// process the properties of the bean
|
||||
PropertyDescriptor[] bean_properties = bean_info.getPropertyDescriptors();
|
||||
var bean_properties = bean_info.getPropertyDescriptors();
|
||||
if (bean_properties.length > 0) {
|
||||
String property_name = null;
|
||||
Method property_write_method = null;
|
||||
|
||||
// iterate over the properties of the bean
|
||||
for (PropertyDescriptor bean_property : bean_properties) {
|
||||
for (var bean_property : bean_properties) {
|
||||
property_name = bean_property.getName();
|
||||
|
||||
// process the property if it was valid
|
||||
|
@ -301,16 +301,16 @@ public abstract class BeanUtils {
|
|||
if (0 == name.length()) throw new IllegalArgumentException("name can't be empty.");
|
||||
|
||||
// obtain the BeanInfo class
|
||||
BeanInfo bean_info = getBeanInfo(beanClass);
|
||||
var bean_info = getBeanInfo(beanClass);
|
||||
|
||||
// process the properties of the bean
|
||||
PropertyDescriptor[] bean_properties = bean_info.getPropertyDescriptors();
|
||||
var bean_properties = bean_info.getPropertyDescriptors();
|
||||
if (bean_properties.length > 0) {
|
||||
String property_name = null;
|
||||
Method property_read_method = null;
|
||||
|
||||
// iterate over the properties of the bean
|
||||
for (PropertyDescriptor bean_property : bean_properties) {
|
||||
for (var bean_property : bean_properties) {
|
||||
property_name = bean_property.getName();
|
||||
|
||||
// process the property if it was valid
|
||||
|
@ -332,7 +332,7 @@ public abstract class BeanUtils {
|
|||
|
||||
public static Map<String, Object> getPropertyValues(Accessors accessors, Object bean, String[] includedProperties, String[] excludedProperties, String prefix)
|
||||
throws BeanUtilsException {
|
||||
final LinkedHashMap<String, Object> property_values = new LinkedHashMap<String, Object>();
|
||||
final var property_values = new LinkedHashMap<String, Object>();
|
||||
|
||||
processPropertyValues(accessors, bean, includedProperties, excludedProperties, prefix, new BeanPropertyValueProcessor() {
|
||||
public void gotProperty(String name, PropertyDescriptor descriptor, Object value)
|
||||
|
@ -374,7 +374,7 @@ public abstract class BeanUtils {
|
|||
throws BeanUtilsException {
|
||||
if (null == beanClass) return Collections.emptyMap();
|
||||
|
||||
final LinkedHashMap<String, Class> property_types = new LinkedHashMap<String, Class>();
|
||||
final var property_types = new LinkedHashMap<String, Class>();
|
||||
|
||||
processProperties(accessors, beanClass, includedProperties, excludedProperties, prefix, new BeanPropertyProcessor() {
|
||||
public boolean gotProperty(String name, PropertyDescriptor descriptor)
|
||||
|
@ -382,11 +382,11 @@ public abstract class BeanUtils {
|
|||
Class property_class = null;
|
||||
|
||||
// obtain and store the property type
|
||||
Method property_read_method = descriptor.getReadMethod();
|
||||
var property_read_method = descriptor.getReadMethod();
|
||||
if (property_read_method != null) {
|
||||
property_class = property_read_method.getReturnType();
|
||||
} else {
|
||||
Method property_write_method = descriptor.getWriteMethod();
|
||||
var property_write_method = descriptor.getWriteMethod();
|
||||
property_class = property_write_method.getParameterTypes()[0];
|
||||
}
|
||||
|
||||
|
@ -416,7 +416,7 @@ public abstract class BeanUtils {
|
|||
throws BeanUtilsException {
|
||||
if (null == beanClass) throw new IllegalArgumentException("beanClass can't be null.");
|
||||
|
||||
HashMap<String, PropertyDescriptor> bean_properties = new HashMap<String, PropertyDescriptor>();
|
||||
var bean_properties = new HashMap<String, PropertyDescriptor>();
|
||||
BeanInfo bean_info = null;
|
||||
PropertyDescriptor[] bean_properties_array = null;
|
||||
|
||||
|
@ -427,7 +427,7 @@ public abstract class BeanUtils {
|
|||
}
|
||||
bean_properties_array = bean_info.getPropertyDescriptors();
|
||||
String bean_property_name = null;
|
||||
for (PropertyDescriptor bean_property : bean_properties_array) {
|
||||
for (var bean_property : bean_properties_array) {
|
||||
bean_property_name = bean_property.getName().toUpperCase();
|
||||
if (bean_properties.containsKey(bean_property_name)) {
|
||||
throw new BeanUtilsException("Duplicate case insensitive bean property '" + bean_property_name + "' in bean '" + beanClass.getName() + "'.", beanClass);
|
||||
|
@ -539,7 +539,7 @@ public abstract class BeanUtils {
|
|||
validated = (Validated) beanInstance;
|
||||
}
|
||||
|
||||
Constrained constrained = ConstrainedUtils.makeConstrainedInstance(beanInstance);
|
||||
var constrained = ConstrainedUtils.makeConstrainedInstance(beanInstance);
|
||||
ConstrainedProperty constrained_property = null;
|
||||
if (constrained != null) {
|
||||
constrained_property = constrained.getConstrainedProperty(property.getName());
|
||||
|
@ -553,20 +553,20 @@ public abstract class BeanUtils {
|
|||
0 == propertyValues.length ||
|
||||
null == propertyValues[0] ||
|
||||
0 == propertyValues[0].length())) {
|
||||
Method read_method = property.getReadMethod();
|
||||
Object empty_value = read_method.invoke(emptyBean, (Object[]) null);
|
||||
var read_method = property.getReadMethod();
|
||||
var empty_value = read_method.invoke(emptyBean, (Object[]) null);
|
||||
write_method.invoke(beanInstance, empty_value);
|
||||
}
|
||||
// assign the value normally
|
||||
else {
|
||||
// process an array property
|
||||
if (property_type.isArray()) {
|
||||
Class component_type = property_type.getComponentType();
|
||||
var component_type = property_type.getComponentType();
|
||||
if (component_type == String.class) {
|
||||
write_method.invoke(beanInstance, new Object[]{propertyValues});
|
||||
} else if (component_type == int.class) {
|
||||
int[] parameter_values_typed = new int[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new int[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
if (constrained_property != null && constrained_property.isFormatted()) {
|
||||
parameter_values_typed[i] = Convert.toInt(constrained_property.getFormat().parseObject(propertyValues[i]));
|
||||
|
@ -577,8 +577,8 @@ public abstract class BeanUtils {
|
|||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == Integer.class) {
|
||||
Integer[] parameter_values_typed = new Integer[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new Integer[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
if (constrained_property != null && constrained_property.isFormatted()) {
|
||||
parameter_values_typed[i] = Convert.toInt(constrained_property.getFormat().parseObject(propertyValues[i]));
|
||||
|
@ -589,40 +589,40 @@ public abstract class BeanUtils {
|
|||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == char.class) {
|
||||
char[] parameter_values_typed = new char[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new char[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
parameter_values_typed[i] = propertyValues[i].charAt(0);
|
||||
}
|
||||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == Character.class) {
|
||||
Character[] parameter_values_typed = new Character[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new Character[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
parameter_values_typed[i] = propertyValues[i].charAt(0);
|
||||
}
|
||||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == boolean.class) {
|
||||
boolean[] parameter_values_typed = new boolean[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new boolean[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
parameter_values_typed[i] = StringUtils.convertToBoolean(propertyValues[i]);
|
||||
}
|
||||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == Boolean.class) {
|
||||
Boolean[] parameter_values_typed = new Boolean[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new Boolean[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
parameter_values_typed[i] = StringUtils.convertToBoolean(propertyValues[i]);
|
||||
}
|
||||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == byte.class) {
|
||||
byte[] parameter_values_typed = new byte[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new byte[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
if (constrained_property != null && constrained_property.isFormatted()) {
|
||||
parameter_values_typed[i] = Convert.toByte(constrained_property.getFormat().parseObject(propertyValues[i]));
|
||||
|
@ -633,8 +633,8 @@ public abstract class BeanUtils {
|
|||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == Byte.class) {
|
||||
Byte[] parameter_values_typed = new Byte[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new Byte[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
if (constrained_property != null && constrained_property.isFormatted()) {
|
||||
parameter_values_typed[i] = Convert.toByte(constrained_property.getFormat().parseObject(propertyValues[i]));
|
||||
|
@ -645,8 +645,8 @@ public abstract class BeanUtils {
|
|||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == double.class) {
|
||||
double[] parameter_values_typed = new double[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new double[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
if (constrained_property != null && constrained_property.isFormatted()) {
|
||||
parameter_values_typed[i] = Convert.toDouble(constrained_property.getFormat().parseObject(propertyValues[i]));
|
||||
|
@ -657,8 +657,8 @@ public abstract class BeanUtils {
|
|||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == Double.class) {
|
||||
Double[] parameter_values_typed = new Double[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new Double[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
if (constrained_property != null && constrained_property.isFormatted()) {
|
||||
parameter_values_typed[i] = Convert.toDouble(constrained_property.getFormat().parseObject(propertyValues[i]));
|
||||
|
@ -669,8 +669,8 @@ public abstract class BeanUtils {
|
|||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == float.class) {
|
||||
float[] parameter_values_typed = new float[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new float[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
if (constrained_property != null && constrained_property.isFormatted()) {
|
||||
parameter_values_typed[i] = Convert.toFloat(constrained_property.getFormat().parseObject(propertyValues[i]));
|
||||
|
@ -681,8 +681,8 @@ public abstract class BeanUtils {
|
|||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == Float.class) {
|
||||
Float[] parameter_values_typed = new Float[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new Float[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
if (constrained_property != null && constrained_property.isFormatted()) {
|
||||
parameter_values_typed[i] = Convert.toFloat(constrained_property.getFormat().parseObject(propertyValues[i]));
|
||||
|
@ -693,8 +693,8 @@ public abstract class BeanUtils {
|
|||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == long.class) {
|
||||
long[] parameter_values_typed = new long[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new long[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
if (constrained_property != null && constrained_property.isFormatted()) {
|
||||
parameter_values_typed[i] = Convert.toLong(constrained_property.getFormat().parseObject(propertyValues[i]));
|
||||
|
@ -705,8 +705,8 @@ public abstract class BeanUtils {
|
|||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == Long.class) {
|
||||
Long[] parameter_values_typed = new Long[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new Long[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
if (constrained_property != null && constrained_property.isFormatted()) {
|
||||
parameter_values_typed[i] = Convert.toLong(constrained_property.getFormat().parseObject(propertyValues[i]));
|
||||
|
@ -717,8 +717,8 @@ public abstract class BeanUtils {
|
|||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == short.class) {
|
||||
short[] parameter_values_typed = new short[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new short[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
if (constrained_property != null && constrained_property.isFormatted()) {
|
||||
parameter_values_typed[i] = Convert.toShort(constrained_property.getFormat().parseObject(propertyValues[i]));
|
||||
|
@ -730,7 +730,7 @@ public abstract class BeanUtils {
|
|||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == Short.class) {
|
||||
Short parameter_values_typed[] = new Short[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
if (constrained_property != null && constrained_property.isFormatted()) {
|
||||
parameter_values_typed[i] = Convert.toShort(constrained_property.getFormat().parseObject(propertyValues[i]));
|
||||
|
@ -741,8 +741,8 @@ public abstract class BeanUtils {
|
|||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == BigDecimal.class) {
|
||||
BigDecimal[] parameter_values_typed = new BigDecimal[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new BigDecimal[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
if (constrained_property != null && constrained_property.isFormatted()) {
|
||||
parameter_values_typed[i] = new BigDecimal(String.valueOf(constrained_property.getFormat().parseObject(propertyValues[i])));
|
||||
|
@ -753,16 +753,16 @@ public abstract class BeanUtils {
|
|||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == StringBuffer.class) {
|
||||
StringBuffer[] parameter_values_typed = new StringBuffer[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new StringBuffer[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
parameter_values_typed[i] = new StringBuffer(propertyValues[i]);
|
||||
}
|
||||
}
|
||||
write_method.invoke(beanInstance, new Object[]{parameter_values_typed});
|
||||
} else if (component_type == StringBuilder.class) {
|
||||
StringBuilder[] parameter_values_typed = new StringBuilder[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new StringBuilder[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
parameter_values_typed[i] = new StringBuilder(propertyValues[i]);
|
||||
}
|
||||
|
@ -776,8 +776,8 @@ public abstract class BeanUtils {
|
|||
}
|
||||
|
||||
try {
|
||||
Date[] parameter_values_typed = new Date[propertyValues.length];
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = new Date[propertyValues.length];
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
Format used_format = null;
|
||||
|
||||
|
@ -815,8 +815,8 @@ public abstract class BeanUtils {
|
|||
}
|
||||
}
|
||||
} else if (component_type.isEnum()) {
|
||||
Object parameter_values_typed = Array.newInstance(component_type, propertyValues.length);
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = Array.newInstance(component_type, propertyValues.length);
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
try {
|
||||
Array.set(parameter_values_typed, i, Enum.valueOf(component_type, propertyValues[i]));
|
||||
|
@ -832,8 +832,8 @@ public abstract class BeanUtils {
|
|||
}
|
||||
write_method.invoke(beanInstance, parameter_values_typed);
|
||||
} else if (Serializable.class.isAssignableFrom(component_type)) {
|
||||
Object parameter_values_typed = Array.newInstance(component_type, propertyValues.length);
|
||||
for (int i = 0; i < propertyValues.length; i++) {
|
||||
var parameter_values_typed = Array.newInstance(component_type, propertyValues.length);
|
||||
for (var i = 0; i < propertyValues.length; i++) {
|
||||
if (propertyValues[i] != null && propertyValues[i].length() > 0) {
|
||||
try {
|
||||
Array.set(parameter_values_typed, i, SerializationUtils.deserializeFromString(propertyValues[i]));
|
||||
|
@ -902,7 +902,7 @@ public abstract class BeanUtils {
|
|||
}
|
||||
} else if (property_type == BigDecimal.class) {
|
||||
if (constrained_property != null && constrained_property.isFormatted()) {
|
||||
Number n = (Number) constrained_property.getFormat().parseObject(propertyValues[0]);
|
||||
var n = (Number) constrained_property.getFormat().parseObject(propertyValues[0]);
|
||||
parameter_value_typed = new BigDecimal(String.valueOf(n));
|
||||
} else {
|
||||
parameter_value_typed = new BigDecimal(propertyValues[0]);
|
||||
|
@ -1062,7 +1062,7 @@ public abstract class BeanUtils {
|
|||
validated = (Validated) beanInstance;
|
||||
}
|
||||
|
||||
Constrained constrained = ConstrainedUtils.makeConstrainedInstance(beanInstance);
|
||||
var constrained = ConstrainedUtils.makeConstrainedInstance(beanInstance);
|
||||
|
||||
try {
|
||||
if (propertyFile.wasSizeExceeded()) {
|
||||
|
@ -1083,20 +1083,20 @@ public abstract class BeanUtils {
|
|||
if (constrained != null) {
|
||||
// fill in the property name automatically if none has been provided
|
||||
// in the constraints
|
||||
ConstrainedProperty constrained_property = constrained.getConstrainedProperty(propertyName);
|
||||
var constrained_property = constrained.getConstrainedProperty(propertyName);
|
||||
if (constrained_property != null &&
|
||||
propertyFile.getName() != null) {
|
||||
if (null == constrained_property.getName()) {
|
||||
// if the filename exceeds the maximum length, reduce it intelligently
|
||||
String file_name = propertyFile.getName();
|
||||
var file_name = propertyFile.getName();
|
||||
if (file_name.length() > 100) {
|
||||
int reduction_index;
|
||||
int min_reduction_index = file_name.length() - 100;
|
||||
int slash_index = file_name.lastIndexOf('/');
|
||||
var min_reduction_index = file_name.length() - 100;
|
||||
var slash_index = file_name.lastIndexOf('/');
|
||||
if (slash_index > min_reduction_index) {
|
||||
reduction_index = slash_index + 1;
|
||||
} else {
|
||||
int backslash_index = file_name.lastIndexOf('\\');
|
||||
var backslash_index = file_name.lastIndexOf('\\');
|
||||
if (backslash_index > min_reduction_index) {
|
||||
reduction_index = backslash_index + 1;
|
||||
} else {
|
||||
|
|
|
@ -37,7 +37,7 @@ public abstract class ClassUtils {
|
|||
}
|
||||
|
||||
public static String simpleClassName(Class klass) {
|
||||
String class_name = klass.getName();
|
||||
var class_name = klass.getName();
|
||||
if (klass.getPackage() != null) {
|
||||
class_name = class_name.substring(klass.getPackage().getName().length() + 1);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public abstract class ClassUtils {
|
|||
public static String[] getEnumClassValues(Class klass) {
|
||||
if (JavaSpecificationUtils.isAtLeastJdk15() &&
|
||||
klass.isEnum()) {
|
||||
Object[] values = klass.getEnumConstants();
|
||||
var values = klass.getEnumConstants();
|
||||
return ArrayUtils.createStringArray(values);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public abstract class ExceptionFormattingUtils {
|
|||
String method_name = null;
|
||||
String file_name = null;
|
||||
|
||||
StringBuilder exceptions = new StringBuilder();
|
||||
var exceptions = new StringBuilder();
|
||||
while (exception != null) {
|
||||
exception_name = exception.getClass().getName();
|
||||
message = exception.getMessage();
|
||||
|
@ -45,10 +45,10 @@ public abstract class ExceptionFormattingUtils {
|
|||
template.setValue("exception_message", template.getEncoder().encode(message));
|
||||
|
||||
if (template.hasValueId("exception_stack_trace")) {
|
||||
StackTraceElement[] stack_trace = exception.getStackTrace();
|
||||
StringBuilder stack_trace_out = new StringBuilder();
|
||||
var stack_trace = exception.getStackTrace();
|
||||
var stack_trace_out = new StringBuilder();
|
||||
StringBuilder stack_trace_details = null;
|
||||
for (int i = 0; i < stack_trace.length; i++) {
|
||||
for (var i = 0; i < stack_trace.length; i++) {
|
||||
class_name = stack_trace[i].getClassName();
|
||||
method_name = stack_trace[i].getMethodName();
|
||||
if (null == class_name) {
|
||||
|
|
|
@ -20,7 +20,7 @@ public abstract class ExceptionUtils {
|
|||
exception.printStackTrace(print_writer);
|
||||
|
||||
stack_trace = string_writer.getBuffer().toString();
|
||||
} catch (IOException e) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
|
||||
return stack_trace;
|
||||
|
@ -30,7 +30,7 @@ public abstract class ExceptionUtils {
|
|||
if (null == exception) throw new IllegalArgumentException("exception can't be null;");
|
||||
|
||||
var messages = new StringBuilder();
|
||||
Throwable t = exception;
|
||||
var t = exception;
|
||||
while (t != null) {
|
||||
if (messages.length() > 0) {
|
||||
messages.append("; ");
|
||||
|
|
|
@ -35,11 +35,11 @@ public abstract class FileUtils {
|
|||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
var filelist = new ArrayList<String>();
|
||||
var file_list = new ArrayList<String>();
|
||||
if (file.isDirectory()) {
|
||||
var list = file.list();
|
||||
if (null != list) {
|
||||
for (String list_entry : list) {
|
||||
for (var list_entry : list) {
|
||||
var next_file = new File(file.getAbsolutePath() + File.separator + list_entry);
|
||||
var dir = getFileList(next_file, included, excluded, false);
|
||||
|
||||
|
@ -54,15 +54,15 @@ public abstract class FileUtils {
|
|||
file_name = file.getName() + File.separator + file_name;
|
||||
}
|
||||
|
||||
var filelist_size = filelist.size();
|
||||
for (int j = 0; j < filelist_size; j++) {
|
||||
if (filelist.get(j).compareTo(file_name) > 0) {
|
||||
filelist.add(j, file_name);
|
||||
var filelist_size = file_list.size();
|
||||
for (var j = 0; j < filelist_size; j++) {
|
||||
if (file_list.get(j).compareTo(file_name) > 0) {
|
||||
file_list.add(j, file_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (filelist.size() == filelist_size) {
|
||||
filelist.add(file_name);
|
||||
if (file_list.size() == filelist_size) {
|
||||
file_list.add(file_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,14 +72,14 @@ public abstract class FileUtils {
|
|||
|
||||
if (root) {
|
||||
if (StringUtils.filter(file_name, included, excluded)) {
|
||||
filelist.add(file_name);
|
||||
file_list.add(file_name);
|
||||
}
|
||||
} else {
|
||||
filelist.add(file_name);
|
||||
file_list.add(file_name);
|
||||
}
|
||||
}
|
||||
|
||||
return filelist;
|
||||
return file_list;
|
||||
}
|
||||
|
||||
public static void moveFile(File source, File target)
|
||||
|
@ -113,11 +113,11 @@ public abstract class FileUtils {
|
|||
target.mkdirs();
|
||||
}
|
||||
|
||||
var filelist = source.list();
|
||||
var file_list = source.list();
|
||||
|
||||
for (var filelist_element : filelist) {
|
||||
var current_file = new File(source.getAbsolutePath() + File.separator + filelist_element);
|
||||
var target_file = new File(target.getAbsolutePath() + File.separator + filelist_element);
|
||||
for (var element : file_list) {
|
||||
var current_file = new File(source.getAbsolutePath() + File.separator + element);
|
||||
var target_file = new File(target.getAbsolutePath() + File.separator + element);
|
||||
|
||||
if (current_file.isDirectory()) {
|
||||
moveDirectory(current_file, target_file);
|
||||
|
@ -139,10 +139,10 @@ public abstract class FileUtils {
|
|||
throw new FileUtilsErrorException("The directory '" + source.getAbsolutePath() + "' does not exist");
|
||||
}
|
||||
|
||||
var filelist = source.list();
|
||||
var file_list = source.list();
|
||||
|
||||
for (var filelist_element : filelist) {
|
||||
File current_file = new File(source.getAbsolutePath() + File.separator + filelist_element);
|
||||
for (var element : file_list) {
|
||||
var current_file = new File(source.getAbsolutePath() + File.separator + element);
|
||||
|
||||
if (current_file.isDirectory()) {
|
||||
deleteDirectory(current_file);
|
||||
|
@ -162,7 +162,7 @@ public abstract class FileUtils {
|
|||
|
||||
try {
|
||||
var buffer = new byte[1024];
|
||||
int return_value = -1;
|
||||
var return_value = -1;
|
||||
|
||||
return_value = inputStream.read(buffer);
|
||||
|
||||
|
@ -231,7 +231,7 @@ public abstract class FileUtils {
|
|||
|
||||
try {
|
||||
var buffer = new byte[1024];
|
||||
int return_value = -1;
|
||||
var return_value = -1;
|
||||
var output_stream = new ByteArrayOutputStream(buffer.length);
|
||||
|
||||
return_value = inputStream.read(buffer);
|
||||
|
@ -263,10 +263,10 @@ public abstract class FileUtils {
|
|||
if (null == reader) throw new IllegalArgumentException("reader can't be null.");
|
||||
|
||||
try {
|
||||
char[] buffer = new char[1024];
|
||||
var buffer = new char[1024];
|
||||
var result = new StringBuilder();
|
||||
|
||||
int size = reader.read(buffer);
|
||||
var size = reader.read(buffer);
|
||||
while (size != -1) {
|
||||
result.append(buffer, 0, size);
|
||||
size = reader.read(buffer);
|
||||
|
@ -448,14 +448,14 @@ public abstract class FileUtils {
|
|||
StringBuilder output_file_directoryname = null;
|
||||
File output_file_directory = null;
|
||||
FileOutputStream file_output_stream = null;
|
||||
byte[] buffer = new byte[1024];
|
||||
int return_value = -1;
|
||||
var buffer = new byte[1024];
|
||||
var return_value = -1;
|
||||
|
||||
entry = (ZipEntry) entries.nextElement();
|
||||
try {
|
||||
input_stream = zip_file.getInputStream(entry);
|
||||
} catch (IOException e) {
|
||||
throw new FileUtilsErrorException("Error while obtaining the inputstream for entry '" + entry.getName() + "'.", e);
|
||||
throw new FileUtilsErrorException("Error while obtaining the input stream for entry '" + entry.getName() + "'.", e);
|
||||
}
|
||||
|
||||
output_filename = destination.getAbsolutePath() + File.separator + entry.getName().replace('/', File.separatorChar);
|
||||
|
@ -505,7 +505,7 @@ public abstract class FileUtils {
|
|||
try {
|
||||
zip_file.close();
|
||||
} catch (IOException e) {
|
||||
throw new FileUtilsErrorException("Error while closing the zipfile '" + source.getAbsolutePath() + "'.", e);
|
||||
throw new FileUtilsErrorException("Error while closing the zip file '" + source.getAbsolutePath() + "'.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,7 +518,7 @@ public abstract class FileUtils {
|
|||
|
||||
String basename = null;
|
||||
|
||||
int index = fileName.lastIndexOf('.');
|
||||
var index = fileName.lastIndexOf('.');
|
||||
if (index > 0 && index < fileName.length() - 1) {
|
||||
basename = fileName.substring(0, index);
|
||||
}
|
||||
|
@ -535,7 +535,7 @@ public abstract class FileUtils {
|
|||
|
||||
String ext = null;
|
||||
|
||||
int index = fileName.lastIndexOf('.');
|
||||
var index = fileName.lastIndexOf('.');
|
||||
if (index > 0 && index < fileName.length() - 1) {
|
||||
ext = fileName.substring(index + 1).toLowerCase();
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class ObjectUtils {
|
|||
}
|
||||
|
||||
try {
|
||||
Method method = object.getClass().getMethod("clone", (Class[]) null);
|
||||
var method = object.getClass().getMethod("clone", (Class[]) null);
|
||||
method.setAccessible(true);
|
||||
return (T) method.invoke(object, (Object[]) null);
|
||||
} catch (Exception e) {
|
||||
|
@ -94,7 +94,7 @@ public class ObjectUtils {
|
|||
return null;
|
||||
}
|
||||
|
||||
String classname = object.getClass().getName();
|
||||
var classname = object.getClass().getName();
|
||||
|
||||
// check if it's an array
|
||||
if ('[' == classname.charAt(0)) {
|
||||
|
@ -124,7 +124,7 @@ public class ObjectUtils {
|
|||
}
|
||||
|
||||
// get the base type and the dimension count of the array
|
||||
int dimension_count = 1;
|
||||
var dimension_count = 1;
|
||||
while (classname.charAt(dimension_count) == '[') {
|
||||
dimension_count += 1;
|
||||
}
|
||||
|
@ -134,23 +134,22 @@ public class ObjectUtils {
|
|||
} else {
|
||||
try {
|
||||
baseClass = Class.forName(classname.substring(dimension_count + 1, classname.length() - 1));
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
} catch (ClassNotFoundException e) {
|
||||
Logger.getLogger("rife.tools").severe("Internal error: class definition inconsistency: " + classname);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// instantiate the array but make all but the first dimension 0.
|
||||
int[] dimensions = new int[dimension_count];
|
||||
var dimensions = new int[dimension_count];
|
||||
dimensions[0] = Array.getLength(object);
|
||||
for (int i = 1; i < dimension_count; i += 1) {
|
||||
for (var i = 1; i < dimension_count; i += 1) {
|
||||
dimensions[i] = 0;
|
||||
}
|
||||
T copy = (T) Array.newInstance(baseClass, dimensions);
|
||||
var copy = (T) Array.newInstance(baseClass, dimensions);
|
||||
|
||||
// now fill in the next level down by recursion.
|
||||
for (int i = 0; i < dimensions[0]; i += 1) {
|
||||
for (var i = 0; i < dimensions[0]; i += 1) {
|
||||
Array.set(copy, i, deepClone(Array.get(object, i)));
|
||||
}
|
||||
|
||||
|
@ -161,11 +160,11 @@ public class ObjectUtils {
|
|||
object instanceof Cloneable) {
|
||||
|
||||
// instantiate the new collection and clear it
|
||||
Collection copy = (Collection) ObjectUtils.genericClone(object);
|
||||
var copy = (Collection) ObjectUtils.genericClone(object);
|
||||
copy.clear();
|
||||
|
||||
// clone all the values in the collection individually
|
||||
for (Object element : collection) {
|
||||
for (var element : collection) {
|
||||
copy.add(deepClone(element));
|
||||
}
|
||||
|
||||
|
@ -176,11 +175,11 @@ public class ObjectUtils {
|
|||
object instanceof Cloneable) {
|
||||
|
||||
// instantiate the new map and clear it
|
||||
Map copy = (Map) ObjectUtils.genericClone(object);
|
||||
var copy = (Map) ObjectUtils.genericClone(object);
|
||||
copy.clear();
|
||||
|
||||
// now clone all the keys and values of the entries
|
||||
Iterator collection_it = map.entrySet().iterator();
|
||||
var collection_it = map.entrySet().iterator();
|
||||
Map.Entry entry = null;
|
||||
while (collection_it.hasNext()) {
|
||||
entry = (Map.Entry) collection_it.next();
|
||||
|
@ -191,7 +190,7 @@ public class ObjectUtils {
|
|||
}
|
||||
// use the generic clone method
|
||||
else {
|
||||
T copy = ObjectUtils.genericClone(object);
|
||||
var copy = ObjectUtils.genericClone(object);
|
||||
if (null == copy) {
|
||||
throw new CloneNotSupportedException(object.getClass().getName());
|
||||
}
|
||||
|
@ -210,10 +209,10 @@ public class ObjectUtils {
|
|||
return Void.TYPE;
|
||||
}
|
||||
|
||||
String className = object.getClass().getName();
|
||||
var className = object.getClass().getName();
|
||||
|
||||
// skip forward over the array dimensions
|
||||
int dims = 0;
|
||||
var dims = 0;
|
||||
while (className.charAt(dims) == '[') {
|
||||
dims += 1;
|
||||
}
|
||||
|
|
|
@ -24,15 +24,14 @@ public abstract class SerializationUtils {
|
|||
byte[] value_bytes_decoded = null;
|
||||
try {
|
||||
value_bytes_decoded = Base64.getDecoder().decode(value);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new DeserializationErrorException(null);
|
||||
}
|
||||
if (null == value_bytes_decoded) {
|
||||
throw new DeserializationErrorException(null);
|
||||
}
|
||||
|
||||
ByteArrayInputStream bytes_is = new ByteArrayInputStream(value_bytes_decoded);
|
||||
var bytes_is = new ByteArrayInputStream(value_bytes_decoded);
|
||||
GZIPInputStream gzip_is = null;
|
||||
ObjectInputStream object_is = null;
|
||||
try {
|
||||
|
@ -48,7 +47,7 @@ public abstract class SerializationUtils {
|
|||
throws SerializationUtilsErrorException {
|
||||
if (null == value) throw new IllegalArgumentException("value can't be null.");
|
||||
|
||||
ByteArrayOutputStream byte_os = new ByteArrayOutputStream();
|
||||
var byte_os = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzip_os;
|
||||
ObjectOutputStream object_os;
|
||||
try {
|
||||
|
@ -62,7 +61,7 @@ public abstract class SerializationUtils {
|
|||
throw new SerializationErrorException(value, e);
|
||||
}
|
||||
|
||||
byte[] value_bytes_decoded = byte_os.toByteArray();
|
||||
var value_bytes_decoded = byte_os.toByteArray();
|
||||
|
||||
return Base64.getEncoder().encodeToString(value_bytes_decoded);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public enum StringEncryptor {
|
|||
if (value.startsWith(OBF.prefix())) {
|
||||
return OBF.prefix() + obfuscate(value.substring(OBF.prefix().length()));
|
||||
} else {
|
||||
boolean encode_base64 = false;
|
||||
var encode_base64 = false;
|
||||
String prefix = null;
|
||||
byte[] bytes = null;
|
||||
if (value.startsWith(SHA.prefix()) || value.startsWith(SHAHEX.prefix())) {
|
||||
|
@ -62,7 +62,7 @@ public enum StringEncryptor {
|
|||
prefix = SHAHEX.prefix();
|
||||
encode_base64 = false;
|
||||
}
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA");
|
||||
var digest = MessageDigest.getInstance("SHA");
|
||||
digest.update(value.substring(prefix.length()).getBytes());
|
||||
bytes = digest.digest();
|
||||
} else if (value.startsWith(WRP.prefix()) || value.startsWith(WRPHEX.prefix())) {
|
||||
|
@ -73,10 +73,10 @@ public enum StringEncryptor {
|
|||
prefix = WRPHEX.prefix();
|
||||
encode_base64 = false;
|
||||
}
|
||||
Whirlpool whirlpool = new Whirlpool();
|
||||
var whirlpool = new Whirlpool();
|
||||
whirlpool.NESSIEinit();
|
||||
whirlpool.NESSIEadd(value.substring(prefix.length()));
|
||||
byte[] digest = new byte[Whirlpool.DIGESTBYTES];
|
||||
var digest = new byte[Whirlpool.DIGESTBYTES];
|
||||
whirlpool.NESSIEfinalize(digest);
|
||||
bytes = digest;
|
||||
} else if (value.startsWith(MD5.prefix()) || value.startsWith(MD5HEX.prefix())) {
|
||||
|
@ -87,7 +87,7 @@ public enum StringEncryptor {
|
|||
prefix = MD5HEX.prefix();
|
||||
encode_base64 = false;
|
||||
}
|
||||
MessageDigest digest = MessageDigest.getInstance("MD5");
|
||||
var digest = MessageDigest.getInstance("MD5");
|
||||
digest.update(value.substring(prefix.length()).getBytes());
|
||||
bytes = digest.digest();
|
||||
} else {
|
||||
|
@ -141,15 +141,15 @@ public enum StringEncryptor {
|
|||
public static String obfuscate(String value) {
|
||||
if (null == value) throw new IllegalArgumentException("value can't be null");
|
||||
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
byte[] bytes = value.getBytes();
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
byte b1 = bytes[i];
|
||||
byte b2 = bytes[value.length() - (i + 1)];
|
||||
int i1 = (int) b1 + (int) b2 + 127;
|
||||
int i2 = (int) b1 - (int) b2 + 127;
|
||||
int i0 = i1 * 256 + i2;
|
||||
String x = Integer.toString(i0, 36);
|
||||
var buffer = new StringBuilder();
|
||||
var bytes = value.getBytes();
|
||||
for (var i = 0; i < bytes.length; i++) {
|
||||
var b1 = bytes[i];
|
||||
var b2 = bytes[value.length() - (i + 1)];
|
||||
var i1 = (int) b1 + (int) b2 + 127;
|
||||
var i2 = (int) b1 - (int) b2 + 127;
|
||||
var i0 = i1 * 256 + i2;
|
||||
var x = Integer.toString(i0, 36);
|
||||
|
||||
switch (x.length()) {
|
||||
case 1:
|
||||
|
@ -173,14 +173,14 @@ public enum StringEncryptor {
|
|||
value = value.substring(OBF.prefix().length());
|
||||
}
|
||||
|
||||
byte[] bytes = new byte[value.length() / 2];
|
||||
int l = 0;
|
||||
var bytes = new byte[value.length() / 2];
|
||||
var l = 0;
|
||||
|
||||
for (int i = 0; i < value.length(); i += 4) {
|
||||
String x = value.substring(i, i + 4);
|
||||
int i0 = Integer.parseInt(x, 36);
|
||||
int i1 = (i0 / 256);
|
||||
int i2 = (i0 % 256);
|
||||
for (var i = 0; i < value.length(); i += 4) {
|
||||
var x = value.substring(i, i + 4);
|
||||
var i0 = Integer.parseInt(x, 36);
|
||||
var i1 = (i0 / 256);
|
||||
var i2 = (i0 % 256);
|
||||
bytes[l++] = (byte) ((i1 + i2 - 254) / 2);
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ public enum StringEncryptor {
|
|||
}
|
||||
|
||||
public static void main(String[] arguments) {
|
||||
boolean valid_arguments = true;
|
||||
var valid_arguments = true;
|
||||
if (arguments.length < 1 ||
|
||||
arguments.length > 3) {
|
||||
valid_arguments = false;
|
||||
|
|
|
@ -324,13 +324,13 @@ public abstract class StringUtils {
|
|||
DEFENSIVE_HTML_ENCODE_MAP.put('\u2665', "♥");
|
||||
DEFENSIVE_HTML_ENCODE_MAP.put('\u2666', "♦");
|
||||
|
||||
Set<Map.Entry<Character, String>> aggresive_entries = AGGRESSIVE_HTML_ENCODE_MAP.entrySet();
|
||||
for (Map.Entry<Character, String> entry : aggresive_entries) {
|
||||
var aggresive_entries = AGGRESSIVE_HTML_ENCODE_MAP.entrySet();
|
||||
for (var entry : aggresive_entries) {
|
||||
HTML_DECODE_MAP.put(entry.getValue(), entry.getKey());
|
||||
}
|
||||
|
||||
Set<Map.Entry<Character, String>> defensive_entries = DEFENSIVE_HTML_ENCODE_MAP.entrySet();
|
||||
for (Map.Entry<Character, String> entry : defensive_entries) {
|
||||
var defensive_entries = DEFENSIVE_HTML_ENCODE_MAP.entrySet();
|
||||
for (var entry : defensive_entries) {
|
||||
HTML_DECODE_MAP.put(entry.getValue(), entry.getKey());
|
||||
}
|
||||
|
||||
|
@ -447,8 +447,8 @@ public abstract class StringUtils {
|
|||
return null;
|
||||
}
|
||||
|
||||
Pattern pattern = Pattern.compile("[^\\w]");
|
||||
Matcher matcher = pattern.matcher(name);
|
||||
var pattern = Pattern.compile("[^\\w]");
|
||||
var matcher = pattern.matcher(name);
|
||||
|
||||
return matcher.replaceAll("_");
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ public abstract class StringUtils {
|
|||
// string is returned as-is
|
||||
var encode = false;
|
||||
char ch;
|
||||
for (int i = 0; i < source.length(); i++) {
|
||||
for (var i = 0; i < source.length(); i++) {
|
||||
ch = source.charAt(i);
|
||||
|
||||
if (ch >= 'a' && ch <= 'z' ||
|
||||
|
@ -504,8 +504,7 @@ public abstract class StringUtils {
|
|||
|
||||
try {
|
||||
return URLEncoder.encode(source, ENCODING_ISO_8859_1);
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// this should never happen, ISO-8859-1 is a standard encoding
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -561,8 +560,7 @@ public abstract class StringUtils {
|
|||
|
||||
return encoded.toString();
|
||||
}
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// this should never happen, ISO-8859-1 is a standard encoding
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -583,14 +581,13 @@ public abstract class StringUtils {
|
|||
*/
|
||||
public static String decodeUrlValue(String source) {
|
||||
try {
|
||||
byte[] decoded = Base64.getDecoder().decode(source.substring(2));
|
||||
var decoded = Base64.getDecoder().decode(source.substring(2));
|
||||
if (null == decoded) {
|
||||
return null;
|
||||
} else {
|
||||
return new String(decoded, StringUtils.ENCODING_UTF_8);
|
||||
}
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// this should never happen, UTF-8 is a standard encoding
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -622,7 +619,7 @@ public abstract class StringUtils {
|
|||
|
||||
var encode = false;
|
||||
char ch;
|
||||
for (int i = 0; i < source.length(); i++) {
|
||||
for (var i = 0; i < source.length(); i++) {
|
||||
ch = source.charAt(i);
|
||||
|
||||
if ((defensive || (ch != '\u0022' && ch != '\u0026' && ch != '\u003C' && ch != '\u003E')) &&
|
||||
|
@ -646,9 +643,9 @@ public abstract class StringUtils {
|
|||
return source;
|
||||
}
|
||||
|
||||
int current_index = 0;
|
||||
int delimiter_start_index = 0;
|
||||
int delimiter_end_index = 0;
|
||||
var current_index = 0;
|
||||
var delimiter_start_index = 0;
|
||||
var delimiter_end_index = 0;
|
||||
|
||||
StringBuilder result = null;
|
||||
|
||||
|
@ -668,14 +665,14 @@ public abstract class StringUtils {
|
|||
}
|
||||
|
||||
// add the decoded entity
|
||||
String entity = source.substring(delimiter_start_index, delimiter_end_index + 1);
|
||||
var entity = source.substring(delimiter_start_index, delimiter_end_index + 1);
|
||||
|
||||
current_index = delimiter_end_index + 1;
|
||||
|
||||
// try to decoded numeric entities
|
||||
if (entity.charAt(1) == '#') {
|
||||
int start = 2;
|
||||
int radix = 10;
|
||||
var start = 2;
|
||||
var radix = 10;
|
||||
// check if the number is hexadecimal
|
||||
if (entity.charAt(2) == 'X' || entity.charAt(2) == 'x') {
|
||||
start++;
|
||||
|
@ -691,7 +688,7 @@ public abstract class StringUtils {
|
|||
}
|
||||
} else {
|
||||
// try to decode the entity as a literal
|
||||
Character decoded = HTML_DECODE_MAP.get(entity);
|
||||
var decoded = HTML_DECODE_MAP.get(entity);
|
||||
if (decoded != null) {
|
||||
result.append(decoded);
|
||||
}
|
||||
|
@ -836,11 +833,11 @@ public abstract class StringUtils {
|
|||
|
||||
var encoded = new StringBuilder();
|
||||
String hexstring = null;
|
||||
for (int i = 0; i < source.length(); i++) {
|
||||
for (var i = 0; i < source.length(); i++) {
|
||||
hexstring = Integer.toHexString(source.charAt(i)).toUpperCase();
|
||||
encoded.append("\\u");
|
||||
// fill with zeros
|
||||
for (int j = hexstring.length(); j < 4; j++) {
|
||||
for (var j = hexstring.length(); j < 4; j++) {
|
||||
encoded.append("0");
|
||||
}
|
||||
encoded.append(hexstring);
|
||||
|
@ -929,9 +926,9 @@ public abstract class StringUtils {
|
|||
var string_to_encode_array = source.toCharArray();
|
||||
var last_match = -1;
|
||||
|
||||
for (int i = 0; i < string_to_encode_array.length; i++) {
|
||||
char char_to_encode = string_to_encode_array[i];
|
||||
for (Map<Character, String> encoding_table : encodingTables) {
|
||||
for (var i = 0; i < string_to_encode_array.length; i++) {
|
||||
var char_to_encode = string_to_encode_array[i];
|
||||
for (var encoding_table : encodingTables) {
|
||||
if (encoding_table.containsKey(char_to_encode)) {
|
||||
encoded_string = prepareEncodedString(source, encoded_string, i, last_match, string_to_encode_array);
|
||||
|
||||
|
@ -953,7 +950,7 @@ public abstract class StringUtils {
|
|||
if (null == encoded_string) {
|
||||
return source;
|
||||
} else {
|
||||
int difference = string_to_encode_array.length - (last_match + 1);
|
||||
var difference = string_to_encode_array.length - (last_match + 1);
|
||||
if (difference > 0) {
|
||||
encoded_string.append(string_to_encode_array, last_match + 1, difference);
|
||||
}
|
||||
|
@ -990,7 +987,7 @@ public abstract class StringUtils {
|
|||
|
||||
public void appendFallback(StringBuilder encodedBuffer, char character) {
|
||||
encodedBuffer.append(PREFIX);
|
||||
encodedBuffer.append((int)character);
|
||||
encodedBuffer.append((int) character);
|
||||
encodedBuffer.append(SUFFIX);
|
||||
}
|
||||
}
|
||||
|
@ -1017,13 +1014,13 @@ public abstract class StringUtils {
|
|||
return source;
|
||||
}
|
||||
|
||||
StringBuilder encoded_string = new StringBuilder();
|
||||
var encoded_string = new StringBuilder();
|
||||
|
||||
char b;
|
||||
char c = 0;
|
||||
String hhhh;
|
||||
int i;
|
||||
int len = source.length();
|
||||
var len = source.length();
|
||||
|
||||
for (i = 0; i < len; i += 1) {
|
||||
b = c;
|
||||
|
@ -1115,8 +1112,8 @@ public abstract class StringUtils {
|
|||
|
||||
|
||||
public static String encodeHex(byte[] bytes) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < bytes.length; ++i) {
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < bytes.length; ++i) {
|
||||
sb.append(Integer.toHexString((bytes[i] & 0xFF) | 0x100), 1, 3);
|
||||
}
|
||||
return sb.toString();
|
||||
|
@ -1318,7 +1315,7 @@ public abstract class StringUtils {
|
|||
var string_parts = split(source, separator, matchCase);
|
||||
var number_of_valid_parts = 0;
|
||||
|
||||
for (String string_part : string_parts) {
|
||||
for (var string_part : string_parts) {
|
||||
try {
|
||||
Integer.parseInt(string_part);
|
||||
number_of_valid_parts++;
|
||||
|
@ -1330,7 +1327,7 @@ public abstract class StringUtils {
|
|||
var string_parts_int = (int[]) Array.newInstance(int.class, number_of_valid_parts);
|
||||
var added_parts = 0;
|
||||
|
||||
for (String string_part : string_parts) {
|
||||
for (var string_part : string_parts) {
|
||||
try {
|
||||
string_parts_int[added_parts] = Integer.parseInt(string_part);
|
||||
added_parts++;
|
||||
|
@ -1374,7 +1371,7 @@ public abstract class StringUtils {
|
|||
public static byte[] splitToByteArray(String source, String separator, boolean matchCase) {
|
||||
var string_parts = split(source, separator, matchCase);
|
||||
var number_of_valid_parts = 0;
|
||||
for (String string_part : string_parts) {
|
||||
for (var string_part : string_parts) {
|
||||
try {
|
||||
Byte.parseByte(string_part);
|
||||
number_of_valid_parts++;
|
||||
|
@ -1385,7 +1382,7 @@ public abstract class StringUtils {
|
|||
|
||||
var string_parts_byte = (byte[]) Array.newInstance(byte.class, number_of_valid_parts);
|
||||
var added_parts = 0;
|
||||
for (String string_part : string_parts) {
|
||||
for (var string_part : string_parts) {
|
||||
try {
|
||||
string_parts_byte[added_parts] = Byte.parseByte(string_part);
|
||||
added_parts++;
|
||||
|
@ -1487,9 +1484,9 @@ public abstract class StringUtils {
|
|||
return source;
|
||||
}
|
||||
|
||||
int strip_length = stringToStrip.length();
|
||||
int new_index = 0;
|
||||
int last_index = 0;
|
||||
var strip_length = stringToStrip.length();
|
||||
var new_index = 0;
|
||||
var last_index = 0;
|
||||
|
||||
String source_lookup_reference = null;
|
||||
if (!matchCase) {
|
||||
|
@ -1562,7 +1559,7 @@ public abstract class StringUtils {
|
|||
var new_string = new StringBuilder();
|
||||
|
||||
while (string_parts.hasNext()) {
|
||||
String string_part = string_parts.next();
|
||||
var string_part = string_parts.next();
|
||||
new_string.append(string_part);
|
||||
if (string_parts.hasNext()) {
|
||||
new_string.append(replacementString);
|
||||
|
@ -1690,8 +1687,8 @@ public abstract class StringUtils {
|
|||
if (0 == collection.size()) {
|
||||
return "";
|
||||
} else {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (Object element : collection) {
|
||||
var result = new StringBuilder();
|
||||
for (var element : collection) {
|
||||
result.append(element);
|
||||
result.append(separator);
|
||||
}
|
||||
|
@ -1811,8 +1808,8 @@ public abstract class StringUtils {
|
|||
if (0 == array.length) {
|
||||
return "";
|
||||
} else {
|
||||
int current_index = 0;
|
||||
String result = "";
|
||||
var current_index = 0;
|
||||
var result = "";
|
||||
while (current_index < array.length - 1) {
|
||||
result = result + array[current_index] + separator;
|
||||
current_index++;
|
||||
|
@ -1844,8 +1841,8 @@ public abstract class StringUtils {
|
|||
if (0 == array.length) {
|
||||
return "";
|
||||
} else {
|
||||
int current_index = 0;
|
||||
String result = "";
|
||||
var current_index = 0;
|
||||
var result = "";
|
||||
while (current_index < array.length - 1) {
|
||||
result = result + array[current_index] + separator;
|
||||
current_index++;
|
||||
|
@ -1877,8 +1874,8 @@ public abstract class StringUtils {
|
|||
if (0 == array.length) {
|
||||
return "";
|
||||
} else {
|
||||
int current_index = 0;
|
||||
String result = "";
|
||||
var current_index = 0;
|
||||
var result = "";
|
||||
while (current_index < array.length - 1) {
|
||||
result = result + array[current_index] + separator;
|
||||
current_index++;
|
||||
|
@ -1910,8 +1907,8 @@ public abstract class StringUtils {
|
|||
if (0 == array.length) {
|
||||
return "";
|
||||
} else {
|
||||
int current_index = 0;
|
||||
String result = "";
|
||||
var current_index = 0;
|
||||
var result = "";
|
||||
while (current_index < array.length - 1) {
|
||||
result = result + array[current_index] + separator;
|
||||
current_index++;
|
||||
|
@ -1943,8 +1940,8 @@ public abstract class StringUtils {
|
|||
if (0 == array.length) {
|
||||
return "";
|
||||
} else {
|
||||
int current_index = 0;
|
||||
String result = "";
|
||||
var current_index = 0;
|
||||
var result = "";
|
||||
while (current_index < array.length - 1) {
|
||||
result = result + array[current_index] + separator;
|
||||
current_index++;
|
||||
|
@ -1976,8 +1973,8 @@ public abstract class StringUtils {
|
|||
if (0 == array.length) {
|
||||
return "";
|
||||
} else {
|
||||
int current_index = 0;
|
||||
String result = "";
|
||||
var current_index = 0;
|
||||
var result = "";
|
||||
while (current_index < array.length - 1) {
|
||||
result = result + array[current_index] + separator;
|
||||
current_index++;
|
||||
|
@ -2009,8 +2006,8 @@ public abstract class StringUtils {
|
|||
if (0 == array.length) {
|
||||
return "";
|
||||
} else {
|
||||
int current_index = 0;
|
||||
String result = "";
|
||||
var current_index = 0;
|
||||
var result = "";
|
||||
while (current_index < array.length - 1) {
|
||||
result = result + array[current_index] + separator;
|
||||
current_index++;
|
||||
|
@ -2060,8 +2057,8 @@ public abstract class StringUtils {
|
|||
if (0 == array.length) {
|
||||
return "";
|
||||
} else {
|
||||
int current_index = 0;
|
||||
StringBuilder result = new StringBuilder();
|
||||
var current_index = 0;
|
||||
var result = new StringBuilder();
|
||||
while (current_index < array.length - 1) {
|
||||
result.append(delimiter);
|
||||
result.append(array[current_index]);
|
||||
|
@ -2156,7 +2153,7 @@ public abstract class StringUtils {
|
|||
regexps != null &&
|
||||
regexps.size() > 0) {
|
||||
Matcher matcher = null;
|
||||
for (Pattern regexp : regexps) {
|
||||
for (var regexp : regexps) {
|
||||
matcher = regexp.matcher(value);
|
||||
if (matcher.matches()) {
|
||||
return matcher;
|
||||
|
@ -2184,7 +2181,7 @@ public abstract class StringUtils {
|
|||
values.size() > 0 &&
|
||||
regexp != null) {
|
||||
Matcher matcher = null;
|
||||
for (String value : values) {
|
||||
for (var value : values) {
|
||||
matcher = regexp.matcher(value);
|
||||
if (matcher.matches()) {
|
||||
return matcher;
|
||||
|
@ -2242,7 +2239,7 @@ public abstract class StringUtils {
|
|||
if (null == included) {
|
||||
accepted = true;
|
||||
} else {
|
||||
for (Pattern pattern : included) {
|
||||
for (var pattern : included) {
|
||||
if (pattern != null &&
|
||||
pattern.matcher(name).matches()) {
|
||||
accepted = true;
|
||||
|
@ -2254,7 +2251,7 @@ public abstract class StringUtils {
|
|||
// remove the excludes
|
||||
if (accepted &&
|
||||
excluded != null) {
|
||||
for (Pattern pattern : excluded) {
|
||||
for (var pattern : excluded) {
|
||||
if (pattern != null &&
|
||||
pattern.matcher(name).matches()) {
|
||||
accepted = false;
|
||||
|
@ -2311,7 +2308,7 @@ public abstract class StringUtils {
|
|||
}
|
||||
|
||||
private static String convertUrl(String source, Pattern pattern, boolean shorten, boolean sanitize, boolean no_follow) {
|
||||
int max_length = RifeConfig.tools().getMaxVisualUrlLength();
|
||||
var max_length = RifeConfig.tools().getMaxVisualUrlLength();
|
||||
|
||||
var result = source;
|
||||
|
||||
|
@ -2320,8 +2317,8 @@ public abstract class StringUtils {
|
|||
if (found) {
|
||||
String visual_url = null;
|
||||
String actual_url = null;
|
||||
int last = 0;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
var last = 0;
|
||||
var sb = new StringBuilder();
|
||||
do {
|
||||
actual_url = url_matcher.group(1);
|
||||
if (url_matcher.groupCount() > 1) {
|
||||
|
@ -2360,8 +2357,8 @@ public abstract class StringUtils {
|
|||
if (visual_url.length() <= max_length || !shorten) {
|
||||
sb.append(visual_url);
|
||||
} else {
|
||||
String ellipsis = "...";
|
||||
int query_index = visual_url.indexOf("?");
|
||||
var ellipsis = "...";
|
||||
var query_index = visual_url.indexOf("?");
|
||||
|
||||
// remove query string but keep '?'
|
||||
if (query_index != -1) {
|
||||
|
@ -2369,8 +2366,8 @@ public abstract class StringUtils {
|
|||
}
|
||||
|
||||
if (visual_url.length() >= max_length) {
|
||||
int last_slash = visual_url.lastIndexOf("/");
|
||||
int start_slash = visual_url.indexOf("/", visual_url.indexOf("://") + 3);
|
||||
var last_slash = visual_url.lastIndexOf("/");
|
||||
var start_slash = visual_url.indexOf("/", visual_url.indexOf("://") + 3);
|
||||
|
||||
if (last_slash != start_slash) {
|
||||
visual_url = visual_url.substring(0, start_slash + 1) + ellipsis + visual_url.substring(last_slash);
|
||||
|
@ -2430,7 +2427,7 @@ public abstract class StringUtils {
|
|||
var convert_bare = false;
|
||||
var no_follow_links = false;
|
||||
if (options != null) {
|
||||
for (BbcodeOption option : options) {
|
||||
for (var option : options) {
|
||||
switch (option) {
|
||||
case SHORTEN_URL -> shorten = true;
|
||||
case SANITIZE_URL -> sanitize = true;
|
||||
|
@ -2448,7 +2445,7 @@ public abstract class StringUtils {
|
|||
int nextCodeIndex;
|
||||
while (-1 != (startindex = source_copy.indexOf("[code]"))) {
|
||||
// handle parsed
|
||||
String parsed = source_copy.substring(0, startindex);
|
||||
var parsed = source_copy.substring(0, startindex);
|
||||
endIndex = source_copy.indexOf("[/code]") + 7; // 7 == the sizeof "[/code]"
|
||||
nextCodeIndex = source_copy.indexOf("[code]", startindex + 6); // 6 == the sizeof "[code]"
|
||||
|
||||
|
@ -2463,7 +2460,7 @@ public abstract class StringUtils {
|
|||
/* must end before the next [code]
|
||||
* this will leave a dangling [/code] but the HTML is valid
|
||||
*/
|
||||
String sourcecopycopy = source_copy.substring(0, nextCodeIndex) +
|
||||
var sourcecopycopy = source_copy.substring(0, nextCodeIndex) +
|
||||
"[/code]" +
|
||||
source_copy.substring(nextCodeIndex);
|
||||
source_copy = sourcecopycopy;
|
||||
|
@ -2479,7 +2476,7 @@ public abstract class StringUtils {
|
|||
}
|
||||
}
|
||||
|
||||
String code = source_copy.substring(startindex, endIndex);
|
||||
var code = source_copy.substring(startindex, endIndex);
|
||||
|
||||
parsed = parseBBCode(parsed, shorten, sanitize, convert_bare, no_follow_links);
|
||||
|
||||
|
@ -2517,9 +2514,9 @@ public abstract class StringUtils {
|
|||
int startIndex;
|
||||
int endIndex;
|
||||
while (-1 != (startIndex = resultLowerCopy.indexOf("[*]"))) {
|
||||
int begin = resultLowerCopy.indexOf("[list]", startIndex + 3);
|
||||
int end = resultLowerCopy.indexOf("[/list]", startIndex + 3);
|
||||
int next = resultLowerCopy.indexOf("[*]", startIndex + 3); // 3 == sizeof [*]
|
||||
var begin = resultLowerCopy.indexOf("[list]", startIndex + 3);
|
||||
var end = resultLowerCopy.indexOf("[/list]", startIndex + 3);
|
||||
var next = resultLowerCopy.indexOf("[*]", startIndex + 3); // 3 == sizeof [*]
|
||||
|
||||
if (begin == -1) {
|
||||
begin = Integer.MAX_VALUE;
|
||||
|
@ -2559,11 +2556,11 @@ public abstract class StringUtils {
|
|||
result = StringUtils.replace(result, "[list]", "<ul>", false);
|
||||
result = StringUtils.replace(result, "[/list]", "</ul>", false);
|
||||
|
||||
Matcher color_matcher = BBCODE_COLOR.matcher(result);
|
||||
var color_matcher = BBCODE_COLOR.matcher(result);
|
||||
result = color_matcher.replaceAll("<font color=\"$1\">");
|
||||
result = StringUtils.replace(result, "[/color]", "</font>", false);
|
||||
|
||||
Matcher size_matcher = BBCODE_SIZE.matcher(result);
|
||||
var size_matcher = BBCODE_SIZE.matcher(result);
|
||||
result = size_matcher.replaceAll("<font size=\"$1\">");
|
||||
result = StringUtils.replace(result, "[/size]", "</font>", false);
|
||||
|
||||
|
@ -2574,10 +2571,10 @@ public abstract class StringUtils {
|
|||
result = convertUrl(result, BBCODE_BAREURL, shorten, sanitize, no_follow);
|
||||
}
|
||||
|
||||
Matcher img_matcher = BBCODE_IMG.matcher(result);
|
||||
var img_matcher = BBCODE_IMG.matcher(result);
|
||||
result = img_matcher.replaceAll("<div class=\"bbcode_img\"><img src=\"$1\" border=\"0\" alt=\"\" /></div>");
|
||||
|
||||
Matcher quote_matcher_long = BBCODE_QUOTE_LONG.matcher(result);
|
||||
var quote_matcher_long = BBCODE_QUOTE_LONG.matcher(result);
|
||||
result = quote_matcher_long.replaceAll("<div class=\"quoteaccount\">$1:</div><div class=\"quotebody\">");
|
||||
result = StringUtils.replace(result, "[quote]", "<div class=\"quotebody\">", false);
|
||||
result = StringUtils.replace(result, "[/quote]", "</div>", false);
|
||||
|
@ -2694,7 +2691,7 @@ public abstract class StringUtils {
|
|||
do {
|
||||
line++;
|
||||
|
||||
for (String linebreak : linebreaks) {
|
||||
for (var linebreak : linebreaks) {
|
||||
match = document.indexOf(linebreak, last_linebreak_index);
|
||||
if (match != -1) {
|
||||
if (match >= characterIndex) {
|
||||
|
@ -2778,7 +2775,7 @@ public abstract class StringUtils {
|
|||
// if they were and by removing them the width is not
|
||||
// exceeded, just continue
|
||||
if (Character.isWhitespace(line.charAt(end - 1))) {
|
||||
for (int j = end - 1; j >= 0; j--) {
|
||||
for (var j = end - 1; j >= 0; j--) {
|
||||
if (!Character.isWhitespace(line.charAt(j))) {
|
||||
if (j - line_start < width) {
|
||||
break_line = false;
|
||||
|
@ -2790,7 +2787,7 @@ public abstract class StringUtils {
|
|||
}
|
||||
|
||||
if (break_line) {
|
||||
String line_breaked = line.substring(line_start, start);
|
||||
var line_breaked = line.substring(line_start, start);
|
||||
// this can happen with trailing whitespace
|
||||
if (line_breaked.length() > width) {
|
||||
line_breaked = line_breaked.substring(0, width);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue