();
params.put("host", "localhost");
params.put("port", 61616 + id);
@@ -103,8 +87,7 @@ public class ServerUtil
cf.createConnection().close();
System.out.println("server " + id + " started");
}
- catch (Exception e)
- {
+ catch (Exception e) {
System.out.println("awaiting server " + id + " start at " + (61616 + id));
Thread.sleep(500);
continue;
@@ -113,10 +96,8 @@ public class ServerUtil
}
}
- public static void killServer(final Process server) throws Exception
- {
- if (server != null)
- {
+ public static void killServer(final Process server) throws Exception {
+ if (server != null) {
System.out.println("**********************************");
System.out.println("Killing server " + server);
System.out.println("**********************************");
@@ -126,35 +107,30 @@ public class ServerUtil
}
}
- public static int getServer(Connection connection)
- {
+ public static int getServer(Connection connection) {
ClientSession session = ((ActiveMQConnection) connection).getInitialSession();
TransportConfiguration transportConfiguration = session.getSessionFactory().getConnectorConfiguration();
String port = (String) transportConfiguration.getParams().get("port");
return Integer.valueOf(port) - 61616;
}
- public static Connection getServerConnection(int server, Connection... connections)
- {
- for (Connection connection : connections)
- {
+ public static Connection getServerConnection(int server, Connection... connections) {
+ for (Connection connection : connections) {
ClientSession session = ((ActiveMQConnection) connection).getInitialSession();
TransportConfiguration transportConfiguration = session.getSessionFactory().getConnectorConfiguration();
String port = (String) transportConfiguration.getParams().get("port");
- if (Integer.valueOf(port) == server + 61616)
- {
+ if (Integer.valueOf(port) == server + 61616) {
return connection;
}
}
return null;
}
-
/**
* Redirect the input stream to a logger (as debug logs)
*/
- static class ProcessLogger extends Thread
- {
+ static class ProcessLogger extends Thread {
+
private final InputStream is;
private final String logName;
@@ -166,8 +142,7 @@ public class ServerUtil
ProcessLogger(final boolean print,
final InputStream is,
final String logName,
- final boolean sendToErr) throws ClassNotFoundException
- {
+ final boolean sendToErr) throws ClassNotFoundException {
this.is = is;
this.print = print;
this.logName = logName;
@@ -176,30 +151,23 @@ public class ServerUtil
}
@Override
- public void run()
- {
- try
- {
+ public void run() {
+ try {
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
- while ((line = br.readLine()) != null)
- {
- if (print)
- {
- if (sendToErr)
- {
+ while ((line = br.readLine()) != null) {
+ if (print) {
+ if (sendToErr) {
System.err.println(logName + "-err:" + line);
}
- else
- {
+ else {
System.out.println(logName + "-out:" + line);
}
}
}
}
- catch (IOException e)
- {
+ catch (IOException e) {
// ok, stream closed
}
}
diff --git a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
index a42fae92e7..cfcc53f985 100644
--- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
+++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
@@ -43,41 +43,35 @@ import org.junit.rules.TemporaryFolder;
/**
* Test to validate that the CLI doesn't throw improper exceptions when invoked.
*/
-public class ArtemisTest
-{
+public class ArtemisTest {
+
@Rule
public TemporaryFolder temporaryFolder;
- public ArtemisTest()
- {
+ public ArtemisTest() {
File parent = new File("./target/tmp");
parent.mkdirs();
temporaryFolder = new TemporaryFolder(parent);
}
-
@After
- public void cleanup()
- {
+ public void cleanup() {
System.clearProperty("artemis.instance");
Run.setEmbedded(false);
}
@Test
- public void invalidCliDoesntThrowException()
- {
+ public void invalidCliDoesntThrowException() {
testCli("create");
}
@Test
- public void invalidPathDoesntThrowException()
- {
- testCli("create","/rawr");
+ public void invalidPathDoesntThrowException() {
+ testCli("create", "/rawr");
}
@Test
- public void testSync() throws Exception
- {
+ public void testSync() throws Exception {
int writes = 2560;
int tries = 10;
long totalAvg = SyncCalculation.syncTest(temporaryFolder.getRoot(), 4096, writes, tries, true, true);
@@ -88,9 +82,9 @@ public class ArtemisTest
Assert.assertEquals(0, LibaioContext.getTotalMaxIO());
}
+
@Test
- public void testSimpleRun() throws Exception
- {
+ public void testSimpleRun() throws Exception {
String queues = "q1,t2";
String topics = "t1,t2";
Run.setEmbedded(true);
@@ -99,24 +93,19 @@ public class ArtemisTest
// Some exceptions may happen on the initialization, but they should be ok on start the basic core protocol
Artemis.execute("run");
-
try (ServerLocator locator = ServerLocatorImpl.newLocator("tcp://localhost:61616");
ClientSessionFactory factory = locator.createSessionFactory();
- ClientSession coreSession = factory.createSession())
- {
- for (String str: queues.split(","))
- {
+ ClientSession coreSession = factory.createSession()) {
+ for (String str : queues.split(",")) {
ClientSession.QueueQuery queryResult = coreSession.queueQuery(SimpleString.toSimpleString("jms.queue." + str));
Assert.assertTrue("Couldn't find queue " + str, queryResult.isExists());
}
- for (String str: topics.split(","))
- {
+ for (String str : topics.split(",")) {
ClientSession.QueueQuery queryResult = coreSession.queueQuery(SimpleString.toSimpleString("jms.topic." + str));
Assert.assertTrue("Couldn't find topic " + str, queryResult.isExists());
}
}
-
Assert.assertEquals(Integer.valueOf(1000), Artemis.execute("producer", "--message-count", "1000", "--verbose"));
Assert.assertEquals(Integer.valueOf(1000), Artemis.execute("consumer", "--verbose", "--break-on-null", "--receive-timeout", "100"));
@@ -125,13 +114,11 @@ public class ArtemisTest
Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
MessageProducer producer = session.createProducer(ActiveMQDestination.createDestination("queue://TEST", ActiveMQDestination.QUEUE_TYPE));
-
TextMessage message = session.createTextMessage("Banana");
message.setStringProperty("fruit", "banana");
producer.send(message);
- for (int i = 0; i < 100; i++)
- {
+ for (int i = 0; i < 100; i++) {
message = session.createTextMessage("orange");
message.setStringProperty("fruit", "orange");
producer.send(message);
@@ -154,7 +141,7 @@ public class ArtemisTest
Assert.assertEquals(Integer.valueOf(1), Artemis.execute("consumer", "--txt-size", "50", "--verbose", "--break-on-null", "--receive-timeout", "100", "--filter", "fruit='banana'"));
// Checking it was acked before
- Assert.assertEquals(Integer.valueOf(100), Artemis.execute("consumer", "--txt-size", "50", "--verbose", "--break-on-null", "--receive-timeout", "100"));
+ Assert.assertEquals(Integer.valueOf(100), Artemis.execute("consumer", "--txt-size", "50", "--verbose", "--break-on-null", "--receive-timeout", "100"));
Artemis.execute("stop");
Assert.assertTrue(Run.latchRunning.await(5, TimeUnit.SECONDS));
@@ -162,14 +149,11 @@ public class ArtemisTest
}
- private void testCli(String... args)
- {
- try
- {
+ private void testCli(String... args) {
+ try {
Artemis.main(args);
}
- catch (Exception e)
- {
+ catch (Exception e) {
e.printStackTrace();
Assert.fail("Exception caught " + e.getMessage());
}
diff --git a/artemis-cli/src/test/java/org/apache/activemq/cli/test/FileBrokerTest.java b/artemis-cli/src/test/java/org/apache/activemq/cli/test/FileBrokerTest.java
index 5d86f6e681..c796f3f3d1 100644
--- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/FileBrokerTest.java
+++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/FileBrokerTest.java
@@ -24,16 +24,14 @@ import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManagerImpl
import org.junit.Assert;
import org.junit.Test;
-public class FileBrokerTest
-{
+public class FileBrokerTest {
+
@Test
- public void startWithJMS() throws Exception
- {
+ public void startWithJMS() throws Exception {
ServerDTO serverDTO = new ServerDTO();
serverDTO.configuration = "broker.xml";
FileBroker broker = null;
- try
- {
+ try {
broker = new FileBroker(serverDTO, new ActiveMQSecurityManagerImpl());
broker.start();
JMSServerManagerImpl jmsServerManager = (JMSServerManagerImpl) broker.getComponents().get("jms");
@@ -46,23 +44,19 @@ public class FileBrokerTest
Assert.assertTrue(activeMQServer.isStarted());
Assert.assertTrue(broker.isStarted());
}
- finally
- {
- if (broker != null)
- {
+ finally {
+ if (broker != null) {
broker.stop();
}
}
}
@Test
- public void startWithoutJMS() throws Exception
- {
+ public void startWithoutJMS() throws Exception {
ServerDTO serverDTO = new ServerDTO();
serverDTO.configuration = "broker-nojms.xml";
FileBroker broker = null;
- try
- {
+ try {
broker = new FileBroker(serverDTO, new ActiveMQSecurityManagerImpl());
broker.start();
JMSServerManagerImpl jmsServerManager = (JMSServerManagerImpl) broker.getComponents().get("jms");
@@ -72,8 +66,7 @@ public class FileBrokerTest
Assert.assertTrue(activeMQServer.isStarted());
Assert.assertTrue(broker.isStarted());
}
- finally
- {
+ finally {
assert broker != null;
broker.stop();
}
diff --git a/artemis-cli/src/test/java/org/apache/activemq/cli/test/StreamClassPathTest.java b/artemis-cli/src/test/java/org/apache/activemq/cli/test/StreamClassPathTest.java
index 0ee3afbcf5..21579dc9b0 100644
--- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/StreamClassPathTest.java
+++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/StreamClassPathTest.java
@@ -23,13 +23,13 @@ import org.apache.activemq.artemis.cli.commands.Create;
import org.junit.Assert;
import org.junit.Test;
-public class StreamClassPathTest
-{
+public class StreamClassPathTest {
- /** Validate if all the known resources are available on the classpath for the jar */
+ /**
+ * Validate if all the known resources are available on the classpath for the jar
+ */
@Test
- public void testFindStreams() throws Exception
- {
+ public void testFindStreams() throws Exception {
openStream(Create.BIN_ARTEMIS_CMD);
openStream(Create.BIN_ARTEMIS_SERVICE_EXE);
openStream(Create.BIN_ARTEMIS_SERVICE_XML);
@@ -52,9 +52,7 @@ public class StreamClassPathTest
openStream(Create.ETC_JOURNAL_BUFFER_SETTINGS);
}
-
- private void openStream(String source) throws Exception
- {
+ private void openStream(String source) throws Exception {
Create create = new Create();
InputStream in = create.openStream(source);
Assert.assertNotNull(source + " not found", in);
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQAddressExistsException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQAddressExistsException.java
index aeec7a87df..9477bb84c4 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQAddressExistsException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQAddressExistsException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* An operation failed because an address exists on the server.
*/
-public final class ActiveMQAddressExistsException extends ActiveMQException
-{
+public final class ActiveMQAddressExistsException extends ActiveMQException {
+
private static final long serialVersionUID = 3032730450033992367L;
- public ActiveMQAddressExistsException()
- {
+ public ActiveMQAddressExistsException() {
super(ActiveMQExceptionType.ADDRESS_EXISTS);
}
- public ActiveMQAddressExistsException(String msg)
- {
+ public ActiveMQAddressExistsException(String msg) {
super(ActiveMQExceptionType.ADDRESS_EXISTS, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQAddressFullException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQAddressFullException.java
index c8cbe458a3..1cd5b6338c 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQAddressFullException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQAddressFullException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* An address is full.
*/
-public final class ActiveMQAddressFullException extends ActiveMQException
-{
+public final class ActiveMQAddressFullException extends ActiveMQException {
+
private static final long serialVersionUID = 0;
- public ActiveMQAddressFullException(String message)
- {
+ public ActiveMQAddressFullException(String message) {
super(ActiveMQExceptionType.ADDRESS_FULL, message);
}
- public ActiveMQAddressFullException()
- {
+ public ActiveMQAddressFullException() {
super(ActiveMQExceptionType.ADDRESS_FULL);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQAlreadyReplicatingException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQAlreadyReplicatingException.java
index 125c4921d9..dd3348c260 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQAlreadyReplicatingException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQAlreadyReplicatingException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* The server is already paired with a replicating backup.
*/
-public final class ActiveMQAlreadyReplicatingException extends ActiveMQException
-{
+public final class ActiveMQAlreadyReplicatingException extends ActiveMQException {
+
private static final long serialVersionUID = -7352538521961996152L;
- public ActiveMQAlreadyReplicatingException()
- {
+ public ActiveMQAlreadyReplicatingException() {
super(ActiveMQExceptionType.ALREADY_REPLICATING);
}
- public ActiveMQAlreadyReplicatingException(String msg)
- {
+ public ActiveMQAlreadyReplicatingException(String msg) {
super(ActiveMQExceptionType.ALREADY_REPLICATING, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffer.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffer.java
index 63d956c927..12dd09f8cc 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffer.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffer.java
@@ -26,10 +26,11 @@ import io.netty.buffer.ByteBuf;
* Instances of it can be obtained from {@link ActiveMQBuffers} factory.
*
* Much of it derived from Netty ChannelBuffer by Trustin Lee
+ *
* @see ActiveMQBuffers
*/
-public interface ActiveMQBuffer
-{
+public interface ActiveMQBuffer {
+
/**
* Returns the underlying Netty's ByteBuf
*
@@ -52,11 +53,10 @@ public interface ActiveMQBuffer
/**
* Sets the {@code readerIndex} of this buffer.
*
- * @throws IndexOutOfBoundsException
- * if the specified {@code readerIndex} is
- * less than {@code 0} or
- * greater than {@code this.writerIndex}
* @param readerIndex The reader's index The reader infex
+ * @throws IndexOutOfBoundsException if the specified {@code readerIndex} is
+ * less than {@code 0} or
+ * greater than {@code this.writerIndex}
*/
void readerIndex(int readerIndex);
@@ -69,10 +69,9 @@ public interface ActiveMQBuffer
* Sets the {@code writerIndex} of this buffer.
*
* @param writerIndex The writer's index
- * @throws IndexOutOfBoundsException
- * if the specified {@code writerIndex} is
- * less than {@code this.readerIndex} or
- * greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code writerIndex} is
+ * less than {@code this.readerIndex} or
+ * greater than {@code this.capacity}
*/
void writerIndex(int writerIndex);
@@ -123,11 +122,10 @@ public interface ActiveMQBuffer
*
* @param readerIndex The reader's index
* @param writerIndex The writer's index
- * @throws IndexOutOfBoundsException
- * if the specified {@code readerIndex} is less than 0,
- * if the specified {@code writerIndex} is less than the specified
- * {@code readerIndex} or if the specified {@code writerIndex} is
- * greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code readerIndex} is less than 0,
+ * if the specified {@code writerIndex} is less than the specified
+ * {@code readerIndex} or if the specified {@code writerIndex} is
+ * greater than {@code this.capacity}
*/
void setIndex(int readerIndex, int writerIndex);
@@ -174,9 +172,8 @@ public interface ActiveMQBuffer
* Repositions the current {@code readerIndex} to the marked
* {@code readerIndex} in this buffer.
*
- * @throws IndexOutOfBoundsException
- * if the current {@code writerIndex} is less than the marked
- * {@code readerIndex}
+ * @throws IndexOutOfBoundsException if the current {@code writerIndex} is less than the marked
+ * {@code readerIndex}
*/
void resetReaderIndex();
@@ -192,9 +189,8 @@ public interface ActiveMQBuffer
* Repositions the current {@code writerIndex} to the marked
* {@code writerIndex} in this buffer.
*
- * @throws IndexOutOfBoundsException
- * if the current {@code readerIndex} is greater than the marked
- * {@code writerIndex}
+ * @throws IndexOutOfBoundsException if the current {@code readerIndex} is greater than the marked
+ * {@code writerIndex}
*/
void resetWriterIndex();
@@ -215,11 +211,10 @@ public interface ActiveMQBuffer
*
* @param index Index into the buffer
* @return The byte at the specified index
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 1} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 1} is greater than {@code this.capacity}
*/
- byte getByte(int index);
+ byte getByte(int index);
/**
* Gets an unsigned byte at the specified absolute {@code index} in this
@@ -228,9 +223,8 @@ public interface ActiveMQBuffer
*
* @param index Index into the buffer
* @return an unsigned byte at the specified absolute {@code index}
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 1} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 1} is greater than {@code this.capacity}
*/
short getUnsignedByte(int index);
@@ -241,9 +235,8 @@ public interface ActiveMQBuffer
*
* @param index Index into the buffer
* @return a 16-bit short integer at the specified absolute {@code index}
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 2} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 2} is greater than {@code this.capacity}
*/
short getShort(int index);
@@ -254,9 +247,8 @@ public interface ActiveMQBuffer
*
* @param index Index into the buffer
* @return an unsigned 16-bit short integer
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 2} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 2} is greater than {@code this.capacity}
*/
int getUnsignedShort(int index);
@@ -267,11 +259,10 @@ public interface ActiveMQBuffer
*
* @param index Index into the buffer
* @return a 32-bit integer at the specified absolute {@code index}
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 4} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 4} is greater than {@code this.capacity}
*/
- int getInt(int index);
+ int getInt(int index);
/**
* Gets an unsigned 32-bit integer at the specified absolute {@code index}
@@ -280,11 +271,10 @@ public interface ActiveMQBuffer
*
* @param index The index into this buffer
* @return an unsigned 32-bit integer at the specified absolute {@code index}
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 4} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 4} is greater than {@code this.capacity}
*/
- long getUnsignedInt(int index);
+ long getUnsignedInt(int index);
/**
* Gets a 64-bit long integer at the specified absolute {@code index} in
@@ -293,11 +283,10 @@ public interface ActiveMQBuffer
*
* @param index Index into the buffer
* @return a 64-bit long integer at the specified absolute {@code index}
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 8} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 8} is greater than {@code this.capacity}
*/
- long getLong(int index);
+ long getLong(int index);
/**
* Transfers this buffer's data to the specified destination starting at
@@ -311,11 +300,10 @@ public interface ActiveMQBuffer
* the source buffer (i.e. {@code this}).
*
* @param index Index into the buffer
- * @param dst The destination buffer
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + dst.writableBytes} is greater than
- * {@code this.capacity}
+ * @param dst The destination buffer
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * if {@code index + dst.writableBytes} is greater than
+ * {@code this.capacity}
*/
void getBytes(int index, ActiveMQBuffer dst);
@@ -330,13 +318,12 @@ public interface ActiveMQBuffer
* the source buffer (i.e. {@code this}).
*
* @param length the number of bytes to transfer
- * @param index Index into the buffer
- * @param dst The destination buffer
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0},
- * if {@code index + length} is greater than
- * {@code this.capacity}, or
- * if {@code length} is greater than {@code dst.writableBytes}
+ * @param index Index into the buffer
+ * @param dst The destination buffer
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0},
+ * if {@code index + length} is greater than
+ * {@code this.capacity}, or
+ * if {@code length} is greater than {@code dst.writableBytes}
*/
void getBytes(int index, ActiveMQBuffer dst, int length);
@@ -346,18 +333,16 @@ public interface ActiveMQBuffer
* This method does not modify {@code readerIndex} or {@code writerIndex}
* of both the source (i.e. {@code this}) and the destination.
*
- * @param dst The destination bufferIndex the first index of the destination
- * @param length The number of bytes to transfer
- * @param index Index into the buffer
+ * @param dst The destination bufferIndex the first index of the destination
+ * @param length The number of bytes to transfer
+ * @param index Index into the buffer
* @param dstIndex The index into the destination bufferThe destination buffer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0},
- * if the specified {@code dstIndex} is less than {@code 0},
- * if {@code index + length} is greater than
- * {@code this.capacity}, or
- * if {@code dstIndex + length} is greater than
- * {@code dst.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0},
+ * if the specified {@code dstIndex} is less than {@code 0},
+ * if {@code index + length} is greater than
+ * {@code this.capacity}, or
+ * if {@code dstIndex + length} is greater than
+ * {@code dst.capacity}
*/
void getBytes(int index, ActiveMQBuffer dst, int dstIndex, int length);
@@ -368,11 +353,10 @@ public interface ActiveMQBuffer
* this buffer
*
* @param index Index into the buffer
- * @param dst The destination buffer
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + dst.length} is greater than
- * {@code this.capacity}
+ * @param dst The destination buffer
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * if {@code index + dst.length} is greater than
+ * {@code this.capacity}
*/
void getBytes(int index, byte[] dst);
@@ -384,16 +368,14 @@ public interface ActiveMQBuffer
*
* @param dstIndex The first index of the destination
* @param length The number of bytes to transfer
- * @param index Index into the buffer
- * @param dst The destination buffer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0},
- * if the specified {@code dstIndex} is less than {@code 0},
- * if {@code index + length} is greater than
- * {@code this.capacity}, or
- * if {@code dstIndex + length} is greater than
- * {@code dst.length}
+ * @param index Index into the buffer
+ * @param dst The destination buffer
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0},
+ * if the specified {@code dstIndex} is less than {@code 0},
+ * if {@code index + length} is greater than
+ * {@code this.capacity}, or
+ * if {@code dstIndex + length} is greater than
+ * {@code dst.length}
*/
void getBytes(int index, byte[] dst, int dstIndex, int length);
@@ -405,11 +387,10 @@ public interface ActiveMQBuffer
* this buffer while the destination's {@code position} will be increased.
*
* @param index Index into the buffer
- * @param dst The destination buffer
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + dst.remaining()} is greater than
- * {@code this.capacity}
+ * @param dst The destination buffer
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * if {@code index + dst.remaining()} is greater than
+ * {@code this.capacity}
*/
void getBytes(int index, ByteBuffer dst);
@@ -420,9 +401,8 @@ public interface ActiveMQBuffer
*
* @param index Index into the buffer
* @return a char at the specified absolute {@code index}
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 2} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 2} is greater than {@code this.capacity}
*/
char getChar(int index);
@@ -433,9 +413,8 @@ public interface ActiveMQBuffer
*
* @param index Index into the buffer
* @return a float at the specified absolute {@code index}
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 4} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 4} is greater than {@code this.capacity}
*/
float getFloat(int index);
@@ -446,9 +425,8 @@ public interface ActiveMQBuffer
*
* @param index Index into the buffer
* @return a double at the specified absolute {@code index}
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 8} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 8} is greater than {@code this.capacity}
*/
double getDouble(int index);
@@ -460,9 +438,8 @@ public interface ActiveMQBuffer
*
* @param index Index into the buffer
* @param value The specified byte
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 1} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 1} is greater than {@code this.capacity}
*/
void setByte(int index, byte value);
@@ -474,9 +451,8 @@ public interface ActiveMQBuffer
*
* @param index Index into the buffer
* @param value The specified 16-bit short integer
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 2} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 2} is greater than {@code this.capacity}
*/
void setShort(int index, short value);
@@ -488,9 +464,8 @@ public interface ActiveMQBuffer
*
* @param index Index into the buffer
* @param value The specified 32-bit integer
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 4} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 4} is greater than {@code this.capacity}
*/
void setInt(int index, int value);
@@ -502,9 +477,8 @@ public interface ActiveMQBuffer
*
* @param index Index into the buffer
* @param value The specified 64-bit long integer
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 8} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 8} is greater than {@code this.capacity}
*/
void setLong(int index, long value);
@@ -520,11 +494,10 @@ public interface ActiveMQBuffer
* the source buffer (i.e. {@code this}).
*
* @param index Index into the buffer
- * @param src The source buffer
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + src.readableBytes} is greater than
- * {@code this.capacity}
+ * @param src The source buffer
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * if {@code index + src.readableBytes} is greater than
+ * {@code this.capacity}
*/
void setBytes(int index, ActiveMQBuffer src);
@@ -539,14 +512,12 @@ public interface ActiveMQBuffer
* the source buffer (i.e. {@code this}).
*
* @param length the number of bytes to transfer
- * @param index Index into the buffer
- * @param src The source buffer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0},
- * if {@code index + length} is greater than
- * {@code this.capacity}, or
- * if {@code length} is greater than {@code src.readableBytes}
+ * @param index Index into the buffer
+ * @param src The source buffer
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0},
+ * if {@code index + length} is greater than
+ * {@code this.capacity}, or
+ * if {@code length} is greater than {@code src.readableBytes}
*/
void setBytes(int index, ActiveMQBuffer src, int length);
@@ -556,18 +527,16 @@ public interface ActiveMQBuffer
* This method does not modify {@code readerIndex} or {@code writerIndex}
* of both the source (i.e. {@code this}) and the destination.
*
- * @param src The source bufferIndex the first index of the source
- * @param length The number of bytes to transfer
- * @param index Index into the buffer
+ * @param src The source bufferIndex the first index of the source
+ * @param length The number of bytes to transfer
+ * @param index Index into the buffer
* @param srcIndex The source buffer index
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0},
- * if the specified {@code srcIndex} is less than {@code 0},
- * if {@code index + length} is greater than
- * {@code this.capacity}, or
- * if {@code srcIndex + length} is greater than
- * {@code src.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0},
+ * if the specified {@code srcIndex} is less than {@code 0},
+ * if {@code index + length} is greater than
+ * {@code this.capacity}, or
+ * if {@code srcIndex + length} is greater than
+ * {@code src.capacity}
*/
void setBytes(int index, ActiveMQBuffer src, int srcIndex, int length);
@@ -578,11 +547,10 @@ public interface ActiveMQBuffer
* this buffer.
*
* @param index Index into the buffer
- * @param src The source buffer
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + src.length} is greater than
- * {@code this.capacity}
+ * @param src The source buffer
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * if {@code index + src.length} is greater than
+ * {@code this.capacity}
*/
void setBytes(int index, byte[] src);
@@ -592,17 +560,15 @@ public interface ActiveMQBuffer
* This method does not modify {@code readerIndex} or {@code writerIndex} of
* this buffer.
*
- * @param index Index into the buffer
- * @param src The source buffer
+ * @param index Index into the buffer
+ * @param src The source buffer
* @param srcIndex The source buffer index
- * @param length The number of bytes to transfer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0},
- * if the specified {@code srcIndex} is less than {@code 0},
- * if {@code index + length} is greater than
- * {@code this.capacity}, or
- * if {@code srcIndex + length} is greater than {@code src.length}
+ * @param length The number of bytes to transfer
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0},
+ * if the specified {@code srcIndex} is less than {@code 0},
+ * if {@code index + length} is greater than
+ * {@code this.capacity}, or
+ * if {@code srcIndex + length} is greater than {@code src.length}
*/
void setBytes(int index, byte[] src, int srcIndex, int length);
@@ -614,11 +580,10 @@ public interface ActiveMQBuffer
* this buffer.
*
* @param index Index into the buffer
- * @param src The source buffer
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * if {@code index + src.remaining()} is greater than
- * {@code this.capacity}
+ * @param src The source buffer
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * if {@code index + src.remaining()} is greater than
+ * {@code this.capacity}
*/
void setBytes(int index, ByteBuffer src);
@@ -630,9 +595,8 @@ public interface ActiveMQBuffer
*
* @param index Index into the buffer
* @param value The specified char
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 2} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 2} is greater than {@code this.capacity}
*/
void setChar(int index, char value);
@@ -644,9 +608,8 @@ public interface ActiveMQBuffer
*
* @param index Index into the buffer
* @param value The specified float
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 4} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 4} is greater than {@code this.capacity}
*/
void setFloat(int index, float value);
@@ -658,9 +621,8 @@ public interface ActiveMQBuffer
*
* @param index Index into the buffer
* @param value The specified double
- * @throws IndexOutOfBoundsException
- * if the specified {@code index} is less than {@code 0} or
- * {@code index + 8} is greater than {@code this.capacity}
+ * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
+ * {@code index + 8} is greater than {@code this.capacity}
*/
void setDouble(int index, double value);
@@ -669,8 +631,7 @@ public interface ActiveMQBuffer
* the {@code readerIndex} by {@code 1} in this buffer.
*
* @return a byte at the current {@code readerIndex}
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 1}
+ * @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 1}
*/
byte readByte();
@@ -679,8 +640,7 @@ public interface ActiveMQBuffer
* the {@code readerIndex} by {@code 1} in this buffer.
*
* @return an unsigned byte at the current {@code readerIndex}
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 1}
+ * @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 1}
*/
short readUnsignedByte();
@@ -689,8 +649,7 @@ public interface ActiveMQBuffer
* and increases the {@code readerIndex} by {@code 2} in this buffer.
*
* @return a 16-bit short integer at the current {@code readerIndex}
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 2}
+ * @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 2}
*/
short readShort();
@@ -699,48 +658,43 @@ public interface ActiveMQBuffer
* and increases the {@code readerIndex} by {@code 2} in this buffer.
*
* @return an unsigned 16-bit short integer at the current {@code readerIndex}
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 2}
+ * @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 2}
*/
- int readUnsignedShort();
+ int readUnsignedShort();
/**
* Gets a 32-bit integer at the current {@code readerIndex}
* and increases the {@code readerIndex} by {@code 4} in this buffer.
*
* @return a 32-bit integer at the current {@code readerIndex}
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 4}
+ * @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 4}
*/
- int readInt();
+ int readInt();
/**
* Gets an unsigned 32-bit integer at the current {@code readerIndex}
* and increases the {@code readerIndex} by {@code 4} in this buffer.
*
* @return an unsigned 32-bit integer at the current {@code readerIndex}
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 4}
+ * @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 4}
*/
- long readUnsignedInt();
+ long readUnsignedInt();
/**
* Gets a 64-bit integer at the current {@code readerIndex}
* and increases the {@code readerIndex} by {@code 8} in this buffer.
*
* @return a 64-bit integer at the current {@code readerIndex}
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 8}
+ * @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 8}
*/
- long readLong();
+ long readLong();
/**
* Gets a char at the current {@code readerIndex}
* and increases the {@code readerIndex} by {@code 2} in this buffer.
*
* @return a char at the current {@code readerIndex}
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 2}
+ * @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 2}
*/
char readChar();
@@ -749,8 +703,7 @@ public interface ActiveMQBuffer
* and increases the {@code readerIndex} by {@code 4} in this buffer.
*
* @return a float at the current {@code readerIndex}
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 4}
+ * @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 4}
*/
float readFloat();
@@ -759,8 +712,7 @@ public interface ActiveMQBuffer
* and increases the {@code readerIndex} by {@code 8} in this buffer.
*
* @return a double at the current {@code readerIndex}
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 8}
+ * @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 8}
*/
double readDouble();
@@ -769,8 +721,7 @@ public interface ActiveMQBuffer
* and increases the {@code readerIndex} by {@code 1} in this buffer.
*
* @return a boolean at the current {@code readerIndex}
- * @throws IndexOutOfBoundsException
- * if {@code this.readableBytes} is less than {@code 1}
+ * @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 1}
*/
boolean readBoolean();
@@ -817,11 +768,8 @@ public interface ActiveMQBuffer
* {@code 0} and {@code length} respectively.
*
* @param length the number of bytes to transfer
-
* @return the newly created buffer which contains the transferred bytes
- *
- * @throws IndexOutOfBoundsException
- * if {@code length} is greater than {@code this.readableBytes}
+ * @throws IndexOutOfBoundsException if {@code length} is greater than {@code this.readableBytes}
*/
ActiveMQBuffer readBytes(int length);
@@ -831,11 +779,8 @@ public interface ActiveMQBuffer
* of the new slice (= {@code length}).
*
* @param length the size of the new slice
- *
* @return the newly created slice
- *
- * @throws IndexOutOfBoundsException
- * if {@code length} is greater than {@code this.readableBytes}
+ * @throws IndexOutOfBoundsException if {@code length} is greater than {@code this.readableBytes}
*/
ActiveMQBuffer readSlice(int length);
@@ -850,9 +795,8 @@ public interface ActiveMQBuffer
* does not.
*
* @param dst The destination buffer
- * @throws IndexOutOfBoundsException
- * if {@code dst.writableBytes} is greater than
- * {@code this.readableBytes}
+ * @throws IndexOutOfBoundsException if {@code dst.writableBytes} is greater than
+ * {@code this.readableBytes}
*/
void readBytes(ActiveMQBuffer dst);
@@ -865,11 +809,10 @@ public interface ActiveMQBuffer
* destination by the number of the transferred bytes (= {@code length})
* while {@link #readBytes(ActiveMQBuffer, int, int)} does not.
*
- * @param dst The destination buffer
+ * @param dst The destination buffer
* @param length The number of bytes to transfer
- * @throws IndexOutOfBoundsException
- * if {@code length} is greater than {@code this.readableBytes} or
- * if {@code length} is greater than {@code dst.writableBytes}
+ * @throws IndexOutOfBoundsException if {@code length} is greater than {@code this.readableBytes} or
+ * if {@code length} is greater than {@code dst.writableBytes}
*/
void readBytes(ActiveMQBuffer dst, int length);
@@ -880,13 +823,11 @@ public interface ActiveMQBuffer
*
* @param dstIndex The destination buffer index
* @param length the number of bytes to transfer
- * @param dst The destination buffer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code dstIndex} is less than {@code 0},
- * if {@code length} is greater than {@code this.readableBytes}, or
- * if {@code dstIndex + length} is greater than
- * {@code dst.capacity}
+ * @param dst The destination buffer
+ * @throws IndexOutOfBoundsException if the specified {@code dstIndex} is less than {@code 0},
+ * if {@code length} is greater than {@code this.readableBytes}, or
+ * if {@code dstIndex + length} is greater than
+ * {@code dst.capacity}
*/
void readBytes(ActiveMQBuffer dst, int dstIndex, int length);
@@ -896,8 +837,7 @@ public interface ActiveMQBuffer
* by the number of the transferred bytes (= {@code dst.length}).
*
* @param dst The destination buffer
- * @throws IndexOutOfBoundsException
- * if {@code dst.length} is greater than {@code this.readableBytes}
+ * @throws IndexOutOfBoundsException if {@code dst.length} is greater than {@code this.readableBytes}
*/
void readBytes(byte[] dst);
@@ -908,12 +848,10 @@ public interface ActiveMQBuffer
*
* @param dstIndex The destination bufferIndex
* @param length the number of bytes to transfer
- * @param dst The destination buffer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code dstIndex} is less than {@code 0},
- * if {@code length} is greater than {@code this.readableBytes}, or
- * if {@code dstIndex + length} is greater than {@code dst.length}
+ * @param dst The destination buffer
+ * @throws IndexOutOfBoundsException if the specified {@code dstIndex} is less than {@code 0},
+ * if {@code length} is greater than {@code this.readableBytes}, or
+ * if {@code dstIndex + length} is greater than {@code dst.length}
*/
void readBytes(byte[] dst, int dstIndex, int length);
@@ -924,9 +862,8 @@ public interface ActiveMQBuffer
* number of the transferred bytes.
*
* @param dst The destination buffer
- * @throws IndexOutOfBoundsException
- * if {@code dst.remaining()} is greater than
- * {@code this.readableBytes}
+ * @throws IndexOutOfBoundsException if {@code dst.remaining()} is greater than
+ * {@code this.readableBytes}
*/
void readBytes(ByteBuffer dst);
@@ -935,8 +872,7 @@ public interface ActiveMQBuffer
* {@code length} in this buffer.
*
* @param length The number of bytes to skip
- * @throws IndexOutOfBoundsException
- * if {@code length} is greater than {@code this.readableBytes}
+ * @throws IndexOutOfBoundsException if {@code length} is greater than {@code this.readableBytes}
*/
void skipBytes(int length);
@@ -945,10 +881,9 @@ public interface ActiveMQBuffer
* and increases the {@code writerIndex} by {@code 1} in this buffer.
*
* @param value The specified byte
- * @throws IndexOutOfBoundsException
- * if {@code this.writableBytes} is less than {@code 1}
+ * @throws IndexOutOfBoundsException if {@code this.writableBytes} is less than {@code 1}
*/
- void writeByte(byte value);
+ void writeByte(byte value);
/**
* Sets the specified 16-bit short integer at the current
@@ -956,8 +891,7 @@ public interface ActiveMQBuffer
* in this buffer.
*
* @param value The specified 16-bit short integer
- * @throws IndexOutOfBoundsException
- * if {@code this.writableBytes} is less than {@code 2}
+ * @throws IndexOutOfBoundsException if {@code this.writableBytes} is less than {@code 2}
*/
void writeShort(short value);
@@ -966,10 +900,9 @@ public interface ActiveMQBuffer
* and increases the {@code writerIndex} by {@code 4} in this buffer.
*
* @param value The specified 32-bit integer
- * @throws IndexOutOfBoundsException
- * if {@code this.writableBytes} is less than {@code 4}
+ * @throws IndexOutOfBoundsException if {@code this.writableBytes} is less than {@code 4}
*/
- void writeInt(int value);
+ void writeInt(int value);
/**
* Sets the specified 64-bit long integer at the current
@@ -977,18 +910,16 @@ public interface ActiveMQBuffer
* in this buffer.
*
* @param value The specified 64-bit long integer
- * @throws IndexOutOfBoundsException
- * if {@code this.writableBytes} is less than {@code 8}
+ * @throws IndexOutOfBoundsException if {@code this.writableBytes} is less than {@code 8}
*/
- void writeLong(long value);
+ void writeLong(long value);
/**
* Sets the specified char at the current {@code writerIndex}
* and increases the {@code writerIndex} by {@code 2} in this buffer.
*
* @param chr The specified char
- * @throws IndexOutOfBoundsException
- * if {@code this.writableBytes} is less than {@code 2}
+ * @throws IndexOutOfBoundsException if {@code this.writableBytes} is less than {@code 2}
*/
void writeChar(char chr);
@@ -997,8 +928,7 @@ public interface ActiveMQBuffer
* and increases the {@code writerIndex} by {@code 4} in this buffer.
*
* @param value The specified float
- * @throws IndexOutOfBoundsException
- * if {@code this.writableBytes} is less than {@code 4}
+ * @throws IndexOutOfBoundsException if {@code this.writableBytes} is less than {@code 4}
*/
void writeFloat(float value);
@@ -1007,13 +937,13 @@ public interface ActiveMQBuffer
* and increases the {@code writerIndex} by {@code 8} in this buffer.
*
* @param value The specified double
- * @throws IndexOutOfBoundsException
- * if {@code this.writableBytes} is less than {@code 8}
+ * @throws IndexOutOfBoundsException if {@code this.writableBytes} is less than {@code 8}
*/
void writeDouble(double value);
/**
* Sets the specified boolean at the current {@code writerIndex}
+ *
* @param val The specified boolean
*/
void writeBoolean(boolean val);
@@ -1064,10 +994,9 @@ public interface ActiveMQBuffer
* {@link #writeBytes(ActiveMQBuffer, int, int)} does not.
*
* @param length the number of bytes to transfer
- * @param src The source buffer
- * @throws IndexOutOfBoundsException
- * if {@code length} is greater than {@code this.writableBytes} or
- * if {@code length} is greater then {@code src.readableBytes}
+ * @param src The source buffer
+ * @throws IndexOutOfBoundsException if {@code length} is greater than {@code this.writableBytes} or
+ * if {@code length} is greater then {@code src.readableBytes}
*/
void writeBytes(ActiveMQBuffer src, int length);
@@ -1078,13 +1007,11 @@ public interface ActiveMQBuffer
*
* @param srcIndex the first index of the source
* @param length the number of bytes to transfer
- * @param src The source buffer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code srcIndex} is less than {@code 0},
- * if {@code srcIndex + length} is greater than
- * {@code src.capacity}, or
- * if {@code length} is greater than {@code this.writableBytes}
+ * @param src The source buffer
+ * @throws IndexOutOfBoundsException if the specified {@code srcIndex} is less than {@code 0},
+ * if {@code srcIndex + length} is greater than
+ * {@code src.capacity}, or
+ * if {@code length} is greater than {@code this.writableBytes}
*/
void writeBytes(ActiveMQBuffer src, int srcIndex, int length);
@@ -1094,8 +1021,7 @@ public interface ActiveMQBuffer
* by the number of the transferred bytes (= {@code src.length}).
*
* @param src The source buffer
- * @throws IndexOutOfBoundsException
- * if {@code src.length} is greater than {@code this.writableBytes}
+ * @throws IndexOutOfBoundsException if {@code src.length} is greater than {@code this.writableBytes}
*/
void writeBytes(byte[] src);
@@ -1106,13 +1032,11 @@ public interface ActiveMQBuffer
*
* @param srcIndex the first index of the source
* @param length the number of bytes to transfer
- * @param src The source buffer
- *
- * @throws IndexOutOfBoundsException
- * if the specified {@code srcIndex} is less than {@code 0},
- * if {@code srcIndex + length} is greater than
- * {@code src.length}, or
- * if {@code length} is greater than {@code this.writableBytes}
+ * @param src The source buffer
+ * @throws IndexOutOfBoundsException if the specified {@code srcIndex} is less than {@code 0},
+ * if {@code srcIndex + length} is greater than
+ * {@code src.length}, or
+ * if {@code length} is greater than {@code this.writableBytes}
*/
void writeBytes(byte[] src, int srcIndex, int length);
@@ -1123,9 +1047,8 @@ public interface ActiveMQBuffer
* number of the transferred bytes.
*
* @param src The source buffer
- * @throws IndexOutOfBoundsException
- * if {@code src.remaining()} is greater than
- * {@code this.writableBytes}
+ * @throws IndexOutOfBoundsException if {@code src.remaining()} is greater than
+ * {@code this.writableBytes}
*/
void writeBytes(ByteBuffer src);
@@ -1146,7 +1069,7 @@ public interface ActiveMQBuffer
* This method does not modify {@code readerIndex} or {@code writerIndex} of
* this buffer.
*
- * @param index Index into the buffer
+ * @param index Index into the buffer
* @param length The number of bytes to copy
* @return a copy of this buffer's readable bytes.
*/
@@ -1171,7 +1094,7 @@ public interface ActiveMQBuffer
* This method does not modify {@code readerIndex} or {@code writerIndex} of
* this buffer.
*
- * @param index Index into the buffer
+ * @param index Index into the buffer
* @param length The number of bytes
* @return a slice of this buffer's sub-region.
*/
@@ -1208,7 +1131,7 @@ public interface ActiveMQBuffer
* This method does not modify {@code readerIndex} or {@code writerIndex} of
* this buffer.
*
- * @param index Index into the buffer
+ * @param index Index into the buffer
* @param length The number of bytes
* @return A converted NIO Buffer
*/
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffers.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffers.java
index 34fee4d575..22f0f9a9a4 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffers.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffers.java
@@ -24,16 +24,15 @@ import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
/**
* Factory class to create instances of {@link ActiveMQBuffer}.
*/
-public final class ActiveMQBuffers
-{
+public final class ActiveMQBuffers {
+
/**
* Creates a self-expanding ActiveMQBuffer with the given initial size
*
* @param size the initial size of the created ActiveMQBuffer
* @return a self-expanding ActiveMQBuffer starting with the given size
*/
- public static ActiveMQBuffer dynamicBuffer(final int size)
- {
+ public static ActiveMQBuffer dynamicBuffer(final int size) {
return new ChannelBufferWrapper(Unpooled.buffer(size));
}
@@ -43,8 +42,7 @@ public final class ActiveMQBuffers
* @param bytes the created buffer will be initially filled with this byte array
* @return a self-expanding ActiveMQBuffer filled with the given byte array
*/
- public static ActiveMQBuffer dynamicBuffer(final byte[] bytes)
- {
+ public static ActiveMQBuffer dynamicBuffer(final byte[] bytes) {
ActiveMQBuffer buff = dynamicBuffer(bytes.length);
buff.writeBytes(bytes);
@@ -60,8 +58,7 @@ public final class ActiveMQBuffers
* @param underlying the underlying NIO ByteBuffer
* @return an ActiveMQBuffer wrapping the underlying NIO ByteBuffer
*/
- public static ActiveMQBuffer wrappedBuffer(final ByteBuffer underlying)
- {
+ public static ActiveMQBuffer wrappedBuffer(final ByteBuffer underlying) {
ActiveMQBuffer buff = new ChannelBufferWrapper(Unpooled.wrappedBuffer(underlying));
buff.clear();
@@ -75,8 +72,7 @@ public final class ActiveMQBuffers
* @param underlying the underlying byte array
* @return an ActiveMQBuffer wrapping the underlying byte array
*/
- public static ActiveMQBuffer wrappedBuffer(final byte[] underlying)
- {
+ public static ActiveMQBuffer wrappedBuffer(final byte[] underlying) {
return new ChannelBufferWrapper(Unpooled.wrappedBuffer(underlying));
}
@@ -86,13 +82,11 @@ public final class ActiveMQBuffers
* @param size the size of the created ActiveMQBuffer
* @return a fixed ActiveMQBuffer with the given size
*/
- public static ActiveMQBuffer fixedBuffer(final int size)
- {
+ public static ActiveMQBuffer fixedBuffer(final int size) {
return new ChannelBufferWrapper(Unpooled.buffer(size, size));
}
- private ActiveMQBuffers()
- {
+ private ActiveMQBuffers() {
// Utility class
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQClusterSecurityException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQClusterSecurityException.java
index 8d53de7bac..6543e42dc6 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQClusterSecurityException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQClusterSecurityException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* Security exception thrown when the cluster user fails authentication.
*/
-public final class ActiveMQClusterSecurityException extends ActiveMQException
-{
+public final class ActiveMQClusterSecurityException extends ActiveMQException {
+
private static final long serialVersionUID = -5890578849781297933L;
- public ActiveMQClusterSecurityException()
- {
+ public ActiveMQClusterSecurityException() {
super(ActiveMQExceptionType.CLUSTER_SECURITY_EXCEPTION);
}
- public ActiveMQClusterSecurityException(final String msg)
- {
+ public ActiveMQClusterSecurityException(final String msg) {
super(ActiveMQExceptionType.CLUSTER_SECURITY_EXCEPTION, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQConnectionTimedOutException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQConnectionTimedOutException.java
index 13c11dd917..1b8a3c72d6 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQConnectionTimedOutException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQConnectionTimedOutException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* A client timed out will connecting to ActiveMQ Artemis server.
*/
-public final class ActiveMQConnectionTimedOutException extends ActiveMQException
-{
+public final class ActiveMQConnectionTimedOutException extends ActiveMQException {
+
private static final long serialVersionUID = 3244233758084830372L;
- public ActiveMQConnectionTimedOutException()
- {
+ public ActiveMQConnectionTimedOutException() {
super(ActiveMQExceptionType.CONNECTION_TIMEDOUT);
}
- public ActiveMQConnectionTimedOutException(String msg)
- {
+ public ActiveMQConnectionTimedOutException(String msg) {
super(ActiveMQExceptionType.CONNECTION_TIMEDOUT, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQDisconnectedException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQDisconnectedException.java
index 2ce6882f05..45a0e7aa1b 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQDisconnectedException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQDisconnectedException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* A client was disconnected from ActiveMQ Artemis server when the server has shut down.
*/
-public final class ActiveMQDisconnectedException extends ActiveMQException
-{
+public final class ActiveMQDisconnectedException extends ActiveMQException {
+
private static final long serialVersionUID = 7414966383933311627L;
- public ActiveMQDisconnectedException()
- {
+ public ActiveMQDisconnectedException() {
super(ActiveMQExceptionType.DISCONNECTED);
}
- public ActiveMQDisconnectedException(String message)
- {
+ public ActiveMQDisconnectedException(String message) {
super(ActiveMQExceptionType.DISCONNECTED, message);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQDuplicateIdException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQDuplicateIdException.java
index 03260cd58e..c999aaf2f9 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQDuplicateIdException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQDuplicateIdException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* A DuplicateID was rejected.
*/
-public final class ActiveMQDuplicateIdException extends ActiveMQException
-{
+public final class ActiveMQDuplicateIdException extends ActiveMQException {
+
private static final long serialVersionUID = -4302979339865777119L;
- public ActiveMQDuplicateIdException()
- {
+ public ActiveMQDuplicateIdException() {
super(ActiveMQExceptionType.DUPLICATE_ID_REJECTED);
}
- public ActiveMQDuplicateIdException(String message)
- {
+ public ActiveMQDuplicateIdException(String message) {
super(ActiveMQExceptionType.DUPLICATE_ID_REJECTED, message);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQDuplicateMetaDataException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQDuplicateMetaDataException.java
index 40f2acbc52..a452011c7e 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQDuplicateMetaDataException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQDuplicateMetaDataException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* A Session Metadata was set in duplication
*/
-public final class ActiveMQDuplicateMetaDataException extends ActiveMQException
-{
+public final class ActiveMQDuplicateMetaDataException extends ActiveMQException {
+
private static final long serialVersionUID = 7877182872143004058L;
- public ActiveMQDuplicateMetaDataException()
- {
+ public ActiveMQDuplicateMetaDataException() {
super(ActiveMQExceptionType.DUPLICATE_METADATA);
}
- public ActiveMQDuplicateMetaDataException(String msg)
- {
+ public ActiveMQDuplicateMetaDataException(String msg) {
super(ActiveMQExceptionType.DUPLICATE_METADATA, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQException.java
index 8fa3a18d9d..13a35b1d51 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQException.java
@@ -19,19 +19,17 @@ package org.apache.activemq.artemis.api.core;
/**
* ActiveMQException is the root exception for the ActiveMQ Artemis API.
*/
-public class ActiveMQException extends Exception
-{
+public class ActiveMQException extends Exception {
+
private static final long serialVersionUID = -4802014152804997417L;
private final ActiveMQExceptionType type;
- public ActiveMQException()
- {
+ public ActiveMQException() {
type = ActiveMQExceptionType.GENERIC_EXCEPTION;
}
- public ActiveMQException(final String msg)
- {
+ public ActiveMQException(final String msg) {
super(msg);
type = ActiveMQExceptionType.GENERIC_EXCEPTION;
}
@@ -39,39 +37,33 @@ public class ActiveMQException extends Exception
/*
* This constructor is needed only for the native layer
*/
- public ActiveMQException(int code, String msg)
- {
+ public ActiveMQException(int code, String msg) {
super(msg);
this.type = ActiveMQExceptionType.getType(code);
}
- public ActiveMQException(ActiveMQExceptionType type, String msg)
- {
+ public ActiveMQException(ActiveMQExceptionType type, String msg) {
super(msg);
this.type = type;
}
- public ActiveMQException(ActiveMQExceptionType type)
- {
+ public ActiveMQException(ActiveMQExceptionType type) {
this.type = type;
}
- public ActiveMQException(ActiveMQExceptionType type, String message, Throwable t)
- {
+ public ActiveMQException(ActiveMQExceptionType type, String message, Throwable t) {
super(message, t);
this.type = type;
}
- public ActiveMQExceptionType getType()
- {
+ public ActiveMQExceptionType getType() {
return type;
}
@Override
- public String toString()
- {
+ public String toString() {
return this.getClass().getSimpleName() + "[errorType=" + type + " message=" + getMessage() + "]";
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQExceptionType.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQExceptionType.java
index 700508e152..6aca1d013d 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQExceptionType.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQExceptionType.java
@@ -24,200 +24,151 @@ import java.util.Map;
/**
* Defines all {@link ActiveMQException} types and their codes.
*/
-public enum ActiveMQExceptionType
-{
+public enum ActiveMQExceptionType {
// Error codes -------------------------------------------------
- INTERNAL_ERROR(000)
- {
+ INTERNAL_ERROR(000) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQInternalErrorException(msg);
}
},
- UNSUPPORTED_PACKET(001)
- {
+ UNSUPPORTED_PACKET(001) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQUnsupportedPacketException(msg);
}
},
- NOT_CONNECTED(002)
- {
+ NOT_CONNECTED(002) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQNotConnectedException(msg);
}
},
- CONNECTION_TIMEDOUT(003)
- {
+ CONNECTION_TIMEDOUT(003) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQConnectionTimedOutException(msg);
}
},
- DISCONNECTED(004)
- {
+ DISCONNECTED(004) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQDisconnectedException(msg);
}
},
- UNBLOCKED(005)
- {
+ UNBLOCKED(005) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQUnBlockedException(msg);
}
},
- IO_ERROR(006)
- {
+ IO_ERROR(006) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQIOErrorException(msg);
}
},
- QUEUE_DOES_NOT_EXIST(100)
- {
+ QUEUE_DOES_NOT_EXIST(100) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQNonExistentQueueException(msg);
}
},
- QUEUE_EXISTS(101)
- {
+ QUEUE_EXISTS(101) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQQueueExistsException(msg);
}
},
- OBJECT_CLOSED(102)
- {
+ OBJECT_CLOSED(102) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQObjectClosedException(msg);
}
},
- INVALID_FILTER_EXPRESSION(103)
- {
+ INVALID_FILTER_EXPRESSION(103) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQInvalidFilterExpressionException(msg);
}
},
- ILLEGAL_STATE(104)
- {
+ ILLEGAL_STATE(104) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQIllegalStateException(msg);
}
},
- SECURITY_EXCEPTION(105)
- {
+ SECURITY_EXCEPTION(105) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQSecurityException(msg);
}
},
- ADDRESS_EXISTS(107)
- {
+ ADDRESS_EXISTS(107) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQAddressExistsException(msg);
}
},
- INCOMPATIBLE_CLIENT_SERVER_VERSIONS(108)
- {
+ INCOMPATIBLE_CLIENT_SERVER_VERSIONS(108) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQIncompatibleClientServerException(msg);
}
},
- LARGE_MESSAGE_ERROR_BODY(110)
- {
+ LARGE_MESSAGE_ERROR_BODY(110) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQLargeMessageException(msg);
}
},
- TRANSACTION_ROLLED_BACK(111)
- {
+ TRANSACTION_ROLLED_BACK(111) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQTransactionRolledBackException(msg);
}
},
- SESSION_CREATION_REJECTED(112)
- {
+ SESSION_CREATION_REJECTED(112) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQSessionCreationException(msg);
}
},
- DUPLICATE_ID_REJECTED(113)
- {
+ DUPLICATE_ID_REJECTED(113) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQDuplicateIdException(msg);
}
},
- DUPLICATE_METADATA(114)
- {
+ DUPLICATE_METADATA(114) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQDuplicateMetaDataException(msg);
}
},
- TRANSACTION_OUTCOME_UNKNOWN(115)
- {
+ TRANSACTION_OUTCOME_UNKNOWN(115) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQTransactionOutcomeUnknownException(msg);
}
},
- ALREADY_REPLICATING(116)
- {
+ ALREADY_REPLICATING(116) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQAlreadyReplicatingException(msg);
}
},
- INTERCEPTOR_REJECTED_PACKET(117)
- {
+ INTERCEPTOR_REJECTED_PACKET(117) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQInterceptorRejectedPacketException(msg);
}
},
- INVALID_TRANSIENT_QUEUE_USE(118)
- {
+ INVALID_TRANSIENT_QUEUE_USE(118) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQInvalidTransientQueueUseException(msg);
}
},
@@ -232,27 +183,21 @@ public enum ActiveMQExceptionType
NATIVE_ERROR_CANT_ALLOCATE_QUEUE(206),
NATIVE_ERROR_PREALLOCATE_FILE(208),
NATIVE_ERROR_ALLOCATE_MEMORY(209),
- ADDRESS_FULL(210)
- {
+ ADDRESS_FULL(210) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQAddressFullException(msg);
}
},
- LARGE_MESSAGE_INTERRUPTED(211)
- {
+ LARGE_MESSAGE_INTERRUPTED(211) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQLargeMessageInterruptedException(msg);
}
},
- CLUSTER_SECURITY_EXCEPTION(212)
- {
+ CLUSTER_SECURITY_EXCEPTION(212) {
@Override
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQClusterSecurityException(msg);
}
@@ -260,11 +205,9 @@ public enum ActiveMQExceptionType
private static final Map TYPE_MAP;
- static
- {
+ static {
HashMap map = new HashMap();
- for (ActiveMQExceptionType type : EnumSet.allOf(ActiveMQExceptionType.class))
- {
+ for (ActiveMQExceptionType type : EnumSet.allOf(ActiveMQExceptionType.class)) {
map.put(type.getCode(), type);
}
TYPE_MAP = Collections.unmodifiableMap(map);
@@ -272,28 +215,23 @@ public enum ActiveMQExceptionType
private final int code;
- ActiveMQExceptionType(int code)
- {
+ ActiveMQExceptionType(int code) {
this.code = code;
}
- public int getCode()
- {
+ public int getCode() {
return code;
}
- public ActiveMQException createException(String msg)
- {
+ public ActiveMQException createException(String msg) {
return new ActiveMQException(msg + ", code:" + this);
}
- public static ActiveMQException createException(int code, String msg)
- {
+ public static ActiveMQException createException(int code, String msg) {
return getType(code).createException(msg);
}
- public static ActiveMQExceptionType getType(int code)
- {
+ public static ActiveMQExceptionType getType(int code) {
ActiveMQExceptionType type = TYPE_MAP.get(code);
if (type != null)
return type;
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQIOErrorException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQIOErrorException.java
index f89ddbd4de..56973d4513 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQIOErrorException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQIOErrorException.java
@@ -19,22 +19,19 @@ package org.apache.activemq.artemis.api.core;
/**
* Unexpected I/O error occurred on the server.
*/
-public final class ActiveMQIOErrorException extends ActiveMQException
-{
+public final class ActiveMQIOErrorException extends ActiveMQException {
+
private static final long serialVersionUID = 797277117077787396L;
- public ActiveMQIOErrorException()
- {
+ public ActiveMQIOErrorException() {
super(ActiveMQExceptionType.IO_ERROR);
}
- public ActiveMQIOErrorException(String msg)
- {
+ public ActiveMQIOErrorException(String msg) {
super(ActiveMQExceptionType.IO_ERROR, msg);
}
- public ActiveMQIOErrorException(String msg, Throwable cause)
- {
+ public ActiveMQIOErrorException(String msg, Throwable cause) {
super(ActiveMQExceptionType.IO_ERROR, msg, cause);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQIllegalStateException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQIllegalStateException.java
index 8ad6b2161b..3ee855b06d 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQIllegalStateException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQIllegalStateException.java
@@ -20,17 +20,15 @@ package org.apache.activemq.artemis.api.core;
* An ActiveMQ Artemis resource is not in a legal state (e.g. calling ClientConsumer.receive() if a
* MessageHandler is set).
*/
-public final class ActiveMQIllegalStateException extends ActiveMQException
-{
+public final class ActiveMQIllegalStateException extends ActiveMQException {
+
private static final long serialVersionUID = -4480125401057788511L;
- public ActiveMQIllegalStateException()
- {
+ public ActiveMQIllegalStateException() {
super(ActiveMQExceptionType.ILLEGAL_STATE);
}
- public ActiveMQIllegalStateException(String message)
- {
+ public ActiveMQIllegalStateException(String message) {
super(ActiveMQExceptionType.ILLEGAL_STATE, message);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQIncompatibleClientServerException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQIncompatibleClientServerException.java
index 7522d101b7..0be739dc8c 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQIncompatibleClientServerException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQIncompatibleClientServerException.java
@@ -21,17 +21,15 @@ package org.apache.activemq.artemis.api.core;
*
* Normally this means you are trying to use a newer client on an older server.
*/
-public final class ActiveMQIncompatibleClientServerException extends ActiveMQException
-{
+public final class ActiveMQIncompatibleClientServerException extends ActiveMQException {
+
private static final long serialVersionUID = -1662999230291452298L;
- public ActiveMQIncompatibleClientServerException()
- {
+ public ActiveMQIncompatibleClientServerException() {
super(ActiveMQExceptionType.INCOMPATIBLE_CLIENT_SERVER_VERSIONS);
}
- public ActiveMQIncompatibleClientServerException(String msg)
- {
+ public ActiveMQIncompatibleClientServerException(String msg) {
super(ActiveMQExceptionType.INCOMPATIBLE_CLIENT_SERVER_VERSIONS, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInterceptorRejectedPacketException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInterceptorRejectedPacketException.java
index 57d60d44c6..e52c113bf4 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInterceptorRejectedPacketException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInterceptorRejectedPacketException.java
@@ -21,17 +21,15 @@ package org.apache.activemq.artemis.api.core;
* See org.apache.activemq.artemis.api.core.client.ServerLocator#addOutgoingInterceptor(org.apache.activemq.artemis.api.core.Interceptor)
*/
// XXX I doubt any reader will make much sense of this Javadoc's text.
-public final class ActiveMQInterceptorRejectedPacketException extends ActiveMQException
-{
+public final class ActiveMQInterceptorRejectedPacketException extends ActiveMQException {
+
private static final long serialVersionUID = -5798841227645281815L;
- public ActiveMQInterceptorRejectedPacketException()
- {
+ public ActiveMQInterceptorRejectedPacketException() {
super(ActiveMQExceptionType.INTERCEPTOR_REJECTED_PACKET);
}
- public ActiveMQInterceptorRejectedPacketException(String msg)
- {
+ public ActiveMQInterceptorRejectedPacketException(String msg) {
super(ActiveMQExceptionType.INTERCEPTOR_REJECTED_PACKET, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInternalErrorException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInternalErrorException.java
index 18a5b16166..9da7d80188 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInternalErrorException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInternalErrorException.java
@@ -19,27 +19,23 @@ package org.apache.activemq.artemis.api.core;
/**
* Internal error which prevented ActiveMQ Artemis from performing an important operation.
*/
-public final class ActiveMQInternalErrorException extends ActiveMQException
-{
+public final class ActiveMQInternalErrorException extends ActiveMQException {
+
private static final long serialVersionUID = -5987814047521530695L;
- public ActiveMQInternalErrorException()
- {
+ public ActiveMQInternalErrorException() {
super(ActiveMQExceptionType.INTERNAL_ERROR);
}
- public ActiveMQInternalErrorException(String msg)
- {
+ public ActiveMQInternalErrorException(String msg) {
super(ActiveMQExceptionType.INTERNAL_ERROR, msg);
}
- public ActiveMQInternalErrorException(String message, Exception e)
- {
+ public ActiveMQInternalErrorException(String message, Exception e) {
super(ActiveMQExceptionType.INTERNAL_ERROR, message, e);
}
- public ActiveMQInternalErrorException(String message, Throwable t)
- {
+ public ActiveMQInternalErrorException(String message, Throwable t) {
super(ActiveMQExceptionType.INTERNAL_ERROR, message, t);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInterruptedException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInterruptedException.java
index eee402bde2..9a3ff7fc49 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInterruptedException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInterruptedException.java
@@ -19,12 +19,11 @@ package org.apache.activemq.artemis.api.core;
/**
* When an interruption happens, we will just throw a non-checked exception.
*/
-public final class ActiveMQInterruptedException extends RuntimeException
-{
+public final class ActiveMQInterruptedException extends RuntimeException {
+
private static final long serialVersionUID = -5744690023549671221L;
- public ActiveMQInterruptedException(Throwable cause)
- {
+ public ActiveMQInterruptedException(Throwable cause) {
super(cause);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInvalidFilterExpressionException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInvalidFilterExpressionException.java
index 60397a29be..f3b0950138 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInvalidFilterExpressionException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInvalidFilterExpressionException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* A filter expression was found to be invalid.
*/
-public final class ActiveMQInvalidFilterExpressionException extends ActiveMQException
-{
+public final class ActiveMQInvalidFilterExpressionException extends ActiveMQException {
+
private static final long serialVersionUID = 7188625553939665128L;
- public ActiveMQInvalidFilterExpressionException()
- {
+ public ActiveMQInvalidFilterExpressionException() {
super(ActiveMQExceptionType.INVALID_FILTER_EXPRESSION);
}
- public ActiveMQInvalidFilterExpressionException(String msg)
- {
+ public ActiveMQInvalidFilterExpressionException(String msg) {
super(ActiveMQExceptionType.INVALID_FILTER_EXPRESSION, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInvalidTransientQueueUseException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInvalidTransientQueueUseException.java
index 8951004398..13416d4bf5 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInvalidTransientQueueUseException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQInvalidTransientQueueUseException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* An operation failed because a queue exists on the server.
*/
-public final class ActiveMQInvalidTransientQueueUseException extends ActiveMQException
-{
+public final class ActiveMQInvalidTransientQueueUseException extends ActiveMQException {
+
private static final long serialVersionUID = -405552292451883063L;
- public ActiveMQInvalidTransientQueueUseException()
- {
+ public ActiveMQInvalidTransientQueueUseException() {
super(ActiveMQExceptionType.INVALID_TRANSIENT_QUEUE_USE);
}
- public ActiveMQInvalidTransientQueueUseException(String msg)
- {
+ public ActiveMQInvalidTransientQueueUseException(String msg) {
super(ActiveMQExceptionType.INVALID_TRANSIENT_QUEUE_USE, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQLargeMessageException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQLargeMessageException.java
index c3f6636fad..9c68cc7b31 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQLargeMessageException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQLargeMessageException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* A problem occurred while manipulating the body of a large message.
*/
-public final class ActiveMQLargeMessageException extends ActiveMQException
-{
+public final class ActiveMQLargeMessageException extends ActiveMQException {
+
private static final long serialVersionUID = 1087867463974768491L;
- public ActiveMQLargeMessageException()
- {
+ public ActiveMQLargeMessageException() {
super(ActiveMQExceptionType.LARGE_MESSAGE_ERROR_BODY);
}
- public ActiveMQLargeMessageException(String msg)
- {
+ public ActiveMQLargeMessageException(String msg) {
super(ActiveMQExceptionType.LARGE_MESSAGE_ERROR_BODY, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQLargeMessageInterruptedException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQLargeMessageInterruptedException.java
index 786bf7df53..77c45b93cb 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQLargeMessageInterruptedException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQLargeMessageInterruptedException.java
@@ -16,21 +16,18 @@
*/
package org.apache.activemq.artemis.api.core;
-
/**
*/
// XXX
-public class ActiveMQLargeMessageInterruptedException extends ActiveMQException
-{
+public class ActiveMQLargeMessageInterruptedException extends ActiveMQException {
+
private static final long serialVersionUID = 0;
- public ActiveMQLargeMessageInterruptedException(String message)
- {
+ public ActiveMQLargeMessageInterruptedException(String message) {
super(ActiveMQExceptionType.LARGE_MESSAGE_INTERRUPTED, message);
}
- public ActiveMQLargeMessageInterruptedException()
- {
+ public ActiveMQLargeMessageInterruptedException() {
super(ActiveMQExceptionType.LARGE_MESSAGE_INTERRUPTED);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQNativeIOError.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQNativeIOError.java
index e69a7fd3f5..1ed755d2ba 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQNativeIOError.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQNativeIOError.java
@@ -16,27 +16,23 @@
*/
package org.apache.activemq.artemis.api.core;
-
/**
* An error has happened at ActiveMQ's native (non-Java) code used in reading and writing data.
*/
// XXX
-public final class ActiveMQNativeIOError extends ActiveMQException
-{
+public final class ActiveMQNativeIOError extends ActiveMQException {
+
private static final long serialVersionUID = 2355120980683293085L;
- public ActiveMQNativeIOError()
- {
+ public ActiveMQNativeIOError() {
super(ActiveMQExceptionType.NATIVE_ERROR_CANT_INITIALIZE_AIO);
}
- public ActiveMQNativeIOError(String msg)
- {
+ public ActiveMQNativeIOError(String msg) {
super(ActiveMQExceptionType.NATIVE_ERROR_CANT_INITIALIZE_AIO, msg);
}
- public ActiveMQNativeIOError(String msg, Throwable e)
- {
+ public ActiveMQNativeIOError(String msg, Throwable e) {
super(ActiveMQExceptionType.NATIVE_ERROR_CANT_INITIALIZE_AIO, msg, e);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQNonExistentQueueException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQNonExistentQueueException.java
index 7b6eb6a2e1..79659bb210 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQNonExistentQueueException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQNonExistentQueueException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* An operation failed because a queue does not exist on the server.
*/
-public final class ActiveMQNonExistentQueueException extends ActiveMQException
-{
+public final class ActiveMQNonExistentQueueException extends ActiveMQException {
+
private static final long serialVersionUID = -8199298881947523607L;
- public ActiveMQNonExistentQueueException()
- {
+ public ActiveMQNonExistentQueueException() {
super(ActiveMQExceptionType.QUEUE_DOES_NOT_EXIST);
}
- public ActiveMQNonExistentQueueException(String msg)
- {
+ public ActiveMQNonExistentQueueException(String msg) {
super(ActiveMQExceptionType.QUEUE_DOES_NOT_EXIST, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQNotConnectedException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQNotConnectedException.java
index 3a95fcd0de..19375a7efd 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQNotConnectedException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQNotConnectedException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* A client is not able to connect to ActiveMQ Artemis server.
*/
-public final class ActiveMQNotConnectedException extends ActiveMQException
-{
+public final class ActiveMQNotConnectedException extends ActiveMQException {
+
private static final long serialVersionUID = -3489189971813613325L;
- public ActiveMQNotConnectedException(String message)
- {
+ public ActiveMQNotConnectedException(String message) {
super(ActiveMQExceptionType.NOT_CONNECTED, message);
}
- public ActiveMQNotConnectedException()
- {
+ public ActiveMQNotConnectedException() {
super(ActiveMQExceptionType.NOT_CONNECTED);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQObjectClosedException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQObjectClosedException.java
index 7ad745f63e..06dad546e5 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQObjectClosedException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQObjectClosedException.java
@@ -20,17 +20,15 @@ package org.apache.activemq.artemis.api.core;
* A client operation failed because the calling resource (ClientSession, ClientProducer, etc.) is
* closed.
*/
-public final class ActiveMQObjectClosedException extends ActiveMQException
-{
+public final class ActiveMQObjectClosedException extends ActiveMQException {
+
private static final long serialVersionUID = 809024052184914812L;
- public ActiveMQObjectClosedException()
- {
+ public ActiveMQObjectClosedException() {
super(ActiveMQExceptionType.OBJECT_CLOSED);
}
- public ActiveMQObjectClosedException(String msg)
- {
+ public ActiveMQObjectClosedException(String msg) {
super(ActiveMQExceptionType.OBJECT_CLOSED, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQPropertyConversionException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQPropertyConversionException.java
index 842a0fed0b..910f74f452 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQPropertyConversionException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQPropertyConversionException.java
@@ -20,13 +20,11 @@ package org.apache.activemq.artemis.api.core;
* A PropertyConversionException is thrown by {@code org.apache.activemq.artemis.api.core.Message} methods when a
* property can not be converted to the expected type.
*/
-public final class ActiveMQPropertyConversionException extends RuntimeException
-{
+public final class ActiveMQPropertyConversionException extends RuntimeException {
private static final long serialVersionUID = -3010008708334904332L;
- public ActiveMQPropertyConversionException(final String message)
- {
+ public ActiveMQPropertyConversionException(final String message) {
super(message);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQQueueExistsException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQQueueExistsException.java
index e88dc17058..426deb8953 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQQueueExistsException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQQueueExistsException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* An operation failed because a queue exists on the server.
*/
-public final class ActiveMQQueueExistsException extends ActiveMQException
-{
+public final class ActiveMQQueueExistsException extends ActiveMQException {
+
private static final long serialVersionUID = -405552292451883063L;
- public ActiveMQQueueExistsException()
- {
+ public ActiveMQQueueExistsException() {
super(ActiveMQExceptionType.QUEUE_EXISTS);
}
- public ActiveMQQueueExistsException(String msg)
- {
+ public ActiveMQQueueExistsException(String msg) {
super(ActiveMQExceptionType.QUEUE_EXISTS, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQSecurityException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQSecurityException.java
index b3ce7d283f..da51b3836d 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQSecurityException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQSecurityException.java
@@ -21,17 +21,15 @@ import static org.apache.activemq.artemis.api.core.ActiveMQExceptionType.SECURIT
/**
* A security problem occurred (authentication issues, permission issues,...)
*/
-public final class ActiveMQSecurityException extends ActiveMQException
-{
+public final class ActiveMQSecurityException extends ActiveMQException {
+
private static final long serialVersionUID = 3291210307590756881L;
- public ActiveMQSecurityException()
- {
+ public ActiveMQSecurityException() {
super(SECURITY_EXCEPTION);
}
- public ActiveMQSecurityException(String msg)
- {
+ public ActiveMQSecurityException(String msg) {
super(SECURITY_EXCEPTION, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQSessionCreationException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQSessionCreationException.java
index c3af3f0cf8..a2c973a4f9 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQSessionCreationException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQSessionCreationException.java
@@ -20,17 +20,15 @@ package org.apache.activemq.artemis.api.core;
* The creation of a session was rejected by the server (e.g. if the server is starting and has not
* finish to be initialized.
*/
-public final class ActiveMQSessionCreationException extends ActiveMQException
-{
+public final class ActiveMQSessionCreationException extends ActiveMQException {
+
private static final long serialVersionUID = -4486139158452585895L;
- public ActiveMQSessionCreationException()
- {
+ public ActiveMQSessionCreationException() {
super(ActiveMQExceptionType.SESSION_CREATION_REJECTED);
}
- public ActiveMQSessionCreationException(String msg)
- {
+ public ActiveMQSessionCreationException(String msg) {
super(ActiveMQExceptionType.SESSION_CREATION_REJECTED, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQTransactionOutcomeUnknownException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQTransactionOutcomeUnknownException.java
index 447cdca493..d0e56a101a 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQTransactionOutcomeUnknownException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQTransactionOutcomeUnknownException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* The outcome of a transaction is unknown.
*/
-public final class ActiveMQTransactionOutcomeUnknownException extends ActiveMQException
-{
+public final class ActiveMQTransactionOutcomeUnknownException extends ActiveMQException {
+
private static final long serialVersionUID = 7940794286427650558L;
- public ActiveMQTransactionOutcomeUnknownException()
- {
+ public ActiveMQTransactionOutcomeUnknownException() {
super(ActiveMQExceptionType.TRANSACTION_OUTCOME_UNKNOWN);
}
- public ActiveMQTransactionOutcomeUnknownException(String msg)
- {
+ public ActiveMQTransactionOutcomeUnknownException(String msg) {
super(ActiveMQExceptionType.TRANSACTION_OUTCOME_UNKNOWN, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQTransactionRolledBackException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQTransactionRolledBackException.java
index e6e4443818..03e4c58717 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQTransactionRolledBackException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQTransactionRolledBackException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* A transaction was rolled back.
*/
-public final class ActiveMQTransactionRolledBackException extends ActiveMQException
-{
+public final class ActiveMQTransactionRolledBackException extends ActiveMQException {
+
private static final long serialVersionUID = 5823412198677126300L;
- public ActiveMQTransactionRolledBackException()
- {
+ public ActiveMQTransactionRolledBackException() {
super(ActiveMQExceptionType.TRANSACTION_ROLLED_BACK);
}
- public ActiveMQTransactionRolledBackException(String msg)
- {
+ public ActiveMQTransactionRolledBackException(String msg) {
super(ActiveMQExceptionType.TRANSACTION_ROLLED_BACK, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQUnBlockedException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQUnBlockedException.java
index 19eb18cb6e..5b2a421bed 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQUnBlockedException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQUnBlockedException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* A blocking call from a client was unblocked during failover.
*/
-public final class ActiveMQUnBlockedException extends ActiveMQException
-{
+public final class ActiveMQUnBlockedException extends ActiveMQException {
+
private static final long serialVersionUID = -4507889261891160608L;
- public ActiveMQUnBlockedException()
- {
+ public ActiveMQUnBlockedException() {
super(ActiveMQExceptionType.UNBLOCKED);
}
- public ActiveMQUnBlockedException(String msg)
- {
+ public ActiveMQUnBlockedException(String msg) {
super(ActiveMQExceptionType.UNBLOCKED, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQUnsupportedPacketException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQUnsupportedPacketException.java
index c6cb7643c5..377d2c51d8 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQUnsupportedPacketException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQUnsupportedPacketException.java
@@ -19,17 +19,15 @@ package org.apache.activemq.artemis.api.core;
/**
* A packet of unsupported type was received by ActiveMQ Artemis PacketHandler.
*/
-public final class ActiveMQUnsupportedPacketException extends ActiveMQException
-{
+public final class ActiveMQUnsupportedPacketException extends ActiveMQException {
+
private static final long serialVersionUID = -7074681529482463675L;
- public ActiveMQUnsupportedPacketException()
- {
+ public ActiveMQUnsupportedPacketException() {
super(ActiveMQExceptionType.UNSUPPORTED_PACKET);
}
- public ActiveMQUnsupportedPacketException(String msg)
- {
+ public ActiveMQUnsupportedPacketException(String msg) {
super(ActiveMQExceptionType.UNSUPPORTED_PACKET, msg);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/Pair.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/Pair.java
index 4497c6ff2a..b3e130f25a 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/Pair.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/Pair.java
@@ -23,12 +23,11 @@ import java.io.Serializable;
*
* This is a utility class.
*/
-public final class Pair implements Serializable
-{
+public final class Pair implements Serializable {
+
private static final long serialVersionUID = -2496357457812368127L;
- public Pair(final A a, final B b)
- {
+ public Pair(final A a, final B b) {
this.a = a;
this.b = b;
@@ -41,16 +40,12 @@ public final class Pair implements Serializable
private int hash = -1;
@Override
- public int hashCode()
- {
- if (hash == -1)
- {
- if (a == null && b == null)
- {
+ public int hashCode() {
+ if (hash == -1) {
+ if (a == null && b == null) {
return super.hashCode();
}
- else
- {
+ else {
hash = (a == null ? 0 : a.hashCode()) + 37 * (b == null ? 0 : b.hashCode());
}
}
@@ -59,49 +54,41 @@ public final class Pair implements Serializable
}
@Override
- public boolean equals(final Object other)
- {
- if (other == this)
- {
+ public boolean equals(final Object other) {
+ if (other == this) {
return true;
}
- if (other instanceof Pair == false)
- {
+ if (other instanceof Pair == false) {
return false;
}
- Pair pother = (Pair)other;
+ Pair pother = (Pair) other;
return (pother.a == null ? a == null : pother.a.equals(a)) && (pother.b == null ? b == null : pother.b.equals(b));
}
@Override
- public String toString()
- {
+ public String toString() {
return "Pair[a=" + a + ", b=" + b + "]";
}
- public void setA(A a)
- {
+ public void setA(A a) {
hash = -1;
this.a = a;
}
- public A getA()
- {
+ public A getA() {
return a;
}
- public void setB(B b)
- {
+ public void setB(B b) {
hash = -1;
this.b = b;
}
- public B getB()
- {
+ public B getB() {
return b;
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/SimpleString.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/SimpleString.java
index 3c8a35c118..d50e46defc 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/SimpleString.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/SimpleString.java
@@ -27,10 +27,9 @@ import org.apache.activemq.artemis.utils.DataConstants;
* minimises expensive copying between String objects.
*
* This object is used heavily throughout ActiveMQ Artemis for performance reasons.
- *
*/
-public final class SimpleString implements CharSequence, Serializable, Comparable
-{
+public final class SimpleString implements CharSequence, Serializable, Comparable {
+
private static final long serialVersionUID = 4204223851422244307L;
// Attributes
@@ -53,10 +52,8 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
* @param string String used to instantiate a SimpleString.
* @return A new SimpleString
*/
- public static SimpleString toSimpleString(final String string)
- {
- if (string == null)
- {
+ public static SimpleString toSimpleString(final String string) {
+ if (string == null) {
return null;
}
return new SimpleString(string);
@@ -70,16 +67,14 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
*
* @param string the string to transform
*/
- public SimpleString(final String string)
- {
+ public SimpleString(final String string) {
int len = string.length();
data = new byte[len << 1];
int j = 0;
- for (int i = 0; i < len; i++)
- {
+ for (int i = 0; i < len; i++) {
char c = string.charAt(i);
byte low = (byte) (c & 0xFF); // low byte
@@ -99,23 +94,19 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
*
* @param data the byte array to use
*/
- public SimpleString(final byte[] data)
- {
+ public SimpleString(final byte[] data) {
this.data = data;
}
// CharSequence implementation
// ---------------------------------------------------------------------------
- public int length()
- {
+ public int length() {
return data.length >> 1;
}
- public char charAt(int pos)
- {
- if (pos < 0 || pos >= data.length >> 1)
- {
+ public char charAt(int pos) {
+ if (pos < 0 || pos >= data.length >> 1) {
throw new IndexOutOfBoundsException();
}
pos <<= 1;
@@ -123,16 +114,13 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
return (char) ((data[pos] & 0xFF) | (data[pos + 1] << 8) & 0xFF00);
}
- public CharSequence subSequence(final int start, final int end)
- {
+ public CharSequence subSequence(final int start, final int end) {
int len = data.length >> 1;
- if (end < start || start < 0 || end > len)
- {
+ if (end < start || start < 0 || end > len) {
throw new IndexOutOfBoundsException();
}
- else
- {
+ else {
int newlen = end - start << 1;
byte[] bytes = new byte[newlen];
@@ -144,8 +132,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
// Comparable implementation -------------------------------------
- public int compareTo(final SimpleString o)
- {
+ public int compareTo(final SimpleString o) {
return toString().compareTo(o.toString());
}
@@ -157,8 +144,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
*
* @return the byte array
*/
- public byte[] getData()
- {
+ public byte[] getData() {
return data;
}
@@ -168,19 +154,15 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
* @param other the SimpleString to look for
* @return true if this SimpleString starts with the same data
*/
- public boolean startsWith(final SimpleString other)
- {
+ public boolean startsWith(final SimpleString other) {
byte[] otherdata = other.data;
- if (otherdata.length > data.length)
- {
+ if (otherdata.length > data.length) {
return false;
}
- for (int i = 0; i < otherdata.length; i++)
- {
- if (data[i] != otherdata[i])
- {
+ for (int i = 0; i < otherdata.length; i++) {
+ if (data[i] != otherdata[i]) {
return false;
}
}
@@ -189,18 +171,15 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
}
@Override
- public String toString()
- {
- if (str == null)
- {
+ public String toString() {
+ if (str == null) {
int len = data.length >> 1;
char[] chars = new char[len];
int j = 0;
- for (int i = 0; i < len; i++)
- {
+ for (int i = 0; i < len; i++) {
int low = data[j++] & 0xFF;
int high = data[j++] << 8 & 0xFF00;
@@ -215,46 +194,36 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
}
@Override
- public boolean equals(final Object other)
- {
- if (this == other)
- {
+ public boolean equals(final Object other) {
+ if (this == other) {
return true;
}
- if (other instanceof SimpleString)
- {
+ if (other instanceof SimpleString) {
SimpleString s = (SimpleString) other;
- if (data.length != s.data.length)
- {
+ if (data.length != s.data.length) {
return false;
}
- for (int i = 0; i < data.length; i++)
- {
- if (data[i] != s.data[i])
- {
+ for (int i = 0; i < data.length; i++) {
+ if (data[i] != s.data[i]) {
return false;
}
}
return true;
}
- else
- {
+ else {
return false;
}
}
@Override
- public int hashCode()
- {
- if (hash == 0)
- {
+ public int hashCode() {
+ if (hash == 0) {
int tmphash = 0;
- for (byte element : data)
- {
+ for (byte element : data) {
tmphash = (tmphash << 5) - tmphash + element; // (hash << 5) - hash is same as hash * 31
}
hash = tmphash;
@@ -270,25 +239,21 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
* @param delim The delimiter to split this SimpleString on.
* @return An array of SimpleStrings
*/
- public SimpleString[] split(final char delim)
- {
+ public SimpleString[] split(final char delim) {
List all = null;
byte low = (byte) (delim & 0xFF); // low byte
byte high = (byte) (delim >> 8 & 0xFF); // high byte
int lasPos = 0;
- for (int i = 0; i < data.length; i += 2)
- {
- if (data[i] == low && data[i + 1] == high)
- {
+ for (int i = 0; i < data.length; i += 2) {
+ if (data[i] == low && data[i + 1] == high) {
byte[] bytes = new byte[i - lasPos];
System.arraycopy(data, lasPos, bytes, 0, bytes.length);
lasPos = i + 2;
// We will create the ArrayList lazily
- if (all == null)
- {
+ if (all == null) {
// There will be at least 2 strings on this case (which is the actual common usecase)
// For that reason I'm allocating the ArrayList with 2 already
// I have thought about using LinkedList here but I think this will be good enough already
@@ -299,12 +264,10 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
}
}
- if (all == null)
- {
+ if (all == null) {
return new SimpleString[]{this};
}
- else
- {
+ else {
// Adding the last one
byte[] bytes = new byte[data.length - lasPos];
System.arraycopy(data, lasPos, bytes, 0, bytes.length);
@@ -322,15 +285,12 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
* @param c the char to check for
* @return true if the char is found, false otherwise.
*/
- public boolean contains(final char c)
- {
+ public boolean contains(final char c) {
final byte low = (byte) (c & 0xFF); // low byte
final byte high = (byte) (c >> 8 & 0xFF); // high byte
- for (int i = 0; i < data.length; i += 2)
- {
- if (data[i] == low && data[i + 1] == high)
- {
+ for (int i = 0; i < data.length; i += 2) {
+ if (data[i] == low && data[i + 1] == high) {
return true;
}
}
@@ -343,8 +303,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
* @param toAdd the String to concatenate with.
* @return the concatenated SimpleString
*/
- public SimpleString concat(final String toAdd)
- {
+ public SimpleString concat(final String toAdd) {
return concat(new SimpleString(toAdd));
}
@@ -354,8 +313,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
* @param toAdd the SimpleString to concatenate with.
* @return the concatenated SimpleString
*/
- public SimpleString concat(final SimpleString toAdd)
- {
+ public SimpleString concat(final SimpleString toAdd) {
byte[] bytes = new byte[data.length + toAdd.getData().length];
System.arraycopy(data, 0, bytes, 0, data.length);
System.arraycopy(toAdd.getData(), 0, bytes, data.length, toAdd.getData().length);
@@ -368,8 +326,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
* @param c the char to concate with.
* @return the concatenated SimpleString
*/
- public SimpleString concat(final char c)
- {
+ public SimpleString concat(final char c) {
byte[] bytes = new byte[data.length + 2];
System.arraycopy(data, 0, bytes, 0, data.length);
bytes[data.length] = (byte) (c & 0xFF);
@@ -382,8 +339,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
*
* @return the size
*/
- public int sizeof()
- {
+ public int sizeof() {
return DataConstants.SIZE_INT + data.length;
}
@@ -393,8 +349,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
* @param str the SimpleString to check
* @return the size
*/
- public static int sizeofString(final SimpleString str)
- {
+ public static int sizeofString(final SimpleString str) {
return str.sizeof();
}
@@ -404,14 +359,11 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
* @param str the SimpleString to check
* @return the size
*/
- public static int sizeofNullableString(final SimpleString str)
- {
- if (str == null)
- {
+ public static int sizeofNullableString(final SimpleString str) {
+ if (str == null) {
return 1;
}
- else
- {
+ else {
return 1 + str.sizeof();
}
}
@@ -421,30 +373,25 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
* This is mainly used by the Parsers on Filters
*
* @param srcBegin The srcBegin
- * @param srcEnd The srcEnd
- * @param dst The destination array
- * @param dstPos The destination position
+ * @param srcEnd The srcEnd
+ * @param dst The destination array
+ * @param dstPos The destination position
*/
- public void getChars(final int srcBegin, final int srcEnd, final char[] dst, final int dstPos)
- {
- if (srcBegin < 0)
- {
+ public void getChars(final int srcBegin, final int srcEnd, final char[] dst, final int dstPos) {
+ if (srcBegin < 0) {
throw new StringIndexOutOfBoundsException(srcBegin);
}
- if (srcEnd > length())
- {
+ if (srcEnd > length()) {
throw new StringIndexOutOfBoundsException(srcEnd);
}
- if (srcBegin > srcEnd)
- {
+ if (srcBegin > srcEnd) {
throw new StringIndexOutOfBoundsException(srcEnd - srcBegin);
}
int j = srcBegin * 2;
int d = dstPos;
- for (int i = srcBegin; i < srcEnd; i++)
- {
+ for (int i = srcBegin; i < srcEnd; i++) {
int low = data[j++] & 0xFF;
int high = data[j++] << 8 & 0xFF00;
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java
index bb45cb70a0..51fea91a01 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java
@@ -25,16 +25,14 @@ import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.utils.DataConstants;
import org.apache.activemq.artemis.utils.UTF8Util;
-public class ChannelBufferWrapper implements ActiveMQBuffer
-{
+public class ChannelBufferWrapper implements ActiveMQBuffer {
+
protected ByteBuf buffer; // NO_UCD (use final)
private final boolean releasable;
- public static ByteBuf unwrap(ByteBuf buffer)
- {
+ public static ByteBuf unwrap(ByteBuf buffer) {
ByteBuf parent;
- while ((parent = buffer.unwrap()) != null &&
- parent != buffer) // this last part is just in case the semantic
+ while ((parent = buffer.unwrap()) != null && parent != buffer) // this last part is just in case the semantic
{ // ever changes where unwrap is returning itself
buffer = parent;
}
@@ -42,591 +40,473 @@ public class ChannelBufferWrapper implements ActiveMQBuffer
return buffer;
}
- public ChannelBufferWrapper(final ByteBuf buffer)
- {
+ public ChannelBufferWrapper(final ByteBuf buffer) {
this(buffer, false);
}
- public ChannelBufferWrapper(final ByteBuf buffer, boolean releasable)
- {
- if (!releasable)
- {
+ public ChannelBufferWrapper(final ByteBuf buffer, boolean releasable) {
+ if (!releasable) {
this.buffer = Unpooled.unreleasableBuffer(buffer);
}
- else
- {
+ else {
this.buffer = buffer;
}
this.releasable = releasable;
}
- public boolean readBoolean()
- {
+ public boolean readBoolean() {
return readByte() != 0;
}
- public SimpleString readNullableSimpleString()
- {
+ public SimpleString readNullableSimpleString() {
int b = buffer.readByte();
- if (b == DataConstants.NULL)
- {
+ if (b == DataConstants.NULL) {
return null;
}
return readSimpleStringInternal();
}
- public String readNullableString()
- {
+ public String readNullableString() {
int b = buffer.readByte();
- if (b == DataConstants.NULL)
- {
+ if (b == DataConstants.NULL) {
return null;
}
return readStringInternal();
}
- public SimpleString readSimpleString()
- {
+ public SimpleString readSimpleString() {
return readSimpleStringInternal();
}
- private SimpleString readSimpleStringInternal()
- {
+ private SimpleString readSimpleStringInternal() {
int len = buffer.readInt();
byte[] data = new byte[len];
buffer.readBytes(data);
return new SimpleString(data);
}
- public String readString()
- {
+ public String readString() {
return readStringInternal();
}
- private String readStringInternal()
- {
+ private String readStringInternal() {
int len = buffer.readInt();
- if (len < 9)
- {
+ if (len < 9) {
char[] chars = new char[len];
- for (int i = 0; i < len; i++)
- {
- chars[i] = (char)buffer.readShort();
+ for (int i = 0; i < len; i++) {
+ chars[i] = (char) buffer.readShort();
}
return new String(chars);
}
- else if (len < 0xfff)
- {
+ else if (len < 0xfff) {
return readUTF();
}
- else
- {
+ else {
return readSimpleStringInternal().toString();
}
}
- public String readUTF()
- {
+ public String readUTF() {
return UTF8Util.readUTF(this);
}
- public void writeBoolean(final boolean val)
- {
- buffer.writeByte((byte)(val ? -1 : 0));
+ public void writeBoolean(final boolean val) {
+ buffer.writeByte((byte) (val ? -1 : 0));
}
- public void writeNullableSimpleString(final SimpleString val)
- {
- if (val == null)
- {
+ public void writeNullableSimpleString(final SimpleString val) {
+ if (val == null) {
buffer.writeByte(DataConstants.NULL);
}
- else
- {
+ else {
buffer.writeByte(DataConstants.NOT_NULL);
writeSimpleStringInternal(val);
}
}
- public void writeNullableString(final String val)
- {
- if (val == null)
- {
+ public void writeNullableString(final String val) {
+ if (val == null) {
buffer.writeByte(DataConstants.NULL);
}
- else
- {
+ else {
buffer.writeByte(DataConstants.NOT_NULL);
writeStringInternal(val);
}
}
- public void writeSimpleString(final SimpleString val)
- {
+ public void writeSimpleString(final SimpleString val) {
writeSimpleStringInternal(val);
}
- private void writeSimpleStringInternal(final SimpleString val)
- {
+ private void writeSimpleStringInternal(final SimpleString val) {
byte[] data = val.getData();
buffer.writeInt(data.length);
buffer.writeBytes(data);
}
- public void writeString(final String val)
- {
+ public void writeString(final String val) {
writeStringInternal(val);
}
- private void writeStringInternal(final String val)
- {
+ private void writeStringInternal(final String val) {
int length = val.length();
buffer.writeInt(length);
- if (length < 9)
- {
+ if (length < 9) {
// If very small it's more performant to store char by char
- for (int i = 0; i < val.length(); i++)
- {
- buffer.writeShort((short)val.charAt(i));
+ for (int i = 0; i < val.length(); i++) {
+ buffer.writeShort((short) val.charAt(i));
}
}
- else if (length < 0xfff)
- {
+ else if (length < 0xfff) {
// Store as UTF - this is quicker than char by char for most strings
writeUTF(val);
}
- else
- {
+ else {
// Store as SimpleString, since can't store utf > 0xffff in length
writeSimpleStringInternal(new SimpleString(val));
}
}
- public void writeUTF(final String utf)
- {
+ public void writeUTF(final String utf) {
UTF8Util.saveUTF(this, utf);
}
- public int capacity()
- {
+ public int capacity() {
return buffer.capacity();
}
- public ByteBuf byteBuf()
- {
+ public ByteBuf byteBuf() {
return buffer;
}
- public void clear()
- {
+ public void clear() {
buffer.clear();
}
- public ActiveMQBuffer copy()
- {
+ public ActiveMQBuffer copy() {
return new ChannelBufferWrapper(buffer.copy(), releasable);
}
- public ActiveMQBuffer copy(final int index, final int length)
- {
+ public ActiveMQBuffer copy(final int index, final int length) {
return new ChannelBufferWrapper(buffer.copy(index, length), releasable);
}
- public void discardReadBytes()
- {
+ public void discardReadBytes() {
buffer.discardReadBytes();
}
- public ActiveMQBuffer duplicate()
- {
+ public ActiveMQBuffer duplicate() {
return new ChannelBufferWrapper(buffer.duplicate(), releasable);
}
- public byte getByte(final int index)
- {
+ public byte getByte(final int index) {
return buffer.getByte(index);
}
- public void getBytes(final int index, final byte[] dst, final int dstIndex, final int length)
- {
+ public void getBytes(final int index, final byte[] dst, final int dstIndex, final int length) {
buffer.getBytes(index, dst, dstIndex, length);
}
- public void getBytes(final int index, final byte[] dst)
- {
+ public void getBytes(final int index, final byte[] dst) {
buffer.getBytes(index, dst);
}
- public void getBytes(final int index, final ByteBuffer dst)
- {
+ public void getBytes(final int index, final ByteBuffer dst) {
buffer.getBytes(index, dst);
}
- public void getBytes(final int index, final ActiveMQBuffer dst, final int dstIndex, final int length)
- {
+ public void getBytes(final int index, final ActiveMQBuffer dst, final int dstIndex, final int length) {
buffer.getBytes(index, dst.byteBuf(), dstIndex, length);
}
- public void getBytes(final int index, final ActiveMQBuffer dst, final int length)
- {
+ public void getBytes(final int index, final ActiveMQBuffer dst, final int length) {
buffer.getBytes(index, dst.byteBuf(), length);
}
- public void getBytes(final int index, final ActiveMQBuffer dst)
- {
+ public void getBytes(final int index, final ActiveMQBuffer dst) {
buffer.getBytes(index, dst.byteBuf());
}
- public char getChar(final int index)
- {
- return (char)buffer.getShort(index);
+ public char getChar(final int index) {
+ return (char) buffer.getShort(index);
}
- public double getDouble(final int index)
- {
+ public double getDouble(final int index) {
return Double.longBitsToDouble(buffer.getLong(index));
}
- public float getFloat(final int index)
- {
+ public float getFloat(final int index) {
return Float.intBitsToFloat(buffer.getInt(index));
}
- public int getInt(final int index)
- {
+ public int getInt(final int index) {
return buffer.getInt(index);
}
- public long getLong(final int index)
- {
+ public long getLong(final int index) {
return buffer.getLong(index);
}
- public short getShort(final int index)
- {
+ public short getShort(final int index) {
return buffer.getShort(index);
}
- public short getUnsignedByte(final int index)
- {
+ public short getUnsignedByte(final int index) {
return buffer.getUnsignedByte(index);
}
- public long getUnsignedInt(final int index)
- {
+ public long getUnsignedInt(final int index) {
return buffer.getUnsignedInt(index);
}
- public int getUnsignedShort(final int index)
- {
+ public int getUnsignedShort(final int index) {
return buffer.getUnsignedShort(index);
}
- public void markReaderIndex()
- {
+ public void markReaderIndex() {
buffer.markReaderIndex();
}
- public void markWriterIndex()
- {
+ public void markWriterIndex() {
buffer.markWriterIndex();
}
- public boolean readable()
- {
+ public boolean readable() {
return buffer.isReadable();
}
- public int readableBytes()
- {
+ public int readableBytes() {
return buffer.readableBytes();
}
- public byte readByte()
- {
+ public byte readByte() {
return buffer.readByte();
}
- public void readBytes(final byte[] dst, final int dstIndex, final int length)
- {
+ public void readBytes(final byte[] dst, final int dstIndex, final int length) {
buffer.readBytes(dst, dstIndex, length);
}
- public void readBytes(final byte[] dst)
- {
+ public void readBytes(final byte[] dst) {
buffer.readBytes(dst);
}
- public void readBytes(final ByteBuffer dst)
- {
+ public void readBytes(final ByteBuffer dst) {
buffer.readBytes(dst);
}
- public void readBytes(final ActiveMQBuffer dst, final int dstIndex, final int length)
- {
+ public void readBytes(final ActiveMQBuffer dst, final int dstIndex, final int length) {
buffer.readBytes(dst.byteBuf(), dstIndex, length);
}
- public void readBytes(final ActiveMQBuffer dst, final int length)
- {
+ public void readBytes(final ActiveMQBuffer dst, final int length) {
buffer.readBytes(dst.byteBuf(), length);
}
- public void readBytes(final ActiveMQBuffer dst)
- {
+ public void readBytes(final ActiveMQBuffer dst) {
buffer.readBytes(dst.byteBuf());
}
- public ActiveMQBuffer readBytes(final int length)
- {
+ public ActiveMQBuffer readBytes(final int length) {
return new ChannelBufferWrapper(buffer.readBytes(length), releasable);
}
- public char readChar()
- {
- return (char)buffer.readShort();
+ public char readChar() {
+ return (char) buffer.readShort();
}
- public double readDouble()
- {
+ public double readDouble() {
return Double.longBitsToDouble(buffer.readLong());
}
- public int readerIndex()
- {
+ public int readerIndex() {
return buffer.readerIndex();
}
- public void readerIndex(final int readerIndex)
- {
+ public void readerIndex(final int readerIndex) {
buffer.readerIndex(readerIndex);
}
- public float readFloat()
- {
+ public float readFloat() {
return Float.intBitsToFloat(buffer.readInt());
}
- public int readInt()
- {
+ public int readInt() {
return buffer.readInt();
}
- public long readLong()
- {
+ public long readLong() {
return buffer.readLong();
}
- public short readShort()
- {
+ public short readShort() {
return buffer.readShort();
}
- public ActiveMQBuffer readSlice(final int length)
- {
+ public ActiveMQBuffer readSlice(final int length) {
return new ChannelBufferWrapper(buffer.readSlice(length), releasable);
}
- public short readUnsignedByte()
- {
+ public short readUnsignedByte() {
return buffer.readUnsignedByte();
}
- public long readUnsignedInt()
- {
+ public long readUnsignedInt() {
return buffer.readUnsignedInt();
}
- public int readUnsignedShort()
- {
+ public int readUnsignedShort() {
return buffer.readUnsignedShort();
}
- public void resetReaderIndex()
- {
+ public void resetReaderIndex() {
buffer.resetReaderIndex();
}
- public void resetWriterIndex()
- {
+ public void resetWriterIndex() {
buffer.resetWriterIndex();
}
- public void setByte(final int index, final byte value)
- {
+ public void setByte(final int index, final byte value) {
buffer.setByte(index, value);
}
- public void setBytes(final int index, final byte[] src, final int srcIndex, final int length)
- {
+ public void setBytes(final int index, final byte[] src, final int srcIndex, final int length) {
buffer.setBytes(index, src, srcIndex, length);
}
- public void setBytes(final int index, final byte[] src)
- {
+ public void setBytes(final int index, final byte[] src) {
buffer.setBytes(index, src);
}
- public void setBytes(final int index, final ByteBuffer src)
- {
+ public void setBytes(final int index, final ByteBuffer src) {
buffer.setBytes(index, src);
}
- public void setBytes(final int index, final ActiveMQBuffer src, final int srcIndex, final int length)
- {
+ public void setBytes(final int index, final ActiveMQBuffer src, final int srcIndex, final int length) {
buffer.setBytes(index, src.byteBuf(), srcIndex, length);
}
- public void setBytes(final int index, final ActiveMQBuffer src, final int length)
- {
+ public void setBytes(final int index, final ActiveMQBuffer src, final int length) {
buffer.setBytes(index, src.byteBuf(), length);
}
- public void setBytes(final int index, final ActiveMQBuffer src)
- {
+ public void setBytes(final int index, final ActiveMQBuffer src) {
buffer.setBytes(index, src.byteBuf());
}
- public void setChar(final int index, final char value)
- {
- buffer.setShort(index, (short)value);
+ public void setChar(final int index, final char value) {
+ buffer.setShort(index, (short) value);
}
- public void setDouble(final int index, final double value)
- {
+ public void setDouble(final int index, final double value) {
buffer.setLong(index, Double.doubleToLongBits(value));
}
- public void setFloat(final int index, final float value)
- {
+ public void setFloat(final int index, final float value) {
buffer.setInt(index, Float.floatToIntBits(value));
}
- public void setIndex(final int readerIndex, final int writerIndex)
- {
+ public void setIndex(final int readerIndex, final int writerIndex) {
buffer.setIndex(readerIndex, writerIndex);
}
- public void setInt(final int index, final int value)
- {
+ public void setInt(final int index, final int value) {
buffer.setInt(index, value);
}
- public void setLong(final int index, final long value)
- {
+ public void setLong(final int index, final long value) {
buffer.setLong(index, value);
}
- public void setShort(final int index, final short value)
- {
+ public void setShort(final int index, final short value) {
buffer.setShort(index, value);
}
- public void skipBytes(final int length)
- {
+ public void skipBytes(final int length) {
buffer.skipBytes(length);
}
- public ActiveMQBuffer slice()
- {
+ public ActiveMQBuffer slice() {
return new ChannelBufferWrapper(buffer.slice(), releasable);
}
- public ActiveMQBuffer slice(final int index, final int length)
- {
+ public ActiveMQBuffer slice(final int index, final int length) {
return new ChannelBufferWrapper(buffer.slice(index, length), releasable);
}
- public ByteBuffer toByteBuffer()
- {
+ public ByteBuffer toByteBuffer() {
return buffer.nioBuffer();
}
- public ByteBuffer toByteBuffer(final int index, final int length)
- {
+ public ByteBuffer toByteBuffer(final int index, final int length) {
return buffer.nioBuffer(index, length);
}
- public boolean writable()
- {
+ public boolean writable() {
return buffer.isWritable();
}
- public int writableBytes()
- {
+ public int writableBytes() {
return buffer.writableBytes();
}
- public void writeByte(final byte value)
- {
+ public void writeByte(final byte value) {
buffer.writeByte(value);
}
- public void writeBytes(final byte[] src, final int srcIndex, final int length)
- {
+ public void writeBytes(final byte[] src, final int srcIndex, final int length) {
buffer.writeBytes(src, srcIndex, length);
}
- public void writeBytes(final byte[] src)
- {
+ public void writeBytes(final byte[] src) {
buffer.writeBytes(src);
}
- public void writeBytes(final ByteBuffer src)
- {
+ public void writeBytes(final ByteBuffer src) {
buffer.writeBytes(src);
}
- public void writeBytes(final ActiveMQBuffer src, final int srcIndex, final int length)
- {
+ public void writeBytes(final ActiveMQBuffer src, final int srcIndex, final int length) {
buffer.writeBytes(src.byteBuf(), srcIndex, length);
}
- public void writeBytes(final ActiveMQBuffer src, final int length)
- {
+ public void writeBytes(final ActiveMQBuffer src, final int length) {
buffer.writeBytes(src.byteBuf(), length);
}
- public void writeChar(final char chr)
- {
- buffer.writeShort((short)chr);
+ public void writeChar(final char chr) {
+ buffer.writeShort((short) chr);
}
- public void writeDouble(final double value)
- {
+ public void writeDouble(final double value) {
buffer.writeLong(Double.doubleToLongBits(value));
}
- public void writeFloat(final float value)
- {
+ public void writeFloat(final float value) {
buffer.writeInt(Float.floatToIntBits(value));
}
- public void writeInt(final int value)
- {
+ public void writeInt(final int value) {
buffer.writeInt(value);
}
- public void writeLong(final long value)
- {
+ public void writeLong(final long value) {
buffer.writeLong(value);
}
- public int writerIndex()
- {
+ public int writerIndex() {
return buffer.writerIndex();
}
- public void writerIndex(final int writerIndex)
- {
+ public void writerIndex(final int writerIndex) {
buffer.writerIndex(writerIndex);
}
- public void writeShort(final short value)
- {
+ public void writeShort(final short value) {
buffer.writeShort(value);
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQComponent.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQComponent.java
index a8428281cc..60dacdcc2d 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQComponent.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQComponent.java
@@ -16,8 +16,8 @@
*/
package org.apache.activemq.artemis.core.server;
-public interface ActiveMQComponent
-{
+public interface ActiveMQComponent {
+
void start() throws Exception;
void stop() throws Exception;
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java
index ae77c5c71a..664470a071 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilBundle.java
@@ -16,7 +16,6 @@
*/
package org.apache.activemq.artemis.logs;
-
import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException;
import org.jboss.logging.annotations.Cause;
import org.jboss.logging.annotations.Message;
@@ -31,11 +30,11 @@ import org.jboss.logging.Messages;
* so 209000 to 209999
*/
@MessageBundle(projectCode = "AMQ")
-public interface ActiveMQUtilBundle
-{
+public interface ActiveMQUtilBundle {
+
ActiveMQUtilBundle BUNDLE = Messages.getBundle(ActiveMQUtilBundle.class);
- @Message(id = 209000, value = "invalid property: {0}" , format = Message.Format.MESSAGE_FORMAT)
+ @Message(id = 209000, value = "invalid property: {0}", format = Message.Format.MESSAGE_FORMAT)
ActiveMQIllegalStateException invalidProperty(String part);
@Message(id = 209001, value = "Invalid type: {0}", format = Message.Format.MESSAGE_FORMAT)
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilLogger.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilLogger.java
index 6d01c5a8a6..b26d30dc26 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilLogger.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilLogger.java
@@ -37,8 +37,8 @@ import org.jboss.logging.annotations.MessageLogger;
* so an INFO message would be 201000 to 201999
*/
@MessageLogger(projectCode = "AMQ")
-public interface ActiveMQUtilLogger extends BasicLogger
-{
+public interface ActiveMQUtilLogger extends BasicLogger {
+
/**
* The default logger.
*/
@@ -46,6 +46,6 @@ public interface ActiveMQUtilLogger extends BasicLogger
@LogMessage(level = Logger.Level.WARN)
@Message(id = 202000, value = "Missing privileges to set Thread Context Class Loader on Thread Factory. Using current Thread Context Class Loader",
- format = Message.Format.MESSAGE_FORMAT)
+ format = Message.Format.MESSAGE_FORMAT)
void missingPrivsForClassloader();
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AssertionLoggerHandler.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AssertionLoggerHandler.java
index b366b61f03..e0c1215dba 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AssertionLoggerHandler.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AssertionLoggerHandler.java
@@ -29,8 +29,7 @@ import org.jboss.logmanager.ExtLogRecord;
*
* Be careful with this use as this is intended for testing only (such as testcases)
*/
-public class AssertionLoggerHandler extends ExtHandler
-{
+public class AssertionLoggerHandler extends ExtHandler {
private static final Map messages = new ConcurrentHashMap<>();
private static boolean capture = false;
@@ -39,40 +38,32 @@ public class AssertionLoggerHandler extends ExtHandler
* {@inheritDoc}
*/
@Override
- public void flush()
- {
+ public void flush() {
}
/**
* {@inheritDoc}
*/
@Override
- public void close() throws SecurityException
- {
+ public void close() throws SecurityException {
}
@Override
- protected void doPublish(final ExtLogRecord record)
- {
- if (capture)
- {
+ protected void doPublish(final ExtLogRecord record) {
+ if (capture) {
messages.put(record.getFormattedMessage(), record);
}
}
-
/**
* is there any record matching Level?
*
* @param level
* @return
*/
- public static boolean hasLevel(Level level)
- {
- for (ExtLogRecord record : messages.values())
- {
- if (record.getLevel().equals(level))
- {
+ public static boolean hasLevel(Level level) {
+ for (ExtLogRecord record : messages.values()) {
+ if (record.getLevel().equals(level)) {
return true;
}
}
@@ -86,37 +77,29 @@ public class AssertionLoggerHandler extends ExtHandler
* @param text
* @return
*/
- public static boolean findText(final String... text)
- {
- for (Map.Entry entry : messages.entrySet())
- {
+ public static boolean findText(final String... text) {
+ for (Map.Entry entry : messages.entrySet()) {
String key = entry.getKey();
boolean found = true;
- for (String txtCheck : text)
- {
+ for (String txtCheck : text) {
found = key.contains(txtCheck);
- if (!found)
- {
+ if (!found) {
// If the main log message doesn't contain what we're looking for let's look in the message from the exception (if there is one).
Throwable throwable = entry.getValue().getThrown();
- if (throwable != null && throwable.getMessage() != null)
- {
+ if (throwable != null && throwable.getMessage() != null) {
found = throwable.getMessage().contains(txtCheck);
- if (!found)
- {
+ if (!found) {
break;
}
}
- else
- {
+ else {
break;
}
}
}
- if (found)
- {
+ if (found) {
return true;
}
}
@@ -124,19 +107,16 @@ public class AssertionLoggerHandler extends ExtHandler
return false;
}
- public static final void clear()
- {
+ public static final void clear() {
messages.clear();
}
- public static final void startCapture()
- {
+ public static final void startCapture() {
clear();
capture = true;
}
- public static final void stopCapture()
- {
+ public static final void stopCapture() {
capture = false;
clear();
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java
index 00d2a731bd..3c59f34b89 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java
@@ -22,8 +22,8 @@ import java.security.PrivilegedAction;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
-public final class ActiveMQThreadFactory implements ThreadFactory
-{
+public final class ActiveMQThreadFactory implements ThreadFactory {
+
private final ThreadGroup group;
private final AtomicInteger threadCount = new AtomicInteger(0);
@@ -36,8 +36,7 @@ public final class ActiveMQThreadFactory implements ThreadFactory
private final AccessControlContext acc;
- public ActiveMQThreadFactory(final String groupName, final boolean daemon, final ClassLoader tccl)
- {
+ public ActiveMQThreadFactory(final String groupName, final boolean daemon, final ClassLoader tccl) {
group = new ThreadGroup(groupName + "-" + System.identityHashCode(this));
this.threadPriority = Thread.NORM_PRIORITY;
@@ -49,36 +48,30 @@ public final class ActiveMQThreadFactory implements ThreadFactory
this.acc = (System.getSecurityManager() == null) ? null : AccessController.getContext();
}
- public Thread newThread(final Runnable command)
- {
+ public Thread newThread(final Runnable command) {
// create a thread in a privileged block if running with Security Manager
- if (acc != null && System.getSecurityManager() != null)
- {
+ if (acc != null && System.getSecurityManager() != null) {
return AccessController.doPrivileged(new ThreadCreateAction(command), acc);
}
- else
- {
+ else {
return createThread(command);
}
}
- private final class ThreadCreateAction implements PrivilegedAction
- {
+ private final class ThreadCreateAction implements PrivilegedAction {
+
private final Runnable target;
- private ThreadCreateAction(final Runnable target)
- {
+ private ThreadCreateAction(final Runnable target) {
this.target = target;
}
- public Thread run()
- {
+ public Thread run() {
return createThread(target);
}
}
- private Thread createThread(final Runnable command)
- {
+ private Thread createThread(final Runnable command) {
final Thread t = new Thread(group, command, "Thread-" + threadCount.getAndIncrement() + " (" + group.getName() + ")");
t.setDaemon(daemon);
t.setPriority(threadPriority);
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Base64.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Base64.java
index 9d2481a371..5284246cdb 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Base64.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Base64.java
@@ -88,8 +88,7 @@ import java.nio.charset.StandardCharsets;
* periodically to check for updates or to contribute improvements.
*
*/
-public class Base64
-{
+public class Base64 {
/* ******** P U B L I C F I E L D S ******** */
@@ -169,203 +168,33 @@ public class Base64
*/
// private final static byte[] ALPHABET;
/* Host platform me be something funny like EBCDIC, so we hardcode these values. */
- private static final byte[] _STANDARD_ALPHABET = {(byte) 'A',
- (byte) 'B',
- (byte) 'C',
- (byte) 'D',
- (byte) 'E',
- (byte) 'F',
- (byte) 'G',
- (byte) 'H',
- (byte) 'I',
- (byte) 'J',
- (byte) 'K',
- (byte) 'L',
- (byte) 'M',
- (byte) 'N',
- (byte) 'O',
- (byte) 'P',
- (byte) 'Q',
- (byte) 'R',
- (byte) 'S',
- (byte) 'T',
- (byte) 'U',
- (byte) 'V',
- (byte) 'W',
- (byte) 'X',
- (byte) 'Y',
- (byte) 'Z',
- (byte) 'a',
- (byte) 'b',
- (byte) 'c',
- (byte) 'd',
- (byte) 'e',
- (byte) 'f',
- (byte) 'g',
- (byte) 'h',
- (byte) 'i',
- (byte) 'j',
- (byte) 'k',
- (byte) 'l',
- (byte) 'm',
- (byte) 'n',
- (byte) 'o',
- (byte) 'p',
- (byte) 'q',
- (byte) 'r',
- (byte) 's',
- (byte) 't',
- (byte) 'u',
- (byte) 'v',
- (byte) 'w',
- (byte) 'x',
- (byte) 'y',
- (byte) 'z',
- (byte) '0',
- (byte) '1',
- (byte) '2',
- (byte) '3',
- (byte) '4',
- (byte) '5',
- (byte) '6',
- (byte) '7',
- (byte) '8',
- (byte) '9',
- (byte) '+',
- (byte) '/'};
+ private static final byte[] _STANDARD_ALPHABET = {(byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G', (byte) 'H', (byte) 'I', (byte) 'J', (byte) 'K', (byte) 'L', (byte) 'M', (byte) 'N', (byte) 'O', (byte) 'P', (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T', (byte) 'U', (byte) 'V', (byte) 'W', (byte) 'X', (byte) 'Y', (byte) 'Z', (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd', (byte) 'e', (byte) 'f', (byte) 'g', (byte) 'h', (byte) 'i', (byte) 'j', (byte) 'k', (byte) 'l', (byte) 'm', (byte) 'n', (byte) 'o', (byte) 'p', (byte) 'q', (byte) 'r', (byte) 's', (byte) 't', (byte) 'u', (byte) 'v', (byte) 'w', (byte) 'x', (byte) 'y', (byte) 'z', (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4', (byte) '5', (byte) '6', (byte) '7', (byte) '8', (byte) '9', (byte) '+', (byte) '/'};
/**
* Translates a Base64 value to either its 6-bit reconstruction value
* or a negative number indicating some other meaning.
*/
- private static final byte[] _STANDARD_DECODABET = {
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9, // Decimal 0 - 8
- -5,
- -5, // Whitespace: Tab and Linefeed
- -9,
- -9, // Decimal 11 - 12
+ private static final byte[] _STANDARD_DECODABET = {-9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 0 - 8
+ -5, -5, // Whitespace: Tab and Linefeed
+ -9, -9, // Decimal 11 - 12
-5, // Whitespace: Carriage Return
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9, // Decimal 14 - 26
- -9,
- -9,
- -9,
- -9,
- -9, // Decimal 27 - 31
+ -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 14 - 26
+ -9, -9, -9, -9, -9, // Decimal 27 - 31
-5, // Whitespace: Space
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9, // Decimal 33 - 42
+ -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 33 - 42
62, // Plus sign at decimal 43
- -9,
- -9,
- -9, // Decimal 44 - 46
+ -9, -9, -9, // Decimal 44 - 46
63, // Slash at decimal 47
- 52,
- 53,
- 54,
- 55,
- 56,
- 57,
- 58,
- 59,
- 60,
- 61, // Numbers zero through nine
- -9,
- -9,
- -9, // Decimal 58 - 60
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, // Numbers zero through nine
+ -9, -9, -9, // Decimal 58 - 60
-1, // Equals sign at decimal 61
- -9,
- -9,
- -9, // Decimal 62 - 64
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9,
- 10,
- 11,
- 12,
- 13, // Letters 'A' through 'N'
- 14,
- 15,
- 16,
- 17,
- 18,
- 19,
- 20,
- 21,
- 22,
- 23,
- 24,
- 25, // Letters 'O' through 'Z'
- -9,
- -9,
- -9,
- -9,
- -9,
- -9, // Decimal 91 - 96
- 26,
- 27,
- 28,
- 29,
- 30,
- 31,
- 32,
- 33,
- 34,
- 35,
- 36,
- 37,
- 38, // Letters 'a' through 'm'
- 39,
- 40,
- 41,
- 42,
- 43,
- 44,
- 45,
- 46,
- 47,
- 48,
- 49,
- 50,
- 51, // Letters 'n' through 'z'
- -9,
- -9,
- -9,
- -9 // Decimal 123 - 126
+ -9, -9, -9, // Decimal 62 - 64
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, // Letters 'A' through 'N'
+ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // Letters 'O' through 'Z'
+ -9, -9, -9, -9, -9, -9, // Decimal 91 - 96
+ 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // Letters 'a' through 'm'
+ 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, // Letters 'n' through 'z'
+ -9, -9, -9, -9 // Decimal 123 - 126
/*,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 127 - 139
-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 140 - 152
-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 153 - 165
@@ -375,8 +204,7 @@ public class Base64
-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 205 - 217
-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 218 - 230
-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 231 - 243
- -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9 // Decimal 244 - 255 */
- };
+ -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9 // Decimal 244 - 255 */};
/* ******** U R L S A F E B A S E 6 4 A L P H A B E T ******** */
@@ -385,203 +213,36 @@ public class Base64
* http://www.faqs.org/rfcs/rfc3548.html.
* Notice that the last two bytes become "hyphen" and "underscore" instead of "plus" and "slash."
*/
- private static final byte[] _URL_SAFE_ALPHABET = {
- (byte) 'A',
- (byte) 'B',
- (byte) 'C',
- (byte) 'D',
- (byte) 'E',
- (byte) 'F',
- (byte) 'G',
- (byte) 'H',
- (byte) 'I',
- (byte) 'J',
- (byte) 'K',
- (byte) 'L',
- (byte) 'M',
- (byte) 'N',
- (byte) 'O',
- (byte) 'P',
- (byte) 'Q',
- (byte) 'R',
- (byte) 'S',
- (byte) 'T',
- (byte) 'U',
- (byte) 'V',
- (byte) 'W',
- (byte) 'X',
- (byte) 'Y',
- (byte) 'Z',
- (byte) 'a',
- (byte) 'b',
- (byte) 'c',
- (byte) 'd',
- (byte) 'e',
- (byte) 'f',
- (byte) 'g',
- (byte) 'h',
- (byte) 'i',
- (byte) 'j',
- (byte) 'k',
- (byte) 'l',
- (byte) 'm',
- (byte) 'n',
- (byte) 'o',
- (byte) 'p',
- (byte) 'q',
- (byte) 'r',
- (byte) 's',
- (byte) 't',
- (byte) 'u',
- (byte) 'v',
- (byte) 'w',
- (byte) 'x',
- (byte) 'y',
- (byte) 'z',
- (byte) '0',
- (byte) '1',
- (byte) '2',
- (byte) '3',
- (byte) '4',
- (byte) '5',
- (byte) '6',
- (byte) '7',
- (byte) '8',
- (byte) '9',
- (byte) '-',
- (byte) '_'};
+ private static final byte[] _URL_SAFE_ALPHABET = {(byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G', (byte) 'H', (byte) 'I', (byte) 'J', (byte) 'K', (byte) 'L', (byte) 'M', (byte) 'N', (byte) 'O', (byte) 'P', (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T', (byte) 'U', (byte) 'V', (byte) 'W', (byte) 'X', (byte) 'Y', (byte) 'Z', (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd', (byte) 'e', (byte) 'f', (byte) 'g', (byte) 'h', (byte) 'i', (byte) 'j', (byte) 'k', (byte) 'l', (byte) 'm', (byte) 'n', (byte) 'o', (byte) 'p', (byte) 'q', (byte) 'r', (byte) 's', (byte) 't', (byte) 'u', (byte) 'v', (byte) 'w', (byte) 'x', (byte) 'y', (byte) 'z', (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4', (byte) '5', (byte) '6', (byte) '7', (byte) '8', (byte) '9', (byte) '-', (byte) '_'};
/**
* Used in decoding URL- and Filename-safe dialects of Base64.
*/
- private static final byte[] _URL_SAFE_DECODABET = {
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9, // Decimal 0 - 8
- -5,
- -5, // Whitespace: Tab and Linefeed
- -9,
- -9, // Decimal 11 - 12
+ private static final byte[] _URL_SAFE_DECODABET = {-9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 0 - 8
+ -5, -5, // Whitespace: Tab and Linefeed
+ -9, -9, // Decimal 11 - 12
-5, // Whitespace: Carriage Return
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9, // Decimal 14 - 26
- -9,
- -9,
- -9,
- -9,
- -9, // Decimal 27 - 31
+ -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 14 - 26
+ -9, -9, -9, -9, -9, // Decimal 27 - 31
-5, // Whitespace: Space
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9, // Decimal 33 - 42
+ -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 33 - 42
-9, // Plus sign at decimal 43
-9, // Decimal 44
62, // Minus sign at decimal 45
-9, // Decimal 46
-9, // Slash at decimal 47
- 52,
- 53,
- 54,
- 55,
- 56,
- 57,
- 58,
- 59,
- 60,
- 61, // Numbers zero through nine
- -9,
- -9,
- -9, // Decimal 58 - 60
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, // Numbers zero through nine
+ -9, -9, -9, // Decimal 58 - 60
-1, // Equals sign at decimal 61
- -9,
- -9,
- -9, // Decimal 62 - 64
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9,
- 10,
- 11,
- 12,
- 13, // Letters 'A' through 'N'
- 14,
- 15,
- 16,
- 17,
- 18,
- 19,
- 20,
- 21,
- 22,
- 23,
- 24,
- 25, // Letters 'O' through 'Z'
- -9,
- -9,
- -9,
- -9, // Decimal 91 - 94
+ -9, -9, -9, // Decimal 62 - 64
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, // Letters 'A' through 'N'
+ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // Letters 'O' through 'Z'
+ -9, -9, -9, -9, // Decimal 91 - 94
63, // Underscore at decimal 95
-9, // Decimal 96
- 26,
- 27,
- 28,
- 29,
- 30,
- 31,
- 32,
- 33,
- 34,
- 35,
- 36,
- 37,
- 38, // Letters 'a' through 'm'
- 39,
- 40,
- 41,
- 42,
- 43,
- 44,
- 45,
- 46,
- 47,
- 48,
- 49,
- 50,
- 51, // Letters 'n' through 'z'
- -9,
- -9,
- -9,
- -9 // Decimal 123 - 126
+ 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // Letters 'a' through 'm'
+ 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, // Letters 'n' through 'z'
+ -9, -9, -9, -9 // Decimal 123 - 126
/*,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 127 - 139
-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 140 - 152
-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 153 - 165
@@ -591,8 +252,7 @@ public class Base64
-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 205 - 217
-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 218 - 230
-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 231 - 243
- -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9 // Decimal 244 - 255 */
- };
+ -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9 // Decimal 244 - 255 */};
/* ******** O R D E R E D B A S E 6 4 A L P H A B E T ******** */
@@ -600,203 +260,36 @@ public class Base64
* I don't get the point of this technique, but it is described here:
* http://www.faqs.org/qa/rfcc-1940.html.
*/
- private static final byte[] _ORDERED_ALPHABET = {
- (byte) '-',
- (byte) '0',
- (byte) '1',
- (byte) '2',
- (byte) '3',
- (byte) '4',
- (byte) '5',
- (byte) '6',
- (byte) '7',
- (byte) '8',
- (byte) '9',
- (byte) 'A',
- (byte) 'B',
- (byte) 'C',
- (byte) 'D',
- (byte) 'E',
- (byte) 'F',
- (byte) 'G',
- (byte) 'H',
- (byte) 'I',
- (byte) 'J',
- (byte) 'K',
- (byte) 'L',
- (byte) 'M',
- (byte) 'N',
- (byte) 'O',
- (byte) 'P',
- (byte) 'Q',
- (byte) 'R',
- (byte) 'S',
- (byte) 'T',
- (byte) 'U',
- (byte) 'V',
- (byte) 'W',
- (byte) 'X',
- (byte) 'Y',
- (byte) 'Z',
- (byte) '_',
- (byte) 'a',
- (byte) 'b',
- (byte) 'c',
- (byte) 'd',
- (byte) 'e',
- (byte) 'f',
- (byte) 'g',
- (byte) 'h',
- (byte) 'i',
- (byte) 'j',
- (byte) 'k',
- (byte) 'l',
- (byte) 'm',
- (byte) 'n',
- (byte) 'o',
- (byte) 'p',
- (byte) 'q',
- (byte) 'r',
- (byte) 's',
- (byte) 't',
- (byte) 'u',
- (byte) 'v',
- (byte) 'w',
- (byte) 'x',
- (byte) 'y',
- (byte) 'z'};
+ private static final byte[] _ORDERED_ALPHABET = {(byte) '-', (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4', (byte) '5', (byte) '6', (byte) '7', (byte) '8', (byte) '9', (byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G', (byte) 'H', (byte) 'I', (byte) 'J', (byte) 'K', (byte) 'L', (byte) 'M', (byte) 'N', (byte) 'O', (byte) 'P', (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T', (byte) 'U', (byte) 'V', (byte) 'W', (byte) 'X', (byte) 'Y', (byte) 'Z', (byte) '_', (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd', (byte) 'e', (byte) 'f', (byte) 'g', (byte) 'h', (byte) 'i', (byte) 'j', (byte) 'k', (byte) 'l', (byte) 'm', (byte) 'n', (byte) 'o', (byte) 'p', (byte) 'q', (byte) 'r', (byte) 's', (byte) 't', (byte) 'u', (byte) 'v', (byte) 'w', (byte) 'x', (byte) 'y', (byte) 'z'};
/**
* Used in decoding the "ordered" dialect of Base64.
*/
- private static final byte[] _ORDERED_DECODABET = {
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9, // Decimal 0 - 8
- -5,
- -5, // Whitespace: Tab and Linefeed
- -9,
- -9, // Decimal 11 - 12
+ private static final byte[] _ORDERED_DECODABET = {-9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 0 - 8
+ -5, -5, // Whitespace: Tab and Linefeed
+ -9, -9, // Decimal 11 - 12
-5, // Whitespace: Carriage Return
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9, // Decimal 14 - 26
- -9,
- -9,
- -9,
- -9,
- -9, // Decimal 27 - 31
+ -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 14 - 26
+ -9, -9, -9, -9, -9, // Decimal 27 - 31
-5, // Whitespace: Space
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9,
- -9, // Decimal 33 - 42
+ -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 33 - 42
-9, // Plus sign at decimal 43
-9, // Decimal 44
0, // Minus sign at decimal 45
-9, // Decimal 46
-9, // Slash at decimal 47
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9,
- 10, // Numbers zero through nine
- -9,
- -9,
- -9, // Decimal 58 - 60
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, // Numbers zero through nine
+ -9, -9, -9, // Decimal 58 - 60
-1, // Equals sign at decimal 61
- -9,
- -9,
- -9, // Decimal 62 - 64
- 11,
- 12,
- 13,
- 14,
- 15,
- 16,
- 17,
- 18,
- 19,
- 20,
- 21,
- 22,
- 23, // Letters 'A' through 'M'
- 24,
- 25,
- 26,
- 27,
- 28,
- 29,
- 30,
- 31,
- 32,
- 33,
- 34,
- 35,
- 36, // Letters 'N' through 'Z'
- -9,
- -9,
- -9,
- -9, // Decimal 91 - 94
+ -9, -9, -9, // Decimal 62 - 64
+ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, // Letters 'A' through 'M'
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, // Letters 'N' through 'Z'
+ -9, -9, -9, -9, // Decimal 91 - 94
37, // Underscore at decimal 95
-9, // Decimal 96
- 38,
- 39,
- 40,
- 41,
- 42,
- 43,
- 44,
- 45,
- 46,
- 47,
- 48,
- 49,
- 50, // Letters 'a' through 'm'
- 51,
- 52,
- 53,
- 54,
- 55,
- 56,
- 57,
- 58,
- 59,
- 60,
- 61,
- 62,
- 63, // Letters 'n' through 'z'
- -9,
- -9,
- -9,
- -9 // Decimal 123 - 126
+ 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, // Letters 'a' through 'm'
+ 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, // Letters 'n' through 'z'
+ -9, -9, -9, -9 // Decimal 123 - 126
/*,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 127 - 139
-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 140 - 152
-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 153 - 165
@@ -806,8 +299,7 @@ public class Base64
-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 205 - 217
-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 218 - 230
-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 231 - 243
- -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9 // Decimal 244 - 255 */
- };
+ -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9 // Decimal 244 - 255 */};
/* ******** D E T E R M I N E W H I C H A L H A B E T ******** */
@@ -818,18 +310,14 @@ public class Base64
* in which case one of them will be picked, though there is
* no guarantee as to which one will be picked.
*/
- private static byte[] getAlphabet(final int options)
- {
- if ((options & Base64.URL_SAFE) == Base64.URL_SAFE)
- {
+ private static byte[] getAlphabet(final int options) {
+ if ((options & Base64.URL_SAFE) == Base64.URL_SAFE) {
return Base64._URL_SAFE_ALPHABET;
}
- else if ((options & Base64.ORDERED) == Base64.ORDERED)
- {
+ else if ((options & Base64.ORDERED) == Base64.ORDERED) {
return Base64._ORDERED_ALPHABET;
}
- else
- {
+ else {
return Base64._STANDARD_ALPHABET;
}
@@ -842,18 +330,14 @@ public class Base64
* in which case one of them will be picked, though there is
* no guarantee as to which one will be picked.
*/
- private static byte[] getDecodabet(final int options)
- {
- if ((options & Base64.URL_SAFE) == Base64.URL_SAFE)
- {
+ private static byte[] getDecodabet(final int options) {
+ if ((options & Base64.URL_SAFE) == Base64.URL_SAFE) {
return Base64._URL_SAFE_DECODABET;
}
- else if ((options & Base64.ORDERED) == Base64.ORDERED)
- {
+ else if ((options & Base64.ORDERED) == Base64.ORDERED) {
return Base64._ORDERED_DECODABET;
}
- else
- {
+ else {
return Base64._STANDARD_DECODABET;
}
@@ -862,8 +346,7 @@ public class Base64
/**
* Defeats instantiation.
*/
- private Base64()
- {
+ private Base64() {
}
/**
@@ -873,27 +356,21 @@ public class Base64
*
* @param args Input args
*/
- public static final void main(final String[] args)
- {
- if (args.length < 3)
- {
+ public static final void main(final String[] args) {
+ if (args.length < 3) {
Base64.usage("Not enough arguments.");
} // end if: args.length < 3
- else
- {
+ else {
String flag = args[0];
String infile = args[1];
String outfile = args[2];
- if (flag.equals("-e"))
- {
+ if (flag.equals("-e")) {
Base64.encodeFileToFile(infile, outfile);
} // end if: encode
- else if (flag.equals("-d"))
- {
+ else if (flag.equals("-d")) {
Base64.decodeFileToFile(infile, outfile);
} // end else if: decode
- else
- {
+ else {
Base64.usage("Unknown flag: " + flag);
} // end else
} // end else
@@ -904,8 +381,7 @@ public class Base64
*
* @param msg A message to include with usage info.
*/
- private static void usage(final String msg)
- {
+ private static void usage(final String msg) {
System.err.println(msg);
System.err.println("Usage: java Base64 -e|-d inputfile outputfile");
} // end usage
@@ -927,8 +403,10 @@ public class Base64
* @return four byte array in Base64 notation.
* @since 1.5.1
*/
- private static byte[] encode3to4(final byte[] b4, final byte[] threeBytes, final int numSigBytes, final int options)
- {
+ private static byte[] encode3to4(final byte[] b4,
+ final byte[] threeBytes,
+ final int numSigBytes,
+ final int options) {
Base64.encode3to4(threeBytes, 0, numSigBytes, b4, 0, options);
return b4;
} // end encode3to4
@@ -961,8 +439,7 @@ public class Base64
final int numSigBytes,
final byte[] destination,
final int destOffset,
- final int options)
- {
+ final int options) {
byte[] ALPHABET = Base64.getAlphabet(options);
// 1 2 3
@@ -976,12 +453,10 @@ public class Base64
// significant bytes passed in the array.
// We have to shift left 24 in order to flush out the 1's that appear
// when Java treats a value as negative that is cast from a byte to an int.
- int inBuff = (numSigBytes > 0 ? source[srcOffset] << 24 >>> 8 : 0) | (numSigBytes > 1 ? source[srcOffset + 1] << 24 >>> 16
- : 0) |
+ int inBuff = (numSigBytes > 0 ? source[srcOffset] << 24 >>> 8 : 0) | (numSigBytes > 1 ? source[srcOffset + 1] << 24 >>> 16 : 0) |
(numSigBytes > 2 ? source[srcOffset + 2] << 24 >>> 24 : 0);
- switch (numSigBytes)
- {
+ switch (numSigBytes) {
case 3:
destination[destOffset] = ALPHABET[(inBuff >>> 18)];
destination[destOffset + 1] = ALPHABET[inBuff >>> 12 & 0x3f];
@@ -1019,8 +494,7 @@ public class Base64
* @return The Base64-encoded object
* @since 1.4
*/
- public static String encodeObject(final java.io.Serializable serializableObject)
- {
+ public static String encodeObject(final java.io.Serializable serializableObject) {
return Base64.encodeObject(serializableObject, Base64.NO_OPTIONS);
} // end encodeObject
@@ -1047,8 +521,7 @@ public class Base64
* @see Base64#DONT_BREAK_LINES
* @since 2.0
*/
- public static String encodeObject(final java.io.Serializable serializableObject, final int options)
- {
+ public static String encodeObject(final java.io.Serializable serializableObject, final int options) {
// Streams
java.io.ByteArrayOutputStream baos = null;
java.io.OutputStream b64os = null;
@@ -1058,59 +531,46 @@ public class Base64
// Isolate options
int gzip = options & Base64.GZIP;
- try
- {
+ try {
// ObjectOutputStream -> (GZIP) -> Base64 -> ByteArrayOutputStream
baos = new java.io.ByteArrayOutputStream();
b64os = new Base64.OutputStream(baos, Base64.ENCODE | options);
// GZip?
- if (gzip == Base64.GZIP)
- {
+ if (gzip == Base64.GZIP) {
gzos = new java.util.zip.GZIPOutputStream(b64os);
oos = new java.io.ObjectOutputStream(gzos);
} // end if: gzip
- else
- {
+ else {
oos = new java.io.ObjectOutputStream(b64os);
}
oos.writeObject(serializableObject);
} // end try
- catch (java.io.IOException e)
- {
+ catch (java.io.IOException e) {
e.printStackTrace();
return null;
} // end catch
- finally
- {
- try
- {
+ finally {
+ try {
oos.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
- try
- {
+ try {
gzos.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
- try
- {
+ try {
b64os.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
- try
- {
+ try {
baos.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
} // end finally
@@ -1127,8 +587,7 @@ public class Base64
* @return Base64 String
* @since 1.4
*/
- public static String encodeBytes(final byte[] source)
- {
+ public static String encodeBytes(final byte[] source) {
return Base64.encodeBytes(source, 0, source.length, Base64.NO_OPTIONS);
} // end encodeBytes
@@ -1152,8 +611,7 @@ public class Base64
* @see Base64#DONT_BREAK_LINES
* @since 2.0
*/
- public static String encodeBytes(final byte[] source, final int options)
- {
+ public static String encodeBytes(final byte[] source, final int options) {
return Base64.encodeBytes(source, 0, source.length, options);
} // end encodeBytes
@@ -1167,8 +625,7 @@ public class Base64
* @return Encoded String
* @since 1.4
*/
- public static String encodeBytes(final byte[] source, final int off, final int len)
- {
+ public static String encodeBytes(final byte[] source, final int off, final int len) {
return Base64.encodeBytes(source, off, len, Base64.NO_OPTIONS);
} // end encodeBytes
@@ -1194,21 +651,18 @@ public class Base64
* @see Base64#DONT_BREAK_LINES
* @since 2.0
*/
- public static String encodeBytes(final byte[] source, final int off, final int len, final int options)
- {
+ public static String encodeBytes(final byte[] source, final int off, final int len, final int options) {
// Isolate options
int dontBreakLines = options & Base64.DONT_BREAK_LINES;
int gzip = options & Base64.GZIP;
// Compress?
- if (gzip == Base64.GZIP)
- {
+ if (gzip == Base64.GZIP) {
java.io.ByteArrayOutputStream baos = null;
java.util.zip.GZIPOutputStream gzos = null;
Base64.OutputStream b64os = null;
- try
- {
+ try {
// GZip -> Base64 -> ByteArray
baos = new java.io.ByteArrayOutputStream();
b64os = new Base64.OutputStream(baos, Base64.ENCODE | options);
@@ -1217,33 +671,25 @@ public class Base64
gzos.write(source, off, len);
gzos.close();
} // end try
- catch (java.io.IOException e)
- {
+ catch (java.io.IOException e) {
e.printStackTrace();
return null;
} // end catch
- finally
- {
- try
- {
+ finally {
+ try {
gzos.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
- try
- {
+ try {
b64os.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
- try
- {
+ try {
baos.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
} // end finally
@@ -1252,8 +698,7 @@ public class Base64
} // end if: compress
// Else, don't compress. Better not to use streams at all then.
- else
- {
+ else {
// Convert option to boolean in way that code likes it.
boolean breakLines = dontBreakLines == 0;
@@ -1265,21 +710,18 @@ public class Base64
int e = 0;
int len2 = len - 2;
int lineLength = 0;
- for (; d < len2; d += 3, e += 4)
- {
+ for (; d < len2; d += 3, e += 4) {
Base64.encode3to4(source, d + off, 3, outBuff, e, options);
lineLength += 4;
- if (breakLines && lineLength == Base64.MAX_LINE_LENGTH)
- {
+ if (breakLines && lineLength == Base64.MAX_LINE_LENGTH) {
outBuff[e + 4] = Base64.NEW_LINE;
e++;
lineLength = 0;
} // end if: end of line
} // en dfor: each piece of array
- if (d < len)
- {
+ if (d < len) {
Base64.encode3to4(source, d + off, len - d, outBuff, e, options);
e += 4;
} // end if: some padding needed
@@ -1321,13 +763,11 @@ public class Base64
final int srcOffset,
final byte[] destination,
final int destOffset,
- final int options)
- {
+ final int options) {
byte[] DECODABET = Base64.getDecodabet(options);
// Example: Dk==
- if (source[srcOffset + 2] == Base64.EQUALS_SIGN)
- {
+ if (source[srcOffset + 2] == Base64.EQUALS_SIGN) {
// Two ways to do the same thing. Don't know which way I like best.
// int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 )
// | ( ( DECODABET[ source[ srcOffset + 1] ] << 24 ) >>> 12 );
@@ -1338,8 +778,7 @@ public class Base64
}
// Example: DkL=
- else if (source[srcOffset + 3] == Base64.EQUALS_SIGN)
- {
+ else if (source[srcOffset + 3] == Base64.EQUALS_SIGN) {
// Two ways to do the same thing. Don't know which way I like best.
// int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 )
// | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 )
@@ -1353,10 +792,8 @@ public class Base64
}
// Example: DkLE
- else
- {
- try
- {
+ else {
+ try {
// Two ways to do the same thing. Don't know which way I like best.
// int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 )
// | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 )
@@ -1364,8 +801,7 @@ public class Base64
// | ( ( DECODABET[ source[ srcOffset + 3 ] ] << 24 ) >>> 24 );
int outBuff = (DECODABET[source[srcOffset]] & 0xFF) << 18 | (DECODABET[source[srcOffset + 1]] & 0xFF) << 12 |
(DECODABET[source[srcOffset + 2]] & 0xFF) << 6 |
- DECODABET[source[srcOffset + 3]] &
- 0xFF;
+ DECODABET[source[srcOffset + 3]] & 0xFF;
destination[destOffset] = (byte) (outBuff >> 16);
destination[destOffset + 1] = (byte) (outBuff >> 8);
@@ -1373,8 +809,7 @@ public class Base64
return 3;
}
- catch (Exception e)
- {
+ catch (Exception e) {
System.out.println("" + source[srcOffset] + ": " + DECODABET[source[srcOffset]]);
System.out.println("" + source[srcOffset + 1] + ": " + DECODABET[source[srcOffset + 1]]);
System.out.println("" + source[srcOffset + 2] + ": " + DECODABET[source[srcOffset + 2]]);
@@ -1389,15 +824,14 @@ public class Base64
* the form of a byte array. Does not support automatically
* gunzipping or any other "fancy" features.
*
- * @param source The Base64 encoded data
- * @param off The offset of where to begin decoding
- * @param len The length of characters to decode
+ * @param source The Base64 encoded data
+ * @param off The offset of where to begin decoding
+ * @param len The length of characters to decode
* @param options Specified options
* @return decoded data
* @since 1.3
*/
- public static byte[] decode(final byte[] source, final int off, final int len, final int options)
- {
+ public static byte[] decode(final byte[] source, final int off, final int len, final int options) {
byte[] DECODABET = Base64.getDecodabet(options);
int len34 = len * 3 / 4;
@@ -1409,24 +843,20 @@ public class Base64
int i = 0;
byte sbiCrop = 0;
byte sbiDecode = 0;
- for (i = off; i < off + len; i++)
- {
+ for (i = off; i < off + len; i++) {
sbiCrop = (byte) (source[i] & 0x7f); // Only the low seven bits
sbiDecode = DECODABET[sbiCrop];
if (sbiDecode >= Base64.WHITE_SPACE_ENC) // White space, Equals sign or better
{
- if (sbiDecode >= Base64.EQUALS_SIGN_ENC)
- {
+ if (sbiDecode >= Base64.EQUALS_SIGN_ENC) {
b4[b4Posn++] = sbiCrop;
- if (b4Posn > 3)
- {
+ if (b4Posn > 3) {
outBuffPosn += Base64.decode4to3(b4, 0, outBuff, outBuffPosn, options);
b4Posn = 0;
// If that was the equals sign, break out of 'for' loop
- if (sbiCrop == Base64.EQUALS_SIGN)
- {
+ if (sbiCrop == Base64.EQUALS_SIGN) {
break;
}
} // end if: quartet built
@@ -1434,8 +864,7 @@ public class Base64
} // end if: equals sign or better
} // end if: white space, equals sign or better
- else
- {
+ else {
System.err.println("Bad Base64 input character at " + i + ": " + source[i] + "(decimal)");
return null;
} // end else:
@@ -1454,8 +883,7 @@ public class Base64
* @return the decoded data
* @since 1.4
*/
- public static byte[] decode(final String s)
- {
+ public static byte[] decode(final String s) {
return Base64.decode(s, Base64.NO_OPTIONS);
}
@@ -1468,8 +896,7 @@ public class Base64
* @return the decoded data
* @since 1.4
*/
- public static byte[] decode(final String s, final int options)
- {
+ public static byte[] decode(final String s, final int options) {
byte[] bytes = s.getBytes(Base64.PREFERRED_ENCODING);
//
@@ -1478,26 +905,22 @@ public class Base64
// Check to see if it's gzip-compressed
// GZIP Magic Two-Byte Number: 0x8b1f (35615)
- if (bytes != null && bytes.length >= 4)
- {
+ if (bytes != null && bytes.length >= 4) {
int head = bytes[0] & 0xff | bytes[1] << 8 & 0xff00;
- if (java.util.zip.GZIPInputStream.GZIP_MAGIC == head)
- {
+ if (java.util.zip.GZIPInputStream.GZIP_MAGIC == head) {
java.io.ByteArrayInputStream bais = null;
java.util.zip.GZIPInputStream gzis = null;
java.io.ByteArrayOutputStream baos = null;
byte[] buffer = new byte[2048];
int length = 0;
- try
- {
+ try {
baos = new java.io.ByteArrayOutputStream();
bais = new java.io.ByteArrayInputStream(bytes);
gzis = new java.util.zip.GZIPInputStream(bais);
- while ((length = gzis.read(buffer)) >= 0)
- {
+ while ((length = gzis.read(buffer)) >= 0) {
baos.write(buffer, 0, length);
} // end while: reading input
@@ -1505,32 +928,24 @@ public class Base64
bytes = baos.toByteArray();
} // end try
- catch (java.io.IOException e)
- {
+ catch (java.io.IOException e) {
// Just return originally-decoded bytes
} // end catch
- finally
- {
- try
- {
+ finally {
+ try {
baos.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
- try
- {
+ try {
gzis.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
- try
- {
+ try {
bais.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
} // end finally
@@ -1548,8 +963,7 @@ public class Base64
* @return The decoded and deserialized object
* @since 1.5
*/
- public static Object decodeToObject(final String encodedObject)
- {
+ public static Object decodeToObject(final String encodedObject) {
// Decode and gunzip if necessary
byte[] objBytes = Base64.decode(encodedObject);
@@ -1557,38 +971,30 @@ public class Base64
java.io.ObjectInputStream ois = null;
Object obj = null;
- try
- {
+ try {
bais = new java.io.ByteArrayInputStream(objBytes);
ois = new java.io.ObjectInputStream(bais);
obj = ois.readObject();
} // end try
- catch (java.io.IOException e)
- {
+ catch (java.io.IOException e) {
e.printStackTrace();
obj = null;
} // end catch
- catch (java.lang.ClassNotFoundException e)
- {
+ catch (java.lang.ClassNotFoundException e) {
e.printStackTrace();
obj = null;
} // end catch
- finally
- {
- try
- {
+ finally {
+ try {
bais.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
- try
- {
+ try {
ois.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
} // end finally
@@ -1603,29 +1009,23 @@ public class Base64
* @return true if successful, false otherwise
* @since 2.1
*/
- public static boolean encodeToFile(final byte[] dataToEncode, final String filename)
- {
+ public static boolean encodeToFile(final byte[] dataToEncode, final String filename) {
boolean success = false;
Base64.OutputStream bos = null;
- try
- {
+ try {
bos = new Base64.OutputStream(new java.io.FileOutputStream(filename), Base64.ENCODE);
bos.write(dataToEncode);
success = true;
} // end try
- catch (java.io.IOException e)
- {
+ catch (java.io.IOException e) {
success = false;
} // end catch: IOException
- finally
- {
- try
- {
+ finally {
+ try {
bos.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
} // end finally
@@ -1640,28 +1040,22 @@ public class Base64
* @return true if successful, false otherwise
* @since 2.1
*/
- public static boolean decodeToFile(final String dataToDecode, final String filename)
- {
+ public static boolean decodeToFile(final String dataToDecode, final String filename) {
boolean success = false;
Base64.OutputStream bos = null;
- try
- {
+ try {
bos = new Base64.OutputStream(new java.io.FileOutputStream(filename), Base64.DECODE);
bos.write(dataToDecode.getBytes(Base64.PREFERRED_ENCODING));
success = true;
} // end try
- catch (java.io.IOException e)
- {
+ catch (java.io.IOException e) {
success = false;
} // end catch: IOException
- finally
- {
- try
- {
+ finally {
+ try {
bos.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
} // end finally
@@ -1676,12 +1070,10 @@ public class Base64
* @return decoded byte array or null if unsuccessful
* @since 2.1
*/
- public static byte[] decodeFromFile(final String filename)
- {
+ public static byte[] decodeFromFile(final String filename) {
byte[] decodedData = null;
Base64.InputStream bis = null;
- try
- {
+ try {
// Set up some useful variables
java.io.File file = new java.io.File(filename);
byte[] buffer = null;
@@ -1689,8 +1081,7 @@ public class Base64
int numBytes = 0;
// Check for size of file
- if (file.length() > Integer.MAX_VALUE)
- {
+ if (file.length() > Integer.MAX_VALUE) {
System.err.println("File is too big for this convenience method (" + file.length() + " bytes).");
return null;
} // end if: file too big for int index
@@ -1700,8 +1091,7 @@ public class Base64
bis = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(file)), Base64.DECODE);
// Read until done
- while ((numBytes = bis.read(buffer, length, 4096)) >= 0)
- {
+ while ((numBytes = bis.read(buffer, length, 4096)) >= 0) {
length += numBytes;
}
@@ -1710,21 +1100,16 @@ public class Base64
System.arraycopy(buffer, 0, decodedData, 0, length);
} // end try
- catch (java.io.IOException e)
- {
+ catch (java.io.IOException e) {
System.err.println("Error decoding from file " + filename);
} // end catch: IOException
- finally
- {
- try
- {
- if (bis != null)
- {
+ finally {
+ try {
+ if (bis != null) {
bis.close();
}
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
} // end finally
@@ -1739,12 +1124,10 @@ public class Base64
* @return base64-encoded string or null if unsuccessful
* @since 2.1
*/
- public static String encodeFromFile(final String filename)
- {
+ public static String encodeFromFile(final String filename) {
String encodedData = null;
Base64.InputStream bis = null;
- try
- {
+ try {
// Set up some useful variables
java.io.File file = new java.io.File(filename);
byte[] buffer = new byte[Math.max((int) (file.length() * 1.4), 40)]; // Need max() for math on small files
@@ -1756,8 +1139,7 @@ public class Base64
bis = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(file)), Base64.ENCODE);
// Read until done
- while ((numBytes = bis.read(buffer, length, 4096)) >= 0)
- {
+ while ((numBytes = bis.read(buffer, length, 4096)) >= 0) {
length += numBytes;
}
@@ -1765,18 +1147,14 @@ public class Base64
encodedData = new String(buffer, 0, length, Base64.PREFERRED_ENCODING);
} // end try
- catch (java.io.IOException e)
- {
+ catch (java.io.IOException e) {
System.err.println("Error encoding from file " + filename);
} // end catch: IOException
- finally
- {
- try
- {
+ finally {
+ try {
bis.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
} // end finally
@@ -1791,43 +1169,33 @@ public class Base64
* @return true if the operation is successful
* @since 2.2
*/
- public static boolean encodeFileToFile(final String infile, final String outfile)
- {
+ public static boolean encodeFileToFile(final String infile, final String outfile) {
boolean success = false;
java.io.InputStream in = null;
java.io.OutputStream out = null;
- try
- {
- in = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(infile)),
- Base64.ENCODE);
+ try {
+ in = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(infile)), Base64.ENCODE);
out = new java.io.BufferedOutputStream(new java.io.FileOutputStream(outfile));
byte[] buffer = new byte[65536]; // 64K
int read = -1;
- while ((read = in.read(buffer)) >= 0)
- {
+ while ((read = in.read(buffer)) >= 0) {
out.write(buffer, 0, read);
} // end while: through file
success = true;
}
- catch (java.io.IOException exc)
- {
+ catch (java.io.IOException exc) {
exc.printStackTrace();
}
- finally
- {
- try
- {
+ finally {
+ try {
in.close();
}
- catch (Exception exc)
- {
+ catch (Exception exc) {
}
- try
- {
+ try {
out.close();
}
- catch (Exception exc)
- {
+ catch (Exception exc) {
}
} // end finally
@@ -1842,43 +1210,33 @@ public class Base64
* @return true if the operation is successful
* @since 2.2
*/
- public static boolean decodeFileToFile(final String infile, final String outfile)
- {
+ public static boolean decodeFileToFile(final String infile, final String outfile) {
boolean success = false;
java.io.InputStream in = null;
java.io.OutputStream out = null;
- try
- {
- in = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(infile)),
- Base64.DECODE);
+ try {
+ in = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(infile)), Base64.DECODE);
out = new java.io.BufferedOutputStream(new java.io.FileOutputStream(outfile));
byte[] buffer = new byte[65536]; // 64K
int read = -1;
- while ((read = in.read(buffer)) >= 0)
- {
+ while ((read = in.read(buffer)) >= 0) {
out.write(buffer, 0, read);
} // end while: through file
success = true;
}
- catch (java.io.IOException exc)
- {
+ catch (java.io.IOException exc) {
exc.printStackTrace();
}
- finally
- {
- try
- {
+ finally {
+ try {
in.close();
}
- catch (Exception exc)
- {
+ catch (Exception exc) {
}
- try
- {
+ try {
out.close();
}
- catch (Exception exc)
- {
+ catch (Exception exc) {
}
} // end finally
@@ -1895,8 +1253,8 @@ public class Base64
* @see Base64
* @since 1.3
*/
- public static class InputStream extends java.io.FilterInputStream
- {
+ public static class InputStream extends java.io.FilterInputStream {
+
private final boolean encode; // Encoding or decoding
private int position; // Current position in the buffer
@@ -1923,8 +1281,7 @@ public class Base64
* @param in the java.io.InputStream from which to read data.
* @since 1.3
*/
- public InputStream(final java.io.InputStream in)
- {
+ public InputStream(final java.io.InputStream in) {
this(in, Base64.DECODE);
} // end constructor
@@ -1948,8 +1305,7 @@ public class Base64
* @see Base64#DONT_BREAK_LINES
* @since 2.0
*/
- public InputStream(final java.io.InputStream in, final int options)
- {
+ public InputStream(final java.io.InputStream in, final int options) {
super(in);
breakLines = (options & Base64.DONT_BREAK_LINES) != Base64.DONT_BREAK_LINES;
encode = (options & Base64.ENCODE) == Base64.ENCODE;
@@ -1970,86 +1326,68 @@ public class Base64
* @since 1.3
*/
@Override
- public int read() throws java.io.IOException
- {
+ public int read() throws java.io.IOException {
// Do we need to get data?
- if (position < 0)
- {
- if (encode)
- {
+ if (position < 0) {
+ if (encode) {
byte[] b3 = new byte[3];
int numBinaryBytes = 0;
- for (int i = 0; i < 3; i++)
- {
- try
- {
+ for (int i = 0; i < 3; i++) {
+ try {
int b = in.read();
// If end of stream, b is -1.
- if (b >= 0)
- {
+ if (b >= 0) {
b3[i] = (byte) b;
numBinaryBytes++;
} // end if: not end of stream
} // end try: read
- catch (java.io.IOException e)
- {
+ catch (java.io.IOException e) {
// Only a problem if we got no data at all.
- if (i == 0)
- {
+ if (i == 0) {
throw e;
}
} // end catch
} // end for: each needed input byte
- if (numBinaryBytes > 0)
- {
+ if (numBinaryBytes > 0) {
Base64.encode3to4(b3, 0, numBinaryBytes, buffer, 0, options);
position = 0;
numSigBytes = 4;
} // end if: got data
- else
- {
+ else {
return -1;
}
} // end if: encoding
// Else decoding
- else
- {
+ else {
byte[] b4 = new byte[4];
int i = 0;
- for (i = 0; i < 4; i++)
- {
+ for (i = 0; i < 4; i++) {
// Read four "meaningful" bytes:
int b = 0;
- do
- {
+ do {
b = in.read();
- }
- while (b >= 0 && decodabet[b & 0x7f] <= Base64.WHITE_SPACE_ENC);
+ } while (b >= 0 && decodabet[b & 0x7f] <= Base64.WHITE_SPACE_ENC);
- if (b < 0)
- {
+ if (b < 0) {
break; // Reads a -1 if end of stream
}
b4[i] = (byte) b;
} // end for: each needed input byte
- if (i == 4)
- {
+ if (i == 4) {
numSigBytes = Base64.decode4to3(b4, 0, buffer, 0, options);
position = 0;
} // end if: got four characters
- else if (i == 0)
- {
+ else if (i == 0) {
return -1;
}
- else
- {
+ else {
// Must have broken out from above.
throw new java.io.IOException("Improperly padded Base64 input.");
}
@@ -2058,29 +1396,24 @@ public class Base64
} // end else: get data
// Got data?
- if (position >= 0)
- {
+ if (position >= 0) {
// End of relevant data?
- if ( /*!encode &&*/position >= numSigBytes)
- {
+ if ( /*!encode &&*/position >= numSigBytes) {
return -1;
}
- if (encode && breakLines && lineLength >= Base64.MAX_LINE_LENGTH)
- {
+ if (encode && breakLines && lineLength >= Base64.MAX_LINE_LENGTH) {
lineLength = 0;
return '\n';
} // end if
- else
- {
+ else {
lineLength++; // This isn't important when decoding
// but throwing an extra "if" seems
// just as wasteful.
int b = buffer[position++];
- if (position >= bufferLength)
- {
+ if (position >= bufferLength) {
position = -1;
}
@@ -2088,8 +1421,7 @@ public class Base64
// intended to be unsigned.
} // end else
} // end if: position >= 0
- else
- {
+ else {
// When JDK1.4 is more accepted, use an assertion here.
throw new java.io.IOException("Error in Base64 code reading stream.");
}
@@ -2108,27 +1440,22 @@ public class Base64
* @since 1.3
*/
@Override
- public int read(final byte[] dest, final int off, final int len) throws java.io.IOException
- {
+ public int read(final byte[] dest, final int off, final int len) throws java.io.IOException {
int i;
int b;
- for (i = 0; i < len; i++)
- {
+ for (i = 0; i < len; i++) {
b = read();
// if( b < 0 && i == 0 )
// return -1;
- if (b >= 0)
- {
+ if (b >= 0) {
dest[off + i] = (byte) b;
}
- else if (i == 0)
- {
+ else if (i == 0) {
return -1;
}
- else
- {
+ else {
break; // Out of 'for' loop
}
} // end for: each byte read
@@ -2147,8 +1474,8 @@ public class Base64
* @see Base64
* @since 1.3
*/
- public static class OutputStream extends java.io.FilterOutputStream
- {
+ public static class OutputStream extends java.io.FilterOutputStream {
+
private final boolean encode;
private int position;
@@ -2177,8 +1504,7 @@ public class Base64
* @param out the java.io.OutputStream to which data will be written.
* @since 1.3
*/
- public OutputStream(final java.io.OutputStream out)
- {
+ public OutputStream(final java.io.OutputStream out) {
this(out, Base64.ENCODE);
} // end constructor
@@ -2202,8 +1528,7 @@ public class Base64
* @see Base64#DONT_BREAK_LINES
* @since 1.3
*/
- public OutputStream(final java.io.OutputStream out, final int options)
- {
+ public OutputStream(final java.io.OutputStream out, final int options) {
super(out);
breakLines = (options & Base64.DONT_BREAK_LINES) != Base64.DONT_BREAK_LINES;
encode = (options & Base64.ENCODE) == Base64.ENCODE;
@@ -2232,26 +1557,21 @@ public class Base64
* @since 1.3
*/
@Override
- public void write(final int theByte) throws java.io.IOException
- {
+ public void write(final int theByte) throws java.io.IOException {
// Encoding suspended?
- if (suspendEncoding)
- {
+ if (suspendEncoding) {
super.out.write(theByte);
return;
} // end if: supsended
// Encode?
- if (encode)
- {
+ if (encode) {
buffer[position++] = (byte) theByte;
- if (position >= bufferLength) // Enough to encode.
- {
+ if (position >= bufferLength) { // Enough to encode.
out.write(Base64.encode3to4(b4, buffer, bufferLength, options));
lineLength += 4;
- if (breakLines && lineLength >= Base64.MAX_LINE_LENGTH)
- {
+ if (breakLines && lineLength >= Base64.MAX_LINE_LENGTH) {
out.write(Base64.NEW_LINE);
lineLength = 0;
} // end if: end of line
@@ -2261,22 +1581,18 @@ public class Base64
} // end if: encoding
// Else, Decoding
- else
- {
+ else {
// Meaningful Base64 character?
- if (decodabet[theByte & 0x7f] > Base64.WHITE_SPACE_ENC)
- {
+ if (decodabet[theByte & 0x7f] > Base64.WHITE_SPACE_ENC) {
buffer[position++] = (byte) theByte;
- if (position >= bufferLength) // Enough to output.
- {
+ if (position >= bufferLength) { // Enough to output.
int len = Base64.decode4to3(buffer, 0, b4, 0, options);
out.write(b4, 0, len);
// out.write( Base64.decode4to3( buffer ) );
position = 0;
} // end if: enough to output
} // end if: meaningful base64 character
- else if (decodabet[theByte & 0x7f] != Base64.WHITE_SPACE_ENC)
- {
+ else if (decodabet[theByte & 0x7f] != Base64.WHITE_SPACE_ENC) {
throw new java.io.IOException("Invalid character in Base64 data.");
}
} // end else: decoding
@@ -2289,21 +1605,18 @@ public class Base64
* @param theBytes array from which to read bytes
* @param off offset for array
* @param len max number of bytes to read into array
- * @since 1.3
* @throws java.io.IOException Throws IOException
+ * @since 1.3
*/
@Override
- public void write(final byte[] theBytes, final int off, final int len) throws java.io.IOException
- {
+ public void write(final byte[] theBytes, final int off, final int len) throws java.io.IOException {
// Encoding suspended?
- if (suspendEncoding)
- {
+ if (suspendEncoding) {
super.out.write(theBytes, off, len);
return;
} // end if: supsended
- for (int i = 0; i < len; i++)
- {
+ for (int i = 0; i < len; i++) {
write(theBytes[off + i]);
} // end for: each byte written
@@ -2312,19 +1625,16 @@ public class Base64
/**
* Method added by PHIL. [Thanks, PHIL. -Rob]
* This pads the buffer without closing the stream.
+ *
* @throws java.io.IOException On IO Exception
*/
- public void flushBase64() throws java.io.IOException
- {
- if (position > 0)
- {
- if (encode)
- {
+ public void flushBase64() throws java.io.IOException {
+ if (position > 0) {
+ if (encode) {
out.write(Base64.encode3to4(b4, buffer, position, options));
position = 0;
} // end if: encoding
- else
- {
+ else {
throw new java.io.IOException("Base64 input not properly padded.");
}
} // end if: buffer partially full
@@ -2336,11 +1646,9 @@ public class Base64
*
* @throws java.io.IOException Throws IOException
* @since 1.3
- *
*/
@Override
- public void close() throws java.io.IOException
- {
+ public void close() throws java.io.IOException {
// 1. Ensure that pending characters are written
flushBase64();
@@ -2356,11 +1664,11 @@ public class Base64
* Suspends encoding of the stream.
* May be helpful if you need to embed a piece of
* base640-encoded data in a stream.
+ *
* @throws java.io.IOException On IO Exception
* @since 1.5.1
*/
- public void suspendEncoding() throws java.io.IOException
- {
+ public void suspendEncoding() throws java.io.IOException {
flushBase64();
suspendEncoding = true;
} // end suspendEncoding
@@ -2372,8 +1680,7 @@ public class Base64
*
* @since 1.5.1
*/
- public void resumeEncoding()
- {
+ public void resumeEncoding() {
suspendEncoding = false;
} // end resumeEncoding
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java
index f2b4e4f1b7..6e2ca99e83 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java
@@ -19,36 +19,28 @@ package org.apache.activemq.artemis.utils;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
-public class ByteUtil
-{
+public class ByteUtil {
private static final char[] hexArray = "0123456789ABCDEF".toCharArray();
- public static String maxString(String value, int size)
- {
- if (value.length() < size)
- {
+ public static String maxString(String value, int size) {
+ if (value.length() < size) {
return value;
}
- else
- {
+ else {
return value.substring(0, size / 2) + " ... " + value.substring(value.length() - size / 2);
}
}
- public static String bytesToHex(byte[] bytes, int groupSize)
- {
- if (bytes == null)
- {
+
+ public static String bytesToHex(byte[] bytes, int groupSize) {
+ if (bytes == null) {
return "null";
}
- else
- {
+ else {
char[] hexChars = new char[bytes.length * 2 + numberOfGroups(bytes, groupSize)];
int outPos = 0;
- for (int j = 0; j < bytes.length; j++)
- {
- if (j > 0 && j % groupSize == 0)
- {
+ for (int j = 0; j < bytes.length; j++) {
+ if (j > 0 && j % groupSize == 0) {
hexChars[outPos++] = ' ';
}
int v = bytes[j] & 0xFF;
@@ -59,20 +51,17 @@ public class ByteUtil
}
}
- private static int numberOfGroups(byte[] bytes, int groupSize)
- {
+ private static int numberOfGroups(byte[] bytes, int groupSize) {
int groups = bytes.length / groupSize;
- if (bytes.length % groupSize == 0)
- {
+ if (bytes.length % groupSize == 0) {
groups--;
}
return groups;
}
- public static byte[] longToBytes(long x)
- {
+ public static byte[] longToBytes(long x) {
ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.heapBuffer(8, 8);
buffer.writeLong(x);
return buffer.array();
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ClassloadingUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ClassloadingUtil.java
index 098bc56d6a..707635eff5 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ClassloadingUtil.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ClassloadingUtil.java
@@ -25,101 +25,80 @@ import java.net.URL;
* Is't required to use a Security Block on any calls to this class.
*/
-public final class ClassloadingUtil
-{
- private static final String INSTANTIATION_EXCEPTION_MESSAGE =
- "Your class must have a constructor without arguments. If it is an inner class, it must be static!";
+public final class ClassloadingUtil {
- public static Object newInstanceFromClassLoader(final String className)
- {
+ private static final String INSTANTIATION_EXCEPTION_MESSAGE = "Your class must have a constructor without arguments. If it is an inner class, it must be static!";
+
+ public static Object newInstanceFromClassLoader(final String className) {
ClassLoader loader = ClassloadingUtil.class.getClassLoader();
- try
- {
+ try {
Class> clazz = loader.loadClass(className);
return clazz.newInstance();
}
- catch (Throwable t)
- {
- if (t instanceof InstantiationException)
- {
+ catch (Throwable t) {
+ if (t instanceof InstantiationException) {
System.out.println(INSTANTIATION_EXCEPTION_MESSAGE);
}
loader = Thread.currentThread().getContextClassLoader();
if (loader == null)
throw new RuntimeException("No local context classloader", t);
- try
- {
+ try {
return loader.loadClass(className).newInstance();
}
- catch (InstantiationException e)
- {
+ catch (InstantiationException e) {
throw new RuntimeException(INSTANTIATION_EXCEPTION_MESSAGE + " " + className, e);
}
- catch (ClassNotFoundException e)
- {
+ catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
}
- catch (IllegalAccessException e)
- {
+ catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}
- public static Object newInstanceFromClassLoader(final String className, Object... objs)
- {
+ public static Object newInstanceFromClassLoader(final String className, Object... objs) {
ClassLoader loader = ClassloadingUtil.class.getClassLoader();
- try
- {
+ try {
Class>[] parametersType = new Class>[objs.length];
- for (int i = 0; i < objs.length; i++)
- {
+ for (int i = 0; i < objs.length; i++) {
parametersType[i] = objs[i].getClass();
}
Class> clazz = loader.loadClass(className);
return clazz.getConstructor(parametersType).newInstance(objs);
}
- catch (Throwable t)
- {
- if (t instanceof InstantiationException)
- {
+ catch (Throwable t) {
+ if (t instanceof InstantiationException) {
System.out.println(INSTANTIATION_EXCEPTION_MESSAGE);
}
loader = Thread.currentThread().getContextClassLoader();
if (loader == null)
throw new RuntimeException("No local context classloader", t);
- try
- {
+ try {
return loader.loadClass(className).newInstance();
}
- catch (InstantiationException e)
- {
+ catch (InstantiationException e) {
throw new RuntimeException(INSTANTIATION_EXCEPTION_MESSAGE + " " + className, e);
}
- catch (ClassNotFoundException e)
- {
+ catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
}
- catch (IllegalAccessException e)
- {
+ catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}
- public static URL findResource(final String resourceName)
- {
+ public static URL findResource(final String resourceName) {
ClassLoader loader = ClassloadingUtil.class.getClassLoader();
- try
- {
+ try {
URL resource = loader.getResource(resourceName);
if (resource != null)
return resource;
}
- catch (Throwable t)
- {
+ catch (Throwable t) {
}
loader = Thread.currentThread().getContextClassLoader();
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ConcurrentHashSet.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ConcurrentHashSet.java
index e39b36e6bf..c0fe578b21 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ConcurrentHashSet.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ConcurrentHashSet.java
@@ -22,67 +22,56 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
- *
* A ConcurrentHashSet.
*
* Offers same concurrency as ConcurrentHashMap but for a Set
- *
*/
-public class ConcurrentHashSet extends AbstractSet implements ConcurrentSet
-{
+public class ConcurrentHashSet extends AbstractSet implements ConcurrentSet {
+
private final ConcurrentMap theMap;
private static final Object dummy = new Object();
- public ConcurrentHashSet()
- {
+ public ConcurrentHashSet() {
theMap = new ConcurrentHashMap();
}
@Override
- public int size()
- {
+ public int size() {
return theMap.size();
}
@Override
- public Iterator iterator()
- {
+ public Iterator iterator() {
return theMap.keySet().iterator();
}
@Override
- public boolean isEmpty()
- {
+ public boolean isEmpty() {
return theMap.isEmpty();
}
@Override
- public boolean add(final E o)
- {
+ public boolean add(final E o) {
return theMap.put(o, ConcurrentHashSet.dummy) == null;
}
@Override
- public boolean contains(final Object o)
- {
+ public boolean contains(final Object o) {
return theMap.containsKey(o);
}
@Override
- public void clear()
- {
+ public void clear() {
theMap.clear();
}
@Override
- public boolean remove(final Object o)
- {
+ public boolean remove(final Object o) {
return theMap.remove(o) == ConcurrentHashSet.dummy;
}
- public boolean addIfAbsent(final E o)
- {
+ public boolean addIfAbsent(final E o) {
Object obj = theMap.putIfAbsent(o, ConcurrentHashSet.dummy);
return obj == null;
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ConcurrentSet.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ConcurrentSet.java
index e88cac4ac1..e55be241aa 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ConcurrentSet.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ConcurrentSet.java
@@ -19,12 +19,11 @@ package org.apache.activemq.artemis.utils;
import java.util.Set;
/**
- *
* A ConcurrentSet
*
* @param The generic class
*/
-public interface ConcurrentSet extends Set
-{
+public interface ConcurrentSet extends Set {
+
boolean addIfAbsent(E o);
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DataConstants.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DataConstants.java
index 9ea5cf38b2..38df9b61e2 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DataConstants.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DataConstants.java
@@ -16,8 +16,8 @@
*/
package org.apache.activemq.artemis.utils;
-public final class DataConstants
-{
+public final class DataConstants {
+
public static final int SIZE_INT = 4;
public static final int SIZE_BOOLEAN = 1;
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodec.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodec.java
index 8e1a1dbe3e..6028742176 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodec.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodec.java
@@ -38,31 +38,24 @@ import javax.crypto.spec.SecretKeySpec;
* The decode() and encode() method is copied originally from
* JBoss AS code base.
*/
-public class DefaultSensitiveStringCodec implements SensitiveDataCodec
-{
+public class DefaultSensitiveStringCodec implements SensitiveDataCodec {
+
private byte[] internalKey = "clusterpassword".getBytes();
- public String decode(Object secret) throws NoSuchPaddingException,
- NoSuchAlgorithmException,
- InvalidKeyException,
- BadPaddingException,
- IllegalBlockSizeException
- {
+ public String decode(Object secret) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
SecretKeySpec key = new SecretKeySpec(internalKey, "Blowfish");
- BigInteger n = new BigInteger((String)secret, 16);
+ BigInteger n = new BigInteger((String) secret, 16);
byte[] encoding = n.toByteArray();
// JBAS-3457: fix leading zeros
- if (encoding.length % 8 != 0)
- {
+ if (encoding.length % 8 != 0) {
int length = encoding.length;
int newLength = ((length / 8) + 1) * 8;
int pad = newLength - length; // number of leading zeros
byte[] old = encoding;
encoding = new byte[newLength];
- for (int i = old.length - 1; i >= 0; i--)
- {
+ for (int i = old.length - 1; i >= 0; i--) {
encoding[i + pad] = old[i];
}
}
@@ -74,12 +67,7 @@ public class DefaultSensitiveStringCodec implements SensitiveDataCodec
return new String(decode);
}
- public Object encode(String secret) throws NoSuchPaddingException,
- NoSuchAlgorithmException,
- InvalidKeyException,
- BadPaddingException,
- IllegalBlockSizeException
- {
+ public Object encode(String secret) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
SecretKeySpec key = new SecretKeySpec(internalKey, "Blowfish");
Cipher cipher = Cipher.getInstance("Blowfish");
@@ -89,24 +77,21 @@ public class DefaultSensitiveStringCodec implements SensitiveDataCodec
return n.toString(16);
}
- public void init(Map params)
- {
+ public void init(Map params) {
String key = params.get("key");
- if (key != null)
- {
+ if (key != null) {
updateKey(key);
}
}
/**
* This main class is as documented on configuration-index.md, where the user can mask the password here. *
+ *
* @param args
* @throws Exception
*/
- public static void main(String[] args) throws Exception
- {
- if (args.length != 1)
- {
+ public static void main(String[] args) throws Exception {
+ if (args.length != 1) {
System.err.println("Use: java -cp org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec password-to-encode");
System.err.println("Error: no password on the args");
System.exit(-1);
@@ -116,10 +101,8 @@ public class DefaultSensitiveStringCodec implements SensitiveDataCodec
System.out.println("Encoded password (without quotes): \"" + encode + "\"");
}
- private void updateKey(String key)
- {
+ private void updateKey(String key) {
this.internalKey = key.getBytes();
}
-
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FactoryFinder.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FactoryFinder.java
index b26a71e35b..5f4f2a8442 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FactoryFinder.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FactoryFinder.java
@@ -23,8 +23,8 @@ import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-public class FactoryFinder
-{
+public class FactoryFinder {
+
/**
* The strategy that the FactoryFinder uses to find load and instantiate Objects
* can be changed out by calling the setObjectFactory method with a custom implementation of ObjectFactory.
@@ -33,15 +33,15 @@ public class FactoryFinder
* environment where service discovery needs to be done via the container system. For example,
* in an OSGi scenario.
*/
- public interface ObjectFactory
- {
+ public interface ObjectFactory {
+
/**
* @param path the full service path
+ * @return Object
* @throws IllegalAccessException illegal access
* @throws InstantiationException on instantiation error
- * @throws IOException On IO Error
+ * @throws IOException On IO Error
* @throws ClassNotFoundException On class not found error
- * @return Object
*/
Object create(String path) throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException;
@@ -50,85 +50,69 @@ public class FactoryFinder
/**
* The default implementation of Object factory which works well in standalone applications.
*/
- protected static class StandaloneObjectFactory implements ObjectFactory
- {
+ protected static class StandaloneObjectFactory implements ObjectFactory {
+
final ConcurrentMap classMap = new ConcurrentHashMap();
- public Object create(final String path) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException
- {
+ public Object create(final String path) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException {
Class clazz = classMap.get(path);
- if (clazz == null)
- {
+ if (clazz == null) {
clazz = loadClass(loadProperties(path));
classMap.put(path, clazz);
}
return clazz.newInstance();
}
- static Class loadClass(Properties properties) throws ClassNotFoundException, IOException
- {
+ static Class loadClass(Properties properties) throws ClassNotFoundException, IOException {
String className = properties.getProperty("class");
- if (className == null)
- {
+ if (className == null) {
throw new IOException("Expected property is missing: class");
}
Class clazz = null;
ClassLoader loader = Thread.currentThread().getContextClassLoader();
- if (loader != null)
- {
- try
- {
+ if (loader != null) {
+ try {
clazz = loader.loadClass(className);
}
- catch (ClassNotFoundException e)
- {
+ catch (ClassNotFoundException e) {
// ignore
}
}
- if (clazz == null)
- {
+ if (clazz == null) {
clazz = FactoryFinder.class.getClassLoader().loadClass(className);
}
return clazz;
}
- public Properties loadProperties(String uri) throws IOException
- {
+ public Properties loadProperties(String uri) throws IOException {
// lets try the thread context class loader first
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- if (classLoader == null)
- {
+ if (classLoader == null) {
classLoader = StandaloneObjectFactory.class.getClassLoader();
}
InputStream in = classLoader.getResourceAsStream(uri);
- if (in == null)
- {
+ if (in == null) {
in = FactoryFinder.class.getClassLoader().getResourceAsStream(uri);
- if (in == null)
- {
+ if (in == null) {
throw new IOException("Could not find factory class for resource: " + uri);
}
}
// lets load the file
BufferedInputStream reader = null;
- try
- {
+ try {
reader = new BufferedInputStream(in);
Properties properties = new Properties();
properties.load(reader);
return properties;
}
- finally
- {
- try
- {
+ finally {
+ try {
reader.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
}
}
@@ -139,13 +123,11 @@ public class FactoryFinder
// ================================================================
private static ObjectFactory objectFactory = new StandaloneObjectFactory();
- public static ObjectFactory getObjectFactory()
- {
+ public static ObjectFactory getObjectFactory() {
return objectFactory;
}
- public static void setObjectFactory(ObjectFactory objectFactory)
- {
+ public static void setObjectFactory(ObjectFactory objectFactory) {
FactoryFinder.objectFactory = objectFactory;
}
@@ -154,8 +136,7 @@ public class FactoryFinder
// ================================================================
private final String path;
- public FactoryFinder(String path)
- {
+ public FactoryFinder(String path) {
this.path = path;
}
@@ -167,11 +148,10 @@ public class FactoryFinder
* @return a newly created instance
* @throws IllegalAccessException On illegal access
* @throws InstantiationException On can not instantiate exception
- * @throws IOException On IOException
+ * @throws IOException On IOException
* @throws ClassNotFoundException When class not on class path
*/
- public Object newInstance(String key) throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException
- {
+ public Object newInstance(String key) throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException {
return objectFactory.create(path + key);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/PasswordMaskingUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/PasswordMaskingUtil.java
index 7ea3e0fef1..b6f5598820 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/PasswordMaskingUtil.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/PasswordMaskingUtil.java
@@ -25,8 +25,8 @@ import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
import org.apache.activemq.artemis.logs.ActiveMQUtilBundle;
-public class PasswordMaskingUtil
-{
+public class PasswordMaskingUtil {
+
/*
* Loading the codec class.
*
@@ -36,8 +36,7 @@ public class PasswordMaskingUtil
*
* Where only is required. key/value pairs are optional
*/
- public static SensitiveDataCodec getCodec(String codecDesc) throws ActiveMQException
- {
+ public static SensitiveDataCodec getCodec(String codecDesc) throws ActiveMQException {
SensitiveDataCodec codecInstance = null;
// semi colons
@@ -49,29 +48,23 @@ public class PasswordMaskingUtil
final String codecClassName = parts[0];
// load class
- codecInstance = AccessController.doPrivileged(new PrivilegedAction>()
- {
- public SensitiveDataCodec run()
- {
+ codecInstance = AccessController.doPrivileged(new PrivilegedAction>() {
+ public SensitiveDataCodec run() {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
- try
- {
+ try {
Class> clazz = loader.loadClass(codecClassName);
- return (SensitiveDataCodec)clazz.newInstance();
+ return (SensitiveDataCodec) clazz.newInstance();
}
- catch (Exception e)
- {
+ catch (Exception e) {
throw ActiveMQUtilBundle.BUNDLE.errorCreatingCodec(e, codecClassName);
}
}
});
- if (parts.length > 1)
- {
+ if (parts.length > 1) {
Map props = new HashMap();
- for (int i = 1; i < parts.length; i++)
- {
+ for (int i = 1; i < parts.length; i++) {
String[] keyVal = parts[i].split("=");
if (keyVal.length != 2)
throw ActiveMQUtilBundle.BUNDLE.invalidProperty(parts[i]);
@@ -83,8 +76,7 @@ public class PasswordMaskingUtil
return codecInstance;
}
- public static SensitiveDataCodec getDefaultCodec()
- {
+ public static SensitiveDataCodec getDefaultCodec() {
return new DefaultSensitiveStringCodec();
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReferenceCounter.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReferenceCounter.java
index 4261ca799d..2f46fb1b94 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReferenceCounter.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReferenceCounter.java
@@ -16,8 +16,8 @@
*/
package org.apache.activemq.artemis.utils;
-public interface ReferenceCounter
-{
+public interface ReferenceCounter {
+
int increment();
int decrement();
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReferenceCounterUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReferenceCounterUtil.java
index 71106b6176..9507cb8860 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReferenceCounterUtil.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReferenceCounterUtil.java
@@ -19,45 +19,39 @@ package org.apache.activemq.artemis.utils;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicInteger;
-public class ReferenceCounterUtil implements ReferenceCounter
-{
+public class ReferenceCounterUtil implements ReferenceCounter {
+
private final Runnable runnable;
- /** If executor is null the runnable will be called within the same thread, otherwise the executor will be used */
+ /**
+ * If executor is null the runnable will be called within the same thread, otherwise the executor will be used
+ */
private final Executor executor;
private final AtomicInteger uses = new AtomicInteger(0);
-
- public ReferenceCounterUtil(Runnable runnable)
- {
+ public ReferenceCounterUtil(Runnable runnable) {
this(runnable, null);
}
- public ReferenceCounterUtil(Runnable runnable, Executor executor)
- {
+ public ReferenceCounterUtil(Runnable runnable, Executor executor) {
this.runnable = runnable;
this.executor = executor;
}
@Override
- public int increment()
- {
+ public int increment() {
return uses.incrementAndGet();
}
@Override
- public int decrement()
- {
+ public int decrement() {
int value = uses.decrementAndGet();
- if (value == 0)
- {
- if (executor != null)
- {
+ if (value == 0) {
+ if (executor != null) {
executor.execute(runnable);
}
- else
- {
+ else {
runnable.run();
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReusableLatch.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReusableLatch.java
index 1ec85f44ab..4f04f22930 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReusableLatch.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ReusableLatch.java
@@ -20,7 +20,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.AbstractQueuedSynchronizer;
/**
- *
* This class will use the framework provided to by AbstractQueuedSynchronizer.
* AbstractQueuedSynchronizer is the framework for any sort of concurrent synchronization, such as Semaphores, events, etc, based on AtomicIntegers.
*
@@ -33,70 +32,59 @@ import java.util.concurrent.locks.AbstractQueuedSynchronizer;
* Note: This latch is reusable. Once it reaches zero, you can call up again, and reuse it on further waits.
*
* For example: prepareTransaction will wait for the current completions, and further adds will be called on the latch. Later on when commit is called you can reuse the same latch.
- *
*/
-public class ReusableLatch
-{
+public class ReusableLatch {
+
/**
* Look at the doc and examples provided by AbstractQueuedSynchronizer for more information
- * @see AbstractQueuedSynchronizer*/
+ *
+ * @see AbstractQueuedSynchronizer
+ */
@SuppressWarnings("serial")
- private static class CountSync extends AbstractQueuedSynchronizer
- {
- public CountSync(int count)
- {
+ private static class CountSync extends AbstractQueuedSynchronizer {
+
+ public CountSync(int count) {
setState(count);
}
- public int getCount()
- {
+ public int getCount() {
return getState();
}
- public void setCount(final int count)
- {
+ public void setCount(final int count) {
setState(count);
}
@Override
- public int tryAcquireShared(final int numberOfAqcquires)
- {
+ public int tryAcquireShared(final int numberOfAqcquires) {
return getState() == 0 ? 1 : -1;
}
- public void add()
- {
- for (;;)
- {
+ public void add() {
+ for (;;) {
int actualState = getState();
int newState = actualState + 1;
- if (compareAndSetState(actualState, newState))
- {
+ if (compareAndSetState(actualState, newState)) {
return;
}
}
}
@Override
- public boolean tryReleaseShared(final int numberOfReleases)
- {
- for (;;)
- {
+ public boolean tryReleaseShared(final int numberOfReleases) {
+ for (;;) {
int actualState = getState();
- if (actualState == 0)
- {
+ if (actualState == 0) {
return true;
}
int newState = actualState - numberOfReleases;
- if (newState < 0)
- {
+ if (newState < 0) {
newState = 0;
}
- if (compareAndSetState(actualState, newState))
- {
+ if (compareAndSetState(actualState, newState)) {
return newState == 0;
}
}
@@ -105,54 +93,43 @@ public class ReusableLatch
private final CountSync control;
- public ReusableLatch()
- {
+ public ReusableLatch() {
this(0);
}
- public ReusableLatch(final int count)
- {
+ public ReusableLatch(final int count) {
control = new CountSync(count);
}
- public int getCount()
- {
+ public int getCount() {
return control.getCount();
}
- public void setCount(final int count)
- {
+ public void setCount(final int count) {
control.setCount(count);
}
- public void countUp()
- {
+ public void countUp() {
control.add();
}
- public void countDown()
- {
+ public void countDown() {
control.releaseShared(1);
}
-
- public void countDown(final int count)
- {
+ public void countDown(final int count) {
control.releaseShared(count);
}
- public void await() throws InterruptedException
- {
+ public void await() throws InterruptedException {
control.acquireSharedInterruptibly(1);
}
- public boolean await(final long milliseconds) throws InterruptedException
- {
+ public boolean await(final long milliseconds) throws InterruptedException {
return control.tryAcquireSharedNanos(1, TimeUnit.MILLISECONDS.toNanos(milliseconds));
}
- public boolean await(final long timeWait, TimeUnit timeUnit) throws InterruptedException
- {
+ public boolean await(final long timeWait, TimeUnit timeUnit) throws InterruptedException {
return control.tryAcquireSharedNanos(1, timeUnit.toNanos(timeWait));
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/SensitiveDataCodec.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/SensitiveDataCodec.java
index a47bf85823..b1bfd2b74b 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/SensitiveDataCodec.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/SensitiveDataCodec.java
@@ -25,8 +25,8 @@ import java.util.Map;
*
* It takes in a mask value and decode it.
*/
-public interface SensitiveDataCodec
-{
+public interface SensitiveDataCodec {
+
T decode(Object mask) throws Exception;
void init(Map params);
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/TypedProperties.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/TypedProperties.java
index 645c3efb95..432e46ff2c 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/TypedProperties.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/TypedProperties.java
@@ -49,8 +49,7 @@ import static org.apache.activemq.artemis.utils.DataConstants.STRING;
*
* TODO - should have typed property getters and do conversions herein
*/
-public final class TypedProperties
-{
+public final class TypedProperties {
private static final SimpleString AMQ_PROPNAME = new SimpleString("_AMQ_");
@@ -60,12 +59,10 @@ public final class TypedProperties
private boolean internalProperties;
- public TypedProperties()
- {
+ public TypedProperties() {
}
- public int getMemoryOffset()
- {
+ public int getMemoryOffset() {
// The estimate is basically the encode size + 2 object references for each entry in the map
// Note we don't include the attributes or anything else since they already included in the memory estimate
// of the ServerMessage
@@ -73,403 +70,316 @@ public final class TypedProperties
return properties == null ? 0 : size + 2 * DataConstants.SIZE_INT * properties.size();
}
- public TypedProperties(final TypedProperties other)
- {
+ public TypedProperties(final TypedProperties other) {
properties = other.properties == null ? null : new HashMap(other.properties);
size = other.size;
}
- public boolean hasInternalProperties()
- {
+ public boolean hasInternalProperties() {
return internalProperties;
}
- public void putBooleanProperty(final SimpleString key, final boolean value)
- {
+ public void putBooleanProperty(final SimpleString key, final boolean value) {
checkCreateProperties();
doPutValue(key, new BooleanValue(value));
}
- public void putByteProperty(final SimpleString key, final byte value)
- {
+ public void putByteProperty(final SimpleString key, final byte value) {
checkCreateProperties();
doPutValue(key, new ByteValue(value));
}
- public void putBytesProperty(final SimpleString key, final byte[] value)
- {
+ public void putBytesProperty(final SimpleString key, final byte[] value) {
checkCreateProperties();
doPutValue(key, value == null ? new NullValue() : new BytesValue(value));
}
- public void putShortProperty(final SimpleString key, final short value)
- {
+ public void putShortProperty(final SimpleString key, final short value) {
checkCreateProperties();
doPutValue(key, new ShortValue(value));
}
- public void putIntProperty(final SimpleString key, final int value)
- {
+ public void putIntProperty(final SimpleString key, final int value) {
checkCreateProperties();
doPutValue(key, new IntValue(value));
}
- public void putLongProperty(final SimpleString key, final long value)
- {
+ public void putLongProperty(final SimpleString key, final long value) {
checkCreateProperties();
doPutValue(key, new LongValue(value));
}
- public void putFloatProperty(final SimpleString key, final float value)
- {
+ public void putFloatProperty(final SimpleString key, final float value) {
checkCreateProperties();
doPutValue(key, new FloatValue(value));
}
- public void putDoubleProperty(final SimpleString key, final double value)
- {
+ public void putDoubleProperty(final SimpleString key, final double value) {
checkCreateProperties();
doPutValue(key, new DoubleValue(value));
}
- public void putSimpleStringProperty(final SimpleString key, final SimpleString value)
- {
+ public void putSimpleStringProperty(final SimpleString key, final SimpleString value) {
checkCreateProperties();
doPutValue(key, value == null ? new NullValue() : new StringValue(value));
}
- public void putNullValue(final SimpleString key)
- {
+ public void putNullValue(final SimpleString key) {
checkCreateProperties();
doPutValue(key, new NullValue());
}
- public void putCharProperty(final SimpleString key, final char value)
- {
+ public void putCharProperty(final SimpleString key, final char value) {
checkCreateProperties();
doPutValue(key, new CharValue(value));
}
- public void putTypedProperties(final TypedProperties otherProps)
- {
- if (otherProps == null || otherProps.properties == null)
- {
+ public void putTypedProperties(final TypedProperties otherProps) {
+ if (otherProps == null || otherProps.properties == null) {
return;
}
checkCreateProperties();
Set> otherEntries = otherProps.properties.entrySet();
- for (Entry otherEntry : otherEntries)
- {
+ for (Entry otherEntry : otherEntries) {
doPutValue(otherEntry.getKey(), otherEntry.getValue());
}
}
- public Object getProperty(final SimpleString key)
- {
+ public Object getProperty(final SimpleString key) {
return doGetProperty(key);
}
- public Boolean getBooleanProperty(final SimpleString key) throws ActiveMQPropertyConversionException
- {
+ public Boolean getBooleanProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
Object value = doGetProperty(key);
- if (value == null)
- {
+ if (value == null) {
return Boolean.valueOf(null);
}
- else if (value instanceof Boolean)
- {
+ else if (value instanceof Boolean) {
return (Boolean) value;
}
- else if (value instanceof SimpleString)
- {
+ else if (value instanceof SimpleString) {
return Boolean.valueOf(((SimpleString) value).toString());
}
- else
- {
+ else {
throw new ActiveMQPropertyConversionException("Invalid conversion");
}
}
- public Byte getByteProperty(final SimpleString key) throws ActiveMQPropertyConversionException
- {
+ public Byte getByteProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
Object value = doGetProperty(key);
- if (value == null)
- {
+ if (value == null) {
return Byte.valueOf(null);
}
- else if (value instanceof Byte)
- {
+ else if (value instanceof Byte) {
return (Byte) value;
}
- else if (value instanceof SimpleString)
- {
+ else if (value instanceof SimpleString) {
return Byte.parseByte(((SimpleString) value).toString());
}
- else
- {
+ else {
throw new ActiveMQPropertyConversionException("Invalid conversion");
}
}
- public Character getCharProperty(final SimpleString key) throws ActiveMQPropertyConversionException
- {
+ public Character getCharProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
Object value = doGetProperty(key);
- if (value == null)
- {
+ if (value == null) {
throw new NullPointerException("Invalid conversion");
}
- if (value instanceof Character)
- {
+ if (value instanceof Character) {
return ((Character) value);
}
- else
- {
+ else {
throw new ActiveMQPropertyConversionException("Invalid conversion");
}
}
- public byte[] getBytesProperty(final SimpleString key) throws ActiveMQPropertyConversionException
- {
+ public byte[] getBytesProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
Object value = doGetProperty(key);
- if (value == null)
- {
+ if (value == null) {
return null;
}
- else if (value instanceof byte[])
- {
+ else if (value instanceof byte[]) {
return (byte[]) value;
}
- else
- {
+ else {
throw new ActiveMQPropertyConversionException("Invalid conversion");
}
}
- public Double getDoubleProperty(final SimpleString key) throws ActiveMQPropertyConversionException
- {
+ public Double getDoubleProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
Object value = doGetProperty(key);
- if (value == null)
- {
+ if (value == null) {
return Double.valueOf(null);
}
- else if (value instanceof Float)
- {
+ else if (value instanceof Float) {
return ((Float) value).doubleValue();
}
- else if (value instanceof Double)
- {
+ else if (value instanceof Double) {
return (Double) value;
}
- else if (value instanceof SimpleString)
- {
+ else if (value instanceof SimpleString) {
return Double.parseDouble(((SimpleString) value).toString());
}
- else
- {
+ else {
throw new ActiveMQPropertyConversionException("Invalid conversion");
}
}
- public Integer getIntProperty(final SimpleString key) throws ActiveMQPropertyConversionException
- {
+ public Integer getIntProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
Object value = doGetProperty(key);
- if (value == null)
- {
+ if (value == null) {
return Integer.valueOf(null);
}
- else if (value instanceof Integer)
- {
+ else if (value instanceof Integer) {
return (Integer) value;
}
- else if (value instanceof Byte)
- {
+ else if (value instanceof Byte) {
return ((Byte) value).intValue();
}
- else if (value instanceof Short)
- {
+ else if (value instanceof Short) {
return ((Short) value).intValue();
}
- else if (value instanceof SimpleString)
- {
+ else if (value instanceof SimpleString) {
return Integer.parseInt(((SimpleString) value).toString());
}
- else
- {
+ else {
throw new ActiveMQPropertyConversionException("Invalid conversion");
}
}
- public Long getLongProperty(final SimpleString key) throws ActiveMQPropertyConversionException
- {
+ public Long getLongProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
Object value = doGetProperty(key);
- if (value == null)
- {
+ if (value == null) {
return Long.valueOf(null);
}
- else if (value instanceof Long)
- {
+ else if (value instanceof Long) {
return (Long) value;
}
- else if (value instanceof Byte)
- {
+ else if (value instanceof Byte) {
return ((Byte) value).longValue();
}
- else if (value instanceof Short)
- {
+ else if (value instanceof Short) {
return ((Short) value).longValue();
}
- else if (value instanceof Integer)
- {
+ else if (value instanceof Integer) {
return ((Integer) value).longValue();
}
- else if (value instanceof SimpleString)
- {
+ else if (value instanceof SimpleString) {
return Long.parseLong(((SimpleString) value).toString());
}
- else
- {
+ else {
throw new ActiveMQPropertyConversionException("Invalid conversion");
}
}
- public Short getShortProperty(final SimpleString key) throws ActiveMQPropertyConversionException
- {
+ public Short getShortProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
Object value = doGetProperty(key);
- if (value == null)
- {
+ if (value == null) {
return Short.valueOf(null);
}
- else if (value instanceof Byte)
- {
+ else if (value instanceof Byte) {
return ((Byte) value).shortValue();
}
- else if (value instanceof Short)
- {
+ else if (value instanceof Short) {
return (Short) value;
}
- else if (value instanceof SimpleString)
- {
+ else if (value instanceof SimpleString) {
return Short.parseShort(((SimpleString) value).toString());
}
- else
- {
+ else {
throw new ActiveMQPropertyConversionException("Invalid Conversion.");
}
}
- public Float getFloatProperty(final SimpleString key) throws ActiveMQPropertyConversionException
- {
+ public Float getFloatProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
Object value = doGetProperty(key);
if (value == null)
return Float.valueOf(null);
- if (value instanceof Float)
- {
+ if (value instanceof Float) {
return ((Float) value);
}
- if (value instanceof SimpleString)
- {
+ if (value instanceof SimpleString) {
return Float.parseFloat(((SimpleString) value).toString());
}
throw new ActiveMQPropertyConversionException("Invalid conversion: " + key);
}
- public SimpleString getSimpleStringProperty(final SimpleString key) throws ActiveMQPropertyConversionException
- {
+ public SimpleString getSimpleStringProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
Object value = doGetProperty(key);
- if (value == null)
- {
+ if (value == null) {
return null;
}
- if (value instanceof SimpleString)
- {
+ if (value instanceof SimpleString) {
return (SimpleString) value;
}
- else if (value instanceof Boolean)
- {
+ else if (value instanceof Boolean) {
return new SimpleString(value.toString());
}
- else if (value instanceof Character)
- {
+ else if (value instanceof Character) {
return new SimpleString(value.toString());
}
- else if (value instanceof Byte)
- {
+ else if (value instanceof Byte) {
return new SimpleString(value.toString());
}
- else if (value instanceof Short)
- {
+ else if (value instanceof Short) {
return new SimpleString(value.toString());
}
- else if (value instanceof Integer)
- {
+ else if (value instanceof Integer) {
return new SimpleString(value.toString());
}
- else if (value instanceof Long)
- {
+ else if (value instanceof Long) {
return new SimpleString(value.toString());
}
- else if (value instanceof Float)
- {
+ else if (value instanceof Float) {
return new SimpleString(value.toString());
}
- else if (value instanceof Double)
- {
+ else if (value instanceof Double) {
return new SimpleString(value.toString());
}
throw new ActiveMQPropertyConversionException("Invalid conversion");
}
- public Object removeProperty(final SimpleString key)
- {
+ public Object removeProperty(final SimpleString key) {
return doRemoveProperty(key);
}
- public boolean containsProperty(final SimpleString key)
- {
- if (size == 0)
- {
+ public boolean containsProperty(final SimpleString key) {
+ if (size == 0) {
return false;
}
- else
- {
+ else {
return properties.containsKey(key);
}
}
- public Set getPropertyNames()
- {
- if (size == 0)
- {
+ public Set getPropertyNames() {
+ if (size == 0) {
return Collections.emptySet();
}
- else
- {
+ else {
return properties.keySet();
}
}
- public synchronized void decode(final ActiveMQBuffer buffer)
- {
+ public synchronized void decode(final ActiveMQBuffer buffer) {
byte b = buffer.readByte();
- if (b == DataConstants.NULL)
- {
+ if (b == DataConstants.NULL) {
properties = null;
}
- else
- {
+ else {
int numHeaders = buffer.readInt();
properties = new HashMap(numHeaders);
size = 0;
- for (int i = 0; i < numHeaders; i++)
- {
+ for (int i = 0; i < numHeaders; i++) {
int len = buffer.readInt();
byte[] data = new byte[len];
buffer.readBytes(data);
@@ -479,76 +389,63 @@ public final class TypedProperties
PropertyValue val;
- switch (type)
- {
- case NULL:
- {
+ switch (type) {
+ case NULL: {
val = new NullValue();
doPutValue(key, val);
break;
}
- case CHAR:
- {
+ case CHAR: {
val = new CharValue(buffer);
doPutValue(key, val);
break;
}
- case BOOLEAN:
- {
+ case BOOLEAN: {
val = new BooleanValue(buffer);
doPutValue(key, val);
break;
}
- case BYTE:
- {
+ case BYTE: {
val = new ByteValue(buffer);
doPutValue(key, val);
break;
}
- case BYTES:
- {
+ case BYTES: {
val = new BytesValue(buffer);
doPutValue(key, val);
break;
}
- case SHORT:
- {
+ case SHORT: {
val = new ShortValue(buffer);
doPutValue(key, val);
break;
}
- case INT:
- {
+ case INT: {
val = new IntValue(buffer);
doPutValue(key, val);
break;
}
- case LONG:
- {
+ case LONG: {
val = new LongValue(buffer);
doPutValue(key, val);
break;
}
- case FLOAT:
- {
+ case FLOAT: {
val = new FloatValue(buffer);
doPutValue(key, val);
break;
}
- case DOUBLE:
- {
+ case DOUBLE: {
val = new DoubleValue(buffer);
doPutValue(key, val);
break;
}
- case STRING:
- {
+ case STRING: {
val = new StringValue(buffer);
doPutValue(key, val);
break;
}
- default:
- {
+ default: {
throw ActiveMQUtilBundle.BUNDLE.invalidType(type);
}
}
@@ -556,20 +453,16 @@ public final class TypedProperties
}
}
- public synchronized void encode(final ActiveMQBuffer buffer)
- {
- if (properties == null)
- {
+ public synchronized void encode(final ActiveMQBuffer buffer) {
+ if (properties == null) {
buffer.writeByte(DataConstants.NULL);
}
- else
- {
+ else {
buffer.writeByte(DataConstants.NOT_NULL);
buffer.writeInt(properties.size());
- for (Map.Entry entry : properties.entrySet())
- {
+ for (Map.Entry entry : properties.entrySet()) {
SimpleString s = entry.getKey();
byte[] data = s.getData();
buffer.writeInt(data.length);
@@ -580,39 +473,30 @@ public final class TypedProperties
}
}
- public int getEncodeSize()
- {
- if (properties == null)
- {
+ public int getEncodeSize() {
+ if (properties == null) {
return DataConstants.SIZE_BYTE;
}
- else
- {
+ else {
return DataConstants.SIZE_BYTE + DataConstants.SIZE_INT + size;
}
}
- public void clear()
- {
- if (properties != null)
- {
+ public void clear() {
+ if (properties != null) {
properties.clear();
}
}
@Override
- public String toString()
- {
+ public String toString() {
StringBuilder sb = new StringBuilder("TypedProperties[");
-
- if (properties != null)
- {
+ if (properties != null) {
Iterator> iter = properties.entrySet().iterator();
- while (iter.hasNext())
- {
+ while (iter.hasNext()) {
Entry iterItem = iter.next();
sb.append(iterItem.getKey() + "=");
@@ -621,46 +505,35 @@ public final class TypedProperties
// The second is to convert the PropertyValue into the actual value
Object theValue = iterItem.getValue().getValue();
-
- if (theValue == null)
- {
+ if (theValue == null) {
sb.append("NULL-value");
}
- else if (theValue instanceof byte[])
- {
- sb.append("[" + ByteUtil.maxString(ByteUtil.bytesToHex((byte [])theValue, 2), 150) + ")");
+ else if (theValue instanceof byte[]) {
+ sb.append("[" + ByteUtil.maxString(ByteUtil.bytesToHex((byte[]) theValue, 2), 150) + ")");
- if (iterItem.getKey().toString().startsWith("_AMQ_ROUTE_TO"))
- {
+ if (iterItem.getKey().toString().startsWith("_AMQ_ROUTE_TO")) {
sb.append(",bytesAsLongs(");
- try
- {
+ try {
ByteBuffer buff = ByteBuffer.wrap((byte[]) theValue);
- while (buff.hasRemaining())
- {
+ while (buff.hasRemaining()) {
long bindingID = buff.getLong();
sb.append(bindingID);
- if (buff.hasRemaining())
- {
+ if (buff.hasRemaining()) {
sb.append(",");
}
}
}
- catch (Throwable e)
- {
+ catch (Throwable e) {
sb.append("error-converting-longs=" + e.getMessage());
}
sb.append("]");
}
}
- else
- {
+ else {
sb.append(theValue.toString());
}
-
- if (iter.hasNext())
- {
+ if (iter.hasNext()) {
sb.append(",");
}
}
@@ -671,76 +544,62 @@ public final class TypedProperties
// Private ------------------------------------------------------------------------------------
- private void checkCreateProperties()
- {
- if (properties == null)
- {
+ private void checkCreateProperties() {
+ if (properties == null) {
properties = new HashMap();
}
}
- private synchronized void doPutValue(final SimpleString key, final PropertyValue value)
- {
- if (key.startsWith(AMQ_PROPNAME))
- {
+ private synchronized void doPutValue(final SimpleString key, final PropertyValue value) {
+ if (key.startsWith(AMQ_PROPNAME)) {
internalProperties = true;
}
PropertyValue oldValue = properties.put(key, value);
- if (oldValue != null)
- {
+ if (oldValue != null) {
size += value.encodeSize() - oldValue.encodeSize();
}
- else
- {
+ else {
size += SimpleString.sizeofString(key) + value.encodeSize();
}
}
- private synchronized Object doRemoveProperty(final SimpleString key)
- {
- if (properties == null)
- {
+ private synchronized Object doRemoveProperty(final SimpleString key) {
+ if (properties == null) {
return null;
}
PropertyValue val = properties.remove(key);
- if (val == null)
- {
+ if (val == null) {
return null;
}
- else
- {
+ else {
size -= SimpleString.sizeofString(key) + val.encodeSize();
return val.getValue();
}
}
- private synchronized Object doGetProperty(final Object key)
- {
- if (size == 0)
- {
+ private synchronized Object doGetProperty(final Object key) {
+ if (size == 0) {
return null;
}
PropertyValue val = properties.get(key);
- if (val == null)
- {
+ if (val == null) {
return null;
}
- else
- {
+ else {
return val.getValue();
}
}
// Inner classes ------------------------------------------------------------------------------
- private abstract static class PropertyValue
- {
+ private abstract static class PropertyValue {
+
abstract Object getValue();
abstract void write(ActiveMQBuffer buffer);
@@ -748,401 +607,341 @@ public final class TypedProperties
abstract int encodeSize();
@Override
- public String toString()
- {
+ public String toString() {
return "" + getValue();
}
}
- private static final class NullValue extends PropertyValue
- {
- public NullValue()
- {
+ private static final class NullValue extends PropertyValue {
+
+ public NullValue() {
}
@Override
- public Object getValue()
- {
+ public Object getValue() {
return null;
}
@Override
- public void write(final ActiveMQBuffer buffer)
- {
+ public void write(final ActiveMQBuffer buffer) {
buffer.writeByte(DataConstants.NULL);
}
@Override
- public int encodeSize()
- {
+ public int encodeSize() {
return DataConstants.SIZE_BYTE;
}
}
- private static final class BooleanValue extends PropertyValue
- {
+ private static final class BooleanValue extends PropertyValue {
+
final boolean val;
- public BooleanValue(final boolean val)
- {
+ public BooleanValue(final boolean val) {
this.val = val;
}
- public BooleanValue(final ActiveMQBuffer buffer)
- {
+ public BooleanValue(final ActiveMQBuffer buffer) {
val = buffer.readBoolean();
}
@Override
- public Object getValue()
- {
+ public Object getValue() {
return val;
}
@Override
- public void write(final ActiveMQBuffer buffer)
- {
+ public void write(final ActiveMQBuffer buffer) {
buffer.writeByte(DataConstants.BOOLEAN);
buffer.writeBoolean(val);
}
@Override
- public int encodeSize()
- {
+ public int encodeSize() {
return DataConstants.SIZE_BYTE + DataConstants.SIZE_BOOLEAN;
}
}
- private static final class ByteValue extends PropertyValue
- {
+ private static final class ByteValue extends PropertyValue {
+
final byte val;
- public ByteValue(final byte val)
- {
+ public ByteValue(final byte val) {
this.val = val;
}
- public ByteValue(final ActiveMQBuffer buffer)
- {
+ public ByteValue(final ActiveMQBuffer buffer) {
val = buffer.readByte();
}
@Override
- public Object getValue()
- {
+ public Object getValue() {
return val;
}
@Override
- public void write(final ActiveMQBuffer buffer)
- {
+ public void write(final ActiveMQBuffer buffer) {
buffer.writeByte(DataConstants.BYTE);
buffer.writeByte(val);
}
@Override
- public int encodeSize()
- {
+ public int encodeSize() {
return DataConstants.SIZE_BYTE + DataConstants.SIZE_BYTE;
}
}
- private static final class BytesValue extends PropertyValue
- {
+ private static final class BytesValue extends PropertyValue {
+
final byte[] val;
- public BytesValue(final byte[] val)
- {
+ public BytesValue(final byte[] val) {
this.val = val;
}
- public BytesValue(final ActiveMQBuffer buffer)
- {
+ public BytesValue(final ActiveMQBuffer buffer) {
int len = buffer.readInt();
val = new byte[len];
buffer.readBytes(val);
}
@Override
- public Object getValue()
- {
+ public Object getValue() {
return val;
}
@Override
- public void write(final ActiveMQBuffer buffer)
- {
+ public void write(final ActiveMQBuffer buffer) {
buffer.writeByte(DataConstants.BYTES);
buffer.writeInt(val.length);
buffer.writeBytes(val);
}
@Override
- public int encodeSize()
- {
+ public int encodeSize() {
return DataConstants.SIZE_BYTE + DataConstants.SIZE_INT + val.length;
}
}
- private static final class ShortValue extends PropertyValue
- {
+ private static final class ShortValue extends PropertyValue {
+
final short val;
- public ShortValue(final short val)
- {
+ public ShortValue(final short val) {
this.val = val;
}
- public ShortValue(final ActiveMQBuffer buffer)
- {
+ public ShortValue(final ActiveMQBuffer buffer) {
val = buffer.readShort();
}
@Override
- public Object getValue()
- {
+ public Object getValue() {
return val;
}
@Override
- public void write(final ActiveMQBuffer buffer)
- {
+ public void write(final ActiveMQBuffer buffer) {
buffer.writeByte(DataConstants.SHORT);
buffer.writeShort(val);
}
@Override
- public int encodeSize()
- {
+ public int encodeSize() {
return DataConstants.SIZE_BYTE + DataConstants.SIZE_SHORT;
}
}
- private static final class IntValue extends PropertyValue
- {
+ private static final class IntValue extends PropertyValue {
+
final int val;
- public IntValue(final int val)
- {
+ public IntValue(final int val) {
this.val = val;
}
- public IntValue(final ActiveMQBuffer buffer)
- {
+ public IntValue(final ActiveMQBuffer buffer) {
val = buffer.readInt();
}
@Override
- public Object getValue()
- {
+ public Object getValue() {
return val;
}
@Override
- public void write(final ActiveMQBuffer buffer)
- {
+ public void write(final ActiveMQBuffer buffer) {
buffer.writeByte(DataConstants.INT);
buffer.writeInt(val);
}
@Override
- public int encodeSize()
- {
+ public int encodeSize() {
return DataConstants.SIZE_BYTE + DataConstants.SIZE_INT;
}
}
- private static final class LongValue extends PropertyValue
- {
+ private static final class LongValue extends PropertyValue {
+
final long val;
- public LongValue(final long val)
- {
+ public LongValue(final long val) {
this.val = val;
}
- public LongValue(final ActiveMQBuffer buffer)
- {
+ public LongValue(final ActiveMQBuffer buffer) {
val = buffer.readLong();
}
@Override
- public Object getValue()
- {
+ public Object getValue() {
return val;
}
@Override
- public void write(final ActiveMQBuffer buffer)
- {
+ public void write(final ActiveMQBuffer buffer) {
buffer.writeByte(DataConstants.LONG);
buffer.writeLong(val);
}
@Override
- public int encodeSize()
- {
+ public int encodeSize() {
return DataConstants.SIZE_BYTE + DataConstants.SIZE_LONG;
}
}
- private static final class FloatValue extends PropertyValue
- {
+ private static final class FloatValue extends PropertyValue {
+
final float val;
- public FloatValue(final float val)
- {
+ public FloatValue(final float val) {
this.val = val;
}
- public FloatValue(final ActiveMQBuffer buffer)
- {
+ public FloatValue(final ActiveMQBuffer buffer) {
val = Float.intBitsToFloat(buffer.readInt());
}
@Override
- public Object getValue()
- {
+ public Object getValue() {
return val;
}
@Override
- public void write(final ActiveMQBuffer buffer)
- {
+ public void write(final ActiveMQBuffer buffer) {
buffer.writeByte(DataConstants.FLOAT);
buffer.writeInt(Float.floatToIntBits(val));
}
@Override
- public int encodeSize()
- {
+ public int encodeSize() {
return DataConstants.SIZE_BYTE + DataConstants.SIZE_FLOAT;
}
}
- private static final class DoubleValue extends PropertyValue
- {
+ private static final class DoubleValue extends PropertyValue {
+
final double val;
- public DoubleValue(final double val)
- {
+ public DoubleValue(final double val) {
this.val = val;
}
- public DoubleValue(final ActiveMQBuffer buffer)
- {
+ public DoubleValue(final ActiveMQBuffer buffer) {
val = Double.longBitsToDouble(buffer.readLong());
}
@Override
- public Object getValue()
- {
+ public Object getValue() {
return val;
}
@Override
- public void write(final ActiveMQBuffer buffer)
- {
+ public void write(final ActiveMQBuffer buffer) {
buffer.writeByte(DataConstants.DOUBLE);
buffer.writeLong(Double.doubleToLongBits(val));
}
@Override
- public int encodeSize()
- {
+ public int encodeSize() {
return DataConstants.SIZE_BYTE + DataConstants.SIZE_DOUBLE;
}
}
- private static final class CharValue extends PropertyValue
- {
+ private static final class CharValue extends PropertyValue {
+
final char val;
- public CharValue(final char val)
- {
+ public CharValue(final char val) {
this.val = val;
}
- public CharValue(final ActiveMQBuffer buffer)
- {
+ public CharValue(final ActiveMQBuffer buffer) {
val = (char) buffer.readShort();
}
@Override
- public Object getValue()
- {
+ public Object getValue() {
return val;
}
@Override
- public void write(final ActiveMQBuffer buffer)
- {
+ public void write(final ActiveMQBuffer buffer) {
buffer.writeByte(DataConstants.CHAR);
buffer.writeShort((short) val);
}
@Override
- public int encodeSize()
- {
+ public int encodeSize() {
return DataConstants.SIZE_BYTE + DataConstants.SIZE_CHAR;
}
}
- private static final class StringValue extends PropertyValue
- {
+ private static final class StringValue extends PropertyValue {
+
final SimpleString val;
- public StringValue(final SimpleString val)
- {
+ public StringValue(final SimpleString val) {
this.val = val;
}
- public StringValue(final ActiveMQBuffer buffer)
- {
+ public StringValue(final ActiveMQBuffer buffer) {
val = buffer.readSimpleString();
}
@Override
- public Object getValue()
- {
+ public Object getValue() {
return val;
}
@Override
- public void write(final ActiveMQBuffer buffer)
- {
+ public void write(final ActiveMQBuffer buffer) {
buffer.writeByte(DataConstants.STRING);
buffer.writeSimpleString(val);
}
@Override
- public int encodeSize()
- {
+ public int encodeSize() {
return DataConstants.SIZE_BYTE + SimpleString.sizeofString(val);
}
}
- public boolean isEmpty()
- {
+ public boolean isEmpty() {
return properties.isEmpty();
}
- public Map getMap()
- {
+ public Map getMap() {
Map m = new HashMap();
- for (Entry entry : properties.entrySet())
- {
+ for (Entry entry : properties.entrySet()) {
Object val = entry.getValue().getValue();
- if (val instanceof SimpleString)
- {
+ if (val instanceof SimpleString) {
m.put(entry.getKey().toString(), ((SimpleString) val).toString());
}
- else
- {
+ else {
m.put(entry.getKey().toString(), val);
}
}
@@ -1152,62 +951,48 @@ public final class TypedProperties
/**
* Helper for MapMessage#setObjectProperty(String, Object)
*
- * @param key The SimpleString key
- * @param value The Object value
+ * @param key The SimpleString key
+ * @param value The Object value
* @param properties The typed properties
*/
- public static void setObjectProperty(final SimpleString key, final Object value, final TypedProperties properties)
- {
- if (value == null)
- {
+ public static void setObjectProperty(final SimpleString key, final Object value, final TypedProperties properties) {
+ if (value == null) {
properties.putNullValue(key);
}
- else if (value instanceof Boolean)
- {
+ else if (value instanceof Boolean) {
properties.putBooleanProperty(key, (Boolean) value);
}
- else if (value instanceof Byte)
- {
+ else if (value instanceof Byte) {
properties.putByteProperty(key, (Byte) value);
}
- else if (value instanceof Character)
- {
+ else if (value instanceof Character) {
properties.putCharProperty(key, (Character) value);
}
- else if (value instanceof Short)
- {
+ else if (value instanceof Short) {
properties.putShortProperty(key, (Short) value);
}
- else if (value instanceof Integer)
- {
+ else if (value instanceof Integer) {
properties.putIntProperty(key, (Integer) value);
}
- else if (value instanceof Long)
- {
+ else if (value instanceof Long) {
properties.putLongProperty(key, (Long) value);
}
- else if (value instanceof Float)
- {
+ else if (value instanceof Float) {
properties.putFloatProperty(key, (Float) value);
}
- else if (value instanceof Double)
- {
+ else if (value instanceof Double) {
properties.putDoubleProperty(key, (Double) value);
}
- else if (value instanceof String)
- {
+ else if (value instanceof String) {
properties.putSimpleStringProperty(key, new SimpleString((String) value));
}
- else if (value instanceof SimpleString)
- {
+ else if (value instanceof SimpleString) {
properties.putSimpleStringProperty(key, (SimpleString) value);
}
- else if (value instanceof byte[])
- {
+ else if (value instanceof byte[]) {
properties.putBytesProperty(key, (byte[]) value);
}
- else
- {
+ else {
throw new ActiveMQPropertyConversionException(value.getClass() + " is not a valid property type");
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java
index 9aaf1a0113..18dca846c3 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java
@@ -27,53 +27,43 @@ import org.apache.activemq.artemis.logs.ActiveMQUtilLogger;
*
* This class will write UTFs directly to the ByteOutput (through the MessageBuffer interface)
*/
-public final class UTF8Util
-{
- private UTF8Util()
- {
+public final class UTF8Util {
+
+ private UTF8Util() {
// utility class
}
private static final boolean isTrace = ActiveMQUtilLogger.LOGGER.isTraceEnabled();
- private static final ThreadLocal> currenBuffer =
- new ThreadLocal>();
+ private static final ThreadLocal> currenBuffer = new ThreadLocal>();
- public static void saveUTF(final ActiveMQBuffer out, final String str)
- {
+ public static void saveUTF(final ActiveMQBuffer out, final String str) {
StringUtilBuffer buffer = UTF8Util.getThreadLocalBuffer();
- if (str.length() > 0xffff)
- {
+ if (str.length() > 0xffff) {
throw ActiveMQUtilBundle.BUNDLE.stringTooLong(str.length());
}
final int len = UTF8Util.calculateUTFSize(str, buffer);
- if (len > 0xffff)
- {
+ if (len > 0xffff) {
throw ActiveMQUtilBundle.BUNDLE.stringTooLong(len);
}
- out.writeShort((short)len);
+ out.writeShort((short) len);
- if (len > buffer.byteBuffer.length)
- {
+ if (len > buffer.byteBuffer.length) {
buffer.resizeByteBuffer(len);
}
- if (len == (long)str.length())
- {
- for (int byteLocation = 0; byteLocation < len; byteLocation++)
- {
- buffer.byteBuffer[byteLocation] = (byte)buffer.charBuffer[byteLocation];
+ if (len == (long) str.length()) {
+ for (int byteLocation = 0; byteLocation < len; byteLocation++) {
+ buffer.byteBuffer[byteLocation] = (byte) buffer.charBuffer[byteLocation];
}
out.writeBytes(buffer.byteBuffer, 0, len);
}
- else
- {
- if (UTF8Util.isTrace)
- {
+ else {
+ if (UTF8Util.isTrace) {
// This message is too verbose for debug, that's why we are using trace here
ActiveMQUtilLogger.LOGGER.trace("Saving string with utfSize=" + len + " stringSize=" + str.length());
}
@@ -82,47 +72,39 @@ public final class UTF8Util
int charCount = 0;
- for (int i = 0; i < stringLength; i++)
- {
+ for (int i = 0; i < stringLength; i++) {
char charAtPos = buffer.charBuffer[i];
- if (charAtPos >= 1 && charAtPos < 0x7f)
- {
- buffer.byteBuffer[charCount++] = (byte)charAtPos;
+ if (charAtPos >= 1 && charAtPos < 0x7f) {
+ buffer.byteBuffer[charCount++] = (byte) charAtPos;
}
- else if (charAtPos >= 0x800)
- {
- buffer.byteBuffer[charCount++] = (byte)(0xE0 | charAtPos >> 12 & 0x0F);
- buffer.byteBuffer[charCount++] = (byte)(0x80 | charAtPos >> 6 & 0x3F);
- buffer.byteBuffer[charCount++] = (byte)(0x80 | charAtPos >> 0 & 0x3F);
+ else if (charAtPos >= 0x800) {
+ buffer.byteBuffer[charCount++] = (byte) (0xE0 | charAtPos >> 12 & 0x0F);
+ buffer.byteBuffer[charCount++] = (byte) (0x80 | charAtPos >> 6 & 0x3F);
+ buffer.byteBuffer[charCount++] = (byte) (0x80 | charAtPos >> 0 & 0x3F);
}
- else
- {
- buffer.byteBuffer[charCount++] = (byte)(0xC0 | charAtPos >> 6 & 0x1F);
- buffer.byteBuffer[charCount++] = (byte)(0x80 | charAtPos >> 0 & 0x3F);
+ else {
+ buffer.byteBuffer[charCount++] = (byte) (0xC0 | charAtPos >> 6 & 0x1F);
+ buffer.byteBuffer[charCount++] = (byte) (0x80 | charAtPos >> 0 & 0x3F);
}
}
out.writeBytes(buffer.byteBuffer, 0, len);
}
}
- public static String readUTF(final ActiveMQBuffer input)
- {
+ public static String readUTF(final ActiveMQBuffer input) {
StringUtilBuffer buffer = UTF8Util.getThreadLocalBuffer();
final int size = input.readUnsignedShort();
- if (size > buffer.byteBuffer.length)
- {
+ if (size > buffer.byteBuffer.length) {
buffer.resizeByteBuffer(size);
}
- if (size > buffer.charBuffer.length)
- {
+ if (size > buffer.charBuffer.length) {
buffer.resizeCharBuffer(size);
}
- if (UTF8Util.isTrace)
- {
+ if (UTF8Util.isTrace) {
// This message is too verbose for debug, that's why we are using trace here
ActiveMQUtilLogger.LOGGER.trace("Reading string with utfSize=" + size);
}
@@ -133,28 +115,24 @@ public final class UTF8Util
input.readBytes(buffer.byteBuffer, 0, size);
- while (count < size)
- {
+ while (count < size) {
byte1 = buffer.byteBuffer[count++];
- if (byte1 > 0 && byte1 <= 0x7F)
- {
- buffer.charBuffer[charCount++] = (char)byte1;
+ if (byte1 > 0 && byte1 <= 0x7F) {
+ buffer.charBuffer[charCount++] = (char) byte1;
}
- else
- {
+ else {
int c = byte1 & 0xff;
- switch (c >> 4)
- {
+ switch (c >> 4) {
case 0xc:
case 0xd:
byte2 = buffer.byteBuffer[count++];
- buffer.charBuffer[charCount++] = (char)((c & 0x1F) << 6 | byte2 & 0x3F);
+ buffer.charBuffer[charCount++] = (char) ((c & 0x1F) << 6 | byte2 & 0x3F);
break;
case 0xe:
byte2 = buffer.byteBuffer[count++];
byte3 = buffer.byteBuffer[count++];
- buffer.charBuffer[charCount++] = (char)((c & 0x0F) << 12 | (byte2 & 0x3F) << 6 | (byte3 & 0x3F) << 0);
+ buffer.charBuffer[charCount++] = (char) ((c & 0x0F) << 12 | (byte2 & 0x3F) << 6 | (byte3 & 0x3F) << 0);
break;
default:
throw new InternalError("unhandled utf8 byte " + c);
@@ -166,23 +144,19 @@ public final class UTF8Util
}
- public static StringUtilBuffer getThreadLocalBuffer()
- {
+ public static StringUtilBuffer getThreadLocalBuffer() {
SoftReference softReference = UTF8Util.currenBuffer.get();
StringUtilBuffer value;
- if (softReference == null)
- {
+ if (softReference == null) {
value = new StringUtilBuffer();
softReference = new SoftReference(value);
UTF8Util.currenBuffer.set(softReference);
}
- else
- {
+ else {
value = softReference.get();
}
- if (value == null)
- {
+ if (value == null) {
value = new StringUtilBuffer();
softReference = new SoftReference(value);
UTF8Util.currenBuffer.set(softReference);
@@ -191,78 +165,63 @@ public final class UTF8Util
return value;
}
- public static void clearBuffer()
- {
+ public static void clearBuffer() {
SoftReference ref = UTF8Util.currenBuffer.get();
- if (ref.get() != null)
- {
+ if (ref.get() != null) {
ref.clear();
}
}
- public static int calculateUTFSize(final String str, final StringUtilBuffer stringBuffer)
- {
+ public static int calculateUTFSize(final String str, final StringUtilBuffer stringBuffer) {
int calculatedLen = 0;
int stringLength = str.length();
- if (stringLength > stringBuffer.charBuffer.length)
- {
+ if (stringLength > stringBuffer.charBuffer.length) {
stringBuffer.resizeCharBuffer(stringLength);
}
str.getChars(0, stringLength, stringBuffer.charBuffer, 0);
- for (int i = 0; i < stringLength; i++)
- {
+ for (int i = 0; i < stringLength; i++) {
char c = stringBuffer.charBuffer[i];
- if (c >= 1 && c < 0x7f)
- {
+ if (c >= 1 && c < 0x7f) {
calculatedLen++;
}
- else if (c >= 0x800)
- {
+ else if (c >= 0x800) {
calculatedLen += 3;
}
- else
- {
+ else {
calculatedLen += 2;
}
}
return calculatedLen;
}
- public static class StringUtilBuffer
- {
+ public static class StringUtilBuffer {
public char[] charBuffer;
public byte[] byteBuffer;
- public void resizeCharBuffer(final int newSize)
- {
- if (newSize > charBuffer.length)
- {
+ public void resizeCharBuffer(final int newSize) {
+ if (newSize > charBuffer.length) {
charBuffer = new char[newSize];
}
}
- public void resizeByteBuffer(final int newSize)
- {
- if (newSize > byteBuffer.length)
- {
+ public void resizeByteBuffer(final int newSize) {
+ if (newSize > byteBuffer.length) {
byteBuffer = new byte[newSize];
}
}
- public StringUtilBuffer()
- {
+ public StringUtilBuffer() {
this(1024, 1024);
}
- public StringUtilBuffer(final int sizeChar, final int sizeByte)
- {
+ public StringUtilBuffer(final int sizeChar, final int sizeByte) {
charBuffer = new char[sizeChar];
byteBuffer = new byte[sizeByte];
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUID.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUID.java
index 296f363e83..342bf5dee9 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUID.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUID.java
@@ -16,7 +16,6 @@
*/
package org.apache.activemq.artemis.utils;
-
/**
* UUID represents Universally Unique Identifiers (aka Global UID in Windows
* world). UUIDs are usually generated via UUIDGenerator (or in case of 'Null
@@ -41,8 +40,8 @@ package org.apache.activemq.artemis.utils;
* bytes).
*/
-public final class UUID
-{
+public final class UUID {
+
private static final String kHexChars = "0123456789abcdefABCDEF";
public static final byte INDEX_CLOCK_HI = 6;
@@ -98,8 +97,7 @@ public final class UUID
* @param type UUID type
* @param data 16 byte UUID contents
*/
- public UUID(final int type, final byte[] data)
- {
+ public UUID(final int type, final byte[] data) {
mId = data;
// Type is multiplexed with time_hi:
mId[UUID.INDEX_TYPE] &= (byte) 0x0F;
@@ -109,8 +107,7 @@ public final class UUID
mId[UUID.INDEX_VARIATION] |= (byte) 0x80;
}
- public byte[] asBytes()
- {
+ public byte[] asBytes() {
return mId;
}
@@ -129,27 +126,22 @@ public final class UUID
private static final int[] kShifts = {3, 7, 17, 21, 29, 4, 9};
@Override
- public int hashCode()
- {
- if (mHashCode == 0)
- {
+ public int hashCode() {
+ if (mHashCode == 0) {
// Let's handle first and last byte separately:
int result = mId[0] & 0xFF;
result |= result << 16;
result |= result << 8;
- for (int i = 1; i < 15; i += 2)
- {
+ for (int i = 1; i < 15; i += 2) {
int curr = (mId[i] & 0xFF) << 8 | mId[i + 1] & 0xFF;
int shift = UUID.kShifts[i >> 1];
- if (shift > 16)
- {
+ if (shift > 16) {
result ^= curr << shift | curr >>> 32 - shift;
}
- else
- {
+ else {
result ^= curr << shift;
}
}
@@ -161,12 +153,10 @@ public final class UUID
result ^= last << 27;
// Let's not accept hash 0 as it indicates 'not hashed yet':
- if (result == 0)
- {
+ if (result == 0) {
mHashCode = -1;
}
- else
- {
+ else {
mHashCode = result;
}
}
@@ -174,23 +164,19 @@ public final class UUID
}
@Override
- public String toString()
- {
+ public String toString() {
/*
* Could be synchronized, but there isn't much harm in just taking our
* chances (ie. in the worst case we'll form the string more than once...
* but result is the same)
*/
- if (mDesc == null)
- {
+ if (mDesc == null) {
StringBuffer b = new StringBuffer(36);
- for (int i = 0; i < 16; ++i)
- {
+ for (int i = 0; i < 16; ++i) {
// Need to bypass hyphens:
- switch (i)
- {
+ switch (i) {
case 4:
case 6:
case 8:
@@ -204,8 +190,7 @@ public final class UUID
b.append(UUID.kHexChars.charAt(hex >> 4));
b.append(UUID.kHexChars.charAt(hex & 0x0f));
}
- if (!UUID.sDescCaching)
- {
+ if (!UUID.sDescCaching) {
return b.toString();
}
mDesc = b.toString();
@@ -220,16 +205,12 @@ public final class UUID
* @return byte array that can be used to recreate a UUID instance from the given String
* representation
*/
- public static byte[] stringToBytes(String uuid)
- {
+ public static byte[] stringToBytes(String uuid) {
byte[] data = new byte[16];
int dataIdx = 0;
- try
- {
- for (int i = 0; i < uuid.length(); )
- {
- while (uuid.charAt(i) == '-')
- {
+ try {
+ for (int i = 0; i < uuid.length(); ) {
+ while (uuid.charAt(i) == '-') {
i++;
}
char c1 = uuid.charAt(i);
@@ -240,8 +221,7 @@ public final class UUID
data[dataIdx++] = (byte) ((c1Bytes << 4) + c2Bytes);
}
}
- catch (RuntimeException e)
- {
+ catch (RuntimeException e) {
throw new IllegalArgumentException(e);
}
return data;
@@ -251,18 +231,14 @@ public final class UUID
* Checking equality of UUIDs is easy; just compare the 128-bit number.
*/
@Override
- public boolean equals(final Object o)
- {
- if (!(o instanceof UUID))
- {
+ public boolean equals(final Object o) {
+ if (!(o instanceof UUID)) {
return false;
}
byte[] otherId = ((UUID) o).mId;
byte[] thisId = mId;
- for (int i = 0; i < 16; ++i)
- {
- if (otherId[i] != thisId[i])
- {
+ for (int i = 0; i < 16; ++i) {
+ if (otherId[i] != thisId[i]) {
return false;
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java
index 0be8e7b521..4163cdcf30 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java
@@ -35,8 +35,8 @@ import java.util.concurrent.TimeUnit;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.logs.ActiveMQUtilLogger;
-public final class UUIDGenerator
-{
+public final class UUIDGenerator {
+
private static final UUIDGenerator sSingleton = new UUIDGenerator();
// Windows has some fake adapters that will return the same HARDWARE ADDRESS on any computer. We need to ignore those
@@ -56,8 +56,7 @@ public final class UUIDGenerator
/**
* Constructor is private to enforce singleton access.
*/
- private UUIDGenerator()
- {
+ private UUIDGenerator() {
}
/**
@@ -65,8 +64,7 @@ public final class UUIDGenerator
*
* @return Instance of UUID Generator
*/
- public static UUIDGenerator getInstance()
- {
+ public static UUIDGenerator getInstance() {
return UUIDGenerator.sSingleton;
}
@@ -84,33 +82,27 @@ public final class UUIDGenerator
*
* @return A Random number generator.
*/
- public Random getRandomNumberGenerator()
- {
+ public Random getRandomNumberGenerator() {
/*
* Could be synchronized, but since side effects are trivial (ie.
* possibility of generating more than one SecureRandom, of which all but
* one are dumped) let's not add synchronization overhead:
*/
- if (mRnd == null)
- {
+ if (mRnd == null) {
mRnd = new SecureRandom();
}
return mRnd;
}
- public UUID generateTimeBasedUUID(final byte[] byteAddr)
- {
+ public UUID generateTimeBasedUUID(final byte[] byteAddr) {
byte[] contents = new byte[16];
int pos = 10;
- for (int i = 0; i < 6; ++i)
- {
+ for (int i = 0; i < 6; ++i) {
contents[pos + i] = byteAddr[i];
}
- synchronized (mTimerLock)
- {
- if (mTimer == null)
- {
+ synchronized (mTimerLock) {
+ if (mTimer == null) {
mTimer = new UUIDTimer(getRandomNumberGenerator());
}
@@ -120,8 +112,7 @@ public final class UUIDGenerator
return new UUID(UUID.TYPE_TIME_BASED, contents);
}
- public byte[] generateDummyAddress()
- {
+ public byte[] generateDummyAddress() {
Random rnd = getRandomNumberGenerator();
byte[] dummy = new byte[6];
rnd.nextBytes(dummy);
@@ -130,8 +121,7 @@ public final class UUIDGenerator
*/
dummy[0] |= (byte) 0x01;
- if (ActiveMQUtilLogger.LOGGER.isDebugEnabled())
- {
+ if (ActiveMQUtilLogger.LOGGER.isDebugEnabled()) {
ActiveMQUtilLogger.LOGGER.debug("using dummy address " + UUIDGenerator.asString(dummy));
}
return dummy;
@@ -143,14 +133,12 @@ public final class UUIDGenerator
*
* @return A byte array containing the hardware address.
*/
- public static byte[] getHardwareAddress()
- {
+ public static byte[] getHardwareAddress() {
Method getHardwareAddressMethod;
Method isUpMethod;
Method isLoopbackMethod;
Method isVirtualMethod;
- try
- {
+ try {
getHardwareAddressMethod = NetworkInterface.class.getMethod("getHardwareAddress");
isUpMethod = NetworkInterface.class.getMethod("isUp");
isLoopbackMethod = NetworkInterface.class.getMethod("isLoopback");
@@ -159,49 +147,37 @@ public final class UUIDGenerator
ExecutorService executor = Executors.newFixedThreadPool(0);
executor.shutdownNow();
}
- catch (Throwable t)
- {
+ catch (Throwable t) {
// not on Java 6 or not enough security permission
return null;
}
- try
- {
+ try {
List ifaces = getAllNetworkInterfaces();
- if (ifaces.size() == 0)
- {
+ if (ifaces.size() == 0) {
return null;
}
- byte[] address = findFirstMatchingHardwareAddress(ifaces,
- getHardwareAddressMethod,
- isUpMethod,
- isLoopbackMethod,
- isVirtualMethod);
- if (address != null)
- {
- if (ActiveMQUtilLogger.LOGGER.isDebugEnabled())
- {
+ byte[] address = findFirstMatchingHardwareAddress(ifaces, getHardwareAddressMethod, isUpMethod, isLoopbackMethod, isVirtualMethod);
+ if (address != null) {
+ if (ActiveMQUtilLogger.LOGGER.isDebugEnabled()) {
ActiveMQUtilLogger.LOGGER.debug("using hardware address " + UUIDGenerator.asString(address));
}
return address;
}
return null;
}
- catch (Exception e)
- {
+ catch (Exception e) {
return null;
}
}
- public SimpleString generateSimpleStringUUID()
- {
+ public SimpleString generateSimpleStringUUID() {
return new SimpleString(generateStringUUID());
}
- public UUID generateUUID()
- {
+ public UUID generateUUID() {
byte[] address = getAddressBytes();
UUID uid = generateTimeBasedUUID(address);
@@ -209,39 +185,30 @@ public final class UUIDGenerator
return uid;
}
- public String generateStringUUID()
- {
+ public String generateStringUUID() {
byte[] address = getAddressBytes();
- if (address == null)
- {
+ if (address == null) {
return java.util.UUID.randomUUID().toString();
}
- else
- {
+ else {
return generateTimeBasedUUID(address).toString();
}
}
- public static byte[] getZeroPaddedSixBytes(final byte[] bytes)
- {
- if (bytes == null)
- {
+ public static byte[] getZeroPaddedSixBytes(final byte[] bytes) {
+ if (bytes == null) {
return null;
}
- if (bytes.length > 0 && bytes.length <= 6)
- {
- if (bytes.length == 6)
- {
+ if (bytes.length > 0 && bytes.length <= 6) {
+ if (bytes.length == 6) {
return bytes;
}
- else
- {
+ else {
// pad with zeroes to have a 6-byte array
byte[] paddedAddress = new byte[6];
System.arraycopy(bytes, 0, paddedAddress, 0, bytes.length);
- for (int i = bytes.length; i < 6; i++)
- {
+ for (int i = bytes.length; i < 6; i++) {
paddedAddress[i] = 0;
}
return paddedAddress;
@@ -252,25 +219,19 @@ public final class UUIDGenerator
// Private -------------------------------------------------------
- private static boolean isBlackList(final byte[] address)
- {
- for (byte[] blackList : UUIDGenerator.BLACK_LIST)
- {
- if (Arrays.equals(address, blackList))
- {
+ private static boolean isBlackList(final byte[] address) {
+ for (byte[] blackList : UUIDGenerator.BLACK_LIST) {
+ if (Arrays.equals(address, blackList)) {
return true;
}
}
return false;
}
- private byte[] getAddressBytes()
- {
- if (address == null)
- {
+ private byte[] getAddressBytes() {
+ if (address == null) {
address = UUIDGenerator.getHardwareAddress();
- if (address == null)
- {
+ if (address == null) {
address = generateDummyAddress();
}
}
@@ -278,16 +239,13 @@ public final class UUIDGenerator
return address;
}
- private static String asString(final byte[] bytes)
- {
- if (bytes == null)
- {
+ private static String asString(final byte[] bytes) {
+ if (bytes == null) {
return null;
}
StringBuilder s = new StringBuilder();
- for (int i = 0; i < bytes.length - 1; i++)
- {
+ for (int i = 0; i < bytes.length - 1; i++) {
s.append(Integer.toHexString(bytes[i]));
s.append(":");
}
@@ -295,22 +253,18 @@ public final class UUIDGenerator
return s.toString();
}
- private static List getAllNetworkInterfaces()
- {
+ private static List getAllNetworkInterfaces() {
Enumeration networkInterfaces;
- try
- {
+ try {
networkInterfaces = NetworkInterface.getNetworkInterfaces();
List ifaces = new ArrayList();
- while (networkInterfaces.hasMoreElements())
- {
+ while (networkInterfaces.hasMoreElements()) {
ifaces.add(networkInterfaces.nextElement());
}
return ifaces;
}
- catch (SocketException e)
- {
+ catch (SocketException e) {
return Collections.emptyList();
}
}
@@ -319,40 +273,32 @@ public final class UUIDGenerator
final Method getHardwareAddressMethod,
final Method isUpMethod,
final Method isLoopbackMethod,
- final Method isVirtualMethod)
- {
+ final Method isVirtualMethod) {
ExecutorService executor = Executors.newFixedThreadPool(ifaces.size());
Collection> tasks = new ArrayList>(ifaces.size());
- for (final NetworkInterface networkInterface : ifaces)
- {
- tasks.add(new Callable()
- {
- public byte[] call() throws Exception
- {
+ for (final NetworkInterface networkInterface : ifaces) {
+ tasks.add(new Callable() {
+ public byte[] call() throws Exception {
boolean up = (Boolean) isUpMethod.invoke(networkInterface);
boolean loopback = (Boolean) isLoopbackMethod.invoke(networkInterface);
boolean virtual = (Boolean) isVirtualMethod.invoke(networkInterface);
- if (loopback || virtual || !up)
- {
+ if (loopback || virtual || !up) {
throw new Exception("not suitable interface");
}
Object res = getHardwareAddressMethod.invoke(networkInterface);
- if (res != null && res instanceof byte[])
- {
+ if (res != null && res instanceof byte[]) {
byte[] address = (byte[]) res;
byte[] paddedAddress = UUIDGenerator.getZeroPaddedSixBytes(address);
- if (UUIDGenerator.isBlackList(address))
- {
+ if (UUIDGenerator.isBlackList(address)) {
throw new Exception("black listed address");
}
- if (paddedAddress != null)
- {
+ if (paddedAddress != null) {
return paddedAddress;
}
}
@@ -361,18 +307,15 @@ public final class UUIDGenerator
}
});
}
- try
- {
+ try {
// we wait 5 seconds to get the first matching hardware address. After that, we give up and return null
byte[] address = executor.invokeAny(tasks, 5, TimeUnit.SECONDS);
return address;
}
- catch (Exception e)
- {
+ catch (Exception e) {
return null;
}
- finally
- {
+ finally {
executor.shutdownNow();
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDTimer.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDTimer.java
index 2af53cec60..b60174fad9 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDTimer.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDTimer.java
@@ -65,8 +65,7 @@ import java.util.Random;
* synchronized context (caller locks on either this object, or a similar timer
* lock), and so has no method synchronization.
*/
-public class UUIDTimer
-{
+public class UUIDTimer {
// // // Constants
/**
@@ -126,8 +125,7 @@ public class UUIDTimer
*/
private int mClockCounter = 0;
- UUIDTimer(final Random rnd)
- {
+ UUIDTimer(final Random rnd) {
mRnd = rnd;
initCounters(rnd);
mLastSystemTimestamp = 0L;
@@ -135,8 +133,7 @@ public class UUIDTimer
mLastUsedTimestamp = 0L;
}
- private void initCounters(final Random rnd)
- {
+ private void initCounters(final Random rnd) {
/*
* Let's generate the clock sequence field now; as with counter, this
* reduces likelihood of collisions (as explained in UUID specs)
@@ -152,8 +149,7 @@ public class UUIDTimer
mClockCounter = mClockSequence[2] & 0xFF;
}
- public void getTimestamp(final byte[] uuidData)
- {
+ public void getTimestamp(final byte[] uuidData) {
// First the clock sequence:
uuidData[UUID.INDEX_CLOCK_SEQUENCE] = mClockSequence[0];
uuidData[UUID.INDEX_CLOCK_SEQUENCE + 1] = mClockSequence[1];
@@ -164,8 +160,7 @@ public class UUIDTimer
* Let's first verify that the system time is not going backwards;
* independent of whether we can use it:
*/
- if (systime < mLastSystemTimestamp)
- {
+ if (systime < mLastSystemTimestamp) {
// Logger.logWarning("System time going backwards! (got value
// "+systime+", last "+mLastSystemTimestamp);
// Let's write it down, still
@@ -177,18 +172,15 @@ public class UUIDTimer
* used (when generating UUIDs fast with coarse clock resolution; or if
* clock has gone backwards over reboot etc).
*/
- if (systime <= mLastUsedTimestamp)
- {
+ if (systime <= mLastUsedTimestamp) {
/*
* Can we just use the last time stamp (ok if the counter hasn't hit
* max yet)
*/
- if (mClockCounter < UUIDTimer.kClockMultiplier)
- { // yup, still have room
+ if (mClockCounter < UUIDTimer.kClockMultiplier) { // yup, still have room
systime = mLastUsedTimestamp;
}
- else
- { // nope, have to roll over to next value and maybe wait
+ else { // nope, have to roll over to next value and maybe wait
long actDiff = mLastUsedTimestamp - systime;
long origTime = systime;
systime = mLastUsedTimestamp + 1L;
@@ -209,14 +201,12 @@ public class UUIDTimer
* been moved backwards, or when coarse clock resolution has forced
* us to advance virtual timer too far)
*/
- if (actDiff >= UUIDTimer.kMaxClockAdvance)
- {
+ if (actDiff >= UUIDTimer.kMaxClockAdvance) {
UUIDTimer.slowDown(origTime, actDiff);
}
}
}
- else
- {
+ else {
/*
* Clock has advanced normally; just need to make sure counter is reset
* to a low value (need not be 0; good to leave a small residual to
@@ -270,10 +260,8 @@ public class UUIDTimer
* Delay is kept to just a millisecond or two, to prevent excessive blocking;
* but that should be enough to eventually synchronize physical clock with
* virtual clock values used for UUIDs.
- *
*/
- private static void slowDown(final long startTime, final long actDiff)
- {
+ private static void slowDown(final long startTime, final long actDiff) {
/*
* First, let's determine how long we'd like to wait. This is based on how
* far ahead are we as of now.
@@ -281,45 +269,36 @@ public class UUIDTimer
long ratio = actDiff / UUIDTimer.kMaxClockAdvance;
long delay;
- if (ratio < 2L)
- { // 200 msecs or less
+ if (ratio < 2L) { // 200 msecs or less
delay = 1L;
}
- else if (ratio < 10L)
- { // 1 second or less
+ else if (ratio < 10L) { // 1 second or less
delay = 2L;
}
- else if (ratio < 600L)
- { // 1 minute or less
+ else if (ratio < 600L) { // 1 minute or less
delay = 3L;
}
- else
- {
+ else {
delay = 5L;
}
// Logger.logWarning("Need to wait for "+delay+" milliseconds; virtual
// clock advanced too far in the future");
long waitUntil = startTime + delay;
int counter = 0;
- do
- {
- try
- {
+ do {
+ try {
Thread.sleep(delay);
}
- catch (InterruptedException ie)
- {
+ catch (InterruptedException ie) {
}
delay = 1L;
/*
* This is just a sanity check: don't want an "infinite" loop if clock
* happened to be moved backwards by, say, an hour...
*/
- if (++counter > UUIDTimer.MAX_WAIT_COUNT)
- {
+ if (++counter > UUIDTimer.MAX_WAIT_COUNT) {
break;
}
- }
- while (System.currentTimeMillis() < waitUntil);
+ } while (System.currentTimeMillis() < waitUntil);
}
}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/SchemaConstants.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/SchemaConstants.java
index eee4a17bd5..0114b8a916 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/SchemaConstants.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/SchemaConstants.java
@@ -16,8 +16,8 @@
*/
package org.apache.activemq.artemis.utils.uri;
-public class SchemaConstants
-{
+public class SchemaConstants {
+
public static final String TCP = "tcp";
public static final String UDP = "udp";
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URIFactory.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URIFactory.java
index b3ff1b6a96..dae6faaf67 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URIFactory.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URIFactory.java
@@ -22,70 +22,57 @@ import java.net.URISyntaxException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-public class URIFactory
-{
+public class URIFactory {
private URI defaultURI;
private final Map> schemas = new ConcurrentHashMap<>();
- public URI getDefaultURI()
- {
+ public URI getDefaultURI() {
return defaultURI;
}
- public void setDefaultURI(URI uri)
- {
+ public void setDefaultURI(URI uri) {
this.defaultURI = uri;
}
- public void registerSchema(URISchema schemaFactory)
- {
+ public void registerSchema(URISchema schemaFactory) {
schemas.put(schemaFactory.getSchemaName(), schemaFactory);
schemaFactory.setFactory(this);
}
- public void removeSchema(final SchemaConstants schemaName)
- {
+ public void removeSchema(final SchemaConstants schemaName) {
schemas.remove(schemaName);
}
- public URI expandURI(String uriString) throws Exception
- {
+ public URI expandURI(String uriString) throws Exception {
return normalise(uriString);
}
- public T newObject(URI uri, P param) throws Exception
- {
+ public T newObject(URI uri, P param) throws Exception {
URISchema schemaFactory = schemas.get(uri.getScheme());
- if (schemaFactory == null)
- {
+ if (schemaFactory == null) {
throw new NullPointerException("Schema " + uri.getScheme() + " not found");
}
-
return schemaFactory.newObject(uri, param);
}
- public void populateObject(URI uri, T bean) throws Exception
- {
+ public void populateObject(URI uri, T bean) throws Exception {
URISchema schemaFactory = schemas.get(uri.getScheme());
- if (schemaFactory == null)
- {
+ if (schemaFactory == null) {
throw new NullPointerException("Schema " + uri.getScheme() + " not found");
}
schemaFactory.populateObject(uri, bean);
}
- public URI createSchema(String scheme, T bean) throws Exception
- {
+ public URI createSchema(String scheme, T bean) throws Exception {
URISchema schemaFactory = schemas.get(scheme);
- if (schemaFactory == null)
- {
+ if (schemaFactory == null) {
throw new NullPointerException("Schema " + scheme + " not found");
}
return schemaFactory.newURI(bean);
@@ -101,32 +88,24 @@ public class URIFactory
*
* It is the job of the URISchema implementation to handle these fragments as needed.
* */
- private URI normalise(String uri) throws URISyntaxException
- {
- if (uri.startsWith("("))
- {
+ private URI normalise(String uri) throws URISyntaxException {
+ if (uri.startsWith("(")) {
String[] split = uri.split("\\)");
String[] connectorURIS = split[0].substring(split[0].indexOf('(') + 1).split(",");
String factoryQuery = split.length > 1 ? split[1] : "";
StringBuilder builder = new StringBuilder(connectorURIS[0]);
- if (factoryQuery != null && factoryQuery.length() > 0)
- {
- if (connectorURIS[0].contains("?"))
- {
+ if (factoryQuery != null && factoryQuery.length() > 0) {
+ if (connectorURIS[0].contains("?")) {
builder.append("&").append(factoryQuery.substring(1));
}
- else
- {
+ else {
builder.append(factoryQuery);
}
}
- if (connectorURIS.length > 1)
- {
+ if (connectorURIS.length > 1) {
builder.append("#");
- for (int i = 1; i < connectorURIS.length; i++)
- {
- if (i > 1)
- {
+ for (int i = 1; i < connectorURIS.length; i++) {
+ if (i > 1) {
builder.append(",");
}
builder.append(connectorURIS[i]);
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java
index e7ee1c1eb1..335833130c 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java
@@ -29,67 +29,53 @@ import java.util.Set;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.beanutils.FluentPropertyBeanIntrospector;
-public abstract class URISchema
-{
+public abstract class URISchema {
+
public abstract String getSchemaName();
- public T newObject(URI uri, P param) throws Exception
- {
+ public T newObject(URI uri, P param) throws Exception {
return newObject(uri, null, param);
}
- public void populateObject(URI uri, T bean) throws Exception
- {
+ public void populateObject(URI uri, T bean) throws Exception {
setData(uri, bean, parseQuery(uri.getQuery(), null));
}
- public URI newURI(T bean) throws Exception
- {
+ public URI newURI(T bean) throws Exception {
return internalNewURI(bean);
}
private URIFactory parentFactory;
-
- void setFactory(URIFactory factory)
- {
+ void setFactory(URIFactory factory) {
this.parentFactory = factory;
}
- protected URIFactory getFactory()
- {
+ protected URIFactory getFactory() {
return parentFactory;
}
-
- protected String getHost(URI uri)
- {
+ protected String getHost(URI uri) {
URI defaultFactory = getDefaultURI();
- if (defaultFactory != null && uri.getHost() == null && defaultFactory.getScheme().equals(uri.getScheme()))
- {
+ if (defaultFactory != null && uri.getHost() == null && defaultFactory.getScheme().equals(uri.getScheme())) {
uri = defaultFactory;
}
return uri.getHost();
}
- protected URI getDefaultURI()
- {
+ protected URI getDefaultURI() {
URIFactory factory = getFactory();
- if (factory == null)
- {
+ if (factory == null) {
return null;
}
- else
- {
+ else {
return factory.getDefaultURI();
}
}
- protected int getPort(URI uri)
- {
+ protected int getPort(URI uri) {
URI defaultFactory = getDefaultURI();
- if (defaultFactory != null && uri.getPort() < 0 && defaultFactory.getScheme().equals(uri.getScheme()))
- {
+ if (defaultFactory != null && uri.getPort() < 0 && defaultFactory.getScheme().equals(uri.getScheme())) {
uri = defaultFactory;
}
return uri.getPort();
@@ -98,13 +84,13 @@ public abstract class URISchema
/**
* It will create a new Object for the URI selected schema.
* the propertyOverrides is used to replace whatever was defined on the URL string
- * @param uri The URI
- * @param propertyOverrides used to replace whatever was defined on the URL string
+ *
+ * @param uri The URI
+ * @param propertyOverrides used to replace whatever was defined on the URL string
* @return new Object
* @throws Exception On error
*/
- public T newObject(URI uri, Map propertyOverrides, P param) throws Exception
- {
+ public T newObject(URI uri, Map propertyOverrides, P param) throws Exception {
return internalNewObject(uri, parseQuery(uri.getQuery(), propertyOverrides), param);
}
@@ -114,83 +100,63 @@ public abstract class URISchema
private static final BeanUtilsBean beanUtils = new BeanUtilsBean();
-
- static
- {
+ static {
// This is to customize the BeanUtils to use Fluent Proeprties as well
beanUtils.getPropertyUtils().addBeanIntrospector(new FluentPropertyBeanIntrospector());
}
-
- public static Map parseQuery(String uri, Map propertyOverrides) throws URISyntaxException
- {
- try
- {
+ public static Map parseQuery(String uri,
+ Map propertyOverrides) throws URISyntaxException {
+ try {
Map rc = new HashMap();
- if (uri != null && !uri.isEmpty())
- {
+ if (uri != null && !uri.isEmpty()) {
String[] parameters = uri.split("&");
- for (int i = 0; i < parameters.length; i++)
- {
+ for (int i = 0; i < parameters.length; i++) {
int p = parameters[i].indexOf("=");
- if (p >= 0)
- {
+ if (p >= 0) {
String name = URLDecoder.decode(parameters[i].substring(0, p), "UTF-8");
String value = URLDecoder.decode(parameters[i].substring(p + 1), "UTF-8");
rc.put(name, value);
}
- else
- {
- if (!parameters[i].trim().isEmpty())
- {
+ else {
+ if (!parameters[i].trim().isEmpty()) {
rc.put(parameters[i], null);
}
}
}
}
- if (propertyOverrides != null)
- {
- for (Map.Entry entry: propertyOverrides.entrySet())
- {
+ if (propertyOverrides != null) {
+ for (Map.Entry entry : propertyOverrides.entrySet()) {
rc.put(entry.getKey(), entry.getValue());
}
}
return rc;
}
- catch (UnsupportedEncodingException e)
- {
+ catch (UnsupportedEncodingException e) {
throw (URISyntaxException) new URISyntaxException(e.toString(), "Invalid encoding").initCause(e);
}
}
-
-
- protected String printQuery(Map query)
- {
+ protected String printQuery(Map query) {
StringBuffer buffer = new StringBuffer();
- for (Map.Entry entry : query.entrySet())
- {
+ for (Map.Entry entry : query.entrySet()) {
buffer.append(entry.getKey() + "=" + entry.getValue());
buffer.append("\n");
}
- return buffer.toString();
+ return buffer.toString();
}
- protected static P copyData(P source, P target) throws Exception
- {
- synchronized (beanUtils)
- {
+ protected static
P copyData(P source, P target) throws Exception {
+ synchronized (beanUtils) {
beanUtils.copyProperties(source, target);
}
return target;
}
- protected static
P setData(URI uri, P obj, Map query) throws Exception
- {
- synchronized (beanUtils)
- {
+ protected static P setData(URI uri, P obj, Map query) throws Exception {
+ synchronized (beanUtils) {
beanUtils.setProperty(obj, "host", uri.getHost());
beanUtils.setProperty(obj, "port", uri.getPort());
beanUtils.setProperty(obj, "userInfo", uri.getUserInfo());
@@ -199,46 +165,36 @@ public abstract class URISchema
return obj;
}
- public static void setData(URI uri, HashMap properties, Set allowableProperties, Map query)
- {
- if (allowableProperties.contains("host"))
- {
+ public static void setData(URI uri,
+ HashMap properties,
+ Set allowableProperties,
+ Map query) {
+ if (allowableProperties.contains("host")) {
properties.put("host", "" + uri.getHost());
}
- if (allowableProperties.contains("port"))
- {
+ if (allowableProperties.contains("port")) {
properties.put("port", "" + uri.getPort());
}
- if (allowableProperties.contains("userInfo"))
- {
+ if (allowableProperties.contains("userInfo")) {
properties.put("userInfo", "" + uri.getUserInfo());
}
- for (Map.Entry entry : query.entrySet())
- {
- if (allowableProperties.contains(entry.getKey()))
- {
+ for (Map.Entry entry : query.entrySet()) {
+ if (allowableProperties.contains(entry.getKey())) {
properties.put(entry.getKey(), entry.getValue());
}
}
}
- public static String getData(List ignored, Object... beans) throws Exception
- {
+ public static String getData(List ignored, Object... beans) throws Exception {
StringBuilder sb = new StringBuilder();
- synchronized (beanUtils)
- {
- for (Object bean : beans)
- {
- if (bean != null)
- {
+ synchronized (beanUtils) {
+ for (Object bean : beans) {
+ if (bean != null) {
PropertyDescriptor[] descriptors = beanUtils.getPropertyUtils().getPropertyDescriptors(bean);
- for (PropertyDescriptor descriptor : descriptors)
- {
- if (descriptor.getReadMethod() != null && isWriteable(descriptor, ignored))
- {
+ for (PropertyDescriptor descriptor : descriptors) {
+ if (descriptor.getReadMethod() != null && isWriteable(descriptor, ignored)) {
String value = beanUtils.getProperty(bean, descriptor.getName());
- if (value != null)
- {
+ if (value != null) {
sb.append("&").append(descriptor.getName()).append("=").append(value);
}
}
@@ -249,23 +205,21 @@ public abstract class URISchema
return sb.toString();
}
- private static boolean isWriteable(PropertyDescriptor descriptor, List ignored)
- {
- if (ignored != null && ignored.contains(descriptor.getName()))
- {
+ private static boolean isWriteable(PropertyDescriptor descriptor, List ignored) {
+ if (ignored != null && ignored.contains(descriptor.getName())) {
return false;
}
Class> type = descriptor.getPropertyType();
return (type == Double.class) ||
- (type == double.class) ||
- (type == Long.class) ||
- (type == long.class) ||
- (type == Integer.class) ||
- (type == int.class) ||
- (type == Float.class) ||
- (type == float.class) ||
- (type == Boolean.class) ||
- (type == boolean.class) ||
- (type == String.class);
+ (type == double.class) ||
+ (type == Long.class) ||
+ (type == long.class) ||
+ (type == Integer.class) ||
+ (type == int.class) ||
+ (type == Float.class) ||
+ (type == float.class) ||
+ (type == Boolean.class) ||
+ (type == boolean.class) ||
+ (type == String.class);
}
}
diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ByteUtilTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ByteUtilTest.java
index 3b54fe722f..ada02f4126 100644
--- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ByteUtilTest.java
+++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ByteUtilTest.java
@@ -19,31 +19,25 @@ package org.apache.activemq.artemis.utils;
import org.junit.Assert;
import org.junit.Test;
-public class ByteUtilTest
-{
+public class ByteUtilTest {
+
@Test
- public void testBytesToString()
- {
- byte[] byteArray = new byte[] {0, 1, 2, 3};
+ public void testBytesToString() {
+ byte[] byteArray = new byte[]{0, 1, 2, 3};
testEquals("0001 0203", ByteUtil.bytesToHex(byteArray, 2));
testEquals("00 01 02 03", ByteUtil.bytesToHex(byteArray, 1));
testEquals("000102 03", ByteUtil.bytesToHex(byteArray, 3));
}
-
@Test
- public void testMaxString()
- {
+ public void testMaxString() {
byte[] byteArray = new byte[20 * 1024];
- System.out.println(ByteUtil.maxString(ByteUtil.bytesToHex(byteArray, 2),150));
+ System.out.println(ByteUtil.maxString(ByteUtil.bytesToHex(byteArray, 2), 150));
}
-
- void testEquals(String string1, String string2)
- {
- if (!string1.equals(string2))
- {
+ void testEquals(String string1, String string2) {
+ if (!string1.equals(string2)) {
Assert.fail("String are not the same:=" + string1 + "!=" + string2);
}
}
diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/PairTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/PairTest.java
index ed33a80e85..b441c7b92a 100644
--- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/PairTest.java
+++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/PairTest.java
@@ -21,13 +21,10 @@ import org.junit.Test;
import org.junit.Assert;
import org.apache.activemq.artemis.api.core.Pair;
-
-public class PairTest extends Assert
-{
+public class PairTest extends Assert {
@Test
- public void testPair()
- {
+ public void testPair() {
Pair p = new Pair(Integer.valueOf(12), Integer.valueOf(13));
int hash = p.hashCode();
p.setA(null);
diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ReferenceCounterTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ReferenceCounterTest.java
index 30f637773c..c338fb3c4a 100644
--- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ReferenceCounterTest.java
+++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ReferenceCounterTest.java
@@ -26,39 +26,34 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Assert;
import org.junit.Test;
-public class ReferenceCounterTest extends Assert
-{
+public class ReferenceCounterTest extends Assert {
+
+ class LatchRunner implements Runnable {
- class LatchRunner implements Runnable
- {
final CountDownLatch latch = new CountDownLatch(1);
final AtomicInteger counts = new AtomicInteger(0);
volatile Thread lastThreadUsed;
- public void run()
- {
+ public void run() {
counts.incrementAndGet();
latch.countDown();
}
}
@Test
- public void testReferenceNoExecutor() throws Exception
- {
+ public void testReferenceNoExecutor() throws Exception {
internalTestReferenceNoExecutor(null);
}
@Test
- public void testReferenceWithExecutor() throws Exception
- {
+ public void testReferenceWithExecutor() throws Exception {
ExecutorService executor = Executors.newSingleThreadExecutor();
internalTestReferenceNoExecutor(executor);
executor.shutdown();
}
@Test
- public void testReferenceValidExecutorUsed() throws Exception
- {
+ public void testReferenceValidExecutorUsed() throws Exception {
ExecutorService executor = Executors.newSingleThreadExecutor();
LatchRunner runner = new LatchRunner();
ReferenceCounterUtil counter = new ReferenceCounterUtil(runner, executor);
@@ -72,54 +67,43 @@ public class ReferenceCounterTest extends Assert
executor.shutdown();
}
- public void internalTestReferenceNoExecutor(Executor executor) throws Exception
- {
+ public void internalTestReferenceNoExecutor(Executor executor) throws Exception {
LatchRunner runner = new LatchRunner();
final ReferenceCounterUtil ref;
- if (executor == null)
- {
+ if (executor == null) {
ref = new ReferenceCounterUtil(runner);
}
- else
- {
+ else {
ref = new ReferenceCounterUtil(runner, executor);
}
Thread[] t = new Thread[100];
- for (int i = 0; i < t.length; i++)
- {
- t[i] = new Thread()
- {
- public void run()
- {
+ for (int i = 0; i < t.length; i++) {
+ t[i] = new Thread() {
+ public void run() {
ref.increment();
}
};
t[i].start();
}
- for (Thread tx : t)
- {
+ for (Thread tx : t) {
tx.join();
}
- for (int i = 0; i < t.length; i++)
- {
- t[i] = new Thread()
- {
- public void run()
- {
+ for (int i = 0; i < t.length; i++) {
+ t[i] = new Thread() {
+ public void run() {
ref.decrement();
}
};
t[i].start();
}
- for (Thread tx : t)
- {
+ for (Thread tx : t) {
tx.join();
}
@@ -127,6 +111,5 @@ public class ReferenceCounterTest extends Assert
assertEquals(1, runner.counts.get());
-
}
}
diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/URIParserTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/URIParserTest.java
index 3155fa28c3..5e4849da69 100644
--- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/URIParserTest.java
+++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/URIParserTest.java
@@ -25,8 +25,7 @@ import org.junit.Test;
import java.net.URI;
import java.util.Map;
-public class URIParserTest
-{
+public class URIParserTest {
/**
* this is just a simple test to validate the model
@@ -34,10 +33,9 @@ public class URIParserTest
* @throws Throwable
*/
@Test
- public void testSchemaFruit() throws Throwable
- {
+ public void testSchemaFruit() throws Throwable {
FruitParser parser = new FruitParser();
- Fruit fruit = (Fruit)parser.newObject(new URI("fruit://some:guy@fair-market:3030?color=green&fluentName=something"), null);
+ Fruit fruit = (Fruit) parser.newObject(new URI("fruit://some:guy@fair-market:3030?color=green&fluentName=something"), null);
Assert.assertEquals("fruit", fruit.getName());
Assert.assertEquals(3030, fruit.getPort());
@@ -46,7 +44,6 @@ public class URIParserTest
Assert.assertEquals("green", fruit.getColor());
Assert.assertEquals("something", fruit.getFluentName());
-
}
/**
@@ -55,8 +52,7 @@ public class URIParserTest
* @throws Throwable
*/
@Test
- public void testSchemaNoHosPropertyt() throws Throwable
- {
+ public void testSchemaNoHosPropertyt() throws Throwable {
FruitParser parser = new FruitParser();
FruitBase fruit = parser.newObject(new URI("base://some:guy@fair-market:3030?color=green&fluentName=something"), null);
Assert.assertEquals("base", fruit.getName());
@@ -70,10 +66,9 @@ public class URIParserTest
* @throws Throwable
*/
@Test
- public void testSchemaNoHostOnURL() throws Throwable
- {
+ public void testSchemaNoHostOnURL() throws Throwable {
FruitParser parser = new FruitParser();
- Fruit fruit = (Fruit)parser.newObject(new URI("fruit://some:guy@port?color=green&fluentName=something"), null);
+ Fruit fruit = (Fruit) parser.newObject(new URI("fruit://some:guy@port?color=green&fluentName=something"), null);
System.out.println("fruit:" + fruit);
Assert.assertEquals("fruit", fruit.getName());
@@ -81,104 +76,84 @@ public class URIParserTest
Assert.assertEquals("something", fruit.getFluentName());
}
+ class FruitParser extends URIFactory {
- class FruitParser extends URIFactory
- {
- FruitParser()
- {
+ FruitParser() {
this.registerSchema(new FruitSchema());
this.registerSchema(new FruitBaseSchema());
}
}
- class FruitSchema extends URISchema
- {
+ class FruitSchema extends URISchema {
+
@Override
- public String getSchemaName()
- {
+ public String getSchemaName() {
return "fruit";
}
-
@Override
- public FruitBase internalNewObject(URI uri, Map query, String fruitName) throws Exception
- {
+ public FruitBase internalNewObject(URI uri, Map