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