http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3fd56062/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8BridgeMethodsWithDefaultMethodBean.java ---------------------------------------------------------------------- diff --git a/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8BridgeMethodsWithDefaultMethodBean.java b/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8BridgeMethodsWithDefaultMethodBean.java new file mode 100644 index 0000000..c7d27a6 --- /dev/null +++ b/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8BridgeMethodsWithDefaultMethodBean.java @@ -0,0 +1,29 @@ +/* + * 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.impl; + +public class Java8BridgeMethodsWithDefaultMethodBean implements Java8BridgeMethodsWithDefaultMethodBeanBase<String> { + + static final String M1_RETURN_VALUE = "m1ReturnValue"; + + public String m1() { + return M1_RETURN_VALUE; + } + +}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3fd56062/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8BridgeMethodsWithDefaultMethodBean2.java ---------------------------------------------------------------------- diff --git a/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8BridgeMethodsWithDefaultMethodBean2.java b/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8BridgeMethodsWithDefaultMethodBean2.java new file mode 100644 index 0000000..7dfb39a --- /dev/null +++ b/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8BridgeMethodsWithDefaultMethodBean2.java @@ -0,0 +1,23 @@ +/* + * 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.impl; + +public class Java8BridgeMethodsWithDefaultMethodBean2 implements Java8BridgeMethodsWithDefaultMethodBeanBase2 { + // All inherited +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3fd56062/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8BridgeMethodsWithDefaultMethodBeanBase.java ---------------------------------------------------------------------- diff --git a/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8BridgeMethodsWithDefaultMethodBeanBase.java b/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8BridgeMethodsWithDefaultMethodBeanBase.java new file mode 100644 index 0000000..fdd8821 --- /dev/null +++ b/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8BridgeMethodsWithDefaultMethodBeanBase.java @@ -0,0 +1,31 @@ +/* + * 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.impl; + +public interface Java8BridgeMethodsWithDefaultMethodBeanBase<T> { + + default T m1() { + return null; + } + + default T m2() { + return null; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3fd56062/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8BridgeMethodsWithDefaultMethodBeanBase2.java ---------------------------------------------------------------------- diff --git a/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8BridgeMethodsWithDefaultMethodBeanBase2.java b/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8BridgeMethodsWithDefaultMethodBeanBase2.java new file mode 100644 index 0000000..6f68dc7 --- /dev/null +++ b/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8BridgeMethodsWithDefaultMethodBeanBase2.java @@ -0,0 +1,28 @@ +/* + * 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.impl; + +public interface Java8BridgeMethodsWithDefaultMethodBeanBase2 extends Java8BridgeMethodsWithDefaultMethodBeanBase<String> { + + @Override + default String m1() { + return Java8BridgeMethodsWithDefaultMethodBean.M1_RETURN_VALUE; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3fd56062/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8DefaultMethodsBean.java ---------------------------------------------------------------------- diff --git a/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8DefaultMethodsBean.java b/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8DefaultMethodsBean.java new file mode 100644 index 0000000..eabc3d0 --- /dev/null +++ b/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8DefaultMethodsBean.java @@ -0,0 +1,84 @@ +/* + * 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.impl; + +public class Java8DefaultMethodsBean implements Java8DefaultMethodsBeanBase { + + static final String NORMAL_PROP = "normalProp"; + static final String NORMAL_PROP_VALUE = "normalPropValue"; + static final String PROP_2_OVERRIDE_VALUE = "prop2OverrideValue"; + static final int NOT_AN_INDEXED_PROP_VALUE = 1; + static final String ARRAY_PROP_2_VALUE_0 = "arrayProp2[0].value"; + private static final int NOT_AN_INDEXED_PROP_3_VALUE = 3; + private static final String NOT_AN_INDEXED_PROP_2_VALUE = "notAnIndecedProp2Value"; + static final String INDEXED_PROP_4 = "indexedProp4"; + static final String INDEXED_PROP_GETTER_4 = "getIndexedProp4"; + static final String INDEXED_PROP_4_VALUE = "indexedProp4Value[0]"; + static final String NORMAL_ACTION = "normalAction"; + static final String NORMAL_ACTION_RETURN_VALUE = "normalActionReturnValue"; + static final String OVERRIDDEN_DEFAULT_METHOD_ACTION_RETURN_VALUE = "overriddenValue"; + + public String getNormalProp() { + return NORMAL_PROP_VALUE; + } + + @Override + public String getDefaultMethodProp2() { + return PROP_2_OVERRIDE_VALUE; + } + + public String[] getDefaultMethodIndexedProp2() { + return new String[] { ARRAY_PROP_2_VALUE_0 }; + } + + /** + * There's a matching non-indexed reader method in the base class, but as this is indexed, it takes over. + */ + public String getDefaultMethodIndexedProp3(int index) { + return ""; + } + + public int getDefaultMethodNotAnIndexedProp() { + return NOT_AN_INDEXED_PROP_VALUE; + } + + /** Actually, this will be indexed if the default method support is off. */ + public String getDefaultMethodNotAnIndexedProp2(int index) { + return NOT_AN_INDEXED_PROP_2_VALUE; + } + + /** Actually, this will be indexed if the default method support is off. */ + public int getDefaultMethodNotAnIndexedProp3(int index) { + return NOT_AN_INDEXED_PROP_3_VALUE; + } + + public String getIndexedProp4(int index) { + return INDEXED_PROP_4_VALUE; + } + + public String normalAction() { + return NORMAL_ACTION_RETURN_VALUE; + } + + @Override + public String overriddenDefaultMethodAction() { + return OVERRIDDEN_DEFAULT_METHOD_ACTION_RETURN_VALUE; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3fd56062/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8DefaultMethodsBeanBase.java ---------------------------------------------------------------------- diff --git a/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8DefaultMethodsBeanBase.java b/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8DefaultMethodsBeanBase.java new file mode 100644 index 0000000..c01422e --- /dev/null +++ b/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8DefaultMethodsBeanBase.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.model.impl; + +public interface Java8DefaultMethodsBeanBase { + + static final String DEFAULT_METHOD_PROP = "defaultMethodProp"; + static final String DEFAULT_METHOD_PROP_VALUE = "defaultMethodPropValue"; + static final String DEFAULT_METHOD_PROP_2 = "defaultMethodProp2"; + static final String DEFAULT_METHOD_INDEXED_PROP = "defaultMethodIndexedProp"; + static final String DEFAULT_METHOD_INDEXED_PROP_GETTER = "getDefaultMethodIndexedProp"; + static final String DEFAULT_METHOD_INDEXED_PROP_VALUE = "defaultMethodIndexedPropValue"; + static final String DEFAULT_METHOD_INDEXED_PROP_2 = "defaultMethodIndexedProp2"; + static final String DEFAULT_METHOD_INDEXED_PROP_2_VALUE_0 = "defaultMethodIndexedProp2(0).value"; + static final String DEFAULT_METHOD_INDEXED_PROP_3 = "defaultMethodIndexedProp3"; + static final String DEFAULT_METHOD_INDEXED_PROP_3_VALUE_0 = "indexedProp3Value[0]"; + static final String DEFAULT_METHOD_NOT_AN_INDEXED_PROP = "defaultMethodNotAnIndexedProp"; + static final String DEFAULT_METHOD_NOT_AN_INDEXED_PROP_VALUE = "defaultMethodNotAnIndexedPropValue"; + static final String DEFAULT_METHOD_NOT_AN_INDEXED_PROP_2 = "defaultMethodNotAnIndexedProp2"; + static final String DEFAULT_METHOD_NOT_AN_INDEXED_PROP_2_VALUE = "defaultMethodNotAnIndexedProp2Value"; + static final String DEFAULT_METHOD_NOT_AN_INDEXED_PROP_3 = "defaultMethodNotAnIndexedProp3"; + static final String DEFAULT_METHOD_NOT_AN_INDEXED_PROP_3_VALUE_0 = "defaultMethodNotAnIndexedProp3Value[0]"; + static final String DEFAULT_METHOD_ACTION = "defaultMethodAction"; + static final String DEFAULT_METHOD_ACTION_RETURN_VALUE = "defaultMethodActionReturnValue"; + static final String OVERRIDDEN_DEFAULT_METHOD_ACTION = "overriddenDefaultMethodAction"; + + default String getDefaultMethodProp() { + return DEFAULT_METHOD_PROP_VALUE; + } + + default String getDefaultMethodProp2() { + return ""; + } + + /** + * Will be kept as there's no non-indexed read methods for this. + */ + default String getDefaultMethodIndexedProp(int i) { + return DEFAULT_METHOD_INDEXED_PROP_VALUE; + } + + /** + * Will be kept as there will be a matching non-indexed read method in the subclass. + * However, as of FM3, the non-indexed read method is used if it's available. + */ + default String getDefaultMethodIndexedProp2(int i) { + return DEFAULT_METHOD_INDEXED_PROP_2_VALUE_0; + } + + /** + * This is not an indexed reader method, but a matching indexed reader method will be added in the subclass. + * However, as of FM3, the non-indexed read method is used if it's available. + */ + default String[] getDefaultMethodIndexedProp3() { + return new String[] {DEFAULT_METHOD_INDEXED_PROP_3_VALUE_0}; + } + + /** Will be discarded because of a non-matching non-indexed read method in a subclass */ + default String getDefaultMethodNotAnIndexedProp(int i) { + return ""; + } + + /** The subclass will try to override this with a non-matching indexed reader, but this will be stronger. */ + default String getDefaultMethodNotAnIndexedProp2() { + return DEFAULT_METHOD_NOT_AN_INDEXED_PROP_2_VALUE; + } + + /** The subclass will try to override this with a non-matching indexed reader, but this will be stronger. */ + default String[] getDefaultMethodNotAnIndexedProp3() { + return new String[] { DEFAULT_METHOD_NOT_AN_INDEXED_PROP_3_VALUE_0 }; + } + + default String defaultMethodAction() { + return DEFAULT_METHOD_ACTION_RETURN_VALUE; + } + + default Object overriddenDefaultMethodAction() { + return null; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3fd56062/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8DefaultObjectWrapperBridgeMethodsTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8DefaultObjectWrapperBridgeMethodsTest.java b/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8DefaultObjectWrapperBridgeMethodsTest.java new file mode 100644 index 0000000..495f3f9 --- /dev/null +++ b/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8DefaultObjectWrapperBridgeMethodsTest.java @@ -0,0 +1,65 @@ +/* + * 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.impl; + +import static org.junit.Assert.*; + +import java.util.Collections; + +import org.junit.Test; + +import org.apache.freemarker.core.Configuration; +import org.apache.freemarker.core.model.TemplateHashModel; +import org.apache.freemarker.core.model.TemplateMethodModelEx; +import org.apache.freemarker.core.model.TemplateModelException; + +public class Java8DefaultObjectWrapperBridgeMethodsTest { + + @Test + public void testWithoutDefaultMethod() throws TemplateModelException { + test(BridgeMethodsBean.class); + } + + @Test + public void testWithDefaultMethod() throws TemplateModelException { + test(Java8BridgeMethodsWithDefaultMethodBean.class); + } + + @Test + public void testWithDefaultMethod2() throws TemplateModelException { + test(Java8BridgeMethodsWithDefaultMethodBean2.class); + } + + private void test(Class<?> pClass) throws TemplateModelException { + DefaultObjectWrapper ow = new DefaultObjectWrapper.Builder(Configuration.VERSION_3_0_0).build(); + TemplateHashModel wrapped; + try { + wrapped = (TemplateHashModel) ow.wrap(pClass.newInstance()); + } catch (Exception e) { + throw new IllegalStateException(e); + } + + TemplateMethodModelEx m1 = (TemplateMethodModelEx) wrapped.get("m1"); + assertEquals(BridgeMethodsBean.M1_RETURN_VALUE, "" + m1.exec(Collections.emptyList())); + + TemplateMethodModelEx m2 = (TemplateMethodModelEx) wrapped.get("m2"); + assertNull(m2.exec(Collections.emptyList())); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3fd56062/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8DefaultObjectWrapperTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8DefaultObjectWrapperTest.java b/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8DefaultObjectWrapperTest.java new file mode 100644 index 0000000..905d536 --- /dev/null +++ b/freemarker-core-java8-test/src/test/java/org/apache/freemarker/core/model/impl/Java8DefaultObjectWrapperTest.java @@ -0,0 +1,160 @@ +/* + * 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.impl; + +import static org.junit.Assert.*; + +import java.util.Collections; + +import org.junit.Test; + +import org.apache.freemarker.core.Configuration; +import org.apache.freemarker.core.model.TemplateHashModel; +import org.apache.freemarker.core.model.TemplateMethodModelEx; +import org.apache.freemarker.core.model.TemplateModelException; +import org.apache.freemarker.core.model.TemplateNumberModel; +import org.apache.freemarker.core.model.TemplateScalarModel; +import org.apache.freemarker.core.model.TemplateSequenceModel; + +public class Java8DefaultObjectWrapperTest { + + @Test + public void testDefaultMethodRecognized() throws TemplateModelException { + DefaultObjectWrapper.Builder owb = new DefaultObjectWrapper.Builder(Configuration.VERSION_3_0_0); + DefaultObjectWrapper ow = owb.build(); + TemplateHashModel wrappedBean = (TemplateHashModel) ow.wrap(new Java8DefaultMethodsBean()); + + { + TemplateScalarModel prop = (TemplateScalarModel) wrappedBean.get(Java8DefaultMethodsBean.NORMAL_PROP); + assertNotNull(prop); + assertEquals(Java8DefaultMethodsBean.NORMAL_PROP_VALUE, prop.getAsString()); + } + { + // This is overridden in the subclass, so it's visible even without default method support: + TemplateScalarModel prop = (TemplateScalarModel) wrappedBean.get( + Java8DefaultMethodsBean.DEFAULT_METHOD_PROP_2); + assertNotNull(prop); + assertEquals(Java8DefaultMethodsBean.PROP_2_OVERRIDE_VALUE, prop.getAsString()); + } + { + TemplateScalarModel prop = (TemplateScalarModel) wrappedBean.get( + Java8DefaultMethodsBeanBase.DEFAULT_METHOD_PROP); + assertNotNull(prop); + assertEquals(Java8DefaultMethodsBeanBase.DEFAULT_METHOD_PROP_VALUE, prop.getAsString()); + } + { + // Has only indexed read method, so it's not exposed as a property + assertNull(wrappedBean.get(Java8DefaultMethodsBeanBase.DEFAULT_METHOD_INDEXED_PROP)); + + TemplateMethodModelEx indexedReadMethod = (TemplateMethodModelEx) wrappedBean.get( + Java8DefaultMethodsBeanBase.DEFAULT_METHOD_INDEXED_PROP_GETTER); + assertNotNull(indexedReadMethod); + assertEquals(Java8DefaultMethodsBeanBase.DEFAULT_METHOD_INDEXED_PROP_VALUE, + ((TemplateScalarModel) indexedReadMethod.exec(Collections.singletonList(new SimpleNumber(0)))) + .getAsString + ()); + } + { + // We see default method indexed read method, but it's invalidated by normal getter in the subclass + TemplateNumberModel prop = (TemplateNumberModel) wrappedBean.get( + Java8DefaultMethodsBean.DEFAULT_METHOD_NOT_AN_INDEXED_PROP); + assertNotNull(prop); + assertEquals(Java8DefaultMethodsBean.NOT_AN_INDEXED_PROP_VALUE, prop.getAsNumber()); + } + { + // The default method read method invalidates the indexed read method in the subclass + TemplateScalarModel prop = (TemplateScalarModel) wrappedBean.get( + Java8DefaultMethodsBean.DEFAULT_METHOD_NOT_AN_INDEXED_PROP_2); + assertNotNull(prop); + assertEquals(Java8DefaultMethodsBean.DEFAULT_METHOD_NOT_AN_INDEXED_PROP_2_VALUE, prop.getAsString()); + } + { + // The default method read method invalidates the indexed read method in the subclass + TemplateSequenceModel prop = (TemplateSequenceModel) wrappedBean.get( + Java8DefaultMethodsBean.DEFAULT_METHOD_NOT_AN_INDEXED_PROP_3); + assertNotNull(prop); + assertEquals(Java8DefaultMethodsBean.DEFAULT_METHOD_NOT_AN_INDEXED_PROP_3_VALUE_0, + ((TemplateScalarModel) prop.get(0)).getAsString()); + } + { + // We see the default method indexed reader, which overrides the plain array reader in the subclass. + TemplateSequenceModel prop = (TemplateSequenceModel) wrappedBean.get( + Java8DefaultMethodsBean.DEFAULT_METHOD_INDEXED_PROP_2); + assertNotNull(prop); + assertEquals(Java8DefaultMethodsBean.ARRAY_PROP_2_VALUE_0, + ((TemplateScalarModel) prop.get(0)).getAsString()); + } + { + // We do see the default method non-indexed reader, but the subclass has a matching indexed reader, so that + // takes over. + TemplateSequenceModel prop = (TemplateSequenceModel) wrappedBean.get( + Java8DefaultMethodsBean.DEFAULT_METHOD_INDEXED_PROP_3); + assertNotNull(prop); + assertEquals(Java8DefaultMethodsBeanBase.DEFAULT_METHOD_INDEXED_PROP_3_VALUE_0, + ((TemplateScalarModel) prop.get(0)).getAsString()); + } + { + // Only present in the subclass. + + // Has only indexed read method, so it's not exposed as a property + assertNull(wrappedBean.get(Java8DefaultMethodsBean.INDEXED_PROP_4)); + + TemplateMethodModelEx indexedReadMethod = (TemplateMethodModelEx) wrappedBean.get( + Java8DefaultMethodsBean.INDEXED_PROP_GETTER_4); + assertNotNull(indexedReadMethod); + assertEquals(Java8DefaultMethodsBean.INDEXED_PROP_4_VALUE, + ((TemplateScalarModel) indexedReadMethod.exec(Collections.singletonList(new SimpleNumber(0)))) + .getAsString()); + } + { + TemplateMethodModelEx action = (TemplateMethodModelEx) wrappedBean.get( + Java8DefaultMethodsBean.NORMAL_ACTION); + assertNotNull(action); + assertEquals( + Java8DefaultMethodsBean.NORMAL_ACTION_RETURN_VALUE, + ((TemplateScalarModel) action.exec(Collections.emptyList())).getAsString()); + } + + { + TemplateMethodModelEx action = (TemplateMethodModelEx) wrappedBean.get( + Java8DefaultMethodsBean.NORMAL_ACTION); + assertNotNull(action); + assertEquals( + Java8DefaultMethodsBean.NORMAL_ACTION_RETURN_VALUE, + ((TemplateScalarModel) action.exec(Collections.emptyList())).getAsString()); + } + { + TemplateMethodModelEx action = (TemplateMethodModelEx) wrappedBean.get( + Java8DefaultMethodsBean.DEFAULT_METHOD_ACTION); + assertNotNull(action); + assertEquals( + Java8DefaultMethodsBean.DEFAULT_METHOD_ACTION_RETURN_VALUE, + ((TemplateScalarModel) action.exec(Collections.emptyList())).getAsString()); + } + { + TemplateMethodModelEx action = (TemplateMethodModelEx) wrappedBean.get( + Java8DefaultMethodsBean.OVERRIDDEN_DEFAULT_METHOD_ACTION); + assertNotNull(action); + assertEquals( + Java8DefaultMethodsBean.OVERRIDDEN_DEFAULT_METHOD_ACTION_RETURN_VALUE, + ((TemplateScalarModel) action.exec(Collections.emptyList())).getAsString()); + } + } + +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3fd56062/freemarker-core/build.gradle ---------------------------------------------------------------------- diff --git a/freemarker-core/build.gradle b/freemarker-core/build.gradle new file mode 100644 index 0000000..3419439 --- /dev/null +++ b/freemarker-core/build.gradle @@ -0,0 +1,155 @@ +/* + * 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. + */ + +plugins { + id "ca.coglinc.javacc" version "2.4.0" +} + +String moduleNiceName = "Apache FreeMarker Core" + +dependencies { + // Note that commond dependencies are added in the root project. + + // ------------------------------------------------------------------------ + // For the main artifact + + compileOnly "org.zeroturnaround:javarebel-sdk:1.2.2" + + // TODO These will be moved to freemarker-dom module: + + compileOnly "jaxen:jaxen:1.0-FCS" + compileOnly "saxpath:saxpath:1.0-FCS" + compileOnly("xalan:xalan:2.7.0") { + // xml-apis is part of Java SE since version 1.4: + exclude group: "xml-apis", module: "xml-apis" + } + + testRuntime "jaxen:jaxen:1.0-FCS" + testRuntime "saxpath:saxpath:1.0-FCS" + testRuntime("xalan:xalan:2.7.0") { + // xml-apis is part of Java SE since version 1.4: + exclude group: "xml-apis", module: "xml-apis" + } + +} + +compileJavacc { + arguments = [ grammar_encoding: "UTF-8" ] + outputDirectory = new File(outputDirectory, 'org/apache/freemarker/core') + doLast { + ant.replace( + file: "${outputDirectory}/FMParser.java", + token: "public class FMParser", + value: "class FMParser" + ) + ant.replace( + file: "${outputDirectory}/FMParser.java", + token: "private final LookaheadSuccess", + value: "private static final LookaheadSuccess" + ) + ant.replace( + file: "${outputDirectory}/FMParserConstants.java", + token: "public interface FMParserConstants", + value: "interface FMParserConstants" + ) + ant.replace( + file: "${outputDirectory}/FMParserTokenManager.java", + token: "public class FMParserTokenManager", + value: "class FMParserTokenManager" + ) + ant.replace( + file: "${outputDirectory}/Token.java", + token: "public class Token", + value: "class Token" + ) + ant.replace( + file: "${outputDirectory}/SimpleCharStream.java", + token: "public class SimpleCharStream", + value: "class SimpleCharStream" + ) + + // Note: The Gradle JavaCC plugin automatically removes generated java files that are already in + // src/main/java, so we don't need to get rid of ParseException.java and TokenMgrError.java (unlike in Ant) + } +} +sourceSets.main.java.srcDir new File(buildDir, 'generated/javacc') // Wasn't needed for the build, but for IDE-s +idea { + module { + generatedSourceDirs += file('build/generated/javacc') // Marks the already(!) added srcDir as "generated" + } +} + +jar { + manifest { + // TODO Import exclusions has to be adjusted as we factor out to external modules! + instructionReplace 'Import-Package', '!org.apache.freemarker.*', 'org.slf4j.*', '*;resolution:="optional"' + // The above makes all imports optional (like servlet API-s, etc.), + // except those that were explicitly listed (or are inside java.*). + // Thus, even when the Java platfrom includes a package, it won't + // be automatically imported, unless bnd generates the import statement + // for them. + + // This is needed for "a.class.from.another.Bundle"?new() to work. + instructionReplace 'DynamicImport-Package', '*' + + // The required minimum is 1.7, but we utilize 1.8 if available. + // See also: http://wiki.eclipse.org/Execution_Environments, "Compiling + // against more than is required" + instructionReplace 'Bundle-RequiredExecutionEnvironment', 'JavaSE-1.8, JavaSE-1.7' + // TODO is this the right way in Require-Capability to specify a version range? + instructionReplace 'Require-Capability', 'osgi.ee;filter:="(&(osgi.ee=JavaSE)(version>=1.7))"' + + attributes( + "Extension-name": moduleNiceName, + "Specification-Title": moduleNiceName, + "Implementation-Title": moduleNiceName + ) + } +} + +javadoc { + title "${moduleNiceName} ${versionCanonical} API" +} + +// The identical parts of Maven "deployer" and "installer" configuration: +def mavenCommons = { callerDelegate -> + delegate = callerDelegate + + pom.project { + description( + "FreeMarker template engine, core module. This module covers all basic functionality, " + + "and is all that's needed for many applications.") + } +} + +uploadArchives { + repositories { + mavenDeployer { + mavenCommons(delegate) + } + } +} + +install { + repositories { + mavenInstaller { + mavenCommons(delegate) + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3fd56062/freemarker-core/src/dist/bin/LICENSE ---------------------------------------------------------------------- diff --git a/freemarker-core/src/dist/bin/LICENSE b/freemarker-core/src/dist/bin/LICENSE new file mode 100644 index 0000000..a0f6dc4 --- /dev/null +++ b/freemarker-core/src/dist/bin/LICENSE @@ -0,0 +1,232 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. + +========================================================================= + +The documentation includes a selection of icons from various icon sets +(fonts), stored together inside these files, which were geneated with +https://icomoon.io/app/: + + documentation/_html/docgen-resources/fonts/icomoon.eot + documentation/_html/docgen-resources/fonts/icomoon.svg + documentation/_html/docgen-resources/fonts/icomoon.ttf + documentation/_html/docgen-resources/fonts/icomoon.woff + +The name, license, and attribution of each icon sets (fonts) used follows: + +- The documentation includes icons from Entypo pictograms, version 2.0, + by Daniel Bruce (http://www.entypo.com/, http://www.danielbruce.se/), + licensed under Creative Commons Attribution-ShareAlike 3.0 (CC BY-SA 3.0) + (http://creativecommons.org/licenses/by-sa/3.0/legalcode) and under SIL + Open Font License 1.1 (http://scripts.sil.org/OFL). + +- The documentation includes icons from Font Awesome by Dave Gandy + (http://fontawesome.io), licensed under SIL Open Font License 1.1 + (http://scripts.sil.org/OFL). + +- The documentation includes icons from Material Design icons by Google + (http://google.github.io/material-design-icons/), licensed under + Creative Common Attribution 4.0 International License (CC-BY 4.0) + (https://creativecommons.org/licenses/by/4.0/). + +========================================================================= http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3fd56062/freemarker-core/src/dist/bin/documentation/index.html ---------------------------------------------------------------------- diff --git a/freemarker-core/src/dist/bin/documentation/index.html b/freemarker-core/src/dist/bin/documentation/index.html new file mode 100644 index 0000000..a482423 --- /dev/null +++ b/freemarker-core/src/dist/bin/documentation/index.html @@ -0,0 +1,67 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- + 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. +--> + +<html lang="hu"> + +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Script-Type" content="text/javascript"> + <title>FreeMarker Documention</title> + <style type="text/css"> + body { + background: #FFF; + padding: 2em; + color: #000000; + font-family: Arial,sans-serif; + font-size: 16px; + } + h1 { + font-size: 166%; + margin-top: 1.5em; + margin-bottom: 0.75em; + color: #0050B2; + font-family: Arial,sans-serif; + font-weight: bold; + } + .top { + margin-top: 0; + } + a:link, + a:visited, + a:hover, + a:active { + color:#00C; + text-decoration: none; + } + </style> +</head> + +<body> + <p class="top">Offline FreeMarker Documentation:</p> + <ul> + <li><a href="_html/index.html">Manual</a></li> + <li><a href="_html/api/index.html">Java API</a></li> + </ul> + + <p><a href="http://freemarker.org/">Visit the FreeMarker home page</a> (help, editor plugins, latest downloads, etc.)</p> + + <p><i><b>Disclaimer:</b> Apache FreeMarker is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.</i></p> +</body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3fd56062/freemarker-core/src/dist/javadoc/META-INF/LICENSE ---------------------------------------------------------------------- diff --git a/freemarker-core/src/dist/javadoc/META-INF/LICENSE b/freemarker-core/src/dist/javadoc/META-INF/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/freemarker-core/src/dist/javadoc/META-INF/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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.
