From e44404fac09c8da04b5ef7874160cb91f8fc98a9 Mon Sep 17 00:00:00 2001
From: rhindes
Date: Thu, 10 Feb 2005 16:22:20 +0000
Subject: [PATCH] some code cleanup. removed unnecessary semikolons, unused
vars, etc.
---
source/Mir.java | 47 +-
source/mir/bundle/CascadingBundleFactory.java | 2 +-
source/mir/bundle/PropertiesBundle.java | 7 +-
source/mir/bundle/PropertiesFileBundleLoader.java | 2 +-
source/mir/config/MirPropertiesConfiguration.java | 6 +-
source/mir/entity/AbstractEntity.java | 7 +-
source/mir/entity/Entity.java | 8 +-
source/mir/entity/EntityBrowser.java | 9 +-
source/mir/entity/EntityList.java | 14 +-
source/mir/entity/StorableObjectEntity.java | 3 +-
source/mir/entity/adapter/EntityAdapter.java | 6 +-
.../entity/adapter/EntityAdapterDefinition.java | 2 +-
source/mir/entity/adapter/EntityAdapterModel.java | 6 +-
.../mir/entity/adapter/EntityIteratorAdapter.java | 2 +-
.../mir/generator/CompositeGeneratorLibrary.java | 11 +-
source/mir/generator/FreemarkerGenerator.java | 28 +-
source/mir/generator/GeneratorHelper.java | 6 +-
source/mir/generator/TALGenerator.java | 6 +-
source/mir/generator/VelocityGenerator.java | 37 +-
.../tal/SimpleTemplateNodeLibraryRegistry.java | 4 +-
source/mir/generator/tal/TALTemplateEngine.java | 18 +-
source/mir/generator/tal/TALTemplateParser.java | 8 +-
source/mir/generator/tal/TALTest.java | 6 +-
.../tal/template/CoreTemplateNodeLibrary.java | 765 ++++-----
.../tal/template/MacroTemplateNodeLibrary.java | 8 +-
.../tal/template/TemplateNodeLibrary.java | 98 +-
source/mir/log/LoggerToWriterAdapter.java | 2 +-
source/mir/log/LoggerWrapper.java | 14 +-
source/mir/log/log4j/LoggerImpl.java | 1 +
source/mir/misc/FileUtil.java | 9 +-
source/mir/misc/StringUtil.java | 29 +-
source/mir/module/AbstractModule.java | 5 +-
source/mir/producer/AssignmentProducerNode.java | 3 +-
source/mir/producer/BundleProducerNode.java | 2 +-
.../mir/producer/EntityBatchingProducerNode.java | 4 +-
.../mir/producer/EntityDeletingProducerNode.java | 2 +-
.../producer/EntityEnumeratingProducerNode.java | 2 +-
.../producer/EvaluatedAssignmentProducerNode.java | 3 +-
.../mir/producer/ExecuteProgramProducerNode.java | 256 +--
.../producer/ExpandedAssignmentProducerNode.java | 3 +-
source/mir/producer/ExternalDbProducerNode.java | 9 +-
source/mir/producer/FreeQueryProducerNode.java | 2 +-
.../mir/producer/ListEnumeratingProducerNode.java | 2 +-
source/mir/producer/LoopProducerNode.java | 2 +-
source/mir/producer/NodedProducer.java | 2 +-
source/mir/producer/ProducerFactory.java | 2 +-
source/mir/producer/ProducerFailure.java | 3 +-
source/mir/producer/RDFAggregatorProducerNode.java | 2 +-
source/mir/producer/RSSProducerNode.java | 2 +-
source/mir/producer/ValuesMapProducerNode.java | 2 +-
.../reader/DefaultProducerNodeBuilders.java | 114 +-
.../mir/producer/reader/ProducerConfigReader.java | 18 +-
.../reader/ProducerNodeBuilderLibrary.java | 3 +-
.../producer/reader/ScriptedProducerFactory.java | 2 +-
source/mir/rss/RSS091Reader.java | 70 +-
source/mir/rss/RSSData.java | 2 +-
source/mir/rss/RSSReader.java | 86 +-
source/mir/servlet/ServletModule.java | 10 +-
source/mir/session/CommonsUploadedFileAdapter.java | 8 +-
source/mir/session/HTTPAdapters.java | 32 +-
source/mir/session/ValidationHelper.java | 3 +-
source/mir/storage/Database.java | 55 +-
source/mir/storage/StorageObjectFailure.java | 4 +-
source/mir/storage/store/ObjectStore.java | 1 +
source/mir/storage/store/StoreContainer.java | 4 +-
source/mir/storage/store/test/EntityC1.java | 2 +-
source/mir/util/CachingRewindableIterator.java | 2 +-
source/mir/util/DateTimeFunctions.java | 19 +-
source/mir/util/FileFunctions.java | 26 +-
source/mir/util/GeneratorDateTimeFunctions.java | 2 +-
source/mir/util/GeneratorFormatAdapters.java | 4 +-
source/mir/util/HTTPParsedRequest.java | 16 +-
source/mir/util/HTTPRequestParser.java | 3 +-
source/mir/util/InternetFunctions.java | 2 +-
source/mir/util/ParameterExpander.java | 49 +-
source/mir/util/PropertiesManipulator.java | 6 +-
source/mir/util/ReflectionRoutines.java | 120 +-
source/mir/util/StreamCopier.java | 2 +-
source/mir/util/StringParseRoutines.java | 4 +-
source/mir/util/StringRoutines.java | 5 +-
source/mir/util/StructuredContentParser.java | 2 +-
source/mir/util/SubsetIterator.java | 7 +-
.../util/generator/BundleGeneratorFunction.java | 6 +-
source/mir/util/xml/AbstractSectionHandler.java | 78 +-
source/mir/util/xml/XMLName.java | 174 +-
source/mir/util/xml/XMLParserEngine.java | 7 +-
source/mir/util/xml/XMLParserFailure.java | 45 +-
source/mir/util/xml/XMLReaderTool.java | 3 +-
source/mir/util/xml/XMLSAXParserProvider.java | 321 ++--
source/mir/util/xml/html/HTMLParser.java | 8 +-
source/mir/util/xml/html/HTMLScanner.java | 7 +-
.../mir/util/xml/html/HTMLSchemaInformation.java | 5 +-
.../mir/util/xml/html/XMLHTMLParserProvider.java | 192 +--
source/mircoders/abuse/FilterEngine.java | 913 +++++------
source/mircoders/abuse/IPFilterType.java | 160 +-
.../abuse/RegularExpressionFilterType.java | 5 +-
source/mircoders/abuse/ThrottleFilter.java | 300 ++--
source/mircoders/accesscontrol/AccessControl.java | 6 +-
source/mircoders/entity/EntityComment.java | 8 +-
source/mircoders/entity/EntityContent.java | 12 +-
source/mircoders/entity/EntityImages.java | 10 +-
source/mircoders/entity/EntityUploadedMedia.java | 8 +-
source/mircoders/entity/EntityVideo.java | 4 +-
source/mircoders/global/Abuse.java | 27 +-
source/mircoders/global/CacheKey.java | 3 +-
source/mircoders/global/DatabaseEngine.java | 1 +
source/mircoders/global/JobQueue.java | 13 +-
source/mircoders/global/MirGlobal.java | 708 ++++----
source/mircoders/global/ProducerEngine.java | 17 +-
.../localizer/MirAdminInterfaceLocalizer.java | 6 +-
.../localizer/MirCachingLocalizerDecorator.java | 12 +-
.../basic/MirBasicAdminInterfaceLocalizer.java | 39 +-
.../basic/MirBasicArticlePostingHandler.java | 17 +-
.../basic/MirBasicChildArticlePostingHandler.java | 2 +-
.../basic/MirBasicCommentPostingHandler.java | 5 +-
.../basic/MirBasicDataModelLocalizer.java | 1710 ++++++++++----------
.../basic/MirBasicEmailArticleHandler.java | 13 +-
.../basic/MirBasicGeneratorLocalizer.java | 10 +-
.../localizer/basic/MirBasicLocalizer.java | 4 +-
.../localizer/basic/MirBasicMediaLocalizer.java | 14 +-
.../basic/MirBasicOpenPostingLocalizer.java | 11 +-
.../basic/MirBasicPostingSessionHandler.java | 26 +-
.../basic/MirBasicProducerAssistantLocalizer.java | 36 +-
.../localizer/basic/MirBasicProducerLocalizer.java | 8 +-
.../basic/MirBasicTranslationPostingHandler.java | 2 +-
.../localizer/basic/MirBasicUtilityFunctions.java | 323 ++--
.../localizer/basic/MirBasicWriterEngine.java | 4 +-
.../basic/actions/ArticleTopicAction.java | 2 +-
source/mircoders/media/AbstractMediaHandler.java | 118 +-
source/mircoders/media/MediaHandlerGeneric.java | 17 +-
source/mircoders/media/MediaHandlerMp3.java | 6 +-
source/mircoders/media/MediaHandlerOgg.java | 3 +-
source/mircoders/media/MediaHandlerRealAudio.java | 4 +-
source/mircoders/media/MediaHandlerRealVideo.java | 10 +-
source/mircoders/media/MediaHelper.java | 19 +-
source/mircoders/media/MediaUploadProcessor.java | 8 +-
source/mircoders/media/URLMediaHandler.java | 6 +-
source/mircoders/module/ModuleComment.java | 6 +-
source/mircoders/module/ModuleLanguage.java | 8 +-
source/mircoders/module/ModuleMediaType.java | 10 +-
source/mircoders/module/ModuleUsers.java | 6 +-
source/mircoders/pdf/PDFGenerator.java | 37 +-
.../mircoders/producer/IndexingProducerNode.java | 4 +-
.../producer/MediaGeneratingProducerNode.java | 2 +-
.../producer/PDFPreFormattingProducerNode.java | 6 +-
.../producer/RadicalendarProducerNode.java | 8 +-
.../mircoders/producer/UnIndexingProducerNode.java | 4 +-
.../reader/SupplementalProducerNodeBuilders.java | 34 +-
source/mircoders/search/AudioSearchTerm.java | 9 +-
source/mircoders/search/ContentSearchTerm.java | 4 +-
source/mircoders/search/ImagesSearchTerm.java | 5 +-
source/mircoders/search/IndexUtil.java | 5 +-
source/mircoders/search/KeywordSearchTerm.java | 4 +-
source/mircoders/search/MediaSearchTerm.java | 4 +-
source/mircoders/search/SearchTerm.java | 3 +
source/mircoders/search/TextSearchTerm.java | 4 +-
source/mircoders/search/TopicMatrixSearchTerm.java | 4 +-
source/mircoders/search/TopicSearchTerm.java | 4 +-
source/mircoders/search/UnStoredSearchTerm.java | 4 +-
source/mircoders/search/VideoSearchTerm.java | 8 +-
source/mircoders/servlet/ServletHelper.java | 343 ++--
source/mircoders/servlet/ServletModuleAbuse.java | 9 +-
source/mircoders/servlet/ServletModuleAdmin.java | 1 +
source/mircoders/servlet/ServletModuleComment.java | 19 +-
source/mircoders/servlet/ServletModuleContent.java | 22 +-
.../mircoders/servlet/ServletModuleFileEdit.java | 13 +-
source/mircoders/servlet/ServletModuleHidden.java | 13 +-
.../mircoders/servlet/ServletModuleLocalizer.java | 12 +-
.../mircoders/servlet/ServletModuleMediaType.java | 1 -
.../mircoders/servlet/ServletModuleOpenIndy.java | 3 +-
.../mircoders/servlet/ServletModuleProducer.java | 18 +-
source/mircoders/servlet/ServletModuleUsers.java | 16 +-
source/mircoders/storage/DatabaseArticleType.java | 1 -
source/mircoders/storage/DatabaseAudio.java | 4 +-
source/mircoders/storage/DatabaseBreaking.java | 1 -
source/mircoders/storage/DatabaseComment.java | 1 -
.../mircoders/storage/DatabaseCommentStatus.java | 1 -
.../mircoders/storage/DatabaseCommentToMedia.java | 6 +-
source/mircoders/storage/DatabaseContent.java | 1 -
.../mircoders/storage/DatabaseContentToMedia.java | 6 +-
.../mircoders/storage/DatabaseContentToTopics.java | 15 +-
source/mircoders/storage/DatabaseFilter.java | 115 +-
source/mircoders/storage/DatabaseFilterGroup.java | 113 +-
source/mircoders/storage/DatabaseImageColor.java | 1 -
source/mircoders/storage/DatabaseImageFormat.java | 1 -
source/mircoders/storage/DatabaseImageLayout.java | 1 -
source/mircoders/storage/DatabaseImageType.java | 1 -
source/mircoders/storage/DatabaseImages.java | 1 -
source/mircoders/storage/DatabaseLanguage.java | 7 +-
source/mircoders/storage/DatabaseMediaType.java | 1 -
source/mircoders/storage/DatabaseMediafolder.java | 1 -
source/mircoders/storage/DatabaseMessages.java | 1 -
source/mircoders/storage/DatabaseOther.java | 1 -
source/mircoders/storage/DatabaseRights.java | 1 -
source/mircoders/storage/DatabaseTopics.java | 7 +-
.../mircoders/storage/DatabaseUploadedMedia.java | 1 -
source/mircoders/storage/DatabaseUsers.java | 1 -
source/mircoders/storage/DatabaseVideo.java | 1 -
source/tool/BundleTool.java | 1 -
source/tool/ImageTool.java | 1 -
200 files changed, 4358 insertions(+), 4226 deletions(-)
diff --git a/source/Mir.java b/source/Mir.java
index 515d1ee1..8d291125 100755
--- a/source/Mir.java
+++ b/source/Mir.java
@@ -28,28 +28,43 @@
* If you do not wish to do so, delete this exception statement from your version.
*/
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.UnavailableException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.http.HttpSessionBindingListener;
+
import mir.bundle.Bundle;
import mir.config.MirPropertiesConfiguration;
-import mir.servlet.*;
+import mir.log.LoggerWrapper;
+import mir.servlet.AbstractServlet;
+import mir.servlet.ServletModule;
+import mir.servlet.ServletModuleDispatch;
+import mir.servlet.ServletModuleExc;
+import mir.servlet.ServletModuleUserExc;
import mir.util.ExceptionFunctions;
import mir.util.StringRoutines;
-import mir.log.LoggerWrapper;
import mircoders.entity.EntityUsers;
import mircoders.global.MirGlobal;
import mircoders.module.ModuleUsers;
import mircoders.servlet.ServletHelper;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.UnavailableException;
-import javax.servlet.http.*;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.PrintStream;
-import java.io.StringWriter;
-import java.lang.reflect.Method;
-import java.util.*;
-
import multex.Failure;
/**
@@ -279,9 +294,7 @@ public class Mir extends AbstractServlet {
throw new ServletModuleExc("*** error resolving classname for " + moduleName + " -- " + e.getMessage());
}
}
- else {
- return (ServletModule) servletModuleInstanceHash.get(moduleName);
- }
+ return (ServletModule) servletModuleInstanceHash.get(moduleName);
}
private void handleUserError(HttpServletRequest aRequest, HttpServletResponse aResponse, ServletModuleUserExc anException) {
diff --git a/source/mir/bundle/CascadingBundleFactory.java b/source/mir/bundle/CascadingBundleFactory.java
index b3a9920e..b50ae089 100755
--- a/source/mir/bundle/CascadingBundleFactory.java
+++ b/source/mir/bundle/CascadingBundleFactory.java
@@ -34,7 +34,7 @@ import java.util.Arrays;
import java.util.List;
public class CascadingBundleFactory implements BundleFactory {
- private BundleFactory masterFactory;
+ BundleFactory masterFactory;
/** {@inheritDoc} */
public CascadingBundleFactory(BundleFactory aMasterFactory) {
diff --git a/source/mir/bundle/PropertiesBundle.java b/source/mir/bundle/PropertiesBundle.java
index a7952852..0409df80 100755
--- a/source/mir/bundle/PropertiesBundle.java
+++ b/source/mir/bundle/PropertiesBundle.java
@@ -29,9 +29,9 @@
*/
package mir.bundle;
-import java.util.Properties;
-import java.util.List;
import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
import mir.util.StringParseRoutines;
@@ -78,7 +78,6 @@ public class PropertiesBundle implements Bundle {
if (result==null || result.trim().length()==0)
return null;
- else
- return formatValue(result, anArguments);
+ return formatValue(result, anArguments);
}
}
diff --git a/source/mir/bundle/PropertiesFileBundleLoader.java b/source/mir/bundle/PropertiesFileBundleLoader.java
index 5e889765..39801244 100755
--- a/source/mir/bundle/PropertiesFileBundleLoader.java
+++ b/source/mir/bundle/PropertiesFileBundleLoader.java
@@ -30,8 +30,8 @@
package mir.bundle;
import java.io.File;
-import java.io.IOException;
import java.io.FileInputStream;
+import java.io.IOException;
import java.util.Properties;
/**
diff --git a/source/mir/config/MirPropertiesConfiguration.java b/source/mir/config/MirPropertiesConfiguration.java
index 80ece216..198ff3ab 100755
--- a/source/mir/config/MirPropertiesConfiguration.java
+++ b/source/mir/config/MirPropertiesConfiguration.java
@@ -34,10 +34,12 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+
import javax.servlet.ServletContext;
import multex.Exc;
import multex.Failure;
+
import org.apache.commons.collections.ExtendedProperties;
/**
@@ -149,9 +151,7 @@ public class MirPropertiesConfiguration extends ExtendedProperties {
if (result.isAbsolute()) {
return result;
}
- else {
- return new File(home, path);
- }
+ return new File(home, path);
}
/**
diff --git a/source/mir/entity/AbstractEntity.java b/source/mir/entity/AbstractEntity.java
index 72e98ec3..ee350740 100755
--- a/source/mir/entity/AbstractEntity.java
+++ b/source/mir/entity/AbstractEntity.java
@@ -36,15 +36,15 @@ import java.util.Map;
import mir.config.MirPropertiesConfiguration;
import mir.log.LoggerWrapper;
+import mir.storage.Database;
import mir.storage.StorageObjectExc;
import mir.storage.StorageObjectFailure;
-import mir.storage.Database;
/**
* Base class the entities are derived from. Provides base functionality of
* an entity.
*
- * @version $Id: AbstractEntity.java,v 1.8.2.5 2005/01/23 15:36:02 zapata Exp $
+ * @version $Id: AbstractEntity.java,v 1.8.2.6 2005/02/10 16:22:30 rhindes Exp $
*/
public class AbstractEntity implements Entity {
@@ -95,8 +95,7 @@ public class AbstractEntity implements Entity {
if (database != null) {
return database.insert(this);
}
- else
- throw new StorageObjectExc("database == null!");
+ throw new StorageObjectExc("database == null!");
}
/** {@inheritDoc} */
diff --git a/source/mir/entity/Entity.java b/source/mir/entity/Entity.java
index cac1e44a..df2cb9a4 100755
--- a/source/mir/entity/Entity.java
+++ b/source/mir/entity/Entity.java
@@ -29,17 +29,17 @@
*/
package mir.entity;
-import mir.storage.StorageObjectExc;
-import mir.storage.StorageObjectFailure;
-
import java.util.List;
import java.util.Map;
+import mir.storage.StorageObjectExc;
+import mir.storage.StorageObjectFailure;
+
/**
* An Entity
represents a persistent data object, typically
* stored in a database.
*
- * @version $Id: Entity.java,v 1.21.2.10 2005/01/23 15:36:02 zapata Exp $
+ * @version $Id: Entity.java,v 1.21.2.11 2005/02/10 16:22:30 rhindes Exp $
*/
public interface Entity {
diff --git a/source/mir/entity/EntityBrowser.java b/source/mir/entity/EntityBrowser.java
index c51d9c94..7d42057f 100755
--- a/source/mir/entity/EntityBrowser.java
+++ b/source/mir/entity/EntityBrowser.java
@@ -30,12 +30,11 @@
package mir.entity;
+import java.util.List;
+
import mir.storage.Database;
import mir.storage.StorageObjectFailure;
import mir.util.RewindableIterator;
-
-import java.util.List;
-
import multex.Failure;
public class EntityBrowser implements RewindableIterator {
@@ -121,9 +120,7 @@ public class EntityBrowser implements RewindableIterator {
return result;
}
- else {
- return null;
- }
+ return null;
}
catch (Throwable t) {
throw new RuntimeException(t.getMessage());
diff --git a/source/mir/entity/EntityList.java b/source/mir/entity/EntityList.java
index 7e3cc85f..700d85d8 100755
--- a/source/mir/entity/EntityList.java
+++ b/source/mir/entity/EntityList.java
@@ -29,6 +29,9 @@
*/
package mir.entity;
+import java.util.ArrayList;
+import java.util.Set;
+
import mir.config.MirPropertiesConfiguration;
import mir.log.LoggerWrapper;
import mir.storage.Database;
@@ -37,9 +40,6 @@ import mir.storage.store.StoreContainerType;
import mir.storage.store.StoreIdentifier;
import mir.storage.store.StoreUtil;
-import java.util.ArrayList;
-import java.util.Set;
-
/**
*
* Container class for lists of Entities.
@@ -205,11 +205,9 @@ public class EntityList implements StorableObject {
StoreUtil.getEntityListUniqueIdentifierFor( storage.getTableName(),
whereClause, orderClause, offset, limit ));
}
- else {
- logger.warn("EntityList could not return StoreIdentifier");
-
- return null;
- }
+ logger.warn("EntityList could not return StoreIdentifier");
+
+ return null;
}
}
diff --git a/source/mir/entity/StorableObjectEntity.java b/source/mir/entity/StorableObjectEntity.java
index 8749bc2d..3f2d6270 100755
--- a/source/mir/entity/StorableObjectEntity.java
+++ b/source/mir/entity/StorableObjectEntity.java
@@ -68,9 +68,8 @@ public class StorableObjectEntity extends AbstractEntity
Class theEntityClass, String theTable, String id) {
if (id == null) {
return null;
- } else {
- return new StoreIdentifier(theEntityClass, id + "@" + theTable);
}
+ return new StoreIdentifier(theEntityClass, id + "@" + theTable);
}
public static final StoreIdentifier getStoreIdentifier(Database theStorage,
diff --git a/source/mir/entity/adapter/EntityAdapter.java b/source/mir/entity/adapter/EntityAdapter.java
index ee997e27..0006328d 100755
--- a/source/mir/entity/adapter/EntityAdapter.java
+++ b/source/mir/entity/adapter/EntityAdapter.java
@@ -175,8 +175,7 @@ public class EntityAdapter implements Map {
if (i.hasNext())
return (EntityAdapter) i.next();
- else
- return null;
+ return null;
}
catch (Throwable t) {
throw new RuntimeException(t.getMessage());
@@ -191,8 +190,7 @@ public class EntityAdapter implements Map {
if (i.hasNext())
return (EntityAdapter) i.next();
- else
- return null;
+ return null;
}
catch (Throwable t) {
throw new RuntimeException(t.getMessage());
diff --git a/source/mir/entity/adapter/EntityAdapterDefinition.java b/source/mir/entity/adapter/EntityAdapterDefinition.java
index 571df52e..9c95ab37 100755
--- a/source/mir/entity/adapter/EntityAdapterDefinition.java
+++ b/source/mir/entity/adapter/EntityAdapterDefinition.java
@@ -75,7 +75,7 @@ public class EntityAdapterDefinition {
/**
*
* @param aFieldName
- * @return
+ * @return boolean true if aFieldName is a calculated Field
*/
public boolean hasCalculatedField(String aFieldName) {
return calculatedFields.containsKey(aFieldName);
diff --git a/source/mir/entity/adapter/EntityAdapterModel.java b/source/mir/entity/adapter/EntityAdapterModel.java
index 0c0a0940..b840bc66 100755
--- a/source/mir/entity/adapter/EntityAdapterModel.java
+++ b/source/mir/entity/adapter/EntityAdapterModel.java
@@ -29,12 +29,12 @@
*/
package mir.entity.adapter;
-import mir.entity.Entity;
-import mir.storage.Database;
-
import java.util.HashMap;
import java.util.Map;
+import mir.entity.Entity;
+import mir.storage.Database;
+
public class EntityAdapterModel {
private Map entityAdapterMappings;
diff --git a/source/mir/entity/adapter/EntityIteratorAdapter.java b/source/mir/entity/adapter/EntityIteratorAdapter.java
index fbc6a01b..967809bb 100755
--- a/source/mir/entity/adapter/EntityIteratorAdapter.java
+++ b/source/mir/entity/adapter/EntityIteratorAdapter.java
@@ -81,5 +81,5 @@ public class EntityIteratorAdapter implements RewindableIterator {
public void rewind() {
iterator.rewind();
- };
+ }
}
diff --git a/source/mir/generator/CompositeGeneratorLibrary.java b/source/mir/generator/CompositeGeneratorLibrary.java
index 324363fc..1f4ce63a 100755
--- a/source/mir/generator/CompositeGeneratorLibrary.java
+++ b/source/mir/generator/CompositeGeneratorLibrary.java
@@ -66,11 +66,8 @@ public class CompositeGeneratorLibrary implements Generator.Library {
return library.makeGenerator(qualifier);
}
- else {
- if (defaultLibrary!=null)
- return defaultLibrary.makeGenerator(anIdentifier);
- else
- throw new GeneratorExc("CompositeGeneratorLibrary: no default library speficied");
- }
- };
+ if (defaultLibrary!=null)
+ return defaultLibrary.makeGenerator(anIdentifier);
+ throw new GeneratorExc("CompositeGeneratorLibrary: no default library speficied");
+ }
}
\ No newline at end of file
diff --git a/source/mir/generator/FreemarkerGenerator.java b/source/mir/generator/FreemarkerGenerator.java
index b774a1d8..576442a3 100755
--- a/source/mir/generator/FreemarkerGenerator.java
+++ b/source/mir/generator/FreemarkerGenerator.java
@@ -29,8 +29,8 @@
*/
package mir.generator;
-import java.io.PrintWriter;
import java.io.File;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@@ -38,6 +38,13 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import mir.log.LoggerWrapper;
+import mir.util.GeneratorFormatAdapters;
+import mir.util.RewindableIterator;
+
+import org.apache.commons.beanutils.MethodUtils;
+import org.apache.commons.beanutils.PropertyUtils;
+
import freemarker.template.FileTemplateCache;
import freemarker.template.SimpleScalar;
import freemarker.template.Template;
@@ -48,11 +55,6 @@ import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
import freemarker.template.TemplateModelRoot;
import freemarker.template.TemplateScalarModel;
-import mir.log.LoggerWrapper;
-import mir.util.GeneratorFormatAdapters;
-import mir.util.RewindableIterator;
-import org.apache.commons.beanutils.MethodUtils;
-import org.apache.commons.beanutils.PropertyUtils;
public class FreemarkerGenerator implements Generator {
@@ -198,7 +200,7 @@ public class FreemarkerGenerator implements Generator {
{
valuesCache.add(makeAdapter(iterator.next()));
}
- };
+ }
public TemplateModel get(int anIndex) throws TemplateModelException {
TemplateModel result;
@@ -211,8 +213,7 @@ public class FreemarkerGenerator implements Generator {
return result;
}
- else
- throw new TemplateModelException( "Iterator out of bounds" );
+ throw new TemplateModelException( "Iterator out of bounds" );
}
public boolean hasNext() {
@@ -266,8 +267,8 @@ public class FreemarkerGenerator implements Generator {
if (i>>ERROR POSITION<<< ");
- }
- catch (Throwable s) {
- throw new TemplateProcessingException(s);
- }
- }
- finally {
- aDestination.append(destination);
- }
- }
- else {
- outerProcess(aParser, aContext, aDestination, aLogger, aTemplateContext, aLibrary);
- }
- }
-
- public String getPlainText() {
- return body.getPlainText();
- }
-
- public void outerProcess(TALExpressionParser aParser, Object aContext,
- StringBuffer aDestination, TALLogger aLogger, Map aTemplateContext,
- TemplateLibrary aLibrary) throws TemplateProcessingException {
-
- Object oldAttributes = aParser.evaluatePseudoVariable(aContext, "tagattributes");
- aParser.processPseudoAssignment(aContext, "tagattributes", Collections.unmodifiableMap(fixedAttributes));
-
- Object oldContent = aParser.evaluatePseudoVariable(aContext, "tagcontent");
- aParser.processPseudoAssignment(aContext, "tagcontent", body.getPlainText());
-
- try {
- Iterator i;
-
- i = definitions.iterator();
- while (i.hasNext()) {
- Definition d = (Definition) i.next();
- aParser.processAssignment(aContext, d.getVariable(), d.getExpression());
- }
-
- if (condition == null || aParser.evaluateBooleanExpression(aContext, condition)) {
- if (repeatExpression != null) {
- i = aParser.evaluateListExpression(aContext, repeatExpression);
-
- while (i.hasNext()) {
- aParser.processDirectAssignment(aContext, repeatVariable, i.next());
- innerProcess(aParser, aContext, aDestination, aLogger, aTemplateContext, aLibrary);
- }
- }
- else {
- innerProcess(aParser, aContext, aDestination, aLogger, aTemplateContext, aLibrary);
- }
- }
- }
- finally {
- try {
- aParser.processPseudoAssignment(aContext, "tagattributes", oldAttributes);
- aParser.processPseudoAssignment(aContext, "tagcontent", oldContent);
- }
- catch (Throwable t) {
- }
- }
- };
-
- private void innerProcess(TALExpressionParser aParser, Object aContext,
- StringBuffer aDestination, TALLogger aLogger, Map aTemplateContext, TemplateLibrary aLibrary)
- throws TemplateProcessingException {
-
- boolean omitTag = false;
- StringBuffer content = aDestination;
-
- if (omitTagExpression != null)
- omitTag = aParser.evaluateBooleanExpression(aContext, omitTagExpression);
-
- if (!omitTag) {
- content = new StringBuffer();
- Map generatedAttributes = new HashMap(fixedAttributes);
-
- Iterator i = attributeModifiers.entrySet().iterator();
- while (i.hasNext()) {
- Map.Entry entry = (Map.Entry) i.next();
-
- generatedAttributes.put(entry.getKey(), aParser.evaluateStringExpression(aContext, entry.getValue()));
- }
-
- aDestination.append("<");
- aDestination.append(tag);
-
- i = generatedAttributes.entrySet().iterator();
- while (i.hasNext()) {
- Map.Entry entry = (Map.Entry) i.next();
- aDestination.append(" ");
- aDestination.append(entry.getKey());
- aDestination.append("=");
- aDestination.append("\"");
- aDestination.append(HTMLRoutines.encodeHTML( (String) entry.getValue()));
- aDestination.append("\"");
- }
- }
-
- try{
- if (contentExpression != null) {
- content.append(aParser.evaluateStringExpression(aContext, contentExpression));
- }
- else {
- if (body != null) {
- body.process(aParser, aContext, content, aLogger, aTemplateContext, aLibrary);
- }
- }
- if (!omitTag) {
- if (content.length()==0) {
- aDestination.append(" />");
- }
- else {
- aDestination.append(">");
- aDestination.append(content);
- aDestination.append("");
- aDestination.append(tag);
- aDestination.append(">");
- }
- }
- }
- catch (Throwable t) {
- if (!omitTag) {
- aDestination.append(content);
- }
-
- if (t instanceof TemplateProcessingException) {
- throw (TemplateProcessingException) t;
- }
- else if (t instanceof RuntimeException) {
- throw (RuntimeException) t;
- }
- else throw new TemplateProcessingException(t.toString());
- }
- }
- }
-}
+/*
+ * Copyright (C) 2001, 2002 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+
+package mir.generator.tal.template;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import mir.generator.tal.interfaces.TALExpressionParser;
+import mir.generator.tal.interfaces.TALLogger;
+import mir.util.HTMLRoutines;
+import mir.util.StringRoutines;
+import mir.util.xml.XMLName;
+import mir.util.xml.XMLParserExc;
+import mir.util.xml.XMLReaderTool;
+
+public class CoreTemplateNodeLibrary implements TemplateNodeLibrary {
+ private String prefix;
+ private String uri;
+
+ private boolean isOurTag(XMLName aName) {
+ return prefix.equals(aName.getPrefix()) || uri.equals(aName.getNamespaceURI());
+ }
+
+ public CoreTemplateNodeLibrary(String aPrefix, String aUri) {
+ prefix = aPrefix;
+ uri = aUri;
+ }
+
+ private static final String CONDITION_ATTRIBUTE = "condition";
+ private static final String REPEAT_ATTRIBUTE = "repeat";
+ private static final String CONTENT_ATTRIBUTE = "content";
+ private static final String ERROR_ATTRIBUTE = "on-error";
+ private static final String REPLACE_ATTRIBUTE = "replace";
+ private static final String DEFINITION_ATTRIBUTE = "define";
+ private static final String OMITTAG_ATTRIBUTE = "omit-tag";
+ private static final String ATTRIBUTE_ATTRIBUTE = "attributes";
+
+ public TemplateNode constructTemplateNode(TALExpressionParser aParser, XMLName aTag, Map anAttributes,
+ TemplateNode aChildTemplateNode, Map aTemplateContext) throws XMLParserExc {
+ TALBasicTemplateNode result = new TALBasicTemplateNode(XMLReaderTool.normalizeXMLName(aTag));
+ result.setBody(aChildTemplateNode);
+
+ if (isOurTag(aTag))
+ result.setOmitTag(aParser.preparseTRUE());
+
+ Iterator i = anAttributes.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry entry = (Map.Entry) i.next();
+ XMLName name = (XMLName) entry.getKey();
+
+ if (!isOurTag(name)) {
+ result.addFixedAttribute(XMLReaderTool.normalizeXMLName(name), (String) entry.getValue());
+ }
+ else {
+ if (name.getLocalName().equalsIgnoreCase(DEFINITION_ATTRIBUTE)) {
+ List definitions = StringRoutines.splitStringWithEscape((String) entry.getValue(), ';', '\\');
+
+ Iterator j = definitions.iterator();
+ while (j.hasNext())
+ {
+ List parts = StringRoutines.separateString((String) j.next(), " ");
+
+ if (parts.size()==2) {
+ result.addDefinition(aParser.preparseReferenceExpression((String) parts.get(0)), aParser.preparseExpression((String) parts.get(1)));
+ }
+ }
+ }
+ else if (name.getLocalName().equalsIgnoreCase(CONDITION_ATTRIBUTE)) {
+ result.setCondition(aParser.preparseBooleanExpression((String) entry.getValue()));
+ }
+ else if (name.getLocalName().equalsIgnoreCase(CONTENT_ATTRIBUTE)) {
+ result.setContent(aParser.preparseStringExpression((String) entry.getValue()));
+ }
+ else if (name.getLocalName().equalsIgnoreCase(ERROR_ATTRIBUTE)) {
+ result.setError(aParser.preparseStringExpression((String) entry.getValue()));
+ }
+ else if (name.getLocalName().equalsIgnoreCase(OMITTAG_ATTRIBUTE)) {
+ if (((String) entry.getValue()).trim().length()==0)
+ result.setOmitTag(aParser.preparseTRUE());
+ else
+ result.setOmitTag(aParser.preparseBooleanExpression((String) entry.getValue()));
+ }
+ else if (name.getLocalName().equalsIgnoreCase(REPLACE_ATTRIBUTE)) {
+ result.setOmitTag(aParser.preparseTRUE());
+ result.setContent(aParser.preparseStringExpression((String) entry.getValue()));
+ }
+ else if (name.getLocalName().equalsIgnoreCase(REPEAT_ATTRIBUTE)) {
+ List parts = StringRoutines.separateString((String) entry.getValue(), " ");
+
+ if (parts.size()==2) {
+ result.setRepeat(aParser.preparseReferenceExpression((String) parts.get(0)), aParser.preparseExpression((String) parts.get(1)));
+ }
+ }
+ else if (name.getLocalName().equalsIgnoreCase(ATTRIBUTE_ATTRIBUTE)) {
+ List attributes = StringRoutines.splitStringWithEscape((String) entry.getValue(), ';', '\\');
+
+ Iterator j = attributes.iterator();
+ while (j.hasNext()) {
+ String value = (String) j.next();
+ List parts = StringRoutines.separateString(value.trim(), " ");
+
+ if (parts.size()==2) {
+ result.addModifiedAttribute((String) parts.get(0), aParser.preparseExpression((String) parts.get(1)));
+ }
+ else {
+ throw new XMLParserExc(ATTRIBUTE_ATTRIBUTE + " tag should have exactly 2 parts ("+value+")");
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public static class TALBasicTemplateNode implements TemplateNode {
+ private String tag;
+ private Map fixedAttributes;
+ private Map attributeModifiers;
+
+ private List definitions;
+ private Object condition;
+
+ private Object repeatVariable;
+ private Object repeatExpression;
+ private Object contentExpression;
+ private Object omitTagExpression;
+ private Object errorExpression;
+
+ private TemplateNode body;
+
+ public TALBasicTemplateNode(String aTag) {
+ tag = aTag;
+
+ fixedAttributes = new HashMap();
+ attributeModifiers = new HashMap();
+
+ definitions = new ArrayList();
+ condition = null;
+
+ repeatVariable = null;
+ repeatExpression = null;
+ contentExpression = null;
+ omitTagExpression = null;
+
+ body = null;
+ }
+
+ public void setBody(TemplateNode aBody) {
+ body = aBody;
+ }
+
+ public void addFixedAttribute(String aKey, String aValue) {
+ fixedAttributes.put(aKey, aValue);
+ }
+
+ public void addModifiedAttribute(String aKey, Object aValue) {
+ attributeModifiers.put(aKey, aValue);
+ }
+
+ public void addDefinition(Object aKey, Object aValue) {
+ definitions.add(new Definition(aKey, aValue));
+ }
+
+ public void setCondition(Object aCondition) {
+ condition = aCondition;
+ }
+
+ public void setRepeat(Object aRepeatVariable, Object aRepeatExpression) {
+ repeatVariable = aRepeatVariable;
+ repeatExpression = aRepeatExpression;
+ }
+
+ public void setContent(Object aContentExpression) {
+ contentExpression = aContentExpression;
+ }
+
+ public void setOmitTag(Object anOmitTagExpression) {
+ omitTagExpression = anOmitTagExpression;
+ }
+
+ public void setError(Object anErrorExpression) {
+ errorExpression = anErrorExpression;
+ }
+
+ public static class Definition {
+ private Object variable;
+ private Object expression;
+
+ public Definition(Object aVariable, Object anExpression) {
+ variable = aVariable;
+ expression = anExpression;
+ }
+
+ public Object getVariable() {
+ return variable;
+ }
+
+ public Object getExpression() {
+ return expression;
+ }
+ }
+
+ public void process(TALExpressionParser aParser, Object aContext,
+ StringBuffer aDestination, TALLogger aLogger, Map aTemplateContext,
+ TemplateLibrary aLibrary) throws TemplateProcessingException {
+ if (errorExpression != null) {
+ StringBuffer destination = new StringBuffer();
+
+ try {
+ outerProcess(aParser, aContext, destination, aLogger, aTemplateContext, aLibrary);
+ }
+ catch (Throwable t) {
+ try {
+// destination.delete(0, destination.length());
+ aParser.processPseudoAssignment(aContext, "exception", t);
+ destination.insert(0, aParser.evaluateStringExpression(aContext, errorExpression));
+ destination.append(" >>>ERROR POSITION<<< ");
+ }
+ catch (Throwable s) {
+ throw new TemplateProcessingException(s);
+ }
+ }
+ finally {
+ aDestination.append(destination);
+ }
+ }
+ else {
+ outerProcess(aParser, aContext, aDestination, aLogger, aTemplateContext, aLibrary);
+ }
+ }
+
+ public String getPlainText() {
+ return body.getPlainText();
+ }
+
+ public void outerProcess(TALExpressionParser aParser, Object aContext,
+ StringBuffer aDestination, TALLogger aLogger, Map aTemplateContext,
+ TemplateLibrary aLibrary) throws TemplateProcessingException {
+
+ Object oldAttributes = aParser.evaluatePseudoVariable(aContext, "tagattributes");
+ aParser.processPseudoAssignment(aContext, "tagattributes", Collections.unmodifiableMap(fixedAttributes));
+
+ Object oldContent = aParser.evaluatePseudoVariable(aContext, "tagcontent");
+ aParser.processPseudoAssignment(aContext, "tagcontent", body.getPlainText());
+
+ try {
+ Iterator i;
+
+ i = definitions.iterator();
+ while (i.hasNext()) {
+ Definition d = (Definition) i.next();
+ aParser.processAssignment(aContext, d.getVariable(), d.getExpression());
+ }
+
+ if (condition == null || aParser.evaluateBooleanExpression(aContext, condition)) {
+ if (repeatExpression != null) {
+ i = aParser.evaluateListExpression(aContext, repeatExpression);
+
+ while (i.hasNext()) {
+ aParser.processDirectAssignment(aContext, repeatVariable, i.next());
+ innerProcess(aParser, aContext, aDestination, aLogger, aTemplateContext, aLibrary);
+ }
+ }
+ else {
+ innerProcess(aParser, aContext, aDestination, aLogger, aTemplateContext, aLibrary);
+ }
+ }
+ }
+ finally {
+ try {
+ aParser.processPseudoAssignment(aContext, "tagattributes", oldAttributes);
+ aParser.processPseudoAssignment(aContext, "tagcontent", oldContent);
+ }
+ catch (Throwable t) {
+ }
+ }
+ }
+
+ private void innerProcess(TALExpressionParser aParser, Object aContext,
+ StringBuffer aDestination, TALLogger aLogger, Map aTemplateContext, TemplateLibrary aLibrary)
+ throws TemplateProcessingException {
+
+ boolean omitTag = false;
+ StringBuffer content = aDestination;
+
+ if (omitTagExpression != null)
+ omitTag = aParser.evaluateBooleanExpression(aContext, omitTagExpression);
+
+ if (!omitTag) {
+ content = new StringBuffer();
+ Map generatedAttributes = new HashMap(fixedAttributes);
+
+ Iterator i = attributeModifiers.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry entry = (Map.Entry) i.next();
+
+ generatedAttributes.put(entry.getKey(), aParser.evaluateStringExpression(aContext, entry.getValue()));
+ }
+
+ aDestination.append("<");
+ aDestination.append(tag);
+
+ i = generatedAttributes.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry entry = (Map.Entry) i.next();
+ aDestination.append(" ");
+ aDestination.append(entry.getKey());
+ aDestination.append("=");
+ aDestination.append("\"");
+ aDestination.append(HTMLRoutines.encodeHTML( (String) entry.getValue()));
+ aDestination.append("\"");
+ }
+ }
+
+ try{
+ if (contentExpression != null) {
+ content.append(aParser.evaluateStringExpression(aContext, contentExpression));
+ }
+ else {
+ if (body != null) {
+ body.process(aParser, aContext, content, aLogger, aTemplateContext, aLibrary);
+ }
+ }
+ if (!omitTag) {
+ if (content.length()==0) {
+ aDestination.append(" />");
+ }
+ else {
+ aDestination.append(">");
+ aDestination.append(content);
+ aDestination.append("");
+ aDestination.append(tag);
+ aDestination.append(">");
+ }
+ }
+ }
+ catch (Throwable t) {
+ if (!omitTag) {
+ aDestination.append(content);
+ }
+
+ if (t instanceof TemplateProcessingException) {
+ throw (TemplateProcessingException) t;
+ }
+ else if (t instanceof RuntimeException) {
+ throw (RuntimeException) t;
+ }
+ else throw new TemplateProcessingException(t.toString());
+ }
+ }
+ }
+}
diff --git a/source/mir/generator/tal/template/MacroTemplateNodeLibrary.java b/source/mir/generator/tal/template/MacroTemplateNodeLibrary.java
index 1310c7ba..fce8d8eb 100755
--- a/source/mir/generator/tal/template/MacroTemplateNodeLibrary.java
+++ b/source/mir/generator/tal/template/MacroTemplateNodeLibrary.java
@@ -29,18 +29,18 @@
*/
package mir.generator.tal.template;
-import java.util.Map;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.HashMap;
+import java.util.Map;
import mir.generator.tal.interfaces.TALExpressionParser;
import mir.generator.tal.interfaces.TALLogger;
+import mir.util.HTMLRoutines;
+import mir.util.StringRoutines;
import mir.util.xml.XMLName;
import mir.util.xml.XMLParserExc;
import mir.util.xml.XMLReaderTool;
-import mir.util.StringRoutines;
-import mir.util.HTMLRoutines;
public class MacroTemplateNodeLibrary implements TemplateNodeLibrary {
/** {@inheritDoc} */
diff --git a/source/mir/generator/tal/template/TemplateNodeLibrary.java b/source/mir/generator/tal/template/TemplateNodeLibrary.java
index bdb85459..de57d158 100755
--- a/source/mir/generator/tal/template/TemplateNodeLibrary.java
+++ b/source/mir/generator/tal/template/TemplateNodeLibrary.java
@@ -1,49 +1,49 @@
-/*
- * Copyright (C) 2001, 2002 The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your version.
- */
-package mir.generator.tal.template;
-
-import java.util.Map;
-
-import mir.util.xml.XMLName;
-import mir.util.xml.XMLParserExc;
-import mir.generator.tal.interfaces.TALExpressionParser;
-
-public interface TemplateNodeLibrary {
- /**
- * Construct a {@link TemplateNode} based on the tag and attributes given.
- *
- * @param anExpressionParser
- * @param aTag
- * @param anAttributes
- * @param aChildTemplateNode
- */
- public TemplateNode constructTemplateNode(TALExpressionParser anExpressionParser,
- XMLName aTag, Map anAttributes, TemplateNode aChildTemplateNode, Map aTemplateContext) throws XMLParserExc;
-}
+/*
+ * Copyright (C) 2001, 2002 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.generator.tal.template;
+
+import java.util.Map;
+
+import mir.generator.tal.interfaces.TALExpressionParser;
+import mir.util.xml.XMLName;
+import mir.util.xml.XMLParserExc;
+
+public interface TemplateNodeLibrary {
+ /**
+ * Construct a {@link TemplateNode} based on the tag and attributes given.
+ *
+ * @param anExpressionParser
+ * @param aTag
+ * @param anAttributes
+ * @param aChildTemplateNode
+ */
+ public TemplateNode constructTemplateNode(TALExpressionParser anExpressionParser,
+ XMLName aTag, Map anAttributes, TemplateNode aChildTemplateNode, Map aTemplateContext) throws XMLParserExc;
+}
diff --git a/source/mir/log/LoggerToWriterAdapter.java b/source/mir/log/LoggerToWriterAdapter.java
index 018547d5..f7eab509 100755
--- a/source/mir/log/LoggerToWriterAdapter.java
+++ b/source/mir/log/LoggerToWriterAdapter.java
@@ -73,7 +73,7 @@ public class LoggerToWriterAdapter extends Writer {
}
lineBuffer.delete(0, from);
- };
+ }
public void write(char[] aBuffer, int anOffset, int aLength) {
lineBuffer.append(aBuffer, anOffset, aLength);
diff --git a/source/mir/log/LoggerWrapper.java b/source/mir/log/LoggerWrapper.java
index 749d9d23..436ed960 100755
--- a/source/mir/log/LoggerWrapper.java
+++ b/source/mir/log/LoggerWrapper.java
@@ -46,31 +46,31 @@ public class LoggerWrapper {
public void debug( String aMessage ) {
LoggerEngine.debug(object, aMessage);
- };
+ }
public void info( String aMessage ) {
LoggerEngine.info(object, aMessage);
- };
+ }
public void warn( String aMessage ) {
LoggerEngine.warn(object, aMessage);
- };
+ }
public void warn(String aMessage, Throwable anException) {
LoggerEngine.warn(object, aMessage, anException);
- };
+ }
public void error( String aMessage ) {
LoggerEngine.error(object, aMessage);
- };
+ }
public void error(String aMessage, Throwable anException) {
LoggerEngine.error(object, aMessage, anException);
- };
+ }
public void fatal( String aMessage ) {
LoggerEngine.fatal(object, aMessage);
- };
+ }
public void message( int aType, String aMessage) {
switch(aType) {
diff --git a/source/mir/log/log4j/LoggerImpl.java b/source/mir/log/log4j/LoggerImpl.java
index 99414998..582854d0 100755
--- a/source/mir/log/log4j/LoggerImpl.java
+++ b/source/mir/log/log4j/LoggerImpl.java
@@ -35,6 +35,7 @@ import java.util.Map;
import mir.config.MirPropertiesConfiguration;
import mir.log.LoggerExc;
import mir.log.LoggerFailure;
+
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
diff --git a/source/mir/misc/FileUtil.java b/source/mir/misc/FileUtil.java
index 688d9514..9226914b 100755
--- a/source/mir/misc/FileUtil.java
+++ b/source/mir/misc/FileUtil.java
@@ -160,14 +160,7 @@ public final class FileUtil {
public static long getSize(String filename) {
File f = null;
f = new File(filename);
- long l = 0;
-
- if (f.exists()) {
- return f.length();
- }
- else {
- return -1;
- }
+ return f.exists() ? f.length():-1;
}
}
diff --git a/source/mir/misc/StringUtil.java b/source/mir/misc/StringUtil.java
index f9c996a7..b05c748f 100755
--- a/source/mir/misc/StringUtil.java
+++ b/source/mir/misc/StringUtil.java
@@ -41,7 +41,7 @@ import java.util.TimeZone;
/**
* Statische Hilfsmethoden zur Stringbehandlung
*
- * @version $Id: StringUtil.java,v 1.33.2.5 2003/10/23 14:55:28 rk Exp $
+ * @version $Id: StringUtil.java,v 1.33.2.6 2005/02/10 16:22:30 rhindes Exp $
* @author mir-coders group
*
*/
@@ -195,11 +195,11 @@ public final class StringUtil {
}
/**
- * Ersetzt in String s
das Regexp pattern
durch substitute
- * @param s
+ * Replaces in haystack
matching pattern
by substitute
+ * @param haystack
* @param pattern
* @param substitute
- * @return String mit den Ersetzungen
+ * @return String with replacements.
*/
public static String regexpReplace(String haystack, String pattern, String substitute) {
try {
@@ -305,28 +305,27 @@ public final class StringUtil {
/**
* this routine takes text in url format and makes
* a clickaeble "" link removing any "illegal" html tags
- * @param haystack, the url
- * @param title, the href link text
- * @param imagRoot, the place to find icons
- * @param extImage, the url of the icon to show next to the link
+ * @param haystack the url
+ * @param title the href link text
+ * @param imageRoot the place to find icons
+ * @param extImage the url of the icon to show next to the link
* @return a String containing the url
*/
public static String createURLLinks(String haystack, String title, String imageRoot,String extImage) {
if (title == null) {
return re_url.substituteAll(haystack," $0");
- } else {
- title = removeHTMLTags(title);
- return re_url.substituteAll(haystack," "+title+"");
}
+ title = removeHTMLTags(title);
+ return re_url.substituteAll(haystack," "+title+"");
}
/**
* this routine takes text in url format and makes
* a clickaeble "" link removing any "illegal" html tags
- * @param haystack, the url
- * @param imageRoot, the place to find icons
- * @param extImage, the url of the icon to show next to the link
- * @param intImage, unused
+ * @param haystack the url
+ * @param imageRoot the place to find icons
+ * @param extImage the url of the icon to show next to the link
+ * @param intImage unused
* @return a String containing the url
*/
public static String createURLLinks(String haystack, String title, String imageRoot,String extImage,String intImage) {
diff --git a/source/mir/module/AbstractModule.java b/source/mir/module/AbstractModule.java
index 490a50d5..4b38727b 100755
--- a/source/mir/module/AbstractModule.java
+++ b/source/mir/module/AbstractModule.java
@@ -29,8 +29,8 @@
*/
package mir.module;
-import java.util.Map;
import java.sql.SQLException;
+import java.util.Map;
import mir.entity.Entity;
import mir.entity.EntityList;
@@ -71,8 +71,7 @@ public class AbstractModule {
if (entity == null)
throw new ModuleExc("AbstractModule.getById: No object for id = " + id);
- else
- return entity;
+ return entity;
}
catch (Throwable e) {
throw new ModuleFailure(e);
diff --git a/source/mir/producer/AssignmentProducerNode.java b/source/mir/producer/AssignmentProducerNode.java
index 32dcc175..13c47934 100755
--- a/source/mir/producer/AssignmentProducerNode.java
+++ b/source/mir/producer/AssignmentProducerNode.java
@@ -36,7 +36,6 @@ import mir.util.ParameterExpander;
public class AssignmentProducerNode extends ProducerNodeDecorator {
private String key;
- private String bundleIdentifier;
private Object value;
public AssignmentProducerNode(String aKey, Object aValue, ProducerNode aSubNode) {
@@ -55,5 +54,5 @@ public class AssignmentProducerNode extends ProducerNodeDecorator {
catch (Throwable t) {
throw new ProducerFailure(t.getMessage(), t);
}
- };
+ }
}
\ No newline at end of file
diff --git a/source/mir/producer/BundleProducerNode.java b/source/mir/producer/BundleProducerNode.java
index f7f8cdb8..c86cdafb 100755
--- a/source/mir/producer/BundleProducerNode.java
+++ b/source/mir/producer/BundleProducerNode.java
@@ -78,6 +78,6 @@ public class BundleProducerNode implements ProducerNode {
aLogger.error("Failed to load bundle " + bundleExpression + " for language " +
languageExpression + " into key " + key + ": " + t.getMessage());
}
- };
+ }
}
\ No newline at end of file
diff --git a/source/mir/producer/EntityBatchingProducerNode.java b/source/mir/producer/EntityBatchingProducerNode.java
index cbf1e9a9..abdacc65 100755
--- a/source/mir/producer/EntityBatchingProducerNode.java
+++ b/source/mir/producer/EntityBatchingProducerNode.java
@@ -29,11 +29,11 @@
*/
package mir.producer;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.ArrayList;
import mir.entity.adapter.EntityAdapterModel;
import mir.entity.adapter.EntityIteratorAdapter;
@@ -213,7 +213,7 @@ public class EntityBatchingProducerNode implements ProducerNode {
catch (Throwable t) {
aLogger.error("EntityBatchingProducerNode caused an exception: " + t.getMessage());
}
- };
+ }
private class BatchLocation {
int nrEntities;
diff --git a/source/mir/producer/EntityDeletingProducerNode.java b/source/mir/producer/EntityDeletingProducerNode.java
index 630c70bc..b82cfe90 100755
--- a/source/mir/producer/EntityDeletingProducerNode.java
+++ b/source/mir/producer/EntityDeletingProducerNode.java
@@ -56,6 +56,6 @@ public class EntityDeletingProducerNode implements ProducerNode {
catch (Throwable t) {
aLogger.error("Error while deleting entities: " + t.toString());
}
- };
+ }
}
diff --git a/source/mir/producer/EntityEnumeratingProducerNode.java b/source/mir/producer/EntityEnumeratingProducerNode.java
index ca4fef8e..0ff765ac 100755
--- a/source/mir/producer/EntityEnumeratingProducerNode.java
+++ b/source/mir/producer/EntityEnumeratingProducerNode.java
@@ -93,5 +93,5 @@ public class EntityEnumeratingProducerNode extends ProducerNodeDecorator {
catch (Throwable t) {
aLogger.error("Exception occurred inside an EntityEnumeratingProducerNode: " + t.getMessage());
}
- };
+ }
}
\ No newline at end of file
diff --git a/source/mir/producer/EvaluatedAssignmentProducerNode.java b/source/mir/producer/EvaluatedAssignmentProducerNode.java
index 8583b987..424c41db 100755
--- a/source/mir/producer/EvaluatedAssignmentProducerNode.java
+++ b/source/mir/producer/EvaluatedAssignmentProducerNode.java
@@ -37,7 +37,6 @@ import mir.util.ParameterExpander;
public class EvaluatedAssignmentProducerNode implements ProducerNode {
private String key;
- private String bundleIdentifier;
private String value;
public EvaluatedAssignmentProducerNode(String aKey, String aValue) {
@@ -56,5 +55,5 @@ public class EvaluatedAssignmentProducerNode implements ProducerNode {
catch (Throwable t) {
aLogger.error("key " + key + " could not be set to " + value + ": " + t.getMessage());
}
- };
+ }
}
\ No newline at end of file
diff --git a/source/mir/producer/ExecuteProgramProducerNode.java b/source/mir/producer/ExecuteProgramProducerNode.java
index 0c57a150..0b7ee74a 100755
--- a/source/mir/producer/ExecuteProgramProducerNode.java
+++ b/source/mir/producer/ExecuteProgramProducerNode.java
@@ -1,128 +1,128 @@
-/*
- * Copyright (C) 2001, 2002 The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your version.
- */
-package mir.producer;
-
-import java.util.Map;
-
-import mir.log.LoggerWrapper;
-import mir.util.ParameterExpander;
-
-public class ExecuteProgramProducerNode implements ProducerNode {
- private String scriptExpression;
- private String maxDurationExpression;
- private String outputVariableExpression;
- private String returnValueVariableExpression;
-
- public ExecuteProgramProducerNode(String aScriptExpression, String aMaxDurationExpression, String anOutputVariableExpression,
- String aReturnValueVariableExpression) {
- scriptExpression = aScriptExpression;
- maxDurationExpression = aMaxDurationExpression;
- outputVariableExpression = anOutputVariableExpression;
- returnValueVariableExpression = aReturnValueVariableExpression;
- }
-
- public void produce(Map aValueMap, String aVerb, LoggerWrapper aLogger) throws ProducerFailure {
- String script;
- long maxDuration;
-
- try {
- script = ParameterExpander.expandExpression(aValueMap, scriptExpression);
- maxDuration = ParameterExpander.evaluateIntegerExpressionWithDefault(aValueMap, maxDurationExpression, 0);
-
- ProcessRunner runner = new ProcessRunner(aLogger, script);
- runner.start();
-
- synchronized (runner) {
- runner.wait(maxDuration);
- }
- runner.interrupt();
-
- if (runner.getFinished()) {
- aLogger.info(script + " terminated successfully, return value = " + runner.getReturnValue() + ".");
-
- if (returnValueVariableExpression != null) {
- ParameterExpander.setValueForKey(aValueMap,
- ParameterExpander.expandExpression(aValueMap, returnValueVariableExpression),
- new Integer(runner.getReturnValue()));
- }
-
- }
- else {
- aLogger.info(script + " interrupted prematurely after " + maxDuration + "ms.");
- }
- }
- catch (Throwable e) {
- aLogger.error("Error while executing " + scriptExpression + " : " + e.toString());
- }
- }
-
- private static class ProcessRunner extends Thread {
- private String script;
- private boolean finished = false;
- private int returnValue = 0;
- private LoggerWrapper logger;
-
- public ProcessRunner(LoggerWrapper aLogger, String aScript) {
- script = aScript;
- logger = aLogger;
- }
-
- public boolean getFinished() {
- return finished;
- }
-
- public int getReturnValue() {
- return returnValue;
- }
-
- public void run() {
- Process process = null;
- try {
- process = Runtime.getRuntime().exec(script);
- returnValue = process.waitFor();
-
- finished = true;
-
- synchronized (this) {
- this.notify();
- }
- }
- catch (InterruptedException e) {
- if (process!=null) {
- process.destroy();
- }
- }
- catch (Exception e) {
- logger.error(script + " failed to execute: " + e.getMessage());
- }
- }
- }
-
-}
+/*
+ * Copyright (C) 2001, 2002 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.producer;
+
+import java.util.Map;
+
+import mir.log.LoggerWrapper;
+import mir.util.ParameterExpander;
+
+public class ExecuteProgramProducerNode implements ProducerNode {
+ private String scriptExpression;
+ private String maxDurationExpression;
+ private String outputVariableExpression;
+ private String returnValueVariableExpression;
+
+ public ExecuteProgramProducerNode(String aScriptExpression, String aMaxDurationExpression, String anOutputVariableExpression,
+ String aReturnValueVariableExpression) {
+ scriptExpression = aScriptExpression;
+ maxDurationExpression = aMaxDurationExpression;
+ outputVariableExpression = anOutputVariableExpression;
+ returnValueVariableExpression = aReturnValueVariableExpression;
+ }
+
+ public void produce(Map aValueMap, String aVerb, LoggerWrapper aLogger) throws ProducerFailure {
+ String script;
+ long maxDuration;
+
+ try {
+ script = ParameterExpander.expandExpression(aValueMap, scriptExpression);
+ maxDuration = ParameterExpander.evaluateIntegerExpressionWithDefault(aValueMap, maxDurationExpression, 0);
+
+ ProcessRunner runner = new ProcessRunner(aLogger, script);
+ runner.start();
+
+ synchronized (runner) {
+ runner.wait(maxDuration);
+ }
+ runner.interrupt();
+
+ if (runner.getFinished()) {
+ aLogger.info(script + " terminated successfully, return value = " + runner.getReturnValue() + ".");
+
+ if (returnValueVariableExpression != null) {
+ ParameterExpander.setValueForKey(aValueMap,
+ ParameterExpander.expandExpression(aValueMap, returnValueVariableExpression),
+ new Integer(runner.getReturnValue()));
+ }
+
+ }
+ else {
+ aLogger.info(script + " interrupted prematurely after " + maxDuration + "ms.");
+ }
+ }
+ catch (Throwable e) {
+ aLogger.error("Error while executing " + scriptExpression + " : " + e.toString());
+ }
+ }
+
+ private static class ProcessRunner extends Thread {
+ private String script;
+ private boolean finished = false;
+ private int returnValue = 0;
+ private LoggerWrapper logger;
+
+ public ProcessRunner(LoggerWrapper aLogger, String aScript) {
+ script = aScript;
+ logger = aLogger;
+ }
+
+ public boolean getFinished() {
+ return finished;
+ }
+
+ public int getReturnValue() {
+ return returnValue;
+ }
+
+ public void run() {
+ Process process = null;
+ try {
+ process = Runtime.getRuntime().exec(script);
+ returnValue = process.waitFor();
+
+ finished = true;
+
+ synchronized (this) {
+ this.notify();
+ }
+ }
+ catch (InterruptedException e) {
+ if (process!=null) {
+ process.destroy();
+ }
+ }
+ catch (Exception e) {
+ logger.error(script + " failed to execute: " + e.getMessage());
+ }
+ }
+ }
+
+}
diff --git a/source/mir/producer/ExpandedAssignmentProducerNode.java b/source/mir/producer/ExpandedAssignmentProducerNode.java
index 7d497a80..0fb8481e 100755
--- a/source/mir/producer/ExpandedAssignmentProducerNode.java
+++ b/source/mir/producer/ExpandedAssignmentProducerNode.java
@@ -36,7 +36,6 @@ import mir.util.ParameterExpander;
public class ExpandedAssignmentProducerNode implements ProducerNode {
private String key;
- private String bundleIdentifier;
private String value;
public ExpandedAssignmentProducerNode(String aKey, String aValue) {
@@ -55,5 +54,5 @@ public class ExpandedAssignmentProducerNode implements ProducerNode {
catch (Throwable t) {
aLogger.error("key " + key + " could not be set to " + value + ": " + t.getMessage());
}
- };
+ }
}
\ No newline at end of file
diff --git a/source/mir/producer/ExternalDbProducerNode.java b/source/mir/producer/ExternalDbProducerNode.java
index cfc1e51c..5c621d89 100755
--- a/source/mir/producer/ExternalDbProducerNode.java
+++ b/source/mir/producer/ExternalDbProducerNode.java
@@ -29,12 +29,15 @@
*/
package mir.producer;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import java.sql.*;
-
import mir.log.LoggerWrapper;
import mir.util.ExceptionFunctions;
@@ -116,5 +119,5 @@ public class ExternalDbProducerNode extends ProducerNodeDecorator {
Throwable s = ExceptionFunctions.traceCauseException(t);
aLogger.error("Error while accessing external database: " + s.getClass().getName()+","+ s.getMessage());
}
- };
+ }
}
diff --git a/source/mir/producer/FreeQueryProducerNode.java b/source/mir/producer/FreeQueryProducerNode.java
index 94e6f420..08b70ebf 100755
--- a/source/mir/producer/FreeQueryProducerNode.java
+++ b/source/mir/producer/FreeQueryProducerNode.java
@@ -95,6 +95,6 @@ public class FreeQueryProducerNode implements ProducerNode {
catch (Throwable t) {
aLogger.error("Error while setting key " + key + ": " + t.toString());
}
- };
+ }
}
\ No newline at end of file
diff --git a/source/mir/producer/ListEnumeratingProducerNode.java b/source/mir/producer/ListEnumeratingProducerNode.java
index e9a68fc6..0a594166 100755
--- a/source/mir/producer/ListEnumeratingProducerNode.java
+++ b/source/mir/producer/ListEnumeratingProducerNode.java
@@ -75,5 +75,5 @@ public class ListEnumeratingProducerNode extends ProducerNodeDecorator {
catch (Throwable t) {
aLogger.error("Exception occurred inside an ListEnumeratingProducerNode: " + t.getMessage());
}
- };
+ }
}
diff --git a/source/mir/producer/LoopProducerNode.java b/source/mir/producer/LoopProducerNode.java
index 43dcbffb..5b56b046 100755
--- a/source/mir/producer/LoopProducerNode.java
+++ b/source/mir/producer/LoopProducerNode.java
@@ -67,5 +67,5 @@ public class LoopProducerNode extends ProducerNodeDecorator {
catch (Throwable t) {
aLogger.error("LoopProducerNode raised an exception: " + t.getMessage());
}
- };
+ }
}
\ No newline at end of file
diff --git a/source/mir/producer/NodedProducer.java b/source/mir/producer/NodedProducer.java
index e4f3da1e..28a31f6a 100755
--- a/source/mir/producer/NodedProducer.java
+++ b/source/mir/producer/NodedProducer.java
@@ -62,7 +62,7 @@ public class NodedProducer implements Producer {
isFinished=true;
return !isAborted;
}
- };
+ }
public void abort() {
synchronized(this) {
diff --git a/source/mir/producer/ProducerFactory.java b/source/mir/producer/ProducerFactory.java
index d3ca0188..dc8d7712 100755
--- a/source/mir/producer/ProducerFactory.java
+++ b/source/mir/producer/ProducerFactory.java
@@ -29,8 +29,8 @@
*/
package mir.producer;
-import java.util.Map;
import java.util.List;
+import java.util.Map;
public interface ProducerFactory {
public interface ProducerVerb {
diff --git a/source/mir/producer/ProducerFailure.java b/source/mir/producer/ProducerFailure.java
index 79a20c75..48728130 100755
--- a/source/mir/producer/ProducerFailure.java
+++ b/source/mir/producer/ProducerFailure.java
@@ -33,7 +33,8 @@ import multex.Failure;
public class ProducerFailure extends Failure {
- public ProducerFailure(String msg,Throwable cause) {
+
+ public ProducerFailure(String msg,Throwable cause) {
super(msg,cause);
}
diff --git a/source/mir/producer/RDFAggregatorProducerNode.java b/source/mir/producer/RDFAggregatorProducerNode.java
index fe99ff66..02ce1596 100755
--- a/source/mir/producer/RDFAggregatorProducerNode.java
+++ b/source/mir/producer/RDFAggregatorProducerNode.java
@@ -83,5 +83,5 @@ public class RDFAggregatorProducerNode implements ProducerNode {
Throwable s = ExceptionFunctions.traceCauseException(t);
aLogger.error("Error while aggregating RDF data: " + s.getClass().getName()+","+ s.getMessage());
}
- };
+ }
}
diff --git a/source/mir/producer/RSSProducerNode.java b/source/mir/producer/RSSProducerNode.java
index 9d62022a..fa2bef15 100755
--- a/source/mir/producer/RSSProducerNode.java
+++ b/source/mir/producer/RSSProducerNode.java
@@ -92,5 +92,5 @@ public class RSSProducerNode implements ProducerNode {
Throwable s = ExceptionFunctions.traceCauseException(t);
aLogger.error("Error while processing RSS data: " + s.getClass().getName()+","+ s.getMessage());
}
- };
+ }
}
\ No newline at end of file
diff --git a/source/mir/producer/ValuesMapProducerNode.java b/source/mir/producer/ValuesMapProducerNode.java
index d0dac9ee..e0a4ffcf 100755
--- a/source/mir/producer/ValuesMapProducerNode.java
+++ b/source/mir/producer/ValuesMapProducerNode.java
@@ -51,5 +51,5 @@ public class ValuesMapProducerNode extends ProducerNodeDecorator {
catch (Throwable t) {
throw new ProducerFailure(t.getMessage(), t);
}
- };
+ }
}
\ No newline at end of file
diff --git a/source/mir/producer/reader/DefaultProducerNodeBuilders.java b/source/mir/producer/reader/DefaultProducerNodeBuilders.java
index c2f9a018..e0c80249 100755
--- a/source/mir/producer/reader/DefaultProducerNodeBuilders.java
+++ b/source/mir/producer/reader/DefaultProducerNodeBuilders.java
@@ -29,6 +29,7 @@
*/
package mir.producer.reader;
+import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
@@ -36,12 +37,12 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.io.File;
import mir.entity.adapter.EntityAdapterModel;
import mir.generator.Generator;
import mir.generator.WriterEngine;
import mir.log.LoggerWrapper;
+import mir.producer.BundleProducerNode;
import mir.producer.ConditionalProducerNode;
import mir.producer.DirCopyingProducerNode;
import mir.producer.EntityBatchingProducerNode;
@@ -50,6 +51,7 @@ import mir.producer.EntityEnumeratingProducerNode;
import mir.producer.EntityListProducerNode;
import mir.producer.EntityModifyingProducerNode;
import mir.producer.EvaluatedAssignmentProducerNode;
+import mir.producer.ExecuteProgramProducerNode;
import mir.producer.ExpandedAssignmentProducerNode;
import mir.producer.ExternalDbProducerNode;
import mir.producer.FileDateSettingProducerNode;
@@ -62,8 +64,6 @@ import mir.producer.LoopProducerNode;
import mir.producer.ProducerNode;
import mir.producer.RDFAggregatorProducerNode;
import mir.producer.RSSProducerNode;
-import mir.producer.BundleProducerNode;
-import mir.producer.ExecuteProgramProducerNode;
import mir.util.StringRoutines;
import mir.util.xml.XMLParserExc;
import mir.util.xml.XMLReaderTool;
@@ -119,11 +119,11 @@ public class DefaultProducerNodeBuilders {
public void setSubNode(String aName, ProducerNode aNode) {
subNodes.put(aName, aNode);
- };
+ }
public Set getAvailableSubNodes() {
return availableSubnodes;
- };
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -162,11 +162,11 @@ public class DefaultProducerNodeBuilders {
key = (String) anAttributes.get(ASSIGNMENT_KEY_ATTRIBUTE);
value = (String) anAttributes.get(ASSIGNMENT_VALUE_ATTRIBUTE);
- };
+ }
public ProducerNode constructNode() {
return new ExpandedAssignmentProducerNode(key, value);
- };
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -185,11 +185,11 @@ public class DefaultProducerNodeBuilders {
key = (String) anAttributes.get(ASSIGNMENT_KEY_ATTRIBUTE);
value = (String) anAttributes.get(ASSIGNMENT_VALUE_ATTRIBUTE);
- };
+ }
public ProducerNode constructNode() {
return new EvaluatedAssignmentProducerNode(key, value);
- };
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -254,14 +254,13 @@ public class DefaultProducerNodeBuilders {
if (parts.size() > 1)
mainTablePrefix = (String) parts.get(1);
}
- };
+ }
public ProducerNode constructNode() {
if (definition!=null)
return new EntityEnumeratingProducerNode(key, model, mainTablePrefix, extraTables, definition, selection, order, limit, skip, getSubNode(ENUMERATION_DEFAULT_SUBNODE ));
- else
- return new ListEnumeratingProducerNode(key, list, getSubNode(ENUMERATION_DEFAULT_SUBNODE ));
- };
+ return new ListEnumeratingProducerNode(key, list, getSubNode(ENUMERATION_DEFAULT_SUBNODE ));
+ }
public static class factory implements ProducerNodeBuilderFactory {
private EntityAdapterModel model;
@@ -306,11 +305,10 @@ public class DefaultProducerNodeBuilders {
fieldValues.putAll(anAttributes);
fieldValues.remove(UPDATE_KEY_ATTRIBUTE);
fieldValues.remove(UPDATE_DEFINITION_ATTRIBUTE);
- };
-
+ }
public ProducerNode constructNode() {
return new EntityModifyingProducerNode(model, false, definition, key, fieldValues);
- };
+ }
public static class factory implements ProducerNodeBuilderFactory {
private EntityAdapterModel model;
@@ -357,11 +355,11 @@ public class DefaultProducerNodeBuilders {
fieldValues.putAll(anAttributes);
fieldValues.remove(CREATEENTITY_KEY_ATTRIBUTE);
fieldValues.remove(CREATEENTITY_DEFINITION_ATTRIBUTE);
- };
+ }
public ProducerNode constructNode() {
return new EntityModifyingProducerNode(model, true, definition, key, fieldValues);
- };
+ }
public static class factory implements ProducerNodeBuilderFactory {
private EntityAdapterModel model;
@@ -398,11 +396,11 @@ public class DefaultProducerNodeBuilders {
condition = (String) anAttributes.get(LOOP_CONDITION_ATTRIBUTE);
limit = XMLReaderTool.getStringAttributeWithDefault(anAttributes, LOOP_LIMIT_ATTRIBUTE, "");
- };
+ }
public ProducerNode constructNode() {
return new LoopProducerNode(condition, limit, getSubNode( LOOP_DEFAULT_SUBNODE ));
- };
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -449,11 +447,11 @@ public class DefaultProducerNodeBuilders {
if (parts.size()>0) definition=(String)parts.get(0);
if (parts.size()>1) mainTablePrefix=(String)parts.get(1);
- };
+ }
public ProducerNode constructNode() {
return new EntityListProducerNode(key, model, mainTablePrefix, extraTables, definition, selection, order, limit, skip, null );
- };
+ }
public static class factory implements ProducerNodeBuilderFactory {
private EntityAdapterModel model;
@@ -493,11 +491,11 @@ public class DefaultProducerNodeBuilders {
definition = (String) anAttributes.get(DELETEENTITY_DEFINITION_ATTRIBUTE);
selection = XMLReaderTool.getStringAttributeWithDefault(anAttributes, DELETEENTITY_SELECTION_ATTRIBUTE, "");
- };
+ }
public ProducerNode constructNode() {
return new EntityDeletingProducerNode(model, definition, selection);
- };
+ }
public static class factory implements ProducerNodeBuilderFactory {
private EntityAdapterModel model;
@@ -552,11 +550,11 @@ public class DefaultProducerNodeBuilders {
}
else
type = LoggerWrapper.INFO_MESSAGE;
- };
+ }
public ProducerNode constructNode() {
return new LoggingProducerNode(message, type);
- };
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -604,11 +602,11 @@ public class DefaultProducerNodeBuilders {
}
else
type = FreeQueryProducerNode.QUERY_TYPE_SET;
- };
+ }
public ProducerNode constructNode() {
return new FreeQueryProducerNode(key, query, limit, type);
- };
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -651,11 +649,11 @@ public class DefaultProducerNodeBuilders {
username = (String) anAttributes.get(EXTDB_USERNAME_ATTRIBUTE);
password = (String) anAttributes.get(EXTDB_PASSWORD_ATTRIBUTE);
query = (String) anAttributes.get(EXTDB_QUERY_ATTRIBUTE);
- };
+ }
public ProducerNode constructNode() {
return new ExternalDbProducerNode(key, driver, host, port, database, username, password, query, getSubNode(EXTDB_DEFAULT_SUBNODE));
- };
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -682,11 +680,11 @@ public class DefaultProducerNodeBuilders {
key = (String) anAttributes.get(RESOURCEBUNDLE_KEY_ATTRIBUTE);
bundle = (String) anAttributes.get(RESOURCEBUNDLE_BUNDLE_ATTRIBUTE);
language = (String) anAttributes.get(RESOURCEBUNDLE_LANGUAGE_ATTRIBUTE);
- };
+ }
public ProducerNode constructNode() {
return new BundleProducerNode(key, bundle, language);
- };
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -710,11 +708,11 @@ public class DefaultProducerNodeBuilders {
fileNameKey = (String) anAttributes.get(FILEDATESETTING_FILE_ATTRIBUTE);
dateKey = (String) anAttributes.get(FILEDATESETTING_DATE_ATTRIBUTE);
- };
+ }
public ProducerNode constructNode() {
return new FileDateSettingProducerNode(fileNameKey, dateKey);
- };
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -735,11 +733,11 @@ public class DefaultProducerNodeBuilders {
XMLReaderTool.checkAttributes(anAttributes, FILEDELETING_REQUIRED_ATTRIBUTES, FILEDELETING_OPTIONAL_ATTRIBUTES);
fileNameKey = (String) anAttributes.get(FILEDELETING_FILE_ATTRIBUTE);
- };
+ }
public ProducerNode constructNode() {
return new FileDeletingProducerNode(fileNameKey);
- };
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -769,12 +767,12 @@ public class DefaultProducerNodeBuilders {
time = XMLReaderTool.getStringAttributeWithDefault(anAttributes, EXECUTEPROGRAM_MAXTIME_ATTRIBUTE, null);
resultvar = XMLReaderTool.getStringAttributeWithDefault(anAttributes, EXECUTEPROGRAM_RESULTVAR_ATTRIBUTE, null);
returnValueVar = XMLReaderTool.getStringAttributeWithDefault(anAttributes, EXECUTEPROGRAM_RETURNVALUE_ATTRIBUTE, null);
- };
+ }
public ProducerNode constructNode() {
return new
ExecuteProgramProducerNode(command, time, resultvar, returnValueVar);
- };
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -803,11 +801,11 @@ public class DefaultProducerNodeBuilders {
source = (String) anAttributes.get(DIRCOPY_SOURCE_ATTRIBUTE);
destination = (String) anAttributes.get(DIRCOPY_DESTINATION_ATTRIBUTE);
- };
+ }
public ProducerNode constructNode() {
return new DirCopyingProducerNode(sourceBasePath, destinationBasePath, source, destination);
- };
+ }
public static class factory implements ProducerNodeBuilderFactory {
private File sourceBasePath;
@@ -853,11 +851,11 @@ public class DefaultProducerNodeBuilders {
generator = (String) anAttributes.get(GENERATION_GENERATOR_ATTRIBUTE);
destination = (String) anAttributes.get(GENERATION_DESTINATION_ATTRIBUTE);
parameters = XMLReaderTool.getStringAttributeWithDefault(anAttributes, GENERATION_PARAMETERS_ATTRIBUTE, "" );
- };
+ }
public ProducerNode constructNode() {
return new GeneratingProducerNode(generatorLibrary, writerEngine, generator, destination, parameters);
- };
+ }
public static class factory implements ProducerNodeBuilderFactory {
private Generator.Library generatorLibrary;
@@ -935,7 +933,7 @@ public class DefaultProducerNodeBuilders {
List parts = StringRoutines.splitString(definition.trim(), " ");
if (parts.size()>0) definition = (String) parts.get(0);
if (parts.size()>1) mainTablePrefix = (String) parts.get(1);
- };
+ }
public ProducerNode constructNode() {
return new EntityBatchingProducerNode(
@@ -954,7 +952,7 @@ public class DefaultProducerNodeBuilders {
getSubNode( BATCHER_BATCH_SUBNODE ),
getSubNode( BATCHER_BATCHLIST_SUBNODE )
);
- };
+ }
public static class factory implements ProducerNodeBuilderFactory {
private EntityAdapterModel model;
@@ -990,7 +988,7 @@ public class DefaultProducerNodeBuilders {
XMLReaderTool.checkAttributes(anAttributes, IF_REQUIRED_ATTRIBUTES, IF_OPTIONAL_ATTRIBUTES);
condition = (String) anAttributes.get( IF_CONDITION_ATTRIBUTE );
- };
+ }
public ProducerNode constructNode() {
return new ConditionalProducerNode(
@@ -998,7 +996,7 @@ public class DefaultProducerNodeBuilders {
getSubNode( IF_TRUE_SUBNODE ),
getSubNode( IF_FALSE_SUBNODE )
);
- };
+ }
}
@@ -1030,11 +1028,11 @@ public class DefaultProducerNodeBuilders {
url = (String) anAttributes.get( RSS_URL_ATTRIBUTE );
version = XMLReaderTool.getStringAttributeWithDefault(anAttributes, RSS_VERSION_ATTRIBUTE, "1.0");
encoding = XMLReaderTool.getStringAttributeWithDefault(anAttributes, RSS_ENCODING_ATTRIBUTE, null);
- };
+ }
public ProducerNode constructNode() {
return new RSSProducerNode(key, url, version, encoding);
- };
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -1065,11 +1063,11 @@ public class DefaultProducerNodeBuilders {
source = (String) anAttributes.get( RDF_AGGREGATOR_SOURCE_ATTRIBUTE );
order = XMLReaderTool.getStringAttributeWithDefault(anAttributes, RDF_AGGREGATOR_SOURCE_ATTRIBUTE, "");
filter = XMLReaderTool.getStringAttributeWithDefault(anAttributes, RDF_AGGREGATOR_FILTER_ATTRIBUTE, "");
- };
+ }
public ProducerNode constructNode() {
return new RDFAggregatorProducerNode(key, source, order, filter);
- };
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -1084,20 +1082,20 @@ public class DefaultProducerNodeBuilders {
}
public void setSubNode(String aName, ProducerNode aNode) {
- };
+ }
public Set getAvailableSubNodes() {
return new HashSet();
- };
+ }
public void setAttributes(Map anAttributes) throws ProducerConfigExc {
if (!anAttributes.isEmpty())
throw new ProducerConfigExc("No parameters allowed here");
- };
+ }
public ProducerNode constructNode() {
return new ScriptedProducerNodeDefinition.NodeParameterProducerNode(scriptedNodeName, parameterName);
- };
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -1122,11 +1120,11 @@ public class DefaultProducerNodeBuilders {
public void setSubNode(String aName, ProducerNode aNode) {
nodeParameterValues.put(aName, aNode);
- };
+ }
public Set getAvailableSubNodes() {
return definition.getNodeParameters();
- };
+ }
public void setAttributes(Map anAttributes) throws ProducerConfigExc, XMLParserExc {
XMLReaderTool.checkAttributeSet(anAttributes.keySet(), definition.getRequiredAttributes(), definition.getOptionalAttributes());
@@ -1140,11 +1138,11 @@ public class DefaultProducerNodeBuilders {
else
stringParameterValues.put(entry.getKey(), entry.getValue());
}
- };
+ }
public ProducerNode constructNode() {
return new ScriptedProducerNode(definition, stringParameterValues, integerParameterValues, nodeParameterValues);
- };
+ }
public static class factory implements ProducerNodeBuilderFactory {
private ScriptedProducerNodeDefinition definition;
diff --git a/source/mir/producer/reader/ProducerConfigReader.java b/source/mir/producer/reader/ProducerConfigReader.java
index 631573f9..d39fbee0 100755
--- a/source/mir/producer/reader/ProducerConfigReader.java
+++ b/source/mir/producer/reader/ProducerConfigReader.java
@@ -54,7 +54,7 @@ public class ProducerConfigReader {
public ProducerConfigReader() {
super();
- };
+ }
public void parse(Reader aReader, ProducerNodeBuilderLibrary aBuilderLibrary, List aProducerFactories) throws ProducerConfigFailure {
try {
@@ -104,8 +104,7 @@ public class ProducerConfigReader {
if (aTag.equals("producers")) {
return new ProducersSectionHandler(producers);
}
- else
- throw new XMLParserExc("Tag 'producers' expected, tag '"+aTag+"' found");
+ throw new XMLParserExc("Tag 'producers' expected, tag '"+aTag+"' found");
}
public void endElement(mir.util.xml.SectionHandler aHandler) {
@@ -201,14 +200,12 @@ public class ProducerConfigReader {
throw new XMLParserExc("Verbs already processed");
if (body!=null)
throw new XMLParserExc("Verbs should come before body");
- else
- return new ProducerVerbsSectionHandler();
+ return new ProducerVerbsSectionHandler();
}
else if (aTag.equals("body")) {
if (body==null)
return new ProducerNodeSectionHandler();
- else
- throw new XMLParserExc("Body already processed");
+ throw new XMLParserExc("Body already processed");
}
throw new XMLParserExc("Unexpected tag: '"+aTag+"'");
}
@@ -288,8 +285,7 @@ public class ProducerConfigReader {
return new ProducerNodeSectionHandler();
}
- else
- throw new XMLParserExc("Only 'verb' tags allowed here, '" + aTag + "' encountered.");
+ throw new XMLParserExc("Only 'verb' tags allowed here, '" + aTag + "' encountered.");
}
public void endElement(mir.util.xml.SectionHandler aHandler) {
@@ -472,9 +468,7 @@ public class ProducerConfigReader {
if (producerNode.getNrSubNodes()==1) {
return producerNode.getSubNode(0);
}
- else {
- return producerNode;
- }
+ return producerNode;
}
public void finishSection() {
diff --git a/source/mir/producer/reader/ProducerNodeBuilderLibrary.java b/source/mir/producer/reader/ProducerNodeBuilderLibrary.java
index bc9f2878..90d1a4f7 100755
--- a/source/mir/producer/reader/ProducerNodeBuilderLibrary.java
+++ b/source/mir/producer/reader/ProducerNodeBuilderLibrary.java
@@ -59,7 +59,6 @@ public class ProducerNodeBuilderLibrary {
public ProducerNodeBuilder constructBuilder(String aName) throws ProducerConfigExc {
if (hasBuilderForName(aName))
return ((ProducerNodeBuilder.ProducerNodeBuilderFactory) nodeBuilders.get(aName)).makeBuilder();
- else
- throw new ProducerConfigExc("ProducerNodeBuilder: no builder with name '" + aName + "' found.");
+ throw new ProducerConfigExc("ProducerNodeBuilder: no builder with name '" + aName + "' found.");
}
}
diff --git a/source/mir/producer/reader/ScriptedProducerFactory.java b/source/mir/producer/reader/ScriptedProducerFactory.java
index 5825ae96..e870733c 100755
--- a/source/mir/producer/reader/ScriptedProducerFactory.java
+++ b/source/mir/producer/reader/ScriptedProducerFactory.java
@@ -84,7 +84,7 @@ public class ScriptedProducerFactory implements ProducerFactory {
rootNode.addSubNode(body);
return new NodedProducer(rootNode, aVerb, aStartingValues);
- };
+ }
public List verbs() {
return verbs;
diff --git a/source/mir/rss/RSS091Reader.java b/source/mir/rss/RSS091Reader.java
index 3a01811c..2b9a4d01 100755
--- a/source/mir/rss/RSS091Reader.java
+++ b/source/mir/rss/RSS091Reader.java
@@ -29,14 +29,18 @@
*/
package mir.rss;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
import mir.util.HTTPClientHelper;
import mir.util.xml.XMLParserEngine;
import mir.util.xml.XMLParserExc;
import mir.util.xml.XMLParserFailure;
-import java.io.InputStream;
-import java.util.*;
-
/**
*
* Title:
@@ -151,20 +155,19 @@ public class RSS091Reader {
if (aTag.getLocalName().equals("rss")) {
return new RSS091SectionHandler(data);
}
- else
- throw new XMLParserFailure(new RSSExc("'rss' tag expected"));
- };
+ throw new XMLParserFailure(new RSSExc("'rss' tag expected"));
+ }
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
if (aCharacters.trim().length()>0)
throw new XMLParserExc("No character data allowed here");
- };
+ }
public void finishSection() throws XMLParserExc {
- };
+ }
}
private class RSS091SectionHandler extends mir.util.xml.AbstractSectionHandler {
@@ -180,15 +183,15 @@ public class RSS091Reader {
return new RSS091ChannelSectionHandler(data);
else
throw new XMLParserExc("channel tag expected, " + aTag.getLocalName() + " found");
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
if (aCharacters.trim().length()>0)
throw new XMLParserExc("No character data allowed here");
- };
+ }
public void finishSection() throws XMLParserExc {
- };
+ }
}
private class RSS091ChannelSectionHandler extends mir.util.xml.AbstractSectionHandler {
@@ -217,7 +220,7 @@ public class RSS091Reader {
}
else
return new DiscardingSectionHandler();
- };
+ }
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
if (aHandler instanceof PCDATASectionHandler) {
@@ -226,12 +229,12 @@ public class RSS091Reader {
else if (aHandler instanceof RSS091ItemSectionHandler) {
items.add((((RSS091ItemSectionHandler) aHandler).getItem()));
}
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
if (aCharacters.trim().length()>0)
throw new XMLParserExc("No character data allowed here");
- };
+ }
public void finishSection() throws XMLParserExc {
Iterator i = items.iterator();
@@ -239,7 +242,7 @@ public class RSS091Reader {
while (i.hasNext()) {
data.addResource((RDFResource) i.next());
}
- };
+ }
}
private class RSS091ItemSectionHandler extends mir.util.xml.AbstractSectionHandler {
@@ -259,20 +262,19 @@ public class RSS091Reader {
currentTag=(String) mappedItemProperties.get(tag);
return new PCDATASectionHandler();
}
- else
- return new DiscardingSectionHandler();
- };
+ return new DiscardingSectionHandler();
+ }
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
if (aHandler instanceof PCDATASectionHandler) {
attributes.put(currentTag, (((PCDATASectionHandler) aHandler).getData()));
}
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
if (aCharacters.trim().length()>0)
throw new XMLParserExc("No character data allowed here");
- };
+ }
public void finishSection() throws XMLParserExc {
item = new RDFResource("rss:item", (String) attributes.get("rss:link"));
@@ -283,7 +285,7 @@ public class RSS091Reader {
item.set((String) entry.getKey(), entry.getValue());
}
- };
+ }
public RDFResource getItem() {
return item;
@@ -300,17 +302,17 @@ public class RSS091Reader {
public mir.util.xml.SectionHandler startElement(String aTag, Map anAttributes) throws XMLParserExc {
throw new XMLParserFailure(new RSSExc("No subtags allowed here"));
- };
+ }
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
data.append(aCharacters);
- };
+ }
public void finishSection() throws XMLParserExc {
- };
+ }
public String getData() {
return data.toString();
@@ -334,16 +336,16 @@ public class RSS091Reader {
}
return new DiscardingSectionHandler();
- };
+ }
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
- };
+ }
public void finishSection() throws XMLParserExc {
- };
+ }
public List getItems() {
return items;
@@ -353,15 +355,15 @@ public class RSS091Reader {
private class DiscardingSectionHandler extends mir.util.xml.AbstractSectionHandler {
public mir.util.xml.SectionHandler startElement(String aTag, Map anAttributes) throws XMLParserExc {
return this;
- };
+ }
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
- };
+ }
public void finishSection() throws XMLParserExc {
- };
+ }
}
}
diff --git a/source/mir/rss/RSSData.java b/source/mir/rss/RSSData.java
index d858aed0..e1aa6a98 100755
--- a/source/mir/rss/RSSData.java
+++ b/source/mir/rss/RSSData.java
@@ -29,10 +29,10 @@
*/
package mir.rss;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.ArrayList;
public class RSSData {
private List resources;
diff --git a/source/mir/rss/RSSReader.java b/source/mir/rss/RSSReader.java
index ad2958a8..faff1ea8 100755
--- a/source/mir/rss/RSSReader.java
+++ b/source/mir/rss/RSSReader.java
@@ -172,20 +172,19 @@ public class RSSReader {
if (aTag.getLocalName().equals("RDF")) {
return new RDFSectionHandler(data);
}
- else
- throw new XMLParserFailure(new RSSExc("'RDF' tag expected"));
- };
+ throw new XMLParserFailure(new RSSExc("'RDF' tag expected"));
+ }
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
if (aCharacters.trim().length()>0)
throw new XMLParserExc("No character data allowed here");
- };
+ }
public void finishSection() throws XMLParserExc {
- };
+ }
}
private class RDFSectionHandler extends mir.util.xml.AbstractSectionHandler {
@@ -201,21 +200,21 @@ public class RSSReader {
String rdfClass = makeQualifiedName(aTag);
return new RDFResourceSectionHandler(rdfClass, identifier);
- };
+ }
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
if (aHandler instanceof RDFResourceSectionHandler) {
data.addResource(((RDFResourceSectionHandler) aHandler).getResource());
}
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
if (aCharacters.trim().length()>0)
throw new XMLParserExc("No character data allowed here");
- };
+ }
public void finishSection() throws XMLParserExc {
- };
+ }
}
private mir.util.xml.SectionHandler makePropertyValueSectionHandler(mir.util.xml.XMLName aTag, Map anAttributes) {
@@ -294,22 +293,22 @@ public class RSSReader {
currentTag = aTag;
return makePropertyValueSectionHandler(aTag, anAttributes);
- };
+ }
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
if (aHandler instanceof PropertyValueSectionHandler) {
usePropertyValueSectionHandler(resource, (PropertyValueSectionHandler) aHandler, currentTag);
// resource.set(makeQualifiedName(currentTag), ( (PropertyValueSectionHandler) aHandler).getFieldValue());
}
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
if (aCharacters.trim().length()>0)
throw new XMLParserExc("No character data allowed here");
- };
+ }
public void finishSection() throws XMLParserExc {
- };
+ }
public RDFResource getResource() {
if ((resource.getIdentifier()==null || resource.getIdentifier().length()==0) && resource.get("rss:link")!=null) {
@@ -338,20 +337,20 @@ public class RSSReader {
return new RDFSequenceSectionHandler();
else
return new DiscardingSectionHandler();
- };
+ }
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
if (aHandler instanceof RDFSequenceSectionHandler) {
structuredData= ((RDFSequenceSectionHandler) aHandler).getItems();
}
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
stringData.append(aCharacters);
- };
+ }
public void finishSection() throws XMLParserExc {
- };
+ }
public String getData() {
return stringData.toString();
@@ -360,8 +359,7 @@ public class RSSReader {
public Object getValue() {
if (structuredData==null)
return stringData.toString();
- else
- return structuredData;
+ return structuredData;
}
}
@@ -377,21 +375,21 @@ public class RSSReader {
return new RDFSequenceSectionHandler();
else
return new DiscardingSectionHandler();
- };
+ }
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
if (aHandler instanceof RDFSequenceSectionHandler) {
items.addAll(((RDFSequenceSectionHandler) aHandler).getItems());
}
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
if (aCharacters.trim().length()>0)
throw new XMLParserExc("No character data allowed here");
- };
+ }
public void finishSection() throws XMLParserExc {
- };
+ }
public List getItems() {
return items;
@@ -411,17 +409,17 @@ public class RSSReader {
public mir.util.xml.SectionHandler startElement(String aTag, Map anAttributes) throws XMLParserExc {
throw new XMLParserFailure(new RSSExc("No subtags allowed here"));
- };
+ }
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
data.append(aCharacters);
- };
+ }
public void finishSection() throws XMLParserExc {
- };
+ }
public String getData() {
return data.toString();
@@ -441,17 +439,17 @@ public class RSSReader {
public mir.util.xml.SectionHandler startElement(String aTag, Map anAttributes) throws XMLParserExc {
throw new XMLParserFailure(new RSSExc("No subtags allowed here"));
- };
+ }
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
data.append(aCharacters);
- };
+ }
public void finishSection() throws XMLParserExc {
- };
+ }
public Object getValue() {
try {
@@ -483,16 +481,16 @@ public class RSSReader {
}
return new DiscardingSectionHandler();
- };
+ }
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
- };
+ }
public void finishSection() throws XMLParserExc {
- };
+ }
public List getItems() {
return items;
@@ -516,19 +514,19 @@ public class RSSReader {
data.append("<"+tag+">");
return new RDFLiteralSectionHandler();
- };
+ }
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
data.append(((RDFLiteralSectionHandler) aHandler).getData());
data.append(""+tag+">");
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
data.append(aCharacters);
- };
+ }
public void finishSection() throws XMLParserExc {
- };
+ }
public Object getValue() {
return data.toString();
@@ -538,15 +536,15 @@ public class RSSReader {
private class DiscardingSectionHandler extends mir.util.xml.AbstractSectionHandler {
public mir.util.xml.SectionHandler startElement(String aTag, Map anAttributes) throws XMLParserExc {
return this;
- };
+ }
public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
- };
+ }
public void characters(String aCharacters) throws XMLParserExc {
- };
+ }
public void finishSection() throws XMLParserExc {
- };
+ }
}
}
diff --git a/source/mir/servlet/ServletModule.java b/source/mir/servlet/ServletModule.java
index b3a2d6c7..13553f3b 100755
--- a/source/mir/servlet/ServletModule.java
+++ b/source/mir/servlet/ServletModule.java
@@ -29,7 +29,13 @@
*/
package mir.servlet;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -376,7 +382,7 @@ public abstract class ServletModule {
catch (ModuleExc t) {
throw new ServletModuleFailure(t);
}
- };
+ }
/**
* Generic delete confirmation servlet method
diff --git a/source/mir/session/CommonsUploadedFileAdapter.java b/source/mir/session/CommonsUploadedFileAdapter.java
index 968c0042..8fcaf883 100755
--- a/source/mir/session/CommonsUploadedFileAdapter.java
+++ b/source/mir/session/CommonsUploadedFileAdapter.java
@@ -29,11 +29,11 @@
*/
package mir.session;
-import org.apache.commons.fileupload.FileItem;
-
import java.io.File;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.fileupload.FileItem;
public class CommonsUploadedFileAdapter implements UploadedFile {
private FileItem fileItem;
@@ -72,5 +72,5 @@ public class CommonsUploadedFileAdapter implements UploadedFile {
public String getContentType() {
return fileItem.getContentType();
- };
+ }
}
\ No newline at end of file
diff --git a/source/mir/session/HTTPAdapters.java b/source/mir/session/HTTPAdapters.java
index 78cd3620..cc16c218 100755
--- a/source/mir/session/HTTPAdapters.java
+++ b/source/mir/session/HTTPAdapters.java
@@ -29,13 +29,20 @@
*/
package mir.session;
-import java.util.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import mir.util.HTTPParsedRequest;
+
import org.apache.commons.fileupload.FileItem;
public class HTTPAdapters {
@@ -68,11 +75,11 @@ public class HTTPAdapters {
}
return request.getHeader(aHeaderName);
- };
+ }
public String getParameter(String aName) {
return request.getParameter(aName);
- };
+ }
public List getPrefixedParameterNames(String aPrefix) {
List result = new ArrayList();
@@ -86,15 +93,15 @@ public class HTTPAdapters {
}
return result;
- };
+ }
public List getUploadedFiles() {
return Collections.EMPTY_LIST;
- };
+ }
public List getParameters(String aName) {
return Arrays.asList(request.getParameterValues(aName));
- };
+ }
public HttpServletRequest getRequest() {
return request;
@@ -117,9 +124,7 @@ public class HTTPAdapters {
if (headers.hasMoreElements()) {
return (String) headers.nextElement();
}
- else {
- return request.getRequest().getRemoteAddr();
- }
+ return request.getRequest().getRemoteAddr();
}
if (aHeaderName.equals("hostname")) {
@@ -140,11 +145,11 @@ public class HTTPAdapters {
public String getParameter(String aName) {
return request.getParameter(aName);
- };
+ }
public List getParameters(String aName) {
return request.getParameterList(aName);
- };
+ }
public List getPrefixedParameterNames(String aPrefix) {
List result = new ArrayList();
@@ -157,9 +162,8 @@ public class HTTPAdapters {
result.add(name);
}
}
-
return result;
- };
+ }
public List getUploadedFiles() {
List result = new ArrayList();
@@ -170,7 +174,7 @@ public class HTTPAdapters {
}
return result;
- };
+ }
public HttpServletRequest getRequest() {
return request.getRequest();
diff --git a/source/mir/session/ValidationHelper.java b/source/mir/session/ValidationHelper.java
index 9ac7e085..83a31bce 100755
--- a/source/mir/session/ValidationHelper.java
+++ b/source/mir/session/ValidationHelper.java
@@ -50,8 +50,7 @@ public class ValidationHelper {
aValidationResults.add(new ValidationError(aFieldName, anErrorMessageResource));
return false;
}
- else
- return true;
+ return true;
}
/**
diff --git a/source/mir/storage/Database.java b/source/mir/storage/Database.java
index ea6d9876..0f886dbb 100755
--- a/source/mir/storage/Database.java
+++ b/source/mir/storage/Database.java
@@ -29,32 +29,52 @@
*/
package mir.storage;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
import mir.config.MirPropertiesConfiguration;
+import mir.entity.AbstractEntity;
import mir.entity.Entity;
import mir.entity.EntityList;
import mir.entity.StorableObjectEntity;
-import mir.entity.AbstractEntity;
import mir.log.LoggerWrapper;
import mir.misc.StringUtil;
-import mir.storage.store.*;
+import mir.storage.store.ObjectStore;
+import mir.storage.store.StorableObject;
+import mir.storage.store.StoreContainerType;
+import mir.storage.store.StoreIdentifier;
+import mir.storage.store.StoreUtil;
import mir.util.JDBCStringRoutines;
import mircoders.global.MirGlobal;
-import java.io.*;
-import java.sql.*;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
import org.apache.commons.dbcp.DelegatingConnection;
import org.postgresql.PGConnection;
-import org.postgresql.largeobject.LargeObjectManager;
import org.postgresql.largeobject.LargeObject;
+import org.postgresql.largeobject.LargeObjectManager;
/**
* Implements database access.
*
- * @version $Id: Database.java,v 1.44.2.26 2005/01/23 15:36:03 zapata Exp $
+ * @version $Id: Database.java,v 1.44.2.27 2005/02/10 16:22:33 rhindes Exp $
* @author rk
*
*/
@@ -882,7 +902,8 @@ public class Database {
con.setAutoCommit(true);
}
catch (Exception e) {
- ;
+
+
}
freeConnection(con, pstmt);
@@ -1041,7 +1062,7 @@ public class Database {
freeConnection(connection, statement);
}
}
- };
+ }
/**
* Executes 1 sql statement and returns the first result row as a Map
s
@@ -1053,8 +1074,7 @@ public class Database {
try {
if (resultList.size()>0)
return (Map) resultList.get(0);
- else
- return null;
+ return null;
}
finally {
}
@@ -1062,7 +1082,7 @@ public class Database {
catch (Throwable t) {
throw new StorageObjectFailure(t);
}
- };
+ }
/**
* Executes 1 sql statement and returns the first column of the first result row as a String
s
@@ -1077,9 +1097,8 @@ public class Database {
Iterator i = row.values().iterator();
if (i.hasNext())
return (String) i.next();
- else
- return null;
- };
+ return null;
+ }
public int getSize(String where) throws SQLException, StorageObjectFailure {
return getSize("", null, where);
diff --git a/source/mir/storage/StorageObjectFailure.java b/source/mir/storage/StorageObjectFailure.java
index c1b7aca1..3b946b9e 100755
--- a/source/mir/storage/StorageObjectFailure.java
+++ b/source/mir/storage/StorageObjectFailure.java
@@ -53,8 +53,8 @@ public class StorageObjectFailure extends Failure {
}
/**
- * Construktor with message
- * @param String msg
+ * Constructor with message
+ * @param msg
*/
public StorageObjectFailure(String msg, Throwable e) {
super(msg, e);
diff --git a/source/mir/storage/store/ObjectStore.java b/source/mir/storage/store/ObjectStore.java
index 0c65b1c9..8c3a7f4a 100755
--- a/source/mir/storage/store/ObjectStore.java
+++ b/source/mir/storage/store/ObjectStore.java
@@ -63,6 +63,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.MissingResourceException;
+
import javax.servlet.http.HttpServletRequest;
import mir.config.MirPropertiesConfiguration;
diff --git a/source/mir/storage/store/StoreContainer.java b/source/mir/storage/store/StoreContainer.java
index dafe1419..e1a455fa 100755
--- a/source/mir/storage/store/StoreContainer.java
+++ b/source/mir/storage/store/StoreContainer.java
@@ -67,7 +67,7 @@ public class StoreContainer {
protected LoggerWrapper logger = new LoggerWrapper("Database.ObjectStore");
// avoid construction without parameters
- private StoreContainer() {};
+ private StoreContainer() {}
public StoreContainer(StoreContainerType stoc_type) {
@@ -183,7 +183,7 @@ public class StoreContainer {
/**
* Method: toString()
* Description: gives out statistical Information, viewable via
- * @see ServletStoreInfo.
+ * @see ServletStoreInfo
*
* @return String
*/
diff --git a/source/mir/storage/store/test/EntityC1.java b/source/mir/storage/store/test/EntityC1.java
index 96273dec..837fb528 100755
--- a/source/mir/storage/store/test/EntityC1.java
+++ b/source/mir/storage/store/test/EntityC1.java
@@ -65,6 +65,6 @@ public class EntityC1 implements StorableObject {
// simulates a relation to EntityC2 with uniqueIdentifier "1"
notifiees.add(new StoreIdentifier(EntityC2.class,"1"));
notifiees.add(new StoreIdentifier(EntityC2.class,"18"));
- return (Set)notifiees;
+ return notifiees;
}
}
\ No newline at end of file
diff --git a/source/mir/util/CachingRewindableIterator.java b/source/mir/util/CachingRewindableIterator.java
index 1bbfc0a8..0678e746 100755
--- a/source/mir/util/CachingRewindableIterator.java
+++ b/source/mir/util/CachingRewindableIterator.java
@@ -67,5 +67,5 @@ public class CachingRewindableIterator implements RewindableIterator {
public void rewind() {
iterationPosition=0;
- };
+ }
}
\ No newline at end of file
diff --git a/source/mir/util/DateTimeFunctions.java b/source/mir/util/DateTimeFunctions.java
index f89ef89d..4eff7486 100755
--- a/source/mir/util/DateTimeFunctions.java
+++ b/source/mir/util/DateTimeFunctions.java
@@ -45,6 +45,15 @@ public class DateTimeFunctions {
private DateTimeFunctions() {
}
+
+ private final static String SPACE = "[\t\n\r ]*";
+ private final static String NUMBER = "[0-9]*";
+ private final static String TWODIGITNUMBER = "[0-9][0-9]";
+ private final static String FOURDIGITNUMBER = "[0-9][0-9][0-9][0-9]";
+ private final static String FRACTION = "(\\.[0-9]*)|)";
+ private final static String SIGN = "[-+]";
+ private final static String TZD = "(Z|(+|-)([0-9][0-9]:[0-9][0-9]|[0-9][0-9][0-9][0-9]))";
+
/**
* Function to parse a W3CDTF formatted string.
*
@@ -52,16 +61,8 @@ public class DateTimeFunctions {
* YYYY[-MM[-DD[Thh:mm[:ss[.s*]]TZD]]]
*
* @param aString
- * @return
+ * @return Date
*/
- private final static String SPACE = "[\t\n\r ]*";
- private final static String NUMBER = "[0-9]*";
- private final static String TWODIGITNUMBER = "[0-9][0-9]";
- private final static String FOURDIGITNUMBER = "[0-9][0-9][0-9][0-9]";
- private final static String FRACTION = "(\\.[0-9]*)|)";
- private final static String SIGN = "[-+]";
- private final static String TZD = "(Z|(+|-)([0-9][0-9]:[0-9][0-9]|[0-9][0-9][0-9][0-9]))";
-
public static Date parseW3CDTFString(String aString) throws UtilExc, UtilFailure {
try {
int year = 1;
diff --git a/source/mir/util/FileFunctions.java b/source/mir/util/FileFunctions.java
index c9e6a109..476451c8 100755
--- a/source/mir/util/FileFunctions.java
+++ b/source/mir/util/FileFunctions.java
@@ -29,13 +29,20 @@
*/
package mir.util;
-import java.io.*;
+import gnu.regexp.RE;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import gnu.regexp.RE;
-
public class FileFunctions {
protected static final int FILE_COPY_BUFFER_SIZE = 65536;
@@ -146,7 +153,7 @@ public class FileFunctions {
inputStream.close();
}
aSource.delete();
- };
+ }
}
public static class RegExpFileFilter implements FilenameFilter {
@@ -179,8 +186,7 @@ public class FileFunctions {
Object[] contents = aDirectory.list(aFilter);
if (contents==null)
return Collections.EMPTY_LIST;
- else
- return Arrays.asList(contents);
+ return Arrays.asList(contents);
}
public static String getExtension(String aPath) {
@@ -188,9 +194,7 @@ public class FileFunctions {
if (position>=0) {
return aPath.substring(position+1);
}
- else {
- return "";
- }
+ return "";
}
public static boolean isAbsolutePath(String aPath) {
@@ -201,8 +205,6 @@ public class FileFunctions {
if (isAbsolutePath(aPath)) {
return new File(aPath);
}
- else {
- return new File(aParentIfRelative, aPath);
- }
+ return new File(aParentIfRelative, aPath);
}
}
\ No newline at end of file
diff --git a/source/mir/util/GeneratorDateTimeFunctions.java b/source/mir/util/GeneratorDateTimeFunctions.java
index d7d88beb..36a8d11a 100755
--- a/source/mir/util/GeneratorDateTimeFunctions.java
+++ b/source/mir/util/GeneratorDateTimeFunctions.java
@@ -90,7 +90,7 @@ public class GeneratorDateTimeFunctions {
catch (Throwable t) {
throw new GeneratorFailure("encodeURIGeneratorFunction: " + t.getMessage(), t);
}
- };
+ }
}
diff --git a/source/mir/util/GeneratorFormatAdapters.java b/source/mir/util/GeneratorFormatAdapters.java
index becea34c..7c7f5a39 100755
--- a/source/mir/util/GeneratorFormatAdapters.java
+++ b/source/mir/util/GeneratorFormatAdapters.java
@@ -72,7 +72,7 @@ public class GeneratorFormatAdapters {
catch (Throwable t) {
throw new GeneratorFailure("NumberFormattingFunction: " + t.getMessage(), t);
}
- };
+ }
}
}
@@ -149,7 +149,7 @@ public class GeneratorFormatAdapters {
catch (Throwable t) {
throw new GeneratorFailure("DateFormattingFunction: " + t.getMessage(), t);
}
- };
+ }
}
/**
diff --git a/source/mir/util/HTTPParsedRequest.java b/source/mir/util/HTTPParsedRequest.java
index 3d9d96ff..881db9c3 100755
--- a/source/mir/util/HTTPParsedRequest.java
+++ b/source/mir/util/HTTPParsedRequest.java
@@ -29,13 +29,23 @@
*/
package mir.util;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
import mir.log.LoggerWrapper;
+
import org.apache.commons.fileupload.DiskFileUpload;
import org.apache.commons.fileupload.FileItem;
-import javax.servlet.http.HttpServletRequest;
-import java.util.*;
-
public class HTTPParsedRequest {
static final String MULTIPART_FORMDATA_CONTENTTYPE = "multipart/form-data";
diff --git a/source/mir/util/HTTPRequestParser.java b/source/mir/util/HTTPRequestParser.java
index 46954688..a24c468d 100755
--- a/source/mir/util/HTTPRequestParser.java
+++ b/source/mir/util/HTTPRequestParser.java
@@ -31,9 +31,10 @@
package mir.util;
import java.util.ArrayList;
-import java.util.List;
import java.util.Collections;
+import java.util.List;
import java.util.Map;
+
import javax.servlet.http.HttpServletRequest;
public class HTTPRequestParser {
diff --git a/source/mir/util/InternetFunctions.java b/source/mir/util/InternetFunctions.java
index 2260d4db..a510aa30 100755
--- a/source/mir/util/InternetFunctions.java
+++ b/source/mir/util/InternetFunctions.java
@@ -31,8 +31,8 @@
package mir.util;
-import java.util.List;
import java.net.InetAddress;
+import java.util.List;
public class InternetFunctions {
private InternetFunctions() {
diff --git a/source/mir/util/ParameterExpander.java b/source/mir/util/ParameterExpander.java
index e397f6f3..3077611a 100755
--- a/source/mir/util/ParameterExpander.java
+++ b/source/mir/util/ParameterExpander.java
@@ -29,14 +29,19 @@
*/
package mir.util;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
import mir.generator.Generator;
import mir.generator.GeneratorExc;
import multex.Exc;
+
import org.apache.commons.beanutils.MethodUtils;
import org.apache.commons.beanutils.PropertyUtils;
-import java.util.*;
-
/**
* Class to work with expressions. Will be gradually phased out and replaced
* with {@link mir.util.expressions.ExpressionParser}
@@ -263,25 +268,25 @@ public class ParameterExpander {
private static abstract class Token {
}
- public static abstract class PunctuationToken extends Token { public PunctuationToken() { }; }
- private static class LeftSquareBraceToken extends PunctuationToken {};
- private static class RightSquareBraceToken extends PunctuationToken {};
- private static class EqualsToken extends PunctuationToken {};
- private static class EqualsNotToken extends PunctuationToken {};
- private static class NOTToken extends PunctuationToken {};
- private static class LeftParenthesisToken extends PunctuationToken {};
- private static class RightParenthesisToken extends PunctuationToken {};
- private static class CommaToken extends PunctuationToken {};
- private static class PeriodToken extends PunctuationToken {};
- private static class PlusToken extends PunctuationToken {};
- private static class TimesToken extends PunctuationToken {};
- private static class DivideToken extends PunctuationToken {};
- private static class MinusToken extends PunctuationToken {};
- private static class ConcatenateToken extends PunctuationToken {};
- private static class LessThanOrEqualsToken extends PunctuationToken {};
- private static class GreaterThanOrEqualsToken extends PunctuationToken {};
- private static class LessThanToken extends PunctuationToken {};
- private static class GreaterThanToken extends PunctuationToken {};
+ public static abstract class PunctuationToken extends Token { public PunctuationToken() { } }
+ private static class LeftSquareBraceToken extends PunctuationToken {}
+ private static class RightSquareBraceToken extends PunctuationToken {}
+ private static class EqualsToken extends PunctuationToken {}
+ private static class EqualsNotToken extends PunctuationToken {}
+ private static class NOTToken extends PunctuationToken {}
+ private static class LeftParenthesisToken extends PunctuationToken {}
+ private static class RightParenthesisToken extends PunctuationToken {}
+ private static class CommaToken extends PunctuationToken {}
+ private static class PeriodToken extends PunctuationToken {}
+ private static class PlusToken extends PunctuationToken {}
+ private static class TimesToken extends PunctuationToken {}
+ private static class DivideToken extends PunctuationToken {}
+ private static class MinusToken extends PunctuationToken {}
+ private static class ConcatenateToken extends PunctuationToken {}
+ private static class LessThanOrEqualsToken extends PunctuationToken {}
+ private static class GreaterThanOrEqualsToken extends PunctuationToken {}
+ private static class LessThanToken extends PunctuationToken {}
+ private static class GreaterThanToken extends PunctuationToken {}
private static class IdentifierToken extends Token {
@@ -443,7 +448,7 @@ public class ParameterExpander {
public void skipWhitespace() {
while (reader.hasNext() && Character.isWhitespace(reader.peek().charValue()))
reader.getNext();
- };
+ }
private boolean isIdentifierStart(char c) {
return Character.isLetter(c) || (c == '_');
diff --git a/source/mir/util/PropertiesManipulator.java b/source/mir/util/PropertiesManipulator.java
index 0044577e..a820f57b 100755
--- a/source/mir/util/PropertiesManipulator.java
+++ b/source/mir/util/PropertiesManipulator.java
@@ -35,7 +35,11 @@ import java.io.LineNumberReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import multex.Exc;
import multex.Failure;
diff --git a/source/mir/util/ReflectionRoutines.java b/source/mir/util/ReflectionRoutines.java
index b15014f9..df34672b 100755
--- a/source/mir/util/ReflectionRoutines.java
+++ b/source/mir/util/ReflectionRoutines.java
@@ -1,60 +1,60 @@
-/*
- * Copyright (C) 2001, 2002 The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your version.
- */
-package mir.util;
-
-import org.apache.commons.beanutils.MethodUtils;
-
-import java.lang.reflect.InvocationTargetException;
-
-public class ReflectionRoutines {
- private ReflectionRoutines() {
- }
-
- /**
- * Method to overcome a shortcoming in {@link org.apache.commons.beanutils}'s
- * {@link MethodUtils#invokeMethod(Object, String, Object[])} involving
- * parameters that are null
- */
- public static Object invokeMethod(Object aTarget, String aMethodName, Object[] aParameters)
- throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
- Class parameterTypes[] = new Class[aParameters.length];
-
- for (int i=0; inull
+ */
+ public static Object invokeMethod(Object aTarget, String aMethodName, Object[] aParameters)
+ throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+ Class parameterTypes[] = new Class[aParameters.length];
+
+ for (int i=0; iTitle:
- * Description:
- * Copyright: Copyright (c) 2003
- * Company:
- * @author not attributable
- * @version 1.0
- */
-
-public abstract class AbstractSectionHandler implements SectionHandler {
- public void extra(String anExtraData) throws XMLParserExc, XMLParserFailure {
- }
-
- public SectionHandler startElement(XMLName aTag, java.util.Map anAttributes) throws XMLParserExc{
- return startElement(aTag.getLocalName(), XMLReaderTool.convertXMLAttributeMap(anAttributes));
- };
-
- public SectionHandler startElement(String aLocalName, java.util.Map anAttributes) throws XMLParserExc{
- return new AbstractSectionHandler() {};
- };
-
- public void endElement(SectionHandler aHandler) throws XMLParserExc{
- };
-
- public void startSection() throws XMLParserExc{
- }
-
- public void finishSection() throws XMLParserExc{
- }
-
- public void characters(String aCharacters) throws XMLParserExc{
- if ( aCharacters.trim().length() > 0) {
- throw new XMLParserExc("Text not allowed");
- }
- }
-}
+package mir.util.xml;
+
+/**
+ *
+ * Title:
+ * Description:
+ * Copyright: Copyright (c) 2003
+ * Company:
+ * @author not attributable
+ * @version 1.0
+ */
+
+public abstract class AbstractSectionHandler implements SectionHandler {
+ public void extra(String anExtraData) throws XMLParserExc, XMLParserFailure {
+ }
+
+ public SectionHandler startElement(XMLName aTag, java.util.Map anAttributes) throws XMLParserExc{
+ return startElement(aTag.getLocalName(), XMLReaderTool.convertXMLAttributeMap(anAttributes));
+ }
+
+ public SectionHandler startElement(String aLocalName, java.util.Map anAttributes) throws XMLParserExc{
+ return new AbstractSectionHandler() {};
+ }
+
+ public void endElement(SectionHandler aHandler) throws XMLParserExc{
+ }
+
+ public void startSection() throws XMLParserExc{
+ }
+
+ public void finishSection() throws XMLParserExc{
+ }
+
+ public void characters(String aCharacters) throws XMLParserExc{
+ if ( aCharacters.trim().length() > 0) {
+ throw new XMLParserExc("Text not allowed");
+ }
+ }
+}
diff --git a/source/mir/util/xml/XMLName.java b/source/mir/util/xml/XMLName.java
index a9f60582..173bc016 100755
--- a/source/mir/util/xml/XMLName.java
+++ b/source/mir/util/xml/XMLName.java
@@ -1,88 +1,86 @@
-package mir.util.xml;
-
-/**
- * Class to encapsulate an XML-style name (either for tagnames,
- * or attribute names).
- *
- *
- * Usage requirements:
- *
- * - Namespace aware parsers must supply a local name
- * and a namespace URI
- *
- Non-namespace aware parsers should supply a local name,
- * and, if present and applicable, also a prefix
- *
- */
-
-public class XMLName {
- private String namespaceURI;
- private String localName;
- private String prefix;
-
- public XMLName(String aLocalName) {
- this(null, null, aLocalName);
- }
-
- public XMLName(String aNamespaceURI, String aPrefix, String aLocalName) {
- localName="";
- prefix="";
- namespaceURI="";
-
- if (aLocalName!=null)
- localName = aLocalName;
- if (aPrefix!=null)
- prefix = aPrefix;
- if (aNamespaceURI!=null)
- namespaceURI = aNamespaceURI;
- }
-
- public XMLName(String aNamespaceURI, String aLocalName) {
- this (aNamespaceURI, null, aLocalName);
- }
-
- /**
- * Returns the namespace URI if available
- */
- public String getNamespaceURI() {
- return namespaceURI;
- }
-
- /**
- * Returns the name of the tag, stripped from prefix
- */
- public String getLocalName() {
- return localName;
- }
-
- /**
- * Returns the prefix of the tag, if present
- */
- public String getPrefix() {
- return prefix;
- }
-
- public int hashCode() {
- if (namespaceURI == null)
- return localName.hashCode() + 3*prefix.hashCode();
- else
- return localName.hashCode() + 3*namespaceURI.hashCode();
- }
-
- public String toString() {
- return ((namespaceURI.length()>0)? "["+namespaceURI+"]":"")+((prefix.length()>0)?prefix+":":"")+localName;
- }
-
- public boolean equals(Object anObject) {
- if (anObject instanceof mir.util.xml.XMLName) {
- if (namespaceURI==null)
- return (((mir.util.xml.XMLName) anObject).namespaceURI == null) &&
- prefix.equals(((mir.util.xml.XMLName) anObject).prefix) &&
- localName.equals(((mir.util.xml.XMLName) anObject).localName);
- else
- return namespaceURI.equals(((mir.util.xml.XMLName) anObject).namespaceURI) &&
- localName.equals(((mir.util.xml.XMLName) anObject).localName);
- }
- else
- return false;
- }
-}
+package mir.util.xml;
+
+/**
+ * Class to encapsulate an XML-style name (either for tagnames,
+ * or attribute names).
+ *
+ *
+ * Usage requirements:
+ *
+ * - Namespace aware parsers must supply a local name
+ * and a namespace URI
+ *
- Non-namespace aware parsers should supply a local name,
+ * and, if present and applicable, also a prefix
+ *
+ */
+
+public class XMLName {
+ private String namespaceURI;
+ private String localName;
+ private String prefix;
+
+ public XMLName(String aLocalName) {
+ this(null, null, aLocalName);
+ }
+
+ public XMLName(String aNamespaceURI, String aPrefix, String aLocalName) {
+ localName="";
+ prefix="";
+ namespaceURI="";
+
+ if (aLocalName!=null)
+ localName = aLocalName;
+ if (aPrefix!=null)
+ prefix = aPrefix;
+ if (aNamespaceURI!=null)
+ namespaceURI = aNamespaceURI;
+ }
+
+ public XMLName(String aNamespaceURI, String aLocalName) {
+ this (aNamespaceURI, null, aLocalName);
+ }
+
+ /**
+ * Returns the namespace URI if available
+ */
+ public String getNamespaceURI() {
+ return namespaceURI;
+ }
+
+ /**
+ * Returns the name of the tag, stripped from prefix
+ */
+ public String getLocalName() {
+ return localName;
+ }
+
+ /**
+ * Returns the prefix of the tag, if present
+ */
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public int hashCode() {
+ if (namespaceURI == null)
+ return localName.hashCode() + 3*prefix.hashCode();
+ return localName.hashCode() + 3*namespaceURI.hashCode();
+ }
+
+ public String toString() {
+ return ((namespaceURI.length()>0)? "["+namespaceURI+"]":"")+((prefix.length()>0)?prefix+":":"")+localName;
+ }
+
+ public boolean equals(Object anObject) {
+ if (anObject instanceof mir.util.xml.XMLName) {
+ if (namespaceURI==null)
+ return (((mir.util.xml.XMLName) anObject).namespaceURI == null) &&
+ prefix.equals(((mir.util.xml.XMLName) anObject).prefix) &&
+ localName.equals(((mir.util.xml.XMLName) anObject).localName);
+ else
+ return namespaceURI.equals(((mir.util.xml.XMLName) anObject).namespaceURI) &&
+ localName.equals(((mir.util.xml.XMLName) anObject).localName);
+ }
+ return false;
+ }
+}
diff --git a/source/mir/util/xml/XMLParserEngine.java b/source/mir/util/xml/XMLParserEngine.java
index ee70a134..9b4d9286 100755
--- a/source/mir/util/xml/XMLParserEngine.java
+++ b/source/mir/util/xml/XMLParserEngine.java
@@ -31,16 +31,15 @@
package mir.util.xml;
import java.io.BufferedInputStream;
+import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
-import java.io.StringReader;
-import java.io.File;
-import java.io.Reader;
import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
-
import java.util.Stack;
import mir.util.ExceptionFunctions;
diff --git a/source/mir/util/xml/XMLParserFailure.java b/source/mir/util/xml/XMLParserFailure.java
index b96d4511..e6c0b66d 100755
--- a/source/mir/util/xml/XMLParserFailure.java
+++ b/source/mir/util/xml/XMLParserFailure.java
@@ -1,20 +1,25 @@
-package mir.util.xml;
-
-/**
- *
- * Title:
- * Description:
- * Copyright: Copyright (c) 2003
- * Company:
- * @author not attributable
- * @version 1.0
- */
-public class XMLParserFailure extends multex.Failure {
- public XMLParserFailure(String aMessage, Throwable aCause) {
- super(aMessage, aCause);
- }
-
- public XMLParserFailure(Throwable aCause) {
- super(aCause.getMessage(), aCause);
- }
-}
+package mir.util.xml;
+
+/**
+ *
+ * Title:
+ * Description:
+ * Copyright: Copyright (c) 2003
+ * Company:
+ * @author not attributable
+ * @version 1.0
+ */
+public class XMLParserFailure extends multex.Failure {
+ /**
+ * Comment for serialVersionUID
+ */
+ private static final long serialVersionUID = 1L;
+
+ public XMLParserFailure(String aMessage, Throwable aCause) {
+ super(aMessage, aCause);
+ }
+
+ public XMLParserFailure(Throwable aCause) {
+ super(aCause.getMessage(), aCause);
+ }
+}
diff --git a/source/mir/util/xml/XMLReaderTool.java b/source/mir/util/xml/XMLReaderTool.java
index fb4859db..84fa8b41 100755
--- a/source/mir/util/xml/XMLReaderTool.java
+++ b/source/mir/util/xml/XMLReaderTool.java
@@ -120,8 +120,7 @@ public class XMLReaderTool {
if (parts.size()==1)
return (String) parts.get(0);
- else
- return (String) parts.get(1);
+ return (String) parts.get(1);
}
/**
diff --git a/source/mir/util/xml/XMLSAXParserProvider.java b/source/mir/util/xml/XMLSAXParserProvider.java
index 0e8a8514..c5ee60ab 100755
--- a/source/mir/util/xml/XMLSAXParserProvider.java
+++ b/source/mir/util/xml/XMLSAXParserProvider.java
@@ -1,160 +1,161 @@
-package mir.util.xml;
-
-import java.util.*;
-
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXParseException;
-import mir.util.ExceptionFunctions;
-
-/**
- *
- * Title:
- * Description:
- * Copyright: Copyright (c) 2003
- * Company:
- * @author not attributable
- * @version 1.0
- */
-class XMLSAXParserProvider implements XMLParserEngine.XMLParserProvider {
- private boolean nameSpaceAware;
-
- public XMLSAXParserProvider(boolean aNameSpaceAware) {
- nameSpaceAware = aNameSpaceAware;
- }
-
- public void parse(java.io.Reader aReader, XMLParserEngine.XMLParserReceiver aReceiver) throws XMLParserExc, XMLParserFailure {
- try {
- javax.xml.parsers.SAXParserFactory parserFactory = javax.xml.parsers.SAXParserFactory.newInstance();
-
- parserFactory.setNamespaceAware(true);
- parserFactory.setValidating(true);
- javax.xml.parsers.SAXParser parser = parserFactory.newSAXParser();
-
- parser.parse(new InputSource(aReader), new SAXHandler(aReceiver));
- }
- catch (org.xml.sax.SAXException e) {
- Throwable t = ExceptionFunctions.traceCauseException(e);
-
- if (t instanceof XMLParserExc) {
- throw (XMLParserExc) t;
- }
-
- if (t instanceof XMLParserFailure) {
- throw (XMLParserFailure) t;
- }
-
- if (t instanceof SAXParseException) {
- throw new XMLParserExc(t.getMessage());
- }
-
- throw new XMLParserFailure(t);
- }
- catch (Throwable t) {
- throw new XMLParserFailure(t);
- }
- }
-
- private class SAXHandler extends org.xml.sax.helpers.DefaultHandler {
- private XMLParserEngine.XMLParserReceiver receiver;
-
- public SAXHandler(XMLParserEngine.XMLParserReceiver aReceiver) throws XMLParserExc, XMLParserFailure {
- super();
-
- receiver = aReceiver;
- receiver.startDocument();
- }
-
- public void setDocumentLocator(final Locator aLocator) {
- receiver.setLocator(
- new XMLParserEngine.XMLLocator() {
- public int getLineNr() {
- return aLocator.getLineNumber();
- }
-
- public int getColumnNr() {
- return aLocator.getColumnNumber();
- }
- }
- );
- }
-
- public void startElement(String aUri, String aLocalName, String aQualifiedName, org.xml.sax.Attributes anAttributes) throws org.xml.sax.SAXException {
- try {
- Map attributes = new java.util.HashMap();
-
- XMLName tag;
- if (nameSpaceAware) {
- tag = new XMLName(aUri, XMLReaderTool.getPrefixFromQualifiedName(aQualifiedName), aLocalName);
- for (int i=0; iTitle:
+ * Description:
+ * Copyright: Copyright (c) 2003
+ * Company:
+ * @author not attributable
+ * @version 1.0
+ */
+class XMLSAXParserProvider implements XMLParserEngine.XMLParserProvider {
+ private boolean nameSpaceAware;
+
+ public XMLSAXParserProvider(boolean aNameSpaceAware) {
+ nameSpaceAware = aNameSpaceAware;
+ }
+
+ public void parse(java.io.Reader aReader, XMLParserEngine.XMLParserReceiver aReceiver) throws XMLParserExc, XMLParserFailure {
+ try {
+ javax.xml.parsers.SAXParserFactory parserFactory = javax.xml.parsers.SAXParserFactory.newInstance();
+
+ parserFactory.setNamespaceAware(true);
+ parserFactory.setValidating(true);
+ javax.xml.parsers.SAXParser parser = parserFactory.newSAXParser();
+
+ parser.parse(new InputSource(aReader), new SAXHandler(aReceiver));
+ }
+ catch (org.xml.sax.SAXException e) {
+ Throwable t = ExceptionFunctions.traceCauseException(e);
+
+ if (t instanceof XMLParserExc) {
+ throw (XMLParserExc) t;
+ }
+
+ if (t instanceof XMLParserFailure) {
+ throw (XMLParserFailure) t;
+ }
+
+ if (t instanceof SAXParseException) {
+ throw new XMLParserExc(t.getMessage());
+ }
+
+ throw new XMLParserFailure(t);
+ }
+ catch (Throwable t) {
+ throw new XMLParserFailure(t);
+ }
+ }
+
+ private class SAXHandler extends org.xml.sax.helpers.DefaultHandler {
+ private XMLParserEngine.XMLParserReceiver receiver;
+
+ public SAXHandler(XMLParserEngine.XMLParserReceiver aReceiver) throws XMLParserExc, XMLParserFailure {
+ super();
+
+ receiver = aReceiver;
+ receiver.startDocument();
+ }
+
+ public void setDocumentLocator(final Locator aLocator) {
+ receiver.setLocator(
+ new XMLParserEngine.XMLLocator() {
+ public int getLineNr() {
+ return aLocator.getLineNumber();
+ }
+
+ public int getColumnNr() {
+ return aLocator.getColumnNumber();
+ }
+ }
+ );
+ }
+
+ public void startElement(String aUri, String aLocalName, String aQualifiedName, org.xml.sax.Attributes anAttributes) throws org.xml.sax.SAXException {
+ try {
+ Map attributes = new java.util.HashMap();
+
+ XMLName tag;
+ if (nameSpaceAware) {
+ tag = new XMLName(aUri, XMLReaderTool.getPrefixFromQualifiedName(aQualifiedName), aLocalName);
+ for (int i=0; i') {
diff --git a/source/mir/util/xml/html/HTMLSchemaInformation.java b/source/mir/util/xml/html/HTMLSchemaInformation.java
index 58562144..8250d22e 100755
--- a/source/mir/util/xml/html/HTMLSchemaInformation.java
+++ b/source/mir/util/xml/html/HTMLSchemaInformation.java
@@ -1,6 +1,9 @@
package mir.util.xml.html;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public class HTMLSchemaInformation {
private Map tags;
diff --git a/source/mir/util/xml/html/XMLHTMLParserProvider.java b/source/mir/util/xml/html/XMLHTMLParserProvider.java
index 31bcc85e..8b19693f 100755
--- a/source/mir/util/xml/html/XMLHTMLParserProvider.java
+++ b/source/mir/util/xml/html/XMLHTMLParserProvider.java
@@ -1,96 +1,96 @@
-package mir.util.xml.html;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import mir.util.xml.XMLParserEngine;
-import mir.util.xml.XMLParserExc;
-import mir.util.xml.XMLParserFailure;
-import mir.util.xml.XMLReaderTool;
-import mir.util.xml.XMLName;
-
-/**
- */
-
-public class XMLHTMLParserProvider implements XMLParserEngine.XMLParserProvider {
- public XMLHTMLParserProvider() {
- }
-
- public void parse(java.io.Reader aReader, final XMLParserEngine.XMLParserReceiver aReceiver) throws XMLParserExc, XMLParserFailure {
- HTMLParser parser = new HTMLParser();
-
- try {
- aReceiver.startDocument();
-
- parser.parse(aReader, new HTMLParser.ParserReceiver() {
- public void dtd(String aDTD) throws HTMLParserExc {
- try {
- aReceiver.extra(aDTD);
- }
- catch (XMLParserExc t) {
- throw new HTMLParserFailure(t);
- }
- }
-
- public void openTag(String aTag, Map anAttributes) {
- Map attributes = new HashMap();
- Iterator i = anAttributes.entrySet().iterator();
-
- while (i.hasNext()) {
- Map.Entry entry = (Map.Entry) i.next();
- XMLName key = XMLReaderTool.getXMLNameForQualifiedName((String) entry.getKey());
- String value = (String) entry.getValue();
- if (value==null)
- value = key.getLocalName();
-
- attributes.put(key, value);
- }
-
- try {
- aReceiver.startElement(XMLReaderTool.getXMLNameForQualifiedName(aTag), attributes);
- }
- catch (XMLParserExc e) {
- throw new HTMLParserFailure(e);
- }
- }
-
- public void closeTag(String aTag) {
- try {
- aReceiver.endElement(XMLReaderTool.getXMLNameForQualifiedName(aTag));
- }
- catch (XMLParserExc e) {
- throw new HTMLParserFailure(e);
- }
- }
-
- public void comment(String aData) {
- try {
- aReceiver.extra("");
- }
- catch (XMLParserExc e) {
- throw new HTMLParserFailure(e);
- }
- }
-
- public void cdata(String aData) {
- try {
- aReceiver.text(aData);
- }
- catch (XMLParserExc e) {
- throw new HTMLParserFailure(e);
- }
- }
- });
-
- aReceiver.endDocument();
- }
- catch (IOException e) {
- throw new XMLParserFailure(e);
- }
- catch (HTMLParserExc e) {
- throw new XMLParserFailure(e);
- }
- }
-}
+package mir.util.xml.html;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import mir.util.xml.XMLName;
+import mir.util.xml.XMLParserEngine;
+import mir.util.xml.XMLParserExc;
+import mir.util.xml.XMLParserFailure;
+import mir.util.xml.XMLReaderTool;
+
+/**
+ */
+
+public class XMLHTMLParserProvider implements XMLParserEngine.XMLParserProvider {
+ public XMLHTMLParserProvider() {
+ }
+
+ public void parse(java.io.Reader aReader, final XMLParserEngine.XMLParserReceiver aReceiver) throws XMLParserExc, XMLParserFailure {
+ HTMLParser parser = new HTMLParser();
+
+ try {
+ aReceiver.startDocument();
+
+ parser.parse(aReader, new HTMLParser.ParserReceiver() {
+ public void dtd(String aDTD) throws HTMLParserExc {
+ try {
+ aReceiver.extra(aDTD);
+ }
+ catch (XMLParserExc t) {
+ throw new HTMLParserFailure(t);
+ }
+ }
+
+ public void openTag(String aTag, Map anAttributes) {
+ Map attributes = new HashMap();
+ Iterator i = anAttributes.entrySet().iterator();
+
+ while (i.hasNext()) {
+ Map.Entry entry = (Map.Entry) i.next();
+ XMLName key = XMLReaderTool.getXMLNameForQualifiedName((String) entry.getKey());
+ String value = (String) entry.getValue();
+ if (value==null)
+ value = key.getLocalName();
+
+ attributes.put(key, value);
+ }
+
+ try {
+ aReceiver.startElement(XMLReaderTool.getXMLNameForQualifiedName(aTag), attributes);
+ }
+ catch (XMLParserExc e) {
+ throw new HTMLParserFailure(e);
+ }
+ }
+
+ public void closeTag(String aTag) {
+ try {
+ aReceiver.endElement(XMLReaderTool.getXMLNameForQualifiedName(aTag));
+ }
+ catch (XMLParserExc e) {
+ throw new HTMLParserFailure(e);
+ }
+ }
+
+ public void comment(String aData) {
+ try {
+ aReceiver.extra("");
+ }
+ catch (XMLParserExc e) {
+ throw new HTMLParserFailure(e);
+ }
+ }
+
+ public void cdata(String aData) {
+ try {
+ aReceiver.text(aData);
+ }
+ catch (XMLParserExc e) {
+ throw new HTMLParserFailure(e);
+ }
+ }
+ });
+
+ aReceiver.endDocument();
+ }
+ catch (IOException e) {
+ throw new XMLParserFailure(e);
+ }
+ catch (HTMLParserExc e) {
+ throw new XMLParserFailure(e);
+ }
+ }
+}
diff --git a/source/mircoders/abuse/FilterEngine.java b/source/mircoders/abuse/FilterEngine.java
index 7a61c852..56c72168 100755
--- a/source/mircoders/abuse/FilterEngine.java
+++ b/source/mircoders/abuse/FilterEngine.java
@@ -1,453 +1,460 @@
-/*
- * Copyright (C) 2001, 2002 The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your version.
- */
-
-package mircoders.abuse;
-
-import mir.entity.Entity;
-import mir.entity.adapter.EntityAdapter;
-import mir.entity.adapter.EntityAdapterModel;
-import mir.entity.adapter.EntityIteratorAdapter;
-import mir.log.LoggerWrapper;
-import mir.storage.StorageObjectExc;
-import mir.session.Request;
-import mir.config.MirPropertiesConfiguration;
-import mircoders.storage.DatabaseFilter;
-import mircoders.storage.DatabaseFilterGroup;
-import mircoders.global.MirGlobal;
-
-import java.util.*;
-import java.text.SimpleDateFormat;
-
-public class FilterEngine {
- private Map filterTypes;
- private List filterTypeIds;
-
- private List filterGroups;
- private Map idToFilterGroup;
- private LoggerWrapper logger;
- private EntityAdapterModel model;
- private SimpleDateFormat dateFormat;
- private MirPropertiesConfiguration configuration = MirPropertiesConfiguration.instance();
-
- public FilterEngine(EntityAdapterModel aModel) {
- logger = new LoggerWrapper("Global.Abuse.FilterEngine");
- filterGroups = new ArrayList();
- idToFilterGroup = new HashMap();
-
- filterTypes = new HashMap();
- filterTypeIds = new ArrayList();
- try {
- Iterator i = MirGlobal.localizer().openPostings().getAntiAbuseFilterTypes().iterator();
- while (i.hasNext()) {
- FilterType filterType = (FilterType) i.next();
-
- filterTypes.put(filterType.getName(), filterType);
- filterTypeIds.add(filterType.getName());
- }
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
-
- model = aModel;
-
- dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- dateFormat.setTimeZone(TimeZone.getTimeZone(configuration.getString("Mir.DefaultTimezone")));
- reload();
- }
-
- public Filter testPosting(Entity anEntity, Request aRequest) {
- Iterator i = filterGroups.iterator();
- while (i.hasNext()) {
- FilterGroup group = (FilterGroup) i.next();
- Iterator j = group.getFilters().iterator();
- while (j.hasNext()) {
- Filter filter = (Filter) j.next();
- try {
- if (filter.test(anEntity, aRequest)) {
- return filter;
- }
- }
- catch (Throwable t) {
- logger.warn("Exception thrown while testing filter " + filter.getType() + " ( " + filter.getExpression() + ") " + t.toString());
- }
- }
- }
-
- return null;
- }
-
- public List getFilterTypes() {
- try {
- List result = new ArrayList();
-
- Iterator i = filterTypeIds.iterator();
- while (i.hasNext()) {
- String id = (String) i.next();
-
- Map action = new HashMap();
- action.put("resource", id);
- action.put("identifier", id);
-
- result.add(action);
- }
-
- return result;
- }
- catch (Throwable t) {
- throw new RuntimeException("can't get article actions");
- }
- }
-
- public class FilterGroup {
- private List filters;
- private Entity entity;
- private Map idToFilter;
-
- public FilterGroup(Entity anEntity) {
- this (anEntity, Collections.EMPTY_LIST);
- }
-
- public FilterGroup(Entity anEntity, List aFilters) {
- entity = anEntity;
- filters = new ArrayList();
- idToFilter = new HashMap();
- Iterator i = aFilters.iterator();
-
- while (i.hasNext()) {
- Entity entity = (Entity) i.next();
- try {
- Filter filter = new Filter(entity);
- introduceFilter(filter);
- }
- catch (AbuseExc e) {
- }
- }
- }
-
- public Entity getEntity() {
- return entity;
- }
-
- public EntityAdapter getEntityAdapter() {
- return model.makeEntityAdapter("filterGroup", entity);
- }
-
- public List getFilterEntityAdapterList() {
- List result = new ArrayList();
-
- Iterator i = filters.iterator();
- while (i.hasNext()) {
- Filter filter = (Filter) i.next();
- result.add(filter.getEntityAdapter());
- }
-
- return result;
- }
-
- public List getFilters() {
- return filters;
- }
-
- public Filter getFilterForId(String anId) {
- Filter result = (Filter) idToFilter.get(anId);
- if (result==null) {
- throw new NullPointerException("No such filter");
- }
-
- return result;
- }
-
- private void introduceFilter(Filter aFilter) {
- filters.add(aFilter);
- idToFilter.put(aFilter.getEntity().getId(), aFilter);
- }
-
- private void removeFilter(Filter aFilter) {
- filters.remove(aFilter);
- idToFilter.remove(aFilter.getEntity().getId());
- }
-
- private void deleteFilter(String anId) {
- Filter filter = getFilterForId(anId);
- removeFilter(filter);
- DatabaseFilter.getInstance().delete(anId);
- }
-
- public void populateFilterEntity(Entity anEntity, String aType, String anExpression,
- String aComments, String aTag, String anArticleAction,
- String aCommentAction) {
-
- anEntity.setFieldValue("type", aType);
- anEntity.setFieldValue("expression", anExpression);
- anEntity.setFieldValue("comment", aComments);
- anEntity.setFieldValue("tag", aTag);
- anEntity.setFieldValue("articleaction", anArticleAction);
- anEntity.setFieldValue("commentaction", aCommentAction);
- }
-
- public String updateFilter(String anId, String aType, String anExpression,
- String aComments, String aTag, String anArticleAction,
- String aCommentAction) {
-
- try {
- getFilterTypeForId(aType).constructFilterInstance(anExpression);
- }
- catch (AbuseExc e) {
- return e.getMessage();
- }
-
- Entity entity = getFilterForId(anId).getEntity();
- populateFilterEntity(entity, aType, anExpression, aComments, aTag,
- anArticleAction, aCommentAction);
- entity.update();
-
- return "";
- }
-
- public String createFilter(String aType, String anExpression,
- String aComments, String aTag, String anArticleAction,
- String aCommentAction) throws StorageObjectExc {
- FilterInstance instance;
-
- try {
- instance = getFilterTypeForId(aType).constructFilterInstance(anExpression);
- }
- catch (AbuseExc e) {
- return e.getMessage();
- }
-
- Entity entity = DatabaseFilter.getInstance().createNewEntity();
- populateFilterEntity(entity, aType, anExpression, aComments, aTag,
- anArticleAction, aCommentAction);
- entity.setFieldValue("priority", "1");
- entity.setFieldValue("filter_group_id", getEntity().getId());
- entity.insert();
-
- Filter filter = new Filter(entity, instance);
- introduceFilter(filter);
-
- return "";
- }
-
- public String getName() {
- return entity.getFieldValue("name");
- }
- }
-
- public class Filter {
- private Entity entity;
- private FilterInstance instance;
-
- public Filter(Entity anEntity) throws AbuseExc {
- this(anEntity, getFilterTypeForId(anEntity.getFieldValue("type")).constructFilterInstance(anEntity.getFieldValue("expression")));
- }
-
- public Filter(Entity anEntity, FilterInstance anInstance) {
- entity = anEntity;
- instance = anInstance;
- }
-
- public Entity getEntity() {
- return entity;
- }
-
- public EntityAdapter getEntityAdapter() {
- return model.makeEntityAdapter("filter", entity);
- }
-
- public void update(String aType, String anExpression, String aComments, String aTag,
- String anArticleAction, String aCommentAction) throws AbuseExc {
-
- instance = getFilterTypeForId(aType).constructFilterInstance(anExpression);
-
- entity.setFieldValue("type", aType);
- entity.setFieldValue("expression", anExpression);
- entity.setFieldValue("tag", aType);
- entity.setFieldValue("comment", aComments);
- entity.setFieldValue("articleaction", anArticleAction);
- entity.setFieldValue("commentaction", aCommentAction);
- entity.setFieldValue("last_hit", null);
- entity.update();
- }
-
- public void updateLastHit(Date aDate) {
- entity.setFieldValue("last_hit", dateFormat.format(aDate));
- entity.update();
- }
-
- public String getType() {
- return entity.getFieldValue("type");
- }
-
- public String getExpression() {
- return entity.getFieldValue("expression");
- }
-
- public String getTag() {
- return entity.getFieldValue("tag");
- }
-
- public String getComment() {
- return entity.getFieldValue("comment");
- }
-
- public String getArticleAction() {
- return entity.getFieldValue("articleaction");
- }
-
- public String getCommentAction() {
- return entity.getFieldValue("commentaction");
- }
-
- public FilterInstance getInstance() {
- return instance;
- }
-
- public boolean test(Entity anEntity, Request aRequest) {
- return instance.test(anEntity, aRequest);
- }
- }
-
- public synchronized void reload() {
- filterGroups.clear();
- idToFilterGroup.clear();
-
- try {
- Iterator i = new EntityIteratorAdapter("", "priority asc", 100, model, "filterGroup");
- while (i.hasNext()) {
- EntityAdapter entityAdapter = (EntityAdapter) i.next();
- List filters = new ArrayList();
- Iterator j = (Iterator) entityAdapter.get("to_filters");
- while (j.hasNext()) {
- filters.add(((EntityAdapter) j.next()).getEntity());
- }
-
- FilterGroup filterGroup = new FilterGroup(entityAdapter.getEntity(), filters);
- introduceFilterGroup(filterGroup);
- }
- }
- catch (Throwable e) {
- logger.error("Can't load filters: " + e.getMessage());
- }
- }
-
- public synchronized List getFilterGroups() {
- List result = new ArrayList();
- Iterator i = filterGroups.iterator();
- while (i.hasNext()) {
- result.add(((FilterGroup) i.next()).getEntityAdapter());
- }
-
- return result;
- }
-
- public synchronized void updateFilterGroup(String anId, String aName) {
- FilterGroup filterGroup = getFilterGroupForId(anId);
- filterGroup.getEntity().setFieldValue("name", aName);
- filterGroup.getEntity().update();
- }
-
- public synchronized void addFilterGroup(String aName) throws StorageObjectExc {
- Entity entity = DatabaseFilterGroup.getInstance().createNewEntity();
- entity.setFieldValue("name", aName);
- entity.setFieldValue("priority", "1");
- entity.insert();
-
- FilterGroup filterGroup = new FilterGroup(entity);
- introduceFilterGroup(filterGroup);
- }
-
- public synchronized void deleteFilterGroup(String anId) {
-
- FilterGroup filterGroup = getFilterGroupForId(anId);
- removeFilterGroup(filterGroup);
- DatabaseFilter.getInstance().deleteByWhereClause("filter_group_id = " + anId);
- DatabaseFilterGroup.getInstance().delete(anId);
- }
-
- public synchronized void deleteFilter(String aGroupId, String anId) {
- getFilterGroupForId(aGroupId).deleteFilter(anId);
- }
-
-
- public synchronized String updateFilter(String aGroupId, String anId,
- String aType, String anExpression,
- String aComments,
- String aTag,
- String anArticleAction,
- String aCommentAction) {
- return getFilterGroupForId(aGroupId).updateFilter(anId, aType,
- anExpression, aComments, aTag, anArticleAction, aCommentAction);
- }
-
- public synchronized String addFilter(String aGroupId,
- String aType, String anExpression,
- String aComments,
- String aTag,
- String anArticleAction,
- String aCommentAction) throws StorageObjectExc {
- return getFilterGroupForId(aGroupId).createFilter(aType, anExpression,
- aComments, aTag, anArticleAction, aCommentAction);
- }
-
-
- public FilterGroup getFilterGroupForId(String anId) {
- FilterGroup result = (FilterGroup) idToFilterGroup.get(anId);
- if (result == null) {
- throw new NullPointerException("No such filter group");
- }
-
- return result;
- }
-
- public Filter getFilterForId(String aGroupId, String anId) {
- return getFilterGroupForId(aGroupId).getFilterForId(anId);
- }
-
-
- public List getFilters(String aFilterGroupId) {
- return getFilterGroupForId(aFilterGroupId).getFilterEntityAdapterList();
- }
-
- private void introduceFilterGroup(FilterGroup aFilterGroup) {
- filterGroups.add(aFilterGroup);
- idToFilterGroup.put(aFilterGroup.getEntity().getId(), aFilterGroup);
- }
-
- private void removeFilterGroup(FilterGroup aFilterGroup) {
- filterGroups.remove(aFilterGroup);
- idToFilterGroup.remove(aFilterGroup.getEntity().getId());
- }
-
- private FilterType getFilterTypeForId(String anId) {
- return (FilterType) filterTypes.get(anId);
- }
-}
+/*
+ * Copyright (C) 2001, 2002 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+
+package mircoders.abuse;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
+import mir.config.MirPropertiesConfiguration;
+import mir.entity.Entity;
+import mir.entity.adapter.EntityAdapter;
+import mir.entity.adapter.EntityAdapterModel;
+import mir.entity.adapter.EntityIteratorAdapter;
+import mir.log.LoggerWrapper;
+import mir.session.Request;
+import mir.storage.StorageObjectExc;
+import mircoders.global.MirGlobal;
+import mircoders.storage.DatabaseFilter;
+import mircoders.storage.DatabaseFilterGroup;
+
+public class FilterEngine {
+ private Map filterTypes;
+ private List filterTypeIds;
+
+ private List filterGroups;
+ private Map idToFilterGroup;
+ private LoggerWrapper logger;
+ private EntityAdapterModel model;
+ private SimpleDateFormat dateFormat;
+ private MirPropertiesConfiguration configuration = MirPropertiesConfiguration.instance();
+
+ public FilterEngine(EntityAdapterModel aModel) {
+ logger = new LoggerWrapper("Global.Abuse.FilterEngine");
+ filterGroups = new ArrayList();
+ idToFilterGroup = new HashMap();
+
+ filterTypes = new HashMap();
+ filterTypeIds = new ArrayList();
+ try {
+ Iterator i = MirGlobal.localizer().openPostings().getAntiAbuseFilterTypes().iterator();
+ while (i.hasNext()) {
+ FilterType filterType = (FilterType) i.next();
+
+ filterTypes.put(filterType.getName(), filterType);
+ filterTypeIds.add(filterType.getName());
+ }
+ }
+ catch (Throwable t) {
+ throw new RuntimeException(t.getMessage());
+ }
+
+ model = aModel;
+
+ dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ dateFormat.setTimeZone(TimeZone.getTimeZone(configuration.getString("Mir.DefaultTimezone")));
+ reload();
+ }
+
+ public Filter testPosting(Entity anEntity, Request aRequest) {
+ Iterator i = filterGroups.iterator();
+ while (i.hasNext()) {
+ FilterGroup group = (FilterGroup) i.next();
+ Iterator j = group.getFilters().iterator();
+ while (j.hasNext()) {
+ Filter filter = (Filter) j.next();
+ try {
+ if (filter.test(anEntity, aRequest)) {
+ return filter;
+ }
+ }
+ catch (Throwable t) {
+ logger.warn("Exception thrown while testing filter " + filter.getType() + " ( " + filter.getExpression() + ") " + t.toString());
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public List getFilterTypes() {
+ try {
+ List result = new ArrayList();
+
+ Iterator i = filterTypeIds.iterator();
+ while (i.hasNext()) {
+ String id = (String) i.next();
+
+ Map action = new HashMap();
+ action.put("resource", id);
+ action.put("identifier", id);
+
+ result.add(action);
+ }
+
+ return result;
+ }
+ catch (Throwable t) {
+ throw new RuntimeException("can't get article actions");
+ }
+ }
+
+ public class FilterGroup {
+ private List filters;
+ private Entity entity;
+ private Map idToFilter;
+
+ public FilterGroup(Entity anEntity) {
+ this (anEntity, Collections.EMPTY_LIST);
+ }
+
+ public FilterGroup(Entity anEntity, List aFilters) {
+ entity = anEntity;
+ filters = new ArrayList();
+ idToFilter = new HashMap();
+ Iterator i = aFilters.iterator();
+
+ while (i.hasNext()) {
+ Entity entity = (Entity) i.next();
+ try {
+ Filter filter = new Filter(entity);
+ introduceFilter(filter);
+ }
+ catch (AbuseExc e) {
+ }
+ }
+ }
+
+ public Entity getEntity() {
+ return entity;
+ }
+
+ public EntityAdapter getEntityAdapter() {
+ return model.makeEntityAdapter("filterGroup", entity);
+ }
+
+ public List getFilterEntityAdapterList() {
+ List result = new ArrayList();
+
+ Iterator i = filters.iterator();
+ while (i.hasNext()) {
+ Filter filter = (Filter) i.next();
+ result.add(filter.getEntityAdapter());
+ }
+
+ return result;
+ }
+
+ public List getFilters() {
+ return filters;
+ }
+
+ public Filter getFilterForId(String anId) {
+ Filter result = (Filter) idToFilter.get(anId);
+ if (result==null) {
+ throw new NullPointerException("No such filter");
+ }
+
+ return result;
+ }
+
+ private void introduceFilter(Filter aFilter) {
+ filters.add(aFilter);
+ idToFilter.put(aFilter.getEntity().getId(), aFilter);
+ }
+
+ private void removeFilter(Filter aFilter) {
+ filters.remove(aFilter);
+ idToFilter.remove(aFilter.getEntity().getId());
+ }
+
+ private void deleteFilter(String anId) {
+ Filter filter = getFilterForId(anId);
+ removeFilter(filter);
+ DatabaseFilter.getInstance().delete(anId);
+ }
+
+ public void populateFilterEntity(Entity anEntity, String aType, String anExpression,
+ String aComments, String aTag, String anArticleAction,
+ String aCommentAction) {
+
+ anEntity.setFieldValue("type", aType);
+ anEntity.setFieldValue("expression", anExpression);
+ anEntity.setFieldValue("comment", aComments);
+ anEntity.setFieldValue("tag", aTag);
+ anEntity.setFieldValue("articleaction", anArticleAction);
+ anEntity.setFieldValue("commentaction", aCommentAction);
+ }
+
+ public String updateFilter(String anId, String aType, String anExpression,
+ String aComments, String aTag, String anArticleAction,
+ String aCommentAction) {
+
+ try {
+ getFilterTypeForId(aType).constructFilterInstance(anExpression);
+ }
+ catch (AbuseExc e) {
+ return e.getMessage();
+ }
+
+ Entity entity = getFilterForId(anId).getEntity();
+ populateFilterEntity(entity, aType, anExpression, aComments, aTag,
+ anArticleAction, aCommentAction);
+ entity.update();
+
+ return "";
+ }
+
+ public String createFilter(String aType, String anExpression,
+ String aComments, String aTag, String anArticleAction,
+ String aCommentAction) throws StorageObjectExc {
+ FilterInstance instance;
+
+ try {
+ instance = getFilterTypeForId(aType).constructFilterInstance(anExpression);
+ }
+ catch (AbuseExc e) {
+ return e.getMessage();
+ }
+
+ Entity entity = DatabaseFilter.getInstance().createNewEntity();
+ populateFilterEntity(entity, aType, anExpression, aComments, aTag,
+ anArticleAction, aCommentAction);
+ entity.setFieldValue("priority", "1");
+ entity.setFieldValue("filter_group_id", getEntity().getId());
+ entity.insert();
+
+ Filter filter = new Filter(entity, instance);
+ introduceFilter(filter);
+
+ return "";
+ }
+
+ public String getName() {
+ return entity.getFieldValue("name");
+ }
+ }
+
+ public class Filter {
+ private Entity entity;
+ private FilterInstance instance;
+
+ public Filter(Entity anEntity) throws AbuseExc {
+ this(anEntity, getFilterTypeForId(anEntity.getFieldValue("type")).constructFilterInstance(anEntity.getFieldValue("expression")));
+ }
+
+ public Filter(Entity anEntity, FilterInstance anInstance) {
+ entity = anEntity;
+ instance = anInstance;
+ }
+
+ public Entity getEntity() {
+ return entity;
+ }
+
+ public EntityAdapter getEntityAdapter() {
+ return model.makeEntityAdapter("filter", entity);
+ }
+
+ public void update(String aType, String anExpression, String aComments, String aTag,
+ String anArticleAction, String aCommentAction) throws AbuseExc {
+
+ instance = getFilterTypeForId(aType).constructFilterInstance(anExpression);
+
+ entity.setFieldValue("type", aType);
+ entity.setFieldValue("expression", anExpression);
+ entity.setFieldValue("tag", aType);
+ entity.setFieldValue("comment", aComments);
+ entity.setFieldValue("articleaction", anArticleAction);
+ entity.setFieldValue("commentaction", aCommentAction);
+ entity.setFieldValue("last_hit", null);
+ entity.update();
+ }
+
+ public void updateLastHit(Date aDate) {
+ entity.setFieldValue("last_hit", dateFormat.format(aDate));
+ entity.update();
+ }
+
+ public String getType() {
+ return entity.getFieldValue("type");
+ }
+
+ public String getExpression() {
+ return entity.getFieldValue("expression");
+ }
+
+ public String getTag() {
+ return entity.getFieldValue("tag");
+ }
+
+ public String getComment() {
+ return entity.getFieldValue("comment");
+ }
+
+ public String getArticleAction() {
+ return entity.getFieldValue("articleaction");
+ }
+
+ public String getCommentAction() {
+ return entity.getFieldValue("commentaction");
+ }
+
+ public FilterInstance getInstance() {
+ return instance;
+ }
+
+ public boolean test(Entity anEntity, Request aRequest) {
+ return instance.test(anEntity, aRequest);
+ }
+ }
+
+ public synchronized void reload() {
+ filterGroups.clear();
+ idToFilterGroup.clear();
+
+ try {
+ Iterator i = new EntityIteratorAdapter("", "priority asc", 100, model, "filterGroup");
+ while (i.hasNext()) {
+ EntityAdapter entityAdapter = (EntityAdapter) i.next();
+ List filters = new ArrayList();
+ Iterator j = (Iterator) entityAdapter.get("to_filters");
+ while (j.hasNext()) {
+ filters.add(((EntityAdapter) j.next()).getEntity());
+ }
+
+ FilterGroup filterGroup = new FilterGroup(entityAdapter.getEntity(), filters);
+ introduceFilterGroup(filterGroup);
+ }
+ }
+ catch (Throwable e) {
+ logger.error("Can't load filters: " + e.getMessage());
+ }
+ }
+
+ public synchronized List getFilterGroups() {
+ List result = new ArrayList();
+ Iterator i = filterGroups.iterator();
+ while (i.hasNext()) {
+ result.add(((FilterGroup) i.next()).getEntityAdapter());
+ }
+
+ return result;
+ }
+
+ public synchronized void updateFilterGroup(String anId, String aName) {
+ FilterGroup filterGroup = getFilterGroupForId(anId);
+ filterGroup.getEntity().setFieldValue("name", aName);
+ filterGroup.getEntity().update();
+ }
+
+ public synchronized void addFilterGroup(String aName) throws StorageObjectExc {
+ Entity entity = DatabaseFilterGroup.getInstance().createNewEntity();
+ entity.setFieldValue("name", aName);
+ entity.setFieldValue("priority", "1");
+ entity.insert();
+
+ FilterGroup filterGroup = new FilterGroup(entity);
+ introduceFilterGroup(filterGroup);
+ }
+
+ public synchronized void deleteFilterGroup(String anId) {
+
+ FilterGroup filterGroup = getFilterGroupForId(anId);
+ removeFilterGroup(filterGroup);
+ DatabaseFilter.getInstance().deleteByWhereClause("filter_group_id = " + anId);
+ DatabaseFilterGroup.getInstance().delete(anId);
+ }
+
+ public synchronized void deleteFilter(String aGroupId, String anId) {
+ getFilterGroupForId(aGroupId).deleteFilter(anId);
+ }
+
+
+ public synchronized String updateFilter(String aGroupId, String anId,
+ String aType, String anExpression,
+ String aComments,
+ String aTag,
+ String anArticleAction,
+ String aCommentAction) {
+ return getFilterGroupForId(aGroupId).updateFilter(anId, aType,
+ anExpression, aComments, aTag, anArticleAction, aCommentAction);
+ }
+
+ public synchronized String addFilter(String aGroupId,
+ String aType, String anExpression,
+ String aComments,
+ String aTag,
+ String anArticleAction,
+ String aCommentAction) throws StorageObjectExc {
+ return getFilterGroupForId(aGroupId).createFilter(aType, anExpression,
+ aComments, aTag, anArticleAction, aCommentAction);
+ }
+
+
+ public FilterGroup getFilterGroupForId(String anId) {
+ FilterGroup result = (FilterGroup) idToFilterGroup.get(anId);
+ if (result == null) {
+ throw new NullPointerException("No such filter group");
+ }
+
+ return result;
+ }
+
+ public Filter getFilterForId(String aGroupId, String anId) {
+ return getFilterGroupForId(aGroupId).getFilterForId(anId);
+ }
+
+
+ public List getFilters(String aFilterGroupId) {
+ return getFilterGroupForId(aFilterGroupId).getFilterEntityAdapterList();
+ }
+
+ private void introduceFilterGroup(FilterGroup aFilterGroup) {
+ filterGroups.add(aFilterGroup);
+ idToFilterGroup.put(aFilterGroup.getEntity().getId(), aFilterGroup);
+ }
+
+ private void removeFilterGroup(FilterGroup aFilterGroup) {
+ filterGroups.remove(aFilterGroup);
+ idToFilterGroup.remove(aFilterGroup.getEntity().getId());
+ }
+
+ private FilterType getFilterTypeForId(String anId) {
+ return (FilterType) filterTypes.get(anId);
+ }
+}
diff --git a/source/mircoders/abuse/IPFilterType.java b/source/mircoders/abuse/IPFilterType.java
index e6018317..9cb08679 100755
--- a/source/mircoders/abuse/IPFilterType.java
+++ b/source/mircoders/abuse/IPFilterType.java
@@ -1,80 +1,80 @@
-/*
- * Copyright (C) 2001, 2002 The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your version.
- */
-package mircoders.abuse;
-
-import mir.util.InternetFunctions;
-import mir.entity.Entity;
-import mir.session.Request;
-
-/**
- * A basic ip filter type. Supports x.x.x.x, x.x.x.x/x and x.x.x.x/x.x.x.x expressions.
- */
-public class IPFilterType extends AbstractFilterType {
- public IPFilterType(String aName) {
- super(aName);
- }
-
- /**
- *
- */
- public boolean validate(String anExpression) {
- try {
- InternetFunctions.isIpAddressInNetwork("1.1.1.1", anExpression);
- return true;
- }
- catch (Throwable t) {
- return false;
- }
- }
-
- public FilterInstance constructFilterInstance(final String anExpression) throws AbuseExc {
- try {
- InternetFunctions.isIpAddressInNetwork("1.1.1.1", anExpression);
- }
- catch (Throwable t) {
- throw new AbuseExc("Invalid expression: " + anExpression);
- }
-
- return new FilterInstance() {
- public boolean test(Entity anEntity, Request aRequest) {
- try {
- return InternetFunctions.isIpAddressInNetwork(aRequest.getHeader("ip"), anExpression);
- }
- catch (Exception e) {
- return false;
- }
- }
-
- public String status() {
- return "";
- }
- };
- }
-}
+/*
+ * Copyright (C) 2001, 2002 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mircoders.abuse;
+
+import mir.entity.Entity;
+import mir.session.Request;
+import mir.util.InternetFunctions;
+
+/**
+ * A basic ip filter type. Supports x.x.x.x, x.x.x.x/x and x.x.x.x/x.x.x.x expressions.
+ */
+public class IPFilterType extends AbstractFilterType {
+ public IPFilterType(String aName) {
+ super(aName);
+ }
+
+ /**
+ *
+ */
+ public boolean validate(String anExpression) {
+ try {
+ InternetFunctions.isIpAddressInNetwork("1.1.1.1", anExpression);
+ return true;
+ }
+ catch (Throwable t) {
+ return false;
+ }
+ }
+
+ public FilterInstance constructFilterInstance(final String anExpression) throws AbuseExc {
+ try {
+ InternetFunctions.isIpAddressInNetwork("1.1.1.1", anExpression);
+ }
+ catch (Throwable t) {
+ throw new AbuseExc("Invalid expression: " + anExpression);
+ }
+
+ return new FilterInstance() {
+ public boolean test(Entity anEntity, Request aRequest) {
+ try {
+ return InternetFunctions.isIpAddressInNetwork(aRequest.getHeader("ip"), anExpression);
+ }
+ catch (Exception e) {
+ return false;
+ }
+ }
+
+ public String status() {
+ return "";
+ }
+ };
+ }
+}
diff --git a/source/mircoders/abuse/RegularExpressionFilterType.java b/source/mircoders/abuse/RegularExpressionFilterType.java
index 13d1db52..fe0e6bbf 100755
--- a/source/mircoders/abuse/RegularExpressionFilterType.java
+++ b/source/mircoders/abuse/RegularExpressionFilterType.java
@@ -31,13 +31,14 @@
package mircoders.abuse;
import gnu.regexp.RE;
-import mir.entity.Entity;
-import mir.session.Request;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
+import mir.entity.Entity;
+import mir.session.Request;
+
/**
* A regular expression filter.
diff --git a/source/mircoders/abuse/ThrottleFilter.java b/source/mircoders/abuse/ThrottleFilter.java
index 714f2058..79e86495 100755
--- a/source/mircoders/abuse/ThrottleFilter.java
+++ b/source/mircoders/abuse/ThrottleFilter.java
@@ -1,151 +1,149 @@
-/*
- * Copyright (C) 2001, 2002 The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your version.
- */
-package mircoders.abuse;
-
-import mir.entity.Entity;
-import mir.session.Request;
-import mir.util.StringRoutines;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * A ip-based throttling filter.
- *
- *
- * Expressions have the form