|
From: <pat...@us...> - 2010-08-18 20:39:59
|
Revision: 1125
http://cishell.svn.sourceforge.net/cishell/?rev=1125&view=rev
Author: pataphil
Date: 2010-08-18 20:39:52 +0000 (Wed, 18 Aug 2010)
Log Message:
-----------
* Style cleanup.
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java
trunk/core/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmCanceledException.java
trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/ConverterImpl.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/Converter.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterPath.java
trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java
Modified: trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java 2010-08-18 20:38:51 UTC (rev 1124)
+++ trunk/clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/AbstractDataManagerView.java 2010-08-18 20:39:52 UTC (rev 1125)
@@ -24,6 +24,7 @@
import org.cishell.app.service.datamanager.DataManagerListener;
import org.cishell.app.service.datamanager.DataManagerService;
import org.cishell.framework.algorithm.Algorithm;
+import org.cishell.framework.algorithm.AlgorithmCanceledException;
import org.cishell.framework.algorithm.AlgorithmExecutionException;
import org.cishell.framework.algorithm.AlgorithmFactory;
import org.cishell.framework.data.Data;
@@ -501,11 +502,14 @@
e.printStackTrace();
} else {
AbstractDataManagerView.this.logger = Activator.getLogService();
- AbstractDataManagerView.this.logger.log(
- LogService.LOG_ERROR,
- "org.cishell.framework.algorithm.AlgorithmExecutionException",
- e);
- e.printStackTrace();
+
+ if (AbstractDataManagerView.this.logger != null) {
+ AbstractDataManagerView.this.logger.log(
+ LogService.LOG_ERROR,
+ "org.cishell.framework.algorithm.AlgorithmExecutionException",
+ e);
+ e.printStackTrace();
+ }
}
}
}
@@ -522,11 +526,17 @@
try {
algorithm.execute();
} catch (AlgorithmExecutionException e) {
- if (logger != null) {
- logger.log(LogService.LOG_ERROR, e.getMessage(), e);
+ if (AbstractDataManagerView.this.logger != null) {
+ AbstractDataManagerView.this.logger.log(
+ LogService.LOG_ERROR, e.getMessage(), e);
} else {
- logger = Activator.getLogService();
- logger.log(LogService.LOG_ERROR, e.getMessage(), e);
+ AbstractDataManagerView.this.logger = Activator.getLogService();
+
+ // TODO: Find occurrences of this crap happening, and make it a method.
+ if (AbstractDataManagerView.this.logger != null) {
+ AbstractDataManagerView.this.logger.log(
+ LogService.LOG_ERROR, e.getMessage(), e);
+ }
}
e.printStackTrace();
Modified: trunk/core/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmCanceledException.java
===================================================================
--- trunk/core/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmCanceledException.java 2010-08-18 20:38:51 UTC (rev 1124)
+++ trunk/core/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmCanceledException.java 2010-08-18 20:39:52 UTC (rev 1125)
@@ -1,6 +1,6 @@
package org.cishell.framework.algorithm;
-public class AlgorithmCanceledException extends Exception {
+public class AlgorithmCanceledException extends RuntimeException {
private static final long serialVersionUID = 9017277008277139930L;
public AlgorithmCanceledException(String message, Throwable exception) {
Modified: trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/ConverterImpl.java
===================================================================
--- trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/ConverterImpl.java 2010-08-18 20:38:51 UTC (rev 1124)
+++ trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/ConverterImpl.java 2010-08-18 20:39:52 UTC (rev 1125)
@@ -33,20 +33,18 @@
import org.osgi.service.metatype.MetaTypeProvider;
public class ConverterImpl implements Converter, AlgorithmFactory, AlgorithmProperty {
- private ServiceReference[] refs;
+ private ServiceReference[] serviceReferences;
private BundleContext bContext;
- private Dictionary properties;
+ private Dictionary<String, Object> properties;
private CIShellContext ciContext;
public ConverterImpl(BundleContext bContext, CIShellContext ciContext, ServiceReference[] refs) {
this.bContext = bContext;
this.ciContext = ciContext;
- this.refs = refs;
+ this.serviceReferences = refs;
+ properties = new Hashtable<String, Object>();
-
- properties = new Hashtable();
-
properties.put(IN_DATA, refs[0].getProperty(IN_DATA));
properties.put(OUT_DATA, refs[refs.length-1].getProperty(OUT_DATA));
properties.put(LABEL, properties.get(IN_DATA) + " -> " + properties.get(OUT_DATA));
@@ -109,7 +107,7 @@
* @see org.cishell.service.conversion.Converter#getConverterChain()
*/
public ServiceReference[] getConverterChain() {
- return refs;
+ return this.serviceReferences;
}
/**
@@ -134,25 +132,27 @@
}
public String toString() {
- String str ="";
- for (int j = 0; j < refs.length; ++j) {
- str += refs[j].getProperty(Constants.SERVICE_ID);
+ String str = "";
+
+ for (ServiceReference serviceReference : this.serviceReferences) {
+ str += serviceReference.getProperty(Constants.SERVICE_ID);
str += " ";
- str += refs[j].getProperty(Constants.SERVICE_PID);
+ str += serviceReference.getProperty(Constants.SERVICE_PID);
str += "-> ";
}
return str;
}
- public boolean equals(Object o) {
+ public boolean equals(Object compareTo) {
boolean equal = false;
- if (o instanceof Converter) {
- ServiceReference[] otherServiceReference =
- ((Converter) o).getConverterChain();
- if (refs.length == otherServiceReference.length) {
+
+ if (compareTo instanceof Converter) {
+ ServiceReference[] otherServiceReference = ((Converter) compareTo).getConverterChain();
+
+ if (this.serviceReferences.length == otherServiceReference.length) {
for (int i = 0; i < otherServiceReference.length; i++) {
- if (refs[i].getProperty(Constants.SERVICE_ID).equals(
+ if (this.serviceReferences[i].getProperty(Constants.SERVICE_ID).equals(
otherServiceReference[i].getProperty(
Constants.SERVICE_ID))) {
equal = true;
@@ -167,7 +167,7 @@
return equal;
}
- /* The conversion chain (refs) is lossless
+ /* The conversion chain (serviceReferences) is lossless
* if and only if no conversion (ref) is lossy.
*/
private String calculateLossiness(ServiceReference[] refs) {
@@ -186,62 +186,61 @@
public static final String MIME_TYPE_PREFIX = "file:";
private Data[] inData;
- private Dictionary parameters;
- private CIShellContext context;
- private LogService log;
+ private Dictionary<String, Object> parameters;
+ private CIShellContext ciShellContext;
+ private LogService logger;
- public ConverterAlgorithm(Data[] inData,
- Dictionary parameters,
- CIShellContext context) {
+ public ConverterAlgorithm(
+ Data[] inData, Dictionary<String, Object> parameters, CIShellContext ciShellContext) {
this.inData = inData;
this.parameters = parameters;
- this.context = context;
- this.log =
- (LogService) context.getService(LogService.class.getName());
+ this.ciShellContext = ciShellContext;
+ this.logger =
+ (LogService) ciShellContext.getService(LogService.class.getName());
}
public Data[] execute() throws AlgorithmExecutionException {
- Data[] convertedData = inData;
+ Data[] convertedData = this.inData;
- // For each converter in the converter chain (refs)
- for (int ii = 0; ii < refs.length; ii++) {
+ // For each converter in the converter chain (serviceReferences)
+ for (int ii = 0; ii < serviceReferences.length; ii++) {
AlgorithmFactory factory =
- (AlgorithmFactory) bContext.getService(refs[ii]);
+ (AlgorithmFactory) bContext.getService(serviceReferences[ii]);
if (factory != null) {
- Algorithm alg =
- factory.createAlgorithm(convertedData, parameters, context);
+ Algorithm algorithm = factory.createAlgorithm(
+ convertedData, this.parameters, this.ciShellContext);
try {
- convertedData = alg.execute();
+ convertedData = algorithm.execute();
} catch(AlgorithmExecutionException e) {
- boolean isLastStep = (ii == refs.length - 1);
- if (isLastStep && isHandler(refs[ii])) {
+ boolean isLastStep = (ii == serviceReferences.length - 1);
+ if (isLastStep && isHandler(serviceReferences[ii])) {
/* If the last step of the converter chain is a
* handler and it is the first (and so only) step
- * to fail, just log a warning and return the
+ * to fail, just logger a warning and return the
* un-handled data.
*/
String warningMessage =
"Warning: Attempting to convert data without "
+ "validating the output since the validator failed "
+ "with this problem:\n "
- + createErrorMessage(refs[ii], e);
+ + createErrorMessage(serviceReferences[ii], e);
- log.log(LogService.LOG_WARNING, warningMessage, e);
+ this.logger.log(LogService.LOG_WARNING, warningMessage, e);
return convertedData;
} else {
throw new AlgorithmExecutionException(
- createErrorMessage(refs[ii], e), e);
+ createErrorMessage(serviceReferences[ii], e), e);
}
}
} else {
throw new AlgorithmExecutionException(
"Missing subconverter: "
- + refs[ii].getProperty(Constants.SERVICE_PID));
+ + serviceReferences[ii].getProperty(Constants.SERVICE_PID));
}
}
@@ -286,7 +285,7 @@
return "Problem converting data from "
+ prettifyDataType(inType)
+ " to " + prettifyDataType(outType)
- + " (See the log file for more details).:\n "
+ + " (See the logger file for more details).:\n "
+ e.getMessage();
}
else {
@@ -296,7 +295,7 @@
+ " during the necessary intermediate conversion from "
+ prettifyDataType(preProblemType) + " to "
+ prettifyDataType(postProblemType)
- + " (See the log file for more details):\n "
+ + " (See the logger file for more details):\n "
+ e.getMessage();
}
}
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/Converter.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/Converter.java 2010-08-18 20:38:51 UTC (rev 1124)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/Converter.java 2010-08-18 20:39:52 UTC (rev 1125)
@@ -12,31 +12,29 @@
import org.osgi.framework.ServiceReference;
public class Converter {
+ private BundleContext bundleContext;
+ private ServiceReference serviceReference;
- private BundleContext bContext;
-
- private ServiceReference ref;
-
- public Converter(BundleContext bContext, ServiceReference ref) {
- this.bContext = bContext;
- this.ref = ref;
+ public Converter(BundleContext bundleContext, ServiceReference serviceReference) {
+ this.bundleContext = bundleContext;
+ this.serviceReference = serviceReference;
}
public ServiceReference getServiceReference() {
- return this.ref;
+ return this.serviceReference;
}
- public ServiceReference getRef() {
- return this.ref;
+ public ServiceReference getServieReference() {
+ return this.serviceReference;
}
public boolean isLossy() {
- String conversion = (String)
- ref.getProperty(AlgorithmProperty.CONVERSION);
+ String conversion =
+ (String) this.serviceReference.getProperty(AlgorithmProperty.CONVERSION);
if (conversion == null) {
return false;
- //if lossiness is not defined, assume it is not lossy.
+ // If lossiness is not defined, assume it is not lossy.
}
if (conversion.equals(AlgorithmProperty.LOSSY)) {
@@ -44,17 +42,17 @@
} else if (conversion.equals(AlgorithmProperty.LOSSLESS)) {
return false;
} else {
- //assuming lossy by default
+ // Assuming lossy by default.
return true;
}
}
public String getInData() {
- return (String) ref.getProperty(AlgorithmProperty.IN_DATA);
+ return (String) this.serviceReference.getProperty(AlgorithmProperty.IN_DATA);
}
public String getOutData() {
- return (String) ref.getProperty(AlgorithmProperty.OUT_DATA);
+ return (String) this.serviceReference.getProperty(AlgorithmProperty.OUT_DATA);
}
public String getShortName() {
@@ -62,23 +60,22 @@
}
public String getUniqueName() {
- return (String) this.ref.getProperty("service.pid");
+ return (String) this.serviceReference.getProperty("service.pid");
}
public String toString() {
return getUniqueName();
}
- public Data[] execute(Data[] input, Hashtable parameters,
- CIShellContext cContext) throws AlgorithmExecutionException {
+ public Data[] execute(
+ Data[] input, Hashtable<String, Object> parameters, CIShellContext ciShellContext)
+ throws AlgorithmExecutionException {
+
+ AlgorithmFactory converterFactory =
+ (AlgorithmFactory) this.bundleContext.getService(this.serviceReference);
+ Algorithm converter = converterFactory.createAlgorithm(input, parameters, ciShellContext);
+ Data[] output = converter.execute();
- AlgorithmFactory convAlgFactory =
- (AlgorithmFactory) this.bContext.getService(this.ref);
- Algorithm convAlg = convAlgFactory.createAlgorithm(input, parameters,
- cContext);
-
- Data[] output = convAlg.execute();
-
return output;
}
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterPath.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterPath.java 2010-08-18 20:38:51 UTC (rev 1124)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/ConverterPath.java 2010-08-18 20:39:52 UTC (rev 1125)
@@ -9,87 +9,74 @@
import org.osgi.service.log.LogService;
public class ConverterPath implements AlgorithmProperty {
+ private LogService logger;
+ private String inData = null;
+ private String outData = null;
+ private List<Converter> path;
- private BundleContext bContext;
- private LogService log;
- private String in_data = null;
- private String out_data = null;
-
- private List path;
-
- public ConverterPath(BundleContext bContext, LogService log){
- this.bContext = bContext;
- this.log = log;
-
- path = new ArrayList();
+ public ConverterPath(BundleContext bundleContext, LogService logger){
+ this.logger = logger;
+ this.path = new ArrayList<Converter>();
}
- public ConverterPath(ConverterPath p, BundleContext bContext) {
- this.bContext = bContext;
-
- in_data = p.getInData();
- out_data = p.getOutData();
+ public ConverterPath(ConverterPath path, BundleContext bundleContext) {
+ this.inData = path.getInData();
+ this.outData = path.getOutData();
+ this.path = new ArrayList<Converter>(path.getPath());
- this.path = new ArrayList(p.getPath());
-
}
- public void setInData(String s){
-
- this.in_data = s;
+ public void setInData(String inData) {
+ this.inData = inData;
}
- public void setOutData(String s){
-
- this.out_data = s;
+ public void setOutData(String outData) {
+ this.outData = outData;
}
- public boolean add(Converter c){
-
- boolean val = true;
-
- if(path.contains(c)){
+ public boolean add(Converter converter) {
+ if (path.contains(converter)) {
return false;
+ } else {
+ path.add(converter);
+ this.setOutData(converter.getOutData());
+
+ return true;
}
-
- path.add(c);
- this.setOutData(c.getOutData());
- return val;
}
- public String getInData(){
-
- return this.in_data;
+ public String getInData() {
+ return this.inData;
}
- public String getOutData(){
-
- return this.out_data;
+ public String getOutData() {
+ return this.outData;
}
public String getAcceptedFileFormat() {
if (size() > 0) {
- return (String) getRef(0).getProperty(AlgorithmProperty.OUT_DATA);
+ return (String) getServiceReference(0).getProperty(AlgorithmProperty.OUT_DATA);
} else {
- this.log.log(LogService.LOG_ERROR, "Converter Path cannot " +
+ this.logger.log(LogService.LOG_ERROR, "Converter Path cannot " +
"determine accepted file format if there are no " +
"converters inside it. Returning null String.");
+
return "";
}
}
- public List getPath(){
-
+ public List<Converter> getPath() {
return this.path;
}
- //inclusive
- public List getPathUpTo(Converter upToConv) {
+ /// Inclusive.
+ public List<Converter> getPathUpTo(Converter upToConverter) {
int convIndex = -1;
+
for (int ii = 0; ii < this.path.size(); ii++) {
Converter aConvInPath = get(ii);
- if (aConvInPath.equals(upToConv)) {
+ if (aConvInPath.equals(upToConverter)) {
convIndex = ii;
break;
}
@@ -108,50 +95,40 @@
return (Converter) this.path.get(index);
}
- public ServiceReference getRef(int index) {
+ public ServiceReference getServiceReference(int index) {
+ Converter converter = this.path.get(index);
+ ServiceReference serviceReference = converter.getServieReference();
- Converter c = (Converter) this.path.get(index);
- ServiceReference ref = c.getRef();
- return ref;
+ return serviceReference;
}
- public Converter[] getPathAsArray(){
-
+ public Converter[] getPathAsArray() {
return (Converter[]) this.path.toArray(new Converter[0]);
}
public boolean isLossy() {
-
- String lossiness = LOSSLESS;
- for (int i = 0; i < this.path.size(); i++) {
- Converter c = (Converter) this.path.get(i);
-
- if (c.isLossy()) {
- lossiness = LOSSY;
+ for (Converter converter : this.path) {
+ if (converter.isLossy()) {
+ return true;
}
}
- boolean result = lossiness.equals(LOSSY);
- return result;
+ return false;
}
public boolean preservesIDs() {
-
- //TODO: Determine this somehow.
+ // TODO: Determine this somehow.
return false;
}
public int size() {
-
return this.path.size();
}
- public boolean containsConverterNamed(String convName) {
- for (int ii = 0; ii < this.path.size(); ii++) {
- Converter conv = (Converter) this.path.get(ii);
-
- if (conv.getShortName().equals(convName) ||
- conv.getUniqueName().equals(convName)) {
+ public boolean containsConverterNamed(String converterName) {
+ for (Converter converter : this.path) {
+ if (converter.getShortName().equals(converterName) ||
+ converter.getUniqueName().equals(converterName)) {
return true;
}
}
@@ -160,6 +137,6 @@
}
public String getConverterName(int index) {
- return (String) get(index).getUniqueName();
+ return get(index).getUniqueName();
}
}
Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java
===================================================================
--- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java 2010-08-18 20:38:51 UTC (rev 1124)
+++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/DefaultTestRunner.java 2010-08-18 20:39:52 UTC (rev 1125)
@@ -28,43 +28,38 @@
import prefuse.data.Graph;
+// TODO: Continue refactoring this.
public class DefaultTestRunner implements TestRunner {
+ private LogService logger;
- private LogService log;
-
- public DefaultTestRunner(LogService log) {
- this.log = log;
+ public DefaultTestRunner(LogService logger) {
+ this.logger = logger;
}
public FilePassResult[] runTest(TestConfigData testData) {
-
Data[][] testFileData = testData.getTestFileData();
ConverterPath testConverters = testData.getTestConverters();
- ConverterPath comparisonConverters = testData
- .getComparisonConverters();
-
- List testResults = new ArrayList();
+ ConverterPath comparisonConverters = testData.getComparisonConverters();
+ List<FilePassResult> testResults = new ArrayList<FilePassResult>();
- for (int ii = 0; ii < testFileData.length; ii++) {
- Data[] originalFileData = testFileData[ii];
-
- // test conversion phase
+ for (Data[] originalFileData : testFileData) {
+ // Test conversion phase.
- ConvertResult testPhaseResult = convert(originalFileData,
- testConverters, testData);
-
+ ConvertResult testPhaseResult = convert(originalFileData, testConverters, testData);
Data[][] allDataFromTestPhase = testPhaseResult.getAllData();
if (!testPhaseResult.succeeded()) {
- FilePassFailure failure = createFailResult(originalFileData,
- PassPhase.TEST_CONV_PHASE,
- testPhaseResult.getFailInfo(),
+ FilePassFailure failure = createFailResult(
+ originalFileData,
+ PassPhase.TEST_CONV_PHASE,
+ testPhaseResult.getFailInfo(),
allDataFromTestPhase,
null,
null);
testResults.add(failure);
continue;
}
+
Data[] resultFileData = testPhaseResult.getResult();
@@ -144,9 +139,8 @@
ConverterPath converters, TestConfigData testData) {
Data[] currentData = getFilePathData(startData);
+ List<Data[]> dataSoFar = new ArrayList<Data[]>();
- List dataSoFar = new ArrayList();
-
// if (startData != null) {
// alterMetaData(startData);
// dataSoFar.add(startData);
@@ -156,7 +150,7 @@
* rig up fake CIShellContext so we can get ahold of
* errors sent to logger.
*/
- FakeLogCIShellContext fakeCContext =
+ FakeLogCIShellContext fakeCIShellContext =
new FakeLogCIShellContext(testData.getContext());
@@ -168,14 +162,15 @@
for (int ii = 0; ii < converters.size(); ii++) {
currentConverter = converters.get(ii);
- Hashtable parameters = new Hashtable(); //no parameters used
+ // No parameters used.
+ Hashtable<String, Object> parameters = new Hashtable<String, Object>();
- currentData = currentConverter.execute(currentData,
- parameters, fakeCContext);
+ currentData =
+ currentConverter.execute(currentData, parameters, fakeCIShellContext);
if (currentData != null) {
- setMetaData(currentData, currentConverter);
- dataSoFar.add(currentData);
+ setMetadata(currentData, currentConverter);
+ dataSoFar.add(currentData);
}
/*
@@ -191,9 +186,9 @@
String explanation = "Result of conversion was null. \r\n";
- if (fakeCContext.hasLogEntries()) {
- String logText = extractLogText(fakeCContext);
- explanation += "Error log contains the following: \r\n" +
+ if (fakeCIShellContext.hasLogEntries()) {
+ String logText = extractLogText(fakeCIShellContext);
+ explanation += "Error logger contains the following: \r\n" +
logText;
} else {
explanation += "No errors logged. Cause unknown. \r\n";
@@ -202,19 +197,24 @@
ConvFailureInfo failInfo = new ConvFailureInfo(
explanation, converter);
- ConvertResult result = new ConvertResult(failInfo, (Data[][]) dataSoFar.toArray(new Data[dataSoFar.size()][]));
+ ConvertResult result = new ConvertResult(
+ failInfo, (Data[][]) dataSoFar.toArray(new Data[dataSoFar.size()][]));
+
return result;
}
}
} catch (Throwable t) {
- ConvFailureInfo failInfo = new ConvFailureInfo(getStackTrace(t),
- currentConverter);
- ConvertResult result = new ConvertResult(failInfo,(Data[][]) dataSoFar.toArray(new Data[dataSoFar.size()][]));
+ ConvFailureInfo failInfo = new ConvFailureInfo(getStackTrace(t), currentConverter);
+ ConvertResult result = new ConvertResult(
+ failInfo,(Data[][]) dataSoFar.toArray(new Data[dataSoFar.size()][]));
+
return result;
}
Data[] resultData = currentData;
- ConvertResult result = new ConvertResult(resultData,(Data[][]) dataSoFar.toArray(new Data[dataSoFar.size()][]));
+ ConvertResult result = new ConvertResult(
+ resultData,(Data[][]) dataSoFar.toArray(new Data[dataSoFar.size()][]));
+
return result;
}
@@ -288,7 +288,7 @@
Data result = new BasicData(filePath, format);
return new Data[] { result };
} catch (IOException e) {
- this.log.log(LogService.LOG_ERROR, "Could not get file path " +
+ this.logger.log(LogService.LOG_ERROR, "Could not get file path " +
"from file " + actualFile, e);
return null;
}
@@ -316,51 +316,49 @@
return logText;
}
- private void setMetaData(Data[] data, Converter converter) {
- if (data == null || data.length < 1) {
+ private void setMetadata(Data[] data, Converter converter) {
+ if ((data == null) || (data.length < 1)) {
return;
}
Data datum = data[0];
- Dictionary md = datum.getMetadata();
- if (md.get(DataProperty.LABEL) == null) {
- md.put(DataProperty.LABEL, "result of " + converter.getShortName());
+ Dictionary<String, Object> metadata = datum.getMetadata();
+
+ if (metadata.get(DataProperty.LABEL) == null) {
+ metadata.put(DataProperty.LABEL, "result of " + converter.getShortName());
} else {
- alterMetaData(data);
- md.put(DataProperty.LABEL, md.get(DataProperty.LABEL) + ": result of " + converter.getShortName());
+ alterMetadata(data);
+ metadata.put(
+ DataProperty.LABEL,
+ metadata.get(DataProperty.LABEL) + ": result of " + converter.getShortName());
}
}
private String getFileName(String fileLabel) {
-
- //index variables will be -1 if index is not found.
+ // Index variables will be -1 if index is not found.
int descriptionEndIndex = fileLabel.lastIndexOf(":");
int filePathEndIndex = fileLabel.lastIndexOf(File.separator);
- //doesn't matter if either variable is -1, since startIndex will be
- //zero and none of the string will be cut off the front.
+ /* Doesn't matter if either variable is -1, since startIndex will be zero and none of the
+ * string will be cut off the front.
+ */
int startIndex = Math.max(descriptionEndIndex, filePathEndIndex) + 1;
-
String fileNameWithExtension = fileLabel.substring(startIndex);
-
-
-
- int endIndex = fileNameWithExtension.length(); // don't cut any off the end.
-
-
+ int endIndex = fileNameWithExtension.length(); // Don't cut any off the end.
String fileNameWithoutExtension = fileNameWithExtension.substring(0, endIndex);
-
String fileName = fileNameWithoutExtension;
+
return fileName;
}
- private void alterMetaData(Data[] origFileData) {
- Data data = origFileData[0];
- Dictionary metadata = data.getMetadata();
+ private void alterMetadata(Data[] originalFileData) {
+ Data data = originalFileData[0];
+ Dictionary<String, Object> metadata = data.getMetadata();
String label = (String) metadata.get(DataProperty.LABEL);
+
if (label != null) {
- metadata.put(DataProperty.LABEL, getFileName(label));
+ metadata.put(DataProperty.LABEL, getFileName(label));
} else {
metadata.put(DataProperty.LABEL, "null");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|