Clean up formatting so I can read the code

This commit is contained in:
Mark H. Wood
2012-06-29 13:20:46 -04:00
parent f05ceff8e8
commit c9820a3bbd

View File

@@ -87,20 +87,22 @@ public class DSpaceControlledVocabulary extends SelfNamedPlugin implements Choic
{ {
class xmlFilter implements java.io.FilenameFilter class xmlFilter implements java.io.FilenameFilter
{ {
@Override
public boolean accept(File dir, String name) public boolean accept(File dir, String name)
{ {
return name.endsWith(".xml"); return name.endsWith(".xml");
} }
} }
String vocabulariesPath = ConfigurationManager.getProperty("dspace.dir") + "/config/controlled-vocabularies/"; String vocabulariesPath = ConfigurationManager.getProperty("dspace.dir")
+ "/config/controlled-vocabularies/";
String[] xmlFiles = (new File(vocabulariesPath)).list(new xmlFilter()); String[] xmlFiles = (new File(vocabulariesPath)).list(new xmlFilter());
List<String> names = new ArrayList<String>(); List<String> names = new ArrayList<String>();
for (String filename : xmlFiles) for (String filename : xmlFiles)
{ {
names.add((new File(filename)).getName().replace(".xml","")); names.add((new File(filename)).getName().replace(".xml", ""));
} }
pluginNames = names.toArray(new String[names.size()]); pluginNames = names.toArray(new String[names.size()]);
log.info("Got plugin names = "+Arrays.deepToString(pluginNames)); log.info("Got plugin names = " + Arrays.deepToString(pluginNames));
} }
} }
@@ -154,6 +156,7 @@ public class DSpaceControlledVocabulary extends SelfNamedPlugin implements Choic
} }
} }
@Override
public Choices getMatches(String field, String text, int collection, int start, int limit, String locale) public Choices getMatches(String field, String text, int collection, int start, int limit, String locale)
{ {
init(); init();
@@ -162,11 +165,12 @@ public class DSpaceControlledVocabulary extends SelfNamedPlugin implements Choic
XPath xpath = XPathFactory.newInstance().newXPath(); XPath xpath = XPathFactory.newInstance().newXPath();
Choice[] choices; Choice[] choices;
try { try {
NodeList results = (NodeList)xpath.evaluate(xpathExpression, vocabulary, XPathConstants.NODESET); NodeList results = (NodeList) xpath.evaluate(xpathExpression,
vocabulary, XPathConstants.NODESET);
String[] authorities = new String[results.getLength()]; String[] authorities = new String[results.getLength()];
String[] values = new String[results.getLength()]; String[] values = new String[results.getLength()];
String[] labels = new String[results.getLength()]; String[] labels = new String[results.getLength()];
for (int i=0; i<results.getLength(); i++) for (int i = 0; i < results.getLength(); i++)
{ {
Node node = results.item(i); Node node = results.item(i);
String hierarchy = this.buildString(node); String hierarchy = this.buildString(node);
@@ -188,13 +192,14 @@ public class DSpaceControlledVocabulary extends SelfNamedPlugin implements Choic
} }
authorities[i] = node.getAttributes().getNamedItem("id").getNodeValue(); authorities[i] = node.getAttributes().getNamedItem("id").getNodeValue();
} }
int resultCount = Math.min(labels.length-start, limit); int resultCount = Math.min(labels.length - start, limit);
choices = new Choice[resultCount]; choices = new Choice[resultCount];
if (resultCount > 0) if (resultCount > 0)
{ {
for (int i=0; i<resultCount; i++) for (int i = 0; i < resultCount; i++)
{ {
choices[i] = new Choice(authorities[start+i],values[start+i],labels[start+i]); choices[i] = new Choice(authorities[start + i], values[start
+ i], labels[start + i]);
} }
} }
} catch(XPathExpressionException e) { } catch(XPathExpressionException e) {
@@ -203,6 +208,7 @@ public class DSpaceControlledVocabulary extends SelfNamedPlugin implements Choic
return new Choices(choices, 0, choices.length, Choices.CF_AMBIGUOUS, false); return new Choices(choices, 0, choices.length, Choices.CF_AMBIGUOUS, false);
} }
@Override
public Choices getBestMatch(String field, String text, int collection, String locale) public Choices getBestMatch(String field, String text, int collection, String locale)
{ {
init(); init();
@@ -210,6 +216,7 @@ public class DSpaceControlledVocabulary extends SelfNamedPlugin implements Choic
return getMatches(field, text, collection, 0, 2, locale); return getMatches(field, text, collection, 0, 2, locale);
} }
@Override
public String getLabel(String field, String key, String locale) public String getLabel(String field, String key, String locale)
{ {
init(); init();