You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2012/07/06 12:51:21 UTC
svn commit: r1358111 [10/13] - in
/incubator/isis/trunk/framework/core/commons: ./
src/main/java/org/apache/isis/core/commons/authentication/
src/main/java/org/apache/isis/core/commons/components/
src/main/java/org/apache/isis/core/commons/config/ src/...
Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/package-info.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/package-info.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/package-info.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/lang/package-info.java Fri Jul 6 10:51:16 2012
@@ -1,27 +1,27 @@
-/*
- * 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.
- */
-
-/**
- * This package holds a small number of classes to extend the JDK.
- *
- * <p>
- * These classes should be thought of as being in the same spirit as
- * the google <i>guava</i> library helper classes (and some may be replaced by guava in the future).
- */
+/*
+ * 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.
+ */
+
+/**
+ * This package holds a small number of classes to extend the JDK.
+ *
+ * <p>
+ * These classes should be thought of as being in the same spirit as
+ * the google <i>guava</i> library helper classes (and some may be replaced by guava in the future).
+ */
package org.apache.isis.core.commons.lang;
\ No newline at end of file
Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/matchers/IsisMatchers.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/matchers/IsisMatchers.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/matchers/IsisMatchers.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/matchers/IsisMatchers.java Fri Jul 6 10:51:16 2012
@@ -1,375 +1,375 @@
-/*
- * 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.isis.core.commons.matchers;
-
-import static org.hamcrest.CoreMatchers.nullValue;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.Description;
-import org.hamcrest.Factory;
-import org.hamcrest.Matcher;
-import org.hamcrest.TypeSafeMatcher;
-import org.hamcrest.core.IsEqual;
-import org.hamcrest.number.IsGreaterThan;
-import org.hamcrest.text.StringContains;
-import org.hamcrest.text.StringEndsWith;
-import org.hamcrest.text.StringStartsWith;
-
-import org.apache.isis.core.commons.lang.StringUtils;
-
-/**
- * Hamcrest {@link Matcher} implementations.
- *
- */
-public final class IsisMatchers {
-
- private IsisMatchers() {
- }
-
- @Factory
- public static Matcher<String> containsStripNewLines(final String expected) {
- final String strippedExpected = StringUtils.stripNewLines(expected);
- return new StringContains(strippedExpected) {
- @Override
- public boolean matchesSafely(final String actual) {
- return super.matchesSafely(StringUtils.stripNewLines(actual));
- }
-
- @Override
- public void describeTo(final Description description) {
- description.appendText("a string (ignoring new lines) containing").appendValue(strippedExpected);
- }
- };
- }
-
- @Factory
- public static Matcher<String> equalToStripNewLines(final String expected) {
- final String strippedExpected = StringUtils.stripNewLines(expected);
- return new IsEqual<String>(strippedExpected) {
- @Override
- public boolean matches(final Object actualObj) {
- final String actual = (String) actualObj;
- return super.matches(StringUtils.stripNewLines(actual));
- }
-
- @Override
- public void describeTo(final Description description) {
- description.appendText("a string (ignoring new lines) equal to").appendValue(strippedExpected);
- }
- };
- }
-
- @Factory
- public static Matcher<String> startsWithStripNewLines(final String expected) {
- final String strippedExpected = StringUtils.stripNewLines(expected);
- return new StringStartsWith(strippedExpected) {
- @Override
- public boolean matchesSafely(final String actual) {
- return super.matchesSafely(StringUtils.stripNewLines(actual));
- }
-
- @Override
- public void describeTo(final Description description) {
- description.appendText("a string (ignoring new lines) starting with").appendValue(strippedExpected);
- }
- };
- }
-
- @Factory
- public static Matcher<String> endsWithStripNewLines(final String expected) {
- final String strippedExpected = StringUtils.stripNewLines(expected);
- return new StringEndsWith(strippedExpected) {
- @Override
- public boolean matchesSafely(final String actual) {
- return super.matchesSafely(StringUtils.stripNewLines(actual));
- }
-
- @Override
- public void describeTo(final Description description) {
- description.appendText("a string (ignoring new lines) ending with").appendValue(strippedExpected);
- }
- };
- }
-
- @Factory
- public static <T> Matcher<T> anInstanceOf(final Class<T> expected) {
- return new TypeSafeMatcher<T>() {
- @Override
- public boolean matchesSafely(final T actual) {
- return expected.isAssignableFrom(actual.getClass());
- }
-
- @Override
- public void describeTo(final Description description) {
- description.appendText("an instance of ").appendValue(expected);
- }
- };
- }
-
- @Factory
- public static Matcher<String> nonEmptyString() {
- return new TypeSafeMatcher<String>() {
- @Override
- public boolean matchesSafely(final String str) {
- return str != null && str.length() > 0;
- }
-
- @Override
- public void describeTo(final Description description) {
- description.appendText("a non empty string");
- }
-
- };
- }
-
- @Factory
- @SuppressWarnings("unchecked")
- public static Matcher<String> nonEmptyStringOrNull() {
- return CoreMatchers.anyOf(nullValue(String.class), nonEmptyString());
- }
-
- @Factory
- public static Matcher<List<?>> containsElementThat(final Matcher<?> elementMatcher) {
- return new TypeSafeMatcher<List<?>>() {
- @Override
- public boolean matchesSafely(final List<?> list) {
- for (final Object o : list) {
- if (elementMatcher.matches(o)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public void describeTo(final Description description) {
- description.appendText("contains element that ").appendDescriptionOf(elementMatcher);
- }
- };
- }
-
- @Factory
- public static <T extends Comparable<T>> Matcher<T> greaterThan(final T c) {
- return new IsGreaterThan<T>(c);
- }
-
- @Factory
- public static Matcher<Class<?>> classEqualTo(final Class<?> operand) {
-
- class ClassEqualsMatcher extends TypeSafeMatcher<Class<?>> {
- private final Class<?> clazz;
-
- public ClassEqualsMatcher(final Class<?> clazz) {
- this.clazz = clazz;
- }
-
- @Override
- public boolean matchesSafely(final Class<?> arg) {
- return clazz == arg;
- }
-
- @Override
- public void describeTo(final Description description) {
- description.appendValue(clazz);
- }
- }
-
- return new ClassEqualsMatcher(operand);
- }
-
- @Factory
- public static Matcher<File> existsAndNotEmpty() {
-
- return new TypeSafeMatcher<File>() {
-
- @Override
- public void describeTo(final Description arg0) {
- arg0.appendText("exists and is not empty");
- }
-
- @Override
- public boolean matchesSafely(final File f) {
- return f.exists() && f.length() > 0;
- }
- };
- }
-
- @Factory
- public static Matcher<String> matches(final String regex) {
- return new TypeSafeMatcher<String>() {
-
- @Override
- public void describeTo(final Description description) {
- description.appendText("string matching " + regex);
- }
-
- @Override
- public boolean matchesSafely(final String str) {
- return str.matches(regex);
- }
- };
- }
-
- @Factory
- public static <X> Matcher<Class<X>> anySubclassOf(final Class<X> cls) {
- return new TypeSafeMatcher<Class<X>>() {
-
- @Override
- public void describeTo(final Description arg0) {
- arg0.appendText("is subclass of ").appendText(cls.getName());
- }
-
- @Override
- public boolean matchesSafely(final Class<X> item) {
- return cls.isAssignableFrom(item);
- }
- };
- }
-
- @Factory
- public static <T> Matcher<List<T>> sameContentsAs(final List<T> expected) {
- return new TypeSafeMatcher<List<T>>() {
-
- @Override
- public void describeTo(final Description description) {
- description.appendText("same sequence as " + expected);
- }
-
- @Override
- public boolean matchesSafely(final List<T> actual) {
- return actual.containsAll(expected) && expected.containsAll(actual);
- }
- };
- }
-
- @Factory
- public static <T> Matcher<List<T>> listContaining(final T t) {
- return new TypeSafeMatcher<List<T>>() {
-
- @Override
- public void describeTo(Description arg0) {
- arg0.appendText("list containing ").appendValue(t);
- }
-
- @Override
- public boolean matchesSafely(List<T> arg0) {
- return arg0.contains(t);
- }
- };
- }
-
- @Factory
- public static <T> Matcher<List<T>> listContainingAll(final T... items) {
- return new TypeSafeMatcher<List<T>>() {
-
- @Override
- public void describeTo(Description arg0) {
- arg0.appendText("has items ").appendValue(items);
-
- }
-
- @Override
- public boolean matchesSafely(List<T> arg0) {
- return arg0.containsAll(Arrays.asList(items));
- }
- };
- }
-
- @Factory
- public static Matcher<List<Object>> containsObjectOfType(final Class<?> cls) {
- return new TypeSafeMatcher<List<Object>>() {
-
- @Override
- public void describeTo(final Description desc) {
- desc.appendText("contains instance of type " + cls.getName());
- }
-
- @Override
- public boolean matchesSafely(final List<Object> items) {
- for (final Object object : items) {
- if (cls.isAssignableFrom(object.getClass())) {
- return true;
- }
- }
- return false;
- }
- };
- }
-
- @Factory
- public static Matcher<String> startsWith(final String expected) {
- return new TypeSafeMatcher<String>() {
-
- @Override
- public void describeTo(Description description) {
- description.appendText(" starts with '" + expected + "'");
- }
-
- @Override
- public boolean matchesSafely(String actual) {
- return actual.startsWith(expected);
- }
- };
- }
-
- @Factory
- public static Matcher<String> contains(final String expected) {
- return new TypeSafeMatcher<String>() {
-
- @Override
- public void describeTo(Description description) {
- description.appendText(" contains '" + expected + "'");
- }
-
- @Override
- public boolean matchesSafely(String actual) {
- return actual.contains(expected);
- }
- };
- }
-
-
- @Factory
- public static Matcher<File> equalsFile(final File file) throws IOException {
- final String canonicalPath = file.getCanonicalPath();
- return new TypeSafeMatcher<File>() {
-
- @Override
- public void describeTo(Description arg0) {
- arg0.appendText("file '" + canonicalPath + "'");
- }
-
- @Override
- public boolean matchesSafely(File arg0) {
- try {
- return arg0.getCanonicalPath().equals(canonicalPath);
- } catch (IOException e) {
- return false;
- }
- }
- };
- }
-
-}
+/*
+ * 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.isis.core.commons.matchers;
+
+import static org.hamcrest.CoreMatchers.nullValue;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.Description;
+import org.hamcrest.Factory;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+import org.hamcrest.core.IsEqual;
+import org.hamcrest.number.IsGreaterThan;
+import org.hamcrest.text.StringContains;
+import org.hamcrest.text.StringEndsWith;
+import org.hamcrest.text.StringStartsWith;
+
+import org.apache.isis.core.commons.lang.StringUtils;
+
+/**
+ * Hamcrest {@link Matcher} implementations.
+ *
+ */
+public final class IsisMatchers {
+
+ private IsisMatchers() {
+ }
+
+ @Factory
+ public static Matcher<String> containsStripNewLines(final String expected) {
+ final String strippedExpected = StringUtils.stripNewLines(expected);
+ return new StringContains(strippedExpected) {
+ @Override
+ public boolean matchesSafely(final String actual) {
+ return super.matchesSafely(StringUtils.stripNewLines(actual));
+ }
+
+ @Override
+ public void describeTo(final Description description) {
+ description.appendText("a string (ignoring new lines) containing").appendValue(strippedExpected);
+ }
+ };
+ }
+
+ @Factory
+ public static Matcher<String> equalToStripNewLines(final String expected) {
+ final String strippedExpected = StringUtils.stripNewLines(expected);
+ return new IsEqual<String>(strippedExpected) {
+ @Override
+ public boolean matches(final Object actualObj) {
+ final String actual = (String) actualObj;
+ return super.matches(StringUtils.stripNewLines(actual));
+ }
+
+ @Override
+ public void describeTo(final Description description) {
+ description.appendText("a string (ignoring new lines) equal to").appendValue(strippedExpected);
+ }
+ };
+ }
+
+ @Factory
+ public static Matcher<String> startsWithStripNewLines(final String expected) {
+ final String strippedExpected = StringUtils.stripNewLines(expected);
+ return new StringStartsWith(strippedExpected) {
+ @Override
+ public boolean matchesSafely(final String actual) {
+ return super.matchesSafely(StringUtils.stripNewLines(actual));
+ }
+
+ @Override
+ public void describeTo(final Description description) {
+ description.appendText("a string (ignoring new lines) starting with").appendValue(strippedExpected);
+ }
+ };
+ }
+
+ @Factory
+ public static Matcher<String> endsWithStripNewLines(final String expected) {
+ final String strippedExpected = StringUtils.stripNewLines(expected);
+ return new StringEndsWith(strippedExpected) {
+ @Override
+ public boolean matchesSafely(final String actual) {
+ return super.matchesSafely(StringUtils.stripNewLines(actual));
+ }
+
+ @Override
+ public void describeTo(final Description description) {
+ description.appendText("a string (ignoring new lines) ending with").appendValue(strippedExpected);
+ }
+ };
+ }
+
+ @Factory
+ public static <T> Matcher<T> anInstanceOf(final Class<T> expected) {
+ return new TypeSafeMatcher<T>() {
+ @Override
+ public boolean matchesSafely(final T actual) {
+ return expected.isAssignableFrom(actual.getClass());
+ }
+
+ @Override
+ public void describeTo(final Description description) {
+ description.appendText("an instance of ").appendValue(expected);
+ }
+ };
+ }
+
+ @Factory
+ public static Matcher<String> nonEmptyString() {
+ return new TypeSafeMatcher<String>() {
+ @Override
+ public boolean matchesSafely(final String str) {
+ return str != null && str.length() > 0;
+ }
+
+ @Override
+ public void describeTo(final Description description) {
+ description.appendText("a non empty string");
+ }
+
+ };
+ }
+
+ @Factory
+ @SuppressWarnings("unchecked")
+ public static Matcher<String> nonEmptyStringOrNull() {
+ return CoreMatchers.anyOf(nullValue(String.class), nonEmptyString());
+ }
+
+ @Factory
+ public static Matcher<List<?>> containsElementThat(final Matcher<?> elementMatcher) {
+ return new TypeSafeMatcher<List<?>>() {
+ @Override
+ public boolean matchesSafely(final List<?> list) {
+ for (final Object o : list) {
+ if (elementMatcher.matches(o)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void describeTo(final Description description) {
+ description.appendText("contains element that ").appendDescriptionOf(elementMatcher);
+ }
+ };
+ }
+
+ @Factory
+ public static <T extends Comparable<T>> Matcher<T> greaterThan(final T c) {
+ return new IsGreaterThan<T>(c);
+ }
+
+ @Factory
+ public static Matcher<Class<?>> classEqualTo(final Class<?> operand) {
+
+ class ClassEqualsMatcher extends TypeSafeMatcher<Class<?>> {
+ private final Class<?> clazz;
+
+ public ClassEqualsMatcher(final Class<?> clazz) {
+ this.clazz = clazz;
+ }
+
+ @Override
+ public boolean matchesSafely(final Class<?> arg) {
+ return clazz == arg;
+ }
+
+ @Override
+ public void describeTo(final Description description) {
+ description.appendValue(clazz);
+ }
+ }
+
+ return new ClassEqualsMatcher(operand);
+ }
+
+ @Factory
+ public static Matcher<File> existsAndNotEmpty() {
+
+ return new TypeSafeMatcher<File>() {
+
+ @Override
+ public void describeTo(final Description arg0) {
+ arg0.appendText("exists and is not empty");
+ }
+
+ @Override
+ public boolean matchesSafely(final File f) {
+ return f.exists() && f.length() > 0;
+ }
+ };
+ }
+
+ @Factory
+ public static Matcher<String> matches(final String regex) {
+ return new TypeSafeMatcher<String>() {
+
+ @Override
+ public void describeTo(final Description description) {
+ description.appendText("string matching " + regex);
+ }
+
+ @Override
+ public boolean matchesSafely(final String str) {
+ return str.matches(regex);
+ }
+ };
+ }
+
+ @Factory
+ public static <X> Matcher<Class<X>> anySubclassOf(final Class<X> cls) {
+ return new TypeSafeMatcher<Class<X>>() {
+
+ @Override
+ public void describeTo(final Description arg0) {
+ arg0.appendText("is subclass of ").appendText(cls.getName());
+ }
+
+ @Override
+ public boolean matchesSafely(final Class<X> item) {
+ return cls.isAssignableFrom(item);
+ }
+ };
+ }
+
+ @Factory
+ public static <T> Matcher<List<T>> sameContentsAs(final List<T> expected) {
+ return new TypeSafeMatcher<List<T>>() {
+
+ @Override
+ public void describeTo(final Description description) {
+ description.appendText("same sequence as " + expected);
+ }
+
+ @Override
+ public boolean matchesSafely(final List<T> actual) {
+ return actual.containsAll(expected) && expected.containsAll(actual);
+ }
+ };
+ }
+
+ @Factory
+ public static <T> Matcher<List<T>> listContaining(final T t) {
+ return new TypeSafeMatcher<List<T>>() {
+
+ @Override
+ public void describeTo(Description arg0) {
+ arg0.appendText("list containing ").appendValue(t);
+ }
+
+ @Override
+ public boolean matchesSafely(List<T> arg0) {
+ return arg0.contains(t);
+ }
+ };
+ }
+
+ @Factory
+ public static <T> Matcher<List<T>> listContainingAll(final T... items) {
+ return new TypeSafeMatcher<List<T>>() {
+
+ @Override
+ public void describeTo(Description arg0) {
+ arg0.appendText("has items ").appendValue(items);
+
+ }
+
+ @Override
+ public boolean matchesSafely(List<T> arg0) {
+ return arg0.containsAll(Arrays.asList(items));
+ }
+ };
+ }
+
+ @Factory
+ public static Matcher<List<Object>> containsObjectOfType(final Class<?> cls) {
+ return new TypeSafeMatcher<List<Object>>() {
+
+ @Override
+ public void describeTo(final Description desc) {
+ desc.appendText("contains instance of type " + cls.getName());
+ }
+
+ @Override
+ public boolean matchesSafely(final List<Object> items) {
+ for (final Object object : items) {
+ if (cls.isAssignableFrom(object.getClass())) {
+ return true;
+ }
+ }
+ return false;
+ }
+ };
+ }
+
+ @Factory
+ public static Matcher<String> startsWith(final String expected) {
+ return new TypeSafeMatcher<String>() {
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText(" starts with '" + expected + "'");
+ }
+
+ @Override
+ public boolean matchesSafely(String actual) {
+ return actual.startsWith(expected);
+ }
+ };
+ }
+
+ @Factory
+ public static Matcher<String> contains(final String expected) {
+ return new TypeSafeMatcher<String>() {
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText(" contains '" + expected + "'");
+ }
+
+ @Override
+ public boolean matchesSafely(String actual) {
+ return actual.contains(expected);
+ }
+ };
+ }
+
+
+ @Factory
+ public static Matcher<File> equalsFile(final File file) throws IOException {
+ final String canonicalPath = file.getCanonicalPath();
+ return new TypeSafeMatcher<File>() {
+
+ @Override
+ public void describeTo(Description arg0) {
+ arg0.appendText("file '" + canonicalPath + "'");
+ }
+
+ @Override
+ public boolean matchesSafely(File arg0) {
+ try {
+ return arg0.getCanonicalPath().equals(canonicalPath);
+ } catch (IOException e) {
+ return false;
+ }
+ }
+ };
+ }
+
+}
Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/matchers/package-info.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/matchers/package-info.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/matchers/package-info.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/matchers/package-info.java Fri Jul 6 10:51:16 2012
@@ -1,24 +1,24 @@
-/*
- * 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.
- */
-
-/**
- * Provides a set of Hamcrest {@link org.hamcrest.Matcher}s for various
- * purposes.
- */
+/*
+ * 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.
+ */
+
+/**
+ * Provides a set of Hamcrest {@link org.hamcrest.Matcher}s for various
+ * purposes.
+ */
package org.apache.isis.core.commons.matchers;
\ No newline at end of file
Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSource.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSource.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSource.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSource.java Fri Jul 6 10:51:16 2012
@@ -1,41 +1,41 @@
-/*
- * 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.isis.core.commons.resource;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public interface ResourceStreamSource {
-
- /**
- * Returns an {@link InputStream} opened for the resource path, or
- * <tt>null</tt> otherwise.
- */
- public InputStream readResource(String resourcePath);
-
- /**
- * Returns an {@link OutputStream} opened to write to the resource, or
- * <tt>null</tt> otherwise.
- */
- public OutputStream writeResource(String resourcePath);
-
- public String getName();
-
-}
+/*
+ * 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.isis.core.commons.resource;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public interface ResourceStreamSource {
+
+ /**
+ * Returns an {@link InputStream} opened for the resource path, or
+ * <tt>null</tt> otherwise.
+ */
+ public InputStream readResource(String resourcePath);
+
+ /**
+ * Returns an {@link OutputStream} opened to write to the resource, or
+ * <tt>null</tt> otherwise.
+ */
+ public OutputStream writeResource(String resourcePath);
+
+ public String getName();
+
+}
Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceAbstract.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceAbstract.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceAbstract.java Fri Jul 6 10:51:16 2012
@@ -1,69 +1,69 @@
-/*
- * 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.isis.core.commons.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.log4j.Logger;
-
-public abstract class ResourceStreamSourceAbstract implements ResourceStreamSource {
-
- private static Logger LOG = Logger.getLogger(ResourceStreamSourceAbstract.class);
-
- @Override
- public final InputStream readResource(final String resourcePath) {
-
- try {
- final InputStream resourceStream = doReadResource(resourcePath);
- if (resourceStream != null) {
- return resourceStream;
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("could not load resource path '" + resourcePath + "' from " + getName());
- }
- } catch (final IOException e) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("could not load resource path '" + resourcePath + "' from " + getName() + ", exception: " + e.getMessage());
- }
- }
- return null;
- }
-
- /**
- * Mandatory hook method; subclasses can return either <tt>null</tt> or
- * throw an exception if the resource could not be found.
- */
- protected abstract InputStream doReadResource(String resourcePath) throws IOException;
-
- /**
- * Default implementation returns <tt>null</tt> (that is, not supported).
- */
- @Override
- public OutputStream writeResource(final String resourcePath) {
- return null;
- }
-
- @Override
- public String toString() {
- return getName();
- }
-}
+/*
+ * 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.isis.core.commons.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.log4j.Logger;
+
+public abstract class ResourceStreamSourceAbstract implements ResourceStreamSource {
+
+ private static Logger LOG = Logger.getLogger(ResourceStreamSourceAbstract.class);
+
+ @Override
+ public final InputStream readResource(final String resourcePath) {
+
+ try {
+ final InputStream resourceStream = doReadResource(resourcePath);
+ if (resourceStream != null) {
+ return resourceStream;
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("could not load resource path '" + resourcePath + "' from " + getName());
+ }
+ } catch (final IOException e) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("could not load resource path '" + resourcePath + "' from " + getName() + ", exception: " + e.getMessage());
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Mandatory hook method; subclasses can return either <tt>null</tt> or
+ * throw an exception if the resource could not be found.
+ */
+ protected abstract InputStream doReadResource(String resourcePath) throws IOException;
+
+ /**
+ * Default implementation returns <tt>null</tt> (that is, not supported).
+ */
+ @Override
+ public OutputStream writeResource(final String resourcePath) {
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
+}
Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceComposite.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceComposite.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceComposite.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceComposite.java Fri Jul 6 10:51:16 2012
@@ -1,89 +1,89 @@
-/*
- * 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.isis.core.commons.resource;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-public class ResourceStreamSourceComposite extends ResourceStreamSourceAbstract {
-
- private static Logger LOG = Logger.getLogger(ResourceStreamSourceComposite.class);
-
- private final List<ResourceStreamSource> resourceStreamSources = new ArrayList<ResourceStreamSource>();
-
- public ResourceStreamSourceComposite(final ResourceStreamSource... resourceStreamSources) {
- for (final ResourceStreamSource rss : resourceStreamSources) {
- addResourceStreamSource(rss);
- }
- }
-
- public void addResourceStreamSource(final ResourceStreamSource rss) {
- this.resourceStreamSources.add(rss);
- }
-
- @Override
- protected InputStream doReadResource(final String resourcePath) {
- for (final ResourceStreamSource rss : resourceStreamSources) {
- final InputStream resourceStream = rss.readResource(resourcePath);
- if (resourceStream != null) {
- return resourceStream;
- }
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("could not load resource path '" + resourcePath + "' from " + getName());
- }
- return null;
- }
-
- @Override
- public OutputStream writeResource(final String resourcePath) {
- for (final ResourceStreamSource rss : resourceStreamSources) {
- final OutputStream os = rss.writeResource(resourcePath);
- if (os != null) {
- return os;
- }
- }
- return null;
- }
-
- @Override
- public String getName() {
- return "[" + resourceStreamNames() + "]";
- }
-
- private String resourceStreamNames() {
- final StringBuilder buf = new StringBuilder();
- boolean first = true;
- for (final ResourceStreamSource rss : resourceStreamSources) {
- if (first) {
- first = false;
- } else {
- buf.append(", ");
- }
- buf.append(rss.getName());
- }
- return buf.toString();
- }
-
-}
+/*
+ * 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.isis.core.commons.resource;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+public class ResourceStreamSourceComposite extends ResourceStreamSourceAbstract {
+
+ private static Logger LOG = Logger.getLogger(ResourceStreamSourceComposite.class);
+
+ private final List<ResourceStreamSource> resourceStreamSources = new ArrayList<ResourceStreamSource>();
+
+ public ResourceStreamSourceComposite(final ResourceStreamSource... resourceStreamSources) {
+ for (final ResourceStreamSource rss : resourceStreamSources) {
+ addResourceStreamSource(rss);
+ }
+ }
+
+ public void addResourceStreamSource(final ResourceStreamSource rss) {
+ this.resourceStreamSources.add(rss);
+ }
+
+ @Override
+ protected InputStream doReadResource(final String resourcePath) {
+ for (final ResourceStreamSource rss : resourceStreamSources) {
+ final InputStream resourceStream = rss.readResource(resourcePath);
+ if (resourceStream != null) {
+ return resourceStream;
+ }
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("could not load resource path '" + resourcePath + "' from " + getName());
+ }
+ return null;
+ }
+
+ @Override
+ public OutputStream writeResource(final String resourcePath) {
+ for (final ResourceStreamSource rss : resourceStreamSources) {
+ final OutputStream os = rss.writeResource(resourcePath);
+ if (os != null) {
+ return os;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return "[" + resourceStreamNames() + "]";
+ }
+
+ private String resourceStreamNames() {
+ final StringBuilder buf = new StringBuilder();
+ boolean first = true;
+ for (final ResourceStreamSource rss : resourceStreamSources) {
+ if (first) {
+ first = false;
+ } else {
+ buf.append(", ");
+ }
+ buf.append(rss.getName());
+ }
+ return buf.toString();
+ }
+
+}
Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceContextLoaderClassPath.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceContextLoaderClassPath.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceContextLoaderClassPath.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceContextLoaderClassPath.java Fri Jul 6 10:51:16 2012
@@ -1,62 +1,62 @@
-/*
- * 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.isis.core.commons.resource;
-
-import java.io.InputStream;
-
-import org.apache.isis.core.commons.lang.PathUtils;
-
-/**
- * Loads the properties from the ContextClassLoader.
- *
- * <p>
- * If this class is on the system class path, then the class loader obtained
- * from this.getClassLoader() won't be able to load resources from the
- * application class path.
- */
-public class ResourceStreamSourceContextLoaderClassPath extends ResourceStreamSourceAbstract {
-
- public static ResourceStreamSourceContextLoaderClassPath create() {
- return create("");
- }
-
- public static ResourceStreamSourceContextLoaderClassPath create(final String prefix) {
- return new ResourceStreamSourceContextLoaderClassPath(prefix);
- }
-
- private final String prefix;
-
- private ResourceStreamSourceContextLoaderClassPath(final String prefix) {
- this.prefix = prefix;
- }
-
- @Override
- protected InputStream doReadResource(final String resourcePath) {
- final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- final String path = PathUtils.combine(prefix, resourcePath);
- return classLoader.getResourceAsStream(path);
- }
-
- @Override
- public String getName() {
- return "context loader classpath";
- }
-
-}
+/*
+ * 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.isis.core.commons.resource;
+
+import java.io.InputStream;
+
+import org.apache.isis.core.commons.lang.PathUtils;
+
+/**
+ * Loads the properties from the ContextClassLoader.
+ *
+ * <p>
+ * If this class is on the system class path, then the class loader obtained
+ * from this.getClassLoader() won't be able to load resources from the
+ * application class path.
+ */
+public class ResourceStreamSourceContextLoaderClassPath extends ResourceStreamSourceAbstract {
+
+ public static ResourceStreamSourceContextLoaderClassPath create() {
+ return create("");
+ }
+
+ public static ResourceStreamSourceContextLoaderClassPath create(final String prefix) {
+ return new ResourceStreamSourceContextLoaderClassPath(prefix);
+ }
+
+ private final String prefix;
+
+ private ResourceStreamSourceContextLoaderClassPath(final String prefix) {
+ this.prefix = prefix;
+ }
+
+ @Override
+ protected InputStream doReadResource(final String resourcePath) {
+ final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ final String path = PathUtils.combine(prefix, resourcePath);
+ return classLoader.getResourceAsStream(path);
+ }
+
+ @Override
+ public String getName() {
+ return "context loader classpath";
+ }
+
+}
Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceCurrentClassClassPath.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceCurrentClassClassPath.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceCurrentClassClassPath.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceCurrentClassClassPath.java Fri Jul 6 10:51:16 2012
@@ -1,46 +1,46 @@
-/*
- * 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.isis.core.commons.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Load from this class' ClassLoader.
- *
- * <p>
- * This is useful if (a) the contextClassLoader is not available and (b) the
- * contextClassLoader does not load from this classes ClassLoader (for example
- * when running under Ant while running unit tests as part of an automated
- * build).
- */
-public class ResourceStreamSourceCurrentClassClassPath extends ResourceStreamSourceAbstract {
-
- @Override
- protected InputStream doReadResource(final String resourcePath) throws IOException {
- return getClass().getClassLoader().getResourceAsStream(resourcePath);
- }
-
- @Override
- public String getName() {
- return "current class' classpath";
- }
-
-}
+/*
+ * 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.isis.core.commons.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Load from this class' ClassLoader.
+ *
+ * <p>
+ * This is useful if (a) the contextClassLoader is not available and (b) the
+ * contextClassLoader does not load from this classes ClassLoader (for example
+ * when running under Ant while running unit tests as part of an automated
+ * build).
+ */
+public class ResourceStreamSourceCurrentClassClassPath extends ResourceStreamSourceAbstract {
+
+ @Override
+ protected InputStream doReadResource(final String resourcePath) throws IOException {
+ return getClass().getClassLoader().getResourceAsStream(resourcePath);
+ }
+
+ @Override
+ public String getName() {
+ return "current class' classpath";
+ }
+
+}
Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceFileSystem.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceFileSystem.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceFileSystem.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/ResourceStreamSourceFileSystem.java Fri Jul 6 10:51:16 2012
@@ -1,65 +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.isis.core.commons.resource;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public class ResourceStreamSourceFileSystem extends ResourceStreamSourceAbstract {
-
- /**
- * Factory method to guard against nulls
- */
- public static ResourceStreamSource create(final String directory2) {
- return directory2 != null ? new ResourceStreamSourceFileSystem(directory2) : null;
- }
-
- private final String directory;
-
- public ResourceStreamSourceFileSystem(final String directory) {
- this.directory = directory;
- }
-
- @Override
- protected InputStream doReadResource(final String resourcePath) throws FileNotFoundException {
- final File file = new File(directory, resourcePath);
- return new FileInputStream(file);
- }
-
- @Override
- public OutputStream writeResource(final String resourcePath) {
- final File file = new File(directory, resourcePath);
- try {
- return new FileOutputStream(file);
- } catch (final FileNotFoundException e) {
- return null;
- }
- }
-
- @Override
- public String getName() {
- return "file system (directory '" + directory + "')";
- }
-
-}
+/*
+ * 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.isis.core.commons.resource;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class ResourceStreamSourceFileSystem extends ResourceStreamSourceAbstract {
+
+ /**
+ * Factory method to guard against nulls
+ */
+ public static ResourceStreamSource create(final String directory2) {
+ return directory2 != null ? new ResourceStreamSourceFileSystem(directory2) : null;
+ }
+
+ private final String directory;
+
+ public ResourceStreamSourceFileSystem(final String directory) {
+ this.directory = directory;
+ }
+
+ @Override
+ protected InputStream doReadResource(final String resourcePath) throws FileNotFoundException {
+ final File file = new File(directory, resourcePath);
+ return new FileInputStream(file);
+ }
+
+ @Override
+ public OutputStream writeResource(final String resourcePath) {
+ final File file = new File(directory, resourcePath);
+ try {
+ return new FileOutputStream(file);
+ } catch (final FileNotFoundException e) {
+ return null;
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "file system (directory '" + directory + "')";
+ }
+
+}
Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/package-info.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/package-info.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/package-info.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/resource/package-info.java Fri Jul 6 10:51:16 2012
@@ -1,34 +1,34 @@
-/*
- * 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.
- */
-
-/**
- * Provides an {@link org.apache.isis.core.commons.resource.ResourceStreamSource abstraction}
- * over {@link java.io.InputStream}s for accessing
- * resources.
- *
- * <p>
- * The principle usage is to allow the easy searching of a single resource (eg
- * <tt>isis.properties</tt> file) in {@link org.apache.isis.core.commons.resource.ResourceStreamSourceContextLoaderClassPath multiple}
- * {@link org.apache.isis.core.commons.resource.ResourceStreamSourceCurrentClassClassPath locations}
- * and {@link org.apache.isis.core.commons.resource.ResourceStreamSourceFileSystem technologies}
- * on the classpath through
- * the use of a {@link org.apache.isis.core.commons.resource.ResourceStreamSourceComposite composite}
- * pattern.
- */
+/*
+ * 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.
+ */
+
+/**
+ * Provides an {@link org.apache.isis.core.commons.resource.ResourceStreamSource abstraction}
+ * over {@link java.io.InputStream}s for accessing
+ * resources.
+ *
+ * <p>
+ * The principle usage is to allow the easy searching of a single resource (eg
+ * <tt>isis.properties</tt> file) in {@link org.apache.isis.core.commons.resource.ResourceStreamSourceContextLoaderClassPath multiple}
+ * {@link org.apache.isis.core.commons.resource.ResourceStreamSourceCurrentClassClassPath locations}
+ * and {@link org.apache.isis.core.commons.resource.ResourceStreamSourceFileSystem technologies}
+ * on the classpath through
+ * the use of a {@link org.apache.isis.core.commons.resource.ResourceStreamSourceComposite composite}
+ * pattern.
+ */
package org.apache.isis.core.commons.resource;
\ No newline at end of file
Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/url/UrlEncodingUtils.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/url/UrlEncodingUtils.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/url/UrlEncodingUtils.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/url/UrlEncodingUtils.java Fri Jul 6 10:51:16 2012
@@ -1,58 +1,58 @@
-/*
- * 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.isis.core.commons.url;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Function;
-
-public final class UrlEncodingUtils {
-
- public final static Function<String, String> FUNCTION = new Function<String, String>() {
-
- @Override
- public String apply(final String input) {
- try {
- return URLDecoder.decode(input, "UTF-8");
- } catch (final UnsupportedEncodingException e) {
- return "";
- }
- }
- };
-
- private UrlEncodingUtils() {
- }
-
- public static String urlDecode(final String string) {
- return FUNCTION.apply(string);
- }
-
- public static String urlEncode(final String str) {
- try {
- return URLEncoder.encode(str, Charsets.UTF_8.name());
- } catch (final UnsupportedEncodingException e) {
- // shouldn't happen
- throw new RuntimeException(e);
- }
- }
-
-}
+/*
+ * 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.isis.core.commons.url;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Function;
+
+public final class UrlEncodingUtils {
+
+ public final static Function<String, String> FUNCTION = new Function<String, String>() {
+
+ @Override
+ public String apply(final String input) {
+ try {
+ return URLDecoder.decode(input, "UTF-8");
+ } catch (final UnsupportedEncodingException e) {
+ return "";
+ }
+ }
+ };
+
+ private UrlEncodingUtils() {
+ }
+
+ public static String urlDecode(final String string) {
+ return FUNCTION.apply(string);
+ }
+
+ public static String urlEncode(final String str) {
+ try {
+ return URLEncoder.encode(str, Charsets.UTF_8.name());
+ } catch (final UnsupportedEncodingException e) {
+ // shouldn't happen
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/xml/ContentWriter.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/xml/ContentWriter.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/xml/ContentWriter.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/xml/ContentWriter.java Fri Jul 6 10:51:16 2012
@@ -1,29 +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.isis.core.commons.xml;
-
-import java.io.IOException;
-import java.io.Writer;
-
-public interface ContentWriter {
-
- void write(Writer writer) throws IOException;
-
-}
+/*
+ * 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.isis.core.commons.xml;
+
+import java.io.IOException;
+import java.io.Writer;
+
+public interface ContentWriter {
+
+ void write(Writer writer) throws IOException;
+
+}
Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/xml/XmlFile.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/xml/XmlFile.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/xml/XmlFile.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/xml/XmlFile.java Fri Jul 6 10:51:16 2012
@@ -1,170 +1,170 @@
-/*
- * 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.isis.core.commons.xml;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.commons.lang.ToString;
-
-public class XmlFile {
- private static final String[] ESCAPE_STRING = { "&", "<", ">", """, "'" };
- private static final String[] SPECIAL_CHARACTERS = { "&", "<", ">", "\"", "'" };
-
- public static String getValueWithSpecialsEscaped(final String s) {
- String result = s;
- for (int i = 0; i < SPECIAL_CHARACTERS.length; i++) {
- final String special = SPECIAL_CHARACTERS[i];
- int pos = -1;
- while (true) {
- pos = result.indexOf(special, pos + 1);
- if (pos < 0) {
- break;
- }
- result = result.substring(0, pos) + ESCAPE_STRING[i] + result.substring(pos + special.length());
- }
- }
- return result;
- }
-
- private final String charset;
- private final File directory;
-
- public XmlFile(final String charset, final String directory) {
- this.directory = new File(directory);
- createDirectoryIfRequired();
- this.charset = charset;
- }
-
- private void createDirectoryIfRequired() {
- if (this.directory.exists()) {
- return;
- }
- this.directory.mkdirs();
- }
-
- private void createDirectoryIfRequired(File file) {
- if(file.exists()) {
- return;
- }
- file.getParentFile().mkdirs();
- }
-
- public File getDirectory() {
- return directory;
- }
-
- private File file(final String fileName) {
- return new File(directory, fileName + ".xml");
- }
-
- public void writeXml(final String name, final ContentWriter writer) {
- OutputStreamWriter pw;
-
- try {
- final File file = file(name);
- createDirectoryIfRequired(file);
- pw = new OutputStreamWriter(new FileOutputStream(file), charset);
- pw.write("<?xml version=\"1.0\" encoding=\"" + charset + "\" ?>\n");
- pw.write("\n");
- writer.write(pw);
- pw.write("\n");
- pw.close();
- } catch (final IOException e) {
- throw new IsisException("Problems writing data files", e);
- }
- }
-
-
- public boolean parse(final ContentHandler handler, final String fileName) {
- XMLReader parser;
-
- try {
- parser = XMLReaderFactory.createXMLReader();
- } catch (final SAXException e) {
- try {
- parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
- } catch (final SAXException e2) {
- try {
- parser = XMLReaderFactory.createXMLReader("org.apache.crimson.parser.XMLReaderImpl");
- } catch (final SAXException failed) {
- throw new IsisException("Couldn't locate a SAX parser");
- }
- }
- }
-
- final File file = file(fileName);
- try {
- parser.setContentHandler(handler);
- final FileInputStream fis = new FileInputStream(file);
- final InputStreamReader isr = new InputStreamReader(fis, charset);
- final InputSource is = new InputSource(isr);
- parser.parse(is);
-
- return true;
- } catch (final FileNotFoundException e) {
- return false;
- } catch (final IOException e) {
- throw new IsisException("Error reading XML file", e);
- } catch (final SAXParseException e) {
- throw new IsisException("Error while parsing: " + e.getMessage() + " in " + file + ")", e);
- } catch (final SAXException e) {
- throw new IsisException("Error in file " + file + " ", e);
- }
- }
-
- public void delete(final String fileName) {
- file(fileName).delete();
- }
-
- /**
- * The XML store is deemed to be initialised if the directory used to store
- * the data has no xml files in it.
- */
- public boolean isFixturesInstalled() {
- final String[] list = directory.list(new FilenameFilter() {
- @Override
- public boolean accept(final File dir, final String name) {
- return name.toLowerCase().endsWith(".xml");
- }
- });
- return list.length > 0;
- }
-
- @Override
- public String toString() {
- return new ToString(this).append("directory", this.directory).toString();
- }
-
-}
+/*
+ * 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.isis.core.commons.xml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.core.commons.lang.ToString;
+
+public class XmlFile {
+ private static final String[] ESCAPE_STRING = { "&", "<", ">", """, "'" };
+ private static final String[] SPECIAL_CHARACTERS = { "&", "<", ">", "\"", "'" };
+
+ public static String getValueWithSpecialsEscaped(final String s) {
+ String result = s;
+ for (int i = 0; i < SPECIAL_CHARACTERS.length; i++) {
+ final String special = SPECIAL_CHARACTERS[i];
+ int pos = -1;
+ while (true) {
+ pos = result.indexOf(special, pos + 1);
+ if (pos < 0) {
+ break;
+ }
+ result = result.substring(0, pos) + ESCAPE_STRING[i] + result.substring(pos + special.length());
+ }
+ }
+ return result;
+ }
+
+ private final String charset;
+ private final File directory;
+
+ public XmlFile(final String charset, final String directory) {
+ this.directory = new File(directory);
+ createDirectoryIfRequired();
+ this.charset = charset;
+ }
+
+ private void createDirectoryIfRequired() {
+ if (this.directory.exists()) {
+ return;
+ }
+ this.directory.mkdirs();
+ }
+
+ private void createDirectoryIfRequired(File file) {
+ if(file.exists()) {
+ return;
+ }
+ file.getParentFile().mkdirs();
+ }
+
+ public File getDirectory() {
+ return directory;
+ }
+
+ private File file(final String fileName) {
+ return new File(directory, fileName + ".xml");
+ }
+
+ public void writeXml(final String name, final ContentWriter writer) {
+ OutputStreamWriter pw;
+
+ try {
+ final File file = file(name);
+ createDirectoryIfRequired(file);
+ pw = new OutputStreamWriter(new FileOutputStream(file), charset);
+ pw.write("<?xml version=\"1.0\" encoding=\"" + charset + "\" ?>\n");
+ pw.write("\n");
+ writer.write(pw);
+ pw.write("\n");
+ pw.close();
+ } catch (final IOException e) {
+ throw new IsisException("Problems writing data files", e);
+ }
+ }
+
+
+ public boolean parse(final ContentHandler handler, final String fileName) {
+ XMLReader parser;
+
+ try {
+ parser = XMLReaderFactory.createXMLReader();
+ } catch (final SAXException e) {
+ try {
+ parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
+ } catch (final SAXException e2) {
+ try {
+ parser = XMLReaderFactory.createXMLReader("org.apache.crimson.parser.XMLReaderImpl");
+ } catch (final SAXException failed) {
+ throw new IsisException("Couldn't locate a SAX parser");
+ }
+ }
+ }
+
+ final File file = file(fileName);
+ try {
+ parser.setContentHandler(handler);
+ final FileInputStream fis = new FileInputStream(file);
+ final InputStreamReader isr = new InputStreamReader(fis, charset);
+ final InputSource is = new InputSource(isr);
+ parser.parse(is);
+
+ return true;
+ } catch (final FileNotFoundException e) {
+ return false;
+ } catch (final IOException e) {
+ throw new IsisException("Error reading XML file", e);
+ } catch (final SAXParseException e) {
+ throw new IsisException("Error while parsing: " + e.getMessage() + " in " + file + ")", e);
+ } catch (final SAXException e) {
+ throw new IsisException("Error in file " + file + " ", e);
+ }
+ }
+
+ public void delete(final String fileName) {
+ file(fileName).delete();
+ }
+
+ /**
+ * The XML store is deemed to be initialised if the directory used to store
+ * the data has no xml files in it.
+ */
+ public boolean isFixturesInstalled() {
+ final String[] list = directory.list(new FilenameFilter() {
+ @Override
+ public boolean accept(final File dir, final String name) {
+ return name.toLowerCase().endsWith(".xml");
+ }
+ });
+ return list.length > 0;
+ }
+
+ @Override
+ public String toString() {
+ return new ToString(this).append("directory", this.directory).toString();
+ }
+
+}
Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/xml/package-info.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/xml/package-info.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/xml/package-info.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/xml/package-info.java Fri Jul 6 10:51:16 2012
@@ -1,28 +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.
- */
-
-/**
- * Provides helper classes for writing alternative implementations
- * that just persist to a proprietary XML format.
- *
- * <p>
- * Specifically, these classes are used by the <i>XmlObjectStore</i>
- * and the <i>XmlProfileStore</i>.
- */
+/*
+ * 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.
+ */
+
+/**
+ * Provides helper classes for writing alternative implementations
+ * that just persist to a proprietary XML format.
+ *
+ * <p>
+ * Specifically, these classes are used by the <i>XmlObjectStore</i>
+ * and the <i>XmlProfileStore</i>.
+ */
package org.apache.isis.core.commons.xml;
\ No newline at end of file