diff --git a/src/net/java/sip/communicator/impl/fileaccess/FileAccessServiceImpl.java b/src/net/java/sip/communicator/impl/fileaccess/FileAccessServiceImpl.java index 58ca977f0..7b1b9508d 100644 --- a/src/net/java/sip/communicator/impl/fileaccess/FileAccessServiceImpl.java +++ b/src/net/java/sip/communicator/impl/fileaccess/FileAccessServiceImpl.java @@ -11,7 +11,6 @@ import net.java.sip.communicator.service.configuration.ConfigurationService; import net.java.sip.communicator.service.fileaccess.FileAccessService; -import net.java.sip.communicator.util.Assert; import net.java.sip.communicator.util.Logger; /** @@ -114,7 +113,7 @@ public File getTemporaryDirectory() throws IOException { * Thrown if the configuration service is not set */ public File getPrivatePersistentFile(String fileName) throws Exception { - Assert.assertNonNull(fileName, "Parameter fileName should be non-null"); + // TODO: Validate: Assert.assertNonNull(fileName, "Parameter fileName should be non-null"); File file = null; @@ -140,7 +139,7 @@ public File getPrivatePersistentFile(String fileName) throws Exception { public File getPrivatePersistentDirectory(String dirName) throws Exception { - Assert.assertNonNull(dirName, "Parameter dirName should be non-null"); + // TODO: Validate: Assert.assertNonNull(dirName, "Parameter dirName should be non-null"); String fullPath = getFullPath(dirName); File dir = new File(fullPath, dirName); @@ -161,8 +160,8 @@ public File getPrivatePersistentDirectory(String dirName) } public File getPrivatePersistentDirectory(String[] dirNames) throws Exception { - Assert.assertNonNull(dirNames, "Parameter dirNames should be non-null"); - Assert.assertTrue(dirNames.length > 0, "dirNames.length should be > 0"); + // TODO: Validate: Assert.assertNonNull(dirNames, "Parameter dirNames should be non-null"); + // TODO: Validate: Assert.assertTrue(dirNames.length > 0, "dirNames.length should be > 0"); StringBuffer dirName = new StringBuffer(); for(int i = 0; i < dirNames.length; i++) { @@ -176,15 +175,15 @@ public File getPrivatePersistentDirectory(String[] dirNames) throws Exception { } private String getFullPath(String fileName) { - Assert.assertNonNull(fileName, "The filename should be non-null."); + // TODO: Validate: Assert.assertNonNull(fileName, "The filename should be non-null."); String userhome = null; String sipSubdir = null; // Obtain configuration service lock synchronized(this.syncRoot) { - Assert.assertNonNull(this.configurationService, - "The configurationService should be non-null."); + // TODO: Assert: Assert.assertNonNull(this.configurationService, + // "The configurationService should be non-null."); userhome = this.configurationService.getString(FileAccessService.CONFPROPERTYKEY_USER_HOME); sipSubdir = this.configurationService.getString(FileAccessService.CONFPROPERTYKEY_SIP_DIRECTORY); diff --git a/src/net/java/sip/communicator/impl/history/HistoryImpl.java b/src/net/java/sip/communicator/impl/history/HistoryImpl.java index 1dea20d56..faf3f1ac4 100644 --- a/src/net/java/sip/communicator/impl/history/HistoryImpl.java +++ b/src/net/java/sip/communicator/impl/history/HistoryImpl.java @@ -20,7 +20,6 @@ import net.java.sip.communicator.service.history.HistoryReader; import net.java.sip.communicator.service.history.HistoryWriter; import net.java.sip.communicator.service.history.records.HistoryRecordStructure; -import net.java.sip.communicator.util.Assert; import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.xml.XMLUtils; @@ -52,9 +51,9 @@ protected HistoryImpl( try { log.logEntry(); - Assert.assertNonNull(historyServiceImpl, "The historyServiceImpl should be non-null."); - Assert.assertNonNull(id, "The ID should be non-null."); - Assert.assertNonNull(historyRecordStructure, "The structure should be non-null."); + // TODO: Assert: Assert.assertNonNull(historyServiceImpl, "The historyServiceImpl should be non-null."); + // TODO: Assert: Assert.assertNonNull(id, "The ID should be non-null."); + // TODO: Assert: Assert.assertNonNull(historyRecordStructure, "The structure should be non-null."); this.id = id; this.directory = directory; @@ -102,7 +101,7 @@ private void reloadDocumentList() { this.historyDocuments.clear(); File[] files = this.directory.listFiles(); - Assert.assertNonNull(files, "The list of files should be non-null."); + // TODO: Assert: Assert.assertNonNull(files, "The list of files should be non-null."); for(int i = 0; i < files.length; i++) { if(!files[i].isDirectory()) { @@ -186,8 +185,8 @@ protected Document getDocumentForFile(String filename) // Cache the loaded document for reuse this.historyDocuments.put(filename, retVal); } else { - Assert.fail("Internal error - the data type " + - "should be either Document or File."); + // TODO: Assert: Assert.fail("Internal error - the data type " + + // "should be either Document or File."); } } diff --git a/src/net/java/sip/communicator/impl/history/HistoryWriterImpl.java b/src/net/java/sip/communicator/impl/history/HistoryWriterImpl.java index 37828d227..67101b859 100644 --- a/src/net/java/sip/communicator/impl/history/HistoryWriterImpl.java +++ b/src/net/java/sip/communicator/impl/history/HistoryWriterImpl.java @@ -19,7 +19,6 @@ import net.java.sip.communicator.service.history.HistoryWriter; import net.java.sip.communicator.service.history.records.HistoryRecord; import net.java.sip.communicator.service.history.records.HistoryRecordStructure; -import net.java.sip.communicator.util.Assert; /** * @author Alexander Pelov @@ -125,8 +124,8 @@ private void createNewDoc(Date date, boolean loadLastFile) { this.currentDoc = this.historyImpl.createDocument(this.currentFile); } - Assert.assertNonNull(this.currentDoc, - "There should be a current document created."); + // TODO: Assert: Assert.assertNonNull(this.currentDoc, + // "There should be a current document created."); this.currentDocElements = this.currentDoc.getFirstChild().getChildNodes().getLength(); } diff --git a/src/net/java/sip/communicator/service/history/HistoryID.java b/src/net/java/sip/communicator/service/history/HistoryID.java index f1b47148a..0ad0bb192 100644 --- a/src/net/java/sip/communicator/service/history/HistoryID.java +++ b/src/net/java/sip/communicator/service/history/HistoryID.java @@ -6,8 +6,6 @@ */ package net.java.sip.communicator.service.history; -import net.java.sip.communicator.util.Assert; - /** * Object used to uniquely identify a group of history records. * @@ -39,8 +37,8 @@ private HistoryID(String[] id) { * strings and they will be safely converted to valid IDs. */ public static HistoryID createFromRawID(String[] rawid) { - Assert.assertNonNull(rawid, "Parameter RAWID should be non-null"); - Assert.assertTrue(rawid.length > 0, "RAWID.length should be > 0"); + // TODO: Validate: Assert.assertNonNull(rawid, "Parameter RAWID should be non-null"); + // TODO: Validate: Assert.assertTrue(rawid.length > 0, "RAWID.length should be > 0"); String[] id = new String[rawid.length]; for(int i = 0; i < rawid.length; i++) { @@ -60,8 +58,8 @@ public static HistoryID createFromRawID(String[] rawid) { public static HistoryID createFromID(String[] id) throws IllegalArgumentException { - Assert.assertNonNull(id, "Parameter ID should be non-null"); - Assert.assertTrue(id.length > 0, "ID.length should be > 0"); + // TODO: Validate: Assert.assertNonNull(id, "Parameter ID should be non-null"); + // TODO: Validate: Assert.assertTrue(id.length > 0, "ID.length should be > 0"); for(int i = 0; i < id.length; i++) { if(!HistoryID.isIDValid(id[i])) { diff --git a/src/net/java/sip/communicator/service/history/records/HistoryRecord.java b/src/net/java/sip/communicator/service/history/records/HistoryRecord.java index 757289299..398ab31d2 100644 --- a/src/net/java/sip/communicator/service/history/records/HistoryRecord.java +++ b/src/net/java/sip/communicator/service/history/records/HistoryRecord.java @@ -8,8 +8,6 @@ import java.util.Date; -import net.java.sip.communicator.util.Assert; - /** * @author Alexander Pelov */ @@ -63,12 +61,12 @@ public HistoryRecord(HistoryRecordStructure entryStructure, String[] propertyVal * @param timestamp */ public HistoryRecord(String[] propertyNames, String[] propertyValues, Date timestamp) { - Assert.assertNonNull(propertyNames, "The property names should be non-null."); - Assert.assertNonNull(propertyValues, "The property values should be non-null."); - Assert.assertNonNull(timestamp, "The timestamp should be non-null."); + // TODO: Validate: Assert.assertNonNull(propertyNames, "The property names should be non-null."); + // TODO: Validate: Assert.assertNonNull(propertyValues, "The property values should be non-null."); + // TODO: Validate: Assert.assertNonNull(timestamp, "The timestamp should be non-null."); - Assert.assertTrue(propertyNames.length == propertyValues.length, - "The length of the property names and property values should be equal."); + // TODO: Validate Assert.assertTrue(propertyNames.length == propertyValues.length, + // "The length of the property names and property values should be equal."); this.propertyNames = propertyNames; this.propertyValues = propertyValues; diff --git a/src/net/java/sip/communicator/service/history/records/HistoryRecordStructure.java b/src/net/java/sip/communicator/service/history/records/HistoryRecordStructure.java index 628a102c6..52b4b4965 100644 --- a/src/net/java/sip/communicator/service/history/records/HistoryRecordStructure.java +++ b/src/net/java/sip/communicator/service/history/records/HistoryRecordStructure.java @@ -6,8 +6,6 @@ */ package net.java.sip.communicator.service.history.records; -import net.java.sip.communicator.util.Assert; - /** * @author Alexander Pelov */ @@ -25,7 +23,8 @@ public class HistoryRecordStructure { * @param propertyNames */ public HistoryRecordStructure(String[] propertyNames) { - Assert.assertNonNull(propertyNames, "Parameter propertyNames should be non-null."); + // TODO: Validate: Assert.assertNonNull(propertyNames, "Parameter propertyNames should be non-null."); + this.propertyNames = new String[propertyNames.length]; System.arraycopy(propertyNames, 0, this.propertyNames, 0, this.propertyNames.length); } diff --git a/src/net/java/sip/communicator/util/Assert.java b/src/net/java/sip/communicator/util/Assert.java deleted file mode 100644 index 593e4e508..000000000 --- a/src/net/java/sip/communicator/util/Assert.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */package net.java.sip.communicator.util; - -/** - * @author Alexander Pelov - */ -public class Assert { - /** - * The logger for this class. - */ - private static final Logger log = Logger.getLogger(Assert.class.getName()); - - /** - * Enables or disables assertion checks. - */ - public static boolean EnableAssertions = true; - - /** - * Throws an exception if the passed condition is false and - * EnableAssertions == true. - * - * @param condition The condition to be met. - * @param message The message to be displayed as explanation on assertion fail. - * @throws IllegalArgumentException Thrown if condition is false and - * assertions are enabled. - */ - public static final void assertTrue(boolean condition, String message) throws AssertionError { - if (EnableAssertions && !condition) { - StackTraceElement caller = new Throwable().getStackTrace()[1]; - - String fullText = "Assertion failed at " + caller.getMethodName() + ", line " + - caller.getLineNumber() + - "\n\tMessage: " + message; - - log.error(fullText); - - throw new AssertionError(fullText); - } - } - - /** - * Throws an exception if EnableAssertions == true. - * - * @param message The message to be displayed as explanation on assertion fail. - * @throws IllegalArgumentException Thrown if assertions are enabled. - */ - public static final void fail(String message) throws AssertionError { - Assert.assertTrue(false, message); - } - - /** - * Throws an exception if the passed object is null and - * EnableAssertions == true. - * - * @param obj The object to be checked. - * @param message The message to be displayed as explanation on assertion fail. - * @throws IllegalArgumentException Thrown if obj is null - * and assertions are enabled. - */ - public static final void assertNonNull(Object obj, String message) throws AssertionError { - Assert.assertTrue(obj != null, message); - } - - /** - * Throws an exception if the passed object is not null and - * EnableAssertions == true. - * - * @param obj The object to be checked. - * @param message The message to be displayed as explanation on assertion fail. - * @throws IllegalArgumentException Thrown if obj is not null and - * assertions are enabled. - */ - public static final void assertNull(Object obj, String message) throws AssertionError { - Assert.assertTrue(obj == null, message); - } -}