DNA SVN: r279 - trunk.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-06-12 16:22:26 -0400 (Thu, 12 Jun 2008)
New Revision: 279
Modified:
trunk/eclipse-preferences.epf
Log:
Added Mockito static methods as favorite static members
Modified: trunk/eclipse-preferences.epf
===================================================================
--- trunk/eclipse-preferences.epf 2008-06-12 20:14:36 UTC (rev 278)
+++ trunk/eclipse-preferences.epf 2008-06-12 20:22:26 UTC (rev 279)
@@ -70,7 +70,7 @@
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.source=1.5
-/instance/org.eclipse.jdt.ui/content_assist_favorite_static_members=org.junit.Assert.*;org.hamcrest.core.Is.is;org.hamcrest.core.IsNot.not;org.hamcrest.core.IsNull.nullValue;org.hamcrest.core.IsNull.notNullValue;org.hamcrest.core.IsSame.sameInstance;org.hamcrest.core.IsInstanceOf.instanceOf;org.hamcrest.core.IsEqual.equalTo;org.hamcrest.core.IsAnything.anything;org.hamcrest.core.IsAnything.any;org.hamcrest.core.DescribedAs.describedAs;org.hamcrest.core.AnyOf.anyOf;org.hamcrest.core.AllOf.allOf;org.junit.matchers.IsCollectionContaining.hasItem;org.junit.matchers.IsCollectionContaining.hasItems;org.junit.matchers.Each.each;org.junit.matchers.JUnitMatchers.hasItem;org.junit.matchers.JUnitMatchers.hasItems;org.junit.matchers.JUnitMatchers.containsString;org.junit.matchers.JUnitMatchers.each;org.junit.matchers.JUnitMatchers.both;org.junit.matchers.JUnitMatchers.either;org.junit.matchers.StringContains.containsString;org.junit.matchers.TypeSafeMatcher.matches
+/instance/org.eclipse.jdt.ui/content_assist_favorite_static_members=org.junit.Assert.*;org.hamcrest.core.IsEqual.*;org.junit.matchers.JUnitMatchers.*;org.hamcrest.core.AllOf.*;org.hamcrest.core.AnyOf.*;org.hamcrest.core.IsInstanceOf.*;org.hamcrest.core.IsNot.*;org.hamcrest.core.IsNull.*;org.hamcrest.core.IsSame.*;org.hamcrest.core.DescribedAs.*;org.junit.matchers.IsCollectionContaining.*;org.junit.matchers.StringContains.*;org.hamcrest.core.Is.is;org.hamcrest.core.IsNot.not;org.hamcrest.core.IsNull.nullValue;org.hamcrest.core.IsNull.notNullValue;org.hamcrest.core.IsSame.sameInstance;org.hamcrest.core.IsInstanceOf.instanceOf;org.hamcrest.core.IsEqual.equalTo;org.hamcrest.core.IsAnything.anything;org.hamcrest.core.IsAnything.any;org.hamcrest.core.DescribedAs.describedAs;org.hamcrest.core.AnyOf.anyOf;org.hamcrest.core.AllOf.allOf;org.junit.matchers.IsCollectionContaining.hasItem;org.junit.matchers.IsCollectionContaining.hasItems;org.junit.matchers.Each.each;org.junit.matchers.!
JUnitMatchers.hasItem;org.junit.matchers.JUnitMatchers.hasItems;org.junit.matchers.JUnitMatchers.containsString;org.junit.matchers.JUnitMatchers.each;org.junit.matchers.JUnitMatchers.both;org.junit.matchers.JUnitMatchers.either;org.junit.matchers.StringContains.containsString;org.junit.matchers.TypeSafeMatcher.matches;org.hamcrest.collection.IsArray.*;org.hamcrest.collection.IsArrayContaining.*;org.hamcrest.number.IsCloseTo.*;org.mockito.Mockito.mock;org.mockito.Mockito.stub;org.mockito.Mockito.verify;org.mockito.Mockito.atLeastOnce;org.mockito.Mockito.inOrder;org.mockito.Mockito.never;org.mockito.Mockito.stubVoid;org.mockito.Mockito.times;org.mockito.Matchers;org.mockito.Matchers.anyBoolean;org.mockito.Matchers.anyByte;org.mockito.Matchers.anyChar;org.mockito.Matchers.anyDouble;org.mockito.Matchers.anyFloat;org.mockito.Matchers.anyInt;org.mockito.Matchers.anyLong;org.mockito.Matchers.anyObject;org.mockito.Matchers.anyShort;org.mockito.Matchers.anyString;org.mockito.Matcher!
s.argThat;org.mockito.Matchers.booleanThat;org.mockito.Matchers.byteTh
at;org.mockito.Matchers.charThat;org.mockito.Matchers.contains;org.mockito.Matchers.doubleThat;org.mockito.Matchers.endsWith;org.mockito.Matchers.eq;org.mockito.Matchers.floatThat;org.mockito.Matchers.intThat;org.mockito.Matchers.isA;org.mockito.Matchers.isNull;org.mockito.Matchers.longThat;org.mockito.Matchers.matches;org.mockito.Matchers.notNull;org.mockito.Matchers.refEq;org.mockito.Matchers.same;org.mockito.Matchers.shortThat;org.mockito.Matchers.startsWith;org.jboss.dna.common.text.StringMatcher.startsWith;org.jboss.dna.spi.graph.connection.RepositorySourceLoadHarness.runLoadTest
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.gettersetter.use.is=true
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.ignorelowercasenames=true
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.importorder=\#;java;javax;org;com;
17 years, 6 months
DNA SVN: r278 - trunk.
by dna-commits@lists.jboss.org
Author: jverhaeg(a)redhat.com
Date: 2008-06-12 16:14:36 -0400 (Thu, 12 Jun 2008)
New Revision: 278
Modified:
trunk/eclipse-preferences.epf
Log:
Added a few preferences that were missing because they are defaults
Modified: trunk/eclipse-preferences.epf
===================================================================
--- trunk/eclipse-preferences.epf 2008-06-12 20:13:18 UTC (rev 277)
+++ trunk/eclipse-preferences.epf 2008-06-12 20:14:36 UTC (rev 278)
@@ -1,7 +1,5 @@
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.argumentPrefixes=
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.argumentSuffixes=
-/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.deprecationCheck=enabled
-/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.discouragedReferenceCheck=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.fieldPrefixes=
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.fieldSuffixes=
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.codeComplete.localPrefixes=
@@ -32,14 +30,14 @@
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
-/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
-/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
@@ -49,7 +47,7 @@
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
@@ -87,7 +85,13 @@
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.code_templates_migrated=true
/instance/org.eclipse.jdt.ui/org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return ${bare_field_name}\n */</template><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} Sets ${bare_field_name} to the specified value.\n */</template><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\!
="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\n * JBoss, Home of Professional Open Source.\n * Copyright 2008, Red Hat Middleware LLC, and individual contributors\n * as indicated by the @author tags. See the copyright.txt file in the\n * distribution for a full listing of individual contributors. \n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You sh!
ould have received a copy of the GNU Lesser General Public\n * License
along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site\: http\://www.fsf.org.\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author John Verhaeg\n * ${tags}\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n */</template><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context!
\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/**\n * {@inheritDoc}\n *\n * ${see_to_overridden}\n */</template><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * {@inheritDoc}\n *\n * ${see_to_target}\n */</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock"></template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_stateme!
nt}</template><template autoinsert\="false" context\="constructorbody_
context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n</template><template autoinsert\="false" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="false" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
/instance/org.eclipse.jdt.ui/outlinesortoption=SF,SI,SM,F,I,C,M,T,
+/instance/org.eclipse.jdt.ui/sp_cleanup.format_source_code=true
+/instance/org.eclipse.jdt.ui/sp_cleanup.on_save_use_additional_actions=true
+/instance/org.eclipse.jdt.ui/sp_cleanup.organize_imports=true
+/instance/org.eclipse.jdt.ui/sp_cleanup.remove_trailing_whitespaces_all=true
+/instance/org.eclipse.jdt.ui/sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+/instance/org.eclipse.jdt.ui/sp_cleanup.remove_trailing_whitespaces=true
/instance/org.eclipse.jdt.ui/tabWidthPropagated=true
-/instance/org.eclipse.ui.editors/printMarginColumn=130
+/instance/org.eclipse.ui.editors/printMarginColumn=132
/instance/org.eclipse.ui.editors/printMargin=true
/instance/org.eclipse.ui.editors/spacesForTabs=true
17 years, 6 months
DNA SVN: r277 - in trunk: dna-maven-classloader/src/main/java/org/jboss/dna/maven/spi and 3 other directories.
by dna-commits@lists.jboss.org
Author: jverhaeg(a)redhat.com
Date: 2008-06-12 16:13:18 -0400 (Thu, 12 Jun 2008)
New Revision: 277
Modified:
trunk/dna-common/src/main/java/org/jboss/dna/common/text/Inflector.java
trunk/dna-maven-classloader/src/main/java/org/jboss/dna/maven/spi/JcrMavenUrlProvider.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/services/AbstractServiceAdministrator.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleServiceTest.java
Log:
Updated code to eliminate compiler warnings related to invalid JavaDocs, etc., and corrected a few vague uses of generics
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/text/Inflector.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/text/Inflector.java 2008-06-12 20:10:35 UTC (rev 276)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/text/Inflector.java 2008-06-12 20:13:18 UTC (rev 277)
@@ -30,6 +30,7 @@
/**
* Transforms words to singular, plural, humanized (human readable), underscore, camel case, or ordinal form.
+ *
* @author Randall Hauch
*/
public class Inflector {
@@ -46,7 +47,8 @@
protected final Pattern expressionPattern;
protected final String replacement;
- protected Rule( String expression, String replacement ) {
+ protected Rule( String expression,
+ String replacement ) {
this.expression = expression;
this.replacement = replacement != null ? replacement : "";
this.expressionPattern = Pattern.compile(this.expression, Pattern.CASE_INSENSITIVE);
@@ -55,6 +57,7 @@
/**
* Apply the rule against the input string, returning the modified string or null if the rule didn't apply (and no
* modifications were made)
+ *
* @param input the input string
* @return the modified string if this rule applied, or null if the input was not modified by this rule
*/
@@ -130,6 +133,7 @@
* <p>
* Note that if the {@link Object#toString()} is called on the supplied object, so this method works for non-strings, too.
* </p>
+ *
* @param word the word that is to be pluralized.
* @return the pluralized form of the word, or the word itself if it could not be pluralized
* @see #singularize(Object)
@@ -146,7 +150,8 @@
return wordStr;
}
- public String pluralize( Object word, int count ) {
+ public String pluralize( Object word,
+ int count ) {
if (word == null) return null;
if (count == 1 || count == -1) {
return word.toString();
@@ -172,6 +177,7 @@
* <p>
* Note that if the {@link Object#toString()} is called on the supplied object, so this method works for non-strings, too.
* </p>
+ *
* @param word the word that is to be pluralized.
* @return the pluralized form of the word, or the word itself if it could not be pluralized
* @see #pluralize(Object)
@@ -201,6 +207,7 @@
* </pre>
*
* </p>
+ *
* @param lowerCaseAndUnderscoredWord the word that is to be converted to camel case
* @param delimiterChars optional characters that are used to delimit word boundaries
* @return the lower camel case version of the word
@@ -208,7 +215,8 @@
* @see #camelCase(String, boolean, char[])
* @see #upperCamelCase(String, char[])
*/
- public String lowerCamelCase( String lowerCaseAndUnderscoredWord, char... delimiterChars ) {
+ public String lowerCamelCase( String lowerCaseAndUnderscoredWord,
+ char... delimiterChars ) {
return camelCase(lowerCaseAndUnderscoredWord, false, delimiterChars);
}
@@ -225,6 +233,7 @@
* </pre>
*
* </p>
+ *
* @param lowerCaseAndUnderscoredWord the word that is to be converted to camel case
* @param delimiterChars optional characters that are used to delimit word boundaries
* @return the upper camel case version of the word
@@ -232,7 +241,8 @@
* @see #camelCase(String, boolean, char[])
* @see #lowerCamelCase(String, char[])
*/
- public String upperCamelCase( String lowerCaseAndUnderscoredWord, char... delimiterChars ) {
+ public String upperCamelCase( String lowerCaseAndUnderscoredWord,
+ char... delimiterChars ) {
return camelCase(lowerCaseAndUnderscoredWord, true, delimiterChars);
}
@@ -253,16 +263,19 @@
* </pre>
*
* </p>
+ *
* @param lowerCaseAndUnderscoredWord the word that is to be converted to camel case
* @param uppercaseFirstLetter true if the first character is to be uppercased, or false if the first character is to be
- * lowercased
+ * lowercased
* @param delimiterChars optional characters that are used to delimit word boundaries
* @return the camel case version of the word
* @see #underscore(String, char[])
* @see #upperCamelCase(String, char[])
* @see #lowerCamelCase(String, char[])
*/
- public String camelCase( String lowerCaseAndUnderscoredWord, boolean uppercaseFirstLetter, char... delimiterChars ) {
+ public String camelCase( String lowerCaseAndUnderscoredWord,
+ boolean uppercaseFirstLetter,
+ char... delimiterChars ) {
if (lowerCaseAndUnderscoredWord == null) return null;
lowerCaseAndUnderscoredWord = lowerCaseAndUnderscoredWord.trim();
if (lowerCaseAndUnderscoredWord.length() == 0) return "";
@@ -279,7 +292,8 @@
return replaceAllWithUppercase(result, "(^|_)(.)", 2);
}
if (lowerCaseAndUnderscoredWord.length() < 2) return lowerCaseAndUnderscoredWord;
- return "" + lowerCaseAndUnderscoredWord.charAt(0) + camelCase(lowerCaseAndUnderscoredWord, true, delimiterChars).substring(1);
+ return "" + lowerCaseAndUnderscoredWord.charAt(0)
+ + camelCase(lowerCaseAndUnderscoredWord, true, delimiterChars).substring(1);
}
/**
@@ -299,11 +313,13 @@
* </pre>
*
* </p>
+ *
* @param camelCaseWord the camel-cased word that is to be converted;
* @param delimiterChars optional characters that are used to delimit word boundaries (beyond capitalization)
* @return a lower-cased version of the input, with separate words delimited by the underscore character.
*/
- public String underscore( String camelCaseWord, char... delimiterChars ) {
+ public String underscore( String camelCaseWord,
+ char... delimiterChars ) {
if (camelCaseWord == null) return null;
String result = camelCaseWord.trim();
if (result.length() == 0) return "";
@@ -320,6 +336,7 @@
/**
* Returns a copy of the input with the first character converted to uppercase and the remainder to lowercase.
+ *
* @param words the word to be capitalized
* @return the string with the first character capitalized and the remaining characters lowercased
*/
@@ -343,12 +360,14 @@
* </pre>
*
* </p>
+ *
* @param lowerCaseAndUnderscoredWords the input to be humanized
* @param removableTokens optional array of tokens that are to be removed
* @return the humanized string
* @see #titleCase(String, String[])
*/
- public String humanize( String lowerCaseAndUnderscoredWords, String... removableTokens ) {
+ public String humanize( String lowerCaseAndUnderscoredWords,
+ String... removableTokens ) {
if (lowerCaseAndUnderscoredWords == null) return null;
String result = lowerCaseAndUnderscoredWords.trim();
if (result.length() == 0) return "";
@@ -377,11 +396,13 @@
* </pre>
*
* </p>
+ *
* @param words the input to be turned into title case
* @param removableTokens optional array of tokens that are to be removed
* @return the title-case version of the supplied words
*/
- public String titleCase( String words, String... removableTokens ) {
+ public String titleCase( String words,
+ String... removableTokens ) {
String result = humanize(words, removableTokens);
result = replaceAllWithUppercase(result, "\\b([a-z])", 1); // change first char of each word to uppercase
return result;
@@ -390,6 +411,7 @@
/**
* Turns a non-negative number into an ordinal string used to denote the position in an ordered sequence, such as 1st, 2nd,
* 3rd, 4th.
+ *
* @param number the non-negative number
* @return the string with the number and ordinal suffix
*/
@@ -411,6 +433,7 @@
/**
* Determine whether the supplied word is considered uncountable by the {@link #pluralize(Object) pluralize} and
* {@link #singularize(Object) singularize} methods.
+ *
* @param word the word
* @return true if the plural and singular forms of the word are the same
*/
@@ -422,23 +445,27 @@
/**
* Get the set of words that are not processed by the Inflector. The resulting map is directly modifiable.
+ *
* @return the set of uncountable words
*/
public Set<String> getUncountables() {
return uncountables;
}
- public void addPluralize( String rule, String replacement ) {
+ public void addPluralize( String rule,
+ String replacement ) {
final Rule pluralizeRule = new Rule(rule, replacement);
this.plurals.addFirst(pluralizeRule);
}
- public void addSingularize( String rule, String replacement ) {
+ public void addSingularize( String rule,
+ String replacement ) {
final Rule singularizeRule = new Rule(rule, replacement);
this.singulars.addFirst(singularizeRule);
}
- public void addIrregular( String singular, String plural ) {
+ public void addIrregular( String singular,
+ String plural ) {
ArgCheck.isNotEmpty(singular, "singular rule");
ArgCheck.isNotEmpty(plural, "plural rule");
String singularRemainder = singular.length() > 1 ? singular.substring(1) : "";
@@ -463,12 +490,15 @@
* string to uppercase or lowercase the backreferences. For example, <code>\L1</code> would lowercase the first
* backreference, and <code>\u3</code> would uppercase the 3rd backreference.
* </p>
+ *
* @param input
* @param regex
* @param groupNumberToUppercase
- * @return
+ * @return the input string with the appropriate characters converted to upper-case
*/
- protected static String replaceAllWithUppercase( String input, String regex, int groupNumberToUppercase ) {
+ protected static String replaceAllWithUppercase( String input,
+ String regex,
+ int groupNumberToUppercase ) {
Pattern underscoreAndDotPattern = Pattern.compile(regex);
Matcher matcher = underscoreAndDotPattern.matcher(input);
StringBuffer sb = new StringBuffer();
Modified: trunk/dna-maven-classloader/src/main/java/org/jboss/dna/maven/spi/JcrMavenUrlProvider.java
===================================================================
--- trunk/dna-maven-classloader/src/main/java/org/jboss/dna/maven/spi/JcrMavenUrlProvider.java 2008-06-12 20:10:35 UTC (rev 276)
+++ trunk/dna-maven-classloader/src/main/java/org/jboss/dna/maven/spi/JcrMavenUrlProvider.java 2008-06-12 20:13:18 UTC (rev 277)
@@ -191,7 +191,10 @@
/**
* {@inheritDoc}
*/
- public URL getUrl( MavenId mavenId, ArtifactType artifactType, SignatureType signatureType, boolean createIfRequired ) throws MalformedURLException, MavenRepositoryException {
+ public URL getUrl( MavenId mavenId,
+ ArtifactType artifactType,
+ SignatureType signatureType,
+ boolean createIfRequired ) throws MalformedURLException, MavenRepositoryException {
final String path = getUrlPath(mavenId, artifactType, signatureType);
MavenUrl mavenUrl = new MavenUrl();
mavenUrl.setWorkspaceName(this.getWorkspaceName());
@@ -232,9 +235,14 @@
session.save();
this.logger.trace("Created Maven repository node for {0}", mavenUrl);
} catch (LoginException err) {
- throw new MavenRepositoryException(MavenI18n.unableToOpenSessiontoRepositoryWhenCreatingNode.text(mavenUrl, err.getMessage()), err);
+ throw new MavenRepositoryException(
+ MavenI18n.unableToOpenSessiontoRepositoryWhenCreatingNode.text(mavenUrl,
+ err.getMessage()),
+ err);
} catch (NoSuchWorkspaceException err) {
- throw new MavenRepositoryException(MavenI18n.unableToFindWorkspaceWhenCreatingNode.text(this.getWorkspaceName(), mavenUrl, err.getMessage()), err);
+ throw new MavenRepositoryException(MavenI18n.unableToFindWorkspaceWhenCreatingNode.text(this.getWorkspaceName(),
+ mavenUrl,
+ err.getMessage()), err);
} catch (PathNotFoundException err) {
return null;
} catch (RepositoryException err) {
@@ -246,8 +254,11 @@
return mavenUrl.getUrl(this.urlStreamHandler, this.urlEncoder);
}
- protected Node getOrCreatePath( Node root, String relPath, String nodeType )
- throws PathNotFoundException, ItemExistsException, NoSuchNodeTypeException, LockException, VersionException, ConstraintViolationException, RepositoryException {
+ protected Node getOrCreatePath( Node root,
+ String relPath,
+ String nodeType )
+ throws PathNotFoundException, ItemExistsException, NoSuchNodeTypeException, LockException, VersionException,
+ ConstraintViolationException, RepositoryException {
// Create the "nt:unstructured" nodes for the folder structures ...
Node current = root;
boolean created = false;
@@ -267,7 +278,8 @@
return current;
}
- protected Node getContentNodeForMavenResource( Session session, MavenUrl mavenUrl ) throws RepositoryException {
+ protected Node getContentNodeForMavenResource( Session session,
+ MavenUrl mavenUrl ) throws RepositoryException {
final String mavenPath = mavenUrl.getPath().replaceFirst("^/+", "");
final String mavenRootPath = this.getPathToTopOfRepository().replaceFirst("^/+", "");
Node root = session.getRootNode();
@@ -285,7 +297,9 @@
* @param signatureType the type of signature; may be null if the signature file is not desired
* @return the path
*/
- protected String getUrlPath( MavenId mavenId, ArtifactType artifactType, SignatureType signatureType ) {
+ protected String getUrlPath( MavenId mavenId,
+ ArtifactType artifactType,
+ SignatureType signatureType ) {
StringBuilder sb = new StringBuilder();
sb.append("/");
if (artifactType == null) {
@@ -335,7 +349,7 @@
/**
* Obtain an input stream to the existing content at the location given by the supplied {@link MavenUrl}. The Maven URL
* should have a path that points to the node where the content is stored in the
- * {@link #getContentProperty() content property}.
+ * {@link #CONTENT_PROPERTY_NAME content property}.
*
* @param mavenUrl the Maven URL to the content; may not be null
* @return the input stream to the content, or null if there is no existing content
@@ -354,9 +368,13 @@
result = new MavenInputStream(session, result);
return result;
} catch (LoginException err) {
- throw new MavenRepositoryException(MavenI18n.unableToOpenSessiontoRepositoryWhenReadingNode.text(mavenUrl, err.getMessage()), err);
+ throw new MavenRepositoryException(MavenI18n.unableToOpenSessiontoRepositoryWhenReadingNode.text(mavenUrl,
+ err.getMessage()),
+ err);
} catch (NoSuchWorkspaceException err) {
- throw new MavenRepositoryException(MavenI18n.unableToFindWorkspaceWhenReadingNode.text(this.getWorkspaceName(), mavenUrl, err.getMessage()), err);
+ throw new MavenRepositoryException(MavenI18n.unableToFindWorkspaceWhenReadingNode.text(this.getWorkspaceName(),
+ mavenUrl,
+ err.getMessage()), err);
} catch (PathNotFoundException err) {
return null;
} catch (RepositoryException err) {
@@ -371,7 +389,7 @@
/**
* Obtain an output stream to the existing content at the location given by the supplied {@link MavenUrl}. The Maven URL
* should have a path that points to the property or to the node where the content is stored in the
- * {@link #getContentProperty() content property}.
+ * {@link #CONTENT_PROPERTY_NAME content property}.
*
* @param mavenUrl the Maven URL to the content; may not be null
* @return the input stream to the content, or null if there is no existing content
@@ -389,15 +407,20 @@
}
return result;
} catch (LoginException err) {
- throw new MavenRepositoryException(MavenI18n.unableToOpenSessiontoRepositoryWhenReadingNode.text(mavenUrl, err.getMessage()), err);
+ throw new MavenRepositoryException(MavenI18n.unableToOpenSessiontoRepositoryWhenReadingNode.text(mavenUrl,
+ err.getMessage()),
+ err);
} catch (NoSuchWorkspaceException err) {
- throw new MavenRepositoryException(MavenI18n.unableToFindWorkspaceWhenReadingNode.text(this.getWorkspaceName(), mavenUrl, err.getMessage()), err);
+ throw new MavenRepositoryException(MavenI18n.unableToFindWorkspaceWhenReadingNode.text(this.getWorkspaceName(),
+ mavenUrl,
+ err.getMessage()), err);
} catch (RepositoryException err) {
throw new MavenRepositoryException(MavenI18n.errorReadingNode.text(mavenUrl, err.getMessage()), err);
}
}
- public void setContent( MavenUrl mavenUrl, InputStream content ) throws IOException {
+ public void setContent( MavenUrl mavenUrl,
+ InputStream content ) throws IOException {
Session session = null;
try {
// Create a new session, find the actual node, create a temporary file to which the content will be written,
@@ -411,7 +434,9 @@
} catch (LoginException err) {
throw new IOException(MavenI18n.unableToOpenSessiontoRepositoryWhenWritingNode.text(mavenUrl, err.getMessage()));
} catch (NoSuchWorkspaceException err) {
- throw new IOException(MavenI18n.unableToFindWorkspaceWhenWritingNode.text(this.getWorkspaceName(), mavenUrl, err.getMessage()));
+ throw new IOException(MavenI18n.unableToFindWorkspaceWhenWritingNode.text(this.getWorkspaceName(),
+ mavenUrl,
+ err.getMessage()));
} catch (RepositoryException err) {
throw new IOException(MavenI18n.errorWritingNode.text(mavenUrl, err.getMessage()));
} finally {
@@ -426,7 +451,8 @@
private final InputStream stream;
private final Session session;
- protected MavenInputStream( final Session session, final InputStream stream ) {
+ protected MavenInputStream( final Session session,
+ final InputStream stream ) {
this.session = session;
this.stream = stream;
}
@@ -458,7 +484,8 @@
private final File file;
private final MavenUrl mavenUrl;
- protected MavenOutputStream( final MavenUrl mavenUrl, final File file ) throws FileNotFoundException {
+ protected MavenOutputStream( final MavenUrl mavenUrl,
+ final File file ) throws FileNotFoundException {
this.mavenUrl = mavenUrl;
this.file = file;
this.stream = new BufferedOutputStream(new FileOutputStream(this.file));
@@ -487,7 +514,9 @@
* {@inheritDoc}
*/
@Override
- public void write( byte[] b, int off, int len ) throws IOException {
+ public void write( byte[] b,
+ int off,
+ int len ) throws IOException {
if (stream == null) throw new IOException(MavenI18n.unableToWriteToClosedStream.text());
stream.write(b, off, len);
}
@@ -512,12 +541,18 @@
try {
inputStream.close();
} catch (IOException ioe) {
- Logger.getLogger(this.getClass()).error(ioe, MavenI18n.errorClosingTempFileStreamAfterWritingContent, mavenUrl, ioe.getMessage());
+ Logger.getLogger(this.getClass()).error(ioe,
+ MavenI18n.errorClosingTempFileStreamAfterWritingContent,
+ mavenUrl,
+ ioe.getMessage());
} finally {
try {
file.delete();
} catch (SecurityException se) {
- Logger.getLogger(this.getClass()).error(se, MavenI18n.errorDeletingTempFileStreamAfterWritingContent, mavenUrl, se.getMessage());
+ Logger.getLogger(this.getClass()).error(se,
+ MavenI18n.errorDeletingTempFileStreamAfterWritingContent,
+ mavenUrl,
+ se.getMessage());
} finally {
stream = null;
}
@@ -563,9 +598,7 @@
private final MavenUrl mavenUrl;
/**
- * @param repository the repository that contains the content from/to which the URL connections will read/write
* @param url the URL that is to be processed
- * @param decoder the decoder that will unescape any characters in the URL
*/
protected MavenUrlConnection( URL url ) {
super(url);
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java 2008-06-12 20:10:35 UTC (rev 276)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java 2008-06-12 20:13:18 UTC (rev 277)
@@ -61,7 +61,8 @@
*/
public static interface ProblemLog {
- void error( String repositoryWorkspaceName, Throwable t );
+ void error( String repositoryWorkspaceName,
+ Throwable t );
}
/**
@@ -74,7 +75,8 @@
/**
* {@inheritDoc}
*/
- public void error( String repositoryWorkspaceName, Throwable t ) {
+ public void error( String repositoryWorkspaceName,
+ Throwable t ) {
getLogger().error(t, RepositoryI18n.errorProcessingEvents, repositoryWorkspaceName);
}
}
@@ -84,7 +86,8 @@
/**
* {@inheritDoc}
*/
- public void error( String repositoryWorkspaceName, Throwable t ) {
+ public void error( String repositoryWorkspaceName,
+ Throwable t ) {
}
}
@@ -113,7 +116,8 @@
/**
* {@inheritDoc}
*/
- public boolean awaitTermination( long timeout, TimeUnit unit ) {
+ public boolean awaitTermination( long timeout,
+ TimeUnit unit ) {
return true;
}
@@ -273,23 +277,29 @@
* </p>
*
* @param repositoryWorkspaceName the name to be used with the session factory to obtain a session to the repository and
- * workspace that is to be monitored
+ * workspace that is to be monitored
* @param absolutePath the absolute path of the node at or below which changes are to be monitored; may be null if all nodes
- * in the workspace are to be monitored
+ * in the workspace are to be monitored
* @param eventTypes the bitmask of the {@link Event} types that are to be monitored
* @param isDeep true if events below the node given by the <code>absolutePath</code> or by the <code>uuids</code> are to
- * be processed, or false if only the events at the node
+ * be processed, or false if only the events at the node
* @param uuids array of UUIDs of nodes that are to be monitored; may be null or empty if the UUIDs are not known
* @param nodeTypeNames array of node type names that are to be monitored; may be null or empty if the monitoring has no node
- * type restrictions
+ * type restrictions
* @param noLocal true if the events originating in the supplied workspace are to be ignored, or false if they are also to be
- * processed.
+ * processed.
* @return the listener that was created and registered to perform the monitoring
* @throws RepositoryException if there is a problem registering the listener
*/
- public WorkspaceListener monitor( String repositoryWorkspaceName, String absolutePath, int eventTypes, boolean isDeep, String[] uuids, String[] nodeTypeNames, boolean noLocal )
- throws RepositoryException {
- WorkspaceListener listener = new WorkspaceListener(repositoryWorkspaceName, eventTypes, absolutePath, isDeep, uuids, nodeTypeNames, noLocal);
+ public WorkspaceListener monitor( String repositoryWorkspaceName,
+ String absolutePath,
+ int eventTypes,
+ boolean isDeep,
+ String[] uuids,
+ String[] nodeTypeNames,
+ boolean noLocal ) throws RepositoryException {
+ WorkspaceListener listener = new WorkspaceListener(repositoryWorkspaceName, eventTypes, absolutePath, isDeep, uuids,
+ nodeTypeNames, noLocal);
listener.register();
this.workspaceListeners.add(listener);
return listener;
@@ -310,16 +320,24 @@
* </p>
*
* @param repositoryWorkspaceName the name to be used with the session factory to obtain a session to the repository and
- * workspace that is to be monitored
+ * workspace that is to be monitored
* @param absolutePath the absolute path of the node at or below which changes are to be monitored; may be null if all nodes
- * in the workspace are to be monitored
+ * in the workspace are to be monitored
* @param nodeTypeNames the names of the node types that are to be monitored; may be null or empty if the monitoring has no
- * node type restrictions
+ * node type restrictions
* @return the listener that was created and registered to perform the monitoring
* @throws RepositoryException if there is a problem registering the listener
*/
- public WorkspaceListener monitor( String repositoryWorkspaceName, String absolutePath, String... nodeTypeNames ) throws RepositoryException {
- return monitor(repositoryWorkspaceName, absolutePath, WorkspaceListener.DEFAULT_EVENT_TYPES, WorkspaceListener.DEFAULT_IS_DEEP, null, nodeTypeNames, WorkspaceListener.DEFAULT_NO_LOCAL);
+ public WorkspaceListener monitor( String repositoryWorkspaceName,
+ String absolutePath,
+ String... nodeTypeNames ) throws RepositoryException {
+ return monitor(repositoryWorkspaceName,
+ absolutePath,
+ WorkspaceListener.DEFAULT_EVENT_TYPES,
+ WorkspaceListener.DEFAULT_IS_DEEP,
+ null,
+ nodeTypeNames,
+ WorkspaceListener.DEFAULT_NO_LOCAL);
}
/**
@@ -336,15 +354,23 @@
* </p>
*
* @param repositoryWorkspaceName the name to be used with the session factory to obtain a session to the repository and
- * workspace that is to be monitored
+ * workspace that is to be monitored
* @param eventTypes the bitmask of the {@link Event} types that are to be monitored
* @param nodeTypeNames the names of the node types that are to be monitored; may be null or empty if the monitoring has no
- * node type restrictions
+ * node type restrictions
* @return the listener that was created and registered to perform the monitoring
* @throws RepositoryException if there is a problem registering the listener
*/
- public WorkspaceListener monitor( String repositoryWorkspaceName, int eventTypes, String... nodeTypeNames ) throws RepositoryException {
- return monitor(repositoryWorkspaceName, WorkspaceListener.DEFAULT_ABSOLUTE_PATH, eventTypes, WorkspaceListener.DEFAULT_IS_DEEP, null, nodeTypeNames, WorkspaceListener.DEFAULT_NO_LOCAL);
+ public WorkspaceListener monitor( String repositoryWorkspaceName,
+ int eventTypes,
+ String... nodeTypeNames ) throws RepositoryException {
+ return monitor(repositoryWorkspaceName,
+ WorkspaceListener.DEFAULT_ABSOLUTE_PATH,
+ eventTypes,
+ WorkspaceListener.DEFAULT_IS_DEEP,
+ null,
+ nodeTypeNames,
+ WorkspaceListener.DEFAULT_NO_LOCAL);
}
protected void unregisterListener( WorkspaceListener listener ) {
@@ -360,10 +386,11 @@
* and filters.
* </p>
*
- * @param events
+ * @param eventIterator
* @param listener
*/
- protected void processEvents( EventIterator eventIterator, WorkspaceListener listener ) {
+ protected void processEvents( EventIterator eventIterator,
+ WorkspaceListener listener ) {
if (eventIterator == null) return;
List<Event> events = new ArrayList<Event>();
// Copy the events ...
@@ -418,7 +445,8 @@
private final int size;
private int position = 0;
- protected DelegatingEventIterator( Iterator<Event> events, int size ) {
+ protected DelegatingEventIterator( Iterator<Event> events,
+ int size ) {
this.events = events;
this.size = size;
}
@@ -487,7 +515,8 @@
public static final boolean DEFAULT_IS_DEEP = true;
public static final boolean DEFAULT_NO_LOCAL = false;
- public static final int DEFAULT_EVENT_TYPES = Event.NODE_ADDED | /* Event.NODE_REMOVED| */Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED /* |Event.PROPERTY_REMOVED */;
+ public static final int DEFAULT_EVENT_TYPES = Event.NODE_ADDED | /* Event.NODE_REMOVED| */Event.PROPERTY_ADDED
+ | Event.PROPERTY_CHANGED /* |Event.PROPERTY_REMOVED */;
public static final String DEFAULT_ABSOLUTE_PATH = "/";
private final String repositoryWorkspaceName;
@@ -500,7 +529,13 @@
@GuardedBy( "this" )
private transient Session session;
- protected WorkspaceListener( String repositoryWorkspaceName, int eventTypes, String absPath, boolean isDeep, String[] uuids, String[] nodeTypeNames, boolean noLocal ) {
+ protected WorkspaceListener( String repositoryWorkspaceName,
+ int eventTypes,
+ String absPath,
+ boolean isDeep,
+ String[] uuids,
+ String[] nodeTypeNames,
+ boolean noLocal ) {
this.repositoryWorkspaceName = repositoryWorkspaceName;
this.eventTypes = eventTypes;
this.deep = isDeep;
@@ -591,7 +626,13 @@
this.session = ObservationService.this.getSessionFactory().createSession(this.repositoryWorkspaceName);
String[] uuids = this.uuids.isEmpty() ? null : this.uuids.toArray(new String[this.uuids.size()]);
String[] nodeTypeNames = this.nodeTypeNames.isEmpty() ? null : this.nodeTypeNames.toArray(new String[this.nodeTypeNames.size()]);
- this.session.getWorkspace().getObservationManager().addEventListener(this, eventTypes, absolutePath, deep, uuids, nodeTypeNames, noLocal);
+ this.session.getWorkspace().getObservationManager().addEventListener(this,
+ eventTypes,
+ absolutePath,
+ deep,
+ uuids,
+ nodeTypeNames,
+ noLocal);
return this;
}
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/services/AbstractServiceAdministrator.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/services/AbstractServiceAdministrator.java 2008-06-12 20:10:35 UTC (rev 276)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/services/AbstractServiceAdministrator.java 2008-06-12 20:13:18 UTC (rev 277)
@@ -39,7 +39,8 @@
private volatile State state;
private final I18n serviceName;
- protected AbstractServiceAdministrator( I18n serviceName, State initialState ) {
+ protected AbstractServiceAdministrator( I18n serviceName,
+ State initialState ) {
assert initialState != null;
assert serviceName != null;
this.state = initialState;
@@ -88,7 +89,7 @@
* @param state the desired state in string form
* @return this object for method chaining purposes
* @throws IllegalArgumentException if the specified state string is null or does not match one of the predefined
- * {@link ServiceAdministrator.State predefined enumerated values}
+ * {@link ServiceAdministrator.State predefined enumerated values}
* @see #setState(State)
* @see #start()
* @see #pause()
@@ -129,8 +130,8 @@
/**
* Implementation of the functionality to switch to the started state. This method is only called if the state from which the
- * service is transitioning is appropriate ({@link State#PAUSED}). This method does nothing by default, and should be
- * overridden if needed.
+ * service is transitioning is appropriate ({@link ServiceAdministrator.State#PAUSED}). This method does nothing by default,
+ * and should be overridden if needed.
*
* @param fromState the state from which this service is transitioning; never null
* @throws IllegalStateException if the service is such that it cannot be transitioned from the supplied state
@@ -166,8 +167,8 @@
/**
* Implementation of the functionality to switch to the paused state. This method is only called if the state from which the
- * service is transitioning is appropriate ({@link State#STARTED}). This method does nothing by default, and should be
- * overridden if needed.
+ * service is transitioning is appropriate ({@link ServiceAdministrator.State#STARTED}). This method does nothing by
+ * default, and should be overridden if needed.
*
* @param fromState the state from which this service is transitioning; never null
* @throws IllegalStateException if the service is such that it cannot be transitioned from the supplied state
@@ -203,8 +204,8 @@
/**
* Implementation of the functionality to switch to the shutdown state. This method is only called if the state from which the
- * service is transitioning is appropriate ({@link State#STARTED} or {@link State#PAUSED}). This method does nothing by
- * default, and should be overridden if needed.
+ * service is transitioning is appropriate ({@link ServiceAdministrator.State#STARTED} or
+ * {@link ServiceAdministrator.State#PAUSED}). This method does nothing by default, and should be overridden if needed.
*
* @param fromState the state from which this service is transitioning; never null
* @throws IllegalStateException if the service is such that it cannot be transitioned from the supplied state
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleServiceTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleServiceTest.java 2008-06-12 20:10:35 UTC (rev 276)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleServiceTest.java 2008-06-12 20:13:18 UTC (rev 277)
@@ -214,9 +214,6 @@
executeRuleSet(validRuleSet.getName());
}
- /**
- * @param validRuleSet
- */
protected void executeRuleSet( String ruleSetName ) {
// Create some simple fact objects ...
RuleInput info = new RuleInput();
17 years, 6 months
DNA SVN: r276 - in trunk: dna-common/src/main/java/org/jboss/dna/common/component and 11 other directories.
by dna-commits@lists.jboss.org
Author: jverhaeg(a)redhat.com
Date: 2008-06-12 16:10:35 -0400 (Thu, 12 Jun 2008)
New Revision: 276
Modified:
trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java
trunk/dna-common/src/main/java/org/jboss/dna/common/component/ComponentLibrary.java
trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressStatus.java
trunk/dna-common/src/main/java/org/jboss/dna/common/util/ArgCheck.java
trunk/dna-common/src/test/java/org/jboss/dna/common/util/ArgCheckTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/util/LoggerTest.java
trunk/dna-maven-classloader/src/main/java/org/jboss/dna/maven/MavenClassLoaders.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepository.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepositorySource.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapter.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPath.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java
trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadata.java
Log:
Updated code to eliminate compiler warnings related to invalid JavaDocs, etc., and corrected a few vague uses of generics
Modified: trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java
===================================================================
--- trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java 2008-06-12 19:57:43 UTC (rev 275)
+++ trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java 2008-06-12 20:10:35 UTC (rev 276)
@@ -72,11 +72,8 @@
private final Cache<Name, Object> cache;
private RepositorySourceListener listener = NO_OP_LISTENER;
- /**
- *
- */
- /* package */JBossCacheConnection( JBossCacheSource source,
- Cache<Name, Object> cache ) {
+ JBossCacheConnection( JBossCacheSource source,
+ Cache<Name, Object> cache ) {
assert source != null;
assert cache != null;
this.source = source;
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/component/ComponentLibrary.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/component/ComponentLibrary.java 2008-06-12 19:57:43 UTC (rev 275)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/component/ComponentLibrary.java 2008-06-12 20:10:35 UTC (rev 276)
@@ -43,6 +43,7 @@
* Therefore, this library does guarantee that the {@link #getInstances() instances} at the time they are
* {@link #getInstances() obtained} are always reflected by the configurations.
* </p>
+ *
* @author Randall Hauch
* @param <ComponentType> the type of component being managed, which may be a subclass of {@link Component}
* @param <ConfigType> the configuration type describing the components
@@ -64,7 +65,7 @@
/**
* The list of component instances. The index of each component instance matches the corresponding configuration instance in
- * {@link #configurations}
+ * {@link #configs}
*/
@GuardedBy( value = "lock" )
private final List<ComponentType> instances = new CopyOnWriteArrayList<ComponentType>();
@@ -83,6 +84,7 @@
* {@link #DEFAULT default} class loader factory, which uses the
* {@link Thread#getContextClassLoader() current thread's context class loader} if not null or the class loader that loaded
* the library class.
+ *
* @return the class loader factory; never null
* @see #setClassLoaderFactory(ClassLoaderFactory)
*/
@@ -95,8 +97,9 @@
* {@link #DEFAULT default} class loader factory, which uses the
* {@link Thread#getContextClassLoader() current thread's context class loader} if not null or the class loader that loaded
* the library class.
+ *
* @param classLoaderFactory the class loader factory reference, or null if the {@link #DEFAULT default class loader factory}
- * should be used
+ * should be used
* @see #getClassLoaderFactory()
*/
public void setClassLoaderFactory( ClassLoaderFactory classLoaderFactory ) {
@@ -106,9 +109,10 @@
/**
* Add the configuration for a sequencer, or update any existing one that represents the
* {@link ConfigType#equals(Object) same configuration}
+ *
* @param config the new configuration
* @return true if the component was added, or false if there already was an existing and
- * {@link ComponentConfig#hasChanged(ComponentConfig) unchanged} component configuration
+ * {@link ComponentConfig#hasChanged(ComponentConfig) unchanged} component configuration
* @throws IllegalArgumentException if <code>config</code> is null
* @see #update(ComponentConfig)
* @see #remove(ComponentConfig)
@@ -140,9 +144,10 @@
/**
* Update the configuration for a sequencer, or add it if there is no {@link ConfigType#equals(Object) matching configuration}.
+ *
* @param config the updated (or new) configuration
* @return true if the component was updated, or false if there already was an existing and
- * {@link ComponentConfig#hasChanged(ComponentConfig) unchanged} component configuration
+ * {@link ComponentConfig#hasChanged(ComponentConfig) unchanged} component configuration
* @throws IllegalArgumentException if <code>config</code> is null
* @see #add(ComponentConfig)
* @see #remove(ComponentConfig)
@@ -153,6 +158,7 @@
/**
* Remove the configuration for a sequencer.
+ *
* @param config the configuration to be removed
* @return true if the component was remove, or false if there was no existing configuration
* @throws IllegalArgumentException if <code>config</code> is null
@@ -179,6 +185,7 @@
/**
* Return the list of sequencers.
+ *
* @return the unmodifiable list of sequencers; never null
*/
public List<ComponentType> getInstances() {
@@ -188,6 +195,7 @@
/**
* Instantiate, configure and return a new sequencer described by the supplied configuration. This method does not manage the
* returned instance.
+ *
* @param config the configuration describing the sequencer
* @return the new sequencer, or null if the sequencer could not be successfully configured
* @throws IllegalArgumentException if the sequencer could not be configured properly
@@ -218,8 +226,9 @@
/**
* Method that instantiates the supplied class. This method can be overridden by subclasses that may need to wrap or adapt the
* instance to be a ComponentType.
+ *
* @param componentClass
- * @return
+ * @return the new ComponentType instance
* @throws InstantiationException
* @throws IllegalAccessException
*/
@@ -229,7 +238,8 @@
}
/**
- * Find the index for the matching {@link #configurations configuration} and {@link #sequencerInstances sequencer}.
+ * Find the index for the matching {@link #configs configuration} and {@link #instances sequencer}.
+ *
* @param config the configuration; may not be null
* @return the index, or -1 if not found
*/
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressStatus.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressStatus.java 2008-06-12 19:57:43 UTC (rev 275)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressStatus.java 2008-06-12 20:10:35 UTC (rev 276)
@@ -24,11 +24,12 @@
import java.io.Serializable;
import java.text.DecimalFormat;
+import net.jcip.annotations.Immutable;
import org.jboss.dna.common.util.StringUtil;
-import net.jcip.annotations.Immutable;
/**
* A snapshot of the progress on an activity.
+ *
* @author Randall Hauch
*/
@Immutable
@@ -42,11 +43,13 @@
/**
* Compute the percentage worked, accounting for imprecision in
+ *
* @param workedSoFar the amount of work so far percentage worked
* @param totalWork the total amount of work for this activity
- * @return
+ * @return the percentage worked
*/
- protected static double computePercentage( double workedSoFar, double totalWork ) {
+ protected static double computePercentage( double workedSoFar,
+ double totalWork ) {
if (isSamePercentage(workedSoFar, 0.0d)) return 0.0d;
assert totalWork > 0.0d;
double percentage = workedSoFar / totalWork * 100.0d;
@@ -54,7 +57,8 @@
return percentage;
}
- protected static boolean isSamePercentage( double percentage1, double percentage2 ) {
+ protected static boolean isSamePercentage( double percentage1,
+ double percentage2 ) {
return Math.abs(percentage1 - percentage2) <= PERCENT_PRECISION;
}
@@ -66,13 +70,17 @@
/**
* Create the progress status.
+ *
* @param activityName the name of the activity, which may not be null
* @param message the message for the progress, which may not be null
* @param percentWorked the percentage worked, ranging from 0.0 for not started to 100.0 for complete; a negative value are
- * treated as 0.0, while a value greater than 100.0 is treated as 100.0
+ * treated as 0.0, while a value greater than 100.0 is treated as 100.0
* @param cancelled true if the activity has been requested to be cancelled, or false otherwise
*/
- public ProgressStatus( String activityName, String message, double percentWorked, boolean cancelled ) {
+ public ProgressStatus( String activityName,
+ String message,
+ double percentWorked,
+ boolean cancelled ) {
assert activityName != null;
assert message != null;
this.activityName = activityName;
@@ -84,18 +92,24 @@
/**
* Create the progress status and compute the percentage worked.
+ *
* @param activityName the name of the activity, which may not be null
* @param message the message for the progress, which may not be null
* @param workedSoFar the amount of work so far percentage worked
* @param totalWork the total amount of work for this activity
* @param cancelled true if the activity has been requested to be cancelled, or false otherwise
*/
- public ProgressStatus( String activityName, String message, double workedSoFar, double totalWork, boolean cancelled ) {
+ public ProgressStatus( String activityName,
+ String message,
+ double workedSoFar,
+ double totalWork,
+ boolean cancelled ) {
this(activityName, message, computePercentage(workedSoFar, totalWork), cancelled);
}
/**
* Get the name of the activity.
+ *
* @return the activity's name
*/
public String getActivityName() {
@@ -104,6 +118,7 @@
/**
* Get the progress as a percentage of the total work that's been completed.
+ *
* @return the percentage worked, ranging from 0.0 to 100.0
*/
public double getPercentWorked() {
@@ -112,6 +127,7 @@
/**
* Get the progress monitor's text message.
+ *
* @return the text message
*/
public String getMessage() {
@@ -120,6 +136,7 @@
/**
* Return whether work on this activity has completed.
+ *
* @return true if work has completed, or false if work on the activity is still progressing
* @see #isCancelled()
*/
@@ -129,6 +146,7 @@
/**
* Return whether the activity was requested to be cancelled.
+ *
* @return cancelled
* @see #isDone()
*/
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/util/ArgCheck.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/util/ArgCheck.java 2008-06-12 19:57:43 UTC (rev 275)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/util/ArgCheck.java 2008-06-12 20:10:35 UTC (rev 276)
@@ -332,15 +332,14 @@
/**
* Check that the object is an instance of the specified Class
*
- * @param <T> the class type
* @param argument Value
* @param expectedClass Class
* @param name The name of the argument
* @throws IllegalArgumentException If value is null
*/
- public static <T> void isInstanceOf( Object argument,
- Class<T> expectedClass,
- String name ) {
+ public static void isInstanceOf( Object argument,
+ Class<?> expectedClass,
+ String name ) {
isNotNull(argument, name);
if (!expectedClass.isInstance(argument)) {
throw new IllegalArgumentException(CommonI18n.argumentMustBeInstanceOf.text(name,
@@ -359,13 +358,12 @@
* @return value cast to the specified Class
* @throws IllegalArgumentException If value is not an instance of theClass.
*/
- @SuppressWarnings( "unchecked" )
// due to cast in return
public static <C> C getInstanceOf( Object argument,
Class<C> expectedClass,
String name ) {
isInstanceOf(argument, expectedClass, name);
- return (C)argument;
+ return expectedClass.cast(argument);
}
/**
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/util/ArgCheckTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/util/ArgCheckTest.java 2008-06-12 19:57:43 UTC (rev 275)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/util/ArgCheckTest.java 2008-06-12 20:10:35 UTC (rev 276)
@@ -22,8 +22,8 @@
package org.jboss.dna.common.util;
-import static org.junit.Assert.*;
-import static org.hamcrest.core.Is.*;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/util/LoggerTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/util/LoggerTest.java 2008-06-12 19:57:43 UTC (rev 275)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/util/LoggerTest.java 2008-06-12 20:10:35 UTC (rev 276)
@@ -436,7 +436,7 @@
*/
public void removeFirst( Logger.Level expectedLevel,
String expectedMessageExpression,
- Class<?> expectedExceptionClass ) {
+ Class<? extends Throwable> expectedExceptionClass ) {
if (!hasEvents()) {
fail("Expected log message but found none: " + expectedLevel + " - " + expectedMessageExpression);
}
Modified: trunk/dna-maven-classloader/src/main/java/org/jboss/dna/maven/MavenClassLoaders.java
===================================================================
--- trunk/dna-maven-classloader/src/main/java/org/jboss/dna/maven/MavenClassLoaders.java 2008-06-12 19:57:43 UTC (rev 275)
+++ trunk/dna-maven-classloader/src/main/java/org/jboss/dna/maven/MavenClassLoaders.java 2008-06-12 20:10:35 UTC (rev 276)
@@ -45,6 +45,7 @@
* dependency rules</a>. Each {@link MavenRepository} instance owns an instance of this class, which provides a cached set of
* class loaders and a facility for {@link MavenRepository#getClassLoader(ClassLoader, MavenId...) getting class loaders} based
* upon a set of one or more versioned libraries.
+ *
* @author Randall Hauch
*/
/* package */class MavenClassLoaders {
@@ -66,8 +67,8 @@
/**
* Create with a specified repository and optionally the parent class loader that should be consulted first and a default
* class loader that should be consulted after all others.
+ *
* @param repository the Maven repository; may not be null
- * @param parentClassLoader the parent class loader that should be accessed before any class loaders for any Maven project.
*/
/* package */MavenClassLoaders( MavenRepository repository ) {
this.repository = repository;
@@ -97,7 +98,8 @@
return result;
}
- public ProjectClassLoader getClassLoader( ClassLoader parent, MavenId... mavenIds ) {
+ public ProjectClassLoader getClassLoader( ClassLoader parent,
+ MavenId... mavenIds ) {
if (parent == null) parent = Thread.currentThread().getContextClassLoader();
if (parent == null) parent = this.getClass().getClassLoader();
ProjectClassLoader result = new ProjectClassLoader(parent);
@@ -129,6 +131,7 @@
/**
* A project class loader is responsible for loading all classes and resources for the project, including delegating to
* dependent projects if required and adhearing to all stated exclusions.
+ *
* @author Randall Hauch
*/
protected class ProjectClassLoader extends ClassLoader {
@@ -141,13 +144,13 @@
/**
* Create a class loader for the given project.
+ *
* @param mavenId
* @param jarFileClassLoader
- * @param dependencies
- * @param parent
* @see MavenClassLoaders#getClassLoader(ClassLoader, MavenId...)
*/
- protected ProjectClassLoader( MavenId mavenId, URLClassLoader jarFileClassLoader ) {
+ protected ProjectClassLoader( MavenId mavenId,
+ URLClassLoader jarFileClassLoader ) {
super(null);
this.mavenId = mavenId;
this.jarFileClassLoader = jarFileClassLoader;
@@ -155,7 +158,7 @@
/**
* Create a class loader that doesn't reference a top level project, but instead references multiple projects.
- * @param dependencies
+ *
* @param parent
* @see MavenClassLoaders#getClassLoader(ClassLoader, MavenId...)
*/
@@ -188,9 +191,10 @@
/**
* Finds the resource with the given name. This implementation first consults the class loader for this project's JAR
* file, and failing that, consults all of the class loaders for the dependent projects.
+ *
* @param name The resource name
* @return A <tt>URL</tt> object for reading the resource, or <tt>null</tt> if the resource could not be found or the
- * invoker doesn't have adequate privileges to get the resource.
+ * invoker doesn't have adequate privileges to get the resource.
*/
@Override
protected URL findResource( String name ) {
@@ -203,17 +207,19 @@
* this method should only be directly called by test methods; subclasses should call {@link #findResource(String)}.</i>
* <p>
* This method first looks in this project's JAR. If the resource is not found, then this method
- * {@link #findResource(String, Set, List) searches the dependencies}. This method's signature allows for a list to be
- * supplied for reporting the list of projects that make up the searched classpath (excluding those that were never
+ * {@link #findResource(String, Set, Set, List) searches the dependencies}. This method's signature allows for a list to
+ * be supplied for reporting the list of projects that make up the searched classpath (excluding those that were never
* searched because the resource was found).
* </p>
+ *
* @param name The resource name
* @param debugSearchPath the list into which the IDs of the searched projects will be placed; may be null if this
- * information is not needed
+ * information is not needed
* @return A <tt>URL</tt> object for reading the resource, or <tt>null</tt> if the resource could not be found or the
- * invoker doesn't have adequate privileges to get the resource.
+ * invoker doesn't have adequate privileges to get the resource.
*/
- protected URL findResource( String name, List<MavenId> debugSearchPath ) {
+ protected URL findResource( String name,
+ List<MavenId> debugSearchPath ) {
Set<MavenId> processed = new HashSet<MavenId>();
// This method is called only by the top-level class loader handling a request.
// Therefore, first look in this project's JAR file ...
@@ -231,7 +237,10 @@
return result;
}
- protected URL findResource( String name, Set<MavenId> processed, Set<MavenId> exclusions, List<MavenId> debugSearchPath ) {
+ protected URL findResource( String name,
+ Set<MavenId> processed,
+ Set<MavenId> exclusions,
+ List<MavenId> debugSearchPath ) {
// If this project is to be excluded, then simply return ...
if (exclusions != null && exclusions.contains(this.mavenId)) return null;
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepository.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepository.java 2008-06-12 19:57:43 UTC (rev 275)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepository.java 2008-06-12 20:10:35 UTC (rev 276)
@@ -79,7 +79,8 @@
/**
* {@inheritDoc}
*/
- public boolean awaitTermination( long timeout, TimeUnit unit ) throws InterruptedException {
+ public boolean awaitTermination( long timeout,
+ TimeUnit unit ) throws InterruptedException {
return FederatedRepository.this.awaitTermination(timeout, unit);
}
@@ -108,7 +109,8 @@
* @param name the name of the repository
* @throws IllegalArgumentException if the service is null or the name is null or blank
*/
- public FederatedRepository( FederationService service, String name ) {
+ public FederatedRepository( FederationService service,
+ String name ) {
ArgCheck.isNotNull(service, "service");
ArgCheck.isNotEmpty(name, "name");
this.name = name;
@@ -165,8 +167,15 @@
/**
* Utility method called by the administrator.
+ *
+ * @param timeout
+ * @param unit
+ * @return true if all pools were terminated in the supplied time (or were already terminated), or false if the timeout
+ * occurred before all the connections were closed
+ * @throws InterruptedException
*/
- protected boolean awaitTermination( long timeout, TimeUnit unit ) throws InterruptedException {
+ protected boolean awaitTermination( long timeout,
+ TimeUnit unit ) throws InterruptedException {
// Check whether all source pools are shut down. This is done inside the sources write lock.
try {
this.sourcesWriteLock.lock();
@@ -245,7 +254,7 @@
*
* @param source the source to add
* @return true if the source is added, or false if the reference is null or if there is already an existing source with the
- * supplied name.
+ * supplied name.
*/
public boolean addSource( FederatedSource source ) {
if (source == null) return false;
@@ -270,10 +279,11 @@
* @param source the source to add
* @param index the index at which the source should be added
* @return true if the source is added, or false if the reference is null or if there is already an existing source with the
- * supplied name.
+ * supplied name.
* @throws IndexOutOfBoundsException if the index is out of bounds
*/
- public boolean addSource( FederatedSource source, int index ) {
+ public boolean addSource( FederatedSource source,
+ int index ) {
if (source == null) return false;
try {
this.sourcesWriteLock.lock();
@@ -297,12 +307,14 @@
*
* @param source the source to be removed
* @param timeToAwait the amount of time to wait while all of the source's connections are closed, or non-positive if the call
- * should not wait at all
+ * should not wait at all
* @param unit the time unit to be used for <code>timeToAwait</code>
* @return true if the source was removed, or false if the source was not a source for this repository.
* @throws InterruptedException if the thread is interrupted while awaiting closing of the connections
*/
- public boolean removeSource( FederatedSource source, long timeToAwait, TimeUnit unit ) throws InterruptedException {
+ public boolean removeSource( FederatedSource source,
+ long timeToAwait,
+ TimeUnit unit ) throws InterruptedException {
// Use the name; don't use the object equality ...
return removeSource(source.getName(), timeToAwait, unit) != null;
}
@@ -317,13 +329,15 @@
*
* @param name the name of the source to be removed
* @param timeToAwait the amount of time to wait while all of the source's connections are closed, or non-positive if the call
- * should not wait at all
+ * should not wait at all
* @param unit the time unit to be used for <code>timeToAwait</code>
* @return the source with the supplied name that was removed, or null if no existing source matching the supplied name could
- * be found
+ * be found
* @throws InterruptedException if the thread is interrupted while awaiting closing of the connections
*/
- public FederatedSource removeSource( String name, long timeToAwait, TimeUnit unit ) throws InterruptedException {
+ public FederatedSource removeSource( String name,
+ long timeToAwait,
+ TimeUnit unit ) throws InterruptedException {
try {
this.sourcesWriteLock.lock();
for (FederatedSource existingSource : this.sources) {
@@ -349,7 +363,7 @@
*
* @param listener the new listener
* @return true if the listener was added, or false if the listener was not added (if reference is null, or if non-null
- * listener is already an existing listener)
+ * listener is already an existing listener)
*/
public boolean addListener( RepositorySourceListener listener ) {
if (listener == null) return false;
@@ -386,7 +400,8 @@
* @param credentials the credentials
* @return true if authentication succeeded, or false otherwise
*/
- public boolean authenticate( String username, Object credentials ) {
+ public boolean authenticate( String username,
+ Object credentials ) {
return true;
}
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepositorySource.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepositorySource.java 2008-06-12 19:57:43 UTC (rev 275)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepositorySource.java 2008-06-12 20:10:35 UTC (rev 276)
@@ -63,10 +63,8 @@
private String username;
private String credentials;
- /**
- *
- */
- protected FederatedRepositorySource( FederationService federationService, String repositoryName ) {
+ protected FederatedRepositorySource( FederationService federationService,
+ String repositoryName ) {
ArgCheck.isNotNull(federationService, "federationService");
ArgCheck.isNotNull(repositoryName, "repositoryName");
this.federationService = federationService;
@@ -102,13 +100,16 @@
// Find the repository ...
FederatedRepository repository = federationService.getRepository(this.repositoryName);
if (repository == null) {
- throw new RepositorySourceException(RepositoryI18n.unableToCreateConnectionToFederatedRepository.text(this.repositoryName));
+ throw new RepositorySourceException(
+ RepositoryI18n.unableToCreateConnectionToFederatedRepository.text(this.repositoryName));
}
// Authenticate the user ...
String username = this.username;
Object credentials = this.credentials;
if (!repository.authenticate(username, credentials)) {
- throw new RepositorySourceException(RepositoryI18n.unableToAuthenticateConnectionToFederatedRepository.text(this.repositoryName, username));
+ throw new RepositorySourceException(
+ RepositoryI18n.unableToAuthenticateConnectionToFederatedRepository.text(this.repositoryName,
+ username));
}
// Return the new connection ...
return new FederatedRepositoryConnection(repository, this);
@@ -188,7 +189,10 @@
/**
* {@inheritDoc}
*/
- public Object getObjectInstance( Object obj, javax.naming.Name name, Context nameCtx, Hashtable<?, ?> environment ) throws Exception {
+ public Object getObjectInstance( Object obj,
+ javax.naming.Name name,
+ Context nameCtx,
+ Hashtable<?, ?> environment ) throws Exception {
if (obj instanceof Reference) {
Map<String, String> values = new HashMap<String, String>();
Reference ref = (Reference)obj;
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java 2008-06-12 19:57:43 UTC (rev 275)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java 2008-06-12 20:10:35 UTC (rev 276)
@@ -54,6 +54,7 @@
* branch are discovered, they are processed asynchronously. This ensure that the processing of the repository contents does not
* block the other listeners of the {@link ObservationService}.
* </p>
+ *
* @author Randall Hauch
*/
@ThreadSafe
@@ -73,14 +74,17 @@
/**
* Create an instance that can listen to the {@link RuleSet} definitions stored in a JCR repository and ensure that the
* {@link RuleSet} instances of a {@link RuleService} reflect the definitions in the repository.
+ *
* @param ruleService the rule service that should be kept in sync with the JCR repository.
* @param jcrAbsolutePath the absolute path to the branch where the rule sets are defined; if null or empty, the
- * {@link #DEFAULT_JCR_ABSOLUTE_PATH default path} is used
+ * {@link #DEFAULT_JCR_ABSOLUTE_PATH default path} is used
* @param executionContext the context in which this monitor is to execute
* @throws IllegalArgumentException if the rule service or execution context is null, or if the supplied
- * <code>jcrAbsolutePath</code> is invalid
+ * <code>jcrAbsolutePath</code> is invalid
*/
- public RuleSetRepositoryMonitor( RuleService ruleService, String jcrAbsolutePath, ExecutionContext executionContext ) {
+ public RuleSetRepositoryMonitor( RuleService ruleService,
+ String jcrAbsolutePath,
+ ExecutionContext executionContext ) {
ArgCheck.isNotNull(ruleService, "rule service");
ArgCheck.isNotNull(executionContext, "execution context");
this.ruleService = ruleService;
@@ -95,7 +99,10 @@
if (!leadingPath.endsWith(JCR_PATH_DELIM)) leadingPath = leadingPath + JCR_PATH_DELIM;
this.ruleSetNamePattern = Pattern.compile(leadingPath + "([^/]+)/?.*");
} catch (PatternSyntaxException e) {
- throw new IllegalArgumentException(RepositoryI18n.unableToBuildRuleSetRegularExpressionPattern.text(e.getPattern(), jcrAbsolutePath, e.getDescription()));
+ throw new IllegalArgumentException(
+ RepositoryI18n.unableToBuildRuleSetRegularExpressionPattern.text(e.getPattern(),
+ jcrAbsolutePath,
+ e.getDescription()));
}
}
@@ -161,6 +168,7 @@
/**
* Process the rule sets given by the supplied names, keyed by the repository workspace name.
+ *
* @param ruleSetNamesByWorkspaceName the set of rule set names keyed by the repository workspace name
*/
protected void processRuleSets( Map<String, Set<String>> ruleSetNamesByWorkspaceName ) {
@@ -221,11 +229,15 @@
* property. Rule set properties are optional.</li>
* </ul>
* </p>
+ *
* @param name the name of the rule set; never null
* @param ruleSetNode the node representing the rule set; null if the rule set doesn't exist
+ * @param tools
* @return the rule set for the information stored in the repository, or null if the rule set does not exist or has errors
*/
- protected RuleSet buildRuleSet( String name, Node ruleSetNode, JcrTools tools ) {
+ protected RuleSet buildRuleSet( String name,
+ Node ruleSetNode,
+ JcrTools tools ) {
if (ruleSetNode == null) return null;
SimpleProblems simpleProblems = new SimpleProblems();
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java 2008-06-12 19:57:43 UTC (rev 275)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java 2008-06-12 20:10:35 UTC (rev 276)
@@ -86,7 +86,9 @@
* @param nodeChange the set of node changes; never null
* @return the list of sequencers that should be used; may not be null
*/
- List<Sequencer> selectSequencers( List<Sequencer> sequencers, Node node, NodeChange nodeChange );
+ List<Sequencer> selectSequencers( List<Sequencer> sequencers,
+ Node node,
+ NodeChange nodeChange );
}
/**
@@ -97,7 +99,9 @@
*/
protected static class DefaultSelector implements Selector {
- public List<Sequencer> selectSequencers( List<Sequencer> sequencers, Node node, NodeChange nodeChange ) {
+ public List<Sequencer> selectSequencers( List<Sequencer> sequencers,
+ Node node,
+ NodeChange nodeChange ) {
return sequencers;
}
}
@@ -149,7 +153,8 @@
* {@link Thread#getContextClassLoader() current thread's context class loader} (if not null) or component library's class
* loader.
*/
- protected static final ClassLoaderFactory DEFAULT_CLASSLOADER_FACTORY = new StandardClassLoaderFactory(SequencingService.class.getClassLoader());
+ protected static final ClassLoaderFactory DEFAULT_CLASSLOADER_FACTORY = new StandardClassLoaderFactory(
+ SequencingService.class.getClassLoader());
/**
* The administrative component for this service.
@@ -191,7 +196,8 @@
/**
* {@inheritDoc}
*/
- public boolean awaitTermination( long timeout, TimeUnit unit ) throws InterruptedException {
+ public boolean awaitTermination( long timeout,
+ TimeUnit unit ) throws InterruptedException {
return doAwaitTermination(timeout, unit);
}
@@ -270,7 +276,7 @@
*
* @param config the new configuration
* @return true if the sequencer was added, or false if there already was an existing and
- * {@link SequencerConfig#hasChanged(SequencerConfig) unchanged} sequencer configuration
+ * {@link SequencerConfig#hasChanged(SequencerConfig) unchanged} sequencer configuration
* @throws IllegalArgumentException if <code>config</code> is null
* @see #updateSequencer(SequencerConfig)
* @see #removeSequencer(SequencerConfig)
@@ -285,7 +291,7 @@
*
* @param config the updated (or new) configuration
* @return true if the sequencer was updated, or false if there already was an existing and
- * {@link SequencerConfig#hasChanged(SequencerConfig) unchanged} sequencer configuration
+ * {@link SequencerConfig#hasChanged(SequencerConfig) unchanged} sequencer configuration
* @throws IllegalArgumentException if <code>config</code> is null
* @see #addSequencer(SequencerConfig)
* @see #removeSequencer(SequencerConfig)
@@ -380,12 +386,12 @@
/**
* Override this method to creates a different kind of default executor service. This method is called when the system is
- * {@link #start() started} without an executor service being {@link #setExecutorService(ExecutorService) set}.
+ * {@link #startService() started} without an executor service being {@link #setExecutorService(ExecutorService) set}.
* <p>
* This method creates a {@link Executors#newSingleThreadExecutor() single-threaded executor}.
* </p>
*
- * @return
+ * @return the executor service
*/
protected ExecutorService createDefaultExecutorService() {
return Executors.newSingleThreadExecutor();
@@ -417,7 +423,8 @@
return true;
}
- protected boolean doAwaitTermination( long timeout, TimeUnit unit ) throws InterruptedException {
+ protected boolean doAwaitTermination( long timeout,
+ TimeUnit unit ) throws InterruptedException {
if (this.executorService == null || this.executorService.isTerminated()) return true;
return this.executorService.awaitTermination(timeout, unit);
}
@@ -483,9 +490,9 @@
/**
* Do the work of processing by sequencing the node. This method is called by the {@link #executorService executor service}
- * when it performs it's work on the enqueued {@link ChangedNode ChangedNode runnable objects}.
+ * when it performs it's work on the enqueued {@link NodeChange NodeChange runnable objects}.
*
- * @param node the node to be processed.
+ * @param changedNode the node to be processed.
*/
protected void processChangedNode( NodeChange changedNode ) {
try {
@@ -506,7 +513,8 @@
SequencerPathExpression.Matcher matcher = pathExpression.matcher(path);
if (matcher.matches()) {
// String selectedPath = matcher.getSelectedPath();
- RepositoryNodePath outputPath = RepositoryNodePath.parse(matcher.getOutputPath(), repositoryWorkspaceName);
+ RepositoryNodePath outputPath = RepositoryNodePath.parse(matcher.getOutputPath(),
+ repositoryWorkspaceName);
SequencerCall call = new SequencerCall(sequencer, propertyName);
// Record the output path ...
Set<RepositoryNodePath> outputPaths = sequencerCalls.get(call);
@@ -562,9 +570,17 @@
final ProgressMonitor sequenceMonitor = progressMonitor.createSubtask(1);
try {
sequenceMonitor.beginTask(100, RepositoryI18n.sequencerSubtask, sequencerName);
- sequencer.execute(node, propertyName, changedNode, outputPaths, executionContext, sequenceMonitor.createSubtask(80)); // 80%
+ sequencer.execute(node,
+ propertyName,
+ changedNode,
+ outputPaths,
+ executionContext,
+ sequenceMonitor.createSubtask(80)); // 80%
} catch (RepositoryException e) {
- this.logger.error(e, RepositoryI18n.errorInRepositoryWhileSequencingNode, sequencerName, changedNode);
+ this.logger.error(e,
+ RepositoryI18n.errorInRepositoryWhileSequencingNode,
+ sequencerName,
+ changedNode);
} catch (SequencerException e) {
this.logger.error(e, RepositoryI18n.errorWhileSequencingNode, sequencerName, changedNode);
} finally {
@@ -721,7 +737,8 @@
private final String sequencedPropertyName;
private final int hc;
- protected SequencerCall( Sequencer sequencer, String sequencedPropertyName ) {
+ protected SequencerCall( Sequencer sequencer,
+ String sequencedPropertyName ) {
this.sequencer = sequencer;
this.sequencerName = sequencer.getConfiguration().getName();
this.sequencedPropertyName = sequencedPropertyName;
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapter.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapter.java 2008-06-12 19:57:43 UTC (rev 275)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapter.java 2008-06-12 20:10:35 UTC (rev 276)
@@ -47,6 +47,7 @@
/**
* An adapter class that wraps a {@link StreamSequencer} instance to be a {@link Sequencer}.
+ *
* @author Randall Hauch
*/
public class StreamSequencerAdapter implements Sequencer {
@@ -75,8 +76,12 @@
/**
* {@inheritDoc}
*/
- public void execute( Node input, String sequencedPropertyName, NodeChange changes, Set<RepositoryNodePath> outputPaths, ExecutionContext context, ProgressMonitor progressMonitor )
- throws RepositoryException, SequencerException {
+ public void execute( Node input,
+ String sequencedPropertyName,
+ NodeChange changes,
+ Set<RepositoryNodePath> outputPaths,
+ ExecutionContext context,
+ ProgressMonitor progressMonitor ) throws RepositoryException, SequencerException {
// 'sequencedPropertyName' contains the name of the modified property on 'input' that resuled the call to this sequencer
// 'changes' contains all of the changes to this node that occurred in the transaction.
// 'outputPaths' contains the paths of the node(s) where this sequencer is to save it's data
@@ -125,7 +130,11 @@
// Find each output node and save the image metadata there ...
ProgressMonitor writingProgress = progressMonitor.createSubtask(40);
- writingProgress.beginTask(outputPaths.size(), RepositoryI18n.writingOutputSequencedFromPropertyOnNodes, sequencedPropertyName, input.getPath(), outputPaths.size());
+ writingProgress.beginTask(outputPaths.size(),
+ RepositoryI18n.writingOutputSequencedFromPropertyOnNodes,
+ sequencedPropertyName,
+ input.getPath(),
+ outputPaths.size());
for (RepositoryNodePath outputPath : outputPaths) {
Session session = null;
try {
@@ -158,13 +167,16 @@
/**
* Save the sequencing output to the supplied node. This method does not need to save the output, as that is done by the
* caller of this method.
+ *
* @param outputNode the existing node onto (or below) which the output is to be written; never null
- * @param outputProperties the (immutable) sequencing output; never null
+ * @param output the (immutable) sequencing output; never null
* @param context the execution context for this sequencing operation; never null
* @return true if the output was written to the node, or false if no information was written
* @throws RepositoryException
*/
- protected boolean saveOutput( Node outputNode, SequencerOutputMap output, ExecutionContext context ) throws RepositoryException {
+ protected boolean saveOutput( Node outputNode,
+ SequencerOutputMap output,
+ ExecutionContext context ) throws RepositoryException {
if (output.isEmpty()) return false;
final PathFactory pathFactory = context.getValueFactories().getPathFactory();
final NamespaceRegistry namespaceRegistry = context.getNamespaceRegistry();
@@ -195,7 +207,8 @@
}
// We only have the primary type for the final one ...
if (i == (max - 1) && primaryType != null) {
- targetNode = targetNode.addNode(qualifiedName, primaryType.getString(namespaceRegistry, Path.NO_OP_ENCODER));
+ targetNode = targetNode.addNode(qualifiedName, primaryType.getString(namespaceRegistry,
+ Path.NO_OP_ENCODER));
} else {
targetNode = targetNode.addNode(qualifiedName);
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPath.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPath.java 2008-06-12 19:57:43 UTC (rev 275)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPath.java 2008-06-12 20:10:35 UTC (rev 276)
@@ -39,7 +39,7 @@
/**
* A basic implementation of {@link Path}.
- *
+ *
* @author Randall Hauch
* @author John Verhaeg
*/
@@ -52,461 +52,461 @@
private static final List<Segment> EMPTY_SEGMENTS = Collections.emptyList();
- public static final Path ROOT = new BasicPath(EMPTY_SEGMENTS, true);
+ public static final Path ROOT = new BasicPath(EMPTY_SEGMENTS, true);
- protected static final Path SELF_PATH = new BasicPath(Collections.singletonList(Path.SELF_SEGMENT), false);
+ protected static final Path SELF_PATH = new BasicPath(Collections.singletonList(Path.SELF_SEGMENT), false);
- private final List<Segment> segments;
- private final boolean absolute;
- private final boolean normalized;
- private transient String path;
+ private final List<Segment> segments;
+ private final boolean absolute;
+ private final boolean normalized;
+ private transient String path;
- /**
- * @param segments the segments
- * @param absolute true if this path is absolute, or false otherwise
- */
- public BasicPath( List<Segment> segments,
- boolean absolute ) {
- ArgCheck.isNotNull(segments, "segments");
- this.segments = segments.isEmpty() ? EMPTY_SEGMENTS : Collections.unmodifiableList(segments);
- this.absolute = absolute;
- this.normalized = isNormalized(this.segments);
- }
+ /**
+ * @param segments the segments
+ * @param absolute true if this path is absolute, or false otherwise
+ */
+ public BasicPath( List<Segment> segments,
+ boolean absolute ) {
+ ArgCheck.isNotNull(segments, "segments");
+ this.segments = segments.isEmpty() ? EMPTY_SEGMENTS : Collections.unmodifiableList(segments);
+ this.absolute = absolute;
+ this.normalized = isNormalized(this.segments);
+ }
- protected boolean isNormalized( List<Segment> segments ) {
- for (Segment segment : segments) {
- if (segment.isSelfReference() || segment.isParentReference()) return false;
- }
- return true;
- }
+ protected boolean isNormalized( List<Segment> segments ) {
+ for (Segment segment : segments) {
+ if (segment.isSelfReference() || segment.isParentReference()) return false;
+ }
+ return true;
+ }
- /**
- * {@inheritDoc}
- */
- public Path getAncestor() {
- if (this.isRoot()) return this;
- if (this.segments.size() == 1) return ROOT;
- return subpath(0, this.segments.size() - 1);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Path getAncestor() {
+ if (this.isRoot()) return this;
+ if (this.segments.size() == 1) return ROOT;
+ return subpath(0, this.segments.size() - 1);
+ }
- /**
- * {@inheritDoc}
- */
- public Path getAncestor( int degree ) {
- ArgCheck.isNonNegative(degree, "degree");
- if (this.isRoot()) return this;
- if (degree == 0) return this;
- int endIndex = this.segments.size() - degree;
- if (endIndex < 0) {
- String msg = SpiI18n.pathAncestorDegreeIsInvalid.text(this.getString(), Inflector.getInstance().ordinalize(degree));
- throw new PathNotFoundException(msg);
- }
- return subpath(0, endIndex);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Path getAncestor( int degree ) {
+ ArgCheck.isNonNegative(degree, "degree");
+ if (this.isRoot()) return this;
+ if (degree == 0) return this;
+ int endIndex = this.segments.size() - degree;
+ if (endIndex < 0) {
+ String msg = SpiI18n.pathAncestorDegreeIsInvalid.text(this.getString(), Inflector.getInstance().ordinalize(degree));
+ throw new PathNotFoundException(msg);
+ }
+ return subpath(0, endIndex);
+ }
- /**
- * {@inheritDoc}
- */
- public Path getCanonicalPath() {
- if (!this.isAbsolute()) {
- String msg = SpiI18n.pathIsNotAbsolute.text(this);
- throw new InvalidPathException(msg);
- }
- if (this.isNormalized()) return this;
- return this.getNormalizedPath();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Path getCanonicalPath() {
+ if (!this.isAbsolute()) {
+ String msg = SpiI18n.pathIsNotAbsolute.text(this);
+ throw new InvalidPathException(msg);
+ }
+ if (this.isNormalized()) return this;
+ return this.getNormalizedPath();
+ }
- /**
- * {@inheritDoc}
- */
- public Path getCommonAncestor( Path that ) {
- if (that == null) return null;
- if (this.isRoot() || that.isRoot()) return ROOT;
- Path normalizedPath = this.getNormalizedPath();
- int lastIndex = 0;
- Iterator<Segment> thisIter = normalizedPath.iterator();
- Iterator<Segment> thatIter = that.getNormalizedPath().iterator();
- while (thisIter.hasNext() && thatIter.hasNext()) {
- Segment thisSeg = thisIter.next();
- Segment thatSeg = thatIter.next();
- if (thisSeg.equals(thatSeg)) {
- ++lastIndex;
- } else {
- break;
- }
- }
- if (lastIndex == 0) return ROOT;
- return normalizedPath.subpath(0, lastIndex);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Path getCommonAncestor( Path that ) {
+ if (that == null) return null;
+ if (this.isRoot() || that.isRoot()) return ROOT;
+ Path normalizedPath = this.getNormalizedPath();
+ int lastIndex = 0;
+ Iterator<Segment> thisIter = normalizedPath.iterator();
+ Iterator<Segment> thatIter = that.getNormalizedPath().iterator();
+ while (thisIter.hasNext() && thatIter.hasNext()) {
+ Segment thisSeg = thisIter.next();
+ Segment thatSeg = thatIter.next();
+ if (thisSeg.equals(thatSeg)) {
+ ++lastIndex;
+ } else {
+ break;
+ }
+ }
+ if (lastIndex == 0) return ROOT;
+ return normalizedPath.subpath(0, lastIndex);
+ }
- /**
- * {@inheritDoc}
- */
- public Path.Segment getLastSegment() {
- if (this.isRoot()) return null;
- return this.segments.get(size() - 1);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Path.Segment getLastSegment() {
+ if (this.isRoot()) return null;
+ return this.segments.get(size() - 1);
+ }
- /**
- * {@inheritDoc}
- */
- public Path getNormalizedPath() {
- if (this.isNormalized()) return this; // ROOT is normalized already
- LinkedList<Segment> newSegments = new LinkedList<Segment>();
- for (Segment segment : segments) {
- if (segment.isSelfReference()) continue;
- if (segment.isParentReference()) {
- if (newSegments.isEmpty()) {
- if (this.isAbsolute()) {
- throw new InvalidPathException(CommonI18n.pathCannotBeNormalized.text(this));
- }
- } else if (!newSegments.getLast().isParentReference()) {
- newSegments.removeLast();
- continue;
- }
- }
- newSegments.add(segment);
- }
- if (newSegments.isEmpty()) {
- if (this.isAbsolute()) return ROOT;
- // Otherwise relative and it had contained nothing but self references ...
- return SELF_PATH;
- }
- return new BasicPath(newSegments, this.isAbsolute());
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Path getNormalizedPath() {
+ if (this.isNormalized()) return this; // ROOT is normalized already
+ LinkedList<Segment> newSegments = new LinkedList<Segment>();
+ for (Segment segment : segments) {
+ if (segment.isSelfReference()) continue;
+ if (segment.isParentReference()) {
+ if (newSegments.isEmpty()) {
+ if (this.isAbsolute()) {
+ throw new InvalidPathException(CommonI18n.pathCannotBeNormalized.text(this));
+ }
+ } else if (!newSegments.getLast().isParentReference()) {
+ newSegments.removeLast();
+ continue;
+ }
+ }
+ newSegments.add(segment);
+ }
+ if (newSegments.isEmpty()) {
+ if (this.isAbsolute()) return ROOT;
+ // Otherwise relative and it had contained nothing but self references ...
+ return SELF_PATH;
+ }
+ return new BasicPath(newSegments, this.isAbsolute());
+ }
- /**
- * {@inheritDoc}
- */
- public Segment getSegment( int index ) {
- return this.segments.get(index);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Segment getSegment( int index ) {
+ return this.segments.get(index);
+ }
- /**
- * {@inheritDoc}
- */
- public Segment[] getSegmentsArray() {
- return this.segments.toArray(new Path.Segment[this.segments.size()]);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Segment[] getSegmentsArray() {
+ return this.segments.toArray(new Path.Segment[this.segments.size()]);
+ }
- /**
- * {@inheritDoc}
- */
- public List<Segment> getSegmentsList() {
- return this.segments;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public List<Segment> getSegmentsList() {
+ return this.segments;
+ }
- /**
- * {@inheritDoc}
- */
- public String getString() {
- return doGetString(null, DEFAULT_ENCODER);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public String getString() {
+ return doGetString(null, DEFAULT_ENCODER);
+ }
- /**
- * {@inheritDoc}
- */
- public String getString( TextEncoder encoder ) {
- return doGetString(null, encoder);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public String getString( TextEncoder encoder ) {
+ return doGetString(null, encoder);
+ }
- /**
- * {@inheritDoc}
- */
- public String getString( NamespaceRegistry namespaceRegistry ) {
- ArgCheck.isNotNull(namespaceRegistry, "namespaceRegistry");
- return doGetString(namespaceRegistry, null);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public String getString( NamespaceRegistry namespaceRegistry ) {
+ ArgCheck.isNotNull(namespaceRegistry, "namespaceRegistry");
+ return doGetString(namespaceRegistry, null);
+ }
- /**
- * {@inheritDoc}
- */
- public String getString( NamespaceRegistry namespaceRegistry,
- TextEncoder encoder ) {
- ArgCheck.isNotNull(namespaceRegistry, "namespaceRegistry");
- return doGetString(namespaceRegistry, encoder);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public String getString( NamespaceRegistry namespaceRegistry,
+ TextEncoder encoder ) {
+ ArgCheck.isNotNull(namespaceRegistry, "namespaceRegistry");
+ return doGetString(namespaceRegistry, encoder);
+ }
- /**
- * Method that creates the string representation. This method works two different ways depending upon whether the namespace
- * registry is provided.
- *
- * @param namespaceRegistry
- * @param encoder
- * @return
- */
- protected String doGetString( NamespaceRegistry namespaceRegistry,
- TextEncoder encoder ) {
- if (encoder == null) encoder = DEFAULT_ENCODER;
- if (encoder == DEFAULT_ENCODER && this.path != null) return this.path;
+ /**
+ * Method that creates the string representation. This method works two different ways depending upon whether the namespace
+ * registry is provided.
+ *
+ * @param namespaceRegistry
+ * @param encoder
+ * @return this path as a string
+ */
+ protected String doGetString( NamespaceRegistry namespaceRegistry,
+ TextEncoder encoder ) {
+ if (encoder == null) encoder = DEFAULT_ENCODER;
+ if (encoder == DEFAULT_ENCODER && this.path != null) return this.path;
- // Since the segments are immutable, this code need not be synchronized because concurrent threads
- // may just compute the same value (with no harm done)
- StringBuilder sb = new StringBuilder();
- if (this.isAbsolute()) sb.append(DELIMITER);
- boolean first = true;
- for (Segment segment : this.segments) {
- if (first) {
- first = false;
- } else {
- sb.append(DELIMITER);
- }
- assert segment != null;
- if (namespaceRegistry != null) {
- sb.append(segment.getString(namespaceRegistry, encoder));
- } else {
- sb.append(segment.getString(encoder));
- }
- }
- String result = sb.toString();
- // Save the result to the internal string if this the default encoder is used.
- // This is not synchronized, but it's okay
- if (encoder == DEFAULT_ENCODER && this.path == null) this.path = result;
- return result;
- }
+ // Since the segments are immutable, this code need not be synchronized because concurrent threads
+ // may just compute the same value (with no harm done)
+ StringBuilder sb = new StringBuilder();
+ if (this.isAbsolute()) sb.append(DELIMITER);
+ boolean first = true;
+ for (Segment segment : this.segments) {
+ if (first) {
+ first = false;
+ } else {
+ sb.append(DELIMITER);
+ }
+ assert segment != null;
+ if (namespaceRegistry != null) {
+ sb.append(segment.getString(namespaceRegistry, encoder));
+ } else {
+ sb.append(segment.getString(encoder));
+ }
+ }
+ String result = sb.toString();
+ // Save the result to the internal string if this the default encoder is used.
+ // This is not synchronized, but it's okay
+ if (encoder == DEFAULT_ENCODER && this.path == null) this.path = result;
+ return result;
+ }
- /**
- * {@inheritDoc}
- */
- public boolean hasSameAncestor( Path that ) {
- if (that == null) return false;
- if (that.size() != this.size()) return false;
- if (this.size() == 1) return false;
- for (int i = this.size() - 2; i < 0; --i) {
- Path.Segment thisSegment = this.getSegment(i);
- Path.Segment thatSegment = that.getSegment(i);
- if (!thisSegment.equals(thatSegment)) return false;
- }
- return true;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean hasSameAncestor( Path that ) {
+ if (that == null) return false;
+ if (that.size() != this.size()) return false;
+ if (this.size() == 1) return false;
+ for (int i = this.size() - 2; i < 0; --i) {
+ Path.Segment thisSegment = this.getSegment(i);
+ Path.Segment thatSegment = that.getSegment(i);
+ if (!thisSegment.equals(thatSegment)) return false;
+ }
+ return true;
+ }
- /**
- * {@inheritDoc}
- */
- public boolean isAbsolute() {
- return this.absolute;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isAbsolute() {
+ return this.absolute;
+ }
- /**
- * {@inheritDoc}
- */
- public boolean isAncestorOf( Path decendant ) {
- if (decendant == null) return false;
- if (this == decendant) return false;
- if (this.size() >= decendant.size()) return false;
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isAncestorOf( Path decendant ) {
+ if (decendant == null) return false;
+ if (this == decendant) return false;
+ if (this.size() >= decendant.size()) return false;
- Iterator<Path.Segment> thisIter = this.iterator();
- Iterator<Path.Segment> thatIter = decendant.iterator();
- while (thisIter.hasNext()) {
- Path.Segment thisSeg = thisIter.next();
- Path.Segment thatSeg = thatIter.next();
- if (!thisSeg.equals(thatSeg)) return false;
- }
- return true;
- }
+ Iterator<Path.Segment> thisIter = this.iterator();
+ Iterator<Path.Segment> thatIter = decendant.iterator();
+ while (thisIter.hasNext()) {
+ Path.Segment thisSeg = thisIter.next();
+ Path.Segment thatSeg = thatIter.next();
+ if (!thisSeg.equals(thatSeg)) return false;
+ }
+ return true;
+ }
- /**
- * {@inheritDoc}
- */
- public boolean isDecendantOf( Path ancestor ) {
- if (ancestor == null) return false;
- return ancestor.isAncestorOf(this);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isDecendantOf( Path ancestor ) {
+ if (ancestor == null) return false;
+ return ancestor.isAncestorOf(this);
+ }
- /**
- * {@inheritDoc}
- */
- public boolean isNormalized() {
- return this.normalized;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isNormalized() {
+ return this.normalized;
+ }
- /**
- * {@inheritDoc}
- */
- public boolean isRoot() {
- return this == ROOT || this.segments.isEmpty();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isRoot() {
+ return this == ROOT || this.segments.isEmpty();
+ }
- /**
- * {@inheritDoc}
- */
- public boolean isSame( Path other ) {
- return this.compareTo(other) == 0;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSame( Path other ) {
+ return this.compareTo(other) == 0;
+ }
- /**
- * {@inheritDoc}
- */
- public Iterator<Segment> iterator() {
- return this.segments.iterator();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Iterator<Segment> iterator() {
+ return this.segments.iterator();
+ }
- /**
- * {@inheritDoc}
- */
- public Path relativeTo( Path startingPath ) {
- ArgCheck.isNotNull(startingPath, "to");
- if (!this.isAbsolute()) {
- String msg = SpiI18n.pathIsNotAbsolute.text(this);
- throw new InvalidPathException(msg);
- }
- if (!startingPath.isAbsolute()) {
- String msg = SpiI18n.pathIsNotAbsolute.text(startingPath);
- throw new InvalidPathException(msg);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Path relativeTo( Path startingPath ) {
+ ArgCheck.isNotNull(startingPath, "to");
+ if (!this.isAbsolute()) {
+ String msg = SpiI18n.pathIsNotAbsolute.text(this);
+ throw new InvalidPathException(msg);
+ }
+ if (!startingPath.isAbsolute()) {
+ String msg = SpiI18n.pathIsNotAbsolute.text(startingPath);
+ throw new InvalidPathException(msg);
+ }
- // Count the number of segments up to the common ancestor (relative path is what remains) ...
- int lengthOfCommonAncestor = 0;
- Iterator<Segment> thisIter = this.getNormalizedPath().iterator();
- Iterator<Segment> toIter = startingPath.getNormalizedPath().iterator();
- while (thisIter.hasNext() && toIter.hasNext()) {
- Segment thisSeg = thisIter.next();
- Segment toSeg = toIter.next();
- if (thisSeg.equals(toSeg)) {
- ++lengthOfCommonAncestor;
- } else {
- break;
- }
- }
- // Create the relative path, starting with parent references to the common ancestor ...
- int numberOfParentReferences = startingPath.size() - lengthOfCommonAncestor;
- List<Segment> relativeSegments = new ArrayList<Segment>();
- for (int i = 0; i != numberOfParentReferences; ++i) {
- relativeSegments.add(Path.PARENT_SEGMENT);
- }
- // Add the segments of this path from the common ancestor ...
- for (int i = lengthOfCommonAncestor; i < this.size(); ++i) {
- relativeSegments.add(this.segments.get(i));
- }
- if (relativeSegments.isEmpty()) {
- relativeSegments.add(Path.SELF_SEGMENT);
- }
- return new BasicPath(relativeSegments, false);
- }
+ // Count the number of segments up to the common ancestor (relative path is what remains) ...
+ int lengthOfCommonAncestor = 0;
+ Iterator<Segment> thisIter = this.getNormalizedPath().iterator();
+ Iterator<Segment> toIter = startingPath.getNormalizedPath().iterator();
+ while (thisIter.hasNext() && toIter.hasNext()) {
+ Segment thisSeg = thisIter.next();
+ Segment toSeg = toIter.next();
+ if (thisSeg.equals(toSeg)) {
+ ++lengthOfCommonAncestor;
+ } else {
+ break;
+ }
+ }
+ // Create the relative path, starting with parent references to the common ancestor ...
+ int numberOfParentReferences = startingPath.size() - lengthOfCommonAncestor;
+ List<Segment> relativeSegments = new ArrayList<Segment>();
+ for (int i = 0; i != numberOfParentReferences; ++i) {
+ relativeSegments.add(Path.PARENT_SEGMENT);
+ }
+ // Add the segments of this path from the common ancestor ...
+ for (int i = lengthOfCommonAncestor; i < this.size(); ++i) {
+ relativeSegments.add(this.segments.get(i));
+ }
+ if (relativeSegments.isEmpty()) {
+ relativeSegments.add(Path.SELF_SEGMENT);
+ }
+ return new BasicPath(relativeSegments, false);
+ }
- /**
- * {@inheritDoc}
- */
- public Path resolve( Path relativePath ) {
- ArgCheck.isNotNull(relativePath, "relative path");
- if (!this.isAbsolute()) {
- String msg = SpiI18n.pathIsAlreadyAbsolute.text(this.path);
- throw new InvalidPathException(msg);
- }
- if (relativePath.isAbsolute()) {
- String msg = SpiI18n.pathIsNotRelative.text(relativePath);
- throw new InvalidPathException(msg);
- }
- // If the relative path is the self or parent reference ...
- relativePath = relativePath.getNormalizedPath();
- if (relativePath.size() == 1) {
- Segment onlySegment = relativePath.getSegment(0);
- if (onlySegment.isSelfReference()) return this;
- if (onlySegment.isParentReference()) return this.getAncestor();
- }
- List<Segment> segments = new ArrayList<Segment>(this.size() + relativePath.size());
- segments.addAll(this.segments);
- segments.addAll(relativePath.getSegmentsList());
- return new BasicPath(segments, true).getNormalizedPath();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Path resolve( Path relativePath ) {
+ ArgCheck.isNotNull(relativePath, "relative path");
+ if (!this.isAbsolute()) {
+ String msg = SpiI18n.pathIsAlreadyAbsolute.text(this.path);
+ throw new InvalidPathException(msg);
+ }
+ if (relativePath.isAbsolute()) {
+ String msg = SpiI18n.pathIsNotRelative.text(relativePath);
+ throw new InvalidPathException(msg);
+ }
+ // If the relative path is the self or parent reference ...
+ relativePath = relativePath.getNormalizedPath();
+ if (relativePath.size() == 1) {
+ Segment onlySegment = relativePath.getSegment(0);
+ if (onlySegment.isSelfReference()) return this;
+ if (onlySegment.isParentReference()) return this.getAncestor();
+ }
+ List<Segment> segments = new ArrayList<Segment>(this.size() + relativePath.size());
+ segments.addAll(this.segments);
+ segments.addAll(relativePath.getSegmentsList());
+ return new BasicPath(segments, true).getNormalizedPath();
+ }
- /**
- * {@inheritDoc}
- */
- public Path resolveAgainst( Path absolutePath ) {
- ArgCheck.isNotNull(absolutePath, "absolute path");
- return absolutePath.resolve(this);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Path resolveAgainst( Path absolutePath ) {
+ ArgCheck.isNotNull(absolutePath, "absolute path");
+ return absolutePath.resolve(this);
+ }
- /**
- * {@inheritDoc}
- */
- public int size() {
- return this.segments.size();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public int size() {
+ return this.segments.size();
+ }
- /**
- * {@inheritDoc}
- */
- public Path subpath( int beginIndex ) {
- if (beginIndex == 0) return this;
- int size = size();
- if (beginIndex >= size) {
- throw new IndexOutOfBoundsException(SpiI18n.unableToCreateSubpathBeginIndexGreaterThanOrEqualToSize.text(beginIndex,
- size));
- }
- if (size == 0) return ROOT;
- return new BasicPath(this.segments.subList(beginIndex, size), this.isAbsolute());
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Path subpath( int beginIndex ) {
+ if (beginIndex == 0) return this;
+ int size = size();
+ if (beginIndex >= size) {
+ throw new IndexOutOfBoundsException(SpiI18n.unableToCreateSubpathBeginIndexGreaterThanOrEqualToSize.text(beginIndex,
+ size));
+ }
+ if (size == 0) return ROOT;
+ return new BasicPath(this.segments.subList(beginIndex, size), this.isAbsolute());
+ }
- /**
- * {@inheritDoc}
- */
- public Path subpath( int beginIndex,
- int endIndex ) {
- int size = size();
- if (beginIndex == 0) {
- if (endIndex == 0) return ROOT;
- if (endIndex == size) return this;
- }
- if (beginIndex >= size) {
- throw new IndexOutOfBoundsException(SpiI18n.unableToCreateSubpathBeginIndexGreaterThanOrEqualToSize.text(beginIndex,
- size));
- }
- if (beginIndex > endIndex) {
- throw new IndexOutOfBoundsException(
- SpiI18n.unableToCreateSubpathBeginIndexGreaterThanOrEqualToEndingIndex.text(beginIndex,
- endIndex));
- }
- // This reuses the same list, so it's pretty efficient ...
- return new BasicPath(this.segments.subList(beginIndex, endIndex), this.isAbsolute());
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Path subpath( int beginIndex,
+ int endIndex ) {
+ int size = size();
+ if (beginIndex == 0) {
+ if (endIndex == 0) return ROOT;
+ if (endIndex == size) return this;
+ }
+ if (beginIndex >= size) {
+ throw new IndexOutOfBoundsException(SpiI18n.unableToCreateSubpathBeginIndexGreaterThanOrEqualToSize.text(beginIndex,
+ size));
+ }
+ if (beginIndex > endIndex) {
+ throw new IndexOutOfBoundsException(
+ SpiI18n.unableToCreateSubpathBeginIndexGreaterThanOrEqualToEndingIndex.text(beginIndex,
+ endIndex));
+ }
+ // This reuses the same list, so it's pretty efficient ...
+ return new BasicPath(this.segments.subList(beginIndex, endIndex), this.isAbsolute());
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.segments.hashCode();
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return this.segments.hashCode();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals( Object obj ) {
- if (obj == this) return true;
- if (obj instanceof Path) {
- Path that = (Path)obj;
- return this.segments.equals(that.getSegmentsList());
- }
- return false;
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if (obj == this) return true;
+ if (obj instanceof Path) {
+ Path that = (Path)obj;
+ return this.segments.equals(that.getSegmentsList());
+ }
+ return false;
+ }
- /**
- * {@inheritDoc}
- */
- public int compareTo( Path that ) {
- if (this == that) return 0;
- Iterator<Segment> thisIter = this.segments.iterator();
- Iterator<Segment> thatIter = that.iterator();
- while (thisIter.hasNext() && thatIter.hasNext()) {
- Segment thisSegment = thisIter.next();
- Segment thatSegment = thatIter.next();
- int diff = thisSegment.compareTo(thatSegment);
- if (diff != 0) return diff;
- }
- if (thisIter.hasNext()) return 1;
- if (thatIter.hasNext()) return -1;
- return 0;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public int compareTo( Path that ) {
+ if (this == that) return 0;
+ Iterator<Segment> thisIter = this.segments.iterator();
+ Iterator<Segment> thatIter = that.iterator();
+ while (thisIter.hasNext() && thatIter.hasNext()) {
+ Segment thisSegment = thisIter.next();
+ Segment thatSegment = thatIter.next();
+ int diff = thisSegment.compareTo(thatSegment);
+ if (diff != 0) return diff;
+ }
+ if (thisIter.hasNext()) return 1;
+ if (thatIter.hasNext()) return -1;
+ return 0;
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return getString(Path.URL_ENCODER);
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return getString(Path.URL_ENCODER);
+ }
}
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java 2008-06-12 19:57:43 UTC (rev 275)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java 2008-06-12 20:10:35 UTC (rev 276)
@@ -154,7 +154,7 @@
*
* @param connectionName
* @param xaResource
- * @return
+ * @return a new Connection
* @throws RepositorySourceException
*/
protected Connection newConnection( String connectionName,
Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java 2008-06-12 19:57:43 UTC (rev 275)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java 2008-06-12 20:10:35 UTC (rev 276)
@@ -368,14 +368,6 @@
this.userInterface.displaySearchResults(medias);
}
- /**
- * @param metadataNodeName
- * @param mediaType
- * @param mediaNode media node
- * @throws RepositoryException
- * @throws PathNotFoundException
- * @throws ValueFormatException
- */
private MediaInfo extractMediaInfo( String metadataNodeName,
String mediaType,
Node mediaNode ) throws RepositoryException, PathNotFoundException, ValueFormatException {
Modified: trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadata.java
===================================================================
--- trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadata.java 2008-06-12 19:57:43 UTC (rev 275)
+++ trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadata.java 2008-06-12 20:10:35 UTC (rev 276)
@@ -15,8 +15,8 @@
import java.io.DataInput;
import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
-import java.io.IOException;
import java.net.URL;
import java.util.Vector;
@@ -35,8 +35,9 @@
* System.err.println("Not a supported image file format.");
* return;
* }
- * System.out.println(ii.getFormatName() + ", " + ii.getMimeType() + ", " + ii.getWidth() + " x " + ii.getHeight() + " pixels, " + ii.getBitsPerPixel() + " bits per pixel, " + ii.getNumberOfImages()
- * + " image(s), " + ii.getNumberOfComments() + " comment(s).");
+ * System.out.println(ii.getFormatName() + ", " + ii.getMimeType() + ", " + ii.getWidth() + " x " + ii.getHeight() + " pixels, "
+ * + ii.getBitsPerPixel() + " bits per pixel, " + ii.getNumberOfImages() + " image(s), "
+ * + ii.getNumberOfComments() + " comment(s).");
* // there are other properties, check out the API documentation
* </pre>
*
@@ -125,6 +126,7 @@
* unnecessary casting. Also removed the unnecessary else statements where the previous block ended in a return. Also renamed to
* <code>ImageMetadata</code>.
* </ul>
+ *
* @author Marco Schmidt
*/
public class ImageMetadata {
@@ -200,8 +202,8 @@
* The names of the MIME types for all supported file formats. The FORMAT_xyz int constants can be used as index values for
* this array.
*/
- private static final String[] MIME_TYPE_STRINGS =
- {"image/jpeg", "image/gif", "image/png", "image/bmp", "image/pcx", "image/iff", "image/ras", "image/x-portable-bitmap", "image/x-portable-graymap", "image/x-portable-pixmap", "image/psd"};
+ private static final String[] MIME_TYPE_STRINGS = {"image/jpeg", "image/gif", "image/png", "image/bmp", "image/pcx",
+ "image/iff", "image/ras", "image/x-portable-bitmap", "image/x-portable-graymap", "image/x-portable-pixmap", "image/psd"};
private int width;
private int height;
@@ -229,6 +231,7 @@
* Call this method after you have provided an input stream or file using {@link #setInput(InputStream)} or
* {@link #setInput(DataInput)}. If true is returned, the file format was known and information on the file's content can be
* retrieved using the various getXyz methods.
+ *
* @return if information could be retrieved from input
*/
public boolean check() {
@@ -280,7 +283,8 @@
return false;
}
bitsPerPixel = getShortLittleEndian(a, 26);
- if (bitsPerPixel != 1 && bitsPerPixel != 4 && bitsPerPixel != 8 && bitsPerPixel != 16 && bitsPerPixel != 24 && bitsPerPixel != 32) {
+ if (bitsPerPixel != 1 && bitsPerPixel != 4 && bitsPerPixel != 8 && bitsPerPixel != 16 && bitsPerPixel != 24
+ && bitsPerPixel != 32) {
return false;
}
int x = (int)(getIntLittleEndian(a, 36) * 0.0254);
@@ -663,8 +667,10 @@
}
/**
- * Run over String list, return false iff at least one of the arguments equals <code>-c</code>.
+ * Run over String list, return false if and only if at least one of the arguments equals <code>-c</code>.
+ *
* @param args string list to check
+ * @return <code>true</code> none of the supplied parameters is <code>-c</code>
*/
private static boolean determineVerbosity( String[] args ) {
if (args != null && args.length > 0) {
@@ -677,7 +683,11 @@
return true;
}
- private static boolean equals( byte[] a1, int offs1, byte[] a2, int offs2, int num ) {
+ private static boolean equals( byte[] a1,
+ int offs1,
+ byte[] a2,
+ int offs2,
+ int num ) {
while (num-- > 0) {
if (a1[offs1++] != a2[offs2++]) {
return false;
@@ -689,6 +699,7 @@
/**
* If {@link #check()} was successful, returns the image's number of bits per pixel. Does not include transparency information
* like the alpha channel.
+ *
* @return number of bits per image pixel
*/
public int getBitsPerPixel() {
@@ -697,6 +708,7 @@
/**
* Returns the index'th comment retrieved from the file.
+ *
* @param index int index of comment to return
* @return the comment at the supplied index
* @throws IllegalArgumentException if index is smaller than 0 or larger than or equal to the number of comments retrieved
@@ -712,6 +724,7 @@
/**
* If {@link #check()} was successful, returns the image format as one of the FORMAT_xyz constants from this class. Use
* {@link #getFormatName()} to get a textual description of the file format.
+ *
* @return file format as a FORMAT_xyz constant
*/
public int getFormat() {
@@ -720,6 +733,7 @@
/**
* If {@link #check()} was successful, returns the image format's name. Use {@link #getFormat()} to get a unique number.
+ *
* @return file format name
*/
public String getFormatName() {
@@ -731,22 +745,26 @@
/**
* If {@link #check()} was successful, returns one the image's vertical resolution in pixels.
+ *
* @return image height in pixels
*/
public int getHeight() {
return height;
}
- private static int getIntBigEndian( byte[] a, int offs ) {
+ private static int getIntBigEndian( byte[] a,
+ int offs ) {
return (a[offs] & 0xff) << 24 | (a[offs + 1] & 0xff) << 16 | (a[offs + 2] & 0xff) << 8 | a[offs + 3] & 0xff;
}
- private static int getIntLittleEndian( byte[] a, int offs ) {
+ private static int getIntLittleEndian( byte[] a,
+ int offs ) {
return (a[offs + 3] & 0xff) << 24 | (a[offs + 2] & 0xff) << 16 | (a[offs + 1] & 0xff) << 8 | a[offs] & 0xff;
}
/**
* If {@link #check()} was successful, returns a String with the MIME type of the format.
+ *
* @return MIME type, e.g. <code>image/jpeg</code>
*/
public String getMimeType() {
@@ -763,6 +781,7 @@
* If {@link #check()} was successful and {@link #setCollectComments(boolean)} was called with <code>true</code> as
* argument, returns the number of comments retrieved from the input image stream / file. Any number >= 0 and smaller than
* this number of comments is then a valid argument for the {@link #getComment(int)} method.
+ *
* @return number of comments retrieved from input image
*/
public int getNumberOfComments() {
@@ -776,6 +795,7 @@
* Returns the number of images in the examined file. Assumes that <code>setDetermineImageNumber(true);</code> was called
* before a successful call to {@link #check()}. This value can currently be only different from <code>1</code> for GIF
* images.
+ *
* @return number of images in file
*/
public int getNumberOfImages() {
@@ -785,6 +805,7 @@
/**
* Returns the physical height of this image in dots per inch (dpi). Assumes that {@link #check()} was successful. Returns
* <code>-1</code> on failure.
+ *
* @return physical height (in dpi)
* @see #getPhysicalWidthDpi()
* @see #getPhysicalHeightInch()
@@ -796,6 +817,7 @@
/**
* If {@link #check()} was successful, returns the physical width of this image in dpi (dots per inch) or -1 if no value could
* be found.
+ *
* @return physical height (in dpi)
* @see #getPhysicalHeightDpi()
* @see #getPhysicalWidthDpi()
@@ -813,6 +835,7 @@
/**
* If {@link #check()} was successful, returns the physical width of this image in dpi (dots per inch) or -1 if no value could
* be found.
+ *
* @return physical width (in dpi)
* @see #getPhysicalHeightDpi()
* @see #getPhysicalWidthInch()
@@ -825,6 +848,7 @@
/**
* Returns the physical width of an image in inches, or <code>-1.0f</code> if width information is not available. Assumes
* that {@link #check} has been called successfully.
+ *
* @return physical width in inches or <code>-1.0f</code> on failure
* @see #getPhysicalWidthDpi
* @see #getPhysicalHeightInch
@@ -838,16 +862,19 @@
return -1.0f;
}
- private static int getShortBigEndian( byte[] a, int offs ) {
+ private static int getShortBigEndian( byte[] a,
+ int offs ) {
return (a[offs] & 0xff) << 8 | (a[offs + 1] & 0xff);
}
- private static int getShortLittleEndian( byte[] a, int offs ) {
+ private static int getShortLittleEndian( byte[] a,
+ int offs ) {
return (a[offs] & 0xff) | (a[offs + 1] & 0xff) << 8;
}
/**
* If {@link #check()} was successful, returns one the image's horizontal resolution in pixels.
+ *
* @return image width in pixels
*/
public int getWidth() {
@@ -856,6 +883,7 @@
/**
* Returns whether the image is stored in a progressive (also called: interlaced) way.
+ *
* @return true for progressive/interlaced, false otherwise
*/
public boolean isProgressive() {
@@ -866,6 +894,7 @@
* To use this class as a command line application, give it either some file names as parameters (information on them will be
* printed to standard output, one line per file) or call it with no parameters. It will then check data given to it via
* standard input.
+ *
* @param args the program arguments which must be file names
*/
public static void main( String[] args ) {
@@ -901,7 +930,9 @@
}
}
- private static void print( String sourceName, ImageMetadata ii, boolean verbose ) {
+ private static void print( String sourceName,
+ ImageMetadata ii,
+ boolean verbose ) {
if (verbose) {
printVerbose(sourceName, ii);
} else {
@@ -909,27 +940,38 @@
}
}
- private static void printCompact( String sourceName, ImageMetadata imageMetadata ) {
+ private static void printCompact( String sourceName,
+ ImageMetadata imageMetadata ) {
final String SEP = "\t";
- System.out.println(sourceName + SEP + imageMetadata.getFormatName() + SEP + imageMetadata.getMimeType() + SEP + imageMetadata.getWidth() + SEP + imageMetadata.getHeight() + SEP
- + imageMetadata.getBitsPerPixel() + SEP + imageMetadata.getNumberOfImages() + SEP + imageMetadata.getPhysicalWidthDpi() + SEP + imageMetadata.getPhysicalHeightDpi() + SEP
- + imageMetadata.getPhysicalWidthInch() + SEP + imageMetadata.getPhysicalHeightInch() + SEP + imageMetadata.isProgressive());
+ System.out.println(sourceName + SEP + imageMetadata.getFormatName() + SEP + imageMetadata.getMimeType() + SEP
+ + imageMetadata.getWidth() + SEP + imageMetadata.getHeight() + SEP + imageMetadata.getBitsPerPixel()
+ + SEP + imageMetadata.getNumberOfImages() + SEP + imageMetadata.getPhysicalWidthDpi() + SEP
+ + imageMetadata.getPhysicalHeightDpi() + SEP + imageMetadata.getPhysicalWidthInch() + SEP
+ + imageMetadata.getPhysicalHeightInch() + SEP + imageMetadata.isProgressive());
}
- private static void printLine( int indentLevels, String text, float value, float minValidValue ) {
+ private static void printLine( int indentLevels,
+ String text,
+ float value,
+ float minValidValue ) {
if (value < minValidValue) {
return;
}
printLine(indentLevels, text, Float.toString(value));
}
- private static void printLine( int indentLevels, String text, int value, int minValidValue ) {
+ private static void printLine( int indentLevels,
+ String text,
+ int value,
+ int minValidValue ) {
if (value >= minValidValue) {
printLine(indentLevels, text, Integer.toString(value));
}
}
- private static void printLine( int indentLevels, String text, String value ) {
+ private static void printLine( int indentLevels,
+ String text,
+ String value ) {
if (value == null || value.length() == 0) {
return;
}
@@ -943,7 +985,8 @@
System.out.println(value);
}
- private static void printVerbose( String sourceName, ImageMetadata ii ) {
+ private static void printVerbose( String sourceName,
+ ImageMetadata ii ) {
printLine(0, null, sourceName);
printLine(1, "File format: ", ii.getFormatName());
printLine(1, "MIME type: ", ii.getMimeType());
@@ -980,7 +1023,9 @@
return a.length;
}
- private int read( byte[] a, int offset, int num ) throws IOException {
+ private int read( byte[] a,
+ int offset,
+ int num ) throws IOException {
if (in != null) {
return in.read(a, offset, num);
}
@@ -1004,7 +1049,10 @@
return sb.toString();
}
- private static void run( String sourceName, InputStream in, ImageMetadata imageMetadata, boolean verbose ) {
+ private static void run( String sourceName,
+ InputStream in,
+ ImageMetadata imageMetadata,
+ boolean verbose ) {
imageMetadata.setInput(in);
imageMetadata.setDetermineImageNumber(true);
imageMetadata.setCollectComments(verbose);
@@ -1016,6 +1064,7 @@
/**
* Specify whether textual comments are supposed to be extracted from input. Default is <code>false</code>. If enabled,
* comments will be added to an internal list.
+ *
* @param newValue if <code>true</code>, this class will read comments
* @see #getNumberOfComments
* @see #getComment
@@ -1030,6 +1079,7 @@
* time-consuming task. Not all file formats support more than one image. If this method is called with <code>true</code> as
* argument, the actual number of images can be queried via {@link #getNumberOfImages()} after a successful call to
* {@link #check()}.
+ *
* @param newValue will the number of images be determined?
* @see #getNumberOfImages
*/
@@ -1040,6 +1090,7 @@
/**
* Set the input stream to the argument stream (or file). Note that {@link java.io.RandomAccessFile} implements
* {@link java.io.DataInput}.
+ *
* @param dataInput the input stream to read from
*/
public void setInput( DataInput dataInput ) {
@@ -1049,6 +1100,7 @@
/**
* Set the input stream to the argument stream (or file).
+ *
* @param inputStream the input stream to read from
*/
public void setInput( InputStream inputStream ) {
17 years, 6 months
DNA SVN: r275 - trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl.
by dna-commits@lists.jboss.org
Author: jverhaeg(a)redhat.com
Date: 2008-06-12 15:57:43 -0400 (Thu, 12 Jun 2008)
New Revision: 275
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java
Log:
Corrected some incorrect use of generics
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java 2008-06-12 18:17:17 UTC (rev 274)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java 2008-06-12 19:57:43 UTC (rev 275)
@@ -128,7 +128,7 @@
}
}
- private AbstractValueFactory<?> factory;
+ private AbstractValueFactory<String> factory;
@Before
public void beforeEach() {
17 years, 6 months
DNA SVN: r274 - in trunk: dna-jcr and 19 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-06-12 14:17:17 -0400 (Thu, 12 Jun 2008)
New Revision: 274
Added:
trunk/dna-jcr/
trunk/dna-jcr/.classpath
trunk/dna-jcr/.project
trunk/dna-jcr/.settings/
trunk/dna-jcr/.settings/org.eclipse.jdt.core.prefs
trunk/dna-jcr/pom.xml
trunk/dna-jcr/src/
trunk/dna-jcr/src/main/
trunk/dna-jcr/src/main/java/
trunk/dna-jcr/src/main/java/org/
trunk/dna-jcr/src/main/java/org/jboss/
trunk/dna-jcr/src/main/java/org/jboss/dna/
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaNamespaceRegistry.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaRepository.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaSession.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaWorkspace.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
trunk/dna-jcr/src/main/resources/
trunk/dna-jcr/src/main/resources/org/
trunk/dna-jcr/src/main/resources/org/jboss/
trunk/dna-jcr/src/main/resources/org/jboss/dna/
trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/
trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
trunk/dna-jcr/src/test/
trunk/dna-jcr/src/test/java/
trunk/dna-jcr/src/test/java/org/
trunk/dna-jcr/src/test/java/org/jboss/
trunk/dna-jcr/src/test/java/org/jboss/dna/
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrI18nTest.java
trunk/dna-jcr/src/test/resources/
Modified:
trunk/pom.xml
Log:
DNA-86 Create Maven project for JCR API implementation - Added new project with stub implementations of a few of the JCR API interfaces.
Property changes on: trunk/dna-jcr
___________________________________________________________________
Name: svn:ignore
+ target
Added: trunk/dna-jcr/.classpath
===================================================================
--- trunk/dna-jcr/.classpath (rev 0)
+++ trunk/dna-jcr/.classpath 2008-06-12 18:17:17 UTC (rev 274)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: trunk/dna-jcr/.project
===================================================================
--- trunk/dna-jcr/.project (rev 0)
+++ trunk/dna-jcr/.project 2008-06-12 18:17:17 UTC (rev 274)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>dna-jcr</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
Added: trunk/dna-jcr/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/dna-jcr/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/dna-jcr/.settings/org.eclipse.jdt.core.prefs 2008-06-12 18:17:17 UTC (rev 274)
@@ -0,0 +1,60 @@
+#Thu Jun 12 12:38:24 CDT 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=error
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=error
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=error
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=error
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=error
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=error
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeUncheckedExceptions=disabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error
Added: trunk/dna-jcr/pom.xml
===================================================================
--- trunk/dna-jcr/pom.xml (rev 0)
+++ trunk/dna-jcr/pom.xml 2008-06-12 18:17:17 UTC (rev 274)
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna</artifactId>
+ <version>0.2-SNAPSHOT</version>
+ </parent>
+ <!-- The groupId and version values are inherited from parent -->
+ <artifactId>dna-jcr</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss DNA JCR implementation</name>
+ <description>JBoss DNA implementation of the JCR API</description>
+ <url>http://labs.jboss.org/dna</url>
+
+ <properties>
+ <dna-version>0.2-SNAPSHOT</dna-version>
+ </properties>
+ <!--
+ Define the dependencies. Note that all version and scopes default to those
+ defined in the dependencyManagement section of the parent pom.
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-common</artifactId>
+ <version>${dna-version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-repository</artifactId>
+ </dependency>
+ <!--
+ Testing (note the scope)
+ -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding for testing)
+ -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ Java Concurrency in Practice annotations
+ -->
+ <dependency>
+ <groupId>net.jcip</groupId>
+ <artifactId>jcip-annotations</artifactId>
+ </dependency>
+ <!--
+ Java Content Repository API
+ -->
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ </dependency>
+ <!--
+ Apache JCR API unit tests (for any JCR implementation), which is a subset of the official TCK
+ -->
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-jcr-tests</artifactId>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaNamespaceRegistry.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaNamespaceRegistry.java (rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaNamespaceRegistry.java 2008-06-12 18:17:17 UTC (rev 274)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.NamespaceException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+
+/**
+ *
+ * @author Randall Hauch
+ */
+public class DnaNamespaceRegistry implements NamespaceRegistry {
+
+ /**
+ *
+ */
+ public DnaNamespaceRegistry() {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getPrefix( String uri ) throws NamespaceException, RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String[] getPrefixes() throws RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getURI( String prefix ) throws NamespaceException, RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String[] getURIs() throws RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void registerNamespace( String prefix, String uri ) throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void unregisterNamespace( String prefix ) throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
+ }
+
+}
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaRepository.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaRepository.java (rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaRepository.java 2008-06-12 18:17:17 UTC (rev 274)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import javax.jcr.Credentials;
+import javax.jcr.LoginException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+/**
+ * @author Randall Hauch
+ */
+public class DnaRepository implements Repository {
+
+ /**
+ *
+ */
+ public DnaRepository() {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getDescriptor( String key ) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String[] getDescriptorKeys() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Session login() throws LoginException, RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Session login( Credentials credentials ) throws LoginException, RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Session login( String workspaceName ) throws LoginException, NoSuchWorkspaceException, RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Session login( Credentials credentials, String workspaceName ) throws LoginException, NoSuchWorkspaceException, RepositoryException {
+ return null;
+ }
+
+ protected void logout( DnaSession session ) {
+
+ }
+
+ protected String[] getWorkspaceNamesAccessibleBy( String username, Credentials credentials ) throws RepositoryException {
+ throw new UnsupportedOperationException();
+ }
+}
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaSession.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaSession.java (rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaSession.java 2008-06-12 18:17:17 UTC (rev 274)
@@ -0,0 +1,312 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.AccessControlException;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Credentials;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.InvalidSerializedDataException;
+import javax.jcr.Item;
+import javax.jcr.ItemExistsException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.LoginException;
+import javax.jcr.NamespaceException;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.ValueFactory;
+import javax.jcr.Workspace;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.version.VersionException;
+import net.jcip.annotations.GuardedBy;
+import net.jcip.annotations.ThreadSafe;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Randall Hauch
+ */
+@ThreadSafe
+public class DnaSession implements Session {
+
+ private final DnaWorkspace workspace;
+ private final DnaRepository repository;
+ private final String username;
+ private final Credentials credentials;
+ private final ReadWriteLock sessionLock = new ReentrantReadWriteLock();
+ @GuardedBy( "sessionLock" )
+ private boolean connected;
+
+ /**
+ * @param repository the {@link DnaRepository} that owns this session; may not be null
+ * @param workspaceName the name of the workspace to which this session is connected; may not be null
+ * @param credentials the credentials that were used to authentiate this session; may not be null
+ * @param username the username used to create this session; may not be null
+ */
+ /* package */DnaSession( DnaRepository repository, String workspaceName, Credentials credentials, String username ) {
+ assert repository != null;
+ assert workspaceName != null;
+ assert credentials != null;
+ assert username != null;
+ this.workspace = new DnaWorkspace(repository, workspaceName, this);
+ this.repository = repository;
+ this.credentials = credentials;
+ this.username = username;
+ this.connected = true;
+ }
+
+ /* package */Credentials getCredentials() {
+ return this.credentials;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addLockToken( String lt ) throws LockException, RepositoryException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void checkPermission( String absPath, String actions ) throws AccessControlException, RepositoryException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void exportDocumentView( String absPath, ContentHandler contentHandler, boolean skipBinary, boolean noRecurse ) throws PathNotFoundException, SAXException, RepositoryException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void exportDocumentView( String absPath, OutputStream out, boolean skipBinary, boolean noRecurse ) throws IOException, PathNotFoundException, RepositoryException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void exportSystemView( String absPath, ContentHandler contentHandler, boolean skipBinary, boolean noRecurse ) throws PathNotFoundException, SAXException, RepositoryException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void exportSystemView( String absPath, OutputStream out, boolean skipBinary, boolean noRecurse ) throws IOException, PathNotFoundException, RepositoryException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getAttribute( String name ) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String[] getAttributeNames() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ContentHandler getImportContentHandler( String parentAbsPath, int uuidBehavior )
+ throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Item getItem( String absPath ) throws PathNotFoundException, RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String[] getLockTokens() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getNamespacePrefix( String uri ) throws NamespaceException, RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String[] getNamespacePrefixes() throws RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getNamespaceURI( String prefix ) throws NamespaceException, RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Node getNodeByUUID( String uuid ) throws ItemNotFoundException, RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Repository getRepository() {
+ return this.repository;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Node getRootNode() throws RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getUserID() {
+ return this.username;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ValueFactory getValueFactory() throws UnsupportedRepositoryOperationException, RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Workspace getWorkspace() {
+ return this.workspace;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean hasPendingChanges() throws RepositoryException {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Session impersonate( Credentials credentials ) throws LoginException, RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void importXML( String parentAbsPath, InputStream in, int uuidBehavior )
+ throws IOException, PathNotFoundException, ItemExistsException, ConstraintViolationException, VersionException, InvalidSerializedDataException, LockException, RepositoryException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isLive() {
+ Lock lock = this.sessionLock.readLock();
+ try {
+ return connected;
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean itemExists( String absPath ) throws RepositoryException {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void logout() {
+ Lock lock = this.sessionLock.writeLock();
+ try {
+ repository.logout(this);
+ connected = false;
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void move( String srcAbsPath, String destAbsPath ) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, RepositoryException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void refresh( boolean keepChanges ) throws RepositoryException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removeLockToken( String lt ) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void save()
+ throws AccessDeniedException, ItemExistsException, ConstraintViolationException, InvalidItemStateException, VersionException, LockException, NoSuchNodeTypeException, RepositoryException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setNamespacePrefix( String newPrefix, String existingUri ) throws NamespaceException, RepositoryException {
+ }
+
+}
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaWorkspace.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaWorkspace.java (rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaWorkspace.java 2008-06-12 18:17:17 UTC (rev 274)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.io.IOException;
+import java.io.InputStream;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.InvalidSerializedDataException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Workspace;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.observation.ObservationManager;
+import javax.jcr.query.QueryManager;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionException;
+import net.jcip.annotations.ThreadSafe;
+import org.xml.sax.ContentHandler;
+
+/**
+ * @author Randall Hauch
+ */
+@ThreadSafe
+public class DnaWorkspace implements Workspace {
+
+ private final String name;
+ private final DnaSession session;
+ private final DnaRepository repository;
+
+ /**
+ * @param repository the repository instance that owns this workspace; may not be null
+ * @param name the name of the workspace; may not be null
+ * @param session the session that owns this workspace; may not be null
+ */
+ /* package */DnaWorkspace( DnaRepository repository, String name, DnaSession session ) {
+ assert repository != null;
+ assert session != null;
+ assert name != null;
+ this.repository = repository;
+ this.session = session;
+ this.name = name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void clone( String srcWorkspace, String srcAbsPath, String destAbsPath, boolean removeExisting )
+ throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void copy( String srcAbsPath, String destAbsPath )
+ throws ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void copy( String srcWorkspace, String srcAbsPath, String destAbsPath )
+ throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String[] getAccessibleWorkspaceNames() throws RepositoryException {
+ return repository.getWorkspaceNamesAccessibleBy(session.getUserID(), session.getCredentials());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ContentHandler getImportContentHandler( String parentAbsPath, int uuidBehavior )
+ throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, AccessDeniedException, RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public NamespaceRegistry getNamespaceRegistry() throws RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public NodeTypeManager getNodeTypeManager() throws RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ObservationManager getObservationManager() throws UnsupportedRepositoryOperationException, RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public QueryManager getQueryManager() throws RepositoryException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Session getSession() {
+ return this.session;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void importXML( String parentAbsPath, InputStream in, int uuidBehavior )
+ throws IOException, PathNotFoundException, ItemExistsException, ConstraintViolationException, InvalidSerializedDataException, LockException, AccessDeniedException, RepositoryException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void move( String srcAbsPath, String destAbsPath )
+ throws ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void restore( Version[] versions, boolean removeExisting )
+ throws ItemExistsException, UnsupportedRepositoryOperationException, VersionException, LockException, InvalidItemStateException, RepositoryException {
+ }
+
+}
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java (rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java 2008-06-12 18:17:17 UTC (rev 274)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.jcr;
+
+import java.util.Locale;
+import java.util.Set;
+import org.jboss.dna.common.i18n.I18n;
+
+/**
+ * @author Randall Hauch
+ */
+public final class JcrI18n {
+
+ // public static I18n invalidStateString;
+
+ static {
+ try {
+ I18n.initialize(JcrI18n.class);
+ } catch (final Exception err) {
+ System.err.println(err);
+ }
+ }
+
+ public static Set<Locale> getLocalizationProblemLocales() {
+ return I18n.getLocalizationProblemLocales(JcrI18n.class);
+ }
+
+ public static Set<String> getLocalizationProblems() {
+ return I18n.getLocalizationProblems(JcrI18n.class);
+ }
+
+ public static Set<String> getLocalizationProblems( Locale locale ) {
+ return I18n.getLocalizationProblems(JcrI18n.class, locale);
+ }
+}
Added: trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
===================================================================
--- trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties (rev 0)
+++ trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties 2008-06-12 18:17:17 UTC (rev 274)
@@ -0,0 +1,21 @@
+#
+# JBoss, Home of Professional Open Source.
+# Copyright 2008, Red Hat Middleware LLC, and individual contributors
+# as indicated by the @author tags. See the copyright.txt file in the
+# distribution for a full listing of individual contributors.
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# This software is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+#
Added: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrI18nTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrI18nTest.java (rev 0)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrI18nTest.java 2008-06-12 18:17:17 UTC (rev 274)
@@ -0,0 +1,13 @@
+package org.jboss.dna.jcr;
+
+import org.jboss.dna.common.AbstractI18nTest;
+
+/**
+ * @author John Verhaeg
+ */
+public class JcrI18nTest extends AbstractI18nTest {
+
+ public JcrI18nTest() {
+ super(JcrI18n.class);
+ }
+}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2008-06-12 17:36:18 UTC (rev 273)
+++ trunk/pom.xml 2008-06-12 18:17:17 UTC (rev 274)
@@ -58,6 +58,7 @@
<module>dna-common</module>
<module>dna-spi</module>
<module>dna-repository</module>
+ <module>dna-jcr</module>
<module>dna-maven-classloader</module>
<module>sequencers/dna-sequencer-images</module>
<module>sequencers/dna-sequencer-mp3</module>
17 years, 6 months
DNA SVN: r273 - in trunk: dna-common/src/main/java/org/jboss/dna/common and 20 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-06-12 13:36:18 -0400 (Thu, 12 Jun 2008)
New Revision: 273
Modified:
trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java
trunk/dna-common/src/main/java/org/jboss/dna/common/SystemFailureException.java
trunk/dna-common/src/main/java/org/jboss/dna/common/collection/UnmodifiableProperties.java
trunk/dna-common/src/main/java/org/jboss/dna/common/component/AbstractComponent.java
trunk/dna-common/src/main/java/org/jboss/dna/common/i18n/I18n.java
trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressStatus.java
trunk/dna-common/src/main/java/org/jboss/dna/common/util/ArgCheck.java
trunk/dna-common/src/main/java/org/jboss/dna/common/util/ClassUtil.java
trunk/dna-common/src/main/java/org/jboss/dna/common/util/Logger.java
trunk/dna-common/src/main/java/org/jboss/dna/common/util/StringUtil.java
trunk/dna-common/src/main/java/org/jboss/dna/common/xml/SimpleNamespaceContext.java
trunk/dna-common/src/test/java/org/jboss/dna/common/AbstractI18nTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/component/ComponentLibraryTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/i18n/I18nTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/util/ArgCheckTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/util/LoggerTest.java
trunk/dna-maven-classloader/src/main/java/org/jboss/dna/maven/MavenRepositoryException.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepositorySource.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederationException.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/InvalidRuleSetException.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/InvalidSequencerPathExpression.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerException.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerPathExpression.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/InvalidPathException.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/IoException.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/NamespaceException.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PathNotFoundException.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PropertyType.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueComparators.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicCreateNodeCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetChildrenCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetNodeCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetPropertiesCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicSetPropertiesCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositorySourceException.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicName.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPath.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPathSegment.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinary.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTime.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReference.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java
Log:
Corrected several compiler warnings regarding serializable classes and improper use of generics.
Modified: trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java
===================================================================
--- trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -56,6 +56,9 @@
@ThreadSafe
public class JBossCacheSource implements RepositorySource, ObjectFactory {
+ /**
+ */
+ private static final long serialVersionUID = 1530716494560375111L;
public static final String DEFAULT_UUID_PROPERTY_NAMESPACE = "http://www.jboss.org/dna/connector/jbosscache";
public static final String DEFAULT_UUID_PROPERTY_NAME = "uuid";
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/SystemFailureException.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/SystemFailureException.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/SystemFailureException.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -30,6 +30,10 @@
public class SystemFailureException extends RuntimeException {
/**
+ */
+ private static final long serialVersionUID = 8281373010920861138L;
+
+ /**
*
*/
public SystemFailureException() {
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/collection/UnmodifiableProperties.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/collection/UnmodifiableProperties.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/collection/UnmodifiableProperties.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -39,6 +39,9 @@
*/
public class UnmodifiableProperties extends Properties {
+ /**
+ */
+ private static final long serialVersionUID = -4670639332874922546L;
private Properties delegate;
public UnmodifiableProperties( Properties props ) {
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/component/AbstractComponent.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/component/AbstractComponent.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/component/AbstractComponent.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -21,24 +21,23 @@
*/
package org.jboss.dna.common.component;
-
/**
- *
+ * @param <T> the type of configuration
* @author Randall Hauch
*/
-public class AbstractComponent implements Component {
+public class AbstractComponent<T extends ComponentConfig> implements Component<T> {
/**
* {@inheritDoc}
*/
- public ComponentConfig getConfiguration() {
+ public T getConfiguration() {
return null;
}
/**
* {@inheritDoc}
*/
- public void setConfiguration( ComponentConfig configuration ) {
+ public void setConfiguration( T configuration ) {
}
}
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/i18n/I18n.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/i18n/I18n.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/i18n/I18n.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -46,391 +46,395 @@
/**
* Manages the initialization of internationalization (i18n) files, substitution of values within i18n message placeholders, and
* dynamically reading properties from i18n property files.
- *
+ *
* @author John Verhaeg
* @author Randall Hauch
*/
@ThreadSafe
public final class I18n {
- private static final LocalizationRepository DEFAULT_LOCALIZATION_REPOSITORY = new ClasspathLocalizationRepository();
+ private static final LocalizationRepository DEFAULT_LOCALIZATION_REPOSITORY = new ClasspathLocalizationRepository();
- /**
- * The first level of this map indicates whether an i18n class has been localized to a particular locale. The second level
- * contains any problems encountered during localization.
- */
- static final ConcurrentMap<Locale, Map<Class, Set<String>>> LOCALE_TO_CLASS_TO_PROBLEMS_MAP = new ConcurrentHashMap<Locale, Map<Class, Set<String>>>();
+ /**
+ * The first level of this map indicates whether an i18n class has been localized to a particular locale. The second level
+ * contains any problems encountered during localization.
+ */
+ static final ConcurrentMap<Locale, Map<Class<?>, Set<String>>> LOCALE_TO_CLASS_TO_PROBLEMS_MAP = new ConcurrentHashMap<Locale, Map<Class<?>, Set<String>>>();
- private static LocalizationRepository localizationRepository = DEFAULT_LOCALIZATION_REPOSITORY;
+ private static LocalizationRepository localizationRepository = DEFAULT_LOCALIZATION_REPOSITORY;
- /**
- * Note, calling this method will <em>not</em> trigger localization of the supplied internationalization class.
- *
- * @param i18nClass The internalization class for which localization problem locales should be returned.
- * @return The locales for which localization problems were encountered while localizing the supplied internationalization
- * class; never <code>null</code>.
- */
- public static Set<Locale> getLocalizationProblemLocales( Class i18nClass ) {
- ArgCheck.isNotNull(i18nClass, "i18nClass");
- Set<Locale> locales = new HashSet<Locale>(LOCALE_TO_CLASS_TO_PROBLEMS_MAP.size());
- for (Entry<Locale, Map<Class, Set<String>>> localeEntry : LOCALE_TO_CLASS_TO_PROBLEMS_MAP.entrySet()) {
- for (Entry<Class, Set<String>> classEntry : localeEntry.getValue().entrySet()) {
- if (!classEntry.getValue().isEmpty()) {
- locales.add(localeEntry.getKey());
- break;
- }
- }
- }
- return locales;
- }
+ /**
+ * Note, calling this method will <em>not</em> trigger localization of the supplied internationalization class.
+ *
+ * @param i18nClass The internalization class for which localization problem locales should be returned.
+ * @return The locales for which localization problems were encountered while localizing the supplied internationalization
+ * class; never <code>null</code>.
+ */
+ public static Set<Locale> getLocalizationProblemLocales( Class<?> i18nClass ) {
+ ArgCheck.isNotNull(i18nClass, "i18nClass");
+ Set<Locale> locales = new HashSet<Locale>(LOCALE_TO_CLASS_TO_PROBLEMS_MAP.size());
+ for (Entry<Locale, Map<Class<?>, Set<String>>> localeEntry : LOCALE_TO_CLASS_TO_PROBLEMS_MAP.entrySet()) {
+ for (Entry<Class<?>, Set<String>> classEntry : localeEntry.getValue().entrySet()) {
+ if (!classEntry.getValue().isEmpty()) {
+ locales.add(localeEntry.getKey());
+ break;
+ }
+ }
+ }
+ return locales;
+ }
- /**
- * Note, calling this method will <em>not</em> trigger localization of the supplied internationalization class.
- *
- * @param i18nClass The internalization class for which localization problems should be returned.
- * @return The localization problems encountered while localizing the supplied internationalization class to the default
- * locale; never <code>null</code>.
- */
- public static Set<String> getLocalizationProblems( Class i18nClass ) {
- return getLocalizationProblems(i18nClass, null);
- }
+ /**
+ * Note, calling this method will <em>not</em> trigger localization of the supplied internationalization class.
+ *
+ * @param i18nClass The internalization class for which localization problems should be returned.
+ * @return The localization problems encountered while localizing the supplied internationalization class to the default
+ * locale; never <code>null</code>.
+ */
+ public static Set<String> getLocalizationProblems( Class<?> i18nClass ) {
+ return getLocalizationProblems(i18nClass, null);
+ }
- /**
- * Note, calling this method will <em>not</em> trigger localization of the supplied internationalization class.
- *
- * @param i18nClass The internalization class for which localization problems should be returned.
- * @param locale The locale for which localization problems should be returned. If <code>null</code>, the default locale
- * will be used.
- * @return The localization problems encountered while localizing the supplied internationalization class to the supplied
- * locale; never <code>null</code>.
- */
- public static Set<String> getLocalizationProblems( Class i18nClass,
- Locale locale ) {
- ArgCheck.isNotNull(i18nClass, "i18nClass");
- Map<Class, Set<String>> classToProblemsMap = LOCALE_TO_CLASS_TO_PROBLEMS_MAP.get(locale == null ? Locale.getDefault() : locale);
- if (classToProblemsMap == null) {
- return Collections.emptySet();
- }
- Set<String> problems = classToProblemsMap.get(i18nClass);
- if (problems == null) {
- return Collections.emptySet();
- }
- return problems;
- }
+ /**
+ * Note, calling this method will <em>not</em> trigger localization of the supplied internationalization class.
+ *
+ * @param i18nClass The internalization class for which localization problems should be returned.
+ * @param locale The locale for which localization problems should be returned. If <code>null</code>, the default locale
+ * will be used.
+ * @return The localization problems encountered while localizing the supplied internationalization class to the supplied
+ * locale; never <code>null</code>.
+ */
+ public static Set<String> getLocalizationProblems( Class<?> i18nClass,
+ Locale locale ) {
+ ArgCheck.isNotNull(i18nClass, "i18nClass");
+ Map<Class<?>, Set<String>> classToProblemsMap = LOCALE_TO_CLASS_TO_PROBLEMS_MAP.get(locale == null ? Locale.getDefault() : locale);
+ if (classToProblemsMap == null) {
+ return Collections.emptySet();
+ }
+ Set<String> problems = classToProblemsMap.get(i18nClass);
+ if (problems == null) {
+ return Collections.emptySet();
+ }
+ return problems;
+ }
- /**
- * Get the repository of localized messages. By default, this instance uses a {@link ClasspathLocalizationRepository} that
- * uses this class' classloader.
- *
- * @return localizationRepository
- */
- public static LocalizationRepository getLocalizationRepository() {
- return localizationRepository;
- }
+ /**
+ * Get the repository of localized messages. By default, this instance uses a {@link ClasspathLocalizationRepository} that
+ * uses this class' classloader.
+ *
+ * @return localizationRepository
+ */
+ public static LocalizationRepository getLocalizationRepository() {
+ return localizationRepository;
+ }
- /**
- * Set the repository of localized messages. If <code>null</code>, a {@link ClasspathLocalizationRepository} instance that
- * uses this class loader will be used.
- *
- * @param localizationRepository the localization repository to use; may be <code>null</code> if the default repository
- * should be used.
- */
- public static void setLocalizationRepository( LocalizationRepository localizationRepository ) {
- I18n.localizationRepository = localizationRepository != null ? localizationRepository : DEFAULT_LOCALIZATION_REPOSITORY;
- }
+ /**
+ * Set the repository of localized messages. If <code>null</code>, a {@link ClasspathLocalizationRepository} instance that
+ * uses this class loader will be used.
+ *
+ * @param localizationRepository the localization repository to use; may be <code>null</code> if the default repository
+ * should be used.
+ */
+ public static void setLocalizationRepository( LocalizationRepository localizationRepository ) {
+ I18n.localizationRepository = localizationRepository != null ? localizationRepository : DEFAULT_LOCALIZATION_REPOSITORY;
+ }
- /**
- * Initializes the internationalization fields declared on the supplied class. Internationalization fields must be public,
- * static, not final, and of type <code>I18n</code>. The supplied class must not be an interface (of course), but has no
- * restrictions as to what class it may extend or what interfaces it must implement.
- *
- * @param i18nClass A class declaring one or more public, static, non-final fields of type <code>I18n</code>.
- */
- public static void initialize( Class i18nClass ) {
- ArgCheck.isNotNull(i18nClass, "i18nClass");
- if (i18nClass.isInterface()) {
- throw new IllegalArgumentException(CommonI18n.i18nClassInterface.text(i18nClass.getName()));
- }
+ /**
+ * Initializes the internationalization fields declared on the supplied class. Internationalization fields must be public,
+ * static, not final, and of type <code>I18n</code>. The supplied class must not be an interface (of course), but has no
+ * restrictions as to what class it may extend or what interfaces it must implement.
+ *
+ * @param i18nClass A class declaring one or more public, static, non-final fields of type <code>I18n</code>.
+ */
+ public static void initialize( Class<?> i18nClass ) {
+ ArgCheck.isNotNull(i18nClass, "i18nClass");
+ if (i18nClass.isInterface()) {
+ throw new IllegalArgumentException(CommonI18n.i18nClassInterface.text(i18nClass.getName()));
+ }
- synchronized (i18nClass) {
- // Find all public static non-final String fields in the supplied class and instantiate an I18n object for each.
- try {
- for (Field fld : i18nClass.getDeclaredFields()) {
+ synchronized (i18nClass) {
+ // Find all public static non-final String fields in the supplied class and instantiate an I18n object for each.
+ try {
+ for (Field fld : i18nClass.getDeclaredFields()) {
- // Ensure field is of type I18n
- if (fld.getType() == I18n.class) {
+ // Ensure field is of type I18n
+ if (fld.getType() == I18n.class) {
- // Ensure field is public
- if ((fld.getModifiers() & Modifier.PUBLIC) != Modifier.PUBLIC) {
- throw new SystemFailureException(CommonI18n.i18nFieldNotPublic.text(fld.getName(), i18nClass));
- }
+ // Ensure field is public
+ if ((fld.getModifiers() & Modifier.PUBLIC) != Modifier.PUBLIC) {
+ throw new SystemFailureException(CommonI18n.i18nFieldNotPublic.text(fld.getName(), i18nClass));
+ }
- // Ensure field is static
- if ((fld.getModifiers() & Modifier.STATIC) != Modifier.STATIC) {
- throw new SystemFailureException(CommonI18n.i18nFieldNotStatic.text(fld.getName(), i18nClass));
- }
+ // Ensure field is static
+ if ((fld.getModifiers() & Modifier.STATIC) != Modifier.STATIC) {
+ throw new SystemFailureException(CommonI18n.i18nFieldNotStatic.text(fld.getName(), i18nClass));
+ }
- // Ensure field is not final
- if ((fld.getModifiers() & Modifier.FINAL) == Modifier.FINAL) {
- throw new SystemFailureException(CommonI18n.i18nFieldFinal.text(fld.getName(), i18nClass));
- }
+ // Ensure field is not final
+ if ((fld.getModifiers() & Modifier.FINAL) == Modifier.FINAL) {
+ throw new SystemFailureException(CommonI18n.i18nFieldFinal.text(fld.getName(), i18nClass));
+ }
- // Ensure we can access field even if it's in a private class
- ClassUtil.makeAccessible(fld);
+ // Ensure we can access field even if it's in a private class
+ ClassUtil.makeAccessible(fld);
- // Initialize field. Do this every time the class is initialized (or re-initialized)
- fld.set(null, new I18n(fld.getName(), i18nClass));
- }
- }
+ // Initialize field. Do this every time the class is initialized (or re-initialized)
+ fld.set(null, new I18n(fld.getName(), i18nClass));
+ }
+ }
- // Remove all entries for the supplied i18n class to indicate it has not been localized.
- for (Entry<Locale, Map<Class, Set<String>>> entry : LOCALE_TO_CLASS_TO_PROBLEMS_MAP.entrySet()) {
- entry.getValue().remove(i18nClass);
- }
- } catch (IllegalAccessException err) {
- // If this happens, it will happen with the first field visited in the above loop
- throw new IllegalArgumentException(CommonI18n.i18nClassNotPublic.text(i18nClass));
- }
- }
- }
+ // Remove all entries for the supplied i18n class to indicate it has not been localized.
+ for (Entry<Locale, Map<Class<?>, Set<String>>> entry : LOCALE_TO_CLASS_TO_PROBLEMS_MAP.entrySet()) {
+ entry.getValue().remove(i18nClass);
+ }
+ } catch (IllegalAccessException err) {
+ // If this happens, it will happen with the first field visited in the above loop
+ throw new IllegalArgumentException(CommonI18n.i18nClassNotPublic.text(i18nClass));
+ }
+ }
+ }
- /**
- * Synchronized on the supplied internalization class.
- *
- * @param i18nClass The internalization class being localized
- * @param locale The locale to which the supplied internationalization class should be localized.
- */
- private static void localize( final Class i18nClass,
- final Locale locale ) {
- assert i18nClass != null;
- assert locale != null;
- // Create a class-to-problem map for this locale if one doesn't exist, else get the existing one.
- Map<Class, Set<String>> classToProblemsMap = new ConcurrentHashMap<Class, Set<String>>();
- Map<Class, Set<String>> existingClassToProblemsMap = LOCALE_TO_CLASS_TO_PROBLEMS_MAP.putIfAbsent(locale,
- classToProblemsMap);
- if (existingClassToProblemsMap != null) {
- classToProblemsMap = existingClassToProblemsMap;
- }
- // Check if already localized outside of synchronization block for 99% use-case
- if (classToProblemsMap.get(i18nClass) != null) {
- return;
- }
- synchronized (i18nClass) {
- // Return if the supplied i18n class has already been localized to the supplied locale, despite the check outside of
- // the synchronization block (1% use-case), else create a class-to-problems map for the class.
- Set<String> problems = classToProblemsMap.get(i18nClass);
- if (problems == null) {
- problems = new CopyOnWriteArraySet<String>();
- classToProblemsMap.put(i18nClass, problems);
- } else {
- return;
- }
- // Get the URL to the localization properties file ...
- final LocalizationRepository repos = getLocalizationRepository();
- final String localizationBaseName = i18nClass.getName();
- URL url = repos.getLocalizationBundle(localizationBaseName, locale);
- if (url == null) {
- // Nothing was found, so try the default locale
- Locale defaultLocale = Locale.getDefault();
- if (!defaultLocale.equals(locale)) {
- url = repos.getLocalizationBundle(localizationBaseName, defaultLocale);
- }
- // Return if no applicable localization file could be found
- if (url == null) {
- problems.add(CommonI18n.i18nLocalizationFileNotFound.text(localizationBaseName));
- return;
- }
- }
- // Initialize i18n map
- final URL finalUrl = url;
- final Set<String> finalProblems = problems;
- Properties props = new Properties() {
+ /**
+ * Synchronized on the supplied internalization class.
+ *
+ * @param i18nClass The internalization class being localized
+ * @param locale The locale to which the supplied internationalization class should be localized.
+ */
+ private static void localize( final Class<?> i18nClass,
+ final Locale locale ) {
+ assert i18nClass != null;
+ assert locale != null;
+ // Create a class-to-problem map for this locale if one doesn't exist, else get the existing one.
+ Map<Class<?>, Set<String>> classToProblemsMap = new ConcurrentHashMap<Class<?>, Set<String>>();
+ Map<Class<?>, Set<String>> existingClassToProblemsMap = LOCALE_TO_CLASS_TO_PROBLEMS_MAP.putIfAbsent(locale,
+ classToProblemsMap);
+ if (existingClassToProblemsMap != null) {
+ classToProblemsMap = existingClassToProblemsMap;
+ }
+ // Check if already localized outside of synchronization block for 99% use-case
+ if (classToProblemsMap.get(i18nClass) != null) {
+ return;
+ }
+ synchronized (i18nClass) {
+ // Return if the supplied i18n class has already been localized to the supplied locale, despite the check outside of
+ // the synchronization block (1% use-case), else create a class-to-problems map for the class.
+ Set<String> problems = classToProblemsMap.get(i18nClass);
+ if (problems == null) {
+ problems = new CopyOnWriteArraySet<String>();
+ classToProblemsMap.put(i18nClass, problems);
+ } else {
+ return;
+ }
+ // Get the URL to the localization properties file ...
+ final LocalizationRepository repos = getLocalizationRepository();
+ final String localizationBaseName = i18nClass.getName();
+ URL url = repos.getLocalizationBundle(localizationBaseName, locale);
+ if (url == null) {
+ // Nothing was found, so try the default locale
+ Locale defaultLocale = Locale.getDefault();
+ if (!defaultLocale.equals(locale)) {
+ url = repos.getLocalizationBundle(localizationBaseName, defaultLocale);
+ }
+ // Return if no applicable localization file could be found
+ if (url == null) {
+ problems.add(CommonI18n.i18nLocalizationFileNotFound.text(localizationBaseName));
+ return;
+ }
+ }
+ // Initialize i18n map
+ final URL finalUrl = url;
+ final Set<String> finalProblems = problems;
+ Properties props = new Properties() {
- @Override
- public synchronized Object put( Object key,
- Object value ) {
- String id = (String)key;
- String text = (String)value;
+ /**
+ */
+ private static final long serialVersionUID = 3920620306881072843L;
- try {
- Field fld = i18nClass.getDeclaredField(id);
- if (fld.getType() != I18n.class) {
- // Invalid field type
- finalProblems.add(CommonI18n.i18nFieldInvalidType.text(id, finalUrl, getClass().getName()));
- } else {
- I18n i18n = (I18n)fld.get(null);
- if (i18n.localeToTextMap.putIfAbsent(locale, text) != null) {
- // Duplicate id encountered
- String prevProblem = i18n.localeToProblemMap.putIfAbsent(locale,
- CommonI18n.i18nPropertyDuplicate.text(id,
- finalUrl));
- assert prevProblem == null;
- }
- }
- } catch (NoSuchFieldException err) {
- // No corresponding field exists
- finalProblems.add(CommonI18n.i18nPropertyUnused.text(id, finalUrl));
- } catch (IllegalAccessException notPossible) {
- // Would have already occurred in initialize method, but allowing for the impossible...
- finalProblems.add(notPossible.getMessage());
- }
+ @Override
+ public synchronized Object put( Object key,
+ Object value ) {
+ String id = (String)key;
+ String text = (String)value;
- return null;
- }
- };
+ try {
+ Field fld = i18nClass.getDeclaredField(id);
+ if (fld.getType() != I18n.class) {
+ // Invalid field type
+ finalProblems.add(CommonI18n.i18nFieldInvalidType.text(id, finalUrl, getClass().getName()));
+ } else {
+ I18n i18n = (I18n)fld.get(null);
+ if (i18n.localeToTextMap.putIfAbsent(locale, text) != null) {
+ // Duplicate id encountered
+ String prevProblem = i18n.localeToProblemMap.putIfAbsent(locale,
+ CommonI18n.i18nPropertyDuplicate.text(id,
+ finalUrl));
+ assert prevProblem == null;
+ }
+ }
+ } catch (NoSuchFieldException err) {
+ // No corresponding field exists
+ finalProblems.add(CommonI18n.i18nPropertyUnused.text(id, finalUrl));
+ } catch (IllegalAccessException notPossible) {
+ // Would have already occurred in initialize method, but allowing for the impossible...
+ finalProblems.add(notPossible.getMessage());
+ }
- try {
- InputStream propStream = url.openStream();
- try {
- props.load(propStream);
- // Check for uninitialized fields
- for (Field fld : i18nClass.getDeclaredFields()) {
- if (fld.getType() == I18n.class) {
- try {
- I18n i18n = (I18n)fld.get(null);
- if (i18n.localeToTextMap.get(locale) == null) {
- i18n.localeToProblemMap.put(locale, CommonI18n.i18nPropertyMissing.text(fld.getName(), url));
- }
- } catch (IllegalAccessException notPossible) {
- // Would have already occurred in initialize method, but allowing for the impossible...
- finalProblems.add(notPossible.getMessage());
- }
- }
- }
- } finally {
- propStream.close();
- }
- } catch (IOException err) {
- finalProblems.add(err.getMessage());
- }
- }
- }
+ return null;
+ }
+ };
- private final String id;
- private final Class i18nClass;
- final ConcurrentHashMap<Locale, String> localeToTextMap = new ConcurrentHashMap<Locale, String>();
- final ConcurrentHashMap<Locale, String> localeToProblemMap = new ConcurrentHashMap<Locale, String>();
+ try {
+ InputStream propStream = url.openStream();
+ try {
+ props.load(propStream);
+ // Check for uninitialized fields
+ for (Field fld : i18nClass.getDeclaredFields()) {
+ if (fld.getType() == I18n.class) {
+ try {
+ I18n i18n = (I18n)fld.get(null);
+ if (i18n.localeToTextMap.get(locale) == null) {
+ i18n.localeToProblemMap.put(locale, CommonI18n.i18nPropertyMissing.text(fld.getName(), url));
+ }
+ } catch (IllegalAccessException notPossible) {
+ // Would have already occurred in initialize method, but allowing for the impossible...
+ finalProblems.add(notPossible.getMessage());
+ }
+ }
+ }
+ } finally {
+ propStream.close();
+ }
+ } catch (IOException err) {
+ finalProblems.add(err.getMessage());
+ }
+ }
+ }
- private I18n( String id,
- Class i18nClass ) {
- this.id = id;
- this.i18nClass = i18nClass;
- }
+ private final String id;
+ private final Class<?> i18nClass;
+ final ConcurrentHashMap<Locale, String> localeToTextMap = new ConcurrentHashMap<Locale, String>();
+ final ConcurrentHashMap<Locale, String> localeToProblemMap = new ConcurrentHashMap<Locale, String>();
- /**
- * @return This internationalization object's ID, which will match both the name of the relevant static field in the
- * internationalization class and the relevant property name in the associated localization files.
- */
- public String id() {
- return id;
- }
+ private I18n( String id,
+ Class<?> i18nClass ) {
+ this.id = id;
+ this.i18nClass = i18nClass;
+ }
- /**
- * @return <code>true</code> if a problem was encountered while localizing this internationalization object to the default
- * locale.
- */
- public boolean hasProblem() {
- return (problem() != null);
- }
+ /**
+ * @return This internationalization object's ID, which will match both the name of the relevant static field in the
+ * internationalization class and the relevant property name in the associated localization files.
+ */
+ public String id() {
+ return id;
+ }
- /**
- * @param locale The locale for which to check whether a problem was encountered.
- * @return <code>true</code> if a problem was encountered while localizing this internationalization object to the supplied
- * locale.
- */
- public boolean hasProblem( Locale locale ) {
- return (problem(locale) != null);
- }
+ /**
+ * @return <code>true</code> if a problem was encountered while localizing this internationalization object to the default
+ * locale.
+ */
+ public boolean hasProblem() {
+ return (problem() != null);
+ }
- /**
- * @return The problem encountered while localizing this internationalization object to the default locale, or
- * <code>null</code> if none was encountered.
- */
- public String problem() {
- return problem(null);
- }
+ /**
+ * @param locale The locale for which to check whether a problem was encountered.
+ * @return <code>true</code> if a problem was encountered while localizing this internationalization object to the supplied
+ * locale.
+ */
+ public boolean hasProblem( Locale locale ) {
+ return (problem(locale) != null);
+ }
- /**
- * @param locale The locale for which to return the problem.
- * @return The problem encountered while localizing this internationalization object to the supplied locale, or
- * <code>null</code> if none was encountered.
- */
- public String problem( Locale locale ) {
- if (locale == null) {
- locale = Locale.getDefault();
- }
- localize(i18nClass, locale);
- // Check for field/property error
- String problem = localeToProblemMap.get(locale);
- if (problem != null) {
- return problem;
- }
- // Check if text exists
- if (localeToTextMap.get(locale) != null) {
- // If so, no problem exists
- return null;
- }
- // If we get here, which will be at most once, there was at least one global localization error, so just return a message
- // indicating to look them up.
- problem = CommonI18n.i18nLocalizationProblems.text(i18nClass, locale);
- localeToProblemMap.put(locale, problem);
- return problem;
- }
+ /**
+ * @return The problem encountered while localizing this internationalization object to the default locale, or
+ * <code>null</code> if none was encountered.
+ */
+ public String problem() {
+ return problem(null);
+ }
- private String rawText( Locale locale ) {
- assert locale != null;
- localize(i18nClass, locale);
- // Check if text exists
- String text = localeToTextMap.get(locale);
- if (text != null) {
- return text;
- }
- // If not, there was a problem, so throw it within an exception so upstream callers can tell the difference between normal
- // text and problem text.
- throw new SystemFailureException(problem(locale));
- }
+ /**
+ * @param locale The locale for which to return the problem.
+ * @return The problem encountered while localizing this internationalization object to the supplied locale, or
+ * <code>null</code> if none was encountered.
+ */
+ public String problem( Locale locale ) {
+ if (locale == null) {
+ locale = Locale.getDefault();
+ }
+ localize(i18nClass, locale);
+ // Check for field/property error
+ String problem = localeToProblemMap.get(locale);
+ if (problem != null) {
+ return problem;
+ }
+ // Check if text exists
+ if (localeToTextMap.get(locale) != null) {
+ // If so, no problem exists
+ return null;
+ }
+ // If we get here, which will be at most once, there was at least one global localization error, so just return a message
+ // indicating to look them up.
+ problem = CommonI18n.i18nLocalizationProblems.text(i18nClass, locale);
+ localeToProblemMap.put(locale, problem);
+ return problem;
+ }
- /**
- * Get the localized text for the {@link Locale#getDefault() current (default) locale}, replacing the parameters in the text
- * with those supplied.
- *
- * @param arguments the arguments for the parameter replacement; may be <code>null</code> or empty
- * @return the localized text
- */
- public String text( Object... arguments ) {
- return text(null, arguments);
- }
+ private String rawText( Locale locale ) {
+ assert locale != null;
+ localize(i18nClass, locale);
+ // Check if text exists
+ String text = localeToTextMap.get(locale);
+ if (text != null) {
+ return text;
+ }
+ // If not, there was a problem, so throw it within an exception so upstream callers can tell the difference between normal
+ // text and problem text.
+ throw new SystemFailureException(problem(locale));
+ }
- /**
- * Get the localized text for the supplied locale, replacing the parameters in the text with those supplied.
- *
- * @param locale the locale, or <code>null</code> if the {@link Locale#getDefault() current (default) locale} should be used
- * @param arguments the arguments for the parameter replacement; may be <code>null</code> or empty
- * @return the localized text
- */
- public String text( Locale locale,
- Object... arguments ) {
- try {
- String rawText = rawText(locale == null ? Locale.getDefault() : locale);
- return StringUtil.createString(rawText, arguments);
- } catch (IllegalArgumentException err) {
- throw new IllegalArgumentException(CommonI18n.i18nRequiredToSuppliedParameterMismatch.text(id,
- i18nClass,
- err.getMessage()));
- } catch (SystemFailureException err) {
- return '<' + err.getMessage() + '>';
- }
- }
+ /**
+ * Get the localized text for the {@link Locale#getDefault() current (default) locale}, replacing the parameters in the text
+ * with those supplied.
+ *
+ * @param arguments the arguments for the parameter replacement; may be <code>null</code> or empty
+ * @return the localized text
+ */
+ public String text( Object... arguments ) {
+ return text(null, arguments);
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- try {
- return rawText(Locale.getDefault());
- } catch (SystemFailureException err) {
- return '<' + err.getMessage() + '>';
- }
- }
+ /**
+ * Get the localized text for the supplied locale, replacing the parameters in the text with those supplied.
+ *
+ * @param locale the locale, or <code>null</code> if the {@link Locale#getDefault() current (default) locale} should be used
+ * @param arguments the arguments for the parameter replacement; may be <code>null</code> or empty
+ * @return the localized text
+ */
+ public String text( Locale locale,
+ Object... arguments ) {
+ try {
+ String rawText = rawText(locale == null ? Locale.getDefault() : locale);
+ return StringUtil.createString(rawText, arguments);
+ } catch (IllegalArgumentException err) {
+ throw new IllegalArgumentException(CommonI18n.i18nRequiredToSuppliedParameterMismatch.text(id,
+ i18nClass,
+ err.getMessage()));
+ } catch (SystemFailureException err) {
+ return '<' + err.getMessage() + '>';
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ try {
+ return rawText(Locale.getDefault());
+ } catch (SystemFailureException err) {
+ return '<' + err.getMessage() + '>';
+ }
+ }
}
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressStatus.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressStatus.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/monitor/ProgressStatus.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -34,6 +34,9 @@
@Immutable
public class ProgressStatus implements Serializable, Comparable<ProgressStatus> {
+ /**
+ */
+ private static final long serialVersionUID = -7771764546193063275L;
protected static final String PERCENTAGE_PATTERN = "##0.0"; // percentage should always fit
protected static final double PERCENT_PRECISION = 0.001d;
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/util/ArgCheck.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/util/ArgCheck.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/util/ArgCheck.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -36,12 +36,15 @@
/**
* Check that the argument is not less than the supplied value
+ *
* @param argument The argument
* @param notLessThanValue the value that is to be used to check the value
* @param name The name of the argument
* @throws IllegalArgumentException If argument is negative (<0)
*/
- public static void isNotLessThan( int argument, int notLessThanValue, String name ) {
+ public static void isNotLessThan( int argument,
+ int notLessThanValue,
+ String name ) {
if (argument < notLessThanValue) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeLessThan.text(name, argument, notLessThanValue));
}
@@ -49,12 +52,15 @@
/**
* Check that the argument is not greater than the supplied value
+ *
* @param argument The argument
* @param notGreaterThanValue the value that is to be used to check the value
* @param name The name of the argument
* @throws IllegalArgumentException If argument is negative (<0)
*/
- public static void isNotGreaterThan( int argument, int notGreaterThanValue, String name ) {
+ public static void isNotGreaterThan( int argument,
+ int notGreaterThanValue,
+ String name ) {
if (argument < notGreaterThanValue) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeGreaterThan.text(name, argument, notGreaterThanValue));
}
@@ -62,11 +68,13 @@
/**
* Check that the argument is non-negative (>=0).
+ *
* @param argument The argument
* @param name The name of the argument
* @throws IllegalArgumentException If argument is negative (<0)
*/
- public static void isNonNegative( int argument, String name ) {
+ public static void isNonNegative( int argument,
+ String name ) {
if (argument < 0) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNegative.text(name, argument));
}
@@ -74,11 +82,13 @@
/**
* Check that the argument is non-positive (<=0).
+ *
* @param argument The argument
* @param name The name of the argument
* @throws IllegalArgumentException If argument is positive (>0)
*/
- public static void isNonPositive( int argument, String name ) {
+ public static void isNonPositive( int argument,
+ String name ) {
if (argument > 0) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBePositive.text(name, argument));
}
@@ -86,11 +96,13 @@
/**
* Check that the argument is negative (<0).
+ *
* @param argument The argument
* @param name The name of the argument
* @throws IllegalArgumentException If argument is non-negative (>=0)
*/
- public static void isNegative( int argument, String name ) {
+ public static void isNegative( int argument,
+ String name ) {
if (argument >= 0) {
throw new IllegalArgumentException(CommonI18n.argumentMustBeNegative.text(name, argument));
}
@@ -98,11 +110,13 @@
/**
* Check that the argument is positive (>0).
+ *
* @param argument The argument
* @param name The name of the argument
* @throws IllegalArgumentException If argument is non-positive (<=0)
*/
- public static void isPositive( int argument, String name ) {
+ public static void isPositive( int argument,
+ String name ) {
if (argument <= 0) {
throw new IllegalArgumentException(CommonI18n.argumentMustBePositive.text(name, argument));
}
@@ -112,11 +126,13 @@
/**
* Check that the argument is non-negative (>=0).
+ *
* @param argument The argument
* @param name The name of the argument
* @throws IllegalArgumentException If argument is negative (<0)
*/
- public static void isNonNegative( long argument, String name ) {
+ public static void isNonNegative( long argument,
+ String name ) {
if (argument < 0) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNegative.text(name, argument));
}
@@ -124,11 +140,13 @@
/**
* Check that the argument is non-positive (<=0).
+ *
* @param argument The argument
* @param name The name of the argument
* @throws IllegalArgumentException If argument is positive (>0)
*/
- public static void isNonPositive( long argument, String name ) {
+ public static void isNonPositive( long argument,
+ String name ) {
if (argument > 0) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBePositive.text(name, argument));
}
@@ -136,11 +154,13 @@
/**
* Check that the argument is negative (<0).
+ *
* @param argument The argument
* @param name The name of the argument
* @throws IllegalArgumentException If argument is non-negative (>=0)
*/
- public static void isNegative( long argument, String name ) {
+ public static void isNegative( long argument,
+ String name ) {
if (argument >= 0) {
throw new IllegalArgumentException(CommonI18n.argumentMustBeNegative.text(name, argument));
}
@@ -148,11 +168,13 @@
/**
* Check that the argument is positive (>0).
+ *
* @param argument The argument
* @param name The name of the argument
* @throws IllegalArgumentException If argument is non-positive (<=0)
*/
- public static void isPositive( long argument, String name ) {
+ public static void isPositive( long argument,
+ String name ) {
if (argument <= 0) {
throw new IllegalArgumentException(CommonI18n.argumentMustBePositive.text(name, argument));
}
@@ -162,11 +184,13 @@
/**
* Check that the argument is non-negative (>=0).
+ *
* @param argument The argument
* @param name The name of the argument
* @throws IllegalArgumentException If argument is negative (<0)
*/
- public static void isNonNegative( double argument, String name ) {
+ public static void isNonNegative( double argument,
+ String name ) {
if (argument < 0.0) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNegative.text(name, argument));
}
@@ -174,11 +198,13 @@
/**
* Check that the argument is non-positive (<=0).
+ *
* @param argument The argument
* @param name The name of the argument
* @throws IllegalArgumentException If argument is positive (>0)
*/
- public static void isNonPositive( double argument, String name ) {
+ public static void isNonPositive( double argument,
+ String name ) {
if (argument > 0.0) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBePositive.text(name, argument));
}
@@ -186,11 +212,13 @@
/**
* Check that the argument is negative (<0).
+ *
* @param argument The argument
* @param name The name of the argument
* @throws IllegalArgumentException If argument is non-negative (>=0)
*/
- public static void isNegative( double argument, String name ) {
+ public static void isNegative( double argument,
+ String name ) {
if (argument >= 0.0) {
throw new IllegalArgumentException(CommonI18n.argumentMustBeNegative.text(name, argument));
}
@@ -198,11 +226,13 @@
/**
* Check that the argument is positive (>0).
+ *
* @param argument The argument
* @param name The name of the argument
* @throws IllegalArgumentException If argument is non-positive (<=0)
*/
- public static void isPositive( double argument, String name ) {
+ public static void isPositive( double argument,
+ String name ) {
if (argument <= 0.0) {
throw new IllegalArgumentException(CommonI18n.argumentMustBePositive.text(name, argument));
}
@@ -210,11 +240,13 @@
/**
* Check that the argument is not NaN.
+ *
* @param argument The argument
* @param name The name of the argument
* @throws IllegalArgumentException If argument is NaN
*/
- public static void isNotNan( double argument, String name ) {
+ public static void isNotNan( double argument,
+ String name ) {
if (Double.isNaN(argument)) {
throw new IllegalArgumentException(CommonI18n.argumentMustBeNumber.text(name));
}
@@ -224,11 +256,13 @@
/**
* Check that the string is non-null and has length > 0
+ *
* @param argument The argument
* @param name The name of the argument
* @throws IllegalArgumentException If value is null or length == 0
*/
- public static void isNotZeroLength( String argument, String name ) {
+ public static void isNotZeroLength( String argument,
+ String name ) {
isNotNull(argument, name);
if (argument.length() <= 0) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNullOrZeroLength.text(name));
@@ -237,11 +271,13 @@
/**
* Check that the string is not empty, is not null, and does not contain only whitespace.
+ *
* @param argument String
* @param name The name of the argument
* @throws IllegalArgumentException If string is null or empty
*/
- public static void isNotEmpty( String argument, String name ) {
+ public static void isNotEmpty( String argument,
+ String name ) {
isNotZeroLength(argument, name);
if (argument != null && argument.trim().length() == 0) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNullOrZeroLengthOrEmpty.text(name));
@@ -252,11 +288,13 @@
/**
* Check that the specified argument is non-null
+ *
* @param argument The argument
* @param name The name of the argument
* @throws IllegalArgumentException If argument is null
*/
- public static void isNotNull( Object argument, String name ) {
+ public static void isNotNull( Object argument,
+ String name ) {
if (argument == null) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNull.text(name));
}
@@ -264,24 +302,28 @@
/**
* Returns the specified argument if it is not <code>null</code>.
+ *
* @param <T>
* @param argument The argument
* @param name The name of the argument
* @return The argument
* @throws IllegalArgumentException If argument is <code>null</code>
*/
- public static <T> T getNotNull( T argument, String name ) {
+ public static <T> T getNotNull( T argument,
+ String name ) {
isNotNull(argument, name);
return argument;
}
/**
* Check that the argument is null
+ *
* @param argument The argument
* @param name The name of the argument
* @throws IllegalArgumentException If value is non-null
*/
- public static void isNull( Object argument, String name ) {
+ public static void isNull( Object argument,
+ String name ) {
if (argument != null) {
throw new IllegalArgumentException(CommonI18n.argumentMustBeNull.text(name));
}
@@ -289,21 +331,28 @@
/**
* Check that the object is an instance of the specified Class
+ *
+ * @param <T> the class type
* @param argument Value
* @param expectedClass Class
* @param name The name of the argument
* @throws IllegalArgumentException If value is null
*/
- public static void isInstanceOf( Object argument, Class expectedClass, String name ) {
+ public static <T> void isInstanceOf( Object argument,
+ Class<T> expectedClass,
+ String name ) {
isNotNull(argument, name);
if (!expectedClass.isInstance(argument)) {
- throw new IllegalArgumentException(CommonI18n.argumentMustBeInstanceOf.text(name, argument.getClass(), expectedClass.getName()));
+ throw new IllegalArgumentException(CommonI18n.argumentMustBeInstanceOf.text(name,
+ argument.getClass(),
+ expectedClass.getName()));
}
}
/**
* Checks that the object is an instance of the specified Class and then returns the object cast to the specified Class
- * @param <C>
+ *
+ * @param <C> the class type
* @param argument Value
* @param expectedClass Class
* @param name The name of the argument
@@ -312,23 +361,29 @@
*/
@SuppressWarnings( "unchecked" )
// due to cast in return
- public static <C> C getInstanceOf( Object argument, Class<C> expectedClass, String name ) {
+ public static <C> C getInstanceOf( Object argument,
+ Class<C> expectedClass,
+ String name ) {
isInstanceOf(argument, expectedClass, name);
return (C)argument;
}
/**
* Asserts that the specified first object is the same as (==) the specified second object.
+ *
* @param <T>
* @param argument The argument to assert as the same as <code>object</code>.
* @param argumentName The name that will be used within the exception message for the argument should an exception be thrown
* @param object The object to assert as the same as <code>argument</code>.
* @param objectName The name that will be used within the exception message for <code>object</code> should an exception be
- * thrown; if <code>null</code> and <code>object</code> is not <code>null</code>, <code>object.toString()</code> will
- * be used.
+ * thrown; if <code>null</code> and <code>object</code> is not <code>null</code>, <code>object.toString()</code>
+ * will be used.
* @throws IllegalArgumentException If the specified objects are not the same.
*/
- public static <T> void isSame( final T argument, String argumentName, final T object, String objectName ) {
+ public static <T> void isSame( final T argument,
+ String argumentName,
+ final T object,
+ String objectName ) {
if (argument != object) {
if (objectName == null) objectName = getObjectName(object);
throw new IllegalArgumentException(CommonI18n.argumentMustBeSameAs.text(argumentName, objectName));
@@ -337,16 +392,20 @@
/**
* Asserts that the specified first object is not the same as (==) the specified second object.
+ *
* @param <T>
* @param argument The argument to assert as not the same as <code>object</code>.
* @param argumentName The name that will be used within the exception message for the argument should an exception be thrown
* @param object The object to assert as not the same as <code>argument</code>.
* @param objectName The name that will be used within the exception message for <code>object</code> should an exception be
- * thrown; if <code>null</code> and <code>object</code> is not <code>null</code>, <code>object.toString()</code> will
- * be used.
+ * thrown; if <code>null</code> and <code>object</code> is not <code>null</code>, <code>object.toString()</code>
+ * will be used.
* @throws IllegalArgumentException If the specified objects are the same.
*/
- public static <T> void isNotSame( final T argument, String argumentName, final T object, String objectName ) {
+ public static <T> void isNotSame( final T argument,
+ String argumentName,
+ final T object,
+ String objectName ) {
if (argument == object) {
if (objectName == null) objectName = getObjectName(object);
throw new IllegalArgumentException(CommonI18n.argumentMustNotBeSameAs.text(argumentName, objectName));
@@ -355,16 +414,20 @@
/**
* Asserts that the specified first object is {@link Object#equals(Object) equal to} the specified second object.
+ *
* @param <T>
* @param argument The argument to assert equal to <code>object</code>.
* @param argumentName The name that will be used within the exception message for the argument should an exception be thrown
* @param object The object to assert as equal to <code>argument</code>.
* @param objectName The name that will be used within the exception message for <code>object</code> should an exception be
- * thrown; if <code>null</code> and <code>object</code> is not <code>null</code>, <code>object.toString()</code> will
- * be used.
+ * thrown; if <code>null</code> and <code>object</code> is not <code>null</code>, <code>object.toString()</code>
+ * will be used.
* @throws IllegalArgumentException If the specified objects are not equal.
*/
- public static <T> void isEquals( final T argument, String argumentName, final T object, String objectName ) {
+ public static <T> void isEquals( final T argument,
+ String argumentName,
+ final T object,
+ String objectName ) {
if (!argument.equals(object)) {
if (objectName == null) objectName = getObjectName(object);
throw new IllegalArgumentException(CommonI18n.argumentMustBeEquals.text(argumentName, objectName));
@@ -373,16 +436,20 @@
/**
* Asserts that the specified first object is not {@link Object#equals(Object) equal to} the specified second object.
+ *
* @param <T>
* @param argument The argument to assert equal to <code>object</code>.
* @param argumentName The name that will be used within the exception message for the argument should an exception be thrown
* @param object The object to assert as equal to <code>argument</code>.
* @param objectName The name that will be used within the exception message for <code>object</code> should an exception be
- * thrown; if <code>null</code> and <code>object</code> is not <code>null</code>, <code>object.toString()</code> will
- * be used.
+ * thrown; if <code>null</code> and <code>object</code> is not <code>null</code>, <code>object.toString()</code>
+ * will be used.
* @throws IllegalArgumentException If the specified objects are equals.
*/
- public static <T> void isNotEquals( final T argument, String argumentName, final T object, String objectName ) {
+ public static <T> void isNotEquals( final T argument,
+ String argumentName,
+ final T object,
+ String objectName ) {
if (argument.equals(object)) {
if (objectName == null) objectName = getObjectName(object);
throw new IllegalArgumentException(CommonI18n.argumentMustNotBeEquals.text(argumentName, objectName));
@@ -393,11 +460,13 @@
/**
* Checks that the iterator is not empty, and throws an exception if it is.
+ *
* @param argument the iterator to check
* @param name The name of the argument
* @throws IllegalArgumentException If iterator is empty (i.e., iterator.hasNext() returns false)
*/
- public static void isNotEmpty( Iterator argument, String name ) {
+ public static void isNotEmpty( Iterator<?> argument,
+ String name ) {
isNotNull(argument, name);
if (!argument.hasNext()) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeEmpty.text(name));
@@ -408,11 +477,13 @@
/**
* Check that the collection is not empty
+ *
* @param argument Collection
* @param name The name of the argument
* @throws IllegalArgumentException If collection is null or empty
*/
- public static void isNotEmpty( Collection argument, String name ) {
+ public static void isNotEmpty( Collection<?> argument,
+ String name ) {
isNotNull(argument, name);
if (argument.isEmpty()) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeEmpty.text(name));
@@ -421,11 +492,13 @@
/**
* Check that the map is not empty
+ *
* @param argument Map
* @param name The name of the argument
* @throws IllegalArgumentException If map is null or empty
*/
- public static void isNotEmpty( Map argument, String name ) {
+ public static void isNotEmpty( Map<?, ?> argument,
+ String name ) {
isNotNull(argument, name);
if (argument.isEmpty()) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeEmpty.text(name));
@@ -434,11 +507,13 @@
/**
* Check that the array is not empty
+ *
* @param argument Array
* @param name The name of the argument
* @throws IllegalArgumentException If array is null or empty
*/
- public static void isNotEmpty( Object[] argument, String name ) {
+ public static void isNotEmpty( Object[] argument,
+ String name ) {
isNotNull(argument, name);
if (argument.length == 0) {
throw new IllegalArgumentException(CommonI18n.argumentMayNotBeEmpty.text(name));
@@ -451,12 +526,15 @@
/**
* Check that the collection contains the value
+ *
* @param argument Collection to check
* @param value Value to check for, may be null
* @param name The name of the argument
* @throws IllegalArgumentException If collection is null or doesn't contain value
*/
- public static void contains( Collection argument, Object value, String name ) {
+ public static void contains( Collection<?> argument,
+ Object value,
+ String name ) {
isNotNull(argument, name);
if (!argument.contains(value)) {
throw new IllegalArgumentException(CommonI18n.argumentDidNotContainObject.text(name, getObjectName(value)));
@@ -465,12 +543,15 @@
/**
* Check that the map contains the key
+ *
* @param argument Map to check
* @param key Key to check for, may be null
* @param name The name of the argument
* @throws IllegalArgumentException If map is null or doesn't contain key
*/
- public static void containsKey( Map argument, Object key, String name ) {
+ public static void containsKey( Map<?, ?> argument,
+ Object key,
+ String name ) {
isNotNull(argument, name);
if (!argument.containsKey(key)) {
throw new IllegalArgumentException(CommonI18n.argumentDidNotContainKey.text(name, getObjectName(key)));
@@ -479,11 +560,13 @@
/**
* Check that the collection is not null and contains no nulls
+ *
* @param argument Array
* @param name The name of the argument
* @throws IllegalArgumentException If array is null or has null values
*/
- public static void containsNoNulls( Collection argument, String name ) {
+ public static void containsNoNulls( Collection<?> argument,
+ String name ) {
isNotNull(argument, name);
int i = 0;
for (Object object : argument) {
@@ -496,11 +579,13 @@
/**
* Check that the array is not null and contains no nulls
+ *
* @param argument Array
* @param name The name of the argument
* @throws IllegalArgumentException If array is null or has null values
*/
- public static void containsNoNulls( Object[] argument, String name ) {
+ public static void containsNoNulls( Object[] argument,
+ String name ) {
isNotNull(argument, name);
int i = 0;
for (Object object : argument) {
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/util/ClassUtil.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/util/ClassUtil.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/util/ClassUtil.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -31,11 +31,15 @@
/**
* Static utilities for working with classes.
+ *
* @author John Verhaeg
*/
public final class ClassUtil {
- private static void addObjectString( Object object, int includeInheritedFieldDepth, Class clazz, StringBuffer text ) {
+ private static void addObjectString( Object object,
+ int includeInheritedFieldDepth,
+ Class<?> clazz,
+ StringBuffer text ) {
// Add class's name
text.append(nonPackageQualifiedName(clazz));
@@ -85,7 +89,8 @@
text.append(')');
}
- private static boolean addSeparator( boolean separatorNeeded, StringBuffer text ) {
+ private static boolean addSeparator( boolean separatorNeeded,
+ StringBuffer text ) {
if (separatorNeeded) {
text.append(", "); //$NON-NLS-1$
}
@@ -114,9 +119,9 @@
/**
* @param clazz A class.
* @return The non-package-qualified name of the specified class. Note, inner class names will still be qualified by their
- * enclosing class names and a "$" delimiter.
+ * enclosing class names and a "$" delimiter.
*/
- public static String nonPackageQualifiedName( final Class clazz ) {
+ public static String nonPackageQualifiedName( final Class<?> clazz ) {
// if (clazz == null) {
// throw new IllegalArgumentException(I18n.format(CommonI18n.mustNotBeNull, "Class")); //$NON-NLS-1$
// }
@@ -127,7 +132,7 @@
/**
* @param object An object.
* @return The non-package-qualified name of the class of the specified object. Note, inner class names will still be
- * qualified by their enclosing class names and a "$" delimiter.
+ * qualified by their enclosing class names and a "$" delimiter.
*/
public static String nonPackageQualifiedName( final Object object ) {
// if (object == null) {
@@ -141,7 +146,8 @@
* @param includeInheritedFieldDepth
* @return A string representation of the specified object, consisting of its class name, properties, and property values.
*/
- public static String toString( Object object, int includeInheritedFieldDepth ) {
+ public static String toString( Object object,
+ int includeInheritedFieldDepth ) {
StringBuffer text = new StringBuffer();
addObjectString(object, includeInheritedFieldDepth, object.getClass(), text);
return text.toString();
@@ -150,6 +156,7 @@
/**
* Determine whether the supplied string represents a well-formed fully-qualified Java classname. This utility method enforces
* no conventions (e.g., packages are all lowercase) nor checks whether the class is available on the classpath.
+ *
* @param classname
* @return true if the string is a fully-qualified class name
*/
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/util/Logger.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/util/Logger.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/util/Logger.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -36,391 +36,391 @@
@ThreadSafe
public final class Logger {
- public enum Level {
- OFF,
- ERROR,
- WARNING,
- INFO,
- DEBUG,
- TRACE;
- }
+ public enum Level {
+ OFF,
+ ERROR,
+ WARNING,
+ INFO,
+ DEBUG,
+ TRACE;
+ }
- private static final AtomicReference<Locale> LOGGING_LOCALE = new AtomicReference<Locale>(null);
+ private static final AtomicReference<Locale> LOGGING_LOCALE = new AtomicReference<Locale>(null);
- /**
- * Get the locale used for the logs. If null, the {@link Locale#getDefault() default locale} is used.
- *
- * @return the current locale used for logging, or null if the system locale is used
- * @see #setLoggingLocale(Locale)
- */
- public static Locale getLoggingLocale() {
- return LOGGING_LOCALE.get();
- }
+ /**
+ * Get the locale used for the logs. If null, the {@link Locale#getDefault() default locale} is used.
+ *
+ * @return the current locale used for logging, or null if the system locale is used
+ * @see #setLoggingLocale(Locale)
+ */
+ public static Locale getLoggingLocale() {
+ return LOGGING_LOCALE.get();
+ }
- /**
- * Set the locale used for the logs. This should be used when the logs are to be written is a specific locale, independent of
- * the {@link Locale#getDefault() default locale}. To use the default locale, call this method with a null value.
- *
- * @param locale the desired locale to use for the logs, or null if the system locale should be used
- * @return the previous locale
- * @see #getLoggingLocale()
- */
- public static Locale setLoggingLocale( Locale locale ) {
- return LOGGING_LOCALE.getAndSet(locale != null ? locale : Locale.getDefault());
- }
+ /**
+ * Set the locale used for the logs. This should be used when the logs are to be written is a specific locale, independent of
+ * the {@link Locale#getDefault() default locale}. To use the default locale, call this method with a null value.
+ *
+ * @param locale the desired locale to use for the logs, or null if the system locale should be used
+ * @return the previous locale
+ * @see #getLoggingLocale()
+ */
+ public static Locale setLoggingLocale( Locale locale ) {
+ return LOGGING_LOCALE.getAndSet(locale != null ? locale : Locale.getDefault());
+ }
- /**
- * Return a logger named corresponding to the class passed as parameter, using the statically bound {@link ILoggerFactory}
- * instance.
- *
- * @param clazz the returned logger will be named after clazz
- * @return logger
- */
- public static Logger getLogger( Class clazz ) {
- return new Logger(LoggerFactory.getLogger(clazz));
- }
+ /**
+ * Return a logger named corresponding to the class passed as parameter, using the statically bound {@link ILoggerFactory}
+ * instance.
+ *
+ * @param clazz the returned logger will be named after clazz
+ * @return logger
+ */
+ public static Logger getLogger( Class<?> clazz ) {
+ return new Logger(LoggerFactory.getLogger(clazz));
+ }
- /**
- * Return a logger named according to the name parameter using the statically bound {@link ILoggerFactory} instance.
- *
- * @param name The name of the logger.
- * @return logger
- */
- public static Logger getLogger( String name ) {
- return new Logger(LoggerFactory.getLogger(name));
- }
+ /**
+ * Return a logger named according to the name parameter using the statically bound {@link ILoggerFactory} instance.
+ *
+ * @param name The name of the logger.
+ * @return logger
+ */
+ public static Logger getLogger( String name ) {
+ return new Logger(LoggerFactory.getLogger(name));
+ }
- private final org.slf4j.Logger delegate;
+ private final org.slf4j.Logger delegate;
- private Logger( org.slf4j.Logger delegate ) {
- this.delegate = delegate;
- }
+ private Logger( org.slf4j.Logger delegate ) {
+ this.delegate = delegate;
+ }
- /**
- * Return the name of this logger instance.
- *
- * @return the logger's name
- */
- public String getName() {
- return this.delegate.getName();
- }
+ /**
+ * Return the name of this logger instance.
+ *
+ * @return the logger's name
+ */
+ public String getName() {
+ return this.delegate.getName();
+ }
- /**
- * Log a message at the suplied level according to the specified format and (optional) parameters. The message should contain
- * a pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is
- * efficient and avoids superfluous object creation when the logger is disabled for the desired level.
- *
- * @param level the level at which to log
- * @param message the (localized) message string
- * @param params the parameter values that are to replace the variables in the format string
- */
- public void log( Level level,
- I18n message,
- Object... params ) {
- if (message == null) return;
- switch (level) {
- case DEBUG:
- debug(message.text(LOGGING_LOCALE.get(), params));
- break;
- case ERROR:
- error(message, params);
- break;
- case INFO:
- info(message, params);
- break;
- case TRACE:
- trace(message.text(LOGGING_LOCALE.get(), params));
- break;
- case WARNING:
- warn(message, params);
- break;
- case OFF:
- break;
- }
- }
+ /**
+ * Log a message at the suplied level according to the specified format and (optional) parameters. The message should contain
+ * a pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is
+ * efficient and avoids superfluous object creation when the logger is disabled for the desired level.
+ *
+ * @param level the level at which to log
+ * @param message the (localized) message string
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public void log( Level level,
+ I18n message,
+ Object... params ) {
+ if (message == null) return;
+ switch (level) {
+ case DEBUG:
+ debug(message.text(LOGGING_LOCALE.get(), params));
+ break;
+ case ERROR:
+ error(message, params);
+ break;
+ case INFO:
+ info(message, params);
+ break;
+ case TRACE:
+ trace(message.text(LOGGING_LOCALE.get(), params));
+ break;
+ case WARNING:
+ warn(message, params);
+ break;
+ case OFF:
+ break;
+ }
+ }
- /**
- * Log an exception (throwable) at the supplied level with an accompanying message. If the exception is null, then this method
- * calls {@link #debug(String, Object...)}.
- *
- * @param level the level at which to log
- * @param t the exception (throwable) to log
- * @param message the message accompanying the exception
- * @param params the parameter values that are to replace the variables in the format string
- */
- public void log( Level level,
- Throwable t,
- I18n message,
- Object... params ) {
- if (message == null) return;
- switch (level) {
- case DEBUG:
- debug(t, message.text(LOGGING_LOCALE.get(), params));
- break;
- case ERROR:
- error(t, message, params);
- break;
- case INFO:
- info(t, message, params);
- break;
- case TRACE:
- trace(t, message.text(LOGGING_LOCALE.get(), params));
- break;
- case WARNING:
- warn(t, message, params);
- break;
- case OFF:
- break;
- }
- }
+ /**
+ * Log an exception (throwable) at the supplied level with an accompanying message. If the exception is null, then this method
+ * calls {@link #debug(String, Object...)}.
+ *
+ * @param level the level at which to log
+ * @param t the exception (throwable) to log
+ * @param message the message accompanying the exception
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public void log( Level level,
+ Throwable t,
+ I18n message,
+ Object... params ) {
+ if (message == null) return;
+ switch (level) {
+ case DEBUG:
+ debug(t, message.text(LOGGING_LOCALE.get(), params));
+ break;
+ case ERROR:
+ error(t, message, params);
+ break;
+ case INFO:
+ info(t, message, params);
+ break;
+ case TRACE:
+ trace(t, message.text(LOGGING_LOCALE.get(), params));
+ break;
+ case WARNING:
+ warn(t, message, params);
+ break;
+ case OFF:
+ break;
+ }
+ }
- /**
- * Log a message at the DEBUG level according to the specified format and (optional) parameters. The message should contain a
- * pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is efficient
- * and avoids superfluous object creation when the logger is disabled for the DEBUG level.
- *
- * @param message the message string
- * @param params the parameter values that are to replace the variables in the format string
- */
- public void debug( String message,
- Object... params ) {
- if (!isDebugEnabled()) return;
- if (message == null) return;
- this.delegate.debug(StringUtil.createString(message, params));
- }
+ /**
+ * Log a message at the DEBUG level according to the specified format and (optional) parameters. The message should contain a
+ * pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is efficient
+ * and avoids superfluous object creation when the logger is disabled for the DEBUG level.
+ *
+ * @param message the message string
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public void debug( String message,
+ Object... params ) {
+ if (!isDebugEnabled()) return;
+ if (message == null) return;
+ this.delegate.debug(StringUtil.createString(message, params));
+ }
- /**
- * Log an exception (throwable) at the DEBUG level with an accompanying message. If the exception is null, then this method
- * calls {@link #debug(String, Object...)}.
- *
- * @param t the exception (throwable) to log
- * @param message the message accompanying the exception
- * @param params the parameter values that are to replace the variables in the format string
- */
- public void debug( Throwable t,
- String message,
- Object... params ) {
- if (!isDebugEnabled()) return;
- if (t == null) {
- debug(message, params);
- return;
- }
- if (message == null) {
- this.delegate.debug(null, t);
- return;
- }
- this.delegate.debug(StringUtil.createString(message, params), t);
- }
+ /**
+ * Log an exception (throwable) at the DEBUG level with an accompanying message. If the exception is null, then this method
+ * calls {@link #debug(String, Object...)}.
+ *
+ * @param t the exception (throwable) to log
+ * @param message the message accompanying the exception
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public void debug( Throwable t,
+ String message,
+ Object... params ) {
+ if (!isDebugEnabled()) return;
+ if (t == null) {
+ debug(message, params);
+ return;
+ }
+ if (message == null) {
+ this.delegate.debug(null, t);
+ return;
+ }
+ this.delegate.debug(StringUtil.createString(message, params), t);
+ }
- /**
- * Log a message at the ERROR level according to the specified format and (optional) parameters. The message should contain a
- * pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is efficient
- * and avoids superfluous object creation when the logger is disabled for the ERROR level.
- *
- * @param message the message string
- * @param params the parameter values that are to replace the variables in the format string
- */
- public void error( I18n message,
- Object... params ) {
- if (!isErrorEnabled()) return;
- if (message == null) return;
- this.delegate.error(message.text(LOGGING_LOCALE.get(), params));
- }
+ /**
+ * Log a message at the ERROR level according to the specified format and (optional) parameters. The message should contain a
+ * pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is efficient
+ * and avoids superfluous object creation when the logger is disabled for the ERROR level.
+ *
+ * @param message the message string
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public void error( I18n message,
+ Object... params ) {
+ if (!isErrorEnabled()) return;
+ if (message == null) return;
+ this.delegate.error(message.text(LOGGING_LOCALE.get(), params));
+ }
- /**
- * Log an exception (throwable) at the ERROR level with an accompanying message. If the exception is null, then this method
- * calls {@link #error(I18n, Object...)}.
- *
- * @param t the exception (throwable) to log
- * @param message the message accompanying the exception
- * @param params the parameter values that are to replace the variables in the format string
- */
- public void error( Throwable t,
- I18n message,
- Object... params ) {
- if (!isErrorEnabled()) return;
- if (t == null) {
- error(message, params);
- return;
- }
- if (message == null) {
- this.delegate.error(null, t);
- return;
- }
- this.delegate.error(message.text(LOGGING_LOCALE.get(), params), t);
- }
+ /**
+ * Log an exception (throwable) at the ERROR level with an accompanying message. If the exception is null, then this method
+ * calls {@link #error(I18n, Object...)}.
+ *
+ * @param t the exception (throwable) to log
+ * @param message the message accompanying the exception
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public void error( Throwable t,
+ I18n message,
+ Object... params ) {
+ if (!isErrorEnabled()) return;
+ if (t == null) {
+ error(message, params);
+ return;
+ }
+ if (message == null) {
+ this.delegate.error(null, t);
+ return;
+ }
+ this.delegate.error(message.text(LOGGING_LOCALE.get(), params), t);
+ }
- /**
- * Log a message at the INFO level according to the specified format and (optional) parameters. The message should contain a
- * pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is efficient
- * and avoids superfluous object creation when the logger is disabled for the INFO level.
- *
- * @param message the message string
- * @param params the parameter values that are to replace the variables in the format string
- */
- public void info( I18n message,
- Object... params ) {
- if (!isInfoEnabled()) return;
- if (message == null) return;
- this.delegate.info(message.text(LOGGING_LOCALE.get(), params));
- }
+ /**
+ * Log a message at the INFO level according to the specified format and (optional) parameters. The message should contain a
+ * pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is efficient
+ * and avoids superfluous object creation when the logger is disabled for the INFO level.
+ *
+ * @param message the message string
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public void info( I18n message,
+ Object... params ) {
+ if (!isInfoEnabled()) return;
+ if (message == null) return;
+ this.delegate.info(message.text(LOGGING_LOCALE.get(), params));
+ }
- /**
- * Log an exception (throwable) at the INFO level with an accompanying message. If the exception is null, then this method
- * calls {@link #info(I18n, Object...)}.
- *
- * @param t the exception (throwable) to log
- * @param message the message accompanying the exception
- * @param params the parameter values that are to replace the variables in the format string
- */
- public void info( Throwable t,
- I18n message,
- Object... params ) {
- if (!isInfoEnabled()) return;
- if (t == null) {
- info(message, params);
- return;
- }
- if (message == null) {
- this.delegate.info(null, t);
- return;
- }
- this.delegate.info(message.text(LOGGING_LOCALE.get(), params), t);
- }
+ /**
+ * Log an exception (throwable) at the INFO level with an accompanying message. If the exception is null, then this method
+ * calls {@link #info(I18n, Object...)}.
+ *
+ * @param t the exception (throwable) to log
+ * @param message the message accompanying the exception
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public void info( Throwable t,
+ I18n message,
+ Object... params ) {
+ if (!isInfoEnabled()) return;
+ if (t == null) {
+ info(message, params);
+ return;
+ }
+ if (message == null) {
+ this.delegate.info(null, t);
+ return;
+ }
+ this.delegate.info(message.text(LOGGING_LOCALE.get(), params), t);
+ }
- /**
- * Log a message at the TRACE level according to the specified format and (optional) parameters. The message should contain a
- * pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is efficient
- * and avoids superfluous object creation when the logger is disabled for the TRACE level.
- *
- * @param message the message string
- * @param params the parameter values that are to replace the variables in the format string
- */
- public void trace( String message,
- Object... params ) {
- if (!isTraceEnabled()) return;
- if (message == null) return;
- this.delegate.trace(StringUtil.createString(message, params));
- }
+ /**
+ * Log a message at the TRACE level according to the specified format and (optional) parameters. The message should contain a
+ * pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is efficient
+ * and avoids superfluous object creation when the logger is disabled for the TRACE level.
+ *
+ * @param message the message string
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public void trace( String message,
+ Object... params ) {
+ if (!isTraceEnabled()) return;
+ if (message == null) return;
+ this.delegate.trace(StringUtil.createString(message, params));
+ }
- /**
- * Log an exception (throwable) at the TRACE level with an accompanying message. If the exception is null, then this method
- * calls {@link #trace(String, Object...)}.
- *
- * @param t the exception (throwable) to log
- * @param message the message accompanying the exception
- * @param params the parameter values that are to replace the variables in the format string
- */
- public void trace( Throwable t,
- String message,
- Object... params ) {
- if (!isTraceEnabled()) return;
- if (t == null) {
- this.trace(message, params);
- return;
- }
- if (message == null) {
- this.delegate.trace(null, t);
- return;
- }
- this.delegate.trace(StringUtil.createString(message, params), t);
- }
+ /**
+ * Log an exception (throwable) at the TRACE level with an accompanying message. If the exception is null, then this method
+ * calls {@link #trace(String, Object...)}.
+ *
+ * @param t the exception (throwable) to log
+ * @param message the message accompanying the exception
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public void trace( Throwable t,
+ String message,
+ Object... params ) {
+ if (!isTraceEnabled()) return;
+ if (t == null) {
+ this.trace(message, params);
+ return;
+ }
+ if (message == null) {
+ this.delegate.trace(null, t);
+ return;
+ }
+ this.delegate.trace(StringUtil.createString(message, params), t);
+ }
- /**
- * Log a message at the WARNING level according to the specified format and (optional) parameters. The message should contain
- * a pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is
- * efficient and avoids superfluous object creation when the logger is disabled for the WARNING level.
- *
- * @param message the message string
- * @param params the parameter values that are to replace the variables in the format string
- */
- public void warn( I18n message,
- Object... params ) {
- if (!isWarnEnabled()) return;
- if (message == null) return;
- this.delegate.warn(message.text(LOGGING_LOCALE.get(), params));
- }
+ /**
+ * Log a message at the WARNING level according to the specified format and (optional) parameters. The message should contain
+ * a pair of empty curly braces for each of the parameter, which should be passed in the correct order. This method is
+ * efficient and avoids superfluous object creation when the logger is disabled for the WARNING level.
+ *
+ * @param message the message string
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public void warn( I18n message,
+ Object... params ) {
+ if (!isWarnEnabled()) return;
+ if (message == null) return;
+ this.delegate.warn(message.text(LOGGING_LOCALE.get(), params));
+ }
- /**
- * Log an exception (throwable) at the WARNING level with an accompanying message. If the exception is null, then this method
- * calls {@link #warn(I18n, Object...)}.
- *
- * @param t the exception (throwable) to log
- * @param message the message accompanying the exception
- * @param params the parameter values that are to replace the variables in the format string
- */
- public void warn( Throwable t,
- I18n message,
- Object... params ) {
- if (!isWarnEnabled()) return;
- if (t == null) {
- warn(message, params);
- return;
- }
- if (message == null) {
- this.delegate.warn(null, t);
- return;
- }
- this.delegate.warn(message.text(LOGGING_LOCALE.get(), params), t);
- }
+ /**
+ * Log an exception (throwable) at the WARNING level with an accompanying message. If the exception is null, then this method
+ * calls {@link #warn(I18n, Object...)}.
+ *
+ * @param t the exception (throwable) to log
+ * @param message the message accompanying the exception
+ * @param params the parameter values that are to replace the variables in the format string
+ */
+ public void warn( Throwable t,
+ I18n message,
+ Object... params ) {
+ if (!isWarnEnabled()) return;
+ if (t == null) {
+ warn(message, params);
+ return;
+ }
+ if (message == null) {
+ this.delegate.warn(null, t);
+ return;
+ }
+ this.delegate.warn(message.text(LOGGING_LOCALE.get(), params), t);
+ }
- /**
- * Return whether messages at the INFORMATION level are being logged.
- *
- * @return true if INFORMATION log messages are currently being logged, or false otherwise.
- */
- public boolean isInfoEnabled() {
- return this.delegate.isInfoEnabled();
- }
+ /**
+ * Return whether messages at the INFORMATION level are being logged.
+ *
+ * @return true if INFORMATION log messages are currently being logged, or false otherwise.
+ */
+ public boolean isInfoEnabled() {
+ return this.delegate.isInfoEnabled();
+ }
- /**
- * Return whether messages at the WARNING level are being logged.
- *
- * @return true if WARNING log messages are currently being logged, or false otherwise.
- */
- public boolean isWarnEnabled() {
- return this.delegate.isWarnEnabled();
- }
+ /**
+ * Return whether messages at the WARNING level are being logged.
+ *
+ * @return true if WARNING log messages are currently being logged, or false otherwise.
+ */
+ public boolean isWarnEnabled() {
+ return this.delegate.isWarnEnabled();
+ }
- /**
- * Return whether messages at the ERROR level are being logged.
- *
- * @return true if ERROR log messages are currently being logged, or false otherwise.
- */
- public boolean isErrorEnabled() {
- return this.delegate.isErrorEnabled();
- }
+ /**
+ * Return whether messages at the ERROR level are being logged.
+ *
+ * @return true if ERROR log messages are currently being logged, or false otherwise.
+ */
+ public boolean isErrorEnabled() {
+ return this.delegate.isErrorEnabled();
+ }
- /**
- * Return whether messages at the DEBUG level are being logged.
- *
- * @return true if DEBUG log messages are currently being logged, or false otherwise.
- */
- public boolean isDebugEnabled() {
- return this.delegate.isDebugEnabled();
- }
+ /**
+ * Return whether messages at the DEBUG level are being logged.
+ *
+ * @return true if DEBUG log messages are currently being logged, or false otherwise.
+ */
+ public boolean isDebugEnabled() {
+ return this.delegate.isDebugEnabled();
+ }
- /**
- * Return whether messages at the TRACE level are being logged.
- *
- * @return true if TRACE log messages are currently being logged, or false otherwise.
- */
- public boolean isTraceEnabled() {
- return this.delegate.isTraceEnabled();
- }
+ /**
+ * Return whether messages at the TRACE level are being logged.
+ *
+ * @return true if TRACE log messages are currently being logged, or false otherwise.
+ */
+ public boolean isTraceEnabled() {
+ return this.delegate.isTraceEnabled();
+ }
- /**
- * Get the logging level at which this logger is current set.
- *
- * @return the current logging level
- */
- public Level getLevel() {
- if (this.isTraceEnabled()) return Level.TRACE;
- if (this.isDebugEnabled()) return Level.DEBUG;
- if (this.isInfoEnabled()) return Level.INFO;
- if (this.isWarnEnabled()) return Level.WARNING;
- if (this.isErrorEnabled()) return Level.ERROR;
- return Level.OFF;
- }
+ /**
+ * Get the logging level at which this logger is current set.
+ *
+ * @return the current logging level
+ */
+ public Level getLevel() {
+ if (this.isTraceEnabled()) return Level.TRACE;
+ if (this.isDebugEnabled()) return Level.DEBUG;
+ if (this.isInfoEnabled()) return Level.INFO;
+ if (this.isWarnEnabled()) return Level.WARNING;
+ if (this.isErrorEnabled()) return Level.ERROR;
+ return Level.OFF;
+ }
}
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/util/StringUtil.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/util/StringUtil.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/util/StringUtil.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -45,611 +45,611 @@
*/
public class StringUtil {
- public static final String[] EMPTY_STRING_ARRAY = new String[0];
- private static final Pattern NORMALIZE_PATTERN = Pattern.compile("\\s+");
- private static final Pattern PARAMETER_COUNT_PATTERN = Pattern.compile("\\{(\\d+)\\}");
+ public static final String[] EMPTY_STRING_ARRAY = new String[0];
+ private static final Pattern NORMALIZE_PATTERN = Pattern.compile("\\s+");
+ private static final Pattern PARAMETER_COUNT_PATTERN = Pattern.compile("\\{(\\d+)\\}");
- /**
- * Split the supplied content into lines, returning each line as an element in the returned list.
- *
- * @param content the string content that is to be split
- * @return the list of lines; never null but may be an empty (unmodifiable) list if the supplied content is null or empty
- */
- public static List<String> splitLines( final String content ) {
- if (content == null || content.length() == 0) return Collections.emptyList();
- String[] lines = content.split("[\\r]?\\n");
- return Arrays.asList(lines);
- }
+ /**
+ * Split the supplied content into lines, returning each line as an element in the returned list.
+ *
+ * @param content the string content that is to be split
+ * @return the list of lines; never null but may be an empty (unmodifiable) list if the supplied content is null or empty
+ */
+ public static List<String> splitLines( final String content ) {
+ if (content == null || content.length() == 0) return Collections.emptyList();
+ String[] lines = content.split("[\\r]?\\n");
+ return Arrays.asList(lines);
+ }
- /**
- * Create a string by substituting the parameters into all key occurrences in the supplied format. The pattern consists of
- * zero or more keys of the form <code>{n}</code>, where <code>n</code> is an integer starting at 1. Therefore, the first
- * parameter replaces all occurrences of "{1}", the second parameter replaces all occurrences of "{2}", etc.
- * <p>
- * If any parameter is null, the corresponding key is replaced with the string "null". Therefore, consider using an empty
- * string when keys are to be removed altogether.
- * </p>
- * <p>
- * If there are no parameters, this method does nothing and returns the supplied pattern as is.
- * </p>
- *
- * @param pattern the pattern
- * @param parameters the parameters used to replace keys
- * @return the string with all keys replaced (or removed)
- */
- public static String createString( String pattern,
- Object... parameters ) {
- ArgCheck.isNotNull(pattern, "pattern");
- if (parameters == null) parameters = EMPTY_STRING_ARRAY;
- Matcher matcher = PARAMETER_COUNT_PATTERN.matcher(pattern);
- StringBuffer text = new StringBuffer();
- int requiredParameterCount = 0;
- boolean err = false;
- while (matcher.find()) {
- int ndx = Integer.valueOf(matcher.group(1));
- if (requiredParameterCount <= ndx) {
- requiredParameterCount = ndx + 1;
- }
- if (ndx >= parameters.length) {
- err = true;
- matcher.appendReplacement(text, matcher.group());
- } else {
- Object parameter = parameters[ndx];
- matcher.appendReplacement(text, Matcher.quoteReplacement(parameter == null ? "null" : parameter.toString()));
- }
- }
- if (err || requiredParameterCount < parameters.length) {
- throw new IllegalArgumentException(
- CommonI18n.requiredToSuppliedParameterMismatch.text(parameters.length,
- parameters.length == 1 ? "" : "s",
- requiredParameterCount,
- requiredParameterCount == 1 ? "" : "s",
- pattern,
- text.toString()));
- }
- matcher.appendTail(text);
+ /**
+ * Create a string by substituting the parameters into all key occurrences in the supplied format. The pattern consists of
+ * zero or more keys of the form <code>{n}</code>, where <code>n</code> is an integer starting at 1. Therefore, the first
+ * parameter replaces all occurrences of "{1}", the second parameter replaces all occurrences of "{2}", etc.
+ * <p>
+ * If any parameter is null, the corresponding key is replaced with the string "null". Therefore, consider using an empty
+ * string when keys are to be removed altogether.
+ * </p>
+ * <p>
+ * If there are no parameters, this method does nothing and returns the supplied pattern as is.
+ * </p>
+ *
+ * @param pattern the pattern
+ * @param parameters the parameters used to replace keys
+ * @return the string with all keys replaced (or removed)
+ */
+ public static String createString( String pattern,
+ Object... parameters ) {
+ ArgCheck.isNotNull(pattern, "pattern");
+ if (parameters == null) parameters = EMPTY_STRING_ARRAY;
+ Matcher matcher = PARAMETER_COUNT_PATTERN.matcher(pattern);
+ StringBuffer text = new StringBuffer();
+ int requiredParameterCount = 0;
+ boolean err = false;
+ while (matcher.find()) {
+ int ndx = Integer.valueOf(matcher.group(1));
+ if (requiredParameterCount <= ndx) {
+ requiredParameterCount = ndx + 1;
+ }
+ if (ndx >= parameters.length) {
+ err = true;
+ matcher.appendReplacement(text, matcher.group());
+ } else {
+ Object parameter = parameters[ndx];
+ matcher.appendReplacement(text, Matcher.quoteReplacement(parameter == null ? "null" : parameter.toString()));
+ }
+ }
+ if (err || requiredParameterCount < parameters.length) {
+ throw new IllegalArgumentException(
+ CommonI18n.requiredToSuppliedParameterMismatch.text(parameters.length,
+ parameters.length == 1 ? "" : "s",
+ requiredParameterCount,
+ requiredParameterCount == 1 ? "" : "s",
+ pattern,
+ text.toString()));
+ }
+ matcher.appendTail(text);
- return text.toString();
- }
+ return text.toString();
+ }
- /**
- * Create a new string containing the specified character repeated a specific number of times.
- *
- * @param charToRepeat the character to repeat
- * @param numberOfRepeats the number of times the character is to repeat in the result; must be greater than 0
- * @return the resulting string
- */
- public static String createString( final char charToRepeat,
- int numberOfRepeats ) {
- assert numberOfRepeats >= 0;
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < numberOfRepeats; ++i) {
- sb.append(charToRepeat);
- }
- return sb.toString();
- }
+ /**
+ * Create a new string containing the specified character repeated a specific number of times.
+ *
+ * @param charToRepeat the character to repeat
+ * @param numberOfRepeats the number of times the character is to repeat in the result; must be greater than 0
+ * @return the resulting string
+ */
+ public static String createString( final char charToRepeat,
+ int numberOfRepeats ) {
+ assert numberOfRepeats >= 0;
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < numberOfRepeats; ++i) {
+ sb.append(charToRepeat);
+ }
+ return sb.toString();
+ }
- /**
- * Set the length of the string, padding with the supplied character if the supplied string is shorter than desired, or
- * truncating the string if it is longer than desired. Unlike {@link #justifyLeft(String, int, char)}, this method does not
- * remove leading and trailing whitespace.
- *
- * @param original the string for which the length is to be set; may not be null
- * @param length the desired length; must be positive
- * @param padChar the character to use for padding, if the supplied string is not long enough
- * @return the string of the desired length
- * @see #justifyLeft(String, int, char)
- */
- public static String setLength( String original,
- int length,
- char padChar ) {
- return justifyLeft(original, length, padChar, false);
- }
+ /**
+ * Set the length of the string, padding with the supplied character if the supplied string is shorter than desired, or
+ * truncating the string if it is longer than desired. Unlike {@link #justifyLeft(String, int, char)}, this method does not
+ * remove leading and trailing whitespace.
+ *
+ * @param original the string for which the length is to be set; may not be null
+ * @param length the desired length; must be positive
+ * @param padChar the character to use for padding, if the supplied string is not long enough
+ * @return the string of the desired length
+ * @see #justifyLeft(String, int, char)
+ */
+ public static String setLength( String original,
+ int length,
+ char padChar ) {
+ return justifyLeft(original, length, padChar, false);
+ }
- /**
- * Right justify the contents of the string, ensuring that the string ends at the last character. If the supplied string is
- * longer than the desired width, the leading characters are removed so that the last character in the supplied string at the
- * last position. If the supplied string is shorter than the desired width, the padding character is inserted one or more
- * times such that the last character in the supplied string appears as the last character in the resulting string and that
- * the length matches that specified.
- *
- * @param str the string to be right justified; if null, an empty string is used
- * @param width the desired width of the string; must be positive
- * @param padWithChar the character to use for padding, if needed
- * @return the right justified string
- */
- public static String justifyRight( String str,
- final int width,
- char padWithChar ) {
- assert width > 0;
- // Trim the leading and trailing whitespace ...
- str = str != null ? str.trim() : "";
+ /**
+ * Right justify the contents of the string, ensuring that the string ends at the last character. If the supplied string is
+ * longer than the desired width, the leading characters are removed so that the last character in the supplied string at the
+ * last position. If the supplied string is shorter than the desired width, the padding character is inserted one or more
+ * times such that the last character in the supplied string appears as the last character in the resulting string and that
+ * the length matches that specified.
+ *
+ * @param str the string to be right justified; if null, an empty string is used
+ * @param width the desired width of the string; must be positive
+ * @param padWithChar the character to use for padding, if needed
+ * @return the right justified string
+ */
+ public static String justifyRight( String str,
+ final int width,
+ char padWithChar ) {
+ assert width > 0;
+ // Trim the leading and trailing whitespace ...
+ str = str != null ? str.trim() : "";
- final int length = str.length();
- int addChars = width - length;
- if (addChars < 0) {
- // truncate the first characters, keep the last
- return str.subSequence(length - width, length).toString();
- }
- // Prepend the whitespace ...
- final StringBuilder sb = new StringBuilder();
- while (addChars > 0) {
- sb.append(padWithChar);
- --addChars;
- }
+ final int length = str.length();
+ int addChars = width - length;
+ if (addChars < 0) {
+ // truncate the first characters, keep the last
+ return str.subSequence(length - width, length).toString();
+ }
+ // Prepend the whitespace ...
+ final StringBuilder sb = new StringBuilder();
+ while (addChars > 0) {
+ sb.append(padWithChar);
+ --addChars;
+ }
- // Write the content ...
- sb.append(str);
- return sb.toString();
- }
+ // Write the content ...
+ sb.append(str);
+ return sb.toString();
+ }
- /**
- * Left justify the contents of the string, ensuring that the supplied string begins at the first character and that the
- * resulting string is of the desired length. If the supplied string is longer than the desired width, it is truncated to the
- * specified length. If the supplied string is shorter than the desired width, the padding character is added to the end of
- * the string one or more times such that the length is that specified. All leading and trailing whitespace is removed.
- *
- * @param str the string to be left justified; if null, an empty string is used
- * @param width the desired width of the string; must be positive
- * @param padWithChar the character to use for padding, if needed
- * @return the left justified string
- * @see #setLength(String, int, char)
- */
- public static String justifyLeft( String str,
- final int width,
- char padWithChar ) {
- return justifyLeft(str, width, padWithChar, true);
- }
+ /**
+ * Left justify the contents of the string, ensuring that the supplied string begins at the first character and that the
+ * resulting string is of the desired length. If the supplied string is longer than the desired width, it is truncated to the
+ * specified length. If the supplied string is shorter than the desired width, the padding character is added to the end of
+ * the string one or more times such that the length is that specified. All leading and trailing whitespace is removed.
+ *
+ * @param str the string to be left justified; if null, an empty string is used
+ * @param width the desired width of the string; must be positive
+ * @param padWithChar the character to use for padding, if needed
+ * @return the left justified string
+ * @see #setLength(String, int, char)
+ */
+ public static String justifyLeft( String str,
+ final int width,
+ char padWithChar ) {
+ return justifyLeft(str, width, padWithChar, true);
+ }
- protected static String justifyLeft( String str,
- final int width,
- char padWithChar,
- boolean trimWhitespace ) {
- // Trim the leading and trailing whitespace ...
- str = str != null ? (trimWhitespace ? str.trim() : str) : "";
+ protected static String justifyLeft( String str,
+ final int width,
+ char padWithChar,
+ boolean trimWhitespace ) {
+ // Trim the leading and trailing whitespace ...
+ str = str != null ? (trimWhitespace ? str.trim() : str) : "";
- int addChars = width - str.length();
- if (addChars < 0) {
- // truncate
- return str.subSequence(0, width).toString();
- }
- // Write the content ...
- final StringBuilder sb = new StringBuilder();
- sb.append(str);
+ int addChars = width - str.length();
+ if (addChars < 0) {
+ // truncate
+ return str.subSequence(0, width).toString();
+ }
+ // Write the content ...
+ final StringBuilder sb = new StringBuilder();
+ sb.append(str);
- // Append the whitespace ...
- while (addChars > 0) {
- sb.append(padWithChar);
- --addChars;
- }
+ // Append the whitespace ...
+ while (addChars > 0) {
+ sb.append(padWithChar);
+ --addChars;
+ }
- return sb.toString();
- }
+ return sb.toString();
+ }
- /**
- * Center the contents of the string. If the supplied string is longer than the desired width, it is truncated to the
- * specified length. If the supplied string is shorter than the desired width, padding characters are added to the beginning
- * and end of the string such that the length is that specified; one additional padding character is prepended if required.
- * All leading and trailing whitespace is removed before centering.
- *
- * @param str the string to be left justified; if null, an empty string is used
- * @param width the desired width of the string; must be positive
- * @param padWithChar the character to use for padding, if needed
- * @return the left justified string
- * @see #setLength(String, int, char)
- */
- public static String justifyCenter( String str,
- final int width,
- char padWithChar ) {
- // Trim the leading and trailing whitespace ...
- str = str != null ? str.trim() : "";
+ /**
+ * Center the contents of the string. If the supplied string is longer than the desired width, it is truncated to the
+ * specified length. If the supplied string is shorter than the desired width, padding characters are added to the beginning
+ * and end of the string such that the length is that specified; one additional padding character is prepended if required.
+ * All leading and trailing whitespace is removed before centering.
+ *
+ * @param str the string to be left justified; if null, an empty string is used
+ * @param width the desired width of the string; must be positive
+ * @param padWithChar the character to use for padding, if needed
+ * @return the left justified string
+ * @see #setLength(String, int, char)
+ */
+ public static String justifyCenter( String str,
+ final int width,
+ char padWithChar ) {
+ // Trim the leading and trailing whitespace ...
+ str = str != null ? str.trim() : "";
- int addChars = width - str.length();
- if (addChars < 0) {
- // truncate
- return str.subSequence(0, width).toString();
- }
- // Write the content ...
- int prependNumber = addChars / 2;
- int appendNumber = prependNumber;
- if ((prependNumber + appendNumber) != addChars) {
- ++prependNumber;
- }
+ int addChars = width - str.length();
+ if (addChars < 0) {
+ // truncate
+ return str.subSequence(0, width).toString();
+ }
+ // Write the content ...
+ int prependNumber = addChars / 2;
+ int appendNumber = prependNumber;
+ if ((prependNumber + appendNumber) != addChars) {
+ ++prependNumber;
+ }
- final StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
- // Prepend the pad character(s) ...
- while (prependNumber > 0) {
- sb.append(padWithChar);
- --prependNumber;
- }
+ // Prepend the pad character(s) ...
+ while (prependNumber > 0) {
+ sb.append(padWithChar);
+ --prependNumber;
+ }
- // Add the actual content
- sb.append(str);
+ // Add the actual content
+ sb.append(str);
- // Append the pad character(s) ...
- while (appendNumber > 0) {
- sb.append(padWithChar);
- --appendNumber;
- }
+ // Append the pad character(s) ...
+ while (appendNumber > 0) {
+ sb.append(padWithChar);
+ --appendNumber;
+ }
- return sb.toString();
- }
+ return sb.toString();
+ }
- /**
- * Truncate the supplied string to be no more than the specified length. This method returns an empty string if the supplied
- * object is null.
- *
- * @param obj the object from which the string is to be obtained using {@link Object#toString()}.
- * @param maxLength the maximum length of the string being returned
- * @return the supplied string if no longer than the maximum length, or the supplied string truncated to be no longer than the
- * maximum length (including the suffix)
- * @throws IllegalArgumentException if the maximum length is negative
- */
- public static String truncate( Object obj,
- int maxLength ) {
- return truncate(obj, maxLength, null);
- }
+ /**
+ * Truncate the supplied string to be no more than the specified length. This method returns an empty string if the supplied
+ * object is null.
+ *
+ * @param obj the object from which the string is to be obtained using {@link Object#toString()}.
+ * @param maxLength the maximum length of the string being returned
+ * @return the supplied string if no longer than the maximum length, or the supplied string truncated to be no longer than the
+ * maximum length (including the suffix)
+ * @throws IllegalArgumentException if the maximum length is negative
+ */
+ public static String truncate( Object obj,
+ int maxLength ) {
+ return truncate(obj, maxLength, null);
+ }
- /**
- * Truncate the supplied string to be no more than the specified length. This method returns an empty string if the supplied
- * object is null.
- *
- * @param obj the object from which the string is to be obtained using {@link Object#toString()}.
- * @param maxLength the maximum length of the string being returned
- * @param suffix the suffix that should be added to the content if the string must be truncated, or null if the default suffix
- * of "..." should be used
- * @return the supplied string if no longer than the maximum length, or the supplied string truncated to be no longer than the
- * maximum length (including the suffix)
- * @throws IllegalArgumentException if the maximum length is negative
- */
- public static String truncate( Object obj,
- int maxLength,
- String suffix ) {
- ArgCheck.isNonNegative(maxLength, "maxLength");
- if (obj == null || maxLength == 0) {
- return "";
- }
- String str = obj.toString();
- if (str.length() <= maxLength) return str;
- if (suffix == null) suffix = "...";
- int maxNumChars = maxLength - suffix.length();
- if (maxNumChars < 0) {
- // Then the max length is actually shorter than the suffix ...
- str = suffix.substring(0, maxLength);
- } else if (str.length() > maxNumChars) {
- str = str.substring(0, maxNumChars) + suffix;
- }
- return str;
- }
+ /**
+ * Truncate the supplied string to be no more than the specified length. This method returns an empty string if the supplied
+ * object is null.
+ *
+ * @param obj the object from which the string is to be obtained using {@link Object#toString()}.
+ * @param maxLength the maximum length of the string being returned
+ * @param suffix the suffix that should be added to the content if the string must be truncated, or null if the default suffix
+ * of "..." should be used
+ * @return the supplied string if no longer than the maximum length, or the supplied string truncated to be no longer than the
+ * maximum length (including the suffix)
+ * @throws IllegalArgumentException if the maximum length is negative
+ */
+ public static String truncate( Object obj,
+ int maxLength,
+ String suffix ) {
+ ArgCheck.isNonNegative(maxLength, "maxLength");
+ if (obj == null || maxLength == 0) {
+ return "";
+ }
+ String str = obj.toString();
+ if (str.length() <= maxLength) return str;
+ if (suffix == null) suffix = "...";
+ int maxNumChars = maxLength - suffix.length();
+ if (maxNumChars < 0) {
+ // Then the max length is actually shorter than the suffix ...
+ str = suffix.substring(0, maxLength);
+ } else if (str.length() > maxNumChars) {
+ str = str.substring(0, maxNumChars) + suffix;
+ }
+ return str;
+ }
- /**
- * Read and return the entire contents of the supplied {@link Reader}. This method always closes the reader when finished
- * reading.
- *
- * @param reader the reader of the contents; may be null
- * @return the contents, or an empty string if the supplied reader is null
- * @throws IOException if there is an error reading the content
- */
- public static String read( Reader reader ) throws IOException {
- return IoUtil.read(reader);
- }
+ /**
+ * Read and return the entire contents of the supplied {@link Reader}. This method always closes the reader when finished
+ * reading.
+ *
+ * @param reader the reader of the contents; may be null
+ * @return the contents, or an empty string if the supplied reader is null
+ * @throws IOException if there is an error reading the content
+ */
+ public static String read( Reader reader ) throws IOException {
+ return IoUtil.read(reader);
+ }
- /**
- * Read and return the entire contents of the supplied {@link InputStream}. This method always closes the stream when
- * finished reading.
- *
- * @param stream the streamed contents; may be null
- * @return the contents, or an empty string if the supplied stream is null
- * @throws IOException if there is an error reading the content
- */
- public static String read( InputStream stream ) throws IOException {
- return IoUtil.read(stream);
- }
+ /**
+ * Read and return the entire contents of the supplied {@link InputStream}. This method always closes the stream when
+ * finished reading.
+ *
+ * @param stream the streamed contents; may be null
+ * @return the contents, or an empty string if the supplied stream is null
+ * @throws IOException if there is an error reading the content
+ */
+ public static String read( InputStream stream ) throws IOException {
+ return IoUtil.read(stream);
+ }
- /**
- * Write the entire contents of the supplied string to the given stream. This method always flushes and closes the stream when
- * finished.
- *
- * @param content the content to write to the stream; may be null
- * @param stream the stream to which the content is to be written
- * @throws IOException
- * @throws IllegalArgumentException if the stream is null
- */
- public static void write( String content,
- OutputStream stream ) throws IOException {
- IoUtil.write(content, stream);
- }
+ /**
+ * Write the entire contents of the supplied string to the given stream. This method always flushes and closes the stream when
+ * finished.
+ *
+ * @param content the content to write to the stream; may be null
+ * @param stream the stream to which the content is to be written
+ * @throws IOException
+ * @throws IllegalArgumentException if the stream is null
+ */
+ public static void write( String content,
+ OutputStream stream ) throws IOException {
+ IoUtil.write(content, stream);
+ }
- /**
- * Write the entire contents of the supplied string to the given writer. This method always flushes and closes the writer when
- * finished.
- *
- * @param content the content to write to the writer; may be null
- * @param writer the writer to which the content is to be written
- * @throws IOException
- * @throws IllegalArgumentException if the writer is null
- */
- public static void write( String content,
- Writer writer ) throws IOException {
- IoUtil.write(content, writer);
- }
+ /**
+ * Write the entire contents of the supplied string to the given writer. This method always flushes and closes the writer when
+ * finished.
+ *
+ * @param content the content to write to the writer; may be null
+ * @param writer the writer to which the content is to be written
+ * @throws IOException
+ * @throws IllegalArgumentException if the writer is null
+ */
+ public static void write( String content,
+ Writer writer ) throws IOException {
+ IoUtil.write(content, writer);
+ }
- /**
- * Create a human-readable form of the supplied object by choosing the representation format based upon the object type.
- * <p>
- * <ul>
- * <li>A null reference results in the "null" string.</li>
- * <li>A string is written wrapped by double quotes.</li>
- * <li>A boolean is written using {@link Boolean#toString()}.</li>
- * <li>A {@link Number number} is written using the standard {@link Number#toString() toString()} method.</li>
- * <li>A {@link java.util.Date date} is written using the the {@link DateUtil#getDateAsStandardString(java.util.Date)}
- * utility method.</li>
- * <li>A {@link java.sql.Date SQL date} is written using the the {@link DateUtil#getDateAsStandardString(java.util.Date)}
- * utility method.</li>
- * <li>A {@link Calendar Calendar instance} is written using the the {@link DateUtil#getDateAsStandardString(Calendar)}
- * utility method.</li>
- * <li>An array of bytes is written with a leading "[ " and trailing " ]" surrounding the bytes written as UTF-8.
- * <li>An array of objects is written with a leading "[ " and trailing " ]", and with all objects sent through
- * {@link #readableString(Object)} and separated by ", ".</li>
- * <li>A collection of objects (e.g, <code>Collection<?></code>) is written with a leading "[ " and trailing " ]", and
- * with all objects sent through {@link #readableString(Object)} and separated by ", ".</li>
- * <li>A map of objects (e.g, <code>Map<?></code>) is written with a leading "{ " and trailing " }", and with all map
- * entries written in the form "key => value" and separated by ", ". All key and value objects are sent through the
- * {@link #readableString(Object)} method.</li>
- * <li>Any other object is written using the object's {@link Object#toString() toString()} method.</li>
- * </ul>
- * </p>
- * <p>
- * This method is capable of generating strings for nested objects. For example, a <code>Map<Date,Object[]></code> would be
- * written in the form:
- *
- * <pre>
- * { 2008-02-03T14:22:49 => [ "description", 3, [ 003459de7389g23aef, true ] ] }
- * </pre>
- *
- * </p>
- *
- * @param obj the object that is to be converted to a string.
- * @return the string representation that is to be human readable
- */
- public static String readableString( Object obj ) {
- if (obj == null) return "null";
- if (obj instanceof Boolean) return ((Boolean)obj).toString();
- if (obj instanceof String) return "\"" + obj.toString() + "\"";
- if (obj instanceof Number) return obj.toString();
- if (obj instanceof Map) return readableString((Map)obj);
- if (obj instanceof Collection) return readableString((Collection)obj);
- if (obj instanceof byte[]) return readableString((byte[])obj);
- if (obj instanceof boolean[]) return readableString((boolean[])obj);
- if (obj instanceof short[]) return readableString((short[])obj);
- if (obj instanceof int[]) return readableString((int[])obj);
- if (obj instanceof long[]) return readableString((long[])obj);
- if (obj instanceof float[]) return readableString((float[])obj);
- if (obj instanceof double[]) return readableString((double[])obj);
- if (obj instanceof Object[]) return readableString((Object[])obj);
- if (obj instanceof Calendar) return DateUtil.getDateAsStandardString((Calendar)obj);
- if (obj instanceof java.util.Date) return DateUtil.getDateAsStandardString((java.util.Date)obj);
- if (obj instanceof java.sql.Date) return DateUtil.getDateAsStandardString((java.sql.Date)obj);
- return obj.toString();
- }
+ /**
+ * Create a human-readable form of the supplied object by choosing the representation format based upon the object type.
+ * <p>
+ * <ul>
+ * <li>A null reference results in the "null" string.</li>
+ * <li>A string is written wrapped by double quotes.</li>
+ * <li>A boolean is written using {@link Boolean#toString()}.</li>
+ * <li>A {@link Number number} is written using the standard {@link Number#toString() toString()} method.</li>
+ * <li>A {@link java.util.Date date} is written using the the {@link DateUtil#getDateAsStandardString(java.util.Date)}
+ * utility method.</li>
+ * <li>A {@link java.sql.Date SQL date} is written using the the {@link DateUtil#getDateAsStandardString(java.util.Date)}
+ * utility method.</li>
+ * <li>A {@link Calendar Calendar instance} is written using the the {@link DateUtil#getDateAsStandardString(Calendar)}
+ * utility method.</li>
+ * <li>An array of bytes is written with a leading "[ " and trailing " ]" surrounding the bytes written as UTF-8.
+ * <li>An array of objects is written with a leading "[ " and trailing " ]", and with all objects sent through
+ * {@link #readableString(Object)} and separated by ", ".</li>
+ * <li>A collection of objects (e.g, <code>Collection<?></code>) is written with a leading "[ " and trailing " ]", and
+ * with all objects sent through {@link #readableString(Object)} and separated by ", ".</li>
+ * <li>A map of objects (e.g, <code>Map<?></code>) is written with a leading "{ " and trailing " }", and with all map
+ * entries written in the form "key => value" and separated by ", ". All key and value objects are sent through the
+ * {@link #readableString(Object)} method.</li>
+ * <li>Any other object is written using the object's {@link Object#toString() toString()} method.</li>
+ * </ul>
+ * </p>
+ * <p>
+ * This method is capable of generating strings for nested objects. For example, a <code>Map<Date,Object[]></code> would be
+ * written in the form:
+ *
+ * <pre>
+ * { 2008-02-03T14:22:49 => [ "description", 3, [ 003459de7389g23aef, true ] ] }
+ * </pre>
+ *
+ * </p>
+ *
+ * @param obj the object that is to be converted to a string.
+ * @return the string representation that is to be human readable
+ */
+ public static String readableString( Object obj ) {
+ if (obj == null) return "null";
+ if (obj instanceof Boolean) return ((Boolean)obj).toString();
+ if (obj instanceof String) return "\"" + obj.toString() + "\"";
+ if (obj instanceof Number) return obj.toString();
+ if (obj instanceof Map<?, ?>) return readableString((Map<?, ?>)obj);
+ if (obj instanceof Collection<?>) return readableString((Collection<?>)obj);
+ if (obj instanceof byte[]) return readableString((byte[])obj);
+ if (obj instanceof boolean[]) return readableString((boolean[])obj);
+ if (obj instanceof short[]) return readableString((short[])obj);
+ if (obj instanceof int[]) return readableString((int[])obj);
+ if (obj instanceof long[]) return readableString((long[])obj);
+ if (obj instanceof float[]) return readableString((float[])obj);
+ if (obj instanceof double[]) return readableString((double[])obj);
+ if (obj instanceof Object[]) return readableString((Object[])obj);
+ if (obj instanceof Calendar) return DateUtil.getDateAsStandardString((Calendar)obj);
+ if (obj instanceof java.util.Date) return DateUtil.getDateAsStandardString((java.util.Date)obj);
+ if (obj instanceof java.sql.Date) return DateUtil.getDateAsStandardString((java.sql.Date)obj);
+ return obj.toString();
+ }
- protected static String readableEmptyArray( Class arrayClass ) {
- assert arrayClass != null;
- Class componentType = arrayClass.getComponentType();
- if (componentType.isArray()) return "[" + readableEmptyArray(componentType) + "]";
- return "[]";
- }
+ protected static String readableEmptyArray( Class<?> arrayClass ) {
+ assert arrayClass != null;
+ Class<?> componentType = arrayClass.getComponentType();
+ if (componentType.isArray()) return "[" + readableEmptyArray(componentType) + "]";
+ return "[]";
+ }
- protected static String readableString( Object[] array ) {
- assert array != null;
- if (array.length == 0) return readableEmptyArray(array.getClass());
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- sb.append("[ ");
- for (Object value : array) {
- if (first) {
- first = false;
- } else {
- sb.append(", ");
- }
- sb.append(readableString(value));
- }
- sb.append(" ]");
- return sb.toString();
- }
+ protected static String readableString( Object[] array ) {
+ assert array != null;
+ if (array.length == 0) return readableEmptyArray(array.getClass());
+ StringBuilder sb = new StringBuilder();
+ boolean first = true;
+ sb.append("[ ");
+ for (Object value : array) {
+ if (first) {
+ first = false;
+ } else {
+ sb.append(", ");
+ }
+ sb.append(readableString(value));
+ }
+ sb.append(" ]");
+ return sb.toString();
+ }
- protected static String readableString( int[] array ) {
- assert array != null;
- if (array.length == 0) return readableEmptyArray(array.getClass());
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- sb.append("[ ");
- for (int value : array) {
- if (first) {
- first = false;
- } else {
- sb.append(", ");
- }
- sb.append(readableString(value));
- }
- sb.append(" ]");
- return sb.toString();
- }
+ protected static String readableString( int[] array ) {
+ assert array != null;
+ if (array.length == 0) return readableEmptyArray(array.getClass());
+ StringBuilder sb = new StringBuilder();
+ boolean first = true;
+ sb.append("[ ");
+ for (int value : array) {
+ if (first) {
+ first = false;
+ } else {
+ sb.append(", ");
+ }
+ sb.append(readableString(value));
+ }
+ sb.append(" ]");
+ return sb.toString();
+ }
- protected static String readableString( short[] array ) {
- assert array != null;
- if (array.length == 0) return readableEmptyArray(array.getClass());
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- sb.append("[ ");
- for (short value : array) {
- if (first) {
- first = false;
- } else {
- sb.append(", ");
- }
- sb.append(readableString(value));
- }
- sb.append(" ]");
- return sb.toString();
- }
+ protected static String readableString( short[] array ) {
+ assert array != null;
+ if (array.length == 0) return readableEmptyArray(array.getClass());
+ StringBuilder sb = new StringBuilder();
+ boolean first = true;
+ sb.append("[ ");
+ for (short value : array) {
+ if (first) {
+ first = false;
+ } else {
+ sb.append(", ");
+ }
+ sb.append(readableString(value));
+ }
+ sb.append(" ]");
+ return sb.toString();
+ }
- protected static String readableString( long[] array ) {
- assert array != null;
- if (array.length == 0) return readableEmptyArray(array.getClass());
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- sb.append("[ ");
- for (long value : array) {
- if (first) {
- first = false;
- } else {
- sb.append(", ");
- }
- sb.append(readableString(value));
- }
- sb.append(" ]");
- return sb.toString();
- }
+ protected static String readableString( long[] array ) {
+ assert array != null;
+ if (array.length == 0) return readableEmptyArray(array.getClass());
+ StringBuilder sb = new StringBuilder();
+ boolean first = true;
+ sb.append("[ ");
+ for (long value : array) {
+ if (first) {
+ first = false;
+ } else {
+ sb.append(", ");
+ }
+ sb.append(readableString(value));
+ }
+ sb.append(" ]");
+ return sb.toString();
+ }
- protected static String readableString( boolean[] array ) {
- assert array != null;
- if (array.length == 0) return readableEmptyArray(array.getClass());
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- sb.append("[ ");
- for (boolean value : array) {
- if (first) {
- first = false;
- } else {
- sb.append(", ");
- }
- sb.append(readableString(value));
- }
- sb.append(" ]");
- return sb.toString();
- }
+ protected static String readableString( boolean[] array ) {
+ assert array != null;
+ if (array.length == 0) return readableEmptyArray(array.getClass());
+ StringBuilder sb = new StringBuilder();
+ boolean first = true;
+ sb.append("[ ");
+ for (boolean value : array) {
+ if (first) {
+ first = false;
+ } else {
+ sb.append(", ");
+ }
+ sb.append(readableString(value));
+ }
+ sb.append(" ]");
+ return sb.toString();
+ }
- protected static String readableString( float[] array ) {
- assert array != null;
- if (array.length == 0) return readableEmptyArray(array.getClass());
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- sb.append("[ ");
- for (float value : array) {
- if (first) {
- first = false;
- } else {
- sb.append(", ");
- }
- sb.append(readableString(value));
- }
- sb.append(" ]");
- return sb.toString();
- }
+ protected static String readableString( float[] array ) {
+ assert array != null;
+ if (array.length == 0) return readableEmptyArray(array.getClass());
+ StringBuilder sb = new StringBuilder();
+ boolean first = true;
+ sb.append("[ ");
+ for (float value : array) {
+ if (first) {
+ first = false;
+ } else {
+ sb.append(", ");
+ }
+ sb.append(readableString(value));
+ }
+ sb.append(" ]");
+ return sb.toString();
+ }
- protected static String readableString( double[] array ) {
- assert array != null;
- if (array.length == 0) return readableEmptyArray(array.getClass());
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- sb.append("[ ");
- for (double value : array) {
- if (first) {
- first = false;
- } else {
- sb.append(", ");
- }
- sb.append(readableString(value));
- }
- sb.append(" ]");
- return sb.toString();
- }
+ protected static String readableString( double[] array ) {
+ assert array != null;
+ if (array.length == 0) return readableEmptyArray(array.getClass());
+ StringBuilder sb = new StringBuilder();
+ boolean first = true;
+ sb.append("[ ");
+ for (double value : array) {
+ if (first) {
+ first = false;
+ } else {
+ sb.append(", ");
+ }
+ sb.append(readableString(value));
+ }
+ sb.append(" ]");
+ return sb.toString();
+ }
- protected static String readableString( byte[] array ) {
- assert array != null;
- if (array.length == 0) return readableEmptyArray(array.getClass());
- StringBuilder sb = new StringBuilder();
- sb.append("[ ");
- try {
- sb.append(new String(array, "UTF-8"));
- } catch (UnsupportedEncodingException e) {
- throw new SystemFailureException(e);
- }
- sb.append(" ]");
- return sb.toString();
- }
+ protected static String readableString( byte[] array ) {
+ assert array != null;
+ if (array.length == 0) return readableEmptyArray(array.getClass());
+ StringBuilder sb = new StringBuilder();
+ sb.append("[ ");
+ try {
+ sb.append(new String(array, "UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ throw new SystemFailureException(e);
+ }
+ sb.append(" ]");
+ return sb.toString();
+ }
- protected static String readableString( Collection<?> collection ) {
- assert collection != null;
- if (collection.isEmpty()) return "[]";
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- sb.append("[ ");
- for (Object value : collection) {
- if (first) {
- first = false;
- } else {
- sb.append(", ");
- }
- sb.append(readableString(value));
- }
- sb.append(" ]");
- return sb.toString();
- }
+ protected static String readableString( Collection<?> collection ) {
+ assert collection != null;
+ if (collection.isEmpty()) return "[]";
+ StringBuilder sb = new StringBuilder();
+ boolean first = true;
+ sb.append("[ ");
+ for (Object value : collection) {
+ if (first) {
+ first = false;
+ } else {
+ sb.append(", ");
+ }
+ sb.append(readableString(value));
+ }
+ sb.append(" ]");
+ return sb.toString();
+ }
- protected static String readableString( Map<?, ?> map ) {
- assert map != null;
- if (map.isEmpty()) return "{}";
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- sb.append("{ ");
- for (Map.Entry<?, ?> entry : map.entrySet()) {
- Object key = entry.getKey();
- Object value = entry.getValue();
- if (first) {
- first = false;
- } else {
- sb.append(", ");
- }
- sb.append(readableString(key));
- sb.append(" => ");
- sb.append(readableString(value));
- }
- sb.append(" }");
- return sb.toString();
- }
+ protected static String readableString( Map<?, ?> map ) {
+ assert map != null;
+ if (map.isEmpty()) return "{}";
+ StringBuilder sb = new StringBuilder();
+ boolean first = true;
+ sb.append("{ ");
+ for (Map.Entry<?, ?> entry : map.entrySet()) {
+ Object key = entry.getKey();
+ Object value = entry.getValue();
+ if (first) {
+ first = false;
+ } else {
+ sb.append(", ");
+ }
+ sb.append(readableString(key));
+ sb.append(" => ");
+ sb.append(readableString(value));
+ }
+ sb.append(" }");
+ return sb.toString();
+ }
- /**
- * Get the stack trace of the supplied exception.
- *
- * @param throwable the exception for which the stack trace is to be returned
- * @return the stack trace, or null if the supplied exception is null
- */
- public static String getStackTrace( Throwable throwable ) {
- if (throwable == null) return null;
- final ByteArrayOutputStream bas = new ByteArrayOutputStream();
- final PrintWriter pw = new PrintWriter(bas);
- throwable.printStackTrace(pw);
- pw.close();
- return bas.toString();
- }
+ /**
+ * Get the stack trace of the supplied exception.
+ *
+ * @param throwable the exception for which the stack trace is to be returned
+ * @return the stack trace, or null if the supplied exception is null
+ */
+ public static String getStackTrace( Throwable throwable ) {
+ if (throwable == null) return null;
+ final ByteArrayOutputStream bas = new ByteArrayOutputStream();
+ final PrintWriter pw = new PrintWriter(bas);
+ throwable.printStackTrace(pw);
+ pw.close();
+ return bas.toString();
+ }
- /**
- * Removes leading and trailing whitespace from the supplied text, and reduces other consecutive whitespace characters to a
- * single space. Whitespace includes line-feeds.
- *
- * @param text the text to be normalized
- * @return the normalized text
- */
- public static String normalize( String text ) {
- ArgCheck.isNotNull(text, "text");
- // This could be much more efficient.
- return NORMALIZE_PATTERN.matcher(text).replaceAll(" ").trim();
- }
+ /**
+ * Removes leading and trailing whitespace from the supplied text, and reduces other consecutive whitespace characters to a
+ * single space. Whitespace includes line-feeds.
+ *
+ * @param text the text to be normalized
+ * @return the normalized text
+ */
+ public static String normalize( String text ) {
+ ArgCheck.isNotNull(text, "text");
+ // This could be much more efficient.
+ return NORMALIZE_PATTERN.matcher(text).replaceAll(" ").trim();
+ }
- private StringUtil() {
- // Prevent construction
- }
+ private StringUtil() {
+ // Prevent construction
+ }
}
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/xml/SimpleNamespaceContext.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/xml/SimpleNamespaceContext.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/xml/SimpleNamespaceContext.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -50,7 +50,8 @@
return null;
}
- public SimpleNamespaceContext setNamespace( String prefix, String namespaceUri ) {
+ public SimpleNamespaceContext setNamespace( String prefix,
+ String namespaceUri ) {
this.prefixToNamespace.put(prefix, namespaceUri);
return this;
}
@@ -58,7 +59,7 @@
/**
* {@inheritDoc}
*/
- public Iterator getPrefixes( String namespaceURI ) {
+ public Iterator<String> getPrefixes( String namespaceURI ) {
return this.prefixToNamespace.keySet().iterator();
}
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/AbstractI18nTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/AbstractI18nTest.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/AbstractI18nTest.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -37,9 +37,9 @@
*/
public abstract class AbstractI18nTest {
- private Class i18nClass;
+ private Class<?> i18nClass;
- protected AbstractI18nTest( Class i18nClass ) {
+ protected AbstractI18nTest( Class<?> i18nClass ) {
this.i18nClass = i18nClass;
}
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/component/ComponentLibraryTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/component/ComponentLibraryTest.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/component/ComponentLibraryTest.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -62,7 +62,7 @@
@Test
public void shouldBeInstantiableWithDefaultConstructor() {
- new ComponentLibrary();
+ new ComponentLibrary<SampleComponent, SampleComponentConfig>();
}
@Test
@@ -146,7 +146,7 @@
components = library.getInstances();
assertThat(components.size(), is(2));
assertThat(components.get(0), instanceOf(MockComponentA.class));
- assertThat(components.get(0), is(sameInstance((Component)secondComponentA)));
+ assertThat(components.get(0), is(sameInstance((Component<SampleComponentConfig>)secondComponentA)));
assertThat(components.get(1), instanceOf(MockComponentB.class));
MockComponentB firstComponentB = (MockComponentB)components.get(1);
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/i18n/I18nTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/i18n/I18nTest.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/i18n/I18nTest.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -59,8 +59,8 @@
clearFields(TestI18nNotStaticField.class);
clearFields(TestI18nPrivate.class);
clearFields(TestI18nUnusedProperty.class);
- for (Entry<Locale, Map<Class, Set<String>>> localeToMapEntry : I18n.LOCALE_TO_CLASS_TO_PROBLEMS_MAP.entrySet()) {
- for (Iterator<Entry<Class, Set<String>>> iter = localeToMapEntry.getValue().entrySet().iterator(); iter.hasNext();) {
+ for (Entry<Locale, Map<Class<?>, Set<String>>> localeToMapEntry : I18n.LOCALE_TO_CLASS_TO_PROBLEMS_MAP.entrySet()) {
+ for (Iterator<Entry<Class<?>, Set<String>>> iter = localeToMapEntry.getValue().entrySet().iterator(); iter.hasNext();) {
if (iter.next().getKey() != CommonI18n.class) {
iter.remove();
}
@@ -68,7 +68,7 @@
}
}
- private void clearFields( Class i18nClass ) throws Exception {
+ private void clearFields( Class<?> i18nClass ) throws Exception {
for (Field fld : i18nClass.getDeclaredFields()) {
if (fld.getType() == I18n.class && (fld.getModifiers() & Modifier.PUBLIC) == Modifier.PUBLIC
&& (fld.getModifiers() & Modifier.STATIC) == Modifier.STATIC
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/util/ArgCheckTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/util/ArgCheckTest.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/util/ArgCheckTest.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -259,7 +259,7 @@
@Test( expected = IllegalArgumentException.class )
public void isNotEmptyCollectionShouldThrowExceptionIfGivenNullCollection() {
- ArgCheck.isNotEmpty((Collection)null, "test");
+ ArgCheck.isNotEmpty((Collection<?>)null, "test");
}
@Test( expected = IllegalArgumentException.class )
@@ -274,7 +274,7 @@
@Test( expected = IllegalArgumentException.class )
public void isNotEmptyMapShouldThrowExceptionIfGivenNullMap() {
- ArgCheck.isNotEmpty((Map)null, "test");
+ ArgCheck.isNotEmpty((Map<?, ?>)null, "test");
}
@Test( expected = IllegalArgumentException.class )
@@ -382,7 +382,7 @@
@Test( expected = IllegalArgumentException.class )
public void containsNoNullsCollectionShouldThrowExceptionIfGivenNullCollection() {
- ArgCheck.containsNoNulls((Collection)null, "test");
+ ArgCheck.containsNoNulls((Collection<?>)null, "test");
}
@Test
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/util/LoggerTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/util/LoggerTest.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/util/LoggerTest.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -96,7 +96,7 @@
org.apache.log4j.Logger theLogger = log4jLogger;
while (theLogger != null) {
List<Appender> appenders = new ArrayList<Appender>();
- Enumeration previousAppenders = theLogger.getAllAppenders();
+ Enumeration<?> previousAppenders = theLogger.getAllAppenders();
while (previousAppenders.hasMoreElements()) {
appenders.add((Appender)previousAppenders.nextElement());
}
@@ -436,7 +436,7 @@
*/
public void removeFirst( Logger.Level expectedLevel,
String expectedMessageExpression,
- Class expectedExceptionClass ) {
+ Class<?> expectedExceptionClass ) {
if (!hasEvents()) {
fail("Expected log message but found none: " + expectedLevel + " - " + expectedMessageExpression);
}
Modified: trunk/dna-maven-classloader/src/main/java/org/jboss/dna/maven/MavenRepositoryException.java
===================================================================
--- trunk/dna-maven-classloader/src/main/java/org/jboss/dna/maven/MavenRepositoryException.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-maven-classloader/src/main/java/org/jboss/dna/maven/MavenRepositoryException.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -28,6 +28,10 @@
public class MavenRepositoryException extends RuntimeException {
/**
+ */
+ private static final long serialVersionUID = -9198687929215916061L;
+
+ /**
*
*/
public MavenRepositoryException() {
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepositorySource.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepositorySource.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepositorySource.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -43,6 +43,10 @@
@ThreadSafe
public class FederatedRepositorySource implements RepositorySource {
+ /**
+ */
+ private static final long serialVersionUID = 7587346948013486977L;
+
public static final int DEFAULT_RETRY_LIMIT = 0;
protected static final String USERNAME = "username";
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederationException.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederationException.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederationException.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -29,6 +29,10 @@
public class FederationException extends RuntimeException {
/**
+ */
+ private static final long serialVersionUID = -27536888064529864L;
+
+ /**
*
*/
public FederationException() {
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/InvalidRuleSetException.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/InvalidRuleSetException.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/InvalidRuleSetException.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -27,6 +27,10 @@
public class InvalidRuleSetException extends RuntimeException {
/**
+ */
+ private static final long serialVersionUID = 6739445071678626125L;
+
+ /**
*
*/
public InvalidRuleSetException() {
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/InvalidSequencerPathExpression.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/InvalidSequencerPathExpression.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/InvalidSequencerPathExpression.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -29,6 +29,10 @@
public class InvalidSequencerPathExpression extends RuntimeException {
/**
+ */
+ private static final long serialVersionUID = -2814638971450551156L;
+
+ /**
*
*/
public InvalidSequencerPathExpression() {
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerException.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerException.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerException.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -28,6 +28,10 @@
/**
*/
+ private static final long serialVersionUID = -7610898771539657335L;
+
+ /**
+ */
public SequencerException() {
}
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerPathExpression.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerPathExpression.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerPathExpression.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -53,6 +53,10 @@
public class SequencerPathExpression implements Serializable {
/**
+ */
+ private static final long serialVersionUID = 229464314137494765L;
+
+ /**
* The pattern used to break the initial input string into the two major parts, the selection and output expressions. Group 1
* contains the selection expression, and group 2 contains the output expression.
*/
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/InvalidPathException.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/InvalidPathException.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/InvalidPathException.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -27,6 +27,10 @@
public class InvalidPathException extends RuntimeException {
/**
+ */
+ private static final long serialVersionUID = 6034512896518552227L;
+
+ /**
*
*/
public InvalidPathException() {
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/IoException.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/IoException.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/IoException.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -28,6 +28,10 @@
public class IoException extends RuntimeException {
/**
+ */
+ private static final long serialVersionUID = -2015526722307950714L;
+
+ /**
*
*/
public IoException() {
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/NamespaceException.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/NamespaceException.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/NamespaceException.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -27,6 +27,10 @@
public class NamespaceException extends RuntimeException {
/**
+ */
+ private static final long serialVersionUID = 1300642242538881207L;
+
+ /**
*
*/
public NamespaceException() {
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PathNotFoundException.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PathNotFoundException.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PathNotFoundException.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -27,6 +27,10 @@
public class PathNotFoundException extends RuntimeException {
/**
+ */
+ private static final long serialVersionUID = -3703984046286975978L;
+
+ /**
*
*/
public PathNotFoundException() {
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PropertyType.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PropertyType.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PropertyType.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -49,18 +49,18 @@
OBJECT("Object", ValueComparators.OBJECT_COMPARATOR, Object.class);
private final String name;
- private final Comparator comparator;
- private final Class valueClass;
+ private final Comparator<?> comparator;
+ private final Class<?> valueClass;
private PropertyType( String name,
- Comparator comparator,
- Class valueClass ) {
+ Comparator<?> comparator,
+ Class<?> valueClass ) {
this.name = name;
this.comparator = comparator;
this.valueClass = valueClass;
}
- public Class getValueClass() {
+ public Class<?> getValueClass() {
return this.valueClass;
}
@@ -68,7 +68,7 @@
return this.name;
}
- public Comparator getComparator() {
+ public Comparator<?> getComparator() {
return this.comparator;
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueComparators.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueComparators.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueComparators.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -41,7 +41,8 @@
*/
public static final Comparator<String> STRING_COMPARATOR = new Comparator<String>() {
- public int compare( String o1, String o2 ) {
+ public int compare( String o1,
+ String o2 ) {
if (o1 == o2) return 0;
if (o1 == null) return -1;
if (o2 == null) return 1;
@@ -53,7 +54,8 @@
*/
public static final Comparator<Long> LONG_COMPARATOR = new Comparator<Long>() {
- public int compare( Long o1, Long o2 ) {
+ public int compare( Long o1,
+ Long o2 ) {
if (o1 == o2) return 0;
if (o1 == null) return -1;
if (o2 == null) return 1;
@@ -65,7 +67,8 @@
*/
public static final Comparator<Double> DOUBLE_COMPARATOR = new Comparator<Double>() {
- public int compare( Double o1, Double o2 ) {
+ public int compare( Double o1,
+ Double o2 ) {
if (o1 == o2) return 0;
if (o1 == null) return -1;
if (o2 == null) return 1;
@@ -77,7 +80,8 @@
*/
public static final Comparator<BigDecimal> DECIMAL_COMPARATOR = new Comparator<BigDecimal>() {
- public int compare( BigDecimal o1, BigDecimal o2 ) {
+ public int compare( BigDecimal o1,
+ BigDecimal o2 ) {
if (o1 == o2) return 0;
if (o1 == null) return -1;
if (o2 == null) return 1;
@@ -91,7 +95,8 @@
*/
public static final Comparator<Binary> BINARY_COMPARATOR = new Comparator<Binary>() {
- public int compare( Binary o1, Binary o2 ) {
+ public int compare( Binary o1,
+ Binary o2 ) {
if (o1 == o2) return 0;
if (o1 == null) return -1;
if (o2 == null) return 1;
@@ -155,7 +160,8 @@
*/
public static final Comparator<Boolean> BOOLEAN_COMPARATOR = new Comparator<Boolean>() {
- public int compare( Boolean o1, Boolean o2 ) {
+ public int compare( Boolean o1,
+ Boolean o2 ) {
if (o1 == o2) return 0;
if (o1 == null) return -1;
if (o2 == null) return 1;
@@ -167,7 +173,8 @@
*/
public static final Comparator<DateTime> DATE_TIME_COMPARATOR = new Comparator<DateTime>() {
- public int compare( DateTime o1, DateTime o2 ) {
+ public int compare( DateTime o1,
+ DateTime o2 ) {
if (o1 == o2) return 0;
if (o1 == null) return -1;
if (o2 == null) return 1;
@@ -179,7 +186,8 @@
*/
public static final Comparator<Date> DATE_COMPARATOR = new Comparator<Date>() {
- public int compare( Date o1, Date o2 ) {
+ public int compare( Date o1,
+ Date o2 ) {
if (o1 == o2) return 0;
if (o1 == null) return -1;
if (o2 == null) return 1;
@@ -191,7 +199,8 @@
*/
public static final Comparator<Calendar> CALENDAR_COMPARATOR = new Comparator<Calendar>() {
- public int compare( Calendar o1, Calendar o2 ) {
+ public int compare( Calendar o1,
+ Calendar o2 ) {
if (o1 == o2) return 0;
if (o1 == null) return -1;
if (o2 == null) return 1;
@@ -203,7 +212,8 @@
*/
public static final Comparator<Name> NAME_COMPARATOR = new Comparator<Name>() {
- public int compare( Name o1, Name o2 ) {
+ public int compare( Name o1,
+ Name o2 ) {
if (o1 == o2) return 0;
if (o1 == null) return -1;
if (o2 == null) return 1;
@@ -215,7 +225,8 @@
*/
public static final Comparator<Path> PATH_COMPARATOR = new Comparator<Path>() {
- public int compare( Path o1, Path o2 ) {
+ public int compare( Path o1,
+ Path o2 ) {
if (o1 == o2) return 0;
if (o1 == null) return -1;
if (o2 == null) return 1;
@@ -227,7 +238,8 @@
*/
public static final Comparator<URI> URI_COMPARATOR = new Comparator<URI>() {
- public int compare( URI o1, URI o2 ) {
+ public int compare( URI o1,
+ URI o2 ) {
if (o1 == o2) return 0;
if (o1 == null) return -1;
if (o2 == null) return 1;
@@ -239,7 +251,8 @@
*/
public static final Comparator<Reference> REFERENCE_COMPARATOR = new Comparator<Reference>() {
- public int compare( Reference o1, Reference o2 ) {
+ public int compare( Reference o1,
+ Reference o2 ) {
if (o1 == o2) return 0;
if (o1 == null) return -1;
if (o2 == null) return 1;
@@ -252,21 +265,22 @@
public static final Comparator<Object> OBJECT_COMPARATOR = new Comparator<Object>() {
@SuppressWarnings( "unchecked" )
- public int compare( Object o1, Object o2 ) {
+ public int compare( Object o1,
+ Object o2 ) {
if (o1 == o2) return 0;
if (o1 == null) return -1;
if (o2 == null) return 1;
PropertyType type1 = PropertyType.discoverType(o1);
PropertyType type2 = PropertyType.discoverType(o2);
if (type1 != PropertyType.OBJECT && type2 != PropertyType.OBJECT) {
- if (type1 == type2) return type1.getComparator().compare(o1, o2);
+ if (type1 == type2) return ((Comparator<Object>)type1.getComparator()).compare(o1, o2);
// The types are different but the classes are the same ...
if (type1.getDeclaringClass().isAssignableFrom(type2.getDeclaringClass())) {
- return type1.getComparator().compare(o1, o2);
+ return ((Comparator<Object>)type1.getComparator()).compare(o1, o2);
}
if (type2.getDeclaringClass().isAssignableFrom(type1.getDeclaringClass())) {
- return type2.getComparator().compare(o1, o2);
+ return ((Comparator<Object>)type2.getComparator()).compare(o1, o2);
}
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicCreateNodeCommand.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicCreateNodeCommand.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicCreateNodeCommand.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -34,6 +34,9 @@
@NotThreadSafe
public class BasicCreateNodeCommand extends BasicGraphCommand implements CreateNodeCommand {
+ /**
+ */
+ private static final long serialVersionUID = -5452285887178397354L;
private final Path path;
private final List<Property> properties;
private CachePolicy cachePolicy;
@@ -43,7 +46,8 @@
* @param path the path to the node; may not be null
* @param properties the properties of the node; may not be null
*/
- public BasicCreateNodeCommand( Path path, List<Property> properties ) {
+ public BasicCreateNodeCommand( Path path,
+ List<Property> properties ) {
super();
assert path != null;
assert properties != null;
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetChildrenCommand.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetChildrenCommand.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetChildrenCommand.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -37,6 +37,9 @@
@NotThreadSafe
public class BasicGetChildrenCommand extends BasicGraphCommand implements GetChildrenCommand {
+ /**
+ */
+ private static final long serialVersionUID = -8515194602506918337L;
private List<Segment> children;
private final Path path;
private CachePolicy cachePolicy;
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetNodeCommand.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetNodeCommand.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetNodeCommand.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -38,6 +38,9 @@
@NotThreadSafe
public class BasicGetNodeCommand extends BasicGetPropertiesCommand implements GetNodeCommand {
+ /**
+ */
+ private static final long serialVersionUID = 5355669032301356873L;
private List<Segment> children;
/**
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetPropertiesCommand.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetPropertiesCommand.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetPropertiesCommand.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -37,6 +37,9 @@
@NotThreadSafe
public class BasicGetPropertiesCommand extends BasicGraphCommand implements GetPropertiesCommand {
+ /**
+ */
+ private static final long serialVersionUID = -7816393217506909521L;
private final Map<Name, List<Object>> propertyValues = new HashMap<Name, List<Object>>();
private final Path path;
private CachePolicy cachePolicy;
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicSetPropertiesCommand.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicSetPropertiesCommand.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicSetPropertiesCommand.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -34,6 +34,9 @@
@NotThreadSafe
public class BasicSetPropertiesCommand extends BasicGraphCommand implements SetPropertiesCommand {
+ /**
+ */
+ private static final long serialVersionUID = -2693642411179501304L;
private final Path path;
private final List<Property> properties;
private CachePolicy cachePolicy;
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositorySourceException.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositorySourceException.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositorySourceException.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -26,6 +26,9 @@
*/
public class RepositorySourceException extends RuntimeException {
+ /**
+ */
+ private static final long serialVersionUID = -7704170453962924565L;
private final String sourceName;
/**
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicName.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicName.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicName.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -38,7 +38,10 @@
@Immutable
public class BasicName implements Name {
- private final String namespaceUri;
+ /**
+ */
+ private static final long serialVersionUID = -1737537720336990144L;
+ private final String namespaceUri;
private final String localName;
private final int hc;
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPath.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPath.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPath.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -46,8 +46,12 @@
@Immutable
public class BasicPath implements Path {
- private static final List<Segment> EMPTY_SEGMENTS = Collections.emptyList();
+ /**
+ */
+ private static final long serialVersionUID = 8488295345524209746L;
+ private static final List<Segment> EMPTY_SEGMENTS = Collections.emptyList();
+
public static final Path ROOT = new BasicPath(EMPTY_SEGMENTS, true);
protected static final Path SELF_PATH = new BasicPath(Collections.singletonList(Path.SELF_SEGMENT), false);
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPathSegment.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPathSegment.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPathSegment.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -35,6 +35,9 @@
@Immutable
public class BasicPathSegment implements Path.Segment {
+ /**
+ */
+ private static final long serialVersionUID = 4367349287846075157L;
private final Name name;
private final int index;
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinary.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinary.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinary.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -35,6 +35,10 @@
@Immutable
public class InMemoryBinary implements Binary {
+ /**
+ */
+ private static final long serialVersionUID = 8792863149767123559L;
+
protected static final byte[] EMPTY_CONTENT = new byte[0];
private final byte[] bytes;
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTime.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTime.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTime.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -38,6 +38,10 @@
@Immutable
public class JodaDateTime implements org.jboss.dna.spi.graph.DateTime {
+ /**
+ */
+ private static final long serialVersionUID = -730188225988292422L;
+
private static final int MILLIS_IN_HOUR = 1000 * 60 * 60;
private final DateTime instance;
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReference.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReference.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReference.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -33,6 +33,9 @@
@Immutable
public class UuidReference implements Reference {
+ /**
+ */
+ private static final long serialVersionUID = 2299467578161645109L;
private UUID uuid;
public UuidReference( UUID uuid ) {
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -41,6 +41,9 @@
@ThreadSafe
public class TimeDelayingRepositorySource implements RepositorySource {
+ /**
+ */
+ private static final long serialVersionUID = -2756725117087437347L;
private final String identifier;
private final AtomicInteger retryLimit = new AtomicInteger(0);
private final AtomicInteger connectionsOpenedCount = new AtomicInteger(0);
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java 2008-06-11 19:21:19 UTC (rev 272)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java 2008-06-12 17:36:18 UTC (rev 273)
@@ -128,7 +128,7 @@
}
}
- private AbstractValueFactory factory;
+ private AbstractValueFactory<?> factory;
@Before
public void beforeEach() {
17 years, 6 months
DNA SVN: r272 - in trunk: sequencers/dna-sequencer-esbMessage and 1 other directory.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2008-06-11 15:21:19 -0400 (Wed, 11 Jun 2008)
New Revision: 272
Modified:
trunk/pom.xml
trunk/sequencers/dna-sequencer-esbMessage/
trunk/sequencers/dna-sequencer-esbMessage/.project
Log:
Fixed some minor problems with the Eclipse project, and temporarily removed the ESB seqeuncer from the parent POM until dependencies are resolved in the JBoss Maven repository
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2008-06-11 16:32:25 UTC (rev 271)
+++ trunk/pom.xml 2008-06-11 19:21:19 UTC (rev 272)
@@ -61,7 +61,7 @@
<module>dna-maven-classloader</module>
<module>sequencers/dna-sequencer-images</module>
<module>sequencers/dna-sequencer-mp3</module>
- <module>sequencers/dna-sequencer-esbMessage</module>
+ <!--module>sequencers/dna-sequencer-esbMessage</module-->
<module>connectors/dna-connector-jbosscache</module>
<module>dna-integration-tests</module>
</modules>
Property changes on: trunk/sequencers/dna-sequencer-esbMessage
___________________________________________________________________
Name: svn:ignore
+ target
Modified: trunk/sequencers/dna-sequencer-esbMessage/.project
===================================================================
--- trunk/sequencers/dna-sequencer-esbMessage/.project 2008-06-11 16:32:25 UTC (rev 271)
+++ trunk/sequencers/dna-sequencer-esbMessage/.project 2008-06-11 19:21:19 UTC (rev 272)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>dna-sequencer-mp3</name>
+ <name>dna-sequencer-esbMessage</name>
<comment></comment>
<projects>
</projects>
17 years, 6 months
DNA SVN: r271 - branches.
by dna-commits@lists.jboss.org
Author: maeste
Date: 2008-06-11 12:32:25 -0400 (Wed, 11 Jun 2008)
New Revision: 271
Removed:
branches/maeste/
Log:
Removing my personal branch used for DNA-78. Changes already merged back on branch at revision 270
17 years, 6 months
DNA SVN: r270 - in trunk: dna-repository and 11 other directories.
by dna-commits@lists.jboss.org
Author: maeste
Date: 2008-06-11 12:27:26 -0400 (Wed, 11 Jun 2008)
New Revision: 270
Added:
trunk/sequencers/dna-sequencer-esbMessage/
trunk/sequencers/dna-sequencer-esbMessage/.classpath
trunk/sequencers/dna-sequencer-esbMessage/.project
trunk/sequencers/dna-sequencer-esbMessage/pom.xml
trunk/sequencers/dna-sequencer-esbMessage/src/
trunk/sequencers/dna-sequencer-esbMessage/src/main/
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencerI18n.java
trunk/sequencers/dna-sequencer-esbMessage/src/main/resources/
trunk/sequencers/dna-sequencer-esbMessage/src/test/
trunk/sequencers/dna-sequencer-esbMessage/src/test/java/
trunk/sequencers/dna-sequencer-esbMessage/src/test/resources/
Removed:
trunk/sequencers/dna-sequencer-esbMessage/.classpath
trunk/sequencers/dna-sequencer-esbMessage/.project
trunk/sequencers/dna-sequencer-esbMessage/pom.xml
trunk/sequencers/dna-sequencer-esbMessage/src/
trunk/sequencers/dna-sequencer-esbMessage/src/main/
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java
trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencerI18n.java
trunk/sequencers/dna-sequencer-esbMessage/src/main/resources/
trunk/sequencers/dna-sequencer-esbMessage/src/test/
trunk/sequencers/dna-sequencer-esbMessage/src/test/java/
trunk/sequencers/dna-sequencer-esbMessage/src/test/resources/
Modified:
trunk/dna-repository/pom.xml
trunk/pom.xml
Log:
merged on trunk [DNA-78]
Modified: trunk/dna-repository/pom.xml
===================================================================
--- trunk/dna-repository/pom.xml 2008-06-11 16:13:44 UTC (rev 269)
+++ trunk/dna-repository/pom.xml 2008-06-11 16:27:26 UTC (rev 270)
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jboss.dna</groupId>
@@ -70,6 +71,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
+ <version>1.3</version>
<scope>test</scope>
</dependency>
<!--
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2008-06-11 16:13:44 UTC (rev 269)
+++ trunk/pom.xml 2008-06-11 16:27:26 UTC (rev 270)
@@ -61,6 +61,7 @@
<module>dna-maven-classloader</module>
<module>sequencers/dna-sequencer-images</module>
<module>sequencers/dna-sequencer-mp3</module>
+ <module>sequencers/dna-sequencer-esbMessage</module>
<module>connectors/dna-connector-jbosscache</module>
<module>dna-integration-tests</module>
</modules>
Copied: trunk/sequencers/dna-sequencer-esbMessage (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage)
Deleted: trunk/sequencers/dna-sequencer-esbMessage/.classpath
===================================================================
--- branches/maeste/sequencers/dna-sequencer-esbMessage/.classpath 2008-06-11 16:13:44 UTC (rev 269)
+++ trunk/sequencers/dna-sequencer-esbMessage/.classpath 2008-06-11 16:27:26 UTC (rev 270)
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/main/resources"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
Copied: trunk/sequencers/dna-sequencer-esbMessage/.classpath (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/.classpath)
===================================================================
--- trunk/sequencers/dna-sequencer-esbMessage/.classpath (rev 0)
+++ trunk/sequencers/dna-sequencer-esbMessage/.classpath 2008-06-11 16:27:26 UTC (rev 270)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Deleted: trunk/sequencers/dna-sequencer-esbMessage/.project
===================================================================
--- branches/maeste/sequencers/dna-sequencer-esbMessage/.project 2008-06-11 16:13:44 UTC (rev 269)
+++ trunk/sequencers/dna-sequencer-esbMessage/.project 2008-06-11 16:27:26 UTC (rev 270)
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>dna-sequencer-mp3</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.maven.ide.eclipse.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.maven.ide.eclipse.maven2Nature</nature>
- </natures>
-</projectDescription>
Copied: trunk/sequencers/dna-sequencer-esbMessage/.project (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/.project)
===================================================================
--- trunk/sequencers/dna-sequencer-esbMessage/.project (rev 0)
+++ trunk/sequencers/dna-sequencer-esbMessage/.project 2008-06-11 16:27:26 UTC (rev 270)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>dna-sequencer-mp3</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
Deleted: trunk/sequencers/dna-sequencer-esbMessage/pom.xml
===================================================================
--- branches/maeste/sequencers/dna-sequencer-esbMessage/pom.xml 2008-06-11 16:13:44 UTC (rev 269)
+++ trunk/sequencers/dna-sequencer-esbMessage/pom.xml 2008-06-11 16:27:26 UTC (rev 270)
@@ -1,35 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>dna</artifactId>
- <groupId>org.jboss.dna</groupId>
- <version>0.2-SNAPSHOT</version>
- <relativePath>../..</relativePath>
- </parent>
- <!-- The groupId and version values are inherited from parent -->
- <artifactId>dna-sequencer-esbMessage</artifactId>
- <packaging>jar</packaging>
- <name>JBoss DNA ESB Message Sequencer</name>
- <description>JBoss DNA Sequencer that processes ESB Message</description>
- <url>http://labs.jboss.org/dna</url>
- <dependencies>
- <dependency>
- <groupId>org.jboss.dna</groupId>
- <artifactId>dna-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.dna</groupId>
- <artifactId>dna-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit-dep</artifactId>
- <version>4.4</version>
- </dependency>
- <dependency>
- <groupId>jbossesb-rosetta.jar</groupId>
- <artifactId>jbossesb-rosetta-dep</artifactId>
- <version>4.3</version>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
Copied: trunk/sequencers/dna-sequencer-esbMessage/pom.xml (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/pom.xml)
===================================================================
--- trunk/sequencers/dna-sequencer-esbMessage/pom.xml (rev 0)
+++ trunk/sequencers/dna-sequencer-esbMessage/pom.xml 2008-06-11 16:27:26 UTC (rev 270)
@@ -0,0 +1,35 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>dna</artifactId>
+ <groupId>org.jboss.dna</groupId>
+ <version>0.2-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+ <!-- The groupId and version values are inherited from parent -->
+ <artifactId>dna-sequencer-esbMessage</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss DNA ESB Message Sequencer</name>
+ <description>JBoss DNA Sequencer that processes ESB Message</description>
+ <url>http://labs.jboss.org/dna</url>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit-dep</artifactId>
+ <version>4.4</version>
+ </dependency>
+ <dependency>
+ <groupId>jbossesb-rosetta.jar</groupId>
+ <artifactId>jbossesb-rosetta-dep</artifactId>
+ <version>4.3</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Copied: trunk/sequencers/dna-sequencer-esbMessage/src (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/src)
Copied: trunk/sequencers/dna-sequencer-esbMessage/src/main (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/src/main)
Copied: trunk/sequencers/dna-sequencer-esbMessage/src/main/java (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java)
Copied: trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org)
Copied: trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss)
Copied: trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna)
Copied: trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer)
Copied: trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage)
Deleted: trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java
===================================================================
--- branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java 2008-06-11 16:13:44 UTC (rev 269)
+++ trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java 2008-06-11 16:27:26 UTC (rev 270)
@@ -1,192 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.sequencer.esbMessage;
-
-import java.io.InputStream;
-import java.io.Serializable;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-import org.jboss.dna.common.monitor.ProgressMonitor;
-import org.jboss.dna.common.util.StringUtil;
-import org.jboss.internal.soa.esb.util.Encoding;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.util.Util;
-
-/**
- * Utility for extracting metadata from MP3 files.
- *
- * @author Stefano Maestri
- */
-public class ESBMessageMetaData {
-
- private URI messageType;
- private EPR to = null;
- private EPR from = null;
- private EPR faultTo = null;
- private EPR replyTo = null;
- private URI relatesTo = null;
- private URI action = null;
- private URI messageID = null;
- private Map<String, Object> bodyMap = null;
- private Map<String, Object> propertiesMap = null;
- private Map<String, Object> attachmentsMap = null;
- private URI faultCode = null;
- private String faultReason;
- private Throwable faultCause;
-
- private ESBMessageMetaData() {
-
- }
-
- public static ESBMessageMetaData instance( InputStream stream,
- ProgressMonitor progressMonitor ) {
-
- ESBMessageMetaData me = null;
- Message message = null;
- progressMonitor.beginTask(10, ESBMessageSequencerI18n.sequencerTaskName);
- try {
- me = new ESBMessageMetaData();
- message = Util.deserialize((Serializable)Encoding.decodeToObject(StringUtil.read(stream)));
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- progressMonitor.worked(2);
- if (progressMonitor.isCancelled()) return null;
-
- me.messageType = message.getType();
- // Context not yet implemented in JBossESB
- // message.getContext();
-
- me.to = message.getHeader().getCall().getTo();
- me.from = message.getHeader().getCall().getFrom();
- me.faultTo = message.getHeader().getCall().getFaultTo();
- me.replyTo = message.getHeader().getCall().getReplyTo();
- me.relatesTo = message.getHeader().getCall().getRelatesTo();
- me.action = message.getHeader().getCall().getAction();
- me.messageID = message.getHeader().getCall().getMessageID();
- progressMonitor.worked(1);
- if (progressMonitor.isCancelled()) return null;
-
- if (message.getBody().getNames().length != 0) {
- me.bodyMap = new HashMap<String, Object>();
- ProgressMonitor subtask = progressMonitor.createSubtask(2);
- subtask.beginTask(message.getBody().getNames().length, ESBMessageSequencerI18n.sequencerTaskName);
- for (String name : message.getBody().getNames()) {
- me.bodyMap.put(name, message.getBody().get(name));
- subtask.worked(1);
- if (progressMonitor.isCancelled()) return null;
- }
- subtask.done();
- }
-
- if (message.getProperties().getNames().length != 0) {
- me.propertiesMap = new HashMap<String, Object>();
- ProgressMonitor subtask = progressMonitor.createSubtask(2);
- subtask.beginTask(message.getProperties().getNames().length, ESBMessageSequencerI18n.sequencerTaskName);
- for (String name : message.getProperties().getNames()) {
- me.propertiesMap.put(name, message.getProperties().getProperty(name));
- subtask.worked(1);
- if (progressMonitor.isCancelled()) return null;
- }
- subtask.done();
- }
-
- if (message.getAttachment().getNames().length != 0) {
- me.attachmentsMap = new HashMap<String, Object>();
- ProgressMonitor subtask = progressMonitor.createSubtask(2);
- subtask.beginTask(message.getAttachment().getNames().length, ESBMessageSequencerI18n.sequencerTaskName);
- for (String name : message.getAttachment().getNames()) {
- me.attachmentsMap.put(name, message.getAttachment().get(name));
- subtask.worked(1);
- if (progressMonitor.isCancelled()) return null;
- }
- subtask.done();
- }
-
- me.faultCause = message.getFault().getCause();
- me.faultCode = message.getFault().getCode();
- me.faultReason = message.getFault().getReason();
- // do last unit of work implicit in done
- progressMonitor.done();
- return me;
-
- }
-
- public URI getMessageType() {
- return messageType;
- }
-
- public EPR getTo() {
- return to;
- }
-
- public EPR getFrom() {
- return from;
- }
-
- public EPR getFaultTo() {
- return faultTo;
- }
-
- public EPR getReplyTo() {
- return replyTo;
- }
-
- public URI getRelatesTo() {
- return relatesTo;
- }
-
- public URI getAction() {
- return action;
- }
-
- public URI getMessageID() {
- return messageID;
- }
-
- public Map<String, Object> getBodyMap() {
- return bodyMap;
- }
-
- public Map<String, Object> getPropertiesMap() {
- return propertiesMap;
- }
-
- public Map<String, Object> getAttachmentsMap() {
- return attachmentsMap;
- }
-
- public URI getFaultCode() {
- return faultCode;
- }
-
- public String getFaultReason() {
- return faultReason;
- }
-
- public Throwable getFaultCause() {
- return faultCause;
- }
-}
Copied: trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java)
===================================================================
--- trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java (rev 0)
+++ trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java 2008-06-11 16:27:26 UTC (rev 270)
@@ -0,0 +1,192 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.esbMessage;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+import org.jboss.dna.common.monitor.ProgressMonitor;
+import org.jboss.dna.common.util.StringUtil;
+import org.jboss.internal.soa.esb.util.Encoding;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.util.Util;
+
+/**
+ * Utility for extracting metadata from MP3 files.
+ *
+ * @author Stefano Maestri
+ */
+public class ESBMessageMetaData {
+
+ private URI messageType;
+ private EPR to = null;
+ private EPR from = null;
+ private EPR faultTo = null;
+ private EPR replyTo = null;
+ private URI relatesTo = null;
+ private URI action = null;
+ private URI messageID = null;
+ private Map<String, Object> bodyMap = null;
+ private Map<String, Object> propertiesMap = null;
+ private Map<String, Object> attachmentsMap = null;
+ private URI faultCode = null;
+ private String faultReason;
+ private Throwable faultCause;
+
+ private ESBMessageMetaData() {
+
+ }
+
+ public static ESBMessageMetaData instance( InputStream stream,
+ ProgressMonitor progressMonitor ) {
+
+ ESBMessageMetaData me = null;
+ Message message = null;
+ progressMonitor.beginTask(10, ESBMessageSequencerI18n.sequencerTaskName);
+ try {
+ me = new ESBMessageMetaData();
+ message = Util.deserialize((Serializable)Encoding.decodeToObject(StringUtil.read(stream)));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ progressMonitor.worked(2);
+ if (progressMonitor.isCancelled()) return null;
+
+ me.messageType = message.getType();
+ // Context not yet implemented in JBossESB
+ // message.getContext();
+
+ me.to = message.getHeader().getCall().getTo();
+ me.from = message.getHeader().getCall().getFrom();
+ me.faultTo = message.getHeader().getCall().getFaultTo();
+ me.replyTo = message.getHeader().getCall().getReplyTo();
+ me.relatesTo = message.getHeader().getCall().getRelatesTo();
+ me.action = message.getHeader().getCall().getAction();
+ me.messageID = message.getHeader().getCall().getMessageID();
+ progressMonitor.worked(1);
+ if (progressMonitor.isCancelled()) return null;
+
+ if (message.getBody().getNames().length != 0) {
+ me.bodyMap = new HashMap<String, Object>();
+ ProgressMonitor subtask = progressMonitor.createSubtask(2);
+ subtask.beginTask(message.getBody().getNames().length, ESBMessageSequencerI18n.sequencerTaskName);
+ for (String name : message.getBody().getNames()) {
+ me.bodyMap.put(name, message.getBody().get(name));
+ subtask.worked(1);
+ if (progressMonitor.isCancelled()) return null;
+ }
+ subtask.done();
+ }
+
+ if (message.getProperties().getNames().length != 0) {
+ me.propertiesMap = new HashMap<String, Object>();
+ ProgressMonitor subtask = progressMonitor.createSubtask(2);
+ subtask.beginTask(message.getProperties().getNames().length, ESBMessageSequencerI18n.sequencerTaskName);
+ for (String name : message.getProperties().getNames()) {
+ me.propertiesMap.put(name, message.getProperties().getProperty(name));
+ subtask.worked(1);
+ if (progressMonitor.isCancelled()) return null;
+ }
+ subtask.done();
+ }
+
+ if (message.getAttachment().getNames().length != 0) {
+ me.attachmentsMap = new HashMap<String, Object>();
+ ProgressMonitor subtask = progressMonitor.createSubtask(2);
+ subtask.beginTask(message.getAttachment().getNames().length, ESBMessageSequencerI18n.sequencerTaskName);
+ for (String name : message.getAttachment().getNames()) {
+ me.attachmentsMap.put(name, message.getAttachment().get(name));
+ subtask.worked(1);
+ if (progressMonitor.isCancelled()) return null;
+ }
+ subtask.done();
+ }
+
+ me.faultCause = message.getFault().getCause();
+ me.faultCode = message.getFault().getCode();
+ me.faultReason = message.getFault().getReason();
+ // do last unit of work implicit in done
+ progressMonitor.done();
+ return me;
+
+ }
+
+ public URI getMessageType() {
+ return messageType;
+ }
+
+ public EPR getTo() {
+ return to;
+ }
+
+ public EPR getFrom() {
+ return from;
+ }
+
+ public EPR getFaultTo() {
+ return faultTo;
+ }
+
+ public EPR getReplyTo() {
+ return replyTo;
+ }
+
+ public URI getRelatesTo() {
+ return relatesTo;
+ }
+
+ public URI getAction() {
+ return action;
+ }
+
+ public URI getMessageID() {
+ return messageID;
+ }
+
+ public Map<String, Object> getBodyMap() {
+ return bodyMap;
+ }
+
+ public Map<String, Object> getPropertiesMap() {
+ return propertiesMap;
+ }
+
+ public Map<String, Object> getAttachmentsMap() {
+ return attachmentsMap;
+ }
+
+ public URI getFaultCode() {
+ return faultCode;
+ }
+
+ public String getFaultReason() {
+ return faultReason;
+ }
+
+ public Throwable getFaultCause() {
+ return faultCause;
+ }
+}
Deleted: trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java
===================================================================
--- branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java 2008-06-11 16:13:44 UTC (rev 269)
+++ trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java 2008-06-11 16:27:26 UTC (rev 270)
@@ -1,148 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.sequencer.esbMessage;
-
-import java.io.InputStream;
-import java.util.Map.Entry;
-import org.jboss.dna.common.monitor.ProgressMonitor;
-import org.jboss.dna.spi.graph.NameFactory;
-import org.jboss.dna.spi.graph.Path;
-import org.jboss.dna.spi.graph.PathFactory;
-import org.jboss.dna.spi.sequencers.SequencerOutput;
-import org.jboss.dna.spi.sequencers.StreamSequencer;
-
-/**
- * A sequencer that processes the binary content of an ESB Message, extracts the metadata for the message, and then writes this
- * metadata to the repository.
- * <p>
- * This sequencer produces data that corresponds to the following structure:
- * <ul>
- * <li><strong>esbMessage:metadata</strong> node of type <code>esbMessage:metadata</code>
- * <ul>
- * <li><strong>esbMessage:to</strong> - optional property for the destination EPR of the message</li>
- * <li><strong>esbMessage:from</strong> - optional property for the source EPR of the message</li>
- * <li><strong>esbMessage:replyTo</strong> - optional property for the reply destination EPR</li>
- * <li><strong>esbMessage:relatesTo</strong> - optional property for the relatesTo URI</li>
- * <li><strong>esbMessage:action</strong> - optional property specifying the action URI</li>
- * <li><strong>esbMessage:messageID</strong> - optional property specifying the messageID URI</li>
- * <li><strong>esbMessage:body</strong> - optional node specifying the message body. It contains a set of properties
- * representing Object contained in body. Properties names reflect object names used in message body</li>
- * <li><strong>esbMessage:properties</strong> - optional node specifying the message properties. It contains a set of properties
- * representing Object contained in message properties. Properties names reflect object names used in message properties</li>
- * <li><strong>esbMessage:attachments</strong> - optional node specifying the message attachments. It contains a set of
- * properties representing Object contained in message attachments. Properties names reflect object names used in message
- * attachments</li>
- * <li><strong>esbMessage:faultCode</strong> - optional property specifying the message fault code. As defined in ESB message
- * it's an URI</li>
- * <li><strong>esbMessage:faultReason</strong> - optional property containing a String describing the fault in a human readable
- * form</li>
- * <li><strong>esbMessage:faultCause</strong> - optional property specifying the Throwable Cause of the fault.</li>
- * </ul>
- * </li>
- * </ul>
- * </p>
- *
- * @author Stefano Maestri
- */
-public class ESBMessageSequencer implements StreamSequencer {
-
- public static final String METADATA_NODE = "esbMessage:metadata";
- public static final String ESB_MESSAGE_PRIMARY_TYPE = "jcr:primaryType";
- public static final String ESB_MESSAGE_TO = "esbMessage:to";
- public static final String ESB_MESSAGE_FROM = "esbMessage:from";
- public static final String ESB_MESSAGE_REPLY_TO = "esbMessage:replyTo";
- public static final String ESB_MESSAGE_RELATES_TO = "esbMessage:relatesTo";
- public static final String ESB_MESSAGE_ACTION = "esbMessage:action";
- public static final String ESB_MESSAGE_MESSAGE_ID = "esbMessage:messageID";
- public static final String ESB_MESSAGE_MESSAGE_TYPE = "esbMessage:messageType";
- public static final String ESB_MESSAGE_BODY = "esbMessage:metadata/esbMessage:body";
- public static final String ESB_MESSAGE_PROPERTIES = "esbMessage:metadata/esbMessage:properties";
- public static final String ESB_MESSAGE_ATTACHMENTS = "esbMessage:metadata/esbMessage:attachments";
- public static final String ESB_MESSAGE_FAULT_CODE = "esbMessage:faultCode";
- public static final String ESB_MESSAGE_FAULT_REASON = "esbMessage:faultReason";
- public static final String ESB_MESSAGE_FAULT_CAUSE = "esbMessage:faultCause";
-
- public static final String ESB_MESSAGE_NAMESPACE = "esbMessage";
-
- public void sequence( InputStream stream,
- SequencerOutput output,
- ProgressMonitor progressMonitor ) {
-
- progressMonitor.beginTask(20, ESBMessageSequencerI18n.sequencerTaskName);
- ESBMessageMetaData metadata = ESBMessageMetaData.instance(stream, progressMonitor.createSubtask(10));
- if (progressMonitor.isCancelled()) return;
-
- if (metadata != null) {
- NameFactory nameFactory = output.getFactories().getNameFactory();
- PathFactory pathFactory = output.getFactories().getPathFactory();
- Path metadataNode = pathFactory.create(METADATA_NODE);
-
- output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_PRIMARY_TYPE), "esbMessage:metadata");
- output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_TO), metadata.getTo());
- output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_FROM), metadata.getFrom());
- output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_REPLY_TO), metadata.getReplyTo());
- output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_RELATES_TO), metadata.getRelatesTo());
- output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_ACTION), metadata.getAction());
- output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_MESSAGE_ID), metadata.getMessageID());
- output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_MESSAGE_TYPE), metadata.getMessageType());
- output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_FAULT_CODE), metadata.getFaultCode());
- output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_FAULT_REASON), metadata.getFaultReason());
- output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_FAULT_CAUSE), metadata.getFaultCause());
- progressMonitor.worked(1);
- if (progressMonitor.isCancelled()) return;
-
- ProgressMonitor subtask = progressMonitor.createSubtask(3);
- subtask.beginTask(metadata.getBodyMap().entrySet().size(), ESBMessageSequencerI18n.sequencerTaskName);
- Path bodyNode = pathFactory.create(metadataNode, nameFactory.create(ESB_MESSAGE_BODY));
- for (Entry<String, Object> entry : metadata.getBodyMap().entrySet()) {
- output.setProperty(bodyNode, nameFactory.create(ESB_MESSAGE_NAMESPACE, entry.getKey()), entry.getValue());
- subtask.worked(1);
- if (progressMonitor.isCancelled()) return;
- }
- subtask.done();
-
- subtask = progressMonitor.createSubtask(3);
- subtask.beginTask(metadata.getPropertiesMap().entrySet().size(), ESBMessageSequencerI18n.sequencerTaskName);
- Path propertiesNode = pathFactory.create(metadataNode, nameFactory.create(ESB_MESSAGE_PROPERTIES));
- for (Entry<String, Object> entry : metadata.getPropertiesMap().entrySet()) {
- output.setProperty(propertiesNode, nameFactory.create(ESB_MESSAGE_NAMESPACE, entry.getKey()), entry.getValue());
- subtask.worked(1);
- if (progressMonitor.isCancelled()) return;
- }
- subtask.done();
-
- subtask = progressMonitor.createSubtask(3);
- subtask.beginTask(metadata.getAttachmentsMap().entrySet().size(), ESBMessageSequencerI18n.sequencerTaskName);
- Path attachmentsNode = pathFactory.create(metadataNode, nameFactory.create(ESB_MESSAGE_ATTACHMENTS));
- for (Entry<String, Object> entry : metadata.getAttachmentsMap().entrySet()) {
- output.setProperty(attachmentsNode, nameFactory.create(ESB_MESSAGE_NAMESPACE, entry.getKey()), entry.getValue());
- subtask.worked(1);
- if (progressMonitor.isCancelled()) return;
- }
- subtask.done();
-
- progressMonitor.done();
-
- }
- }
-
-}
Copied: trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java)
===================================================================
--- trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java (rev 0)
+++ trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java 2008-06-11 16:27:26 UTC (rev 270)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.esbMessage;
+
+import java.io.InputStream;
+import java.util.Map.Entry;
+import org.jboss.dna.common.monitor.ProgressMonitor;
+import org.jboss.dna.spi.graph.NameFactory;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.PathFactory;
+import org.jboss.dna.spi.sequencers.SequencerOutput;
+import org.jboss.dna.spi.sequencers.StreamSequencer;
+
+/**
+ * A sequencer that processes the binary content of an ESB Message, extracts the metadata for the message, and then writes this
+ * metadata to the repository.
+ * <p>
+ * This sequencer produces data that corresponds to the following structure:
+ * <ul>
+ * <li><strong>esbMessage:metadata</strong> node of type <code>esbMessage:metadata</code>
+ * <ul>
+ * <li><strong>esbMessage:to</strong> - optional property for the destination EPR of the message</li>
+ * <li><strong>esbMessage:from</strong> - optional property for the source EPR of the message</li>
+ * <li><strong>esbMessage:replyTo</strong> - optional property for the reply destination EPR</li>
+ * <li><strong>esbMessage:relatesTo</strong> - optional property for the relatesTo URI</li>
+ * <li><strong>esbMessage:action</strong> - optional property specifying the action URI</li>
+ * <li><strong>esbMessage:messageID</strong> - optional property specifying the messageID URI</li>
+ * <li><strong>esbMessage:body</strong> - optional node specifying the message body. It contains a set of properties
+ * representing Object contained in body. Properties names reflect object names used in message body</li>
+ * <li><strong>esbMessage:properties</strong> - optional node specifying the message properties. It contains a set of properties
+ * representing Object contained in message properties. Properties names reflect object names used in message properties</li>
+ * <li><strong>esbMessage:attachments</strong> - optional node specifying the message attachments. It contains a set of
+ * properties representing Object contained in message attachments. Properties names reflect object names used in message
+ * attachments</li>
+ * <li><strong>esbMessage:faultCode</strong> - optional property specifying the message fault code. As defined in ESB message
+ * it's an URI</li>
+ * <li><strong>esbMessage:faultReason</strong> - optional property containing a String describing the fault in a human readable
+ * form</li>
+ * <li><strong>esbMessage:faultCause</strong> - optional property specifying the Throwable Cause of the fault.</li>
+ * </ul>
+ * </li>
+ * </ul>
+ * </p>
+ *
+ * @author Stefano Maestri
+ */
+public class ESBMessageSequencer implements StreamSequencer {
+
+ public static final String METADATA_NODE = "esbMessage:metadata";
+ public static final String ESB_MESSAGE_PRIMARY_TYPE = "jcr:primaryType";
+ public static final String ESB_MESSAGE_TO = "esbMessage:to";
+ public static final String ESB_MESSAGE_FROM = "esbMessage:from";
+ public static final String ESB_MESSAGE_REPLY_TO = "esbMessage:replyTo";
+ public static final String ESB_MESSAGE_RELATES_TO = "esbMessage:relatesTo";
+ public static final String ESB_MESSAGE_ACTION = "esbMessage:action";
+ public static final String ESB_MESSAGE_MESSAGE_ID = "esbMessage:messageID";
+ public static final String ESB_MESSAGE_MESSAGE_TYPE = "esbMessage:messageType";
+ public static final String ESB_MESSAGE_BODY = "esbMessage:metadata/esbMessage:body";
+ public static final String ESB_MESSAGE_PROPERTIES = "esbMessage:metadata/esbMessage:properties";
+ public static final String ESB_MESSAGE_ATTACHMENTS = "esbMessage:metadata/esbMessage:attachments";
+ public static final String ESB_MESSAGE_FAULT_CODE = "esbMessage:faultCode";
+ public static final String ESB_MESSAGE_FAULT_REASON = "esbMessage:faultReason";
+ public static final String ESB_MESSAGE_FAULT_CAUSE = "esbMessage:faultCause";
+
+ public static final String ESB_MESSAGE_NAMESPACE = "esbMessage";
+
+ public void sequence( InputStream stream,
+ SequencerOutput output,
+ ProgressMonitor progressMonitor ) {
+
+ progressMonitor.beginTask(20, ESBMessageSequencerI18n.sequencerTaskName);
+ ESBMessageMetaData metadata = ESBMessageMetaData.instance(stream, progressMonitor.createSubtask(10));
+ if (progressMonitor.isCancelled()) return;
+
+ if (metadata != null) {
+ NameFactory nameFactory = output.getFactories().getNameFactory();
+ PathFactory pathFactory = output.getFactories().getPathFactory();
+ Path metadataNode = pathFactory.create(METADATA_NODE);
+
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_PRIMARY_TYPE), "esbMessage:metadata");
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_TO), metadata.getTo());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_FROM), metadata.getFrom());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_REPLY_TO), metadata.getReplyTo());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_RELATES_TO), metadata.getRelatesTo());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_ACTION), metadata.getAction());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_MESSAGE_ID), metadata.getMessageID());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_MESSAGE_TYPE), metadata.getMessageType());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_FAULT_CODE), metadata.getFaultCode());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_FAULT_REASON), metadata.getFaultReason());
+ output.setProperty(metadataNode, nameFactory.create(ESB_MESSAGE_FAULT_CAUSE), metadata.getFaultCause());
+ progressMonitor.worked(1);
+ if (progressMonitor.isCancelled()) return;
+
+ ProgressMonitor subtask = progressMonitor.createSubtask(3);
+ subtask.beginTask(metadata.getBodyMap().entrySet().size(), ESBMessageSequencerI18n.sequencerTaskName);
+ Path bodyNode = pathFactory.create(metadataNode, nameFactory.create(ESB_MESSAGE_BODY));
+ for (Entry<String, Object> entry : metadata.getBodyMap().entrySet()) {
+ output.setProperty(bodyNode, nameFactory.create(ESB_MESSAGE_NAMESPACE, entry.getKey()), entry.getValue());
+ subtask.worked(1);
+ if (progressMonitor.isCancelled()) return;
+ }
+ subtask.done();
+
+ subtask = progressMonitor.createSubtask(3);
+ subtask.beginTask(metadata.getPropertiesMap().entrySet().size(), ESBMessageSequencerI18n.sequencerTaskName);
+ Path propertiesNode = pathFactory.create(metadataNode, nameFactory.create(ESB_MESSAGE_PROPERTIES));
+ for (Entry<String, Object> entry : metadata.getPropertiesMap().entrySet()) {
+ output.setProperty(propertiesNode, nameFactory.create(ESB_MESSAGE_NAMESPACE, entry.getKey()), entry.getValue());
+ subtask.worked(1);
+ if (progressMonitor.isCancelled()) return;
+ }
+ subtask.done();
+
+ subtask = progressMonitor.createSubtask(3);
+ subtask.beginTask(metadata.getAttachmentsMap().entrySet().size(), ESBMessageSequencerI18n.sequencerTaskName);
+ Path attachmentsNode = pathFactory.create(metadataNode, nameFactory.create(ESB_MESSAGE_ATTACHMENTS));
+ for (Entry<String, Object> entry : metadata.getAttachmentsMap().entrySet()) {
+ output.setProperty(attachmentsNode, nameFactory.create(ESB_MESSAGE_NAMESPACE, entry.getKey()), entry.getValue());
+ subtask.worked(1);
+ if (progressMonitor.isCancelled()) return;
+ }
+ subtask.done();
+
+ progressMonitor.done();
+
+ }
+ }
+
+}
Deleted: trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencerI18n.java
===================================================================
--- branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencerI18n.java 2008-06-11 16:13:44 UTC (rev 269)
+++ trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencerI18n.java 2008-06-11 16:27:26 UTC (rev 270)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.sequencer.esbMessage;
-
-import java.util.Locale;
-import java.util.Set;
-import org.jboss.dna.common.i18n.I18n;
-
-/**
- * @author Stefano Maestri
- */
-public final class ESBMessageSequencerI18n {
-
- public static I18n sequencerTaskName;
-
- static {
- try {
- I18n.initialize(ESBMessageSequencerI18n.class);
- } catch (final Exception err) {
- System.err.println(err);
- }
- }
-
- public static Set<Locale> getLocalizationProblemLocales() {
- return I18n.getLocalizationProblemLocales(ESBMessageSequencerI18n.class);
- }
-
- public static Set<String> getLocalizationProblems() {
- return I18n.getLocalizationProblems(ESBMessageSequencerI18n.class);
- }
-
- public static Set<String> getLocalizationProblems( Locale locale ) {
- return I18n.getLocalizationProblems(ESBMessageSequencerI18n.class, locale);
- }
-}
Copied: trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencerI18n.java (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencerI18n.java)
===================================================================
--- trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencerI18n.java (rev 0)
+++ trunk/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencerI18n.java 2008-06-11 16:27:26 UTC (rev 270)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.esbMessage;
+
+import java.util.Locale;
+import java.util.Set;
+import org.jboss.dna.common.i18n.I18n;
+
+/**
+ * @author Stefano Maestri
+ */
+public final class ESBMessageSequencerI18n {
+
+ public static I18n sequencerTaskName;
+
+ static {
+ try {
+ I18n.initialize(ESBMessageSequencerI18n.class);
+ } catch (final Exception err) {
+ System.err.println(err);
+ }
+ }
+
+ public static Set<Locale> getLocalizationProblemLocales() {
+ return I18n.getLocalizationProblemLocales(ESBMessageSequencerI18n.class);
+ }
+
+ public static Set<String> getLocalizationProblems() {
+ return I18n.getLocalizationProblems(ESBMessageSequencerI18n.class);
+ }
+
+ public static Set<String> getLocalizationProblems( Locale locale ) {
+ return I18n.getLocalizationProblems(ESBMessageSequencerI18n.class, locale);
+ }
+}
Copied: trunk/sequencers/dna-sequencer-esbMessage/src/main/resources (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/resources)
Copied: trunk/sequencers/dna-sequencer-esbMessage/src/test (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/src/test)
Copied: trunk/sequencers/dna-sequencer-esbMessage/src/test/java (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/src/test/java)
Copied: trunk/sequencers/dna-sequencer-esbMessage/src/test/resources (from rev 269, branches/maeste/sequencers/dna-sequencer-esbMessage/src/test/resources)
17 years, 6 months