http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/ast/_DelayedShortClassName.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/_DelayedShortClassName.java b/src/main/java/org/apache/freemarker/core/ast/_DelayedShortClassName.java index 24f2881..54916aa 100644 --- a/src/main/java/org/apache/freemarker/core/ast/_DelayedShortClassName.java +++ b/src/main/java/org/apache/freemarker/core/ast/_DelayedShortClassName.java @@ -19,7 +19,7 @@ package org.apache.freemarker.core.ast; -import org.apache.freemarker.core.util.ClassUtil; +import org.apache.freemarker.core.util._ClassUtil; public class _DelayedShortClassName extends _DelayedConversionToString { @@ -29,7 +29,7 @@ public class _DelayedShortClassName extends _DelayedConversionToString { @Override protected String doConversion(Object obj) { - return ClassUtil.getShortClassName((Class) obj, true); + return _ClassUtil.getShortClassName((Class) obj, true); } }
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/ast/_ErrorDescriptionBuilder.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/_ErrorDescriptionBuilder.java b/src/main/java/org/apache/freemarker/core/ast/_ErrorDescriptionBuilder.java index 9604869..eb022b5 100644 --- a/src/main/java/org/apache/freemarker/core/ast/_ErrorDescriptionBuilder.java +++ b/src/main/java/org/apache/freemarker/core/ast/_ErrorDescriptionBuilder.java @@ -27,8 +27,8 @@ import org.apache.freemarker.core.Configuration; import org.apache.freemarker.core.Template; import org.apache.freemarker.core._CoreLogs; import org.apache.freemarker.core.model.impl.beans._MethodUtil; -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; import org.slf4j.Logger; /** @@ -262,19 +262,19 @@ public class _ErrorDescriptionBuilder { if (partObj == null) { return null; } else if (partObj instanceof Class) { - partStr = ClassUtil.getShortClassName((Class) partObj); + partStr = _ClassUtil.getShortClassName((Class) partObj); } else if (partObj instanceof Method || partObj instanceof Constructor) { partStr = _MethodUtil.toString((Member) partObj); } else { - partStr = suppressToStringException ? StringUtil.tryToString(partObj) : partObj.toString(); + partStr = suppressToStringException ? _StringUtil.tryToString(partObj) : partObj.toString(); } return partStr; } private String[] splitToLines(String s) { - s = StringUtil.replace(s, "\r\n", "\n"); - s = StringUtil.replace(s, "\r", "\n"); - String[] lines = StringUtil.split(s, '\n'); + s = _StringUtil.replace(s, "\r\n", "\n"); + s = _StringUtil.replace(s, "\r", "\n"); + String[] lines = _StringUtil.split(s, '\n'); return lines; } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/ast/_Java8.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/_Java8.java b/src/main/java/org/apache/freemarker/core/ast/_Java8.java deleted file mode 100644 index 81d0daf..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/_Java8.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.ast; - -/** - * Used internally only, might changes without notice! - * Used for accessing functionality that's only present in Java 6 or later. - */ -public interface _Java8 { - - /** - * This is just a placeholder. Remove this when we have some real functionality here. - */ - void doSomething(); - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/ast/_Java8Impl.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/_Java8Impl.java b/src/main/java/org/apache/freemarker/core/ast/_Java8Impl.java deleted file mode 100644 index eccb0f6..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/_Java8Impl.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.ast; - -/** - * Used internally only, might changes without notice! - * Used for accessing functionality that's only present in Java 6 or later. - */ -// Compile this against Java 8 -public final class _Java8Impl implements _Java8 { - - public static final _Java8 INSTANCE = new _Java8Impl(); - - private _Java8Impl() { - // Not meant to be instantiated - } - - @Override - public void doSomething() { - // Do something that requires Java 8 here - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/ast/_JavaVersions.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/_JavaVersions.java b/src/main/java/org/apache/freemarker/core/ast/_JavaVersions.java deleted file mode 100644 index c24c400..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/_JavaVersions.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.ast; - -import org.apache.freemarker.core.Version; -import org.apache.freemarker.core._CoreLogs; -import org.apache.freemarker.core.util.SecurityUtilities; - -/** - * Used internally only, might changes without notice! - */ -public final class _JavaVersions { - - private _JavaVersions() { - // Not meant to be instantiated - } - - private static final boolean IS_AT_LEAST_8; - static { - boolean result = false; - String vStr = SecurityUtilities.getSystemProperty("java.version", null); - if (vStr != null) { - try { - Version v = new Version(vStr); - result = v.getMajor() == 1 && v.getMinor() >= 8 || v.getMajor() > 1; - } catch (Exception e) { - // Ignore - } - } else { - try { - Class.forName("java.time.Instant"); - result = true; - } catch (Exception e) { - // Ignore - } - } - IS_AT_LEAST_8 = result; - } - - /** - * {@code null} if Java 8 is not available, otherwise the object through with the Java 8 operations are available. - */ - static public final _Java8 JAVA_8; - static { - _Java8 java8; - if (IS_AT_LEAST_8) { - try { - java8 = (_Java8) Class.forName("org.apache.freemarker.core.ast._Java8Impl") - .getField("INSTANCE").get(null); - } catch (Exception e) { - try { - _CoreLogs.RUNTIME.error("Failed to access Java 6 functionality", e); - } catch (Exception e2) { - // Suppressed - } - java8 = null; - } - } else { - java8 = null; - } - JAVA_8 = java8; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/ast/_ObjectBuilderSettingEvaluationException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/_ObjectBuilderSettingEvaluationException.java b/src/main/java/org/apache/freemarker/core/ast/_ObjectBuilderSettingEvaluationException.java index 385fe84..b3dc277 100644 --- a/src/main/java/org/apache/freemarker/core/ast/_ObjectBuilderSettingEvaluationException.java +++ b/src/main/java/org/apache/freemarker/core/ast/_ObjectBuilderSettingEvaluationException.java @@ -19,7 +19,7 @@ package org.apache.freemarker.core.ast; -import org.apache.freemarker.core.util.StringUtil; +import org.apache.freemarker.core.util._StringUtil; /** * Don't use this; used internally by FreeMarker, might changes without notice. @@ -38,7 +38,7 @@ public class _ObjectBuilderSettingEvaluationException extends Exception { public _ObjectBuilderSettingEvaluationException(String expected, String src, int location) { super("Expression syntax error: Expected a(n) " + expected + ", but " + (location < src.length() - ? "found character " + StringUtil.jQuote("" + src.charAt(location)) + " at position " + ? "found character " + _StringUtil.jQuote("" + src.charAt(location)) + " at position " + (location + 1) + "." : "the end of the parsed string was reached.") ); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/ast/_ObjectBuilderSettingEvaluator.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/_ObjectBuilderSettingEvaluator.java b/src/main/java/org/apache/freemarker/core/ast/_ObjectBuilderSettingEvaluator.java index 96d061e..984babe 100644 --- a/src/main/java/org/apache/freemarker/core/ast/_ObjectBuilderSettingEvaluator.java +++ b/src/main/java/org/apache/freemarker/core/ast/_ObjectBuilderSettingEvaluator.java @@ -54,9 +54,9 @@ import org.apache.freemarker.core.templateresolver.NotMatcher; import org.apache.freemarker.core.templateresolver.OrMatcher; import org.apache.freemarker.core.templateresolver.PathGlobMatcher; import org.apache.freemarker.core.templateresolver.PathRegexMatcher; -import org.apache.freemarker.core.util.ClassUtil; -import org.apache.freemarker.core.util.StringUtil; import org.apache.freemarker.core.util.WriteProtectable; +import org.apache.freemarker.core.util._ClassUtil; +import org.apache.freemarker.core.util._StringUtil; /** * Don't use this; used internally by FreeMarker, might changes without notice. @@ -539,7 +539,7 @@ public class _ObjectBuilderSettingEvaluator { final String sInside = src.substring(startPos + (raw ? 2 : 1), pos); try { pos++; // skip closing quotation mark - return raw ? sInside : StringUtil.FTLStringLiteralDec(sInside); + return raw ? sInside : _StringUtil.FTLStringLiteralDec(sInside); } catch (ParseException e) { throw new _ObjectBuilderSettingEvaluationException("Malformed string literal: " + sInside, e); } @@ -640,7 +640,7 @@ public class _ObjectBuilderSettingEvaluator { if (i != 0) { sb.append(" or "); } - sb.append(StringUtil.jQuote(expectedChars.substring(i, i + 1))); + sb.append(_StringUtil.jQuote(expectedChars.substring(i, i + 1))); } throw new _ObjectBuilderSettingEvaluationException( sb.toString(), @@ -689,7 +689,8 @@ public class _ObjectBuilderSettingEvaluator { addWithSimpleName(SHORTHANDS, UndefinedOutputFormat.class); addWithSimpleName(SHORTHANDS, Locale.class); - SHORTHANDS.put("TimeZone", "org.apache.freemarker.core.ast._TimeZone"); + String tzbClassName = _TimeZoneBuilder.class.getName(); + SHORTHANDS.put("TimeZone", tzbClassName.substring(0, tzbClassName.length() - 7)); // For accessing static fields: addWithSimpleName(SHORTHANDS, Configuration.class); @@ -731,13 +732,13 @@ public class _ObjectBuilderSettingEvaluator { if (!beanPropSetters.containsKey(name)) { throw new _ObjectBuilderSettingEvaluationException( "The " + cl.getName() + " class has no writeable JavaBeans property called " - + StringUtil.jQuote(name) + "."); + + _StringUtil.jQuote(name) + "."); } Method beanPropSetter = (Method) beanPropSetters.put(name, null); if (beanPropSetter == null) { throw new _ObjectBuilderSettingEvaluationException( - "JavaBeans property " + StringUtil.jQuote(name) + " is set twice."); + "JavaBeans property " + _StringUtil.jQuote(name) + " is set twice."); } try { @@ -757,14 +758,14 @@ public class _ObjectBuilderSettingEvaluator { } if (!(m instanceof TemplateMethodModelEx)) { throw new _ObjectBuilderSettingEvaluationException( - StringUtil.jQuote(beanPropSetter.getName()) + " wasn't a TemplateMethodModelEx."); + _StringUtil.jQuote(beanPropSetter.getName()) + " wasn't a TemplateMethodModelEx."); } List/*TemplateModel*/ args = new ArrayList(); args.add(env.getObjectWrapper().wrap(namedParamValues.get(i))); ((TemplateMethodModelEx) m).exec(args); } catch (Exception e) { throw new _ObjectBuilderSettingEvaluationException( - "Failed to set " + StringUtil.jQuote(name), e); + "Failed to set " + _StringUtil.jQuote(name), e); } } } @@ -869,7 +870,7 @@ public class _ObjectBuilderSettingEvaluator { if (!modernMode) { try { try { - return ClassUtil.forName(className).newInstance(); + return _ClassUtil.forName(className).newInstance(); } catch (InstantiationException e) { throw new LegacyExceptionWrapperSettingEvaluationExpression(e); } catch (IllegalAccessException e) { @@ -892,12 +893,12 @@ public class _ObjectBuilderSettingEvaluator { boolean clIsBuilderClass; try { - cl = ClassUtil.forName(className + BUILDER_CLASS_POSTFIX); + cl = _ClassUtil.forName(className + BUILDER_CLASS_POSTFIX); clIsBuilderClass = true; } catch (ClassNotFoundException e) { clIsBuilderClass = false; try { - cl = ClassUtil.forName(className); + cl = _ClassUtil.forName(className); } catch (Exception e2) { boolean failedToGetAsStaticField; if (canBeStaticField) { @@ -912,7 +913,7 @@ public class _ObjectBuilderSettingEvaluator { failedToGetAsStaticField = false; } throw new _ObjectBuilderSettingEvaluationException( - "Failed to get class " + StringUtil.jQuote(className) + "Failed to get class " + _StringUtil.jQuote(className) + (failedToGetAsStaticField ? " (also failed to resolve name as static field)" : "") + ".", e2); @@ -930,7 +931,7 @@ public class _ObjectBuilderSettingEvaluator { // Expected } catch (Exception e) { throw new _ObjectBuilderSettingEvaluationException( - "Error when trying to access " + StringUtil.jQuote(className) + "." + "Error when trying to access " + _StringUtil.jQuote(className) + "." + INSTANCE_FIELD_NAME, e); } } @@ -964,10 +965,10 @@ public class _ObjectBuilderSettingEvaluator { Class<?> cl; try { - cl = ClassUtil.forName(className); + cl = _ClassUtil.forName(className); } catch (Exception e) { throw new _ObjectBuilderSettingEvaluationException( - "Failed to get field's parent class, " + StringUtil.jQuote(className) + ".", + "Failed to get field's parent class, " + _StringUtil.jQuote(className) + ".", e); } @@ -976,8 +977,8 @@ public class _ObjectBuilderSettingEvaluator { field = cl.getField(fieldName); } catch (Exception e) { throw new _ObjectBuilderSettingEvaluationException( - "Failed to get field " + StringUtil.jQuote(fieldName) + " from class " - + StringUtil.jQuote(className) + ".", + "Failed to get field " + _StringUtil.jQuote(fieldName) + " from class " + + _StringUtil.jQuote(className) + ".", e); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/ast/_SortedArraySet.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/_SortedArraySet.java b/src/main/java/org/apache/freemarker/core/ast/_SortedArraySet.java deleted file mode 100644 index 5fd17b9..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/_SortedArraySet.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.ast; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; - -/** Don't use this; used internally by FreeMarker, might changes without notice. */ -public class _SortedArraySet<E> extends _UnmodifiableSet<E> { - - private final E[] array; - - public _SortedArraySet(E[] array) { - this.array = array; - } - - @Override - public int size() { - return array.length; - } - - @Override - public boolean contains(Object o) { - return Arrays.binarySearch(array, o) >= 0; - } - - @Override - public Iterator<E> iterator() { - return new _ArrayIterator(array); - } - - @Override - public boolean add(E o) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean addAll(Collection<? extends E> c) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean removeAll(Collection<?> c) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean retainAll(Collection<?> c) { - throw new UnsupportedOperationException(); - } - - @Override - public void clear() { - throw new UnsupportedOperationException(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/ast/_TemplateModelException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/_TemplateModelException.java b/src/main/java/org/apache/freemarker/core/ast/_TemplateModelException.java index b616342..cfe7307 100644 --- a/src/main/java/org/apache/freemarker/core/ast/_TemplateModelException.java +++ b/src/main/java/org/apache/freemarker/core/ast/_TemplateModelException.java @@ -21,7 +21,7 @@ package org.apache.freemarker.core.ast; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.util.ClassUtil; +import org.apache.freemarker.core.util._ClassUtil; public class _TemplateModelException extends TemplateModelException { @@ -126,7 +126,7 @@ public class _TemplateModelException extends TemplateModelException { return new Object[] { "The FreeMarker value exists, but has nothing inside it; the TemplateModel object (class: ", model.getClass().getName(), ") has returned a null", - (expected != null ? new Object[] { " instead of a ", ClassUtil.getShortClassName(expected) } : ""), + (expected != null ? new Object[] { " instead of a ", _ClassUtil.getShortClassName(expected) } : ""), ". This is possibly a bug in the non-FreeMarker code that builds the data-model." }; } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/ast/_UnmodifiableCompositeSet.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/_UnmodifiableCompositeSet.java b/src/main/java/org/apache/freemarker/core/ast/_UnmodifiableCompositeSet.java deleted file mode 100644 index 2a0e259..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/_UnmodifiableCompositeSet.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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.ast; - -import java.util.Iterator; -import java.util.Set; - -/** 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/ast/_UnmodifiableSet.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ast/_UnmodifiableSet.java b/src/main/java/org/apache/freemarker/core/ast/_UnmodifiableSet.java deleted file mode 100644 index d726f73..0000000 --- a/src/main/java/org/apache/freemarker/core/ast/_UnmodifiableSet.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.ast; - -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/core/debug/impl/DebuggerServer.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/debug/impl/DebuggerServer.java b/src/main/java/org/apache/freemarker/core/debug/impl/DebuggerServer.java index a7cfc2c..42db661 100644 --- a/src/main/java/org/apache/freemarker/core/debug/impl/DebuggerServer.java +++ b/src/main/java/org/apache/freemarker/core/debug/impl/DebuggerServer.java @@ -33,7 +33,7 @@ import java.util.Random; import org.apache.freemarker.core._CoreLogs; import org.apache.freemarker.core.debug.Debugger; -import org.apache.freemarker.core.util.SecurityUtilities; +import org.apache.freemarker.core.util._SecurityUtil; import org.apache.freemarker.core.util.UndeclaredThrowableException; import org.slf4j.Logger; @@ -54,9 +54,9 @@ class DebuggerServer { private ServerSocket serverSocket; public DebuggerServer(Serializable debuggerStub) { - port = SecurityUtilities.getSystemProperty("org.apache.freemarker.core.debug.port", Debugger.DEFAULT_PORT).intValue(); + port = _SecurityUtil.getSystemProperty("org.apache.freemarker.core.debug.port", Debugger.DEFAULT_PORT).intValue(); try { - password = SecurityUtilities.getSystemProperty("org.apache.freemarker.core.debug.password", "").getBytes("UTF-8"); + password = _SecurityUtil.getSystemProperty("org.apache.freemarker.core.debug.password", "").getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { throw new UndeclaredThrowableException(e); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/debug/impl/DebuggerService.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/debug/impl/DebuggerService.java b/src/main/java/org/apache/freemarker/core/debug/impl/DebuggerService.java index fa4078e..1115090 100644 --- a/src/main/java/org/apache/freemarker/core/debug/impl/DebuggerService.java +++ b/src/main/java/org/apache/freemarker/core/debug/impl/DebuggerService.java @@ -25,7 +25,7 @@ import java.util.List; import org.apache.freemarker.core.Template; import org.apache.freemarker.core.ast.Environment; -import org.apache.freemarker.core.util.SecurityUtilities; +import org.apache.freemarker.core.util._SecurityUtil; /** * This class provides debugging hooks for the core FreeMarker engine. It is @@ -40,7 +40,7 @@ public abstract class DebuggerService { // off, this is a fast no-op service, otherwise it's the real-thing // RMI service. return - SecurityUtilities.getSystemProperty("org.apache.freemarker.core.debug.password", null) == null + _SecurityUtil.getSystemProperty("org.apache.freemarker.core.debug.password", null) == null ? (DebuggerService) new NoOpDebuggerService() : (DebuggerService) new RmiDebuggerService(); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/Constants.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/Constants.java b/src/main/java/org/apache/freemarker/core/model/Constants.java new file mode 100644 index 0000000..76f2f45 --- /dev/null +++ b/src/main/java/org/apache/freemarker/core/model/Constants.java @@ -0,0 +1,122 @@ +/* + * 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.model; + +import java.io.Serializable; + +import org.apache.freemarker.core.model.TemplateBooleanModel; +import org.apache.freemarker.core.model.TemplateCollectionModel; +import org.apache.freemarker.core.model.TemplateHashModelEx; +import org.apache.freemarker.core.model.TemplateModel; +import org.apache.freemarker.core.model.TemplateModelException; +import org.apache.freemarker.core.model.TemplateModelIterator; +import org.apache.freemarker.core.model.TemplateNumberModel; +import org.apache.freemarker.core.model.TemplateScalarModel; +import org.apache.freemarker.core.model.TemplateSequenceModel; +import org.apache.freemarker.core.model.impl.SimpleNumber; + +/** + * Frequently used constant {@link TemplateModel} values. + * + * <p>These constants should be stored in the {@link TemplateModel} + * sub-interfaces, but for bacward compatibility they are stored here instead. + * Starting from FreeMarker 2.4 they should be copyed (not moved!) into the + * {@link TemplateModel} sub-interfaces, and this class should be marked as + * deprecated.</p> + */ +public class Constants { + + public static final TemplateBooleanModel TRUE = TemplateBooleanModel.TRUE; + + public static final TemplateBooleanModel FALSE = TemplateBooleanModel.FALSE; + + public static final TemplateScalarModel EMPTY_STRING = (TemplateScalarModel) TemplateScalarModel.EMPTY_STRING; + + public static final TemplateNumberModel ZERO = new SimpleNumber(0); + + public static final TemplateNumberModel ONE = new SimpleNumber(1); + + public static final TemplateNumberModel MINUS_ONE = new SimpleNumber(-1); + + public static final TemplateModelIterator EMPTY_ITERATOR = new EmptyIteratorModel(); + + private static class EmptyIteratorModel implements TemplateModelIterator, Serializable { + + public TemplateModel next() throws TemplateModelException { + throw new TemplateModelException("The collection has no more elements."); + } + + public boolean hasNext() throws TemplateModelException { + return false; + } + + } + + public static final TemplateCollectionModel EMPTY_COLLECTION = new EmptyCollectionModel(); + + private static class EmptyCollectionModel implements TemplateCollectionModel, Serializable { + + public TemplateModelIterator iterator() throws TemplateModelException { + return EMPTY_ITERATOR; + } + + } + + public static final TemplateSequenceModel EMPTY_SEQUENCE = new EmptySequenceModel(); + + private static class EmptySequenceModel implements TemplateSequenceModel, Serializable { + + public TemplateModel get(int index) throws TemplateModelException { + return null; + } + + public int size() throws TemplateModelException { + return 0; + } + + } + + public static final TemplateHashModelEx EMPTY_HASH = new EmptyHashModel(); + + private static class EmptyHashModel implements TemplateHashModelEx, Serializable { + + public int size() throws TemplateModelException { + return 0; + } + + public TemplateCollectionModel keys() throws TemplateModelException { + return EMPTY_COLLECTION; + } + + public TemplateCollectionModel values() throws TemplateModelException { + return EMPTY_COLLECTION; + } + + public TemplateModel get(String key) throws TemplateModelException { + return null; + } + + public boolean isEmpty() throws TemplateModelException { + return true; + } + + } + +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/ObjectWrapperWithAPISupport.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/ObjectWrapperWithAPISupport.java b/src/main/java/org/apache/freemarker/core/model/ObjectWrapperWithAPISupport.java new file mode 100644 index 0000000..19c3602 --- /dev/null +++ b/src/main/java/org/apache/freemarker/core/model/ObjectWrapperWithAPISupport.java @@ -0,0 +1,51 @@ +/* + * 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.model; + +import org.apache.freemarker.core.model.ObjectWrapper; +import org.apache.freemarker.core.model.TemplateHashModel; +import org.apache.freemarker.core.model.TemplateModel; +import org.apache.freemarker.core.model.TemplateModelException; + +/** + * <b>Experimental - subject to change:</b> Implemented by {@link ObjectWrapper}-s to help {@link TemplateModel}-s to + * implement the {@code someValue?api} operation. + * + * <p> + * <b>Experimental status warning:</b> This interface is subject to change on non-backward compatible ways, hence, it + * shouldn't be implemented outside FreeMarker yet. + * + * @since 2.3.22 + */ +public interface ObjectWrapperWithAPISupport extends ObjectWrapper { + + /** + * Wraps an object to a {@link TemplateModel} that exposes the object's "native" (usually, Java) API. + * + * @param obj + * The object for which the API model has to be returned. Shouldn't be {@code null}. + * + * @return The {@link TemplateModel} through which the API of the object can be accessed. Can't be {@code null}. + * + * @since 2.3.22 + */ + TemplateHashModel wrapAsAPI(Object obj) throws TemplateModelException; + +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/RichObjectWrapper.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/RichObjectWrapper.java b/src/main/java/org/apache/freemarker/core/model/RichObjectWrapper.java new file mode 100644 index 0000000..2f24014 --- /dev/null +++ b/src/main/java/org/apache/freemarker/core/model/RichObjectWrapper.java @@ -0,0 +1,38 @@ +/* + * 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.model; + +import org.apache.freemarker.core.model.ObjectWrapper; +import org.apache.freemarker.core.model.ObjectWrapperAndUnwrapper; +import org.apache.freemarker.core.model.ObjectWrapperWithAPISupport; + +/** + * <b>Experimental - subject to change:</b> Union of the interfaces that a typical feature rich {@link ObjectWrapper} is + * expected to implement. + * + * <p> + * <b>Experimental status warning:</b> This interface is subject to change on non-backward compatible ways, hence, it + * shouldn't be implemented outside FreeMarker yet. + * + * @since 2.3.22 + */ +public interface RichObjectWrapper extends ObjectWrapperAndUnwrapper, ObjectWrapperWithAPISupport { + +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/TemplateModel.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/TemplateModel.java b/src/main/java/org/apache/freemarker/core/model/TemplateModel.java index c5e8f85..f92cd4a 100644 --- a/src/main/java/org/apache/freemarker/core/model/TemplateModel.java +++ b/src/main/java/org/apache/freemarker/core/model/TemplateModel.java @@ -20,7 +20,7 @@ package org.apache.freemarker.core.model; import org.apache.freemarker.core.Configuration; -import org.apache.freemarker.core.util.ClassUtil; +import org.apache.freemarker.core.util._ClassUtil; /** * The common super-interface of the interfaces that stand for the FreeMarker Template Language (FTL) data types. @@ -42,7 +42,7 @@ import org.apache.freemarker.core.util.ClassUtil; * these types: string, number, boolean, date. The intended applications are like string+hash, string+method, * hash+sequence, etc. * - * @see ClassUtil#getFTLTypeDescription(TemplateModel) + * @see _ClassUtil#getFTLTypeDescription(TemplateModel) */ public interface TemplateModel { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/TemplateModelWithAPISupport.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/TemplateModelWithAPISupport.java b/src/main/java/org/apache/freemarker/core/model/TemplateModelWithAPISupport.java index 607087a..0f2ece0 100644 --- a/src/main/java/org/apache/freemarker/core/model/TemplateModelWithAPISupport.java +++ b/src/main/java/org/apache/freemarker/core/model/TemplateModelWithAPISupport.java @@ -19,8 +19,6 @@ package org.apache.freemarker.core.model; -import org.apache.freemarker.core.util.ObjectWrapperWithAPISupport; - /** * <b>Experimental - subject to change:</b> A {@link TemplateModel} on which the {@code ?api} operation can be applied. * http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/DefaultIterableAdapter.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/DefaultIterableAdapter.java b/src/main/java/org/apache/freemarker/core/model/impl/DefaultIterableAdapter.java index d4682e5..a5899c8 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/DefaultIterableAdapter.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/DefaultIterableAdapter.java @@ -33,7 +33,7 @@ import org.apache.freemarker.core.model.TemplateModelIterator; import org.apache.freemarker.core.model.TemplateModelWithAPISupport; import org.apache.freemarker.core.model.WrapperTemplateModel; import org.apache.freemarker.core.model.WrappingTemplateModel; -import org.apache.freemarker.core.util.ObjectWrapperWithAPISupport; +import org.apache.freemarker.core.model.ObjectWrapperWithAPISupport; /** * Adapts an {@link Iterable} to the corresponding {@link TemplateModel} interface(s), most importantly to http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/DefaultListAdapter.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/DefaultListAdapter.java b/src/main/java/org/apache/freemarker/core/model/impl/DefaultListAdapter.java index 23a6f42..16f21f8 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/DefaultListAdapter.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/DefaultListAdapter.java @@ -33,8 +33,8 @@ import org.apache.freemarker.core.model.TemplateModelWithAPISupport; import org.apache.freemarker.core.model.TemplateSequenceModel; import org.apache.freemarker.core.model.WrapperTemplateModel; import org.apache.freemarker.core.model.WrappingTemplateModel; -import org.apache.freemarker.core.util.ObjectWrapperWithAPISupport; -import org.apache.freemarker.core.util.RichObjectWrapper; +import org.apache.freemarker.core.model.ObjectWrapperWithAPISupport; +import org.apache.freemarker.core.model.RichObjectWrapper; /** * Adapts a {@link List} to the corresponding {@link TemplateModel} interface(s), most importantly to http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/DefaultMapAdapter.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/DefaultMapAdapter.java b/src/main/java/org/apache/freemarker/core/model/impl/DefaultMapAdapter.java index 61076e9..522c7d0 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/DefaultMapAdapter.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/DefaultMapAdapter.java @@ -35,7 +35,7 @@ import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateModelWithAPISupport; import org.apache.freemarker.core.model.WrapperTemplateModel; import org.apache.freemarker.core.model.WrappingTemplateModel; -import org.apache.freemarker.core.util.ObjectWrapperWithAPISupport; +import org.apache.freemarker.core.model.ObjectWrapperWithAPISupport; /** * Adapts a {@link Map} to the corresponding {@link TemplateModel} interface(s), most importantly to http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/DefaultNonListCollectionAdapter.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/DefaultNonListCollectionAdapter.java b/src/main/java/org/apache/freemarker/core/model/impl/DefaultNonListCollectionAdapter.java index 3863f38..f5f6cec 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/DefaultNonListCollectionAdapter.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/DefaultNonListCollectionAdapter.java @@ -35,7 +35,7 @@ import org.apache.freemarker.core.model.TemplateModelIterator; import org.apache.freemarker.core.model.TemplateModelWithAPISupport; import org.apache.freemarker.core.model.WrapperTemplateModel; import org.apache.freemarker.core.model.WrappingTemplateModel; -import org.apache.freemarker.core.util.ObjectWrapperWithAPISupport; +import org.apache.freemarker.core.model.ObjectWrapperWithAPISupport; /** * <b>Experimental - subject to change:</b> Adapts a non-{@link List} Java {@link Collection} to the corresponding http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/SimpleSequence.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/SimpleSequence.java b/src/main/java/org/apache/freemarker/core/model/impl/SimpleSequence.java index 193d1fb..8f86f3f 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/SimpleSequence.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/SimpleSequence.java @@ -24,14 +24,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.apache.freemarker.core.model.ObjectWrapper; -import org.apache.freemarker.core.model.TemplateBooleanModel; -import org.apache.freemarker.core.model.TemplateCollectionModel; -import org.apache.freemarker.core.model.TemplateModel; -import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.model.TemplateModelIterator; -import org.apache.freemarker.core.model.TemplateSequenceModel; -import org.apache.freemarker.core.model.WrappingTemplateModel; +import org.apache.freemarker.core.model.*; import org.apache.freemarker.core.model.impl.beans.BeansWrapper; /** @@ -61,7 +54,7 @@ import org.apache.freemarker.core.model.impl.beans.BeansWrapper; * * <p> * If regardless of which of the above two cases stand, you just need to (or more convenient to) create the sequence - * from a {@link List} (via {@link DefaultListAdapter#adapt(List, org.apache.freemarker.core.util.RichObjectWrapper)} or + * from a {@link List} (via {@link DefaultListAdapter#adapt(List, RichObjectWrapper)} or * {@link SimpleSequence#SimpleSequence(Collection)}), which will be the faster depends on how many times will the * <em>same</em> {@link List} entry be read from the template(s) later, on average. If, on average, you read each entry * for more than 4 times, {@link SimpleSequence} will be most certainly faster, but if for 2 times or less (and http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/_StaticObjectWrappers.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/_StaticObjectWrappers.java b/src/main/java/org/apache/freemarker/core/model/impl/_StaticObjectWrappers.java index 67ea1c8..d891f3b 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/_StaticObjectWrappers.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/_StaticObjectWrappers.java @@ -24,9 +24,7 @@ import org.apache.freemarker.core.model.impl.beans.BeansWrapperBuilder; /** * For internal use only; don't depend on this, there's no backward compatibility guarantee at all! - * This class is to work around the lack of module system in Java, i.e., so that other FreeMarker packages can - * access things inside this package that users shouldn't. - */ + */ // [FM3] This was added temporary until we get to cleaning up the parts that depend on a static ObjectWrapper. The // ObjectWrapper should always come from the Configuration, not from the statics here. public final class _StaticObjectWrappers { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/beans/ArgumentTypes.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/beans/ArgumentTypes.java b/src/main/java/org/apache/freemarker/core/model/impl/beans/ArgumentTypes.java index 83f12ff..a386c4c 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/beans/ArgumentTypes.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/beans/ArgumentTypes.java @@ -29,7 +29,7 @@ import org.apache.freemarker.core.Version; import org.apache.freemarker.core.ast.BugException; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.util.ClassUtil; +import org.apache.freemarker.core.util._ClassUtil; /** * The argument types of a method call; usable as cache key. @@ -201,9 +201,9 @@ final class ArgumentTypes { final boolean argIsNum = Number.class.isAssignableFrom(argType); final int numConvPrice1; - if (argIsNum && ClassUtil.isNumerical(paramType1)) { + if (argIsNum && _ClassUtil.isNumerical(paramType1)) { final Class<?> nonPrimParamType1 = paramType1.isPrimitive() - ? ClassUtil.primitiveClassToBoxingClass(paramType1) : paramType1; + ? _ClassUtil.primitiveClassToBoxingClass(paramType1) : paramType1; numConvPrice1 = OverloadedNumberUtil.getArgumentConversionPrice(argType, nonPrimParamType1); } else { numConvPrice1 = Integer.MAX_VALUE; @@ -213,9 +213,9 @@ final class ArgumentTypes { // - FM doesn't know some of the numerical types, or the conversion between them is not allowed final int numConvPrice2; - if (argIsNum && ClassUtil.isNumerical(paramType2)) { + if (argIsNum && _ClassUtil.isNumerical(paramType2)) { final Class<?> nonPrimParamType2 = paramType2.isPrimitive() - ? ClassUtil.primitiveClassToBoxingClass(paramType2) : paramType2; + ? _ClassUtil.primitiveClassToBoxingClass(paramType2) : paramType2; numConvPrice2 = OverloadedNumberUtil.getArgumentConversionPrice(argType, nonPrimParamType2); } else { numConvPrice2 = Integer.MAX_VALUE; @@ -358,7 +358,7 @@ final class ArgumentTypes { if (argTypesLen == paramTypes1Len - 1) { Class<?> paramType1 = getParamType(paramTypes1, paramTypes1Len, argTypesLen, true); Class<?> paramType2 = getParamType(paramTypes2, paramTypes2Len, argTypesLen, true); - if (ClassUtil.isNumerical(paramType1) && ClassUtil.isNumerical(paramType2)) { + if (_ClassUtil.isNumerical(paramType1) && _ClassUtil.isNumerical(paramType2)) { int r = OverloadedNumberUtil.compareNumberTypeSpecificity(paramType1, paramType2); if (r != 0) return r; // falls through @@ -412,9 +412,9 @@ final class ArgumentTypes { // The more specific (smaller) type wins. final Class<?> nonPrimParamType1 = paramType1.isPrimitive() - ? ClassUtil.primitiveClassToBoxingClass(paramType1) : paramType1; + ? _ClassUtil.primitiveClassToBoxingClass(paramType1) : paramType1; final Class<?> nonPrimParamType2 = paramType2.isPrimitive() - ? ClassUtil.primitiveClassToBoxingClass(paramType2) : paramType2; + ? _ClassUtil.primitiveClassToBoxingClass(paramType2) : paramType2; if (nonPrimParamType1 == nonPrimParamType2) { if (nonPrimParamType1 != paramType1) { @@ -540,7 +540,7 @@ final class ArgumentTypes { return CONVERSION_DIFFICULTY_IMPOSSIBLE; } - formalNP = ClassUtil.primitiveClassToBoxingClass(formal); + formalNP = _ClassUtil.primitiveClassToBoxingClass(formal); if (actual == formalNP) { // Character and char, etc. return CONVERSION_DIFFICULTY_REFLECTION; @@ -610,7 +610,7 @@ final class ArgumentTypes { } else if (formal == Short.TYPE && (actual == Short.class || actual == Byte.class)) { return CONVERSION_DIFFICULTY_REFLECTION; - } else if (BigDecimal.class.isAssignableFrom(actual) && ClassUtil.isNumerical(formal)) { + } else if (BigDecimal.class.isAssignableFrom(actual) && _ClassUtil.isNumerical(formal)) { // Special case for BigDecimals as we deem BigDecimal to be // convertible to any numeric type - either object or primitive. // This can actually cause us trouble as this is a narrowing http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/beans/BeanModel.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/beans/BeanModel.java b/src/main/java/org/apache/freemarker/core/model/impl/beans/BeanModel.java index e234d41..1095d7e 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/beans/BeanModel.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/beans/BeanModel.java @@ -49,7 +49,7 @@ import org.apache.freemarker.core.model.TemplateScalarModel; import org.apache.freemarker.core.model.WrapperTemplateModel; import org.apache.freemarker.core.model.impl.SimpleScalar; import org.apache.freemarker.core.model.impl.SimpleSequence; -import org.apache.freemarker.core.util.StringUtil; +import org.apache.freemarker.core.util._StringUtil; import org.slf4j.Logger; /** @@ -197,7 +197,7 @@ implements private void logNoSuchKey(String key, Map<?, ?> keyMap) { if (LOG.isDebugEnabled()) { - LOG.debug("Key " + StringUtil.jQuoteNoXSS(key) + " was not found on instance of " + + LOG.debug("Key " + _StringUtil.jQuoteNoXSS(key) + " was not found on instance of " + object.getClass().getName() + ". Introspection information for " + "the class is: " + keyMap); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/beans/BeansWrapper.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/beans/BeansWrapper.java b/src/main/java/org/apache/freemarker/core/model/impl/beans/BeansWrapper.java index 76e4dcc..edff45f 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/beans/BeansWrapper.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/beans/BeansWrapper.java @@ -63,8 +63,8 @@ import org.apache.freemarker.core.model.TemplateSequenceModel; import org.apache.freemarker.core.model.WrapperTemplateModel; import org.apache.freemarker.core.model.impl.DefaultObjectWrapper; import org.apache.freemarker.core.model.impl.SimpleObjectWrapper; -import org.apache.freemarker.core.util.ClassUtil; -import org.apache.freemarker.core.util.RichObjectWrapper; +import org.apache.freemarker.core.util._ClassUtil; +import org.apache.freemarker.core.model.RichObjectWrapper; import org.apache.freemarker.core.util.UndeclaredThrowableException; import org.apache.freemarker.core.util.WriteProtectable; import org.slf4j.Logger; @@ -1015,7 +1015,7 @@ public class BeansWrapper implements RichObjectWrapper, WriteProtectable { final boolean is2321Bugfixed = is2321Bugfixed(); if (is2321Bugfixed && targetClass.isPrimitive()) { - targetClass = ClassUtil.primitiveClassToBoxingClass(targetClass); + targetClass = _ClassUtil.primitiveClassToBoxingClass(targetClass); } // This is for transparent interop with other wrappers (and ourselves) @@ -1029,7 +1029,7 @@ public class BeansWrapper implements RichObjectWrapper, WriteProtectable { } // Attempt numeric conversion: - if (targetClass != Object.class && (wrapped instanceof Number && ClassUtil.isNumerical(targetClass))) { + if (targetClass != Object.class && (wrapped instanceof Number && _ClassUtil.isNumerical(targetClass))) { Number number = forceUnwrappedNumberToType((Number) wrapped, targetClass, is2321Bugfixed); if (number != null) return number; } @@ -1042,7 +1042,7 @@ public class BeansWrapper implements RichObjectWrapper, WriteProtectable { } // Attempt numeric conversion: - if (targetClass != Object.class && (wrapped instanceof Number && ClassUtil.isNumerical(targetClass))) { + if (targetClass != Object.class && (wrapped instanceof Number && _ClassUtil.isNumerical(targetClass))) { Number number = forceUnwrappedNumberToType((Number) wrapped, targetClass, is2321Bugfixed); if (number != null) { return number; @@ -1066,7 +1066,7 @@ public class BeansWrapper implements RichObjectWrapper, WriteProtectable { } // Primitive numeric types & Number.class and its subclasses - if (ClassUtil.isNumerical(targetClass)) { + if (_ClassUtil.isNumerical(targetClass)) { if (model instanceof TemplateNumberModel) { Number number = forceUnwrappedNumberToType( ((TemplateNumberModel) model).getAsNumber(), targetClass, is2321Bugfixed); @@ -1302,7 +1302,7 @@ public class BeansWrapper implements RichObjectWrapper, WriteProtectable { if (listItem != null && !componentType.isInstance(listItem)) { // Type conversion is needed. If we can't do it, we just let it fail at Array.set later. if (!isComponentTypeExamined) { - isComponentTypeNumerical = ClassUtil.isNumerical(componentType); + isComponentTypeNumerical = _ClassUtil.isNumerical(componentType); isComponentTypeList = List.class.isAssignableFrom(componentType); isComponentTypeExamined = true; } @@ -1330,10 +1330,10 @@ public class BeansWrapper implements RichObjectWrapper, WriteProtectable { Array.set(array, i, listItem); } catch (IllegalArgumentException e) { throw new TemplateModelException( - "Failed to convert " + ClassUtil.getShortClassNameOfObject(list) - + " object to " + ClassUtil.getShortClassNameOfObject(array) + "Failed to convert " + _ClassUtil.getShortClassNameOfObject(list) + + " object to " + _ClassUtil.getShortClassNameOfObject(array) + ": Problematic List item at index " + i + " with value type: " - + ClassUtil.getShortClassNameOfObject(listItem), e); + + _ClassUtil.getShortClassNameOfObject(listItem), e); } i++; } @@ -1671,7 +1671,7 @@ public class BeansWrapper implements RichObjectWrapper, WriteProtectable { @Override public String toString() { final String propsStr = toPropertiesString(); - return ClassUtil.getShortClassNameOfObject(this) + "@" + System.identityHashCode(this) + return _ClassUtil.getShortClassNameOfObject(this) + "@" + System.identityHashCode(this) + "(" + incompatibleImprovements + ", " + (propsStr.length() != 0 ? propsStr + ", ..." : "") + ")"; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/beans/ClassBasedModelFactory.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/beans/ClassBasedModelFactory.java b/src/main/java/org/apache/freemarker/core/model/impl/beans/ClassBasedModelFactory.java index 91a27a8..f3274b6 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/beans/ClassBasedModelFactory.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/beans/ClassBasedModelFactory.java @@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.freemarker.core.model.TemplateHashModel; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.util.ClassUtil; +import org.apache.freemarker.core.util._ClassUtil; /** * Base class for hash models keyed by Java class names. @@ -90,7 +90,7 @@ abstract class ClassBasedModelFactory implements TemplateHashModel { classIntrospectorClearingCounter = classIntrospector.getClearingCounter(); } try { - final Class clazz = ClassUtil.forName(key); + final Class clazz = _ClassUtil.forName(key); // This is called so that we trigger the // class-reloading detector. If clazz is a reloaded class, http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/beans/ClassIntrospector.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/beans/ClassIntrospector.java b/src/main/java/org/apache/freemarker/core/model/impl/beans/ClassIntrospector.java index 975e247..e793078 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/beans/ClassIntrospector.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/beans/ClassIntrospector.java @@ -48,7 +48,7 @@ import org.apache.freemarker.core._CoreLogs; import org.apache.freemarker.core.ast.BugException; import org.apache.freemarker.core.model.impl.beans.BeansWrapper.MethodAppearanceDecision; import org.apache.freemarker.core.model.impl.beans.BeansWrapper.MethodAppearanceDecisionInput; -import org.apache.freemarker.core.util.NullArgumentException; +import org.apache.freemarker.core.util._NullArgumentException; import org.slf4j.Logger; /** @@ -171,7 +171,7 @@ class ClassIntrospector { */ ClassIntrospector(ClassIntrospectorBuilder builder, Object sharedLock, boolean hasSharedInstanceRestrictons, boolean shared) { - NullArgumentException.check("sharedLock", sharedLock); + _NullArgumentException.check("sharedLock", sharedLock); this.exposureLevel = builder.getExposureLevel(); this.exposeFields = builder.getExposeFields(); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/beans/OverloadedMethods.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/beans/OverloadedMethods.java b/src/main/java/org/apache/freemarker/core/model/impl/beans/OverloadedMethods.java index 335cf08..2682e25 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/beans/OverloadedMethods.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/beans/OverloadedMethods.java @@ -31,7 +31,7 @@ import org.apache.freemarker.core.ast._ErrorDescriptionBuilder; import org.apache.freemarker.core.ast._TemplateModelException; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.util.ClassUtil; +import org.apache.freemarker.core.util._ClassUtil; /** * Used instead of {@link java.lang.reflect.Method} or {@link java.lang.reflect.Constructor} for overloaded methods and @@ -218,7 +218,7 @@ final class OverloadedMethods { private _DelayedConversionToString getTMActualParameterTypes(List arguments) { final String[] argumentTypeDescs = new String[arguments.size()]; for (int i = 0; i < arguments.size(); i++) { - argumentTypeDescs[i] = ClassUtil.getFTLTypeDescription((TemplateModel) arguments.get(i)); + argumentTypeDescs[i] = _ClassUtil.getFTLTypeDescription((TemplateModel) arguments.get(i)); } return new DelayedCallSignatureToString(argumentTypeDescs) { @@ -243,8 +243,8 @@ final class OverloadedMethods { @Override String argumentToString(Object argType) { return argType != null - ? ClassUtil.getShortClassName((Class) argType) - : ClassUtil.getShortClassNameOfObject(null); + ? _ClassUtil.getShortClassName((Class) argType) + : _ClassUtil.getShortClassNameOfObject(null); } }; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/beans/OverloadedMethodsSubset.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/beans/OverloadedMethodsSubset.java b/src/main/java/org/apache/freemarker/core/model/impl/beans/OverloadedMethodsSubset.java index 27f870c..3960d3c 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/beans/OverloadedMethodsSubset.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/beans/OverloadedMethodsSubset.java @@ -28,8 +28,8 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.util.ClassUtil; -import org.apache.freemarker.core.util.NullArgumentException; +import org.apache.freemarker.core.util._ClassUtil; +import org.apache.freemarker.core.util._NullArgumentException; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -184,7 +184,7 @@ abstract class OverloadedMethodsSubset { // c1 primitive class to boxing class: final boolean c1WasPrim; if (c1.isPrimitive()) { - c1 = ClassUtil.primitiveClassToBoxingClass(c1); + c1 = _ClassUtil.primitiveClassToBoxingClass(c1); c1WasPrim = true; } else { c1WasPrim = false; @@ -193,7 +193,7 @@ abstract class OverloadedMethodsSubset { // c2 primitive class to boxing class: final boolean c2WasPrim; if (c2.isPrimitive()) { - c2 = ClassUtil.primitiveClassToBoxingClass(c2); + c2 = _ClassUtil.primitiveClassToBoxingClass(c2); c2WasPrim = true; } else { c2WasPrim = false; @@ -326,7 +326,7 @@ abstract class OverloadedMethodsSubset { * Maybe {@link #ALL_ZEROS_ARRAY}. Maybe a 0-length array. Can't be {@code null}. */ final protected void mergeInTypesFlags(int dstParamCount, int[] srcTypeFlagsByParamIdx) { - NullArgumentException.check("srcTypesFlagsByParamIdx", srcTypeFlagsByParamIdx); + _NullArgumentException.check("srcTypesFlagsByParamIdx", srcTypeFlagsByParamIdx); // Special case of 0 param count: if (dstParamCount == 0) { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/beans/OverloadedNumberUtil.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/beans/OverloadedNumberUtil.java b/src/main/java/org/apache/freemarker/core/model/impl/beans/OverloadedNumberUtil.java index 4dc8696..8f27ecf 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/beans/OverloadedNumberUtil.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/beans/OverloadedNumberUtil.java @@ -23,8 +23,8 @@ import java.math.BigDecimal; import java.math.BigInteger; import org.apache.freemarker.core.model.TemplateNumberModel; -import org.apache.freemarker.core.util.ClassUtil; -import org.apache.freemarker.core.util.NumberUtil; +import org.apache.freemarker.core.util._ClassUtil; +import org.apache.freemarker.core.util._NumberUtil; /** * Everything related to coercion to ambiguous numerical types. @@ -101,7 +101,7 @@ class OverloadedNumberUtil { BigDecimal n = (BigDecimal) num; if ((typeFlags & TypeFlags.MASK_KNOWN_INTEGERS) != 0 && (typeFlags & TypeFlags.MASK_KNOWN_NONINTEGERS) != 0 - && NumberUtil.isIntegerBigDecimal(n) /* <- can be expensive */) { + && _NumberUtil.isIntegerBigDecimal(n) /* <- can be expensive */) { return new IntegerBigDecimal(n); } else { // Either it was a non-integer, or it didn't mater what it was, as we don't have both integer and @@ -1197,8 +1197,8 @@ class OverloadedNumberUtil { static int compareNumberTypeSpecificity(Class c1, Class c2) { // DO NOT EDIT, generated code! // See: src\main\misc\overloadedNumberRules\README.txt - c1 = ClassUtil.primitiveClassToBoxingClass(c1); - c2 = ClassUtil.primitiveClassToBoxingClass(c2); + c1 = _ClassUtil.primitiveClassToBoxingClass(c1); + c2 = _ClassUtil.primitiveClassToBoxingClass(c2); if (c1 == c2) return 0; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/beans/SimpleMapModel.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/beans/SimpleMapModel.java b/src/main/java/org/apache/freemarker/core/model/impl/beans/SimpleMapModel.java index d5c65f5..c681d9c 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/beans/SimpleMapModel.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/beans/SimpleMapModel.java @@ -35,7 +35,7 @@ import org.apache.freemarker.core.model.WrapperTemplateModel; import org.apache.freemarker.core.model.WrappingTemplateModel; import org.apache.freemarker.core.model.impl.MapKeyValuePairIterator; import org.apache.freemarker.core.model.impl.SimpleSequence; -import org.apache.freemarker.core.util.RichObjectWrapper; +import org.apache.freemarker.core.model.RichObjectWrapper; /** * Model used by {@link BeansWrapper} when <tt>simpleMapWrapper</tt> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/beans/SimpleMethod.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/beans/SimpleMethod.java b/src/main/java/org/apache/freemarker/core/model/impl/beans/SimpleMethod.java index f0b2874..00223e7 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/beans/SimpleMethod.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/beans/SimpleMethod.java @@ -32,7 +32,7 @@ import org.apache.freemarker.core.ast._TemplateModelException; import org.apache.freemarker.core.model.ObjectWrapperAndUnwrapper; import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.util.ClassUtil; +import org.apache.freemarker.core.util._ClassUtil; /** * This class is used for as a base for non-overloaded method models and for constructors. @@ -153,7 +153,7 @@ class SimpleMethod { _ErrorDescriptionBuilder desc = new _ErrorDescriptionBuilder( _MethodUtil.invocationErrorMessageStart(member), " couldn't be called: Can't convert the ", new _DelayedOrdinal(Integer.valueOf(argIdx + 1)), - " argument's value to the target Java type, ", ClassUtil.getShortClassName(targetType), + " argument's value to the target Java type, ", _ClassUtil.getShortClassName(targetType), ". The type of the actual value was: ", new _DelayedFTLTypeDescription(argVal)); if (argVal instanceof TemplateMarkupOutputModel && (targetType.isAssignableFrom(String.class))) { desc.tip(MARKUP_OUTPUT_TO_STRING_TIP); @@ -165,7 +165,7 @@ class SimpleMethod { return new _TemplateModelException( _MethodUtil.invocationErrorMessageStart(member), " couldn't be called: The value of the ", new _DelayedOrdinal(Integer.valueOf(argIdx + 1)), - " argument was null, but the target Java parameter type (", ClassUtil.getShortClassName(targetType), + " argument was null, but the target Java parameter type (", _ClassUtil.getShortClassName(targetType), ") is primitive and so can't store null."); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/beans/SimpleMethodModel.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/beans/SimpleMethodModel.java b/src/main/java/org/apache/freemarker/core/model/impl/beans/SimpleMethodModel.java index abac682..220f5fe 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/beans/SimpleMethodModel.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/beans/SimpleMethodModel.java @@ -30,7 +30,7 @@ import org.apache.freemarker.core.model.TemplateModel; import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.TemplateSequenceModel; import org.apache.freemarker.core.model.impl.SimpleNumber; -import org.apache.freemarker.core.util.ClassUtil; +import org.apache.freemarker.core.util._ClassUtil; /** * A class that will wrap a reflected method call into a @@ -83,7 +83,7 @@ public final class SimpleMethodModel extends SimpleMethod public int size() throws TemplateModelException { throw new TemplateModelException( "Getting the number of items or enumerating the items is not supported on this " - + ClassUtil.getFTLTypeDescription(this) + " value.\n" + + _ClassUtil.getFTLTypeDescription(this) + " value.\n" + "(" + "Hint 1: Maybe you wanted to call this method first and then do something with its return value. " + "Hint 2: Getting items by intex possibly works, hence it's a \"+sequence\"." http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/beans/UnsafeMethods.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/beans/UnsafeMethods.java b/src/main/java/org/apache/freemarker/core/model/impl/beans/UnsafeMethods.java index 4c46467..78f5093 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/beans/UnsafeMethods.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/beans/UnsafeMethods.java @@ -30,7 +30,7 @@ import java.util.Set; import java.util.StringTokenizer; import org.apache.freemarker.core._CoreLogs; -import org.apache.freemarker.core.util.ClassUtil; +import org.apache.freemarker.core.util._ClassUtil; import org.slf4j.Logger; class UnsafeMethods { @@ -80,7 +80,7 @@ class UnsafeMethods { NoSuchMethodException { int brace = methodSpec.indexOf('('); int dot = methodSpec.lastIndexOf('.', brace); - Class clazz = ClassUtil.forName(methodSpec.substring(0, dot)); + Class clazz = _ClassUtil.forName(methodSpec.substring(0, dot)); String methodName = methodSpec.substring(dot + 1, brace); String argSpec = methodSpec.substring(brace + 1, methodSpec.length() - 1); StringTokenizer tok = new StringTokenizer(argSpec, ","); @@ -90,7 +90,7 @@ class UnsafeMethods { String argClassName = tok.nextToken(); argTypes[i] = (Class) primClasses.get(argClassName); if (argTypes[i] == null) { - argTypes[i] = ClassUtil.forName(argClassName); + argTypes[i] = _ClassUtil.forName(argClassName); } } return clazz.getMethod(methodName, argTypes); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/beans/_BeansAPI.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/beans/_BeansAPI.java b/src/main/java/org/apache/freemarker/core/model/impl/beans/_BeansAPI.java index a6e67a7..40a1595 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/beans/_BeansAPI.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/beans/_BeansAPI.java @@ -34,7 +34,7 @@ import java.util.Map; import org.apache.freemarker.core.ast.BugException; import org.apache.freemarker.core.model.TemplateModelException; import org.apache.freemarker.core.model.impl.DefaultObjectWrapper; -import org.apache.freemarker.core.util.CollectionUtils; +import org.apache.freemarker.core.util._CollectionUtil; /** * For internal use only; don't depend on this, there's no backward compatibility guarantee at all! @@ -58,7 +58,7 @@ public class _BeansAPI { */ private static CallableMemberDescriptor getConstructorDescriptor(Class<?> pClass, Object[] args) throws NoSuchMethodException { - if (args == null) args = CollectionUtils.EMPTY_OBJECT_ARRAY; + if (args == null) args = _CollectionUtil.EMPTY_OBJECT_ARRAY; final ArgumentTypes argTypes = new ArgumentTypes(args, true); final List<ReflectionCallableMemberDescriptor> fixedArgMemberDescs @@ -101,7 +101,7 @@ public class _BeansAPI { private static Object newInstance(CallableMemberDescriptor constrDesc, Object[] args, BeansWrapper bw) throws InstantiationException, IllegalAccessException, InvocationTargetException, IllegalArgumentException, TemplateModelException { - if (args == null) args = CollectionUtils.EMPTY_OBJECT_ARRAY; + if (args == null) args = _CollectionUtil.EMPTY_OBJECT_ARRAY; final Object[] packedArgs; if (constrDesc.isVarargs()) { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/beans/_MethodUtil.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/beans/_MethodUtil.java b/src/main/java/org/apache/freemarker/core/model/impl/beans/_MethodUtil.java index a06749b..ae99450 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/beans/_MethodUtil.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/beans/_MethodUtil.java @@ -31,13 +31,11 @@ import org.apache.freemarker.core.ast._DelayedConversionToString; import org.apache.freemarker.core.ast._DelayedJQuote; import org.apache.freemarker.core.ast._TemplateModelException; import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.util.ClassUtil; +import org.apache.freemarker.core.util._ClassUtil; /** * For internal use only; don't depend on this, there's no backward compatibility guarantee at all! - * This class is to work around the lack of module system in Java, i.e., so that other FreeMarker packages can - * access things inside this package that users shouldn't. - */ + */ public final class _MethodUtil { private _MethodUtil() { @@ -80,7 +78,7 @@ public final class _MethodUtil { return isWideningPrimitiveNumberConversion(specific, generic) ? 3 : 0; } else { // => specificIsPrim && !genericIsPrim if (bugfixed) { - final Class specificAsBoxed = ClassUtil.primitiveClassToBoxingClass(specific); + final Class specificAsBoxed = _ClassUtil.primitiveClassToBoxingClass(specific); if (specificAsBoxed == generic) { // A primitive class is more specific than its boxing class, because it can't store null return 2; @@ -216,7 +214,7 @@ public final class _MethodUtil { sb.append("static "); } - String className = ClassUtil.getShortClassName(member.getDeclaringClass()); + String className = _ClassUtil.getShortClassName(member.getDeclaringClass()); if (className != null) { sb.append(className); sb.append('.'); @@ -227,7 +225,7 @@ public final class _MethodUtil { Class[] paramTypes = _MethodUtil.getParameterTypes(member); for (int i = 0; i < paramTypes.length; i++) { if (i != 0) sb.append(", "); - String paramTypeDecl = ClassUtil.getShortClassName(paramTypes[i]); + String paramTypeDecl = _ClassUtil.getShortClassName(paramTypes[i]); if (i == paramTypes.length - 1 && paramTypeDecl.endsWith("[]") && _MethodUtil.isVarargs(member)) { sb.append(paramTypeDecl.substring(0, paramTypeDecl.length() - 2)); sb.append("..."); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a5d9575f/src/main/java/org/apache/freemarker/core/model/impl/dom/NodeOutputter.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/model/impl/dom/NodeOutputter.java b/src/main/java/org/apache/freemarker/core/model/impl/dom/NodeOutputter.java index 0921cb5..fcd40bb 100644 --- a/src/main/java/org/apache/freemarker/core/model/impl/dom/NodeOutputter.java +++ b/src/main/java/org/apache/freemarker/core/model/impl/dom/NodeOutputter.java @@ -25,7 +25,7 @@ import java.util.LinkedHashMap; import org.apache.freemarker.core.Template; import org.apache.freemarker.core.ast.BugException; import org.apache.freemarker.core.ast.Environment; -import org.apache.freemarker.core.util.StringUtil; +import org.apache.freemarker.core.util._StringUtil; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.DocumentType; @@ -78,7 +78,7 @@ class NodeOutputter { if (prefix == null) { // Assign a generated prefix: do { - prefix = StringUtil.toLowerABC(nextGeneratedPrefixNumber++); + prefix = _StringUtil.toLowerABC(nextGeneratedPrefixNumber++); } while (env.getNamespaceForPrefix(prefix) != null); } } @@ -150,7 +150,7 @@ class NodeOutputter { buf.append(' '); outputQualifiedName(n, buf); buf.append("=\"") - .append(StringUtil.XMLEncQAttr(n.getNodeValue())) + .append(_StringUtil.XMLEncQAttr(n.getNodeValue())) .append('"'); } break; @@ -216,7 +216,7 @@ class NodeOutputter { }*/ case Node.CDATA_SECTION_NODE: case Node.TEXT_NODE: { - buf.append(StringUtil.XMLEncNQG(n.getNodeValue())); + buf.append(_StringUtil.XMLEncNQG(n.getNodeValue())); break; } }
