http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/util/_UnmodifiableCompositeSet.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/util/_UnmodifiableCompositeSet.java b/src/main/java/org/apache/freemarker/core/util/_UnmodifiableCompositeSet.java new file mode 100644 index 0000000..b64ab10 --- /dev/null +++ b/src/main/java/org/apache/freemarker/core/util/_UnmodifiableCompositeSet.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.freemarker.core.util; + +import java.util.Iterator; +import java.util.Set; + +import org.apache.freemarker.core.util._UnmodifiableSet; + +/** Don't use this; used internally by FreeMarker, might changes without notice. */ +public class _UnmodifiableCompositeSet<E> extends _UnmodifiableSet<E> { + + private final Set<E> set1, set2; + + public _UnmodifiableCompositeSet(Set<E> set1, Set<E> set2) { + this.set1 = set1; + this.set2 = set2; + } + + @Override + public Iterator<E> iterator() { + return new CompositeIterator(); + } + + @Override + public boolean contains(Object o) { + return set1.contains(o) || set2.contains(o); + } + + @Override + public int size() { + return set1.size() + set2.size(); + } + + private class CompositeIterator implements Iterator<E> { + + private Iterator<E> it1, it2; + private boolean it1Deplected; + + public boolean hasNext() { + if (!it1Deplected) { + if (it1 == null) { + it1 = set1.iterator(); + } + if (it1.hasNext()) { + return true; + } + + it2 = set2.iterator(); + it1 = null; + it1Deplected = true; + // Falls through + } + return it2.hasNext(); + } + + public E next() { + if (!it1Deplected) { + if (it1 == null) { + it1 = set1.iterator(); + } + if (it1.hasNext()) { + return it1.next(); + } + + it2 = set2.iterator(); + it1 = null; + it1Deplected = true; + // Falls through + } + return it2.next(); + } + + public void remove() { + throw new UnsupportedOperationException(); + } + + } + +}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/util/_UnmodifiableSet.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/util/_UnmodifiableSet.java b/src/main/java/org/apache/freemarker/core/util/_UnmodifiableSet.java new file mode 100644 index 0000000..efe59a1 --- /dev/null +++ b/src/main/java/org/apache/freemarker/core/util/_UnmodifiableSet.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.freemarker.core.util; + +import java.util.AbstractSet; + +/** Don't use this; used internally by FreeMarker, might changes without notice. */ +public abstract class _UnmodifiableSet<E> extends AbstractSet<E> { + + @Override + public boolean add(E o) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean remove(Object o) { + if (contains(o)) { + throw new UnsupportedOperationException(); + } + return false; + } + + @Override + public void clear() { + if (!isEmpty()) { + throw new UnsupportedOperationException(); + } + } + +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/servlet/FreemarkerServlet.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/servlet/FreemarkerServlet.java b/src/main/java/org/apache/freemarker/servlet/FreemarkerServlet.java index 2f11ad8..b22d5ec 100644 --- a/src/main/java/org/apache/freemarker/servlet/FreemarkerServlet.java +++ b/src/main/java/org/apache/freemarker/servlet/FreemarkerServlet.java @@ -59,8 +59,8 @@ import org.apache.freemarker.core.templateresolver.TemplateLoader; import org.apache.freemarker.core.templateresolver.impl.ClassTemplateLoader; import org.apache.freemarker.core.templateresolver.impl.FileTemplateLoader; import org.apache.freemarker.core.templateresolver.impl.MultiTemplateLoader; -import org.apache.freemarker.core.util.SecurityUtilities; -import org.apache.freemarker.core.util.StringUtil; +import org.apache.freemarker.core.util._SecurityUtil; +import org.apache.freemarker.core.util._StringUtil; import org.apache.freemarker.servlet.jsp.TaglibFactory; import org.apache.freemarker.servlet.jsp.TaglibFactory.ClasspathMetaInfTldSource; import org.apache.freemarker.servlet.jsp.TaglibFactory.ClearMetaInfTldSource; @@ -613,7 +613,7 @@ public class FreemarkerServlet extends HttpServlet { } if (value == null) { throw new MalformedWebXmlException( - "init-param " + StringUtil.jQuote(name) + " without param-value. " + "init-param " + _StringUtil.jQuote(name) + " without param-value. " + "Maybe the web.xml is not well-formed?"); } @@ -658,16 +658,16 @@ public class FreemarkerServlet extends HttpServlet { "Not one of the supported values."); } } else if (name.equals(INIT_PARAM_NO_CACHE)) { - noCache = StringUtil.getYesNo(value); + noCache = _StringUtil.getYesNo(value); } else if (name.equals(INIT_PARAM_BUFFER_SIZE)) { bufferSize = Integer.valueOf(parseSize(value)); } else if (name.equals(DEPR_INITPARAM_DEBUG)) { // BC if (getInitParameter(INIT_PARAM_DEBUG) != null) { throw new ConflictingInitParamsException(INIT_PARAM_DEBUG, DEPR_INITPARAM_DEBUG); } - debug = StringUtil.getYesNo(value); + debug = _StringUtil.getYesNo(value); } else if (name.equals(INIT_PARAM_DEBUG)) { - debug = StringUtil.getYesNo(value); + debug = _StringUtil.getYesNo(value); } else if (name.equals(INIT_PARAM_CONTENT_TYPE)) { contentType = new ContentType(value); } else if (name.equals(INIT_PARAM_OVERRIDE_RESPONSE_CONTENT_TYPE)) { @@ -681,7 +681,7 @@ public class FreemarkerServlet extends HttpServlet { } else if (name.equals(INIT_PARAM_OVERRIDE_RESPONSE_LOCALE)) { overrideResponseLocale = initParamValueToEnum(value, OverrideResponseLocale.values()); } else if (name.equals(INIT_PARAM_EXCEPTION_ON_MISSING_TEMPLATE)) { - exceptionOnMissingTemplate = StringUtil.getYesNo(value); + exceptionOnMissingTemplate = _StringUtil.getYesNo(value); } else if (name.equals(INIT_PARAM_META_INF_TLD_LOCATIONS)) {; metaInfTldSources = parseAsMetaInfTldLocations(value); } else if (name.equals(INIT_PARAM_CLASSPATH_TLDS)) {; @@ -796,7 +796,7 @@ public class FreemarkerServlet extends HttpServlet { String templatePath = requestUrlToTemplatePath(request); if (LOG.isDebugEnabled()) { - LOG.debug("Requested template " + StringUtil.jQuoteNoXSS(templatePath) + "."); + LOG.debug("Requested template " + _StringUtil.jQuoteNoXSS(templatePath) + "."); } Locale locale = request.getLocale(); @@ -810,21 +810,21 @@ public class FreemarkerServlet extends HttpServlet { } catch (TemplateNotFoundException e) { if (exceptionOnMissingTemplate) { throw newServletExceptionWithFreeMarkerLogging( - "Template not found for name " + StringUtil.jQuoteNoXSS(templatePath) + ".", e); + "Template not found for name " + _StringUtil.jQuoteNoXSS(templatePath) + ".", e); } else { if (LOG.isDebugEnabled()) { LOG.debug("Responding HTTP 404 \"Not found\" for missing template " - + StringUtil.jQuoteNoXSS(templatePath) + ".", e); + + _StringUtil.jQuoteNoXSS(templatePath) + ".", e); } response.sendError(HttpServletResponse.SC_NOT_FOUND, "Page template not found"); return; } } catch (org.apache.freemarker.core.ast.ParseException e) { throw newServletExceptionWithFreeMarkerLogging( - "Parsing error with template " + StringUtil.jQuoteNoXSS(templatePath) + ".", e); + "Parsing error with template " + _StringUtil.jQuoteNoXSS(templatePath) + ".", e); } catch (Exception e) { throw newServletExceptionWithFreeMarkerLogging( - "Unexpected error when loading template " + StringUtil.jQuoteNoXSS(templatePath) + ".", e); + "Unexpected error when loading template " + _StringUtil.jQuoteNoXSS(templatePath) + ".", e); } boolean tempSpecContentTypeContainsCharset = false; @@ -1097,7 +1097,7 @@ public class FreemarkerServlet extends HttpServlet { mergedMetaInfTldSources.addAll(metaInfTldSources); } - String sysPropVal = SecurityUtilities.getSystemProperty(SYSTEM_PROPERTY_META_INF_TLD_SOURCES, null); + String sysPropVal = _SecurityUtil.getSystemProperty(SYSTEM_PROPERTY_META_INF_TLD_SOURCES, null); if (sysPropVal != null) { try { List metaInfTldSourcesSysProp = parseAsMetaInfTldLocations(sysPropVal); @@ -1134,7 +1134,7 @@ public class FreemarkerServlet extends HttpServlet { mergedClassPathTlds.addAll(classpathTlds); } - String sysPropVal = SecurityUtilities.getSystemProperty(SYSTEM_PROPERTY_CLASSPATH_TLDS, null); + String sysPropVal = _SecurityUtil.getSystemProperty(SYSTEM_PROPERTY_CLASSPATH_TLDS, null); if (sysPropVal != null) { try { List/*<String>*/ classpathTldsSysProp = InitParamParser.parseCommaSeparatedList(sysPropVal); @@ -1517,14 +1517,14 @@ public class FreemarkerServlet extends HttpServlet { private static class InitParamValueException extends Exception { InitParamValueException(String initParamName, String initParamValue, Throwable casue) { - super("Failed to set the " + StringUtil.jQuote(initParamName) + " servlet init-param to " - + StringUtil.jQuote(initParamValue) + "; see cause exception.", + super("Failed to set the " + _StringUtil.jQuote(initParamName) + " servlet init-param to " + + _StringUtil.jQuote(initParamValue) + "; see cause exception.", casue); } public InitParamValueException(String initParamName, String initParamValue, String cause) { - super("Failed to set the " + StringUtil.jQuote(initParamName) + " servlet init-param to " - + StringUtil.jQuote(initParamValue) + ": " + cause); + super("Failed to set the " + _StringUtil.jQuote(initParamName) + " servlet init-param to " + + _StringUtil.jQuote(initParamValue) + ": " + cause); } } @@ -1533,8 +1533,8 @@ public class FreemarkerServlet extends HttpServlet { ConflictingInitParamsException(String recommendedName, String otherName) { super("Conflicting servlet init-params: " - + StringUtil.jQuote(recommendedName) + " and " + StringUtil.jQuote(otherName) - + ". Only use " + StringUtil.jQuote(recommendedName) + "."); + + _StringUtil.jQuote(recommendedName) + " and " + _StringUtil.jQuote(otherName) + + ". Only use " + _StringUtil.jQuote(recommendedName) + "."); } } @@ -1597,7 +1597,7 @@ public class FreemarkerServlet extends HttpServlet { } StringBuilder sb = new StringBuilder(); - sb.append(StringUtil.jQuote(initParamValue)); + sb.append(_StringUtil.jQuote(initParamValue)); sb.append(" is not a one of the enumeration values: "); boolean first = true; for (T value : enumValues) { @@ -1606,7 +1606,7 @@ public class FreemarkerServlet extends HttpServlet { } else { first = false; } - sb.append(StringUtil.jQuote(value.getInitParamValue())); + sb.append(_StringUtil.jQuote(value.getInitParamValue())); } throw new IllegalArgumentException(sb.toString()); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/servlet/InitParamParser.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/servlet/InitParamParser.java b/src/main/java/org/apache/freemarker/servlet/InitParamParser.java index 35f4680..ee2b78d 100644 --- a/src/main/java/org/apache/freemarker/servlet/InitParamParser.java +++ b/src/main/java/org/apache/freemarker/servlet/InitParamParser.java @@ -35,7 +35,7 @@ import org.apache.freemarker.core.templateresolver.TemplateLoader; import org.apache.freemarker.core.templateresolver.impl.ClassTemplateLoader; import org.apache.freemarker.core.templateresolver.impl.FileTemplateLoader; import org.apache.freemarker.core.templateresolver.impl.MultiTemplateLoader; -import org.apache.freemarker.core.util.StringUtil; +import org.apache.freemarker.core.util._StringUtil; import org.slf4j.Logger; @@ -127,7 +127,7 @@ final class InitParamParser { static List/*<String>*/ parseCommaSeparatedList(String value) throws ParseException { List/*<String>*/ valuesList = new ArrayList(); - String[] values = StringUtil.split(value, ','); + String[] values = _StringUtil.split(value, ','); for (int i = 0; i < values.length; i++) { final String s = values[i].trim(); if (s.length() != 0) { @@ -243,7 +243,7 @@ final class InitParamParser { if (!biName.equals(TEMPLATE_PATH_SETTINGS_BI_NAME)) { throw new TemplatePathParsingException( - StringUtil.jQuote(biName) + " is unexpected after the \"?\". " + _StringUtil.jQuote(biName) + " is unexpected after the \"?\". " + "Expected \"" + TEMPLATE_PATH_SETTINGS_BI_NAME + "\"."); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/servlet/WebAppTemplateLoader.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/servlet/WebAppTemplateLoader.java b/src/main/java/org/apache/freemarker/servlet/WebAppTemplateLoader.java index 8e74033..b3caaa7 100644 --- a/src/main/java/org/apache/freemarker/servlet/WebAppTemplateLoader.java +++ b/src/main/java/org/apache/freemarker/servlet/WebAppTemplateLoader.java @@ -35,9 +35,9 @@ import org.apache.freemarker.core.Configuration; import org.apache.freemarker.core._CoreLogs; import org.apache.freemarker.core.templateresolver.TemplateLoader; import org.apache.freemarker.core.templateresolver.TemplateLoaderSession; -import org.apache.freemarker.core.util.CollectionUtils; -import org.apache.freemarker.core.util.NullArgumentException; -import org.apache.freemarker.core.util.StringUtil; +import org.apache.freemarker.core.util._CollectionUtil; +import org.apache.freemarker.core.util._NullArgumentException; +import org.apache.freemarker.core.util._StringUtil; import org.apache.freemarker.core.templateresolver.TemplateLoadingResult; import org.apache.freemarker.core.templateresolver.TemplateLoadingSource; import org.apache.freemarker.core.templateresolver.impl.URLTemplateLoader; @@ -85,8 +85,8 @@ public class WebAppTemplateLoader implements TemplateLoader { * the base path to template resources. */ public WebAppTemplateLoader(ServletContext servletContext, String subdirPath) { - NullArgumentException.check("servletContext", servletContext); - NullArgumentException.check("subdirPath", subdirPath); + _NullArgumentException.check("servletContext", servletContext); + _NullArgumentException.check("subdirPath", subdirPath); subdirPath = subdirPath.replace('\\', '/'); if (!subdirPath.endsWith("/")) { @@ -125,16 +125,16 @@ public class WebAppTemplateLoader implements TemplateLoader { @Override public String toString() { return _TemplateLoaderUtils.getClassNameForToString(this) - + "(subdirPath=" + StringUtil.jQuote(subdirPath) - + ", servletContext={contextPath=" + StringUtil.jQuote(getContextPath()) - + ", displayName=" + StringUtil.jQuote(servletContext.getServletContextName()) + "})"; + + "(subdirPath=" + _StringUtil.jQuote(subdirPath) + + ", servletContext={contextPath=" + _StringUtil.jQuote(getContextPath()) + + ", displayName=" + _StringUtil.jQuote(servletContext.getServletContextName()) + "})"; } /** Gets the context path if we are on Servlet 2.5+, or else returns failure description string. */ private String getContextPath() { try { - Method m = servletContext.getClass().getMethod("getContextPath", CollectionUtils.EMPTY_CLASS_ARRAY); - return (String) m.invoke(servletContext, CollectionUtils.EMPTY_OBJECT_ARRAY); + Method m = servletContext.getClass().getMethod("getContextPath", _CollectionUtil.EMPTY_CLASS_ARRAY); + return (String) m.invoke(servletContext, _CollectionUtil.EMPTY_OBJECT_ARRAY); } catch (Throwable e) { return "[can't query before Serlvet 2.5]"; } @@ -231,7 +231,7 @@ public class WebAppTemplateLoader implements TemplateLoader { url = servletContext.getResource(fullPath); } catch (MalformedURLException e) { if (LOG.isWarnEnabled()) { - LOG.warn("Could not retrieve resource " + StringUtil.jQuoteNoXSS(fullPath), e); + LOG.warn("Could not retrieve resource " + _StringUtil.jQuoteNoXSS(fullPath), e); } return null; } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/servlet/jsp/CustomTagAndELFunctionCombiner.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/servlet/jsp/CustomTagAndELFunctionCombiner.java b/src/main/java/org/apache/freemarker/servlet/jsp/CustomTagAndELFunctionCombiner.java index e81bd28..9e87e01 100644 --- a/src/main/java/org/apache/freemarker/servlet/jsp/CustomTagAndELFunctionCombiner.java +++ b/src/main/java/org/apache/freemarker/servlet/jsp/CustomTagAndELFunctionCombiner.java @@ -35,7 +35,7 @@ import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateSequenceModel; import org.apache.freemarker.core.model.TemplateTransformModel; import org.apache.freemarker.core.model.impl.beans.SimpleMethodModel; -import org.apache.freemarker.core.util.ClassUtil; +import org.apache.freemarker.core.util._ClassUtil; /** * Used when a custom JSP tag and an EL function uses the same name in a tag library, to create a single FTL value from @@ -66,7 +66,7 @@ class CustomTagAndELFunctionCombiner { (TemplateTransformModel) customTag, elFunction); } else { throw new BugException( - "Unexpected custom JSP tag class: " + ClassUtil.getShortClassNameOfObject(customTag)); + "Unexpected custom JSP tag class: " + _ClassUtil.getShortClassNameOfObject(customTag)); } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/servlet/jsp/FreeMarkerJspApplicationContext.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/servlet/jsp/FreeMarkerJspApplicationContext.java b/src/main/java/org/apache/freemarker/servlet/jsp/FreeMarkerJspApplicationContext.java index 26cac1a..17fa734 100644 --- a/src/main/java/org/apache/freemarker/servlet/jsp/FreeMarkerJspApplicationContext.java +++ b/src/main/java/org/apache/freemarker/servlet/jsp/FreeMarkerJspApplicationContext.java @@ -40,7 +40,7 @@ import javax.servlet.jsp.JspApplicationContext; import javax.servlet.jsp.el.ImplicitObjectELResolver; import javax.servlet.jsp.el.ScopedAttributeELResolver; -import org.apache.freemarker.core.util.ClassUtil; +import org.apache.freemarker.core.util._ClassUtil; import org.apache.freemarker.servlet._ServletLogs; import org.slf4j.Logger; @@ -85,7 +85,7 @@ class FreeMarkerJspApplicationContext implements JspApplicationContext { private static ExpressionFactory tryExpressionFactoryImplementation(String packagePrefix) { String className = packagePrefix + ".el.ExpressionFactoryImpl"; try { - Class cl = ClassUtil.forName(className); + Class cl = _ClassUtil.forName(className); if (ExpressionFactory.class.isAssignableFrom(cl)) { LOG.info("Using {} as implementation of {}", className, ExpressionFactory.class.getName()); return (ExpressionFactory) cl.newInstance(); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/servlet/jsp/JspTagModelBase.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/servlet/jsp/JspTagModelBase.java b/src/main/java/org/apache/freemarker/servlet/jsp/JspTagModelBase.java index f0b38ce..61b965e 100644 --- a/src/main/java/org/apache/freemarker/servlet/jsp/JspTagModelBase.java +++ b/src/main/java/org/apache/freemarker/servlet/jsp/JspTagModelBase.java @@ -41,7 +41,7 @@ import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.impl._StaticObjectWrappers; import org.apache.freemarker.core.model.impl.beans.BeansWrapper; -import org.apache.freemarker.core.util.StringUtil; +import org.apache.freemarker.core.util._StringUtil; import org.apache.freemarker.servlet.jsp.SimpleTagDirectiveModel.TemplateExceptionWrapperJspException; class JspTagModelBase { @@ -96,7 +96,7 @@ class JspTagModelBase { if (setterMethod == null) { if (dynaSetter == null) { throw new TemplateModelException("Unknown property " - + StringUtil.jQuote(paramName.toString()) + + _StringUtil.jQuote(paramName.toString()) + " on instance of " + tagClass.getName()); } else { dynaSetter.invoke(tag, null, paramName, argArray[0]); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/servlet/jsp/JspWriterAdapter.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/servlet/jsp/JspWriterAdapter.java b/src/main/java/org/apache/freemarker/servlet/jsp/JspWriterAdapter.java index f11e1d5..c75c198 100644 --- a/src/main/java/org/apache/freemarker/servlet/jsp/JspWriterAdapter.java +++ b/src/main/java/org/apache/freemarker/servlet/jsp/JspWriterAdapter.java @@ -24,10 +24,10 @@ import java.io.Writer; import javax.servlet.jsp.JspWriter; -import org.apache.freemarker.core.util.SecurityUtilities; +import org.apache.freemarker.core.util._SecurityUtil; class JspWriterAdapter extends JspWriter { - static final char[] NEWLINE = SecurityUtilities.getSystemProperty("line.separator", "\n").toCharArray(); + static final char[] NEWLINE = _SecurityUtil.getSystemProperty("line.separator", "\n").toCharArray(); private final Writer out; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/servlet/jsp/TaglibFactory.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/servlet/jsp/TaglibFactory.java b/src/main/java/org/apache/freemarker/servlet/jsp/TaglibFactory.java index b6ad6d0..4c9ec46 100644 --- a/src/main/java/org/apache/freemarker/servlet/jsp/TaglibFactory.java +++ b/src/main/java/org/apache/freemarker/servlet/jsp/TaglibFactory.java @@ -70,10 +70,10 @@ import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateTransformModel; import org.apache.freemarker.core.model.impl.DefaultObjectWrapper; import org.apache.freemarker.core.model.impl.beans.BeansWrapper; -import org.apache.freemarker.core.util.ClassUtil; -import org.apache.freemarker.core.util.NullArgumentException; -import org.apache.freemarker.core.util.SecurityUtilities; -import org.apache.freemarker.core.util.StringUtil; +import org.apache.freemarker.core.util._ClassUtil; +import org.apache.freemarker.core.util._NullArgumentException; +import org.apache.freemarker.core.util._SecurityUtil; +import org.apache.freemarker.core.util._StringUtil; import org.apache.freemarker.servlet.FreemarkerServlet; import org.apache.freemarker.servlet.HttpRequestHashModel; import org.apache.freemarker.servlet._ServletLogs; @@ -123,7 +123,7 @@ public class TaglibFactory implements TemplateHashModel { private static final String DEFAULT_TLD_RESOURCE_PATH = META_INF_ABS_PATH + "taglib.tld"; private static final String JAR_URL_ENTRY_PATH_START = "!/"; - private static final String PLATFORM_FILE_ENCODING = SecurityUtilities.getSystemProperty("file.encoding", "utf-8"); + private static final String PLATFORM_FILE_ENCODING = _SecurityUtil.getSystemProperty("file.encoding", "utf-8"); private final ServletContext servletContext; @@ -190,7 +190,7 @@ public class TaglibFactory implements TemplateHashModel { final String normalizedTaglibUri; try { if (LOG.isDebugEnabled()) { - LOG.debug("Locating TLD for taglib URI " + StringUtil.jQuoteNoXSS(taglibUri) + "."); + LOG.debug("Locating TLD for taglib URI " + _StringUtil.jQuoteNoXSS(taglibUri) + "."); } TldLocation explicitlyMappedTldLocation = getExplicitlyMappedTldLocation(taglibUri); @@ -204,7 +204,7 @@ public class TaglibFactory implements TemplateHashModel { try { urlType = getUriType(taglibUri); } catch (MalformedURLException e) { - throw new TaglibGettingException("Malformed taglib URI: " + StringUtil.jQuote(taglibUri), e); + throw new TaglibGettingException("Malformed taglib URI: " + _StringUtil.jQuote(taglibUri), e); } if (urlType == URL_TYPE_RELATIVE) { normalizedTaglibUri = resolveRelativeUri(taglibUri); @@ -215,7 +215,7 @@ public class TaglibFactory implements TemplateHashModel { String failedTLDsList = getFailedTLDsList(); failedTldListAlreadyIncluded = true; throw new TaglibGettingException("No TLD was found for the " - + StringUtil.jQuoteNoXSS(taglibUri) + " JSP taglib URI. (TLD-s are searched according " + + _StringUtil.jQuoteNoXSS(taglibUri) + " JSP taglib URI. (TLD-s are searched according " + "the JSP 2.2 specification. In development- and embedded-servlet-container " + "setups you may also need the " + "\"" + FreemarkerServlet.INIT_PARAM_META_INF_TLD_LOCATIONS + "\" and " @@ -246,7 +246,7 @@ public class TaglibFactory implements TemplateHashModel { } catch (Exception e) { String failedTLDsList = failedTldListAlreadyIncluded ? null : getFailedTLDsList(); throw new TemplateModelException( - "Error while looking for TLD file for " + StringUtil.jQuoteNoXSS(taglibUri) + "Error while looking for TLD file for " + _StringUtil.jQuoteNoXSS(taglibUri) + "; see cause exception." + (failedTLDsList == null ? "" @@ -259,8 +259,8 @@ public class TaglibFactory implements TemplateHashModel { return loadTaglib(tldLocation, normalizedTaglibUri); } catch (Exception e) { throw new TemplateModelException("Error while loading tag library for URI " - + StringUtil.jQuoteNoXSS(normalizedTaglibUri) + " from TLD location " - + StringUtil.jQuoteNoXSS(tldLocation) + "; see cause exception.", + + _StringUtil.jQuoteNoXSS(normalizedTaglibUri) + " from TLD location " + + _StringUtil.jQuoteNoXSS(tldLocation) + "; see cause exception.", e); } } @@ -279,7 +279,7 @@ public class TaglibFactory implements TemplateHashModel { if (i != 0) { sb.append(", "); } - sb.append(StringUtil.jQuote(failedTldLocations.get(i))); + sb.append(_StringUtil.jQuote(failedTldLocations.get(i))); } return sb.toString(); } @@ -344,7 +344,7 @@ public class TaglibFactory implements TemplateHashModel { */ public void setMetaInfTldSources(List/*<? extends MetaInfTldSource>*/ metaInfTldSources) { checkNotStarted(); - NullArgumentException.check("metaInfTldSources", metaInfTldSources); + _NullArgumentException.check("metaInfTldSources", metaInfTldSources); this.metaInfTldSources = metaInfTldSources; } @@ -375,7 +375,7 @@ public class TaglibFactory implements TemplateHashModel { */ public void setClasspathTlds(List/*<String>*/ classpathTlds) { checkNotStarted(); - NullArgumentException.check("classpathTlds", classpathTlds); + _NullArgumentException.check("classpathTlds", classpathTlds); this.classpathTlds = classpathTlds; } @@ -573,7 +573,7 @@ public class TaglibFactory implements TemplateHashModel { in = tldLocation.getInputStream(); } catch (IOException e) { if (LOG.isWarnEnabled()) { - LOG.warn("Ignored classpath TLD location " + StringUtil.jQuoteNoXSS(tldResourcePath) + LOG.warn("Ignored classpath TLD location " + _StringUtil.jQuoteNoXSS(tldResourcePath) + " because of error", e); } in = null; @@ -741,7 +741,7 @@ public class TaglibFactory implements TemplateHashModel { private void addTldLocationsFromFileDirectory(final File dir) throws IOException, SAXException { if (dir.isDirectory()) { if (LOG.isDebugEnabled()) { - LOG.debug("Scanning for *.tld-s in File directory: " + StringUtil.jQuoteNoXSS(dir)); + LOG.debug("Scanning for *.tld-s in File directory: " + _StringUtil.jQuoteNoXSS(dir)); } File[] tldFiles = dir.listFiles(new FilenameFilter() { @@ -759,7 +759,7 @@ public class TaglibFactory implements TemplateHashModel { addTldLocationFromTld(new FileTldLocation(file)); } } else { - LOG.warn("Skipped scanning for *.tld for non-existent directory: " + StringUtil.jQuoteNoXSS(dir)); + LOG.warn("Skipped scanning for *.tld for non-existent directory: " + _StringUtil.jQuoteNoXSS(dir)); } } @@ -802,14 +802,14 @@ public class TaglibFactory implements TemplateHashModel { private void addTldLocation(TldLocation tldLocation, String taglibUri) { if (tldLocations.containsKey(taglibUri)) { if (LOG.isDebugEnabled()) { - LOG.debug("Ignored duplicate mapping of taglib URI " + StringUtil.jQuoteNoXSS(taglibUri) - + " to TLD location " + StringUtil.jQuoteNoXSS(tldLocation)); + LOG.debug("Ignored duplicate mapping of taglib URI " + _StringUtil.jQuoteNoXSS(taglibUri) + + " to TLD location " + _StringUtil.jQuoteNoXSS(tldLocation)); } } else { tldLocations.put(taglibUri, tldLocation); if (LOG.isDebugEnabled()) { - LOG.debug("Mapped taglib URI " + StringUtil.jQuoteNoXSS(taglibUri) - + " to TLD location " + StringUtil.jQuoteNoXSS(tldLocation)); + LOG.debug("Mapped taglib URI " + _StringUtil.jQuoteNoXSS(taglibUri) + + " to TLD location " + _StringUtil.jQuoteNoXSS(tldLocation)); } } } @@ -853,8 +853,8 @@ public class TaglibFactory implements TemplateHashModel { */ private TemplateHashModel loadTaglib(TldLocation tldLocation, String taglibUri) throws IOException, SAXException { if (LOG.isDebugEnabled()) { - LOG.debug("Loading taglib for URI " + StringUtil.jQuoteNoXSS(taglibUri) - + " from TLD location " + StringUtil.jQuoteNoXSS(tldLocation)); + LOG.debug("Loading taglib for URI " + _StringUtil.jQuoteNoXSS(taglibUri) + + " from TLD location " + _StringUtil.jQuoteNoXSS(tldLocation)); } final Taglib taglib = new Taglib(servletContext, tldLocation, objectWrapper); taglibs.put(taglibUri, taglib); @@ -973,7 +973,7 @@ public class TaglibFactory implements TemplateHashModel { relativeEntryPath = relativeEntryPath.substring(1); } try { - return new URL(jarBaseEntryUrl, StringUtil.URLPathEnc(relativeEntryPath, PLATFORM_FILE_ENCODING)); + return new URL(jarBaseEntryUrl, _StringUtil.URLPathEnc(relativeEntryPath, PLATFORM_FILE_ENCODING)); } catch (UnsupportedEncodingException e) { throw new BugException(); } @@ -1071,8 +1071,8 @@ public class TaglibFactory implements TemplateHashModel { PLATFORM_FILE_ENCODING)); } catch (Exception e) { LOG.error("Couldn't get URL for serlvetContext resource " - + StringUtil.jQuoteNoXSS(servletContextJarFilePath) - + " / jar entry " + StringUtil.jQuoteNoXSS(entryPath), + + _StringUtil.jQuoteNoXSS(servletContextJarFilePath) + + " / jar entry " + _StringUtil.jQuoteNoXSS(entryPath), e); return null; } @@ -1304,8 +1304,8 @@ public class TaglibFactory implements TemplateHashModel { public JarEntryTldLocation(URL entryUrl, InputStreamFactory fallbackRawJarContentInputStreamFactory, String entryPath) { if (entryUrl == null) { - NullArgumentException.check(fallbackRawJarContentInputStreamFactory); - NullArgumentException.check(entryPath); + _NullArgumentException.check(fallbackRawJarContentInputStreamFactory); + _NullArgumentException.check(entryPath); } this.entryUrl = entryUrl; @@ -1369,7 +1369,7 @@ public class TaglibFactory implements TemplateHashModel { while (true) { final ZipEntry macthedJarEntry = zipIn.getNextEntry(); if (macthedJarEntry == null) { - throw new IOException("Could not find JAR entry " + StringUtil.jQuoteNoXSS(entryPath) + "."); + throw new IOException("Could not find JAR entry " + _StringUtil.jQuoteNoXSS(entryPath) + "."); } if (entryPath.equals(normalizeJarEntryPath(macthedJarEntry.getName(), false))) { returnedZipIn = true; @@ -1740,7 +1740,7 @@ public class TaglibFactory implements TemplateHashModel { customTagModel, (TemplateMethodModelEx) replacedTagOrFunction)); } else { if (LOG.isWarnEnabled()) { - LOG.warn("TLD contains multiple tags with name " + StringUtil.jQuote(tagNameCData) + LOG.warn("TLD contains multiple tags with name " + _StringUtil.jQuote(tagNameCData) + "; keeping only the last one."); } } @@ -1762,9 +1762,9 @@ public class TaglibFactory implements TemplateHashModel { functionClass, functionSignatureCData); } catch (Exception e) { throw new TldParsingSAXException( - "Error while trying to resolve signature " + StringUtil.jQuote(functionSignatureCData) - + " on class " + StringUtil.jQuote(functionClass.getName()) - + " for custom EL function " + StringUtil.jQuote(functionNameCData) + ".", + "Error while trying to resolve signature " + _StringUtil.jQuote(functionSignatureCData) + + " on class " + _StringUtil.jQuote(functionClass.getName()) + + " for custom EL function " + _StringUtil.jQuote(functionNameCData) + ".", locator, e); } @@ -1793,7 +1793,7 @@ public class TaglibFactory implements TemplateHashModel { } else { if (LOG.isWarnEnabled()) { LOG.warn("TLD contains multiple functions with name " - + StringUtil.jQuote(functionNameCData) + "; keeping only the last one."); + + _StringUtil.jQuote(functionNameCData) + "; keeping only the last one."); } } } @@ -1843,7 +1843,7 @@ public class TaglibFactory implements TemplateHashModel { private Class resoveClassFromTLD(String className, String entryType, String entryName) throws TldParsingSAXException { try { - return ClassUtil.forName(className); + return _ClassUtil.forName(className); } catch (LinkageError e) { throw newTLDEntryClassLoadingException(e, className, entryType, entryName); } catch (ClassNotFoundException e) { @@ -1863,8 +1863,8 @@ public class TaglibFactory implements TemplateHashModel { && Character.isUpperCase(className.charAt(dotIdx + 1)); return new TldParsingSAXException( (e instanceof ClassNotFoundException ? "Not found class " : "Can't load class ") - + StringUtil.jQuote(className) + " for " + entryType - + (entryName != null ? " " + StringUtil.jQuote(entryName) : "") + "." + + _StringUtil.jQuote(className) + " for " + entryType + + (entryName != null ? " " + _StringUtil.jQuote(entryName) : "") + "." + (looksLikeNestedClass ? " Hint: Before nested classes, use \"$\", not \".\"." : ""), http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/servlet/jsp/TaglibMethodUtil.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/servlet/jsp/TaglibMethodUtil.java b/src/main/java/org/apache/freemarker/servlet/jsp/TaglibMethodUtil.java index 6530e81..4f36ee1 100644 --- a/src/main/java/org/apache/freemarker/servlet/jsp/TaglibMethodUtil.java +++ b/src/main/java/org/apache/freemarker/servlet/jsp/TaglibMethodUtil.java @@ -23,8 +23,8 @@ import java.lang.reflect.Method; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.freemarker.core.util.ClassUtil; -import org.apache.freemarker.core.util.StringUtil; +import org.apache.freemarker.core.util._ClassUtil; +import org.apache.freemarker.core.util._StringUtil; final class TaglibMethodUtil { @@ -61,7 +61,7 @@ final class TaglibMethodUtil { if ("".equals(params)) { paramTypes = new Class[0]; } else { - String [] paramsArray = StringUtil.split(params, ','); + String [] paramsArray = _StringUtil.split(params, ','); paramTypes = new Class[paramsArray.length]; String token = null; String paramType = null; @@ -103,9 +103,9 @@ final class TaglibMethodUtil { } } else { if (isArrayType) { - paramTypes[i] = ClassUtil.forName("[L" + paramType + ";"); + paramTypes[i] = _ClassUtil.forName("[L" + paramType + ";"); } else { - paramTypes[i] = ClassUtil.forName(paramType); + paramTypes[i] = _ClassUtil.forName(paramType); } } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/servlet/jsp/_FreeMarkerPageContext21.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/servlet/jsp/_FreeMarkerPageContext21.java b/src/main/java/org/apache/freemarker/servlet/jsp/_FreeMarkerPageContext21.java index 4106439..af6f350 100644 --- a/src/main/java/org/apache/freemarker/servlet/jsp/_FreeMarkerPageContext21.java +++ b/src/main/java/org/apache/freemarker/servlet/jsp/_FreeMarkerPageContext21.java @@ -32,7 +32,7 @@ import javax.servlet.jsp.el.ExpressionEvaluator; import javax.servlet.jsp.el.VariableResolver; import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.util.ClassUtil; +import org.apache.freemarker.core.util._ClassUtil; import org.apache.freemarker.servlet._ServletLogs; import org.slf4j.Logger; @@ -111,7 +111,7 @@ public class _FreeMarkerPageContext21 extends FreeMarkerPageContext { } else { throw new UnsupportedOperationException( "Can not create an ELContext using a foreign JspApplicationContext (of class " - + ClassUtil.getShortClassNameOfObject(jspctx) + ").\n" + + + _ClassUtil.getShortClassNameOfObject(jspctx) + ").\n" + "Hint: The cause of this is often that you are trying to use JSTL tags/functions in FTL. " + "In that case, know that that's not really suppored, and you are supposed to use FTL " + "constrcuts instead, like #list instead of JSTL's forEach, etc."); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/javacc/FTL.jj ---------------------------------------------------------------------- diff --git a/src/main/javacc/FTL.jj b/src/main/javacc/FTL.jj index 9c9b4b2..e6cedca 100644 --- a/src/main/javacc/FTL.jj +++ b/src/main/javacc/FTL.jj @@ -113,13 +113,13 @@ public class FMParser { TemplateSpecifiedEncodingHandler templateSpecifiedEncodingHandler) { this(tkMan); - NullArgumentException.check(pCfg); + _NullArgumentException.check(pCfg); this.pCfg = pCfg; - NullArgumentException.check(templateSpecifiedEncodingHandler); + _NullArgumentException.check(templateSpecifiedEncodingHandler); this.templateSpecifiedEncodingHandler = templateSpecifiedEncodingHandler; - NullArgumentException.check(template); + _NullArgumentException.check(template); this.template = template; int incompatibleImprovements = pCfg.getIncompatibleImprovements().intValue(); @@ -387,7 +387,7 @@ public class FMParser { } if (legacyCompat && tm instanceof TemplateScalarModel) { try { - return StringUtil.getYesNo(((TemplateScalarModel) tm).getAsString()); + return _StringUtil.getYesNo(((TemplateScalarModel) tm).getAsString()); } catch (Exception e) { throw new ParseException(e.getMessage() + "\nExpecting boolean (true/false), found: " + exp.getCanonicalForm(), @@ -553,7 +553,7 @@ TOKEN_MGR_DECLS: } void checkNamingConvention(Token tok) { - checkNamingConvention(tok, _CoreStringUtils.getIdentifierNamingConvention(tok.image)); + checkNamingConvention(tok, _StringUtil.getIdentifierNamingConvention(tok.image)); } void checkNamingConvention(Token tok, int tokenNamingConvention) { @@ -585,9 +585,9 @@ TOKEN_MGR_DECLS: ? "estabilished by auto-detection at " + MessageUtil.formatPosition( namingConventionEstabilisher.beginLine, namingConventionEstabilisher.beginColumn) - + " by token " + StringUtil.jQuote(namingConventionEstabilisher.image.trim()) + + " by token " + _StringUtil.jQuote(namingConventionEstabilisher.image.trim()) : "") - + ", but the problematic token, " + StringUtil.jQuote(tok.image.trim()) + + ", but the problematic token, " + _StringUtil.jQuote(tok.image.trim()) + ", uses a different convention.", TokenMgrError.LEXICAL_ERROR, tok.beginLine, tok.beginColumn, tok.endLine, tok.endColumn); @@ -600,7 +600,7 @@ TOKEN_MGR_DECLS: * The index of the deciding character relatively to the first letter of the name. */ private static int getTagNamingConvention(Token tok, int charIdxInName) { - return _CoreStringUtils.isUpperUSASCII(getTagNameCharAt(tok, charIdxInName)) + return _StringUtil.isUpperUSASCII(getTagNameCharAt(tok, charIdxInName)) ? Configuration.CAMEL_CASE_NAMING_CONVENTION : Configuration.LEGACY_NAMING_CONVENTION; } @@ -2151,7 +2151,7 @@ StringLiteral StringLiteral(boolean interpolate) : s = t.image.substring(2, t.image.length() -1); } else { try { - s = StringUtil.FTLStringLiteralDec(t.image.substring(1, t.image.length() -1)); + s = _StringUtil.FTLStringLiteralDec(t.image.substring(1, t.image.length() -1)); } catch (ParseException pe) { pe.lineNumber = t.beginLine; pe.columnNumber = t.beginColumn; @@ -3605,7 +3605,7 @@ OutputFormatBlock OutputFormat() : } } else { throw new ParseException( - "Parameter must be a string, but was: " + ClassUtil.getFTLTypeDescription(paramTM), + "Parameter must be a string, but was: " + _ClassUtil.getFTLTypeDescription(paramTM), paramExp); } @@ -3982,7 +3982,7 @@ TemplateElement OptionalBlock() : tp = MixedContent() ] { - return tp != null ? tp : new TextBlock(CollectionUtils.EMPTY_CHAR_ARRAY, false); + return tp != null ? tp : new TextBlock(_CollectionUtil.EMPTY_CHAR_ARRAY, false); } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/manual/en_US/FM3-CHANGE-LOG.txt ---------------------------------------------------------------------- diff --git a/src/manual/en_US/FM3-CHANGE-LOG.txt b/src/manual/en_US/FM3-CHANGE-LOG.txt index e75b945..04dd6ab 100644 --- a/src/manual/en_US/FM3-CHANGE-LOG.txt +++ b/src/manual/en_US/FM3-CHANGE-LOG.txt @@ -80,4 +80,7 @@ the FreeMarer 3 changelog here: - Removed ResourceBundleLocalizedString and LocalizedString: Hardly anybody has discovered these, and they had no JUnit coverage. - Added early draft of TemplateResolver, renamed TemplateCache to DefaultTemplateResolver. TemplateResolver is not yet directly used in Configuration. This was only added in a hurry, so that it's visible why the - o.a.f.core.templateresolver subpackage name makes sense. \ No newline at end of file + o.a.f.core.templateresolver subpackage name makes sense. +- Marked most static utility classes as internal, and renamed them to start with "_" (for example StringUtils was renamed to + _StringUtil, thus people won't accidentally use it when they wanted to autocomplete to Apache Commons StringUtil). +- Deleted o.a.f..core.util.DOMNodeModel \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/test/java/org/apache/freemarker/core/ConfigurationTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/ConfigurationTest.java b/src/test/java/org/apache/freemarker/core/ConfigurationTest.java index 9cec543..3451dac 100644 --- a/src/test/java/org/apache/freemarker/core/ConfigurationTest.java +++ b/src/test/java/org/apache/freemarker/core/ConfigurationTest.java @@ -66,7 +66,6 @@ import org.apache.freemarker.core.ast.TemplateNumberFormatFactory; import org.apache.freemarker.core.ast.UndefinedOutputFormat; import org.apache.freemarker.core.ast.UnregisteredOutputFormatException; import org.apache.freemarker.core.ast.XMLOutputFormat; -import org.apache.freemarker.core.ast._CoreStringUtils; import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateScalarModel; import org.apache.freemarker.core.model.impl.DefaultObjectWrapper; @@ -88,9 +87,10 @@ import org.apache.freemarker.core.templateresolver.impl.NullCacheStorage; import org.apache.freemarker.core.templateresolver.impl.SoftCacheStorage; import org.apache.freemarker.core.templateresolver.impl.StringTemplateLoader; import org.apache.freemarker.core.templateresolver.impl.StrongCacheStorage; -import org.apache.freemarker.core.util.DateUtil; -import org.apache.freemarker.core.util.NullArgumentException; -import org.apache.freemarker.core.util.NullWriter; +import org.apache.freemarker.core.util._DateUtil; +import org.apache.freemarker.core.util._NullArgumentException; +import org.apache.freemarker.core.util._NullWriter; +import org.apache.freemarker.core.util._StringUtil; import org.junit.Test; import com.google.common.collect.ImmutableList; @@ -327,7 +327,7 @@ public class ConfigurationTest extends TestCase { public void testShowErrorTips() throws Exception { Configuration cfg = new Configuration(); try { - new Template(null, "${x}", cfg).process(null, NullWriter.INSTANCE); + new Template(null, "${x}", cfg).process(null, _NullWriter.INSTANCE); fail(); } catch (TemplateException e) { assertThat(e.getMessage(), containsString("Tip:")); @@ -335,7 +335,7 @@ public class ConfigurationTest extends TestCase { cfg.setShowErrorTips(false); try { - new Template(null, "${x}", cfg).process(null, NullWriter.INSTANCE); + new Template(null, "${x}", cfg).process(null, _NullWriter.INSTANCE); fail(); } catch (TemplateException e) { assertThat(e.getMessage(), not(containsString("Tip:"))); @@ -858,7 +858,7 @@ public class ConfigurationTest extends TestCase { { Template t = cfg.getTemplate("Stat/t.de.ftlx"); assertEquals("TODO,XML", t.getBooleanFormat()); - assertEquals(DateUtil.UTC, t.getTimeZone()); + assertEquals(_DateUtil.UTC, t.getTimeZone()); } assertNotNull(cfg.getTemplateConfigurations()); @@ -912,7 +912,7 @@ public class ConfigurationTest extends TestCase { try { cfg.setOutputFormat(null); fail(); - } catch (NullArgumentException e) { + } catch (_NullArgumentException e) { // Expected } @@ -1118,15 +1118,15 @@ public class ConfigurationTest extends TestCase { assertNull(env2.getSQLDateAndTimeTimeZone()); assertEquals("null", env2.getSetting(Configurable.SQL_DATE_AND_TIME_TIME_ZONE_KEY)); - env1.setSQLDateAndTimeTimeZone(DateUtil.UTC); + env1.setSQLDateAndTimeTimeZone(_DateUtil.UTC); // cfg: assertEquals(TimeZone.getDefault(), cfg.getTimeZone()); assertNull(cfg.getSQLDateAndTimeTimeZone()); assertEquals("null", cfg.getSetting(Configurable.SQL_DATE_AND_TIME_TIME_ZONE_KEY)); // env: assertEquals(TimeZone.getDefault(), env1.getTimeZone()); - assertEquals(DateUtil.UTC, env1.getSQLDateAndTimeTimeZone()); - assertEquals(DateUtil.UTC.getID(), env1.getSetting(Configurable.SQL_DATE_AND_TIME_TIME_ZONE_KEY)); + assertEquals(_DateUtil.UTC, env1.getSQLDateAndTimeTimeZone()); + assertEquals(_DateUtil.UTC.getID(), env1.getSetting(Configurable.SQL_DATE_AND_TIME_TIME_ZONE_KEY)); TimeZone localTZ = TimeZone.getTimeZone("Europe/Brussels"); env1.setTimeZone(localTZ); @@ -1136,8 +1136,8 @@ public class ConfigurationTest extends TestCase { assertEquals("null", cfg.getSetting(Configurable.SQL_DATE_AND_TIME_TIME_ZONE_KEY)); // env: assertEquals(localTZ, env1.getTimeZone()); - assertEquals(DateUtil.UTC, env1.getSQLDateAndTimeTimeZone()); - assertEquals(DateUtil.UTC.getID(), env1.getSetting(Configurable.SQL_DATE_AND_TIME_TIME_ZONE_KEY)); + assertEquals(_DateUtil.UTC, env1.getSQLDateAndTimeTimeZone()); + assertEquals(_DateUtil.UTC.getID(), env1.getSetting(Configurable.SQL_DATE_AND_TIME_TIME_ZONE_KEY)); // env 2: assertEquals(TimeZone.getDefault(), env2.getTimeZone()); assertNull(env2.getSQLDateAndTimeTimeZone()); @@ -1154,8 +1154,8 @@ public class ConfigurationTest extends TestCase { assertEquals(otherTZ2.getID(), cfg.getSetting(Configurable.SQL_DATE_AND_TIME_TIME_ZONE_KEY)); // env: assertEquals(localTZ, env1.getTimeZone()); - assertEquals(DateUtil.UTC, env1.getSQLDateAndTimeTimeZone()); - assertEquals(DateUtil.UTC.getID(), env1.getSetting(Configurable.SQL_DATE_AND_TIME_TIME_ZONE_KEY)); + assertEquals(_DateUtil.UTC, env1.getSQLDateAndTimeTimeZone()); + assertEquals(_DateUtil.UTC.getID(), env1.getSetting(Configurable.SQL_DATE_AND_TIME_TIME_ZONE_KEY)); // env 2: assertEquals(otherTZ1, env2.getTimeZone()); assertEquals(otherTZ2, env2.getSQLDateAndTimeTimeZone()); @@ -1248,7 +1248,7 @@ public class ConfigurationTest extends TestCase { for (Version v : new Version[] { Configuration.VERSION_2_3_0, Configuration.VERSION_2_3_22 }) { Configuration cfg = new Configuration(v); try { - new Template(null, "${1?api}", cfg).process(null, NullWriter.INSTANCE); + new Template(null, "${1?api}", cfg).process(null, _NullWriter.INSTANCE); fail(); } catch (TemplateException e) { assertThat(e.getMessage(), containsString(Configurable.API_BUILTIN_ENABLED_KEY)); @@ -1258,7 +1258,7 @@ public class ConfigurationTest extends TestCase { Configuration cfg = new Configuration(Configuration.VERSION_2_3_22); cfg.setAPIBuiltinEnabled(true); new Template(null, "${m?api.hashCode()}", cfg) - .process(Collections.singletonMap("m", new HashMap()), NullWriter.INSTANCE); + .process(Collections.singletonMap("m", new HashMap()), _NullWriter.INSTANCE); } @Test @@ -1694,7 +1694,7 @@ public class ConfigurationTest extends TestCase { resultCC = e; } - String nameSC = _CoreStringUtils.camelCaseToUnderscored(nameCC); + String nameSC = _StringUtil.camelCaseToUnderscored(nameCC); Exception resultSC = null; try { cfg.setSetting(nameSC, value); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/test/java/org/apache/freemarker/core/CustomAttributeTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/CustomAttributeTest.java b/src/test/java/org/apache/freemarker/core/CustomAttributeTest.java index 23849a3..3f314e8 100644 --- a/src/test/java/org/apache/freemarker/core/CustomAttributeTest.java +++ b/src/test/java/org/apache/freemarker/core/CustomAttributeTest.java @@ -24,11 +24,9 @@ import static org.junit.Assert.*; import java.math.BigDecimal; import java.util.Arrays; -import org.apache.freemarker.core.Configuration; -import org.apache.freemarker.core.Template; import org.apache.freemarker.core.ast.CustomAttribute; import org.apache.freemarker.core.ast.Environment; -import org.apache.freemarker.core.util.NullWriter; +import org.apache.freemarker.core.util._NullWriter; import org.junit.Test; import com.google.common.collect.ImmutableList; @@ -199,7 +197,7 @@ public class CustomAttributeTest { final Configuration cfg = new Configuration(Configuration.VERSION_2_3_22); final Template t = new Template(null, "${testScopesFromTemplateStep1()}", cfg); - Environment env = t.createProcessingEnvironment(this, NullWriter.INSTANCE); + Environment env = t.createProcessingEnvironment(this, _NullWriter.INSTANCE); CUST_ATT_TMP_2.set(123, env); CUST_ATT_ENV_2.set(1234, env); CUST_ATT_CFG_2.set(12345, env); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/test/java/org/apache/freemarker/core/ExceptionTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/ExceptionTest.java b/src/test/java/org/apache/freemarker/core/ExceptionTest.java index 710f0bc..c2f2a9f 100644 --- a/src/test/java/org/apache/freemarker/core/ExceptionTest.java +++ b/src/test/java/org/apache/freemarker/core/ExceptionTest.java @@ -32,12 +32,9 @@ import java.io.StringWriter; import java.util.Collections; import java.util.Locale; -import org.apache.freemarker.core.Configuration; -import org.apache.freemarker.core.Template; -import org.apache.freemarker.core.TemplateException; import org.apache.freemarker.core.ast.ParseException; import org.apache.freemarker.core.templateresolver.impl.StringTemplateLoader; -import org.apache.freemarker.core.util.NullWriter; +import org.apache.freemarker.core.util._NullWriter; import junit.framework.TestCase; public class ExceptionTest extends TestCase { @@ -81,7 +78,7 @@ public class ExceptionTest extends TestCase { Template t = cfg.getTemplate("foo.ftl", Locale.US); try { - t.process(null, NullWriter.INSTANCE); + t.process(null, _NullWriter.INSTANCE); fail(); } catch (TemplateException e) { assertEquals("foo.ftl", e.getTemplateName()); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/test/java/org/apache/freemarker/core/MistakenlyPublicImportAPIsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/MistakenlyPublicImportAPIsTest.java b/src/test/java/org/apache/freemarker/core/MistakenlyPublicImportAPIsTest.java index 6c65c5b..5d742bd 100644 --- a/src/test/java/org/apache/freemarker/core/MistakenlyPublicImportAPIsTest.java +++ b/src/test/java/org/apache/freemarker/core/MistakenlyPublicImportAPIsTest.java @@ -26,16 +26,13 @@ import java.io.IOException; import java.io.StringWriter; import java.util.List; -import org.apache.freemarker.core.Configuration; -import org.apache.freemarker.core.Template; -import org.apache.freemarker.core.TemplateException; import org.apache.freemarker.core.ast.Environment; import org.apache.freemarker.core.ast.InvalidReferenceException; import org.apache.freemarker.core.ast.LibraryLoad; import org.apache.freemarker.core.ast.Environment.Namespace; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.templateresolver.impl.StringTemplateLoader; -import org.apache.freemarker.core.util.NullWriter; +import org.apache.freemarker.core.util._NullWriter; import org.junit.Test; /** @@ -62,7 +59,7 @@ public class MistakenlyPublicImportAPIsTest { } try { - t2.process(null, NullWriter.INSTANCE); + t2.process(null, _NullWriter.INSTANCE); fail(); } catch (InvalidReferenceException e) { // Apparenly, it has never worked like this... @@ -71,7 +68,7 @@ public class MistakenlyPublicImportAPIsTest { } // It works this way, though it has nothing to do with the problematic API-s: - Environment env = t1.createProcessingEnvironment(null, NullWriter.INSTANCE); + Environment env = t1.createProcessingEnvironment(null, _NullWriter.INSTANCE); env.process(); TemplateModel i1 = env.getVariable("i1"); assertThat(i1, instanceOf(Namespace.class)); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/test/java/org/apache/freemarker/core/MistakenlyPublicMacroAPIsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/MistakenlyPublicMacroAPIsTest.java b/src/test/java/org/apache/freemarker/core/MistakenlyPublicMacroAPIsTest.java index 1774c2f..594af53 100644 --- a/src/test/java/org/apache/freemarker/core/MistakenlyPublicMacroAPIsTest.java +++ b/src/test/java/org/apache/freemarker/core/MistakenlyPublicMacroAPIsTest.java @@ -26,13 +26,10 @@ import java.io.IOException; import java.io.StringWriter; import java.util.Map; -import org.apache.freemarker.core.Configuration; -import org.apache.freemarker.core.Template; -import org.apache.freemarker.core.TemplateException; import org.apache.freemarker.core.ast.Environment; import org.apache.freemarker.core.ast.Macro; import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.util.NullWriter; +import org.apache.freemarker.core.util._NullWriter; import org.junit.Test; /** @@ -72,7 +69,7 @@ public class MistakenlyPublicMacroAPIsTest { @Test public void testMacroCopyingFromFTLVariable() throws IOException, TemplateException { Template tMacros = new Template(null, "<#assign x = 0><#macro m1>${x}</#macro>", cfg); - Environment env = tMacros.createProcessingEnvironment(null, NullWriter.INSTANCE); + Environment env = tMacros.createProcessingEnvironment(null, _NullWriter.INSTANCE); env.process(); TemplateModel m1 = env.getVariable("m1"); assertThat(m1, instanceOf(Macro.class)); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/test/java/org/apache/freemarker/core/ast/ASTPrinter.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/ast/ASTPrinter.java b/src/test/java/org/apache/freemarker/core/ast/ASTPrinter.java index f002ff4..d1af0d2 100644 --- a/src/test/java/org/apache/freemarker/core/ast/ASTPrinter.java +++ b/src/test/java/org/apache/freemarker/core/ast/ASTPrinter.java @@ -40,15 +40,9 @@ import java.util.regex.PatternSyntaxException; import org.apache.freemarker.core.Configuration; import org.apache.freemarker.core.Template; -import org.apache.freemarker.core.ast.Expression; -import org.apache.freemarker.core.ast.MixedContent; -import org.apache.freemarker.core.ast.ParameterRole; -import org.apache.freemarker.core.ast.ParseException; -import org.apache.freemarker.core.ast.TemplateElement; -import org.apache.freemarker.core.ast.TemplateObject; import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.util.ClassUtil; -import org.apache.freemarker.core.util.StringUtil; +import org.apache.freemarker.core.util._ClassUtil; +import org.apache.freemarker.core.util._StringUtil; /** * Static methods and command-line tool for printing the AST of a template. @@ -115,7 +109,7 @@ public class ASTPrinter { try { fnPattern = Pattern.compile(args[2]); } catch (PatternSyntaxException e) { - p(StringUtil.jQuote(args[2]) + " is not a valid regular expression"); + p(_StringUtil.jQuote(args[2]) + " is not a valid regular expression"); System.exit(-1); return; } @@ -337,7 +331,7 @@ public class ASTPrinter { out.write(INDENTATION); out.write(ind); out.write("= const "); - out.write(ClassUtil.getFTLTypeDescription(tm)); + out.write(_ClassUtil.getFTLTypeDescription(tm)); out.write(' '); out.write(tm.toString()); out.write('\n'); @@ -359,7 +353,7 @@ public class ASTPrinter { } } else { printNodeLineStart(paramRole, ind, out); - out.write(StringUtil.jQuote(node)); + out.write(_StringUtil.jQuote(node)); printNodeLineEnd(node, out, opts); } } @@ -369,7 +363,7 @@ public class ASTPrinter { if (opts.getShowJavaClass()) { out.write(" // "); commentStared = true; - out.write(ClassUtil.getShortClassNameOfObject(node, true)); + out.write(_ClassUtil.getShortClassNameOfObject(node, true)); } if (opts.getShowLocation() && node instanceof TemplateObject) { if (!commentStared) { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/test/java/org/apache/freemarker/core/ast/ASTTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/ast/ASTTest.java b/src/test/java/org/apache/freemarker/core/ast/ASTTest.java index e5c31a8..21e54e2 100644 --- a/src/test/java/org/apache/freemarker/core/ast/ASTTest.java +++ b/src/test/java/org/apache/freemarker/core/ast/ASTTest.java @@ -23,7 +23,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import org.apache.freemarker.core.ast.ASTPrinter.Options; -import org.apache.freemarker.core.util.StringUtil; +import org.apache.freemarker.core.util._StringUtil; import org.apache.freemarker.test.util.FileTestCase; import org.apache.freemarker.test.util.TestUtil; @@ -92,7 +92,7 @@ public class ASTTest extends FileTestCase { } private String normalizeLineBreaks(final String s) throws FileNotFoundException, IOException { - return StringUtil.replace(s, "\r\n", "\n").replace('\r', '\n'); + return _StringUtil.replace(s, "\r\n", "\n").replace('\r', '\n'); } } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/test/java/org/apache/freemarker/core/ast/BaseNTemplateNumberFormatFactory.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/ast/BaseNTemplateNumberFormatFactory.java b/src/test/java/org/apache/freemarker/core/ast/BaseNTemplateNumberFormatFactory.java index 0ce32e3..d095621 100644 --- a/src/test/java/org/apache/freemarker/core/ast/BaseNTemplateNumberFormatFactory.java +++ b/src/test/java/org/apache/freemarker/core/ast/BaseNTemplateNumberFormatFactory.java @@ -29,8 +29,8 @@ import org.apache.freemarker.core.ast.TemplateValueFormatException; import org.apache.freemarker.core.ast.UnformattableValueException; import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateNumberModel; -import org.apache.freemarker.core.util.NumberUtil; -import org.apache.freemarker.core.util.StringUtil; +import org.apache.freemarker.core.util._NumberUtil; +import org.apache.freemarker.core.util._StringUtil; /** * Shows a number in base N number system. Can only format numbers that fit into an {@code int}, @@ -60,7 +60,7 @@ public class BaseNTemplateNumberFormatFactory extends TemplateNumberFormatFactor } catch (TemplateValueFormatException e) { throw new InvalidFormatParametersException( "Couldn't get the fallback number format (specified after the \"|\"), " - + StringUtil.jQuote(fallbackFormatStr) + ". Reason: " + e.getMessage(), + + _StringUtil.jQuote(fallbackFormatStr) + ". Reason: " + e.getMessage(), e); } } else { @@ -78,7 +78,7 @@ public class BaseNTemplateNumberFormatFactory extends TemplateNumberFormatFactor } throw new InvalidFormatParametersException( "The format paramter must be an integer, but was (shown quoted): " - + StringUtil.jQuote(params)); + + _StringUtil.jQuote(params)); } if (base < 2) { throw new InvalidFormatParametersException("A base must be at least 2."); @@ -101,7 +101,7 @@ public class BaseNTemplateNumberFormatFactory extends TemplateNumberFormatFactor throws TemplateModelException, TemplateValueFormatException { Number n = TemplateFormatUtil.getNonNullNumber(numberModel); try { - return Integer.toString(NumberUtil.toIntExact(n), base); + return Integer.toString(_NumberUtil.toIntExact(n), base); } catch (ArithmeticException e) { if (fallbackFormat == null) { throw new UnformattableValueException( http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/test/java/org/apache/freemarker/core/ast/CamelCaseTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/ast/CamelCaseTest.java b/src/test/java/org/apache/freemarker/core/ast/CamelCaseTest.java index 4e47f29..58c4b6d 100644 --- a/src/test/java/org/apache/freemarker/core/ast/CamelCaseTest.java +++ b/src/test/java/org/apache/freemarker/core/ast/CamelCaseTest.java @@ -33,7 +33,7 @@ import org.apache.freemarker.core.ast.BuiltIn; import org.apache.freemarker.core.ast.BuiltinVariable; import org.apache.freemarker.core.ast.HTMLOutputFormat; import org.apache.freemarker.core.ast.UndefinedOutputFormat; -import org.apache.freemarker.core.ast._CoreStringUtils; +import org.apache.freemarker.core.util._StringUtil; import org.apache.freemarker.test.TemplateTest; import org.junit.Test; @@ -273,8 +273,8 @@ public class CamelCaseTest extends TemplateTest { private void assertContainsBothNamingStyles(Set<String> names, NamePairAssertion namePairAssertion) { Set<String> underscoredNamesWithCamelCasePair = new HashSet<String>(); for (String name : names) { - if (_CoreStringUtils.getIdentifierNamingConvention(name) == Configuration.CAMEL_CASE_NAMING_CONVENTION) { - String underscoredName = correctIsoBIExceptions(_CoreStringUtils.camelCaseToUnderscored(name)); + if (_StringUtil.getIdentifierNamingConvention(name) == Configuration.CAMEL_CASE_NAMING_CONVENTION) { + String underscoredName = correctIsoBIExceptions(_StringUtil.camelCaseToUnderscored(name)); assertTrue( "Missing underscored variation \"" + underscoredName + "\" for \"" + name + "\".", names.contains(underscoredName)); @@ -284,7 +284,7 @@ public class CamelCaseTest extends TemplateTest { } } for (String name : names) { - if (_CoreStringUtils.getIdentifierNamingConvention(name) == Configuration.LEGACY_NAMING_CONVENTION) { + if (_StringUtil.getIdentifierNamingConvention(name) == Configuration.LEGACY_NAMING_CONVENTION) { assertTrue("Missing camel case variation for \"" + name + "\".", underscoredNamesWithCamelCasePair.contains(name)); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/test/java/org/apache/freemarker/core/ast/ConfigurableTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/ast/ConfigurableTest.java b/src/test/java/org/apache/freemarker/core/ast/ConfigurableTest.java index 7ffa066..d484c1f 100644 --- a/src/test/java/org/apache/freemarker/core/ast/ConfigurableTest.java +++ b/src/test/java/org/apache/freemarker/core/ast/ConfigurableTest.java @@ -33,7 +33,7 @@ import java.util.Set; import org.apache.freemarker.core.Configuration; import org.apache.freemarker.core.Template; import org.apache.freemarker.core.ast.Configurable; -import org.apache.freemarker.core.ast._CoreStringUtils; +import org.apache.freemarker.core.util._StringUtil; import org.junit.Test; public class ConfigurableTest { @@ -100,7 +100,7 @@ public class ConfigurableTest { if (fieldName.endsWith("_KEY")) { String keyFieldValue = (String) field.get(null); assertNotEquals(Configuration.CAMEL_CASE_NAMING_CONVENTION, - _CoreStringUtils.getIdentifierNamingConvention(keyFieldValue)); + _StringUtil.getIdentifierNamingConvention(keyFieldValue)); assertEquals(fieldName.substring(0, fieldName.length() - 4).toLowerCase(), keyFieldValue); try { @@ -113,8 +113,8 @@ public class ConfigurableTest { try { String keyCCFieldValue = (String) confClass.getField(fieldName + "_CAMEL_CASE").get(null); assertNotEquals(Configuration.LEGACY_NAMING_CONVENTION, - _CoreStringUtils.getIdentifierNamingConvention(keyCCFieldValue)); - assertEquals(keyFieldValue, _CoreStringUtils.camelCaseToUnderscored(keyCCFieldValue)); + _StringUtil.getIdentifierNamingConvention(keyCCFieldValue)); + assertEquals(keyFieldValue, _StringUtil.camelCaseToUnderscored(keyCCFieldValue)); } catch (NoSuchFieldException e) { fail("Missing ..._CAMEL_CASE field for " + fieldName); } @@ -156,7 +156,7 @@ public class ConfigurableTest { assertEquals(namesSC.size(), namesCC.size()); for (String nameCC : namesCC) { - final String nameSC = _CoreStringUtils.camelCaseToUnderscored(nameCC); + final String nameSC = _StringUtil.camelCaseToUnderscored(nameCC); if (!namesSC.contains(nameSC)) { fail("\"" + nameCC + "\" misses corresponding snake case name, \"" + nameSC + "\"."); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/test/java/org/apache/freemarker/core/ast/CoreLocaleUtilsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/ast/CoreLocaleUtilsTest.java b/src/test/java/org/apache/freemarker/core/ast/CoreLocaleUtilsTest.java index cd00553..0235a93 100644 --- a/src/test/java/org/apache/freemarker/core/ast/CoreLocaleUtilsTest.java +++ b/src/test/java/org/apache/freemarker/core/ast/CoreLocaleUtilsTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.*; import java.util.Locale; -import org.apache.freemarker.core.ast._CoreLocaleUtils; +import org.apache.freemarker.core.util._LocaleUtil; import org.junit.Test; public class CoreLocaleUtilsTest { @@ -33,40 +33,40 @@ public class CoreLocaleUtilsTest { locale = new Locale("ru", "RU", "Linux"); assertEquals("ru_RU_Linux", locale.toString()); - locale = _CoreLocaleUtils.getLessSpecificLocale(locale); + locale = _LocaleUtil.getLessSpecificLocale(locale); assertEquals("ru_RU", locale.toString()); - locale = _CoreLocaleUtils.getLessSpecificLocale(locale); + locale = _LocaleUtil.getLessSpecificLocale(locale); assertEquals("ru", locale.toString()); - locale = _CoreLocaleUtils.getLessSpecificLocale(locale); + locale = _LocaleUtil.getLessSpecificLocale(locale); assertNull(locale); locale = new Locale("ch", "CH"); assertEquals("ch_CH", locale.toString()); - locale = _CoreLocaleUtils.getLessSpecificLocale(locale); + locale = _LocaleUtil.getLessSpecificLocale(locale); assertEquals("ch", locale.toString()); - locale = _CoreLocaleUtils.getLessSpecificLocale(locale); + locale = _LocaleUtil.getLessSpecificLocale(locale); assertNull(locale); locale = new Locale("ja"); assertEquals("ja", locale.toString()); - locale = _CoreLocaleUtils.getLessSpecificLocale(locale); + locale = _LocaleUtil.getLessSpecificLocale(locale); assertNull(locale); locale = new Locale("ja", "", ""); assertEquals("ja", locale.toString()); - locale = _CoreLocaleUtils.getLessSpecificLocale(locale); + locale = _LocaleUtil.getLessSpecificLocale(locale); assertNull(locale); locale = new Locale(""); assertEquals("", locale.toString()); - locale = _CoreLocaleUtils.getLessSpecificLocale(locale); + locale = _LocaleUtil.getLessSpecificLocale(locale); assertNull(locale); locale = new Locale("hu", "", "Linux"); assertEquals("hu__Linux", locale.toString()); - locale = _CoreLocaleUtils.getLessSpecificLocale(locale); + locale = _LocaleUtil.getLessSpecificLocale(locale); assertEquals("hu", locale.toString()); - locale = _CoreLocaleUtils.getLessSpecificLocale(locale); + locale = _LocaleUtil.getLessSpecificLocale(locale); assertNull(locale); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/test/java/org/apache/freemarker/core/ast/CustomHTMLOutputFormat.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/ast/CustomHTMLOutputFormat.java b/src/test/java/org/apache/freemarker/core/ast/CustomHTMLOutputFormat.java index 30f2ffb..1d0265b 100644 --- a/src/test/java/org/apache/freemarker/core/ast/CustomHTMLOutputFormat.java +++ b/src/test/java/org/apache/freemarker/core/ast/CustomHTMLOutputFormat.java @@ -23,7 +23,7 @@ import java.io.Writer; import org.apache.freemarker.core.ast.CommonMarkupOutputFormat; import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.util.StringUtil; +import org.apache.freemarker.core.util._StringUtil; /** * Represents the HTML output format. @@ -56,7 +56,7 @@ public final class CustomHTMLOutputFormat extends CommonMarkupOutputFormat<Custo @Override public String escapePlainText(String plainTextContent) { - return StringUtil.XHTMLEnc(plainTextContent.replace('x', 'X')); + return _StringUtil.XHTMLEnc(plainTextContent.replace('x', 'X')); } @Override http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/test/java/org/apache/freemarker/core/ast/EpochMillisDivTemplateDateFormatFactory.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/ast/EpochMillisDivTemplateDateFormatFactory.java b/src/test/java/org/apache/freemarker/core/ast/EpochMillisDivTemplateDateFormatFactory.java index a88c28b..5a107f1 100644 --- a/src/test/java/org/apache/freemarker/core/ast/EpochMillisDivTemplateDateFormatFactory.java +++ b/src/test/java/org/apache/freemarker/core/ast/EpochMillisDivTemplateDateFormatFactory.java @@ -32,7 +32,7 @@ import org.apache.freemarker.core.ast.UnknownDateTypeFormattingUnsupportedExcept import org.apache.freemarker.core.ast.UnparsableValueException; import org.apache.freemarker.core.model.TemplateDateModel; import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.util.StringUtil; +import org.apache.freemarker.core.util._StringUtil; public class EpochMillisDivTemplateDateFormatFactory extends TemplateDateFormatFactory { @@ -54,7 +54,7 @@ public class EpochMillisDivTemplateDateFormatFactory extends TemplateDateFormatF "A format parameter is required, which specifies the divisor."); } throw new InvalidFormatParametersException( - "The format paramter must be an integer, but was (shown quoted): " + StringUtil.jQuote(params)); + "The format paramter must be an integer, but was (shown quoted): " + _StringUtil.jQuote(params)); } return new EpochMillisDivTemplateDateFormat(divisor); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/test/java/org/apache/freemarker/core/ast/HTMLISOTemplateDateFormatFactory.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/ast/HTMLISOTemplateDateFormatFactory.java b/src/test/java/org/apache/freemarker/core/ast/HTMLISOTemplateDateFormatFactory.java index 5c62f5e..c273cbc 100644 --- a/src/test/java/org/apache/freemarker/core/ast/HTMLISOTemplateDateFormatFactory.java +++ b/src/test/java/org/apache/freemarker/core/ast/HTMLISOTemplateDateFormatFactory.java @@ -22,21 +22,11 @@ import java.util.Date; import java.util.Locale; import java.util.TimeZone; -import org.apache.freemarker.core.ast.Environment; -import org.apache.freemarker.core.ast.HTMLOutputFormat; -import org.apache.freemarker.core.ast.InvalidFormatParametersException; -import org.apache.freemarker.core.ast.TemplateDateFormat; -import org.apache.freemarker.core.ast.TemplateDateFormatFactory; -import org.apache.freemarker.core.ast.TemplateFormatUtil; -import org.apache.freemarker.core.ast.TemplateValueFormatException; -import org.apache.freemarker.core.ast.UnformattableValueException; -import org.apache.freemarker.core.ast.UnknownDateTypeFormattingUnsupportedException; -import org.apache.freemarker.core.ast.UnparsableValueException; import org.apache.freemarker.core.model.TemplateDateModel; import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.util.DateUtil; -import org.apache.freemarker.core.util.DateUtil.CalendarFieldsToDateConverter; -import org.apache.freemarker.core.util.DateUtil.DateParseException; +import org.apache.freemarker.core.util._DateUtil; +import org.apache.freemarker.core.util._DateUtil.CalendarFieldsToDateConverter; +import org.apache.freemarker.core.util._DateUtil.DateParseException; public class HTMLISOTemplateDateFormatFactory extends TemplateDateFormatFactory { @@ -57,7 +47,7 @@ public class HTMLISOTemplateDateFormatFactory extends TemplateDateFormatFactory private static final HTMLISOTemplateDateFormat INSTANCE = new HTMLISOTemplateDateFormat(); - private DateUtil.TrivialDateToISO8601CalendarFactory calendarFactory; + private _DateUtil.TrivialDateToISO8601CalendarFactory calendarFactory; private CalendarFieldsToDateConverter calToDateConverter; @@ -67,11 +57,11 @@ public class HTMLISOTemplateDateFormatFactory extends TemplateDateFormatFactory public String formatToPlainText(TemplateDateModel dateModel) throws UnformattableValueException, TemplateModelException { if (calendarFactory == null) { - calendarFactory = new DateUtil.TrivialDateToISO8601CalendarFactory(); + calendarFactory = new _DateUtil.TrivialDateToISO8601CalendarFactory(); } - return DateUtil.dateToISO8601String( + return _DateUtil.dateToISO8601String( TemplateFormatUtil.getNonNullDate(dateModel), - true, true, true, DateUtil.ACCURACY_SECONDS, DateUtil.UTC, + true, true, true, _DateUtil.ACCURACY_SECONDS, _DateUtil.UTC, calendarFactory); } @@ -89,9 +79,9 @@ public class HTMLISOTemplateDateFormatFactory extends TemplateDateFormatFactory public Date parse(String s, int dateType) throws UnparsableValueException { try { if (calToDateConverter == null) { - calToDateConverter = new DateUtil.TrivialCalendarFieldsToDateConverter(); + calToDateConverter = new _DateUtil.TrivialCalendarFieldsToDateConverter(); } - return DateUtil.parseISO8601DateTime(s, DateUtil.UTC, calToDateConverter); + return _DateUtil.parseISO8601DateTime(s, _DateUtil.UTC, calToDateConverter); } catch (DateParseException e) { throw new UnparsableValueException("Malformed ISO date-time", e); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/test/java/org/apache/freemarker/core/ast/HexTemplateNumberFormatFactory.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/ast/HexTemplateNumberFormatFactory.java b/src/test/java/org/apache/freemarker/core/ast/HexTemplateNumberFormatFactory.java index 0d78cf0..9ae2fe0 100644 --- a/src/test/java/org/apache/freemarker/core/ast/HexTemplateNumberFormatFactory.java +++ b/src/test/java/org/apache/freemarker/core/ast/HexTemplateNumberFormatFactory.java @@ -28,7 +28,7 @@ import org.apache.freemarker.core.ast.TemplateNumberFormatFactory; import org.apache.freemarker.core.ast.UnformattableValueException; import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateNumberModel; -import org.apache.freemarker.core.util.NumberUtil; +import org.apache.freemarker.core.util._NumberUtil; public class HexTemplateNumberFormatFactory extends TemplateNumberFormatFactory { @@ -56,7 +56,7 @@ public class HexTemplateNumberFormatFactory extends TemplateNumberFormatFactory throws UnformattableValueException, TemplateModelException { Number n = TemplateFormatUtil.getNonNullNumber(numberModel); try { - return Integer.toHexString(NumberUtil.toIntExact(n)); + return Integer.toHexString(_NumberUtil.toIntExact(n)); } catch (ArithmeticException e) { throw new UnformattableValueException(n + " doesn't fit into an int"); }
