Make exception messages consistent.

This commit is contained in:
Major-
2014-02-13 15:14:49 +00:00
parent 1ed7801598
commit 4f316c08b4
47 changed files with 156 additions and 142 deletions
+3 -3
View File
@@ -74,16 +74,16 @@ public final class ServiceManager {
}
if (!rootNode.getName().equals("services")) {
throw new IOException("unexpected name of root node");
throw new IOException("Unexpected name of root node.");
}
for (XmlNode childNode : rootNode) {
if (!childNode.getName().equals("service")) {
throw new IOException("unexpected name of child node");
throw new IOException("Unexpected name of child node.");
}
if (!childNode.hasValue()) {
throw new IOException("child node must have a value!");
throw new IOException("Child node must have a value.");
}
Class<? extends Service> clazz = (Class<? extends Service>) Class.forName(childNode.getValue());
+8 -8
View File
@@ -81,7 +81,7 @@ public final class IndexedFileSystem implements Closeable {
}
}
if (indexCount <= 0) {
throw new FileNotFoundException("No index file(s) present");
throw new FileNotFoundException("No index file(s) present.");
}
File oldEngineData = new File(base.getAbsolutePath() + "/main_file_cache.dat");
@@ -91,7 +91,7 @@ public final class IndexedFileSystem implements Closeable {
} else if (newEngineData.exists() && !oldEngineData.isDirectory()) {
data = new RandomAccessFile(newEngineData, readOnly ? "r" : "rw");
} else {
throw new FileNotFoundException("no data file present");
throw new FileNotFoundException("No data file present.");
}
}
@@ -141,7 +141,7 @@ public final class IndexedFileSystem implements Closeable {
return crcTable.duplicate();
}
}
throw new IOException("cannot get CRC table from a writable file system");
throw new IOException("Cannot get CRC table from a writable file system.");
}
/**
@@ -207,11 +207,11 @@ public final class IndexedFileSystem implements Closeable {
// if we still have more data to read, check the validity of the header
if (size > read) {
if (nextType != descriptor.getType() + 1) {
throw new IOException("file type mismatch.");
throw new IOException("File type mismatch.");
}
if (nextFile != descriptor.getFile()) {
throw new IOException("file id mismatch.");
throw new IOException("File id mismatch.");
}
}
}
@@ -241,7 +241,7 @@ public final class IndexedFileSystem implements Closeable {
*/
private int getFileCount(int type) throws IOException {
if (type < 0 || type >= indices.length) {
throw new IndexOutOfBoundsException("file type out of bounds");
throw new IndexOutOfBoundsException("File type out of bounds.");
}
RandomAccessFile indexFile = indices[type];
@@ -260,7 +260,7 @@ public final class IndexedFileSystem implements Closeable {
private Index getIndex(FileDescriptor descriptor) throws IOException {
int index = descriptor.getType();
if (index < 0 || index >= indices.length) {
throw new IndexOutOfBoundsException("file descriptor type out of bounds");
throw new IndexOutOfBoundsException("File descriptor type out of bounds.");
}
byte[] buffer = new byte[FileSystemConstants.INDEX_SIZE];
@@ -271,7 +271,7 @@ public final class IndexedFileSystem implements Closeable {
indexFile.seek(ptr);
indexFile.readFully(buffer);
} else {
throw new FileNotFoundException("could not find find index");
throw new FileNotFoundException("Could not find find index.");
}
}
+1 -1
View File
@@ -99,7 +99,7 @@ public final class Archive {
return entry;
}
}
throw new FileNotFoundException("could not find entry: " + name);
throw new FileNotFoundException("Could not find entry: " + name + ".");
}
}
@@ -42,7 +42,7 @@ public final class PlayerDesignVerificationHandler extends EventHandler<PlayerDe
} else if (gender == Gender.FEMALE) {
return validFemaleStyle(appearance);
}
throw new IllegalArgumentException("player can only be either male or female");
throw new IllegalArgumentException("Player can only be either male or female.");
}
/**
@@ -55,6 +55,17 @@ public final class SetTileItemEvent extends Event {
this(id, amount, ItemDefinition.lookup(id).isStackable(), false, 0, 0);
}
/**
* Creates a new event that updates the previous amount of the item.
*
* @param id The id of the item.
* @param amount The amount of the item.
* @param previousAmount The previous amount of the item.
*/
public SetTileItemEvent(int id, int amount, int previousAmount) {
this(id, amount, true, true, previousAmount, 0);
}
/**
* Creates a new set tile item event.
*
@@ -77,17 +88,6 @@ public final class SetTileItemEvent extends Event {
this.positionOffset = positionOffset;
}
/**
* Creates a new event that updates the previous amount of the item.
*
* @param id The id of the item.
* @param amount The amount of the item.
* @param previousAmount The previous amount of the item.
*/
public SetTileItemEvent(int id, int amount, int previousAmount) {
this(id, amount, true, true, previousAmount, 0);
}
/**
* Gets the amount of the item.
*
@@ -28,7 +28,7 @@ public final class WalkEvent extends Event {
*/
public WalkEvent(Position[] steps, boolean run) {
if (steps.length < 0) {
throw new IllegalArgumentException("number of steps must not be negative");
throw new IllegalArgumentException("Number of steps must not be negative.");
}
this.steps = steps;
this.run = run;
+3 -3
View File
@@ -39,13 +39,13 @@ public final class Appearance {
*/
public Appearance(Gender gender, int[] style, int[] colors) {
if (gender == null || style == null || colors == null) {
throw new NullPointerException("no arguments can be null");
throw new NullPointerException("No arguments can be null.");
}
if (style.length != 7) {
throw new IllegalArgumentException("the style array must have 7 elements");
throw new IllegalArgumentException("The style array must have 7 elements.");
}
if (colors.length != 5) {
throw new IllegalArgumentException("the colors array must have 5 elements");
throw new IllegalArgumentException("The colors array must have 5 elements.");
}
this.gender = gender;
this.style = style;
+3 -3
View File
@@ -88,10 +88,10 @@ public final class Inventory implements Cloneable {
*/
public Inventory(int capacity, StackMode mode) {
if (capacity < 0) {
throw new IllegalArgumentException("capacity cannot be negative");
throw new IllegalArgumentException("Capacity cannot be negative.");
}
if (mode == null) {
throw new NullPointerException("stacking mode cannot be null");
throw new NullPointerException("Stacking mode cannot be null.");
}
this.capacity = capacity;
items = new Item[capacity];
@@ -219,7 +219,7 @@ public final class Inventory implements Cloneable {
*/
private void checkBounds(int slot) {
if (slot < 0 || slot >= capacity) {
throw new IndexOutOfBoundsException("slot out of bounds");
throw new IndexOutOfBoundsException("Slot out of bounds.");
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ public final class Item {
*/
public Item(int id, int amount) {
if (amount < 0) {
throw new IllegalArgumentException("negative amount");
throw new IllegalArgumentException("Negative amount.");
}
this.id = id;
this.amount = amount;
+1 -1
View File
@@ -48,7 +48,7 @@ public final class Npc extends Mob {
*/
public void transform(int id) {
if (id < 0 || id >= NpcDefinition.count()) {
throw new IllegalArgumentException("id to transform to is out of bounds");
throw new IllegalArgumentException("Id to transform to is out of bounds.");
}
definition = NpcDefinition.lookup(id);
blockSet.add(SynchronizationBlock.createTransformBlock(id));
+1 -1
View File
@@ -700,7 +700,7 @@ public final class Player extends Mob {
public void sendQuestInterface(List<String> text) {
int size = text.size(), lines = InterfaceConstants.QUEST_TEXT.length;
if (size > lines) {
throw new IllegalArgumentException("List contains too much text for this interface.");
throw new IllegalArgumentException("List contains too much text to display on this interface.");
}
for (int pos = 0; pos < lines; pos++) {
+1 -1
View File
@@ -153,7 +153,7 @@ public final class SkillSet {
*/
private void checkBounds(int id) {
if (id < 0 || id >= skills.length) {
throw new IndexOutOfBoundsException("skill id is out of bounds");
throw new IndexOutOfBoundsException("Skill id is out of bounds.");
}
}
@@ -29,7 +29,7 @@ public final class EquipmentDefinition {
EquipmentDefinition def = definitions[id];
if (def != null) {
if (def.getId() != id) {
throw new RuntimeException("Equipment definition id mismatch!");
throw new RuntimeException("Equipment definition id mismatch.");
}
EquipmentDefinition.definitions.put(def.getId(), def);
}
@@ -56,7 +56,7 @@ public final class ItemDefinition {
for (int id = 0; id < definitions.length; id++) {
ItemDefinition def = definitions[id];
if (def.getId() != id) {
throw new RuntimeException("Item definition id mismatch!");
throw new RuntimeException("Item definition id mismatch.");
}
if (def.isNote()) {
def.toNote();
@@ -190,7 +190,7 @@ public final class ItemDefinition {
*/
public String getGroundAction(int id) {
if (id < 0 || id >= groundActions.length) {
throw new IndexOutOfBoundsException("ground action id is out of bounds");
throw new IndexOutOfBoundsException("Ground action id is out of bounds.");
}
return groundActions[id];
}
@@ -213,7 +213,7 @@ public final class ItemDefinition {
*/
public String getInventoryAction(int id) {
if (id < 0 || id >= inventoryActions.length) {
throw new IndexOutOfBoundsException("inventory action id is out of bounds");
throw new IndexOutOfBoundsException("Inventory action id is out of bounds.");
}
return inventoryActions[id];
}
@@ -308,7 +308,7 @@ public final class ItemDefinition {
*/
public void setGroundAction(int id, String action) {
if (id < 0 || id >= groundActions.length) {
throw new IndexOutOfBoundsException("ground action id is out of bounds");
throw new IndexOutOfBoundsException("Ground action id is out of bounds.");
}
groundActions[id] = action;
}
@@ -322,7 +322,7 @@ public final class ItemDefinition {
*/
public void setInventoryAction(int id, String action) {
if (id < 0 || id >= inventoryActions.length) {
throw new IndexOutOfBoundsException("inventory action id is out of bounds");
throw new IndexOutOfBoundsException("Inventory action id is out of bounds.");
}
inventoryActions[id] = action;
}
@@ -43,7 +43,7 @@ public final class NpcDefinition {
for (int id = 0; id < definitions.length; id++) {
NpcDefinition def = definitions[id];
if (def.getId() != id) {
throw new RuntimeException("Npc definition id mismatch!");
throw new RuntimeException("Npc definition id mismatch.");
}
}
}
@@ -143,7 +143,7 @@ public final class NpcDefinition {
*/
public String getInteraction(int slot) {
if (slot < 0 || slot >= interactions.length) {
throw new IndexOutOfBoundsException("npc interaction id is out of bounds");
throw new IndexOutOfBoundsException("Npc interaction id is out of bounds.");
}
return interactions[slot];
}
@@ -238,7 +238,7 @@ public final class NpcDefinition {
*/
public boolean hasInteraction(int slot) {
if (slot < 0 || slot >= interactions.length) {
throw new IndexOutOfBoundsException("npc interaction id is out of bounds");
throw new IndexOutOfBoundsException("Npc interaction id is out of bounds.");
}
return interactions[slot] != null;
}
@@ -315,7 +315,7 @@ public final class NpcDefinition {
*/
public void setInteraction(int slot, String interaction) {
if (slot < 0 || slot >= interactions.length) {
throw new IndexOutOfBoundsException("npc interaction id is out of bounds");
throw new IndexOutOfBoundsException("Npc interaction id is out of bounds.");
}
interactions[slot] = interaction;
}
@@ -41,10 +41,9 @@ public final class ObjectDefinition {
public static void init(ObjectDefinition[] definitions) {
ObjectDefinition.definitions = definitions;
for (int id = 0; id < definitions.length; id++) {
// This also verifies that none of the definitions are null.
ObjectDefinition def = definitions[id];
if (def.getId() != id) {
throw new RuntimeException("Item definition id mismatch!");
throw new RuntimeException("Item definition id mismatch.");
}
}
}
@@ -41,10 +41,10 @@ public final class SectorRepository {
*/
public void add(Sector sector) {
if (sector == null) {
throw new IllegalArgumentException("sector cannot be null");
throw new IllegalArgumentException("Sector cannot be null.");
} else if (sectors.containsKey(sector.getCoordinates()) && !permitRemoval) {
throw new UnsupportedOperationException(
"cannot add a sector with the same coordinates as an existing sector");
"Cannot add a sector with the same coordinates as an existing sector.");
}
sectors.put(sector.getCoordinates(), sector);
}
@@ -95,7 +95,7 @@ public final class SectorRepository {
*/
public void remove(Sector sector) {
if (!permitRemoval) {
throw new UnsupportedOperationException("cannot remove sectors from this repository");
throw new UnsupportedOperationException("Cannot remove sectors from this repository.");
}
sectors.remove(sector.getCoordinates());
}
@@ -33,12 +33,12 @@ public enum PrivacyState {
*
* @param value The numerical value.
* @return The privacy state.
* @throws IllegalArgumentException If the numerical value is invalid.
* @throws IllegalArgumentException If the specified value is out of bounds.
*/
public static PrivacyState valueOf(int value) {
PrivacyState[] values = values();
if (value < 0 || value >= values.length) {
throw new IllegalArgumentException("Invalid privacy option integer value specified: " + value);
throw new IllegalArgumentException("Invalid privacy option integer value specified: " + value + ".");
}
return values[value];
}
@@ -23,16 +23,16 @@ public enum PrivilegeLevel {
ADMINISTRATOR(2);
/**
* Gets the privilege level for the specified numerical level.
* Gets the privilege level for the specified numerical value.
*
* @param value The numerical level.
* @param value The numerical value.
* @return The privilege level.
* @throws IllegalArgumentException If the numerical level is invalid.
* @throws IllegalArgumentException If the specified value is out of bounds.
*/
public static PrivilegeLevel valueOf(int value) {
PrivilegeLevel[] values = values();
if (value < 0 || value >= values.length) {
throw new IndexOutOfBoundsException("Invalid privilege level integer value supplied");
throw new IndexOutOfBoundsException("Invalid privilege level integer value supplied " + value + ".");
}
return values[value];
}
@@ -32,12 +32,12 @@ public enum ScreenBrightness {
*
* @param value The numerical value.
* @return The screen brightness.
* @throws IllegalArgumentException If the numerical value is invalid.
* @throws IllegalArgumentException If the specified value is out of bounds.
*/
public static ScreenBrightness valueOf(int value) {
ScreenBrightness[] values = values();
if (value < 0 || value >= values.length) {
throw new IllegalArgumentException("Invalid screen brightness integer value specified");
throw new IllegalArgumentException("Invalid screen brightness integer value specified " + value + ".");
}
return values[value];
}
@@ -45,4 +45,19 @@ public enum ServerStatus {
return code;
}
/**
* Gets the server status for the specified numerical value.
*
* @param value The value.
* @return The server status.
* @throws IndexOutOfBoundsException If the specified value is out of bounds.
*/
public static ServerStatus valueOf(int value) {
ServerStatus[] values = values();
if (value < 0 || value >= values.length) {
throw new IndexOutOfBoundsException("Invalid server status integer value supplied " + value + ".");
}
return values[value];
}
}
@@ -67,7 +67,7 @@ public abstract class ScheduledTask {
*/
public void setDelay(int delay) {
if (delay < 0) {
throw new IllegalArgumentException("delay cannot be less than 0");
throw new IllegalArgumentException("Delay cannot be less than 0.");
}
this.delay = delay;
}
@@ -25,7 +25,7 @@ public final class MovementSegment extends SynchronizationSegment {
public MovementSegment(SynchronizationBlockSet blockSet, Direction[] directions) {
super(blockSet);
if (directions.length < 0 || directions.length > 2) {
throw new IllegalArgumentException("directions length must be between 0 and 2 inclusive");
throw new IllegalArgumentException("Directions length must be between 0 and 2 inclusive.");
}
this.directions = directions;
}
@@ -49,7 +49,7 @@ public final class MovementSegment extends SynchronizationSegment {
case 2:
return SegmentType.RUN;
default:
throw new IllegalStateException("direction type unsupported");
throw new IllegalStateException("Direction type unsupported.");
}
}
@@ -58,28 +58,28 @@ public final class EventHandlerChainParser {
InstantiationException, IllegalAccessException {
XmlNode rootNode = parser.parse(is);
if (!rootNode.getName().equals("events")) {
throw new IOException("root node name is not 'events'");
throw new IOException("Root node name is not 'events'.");
}
Map<Class<? extends Event>, EventHandlerChain<?>> chains = new HashMap<Class<? extends Event>, EventHandlerChain<?>>();
for (XmlNode eventNode : rootNode) {
if (!eventNode.getName().equals("event")) {
throw new IOException("only expected nodes named 'event' beneath the root node");
throw new IOException("Only expected nodes named 'event' beneath the root node.");
}
XmlNode typeNode = eventNode.getChild("type");
if (typeNode == null) {
throw new IOException("no node named 'type' beneath current event node");
throw new IOException("No node named 'type' beneath current event node.");
}
XmlNode chainNode = eventNode.getChild("chain");
if (chainNode == null) {
throw new IOException("no node named 'chain' beneath current event node");
throw new IOException("No node named 'chain' beneath current event node.");
}
String eventClassName = typeNode.getValue();
if (eventClassName == null) {
throw new IOException("type node must have a value");
throw new IOException("Type node must have a value.");
}
Class<? extends Event> eventClass = (Class<? extends Event>) Class.forName(eventClassName);
@@ -87,12 +87,12 @@ public final class EventHandlerChainParser {
for (XmlNode handlerNode : chainNode) {
if (!handlerNode.getName().equals("handler")) {
throw new IOException("only expected nodes named 'handler' beneath the root node");
throw new IOException("Only expected nodes named 'handler' beneath the root node.");
}
String handlerClassName = handlerNode.getValue();
if (handlerClassName == null) {
throw new IOException("handler node must have a value");
throw new IOException("Handler node must have a value.");
}
Class<? extends EventHandler<?>> handlerClass = (Class<? extends EventHandler<?>>) Class
+6 -6
View File
@@ -52,7 +52,7 @@ public final class PluginMetaDataParser {
private XmlNode getElement(XmlNode node, String name) throws IOException {
XmlNode child = node.getChild(name);
if (child == null) {
throw new IOException("no " + name + " element found");
throw new IOException("No " + name + " element found.");
}
return child;
}
@@ -67,7 +67,7 @@ public final class PluginMetaDataParser {
public PluginMetaData parse() throws IOException, SAXException {
XmlNode rootNode = parser.parse(is);
if (!rootNode.getName().equals("plugin")) {
throw new IOException("root node must be named plugin");
throw new IOException("Root node must be named plugin.");
}
XmlNode idNode = getElement(rootNode, "id");
@@ -84,7 +84,7 @@ public final class PluginMetaDataParser {
int version = Integer.parseInt(versionNode.getValue());
if (id == null || name == null || description == null) {
throw new IOException("id, name and description must have values");
throw new IOException("Id, name and description must have values.");
}
XmlNode[] authorNodes = authorsNode.getChildren().toArray(EMPTY_NODE_ARRAY);
@@ -98,21 +98,21 @@ public final class PluginMetaDataParser {
for (int i = 0; i < authorNodes.length; i++) {
authors[i] = authorNodes[i].getValue();
if (authors[i] == null) {
throw new IOException("author elements must have values");
throw new IOException("Author elements must have values.");
}
}
for (int i = 0; i < scriptNodes.length; i++) {
scripts[i] = scriptNodes[i].getValue();
if (scripts[i] == null) {
throw new IOException("script elements must have values");
throw new IOException("Script elements must have values.");
}
}
for (int i = 0; i < dependencyNodes.length; i++) {
dependencies[i] = dependencyNodes[i].getValue();
if (dependencies[i] == null) {
throw new IOException("dependency elements must have values");
throw new IOException("Dependency elements must have values.");
}
}
+3 -3
View File
@@ -46,17 +46,17 @@ public final class RsaKeyParser {
public void parse() throws SAXException, IOException {
XmlNode rootNode = parser.parse(is);
if (!rootNode.getName().equals("rsa")) {
throw new IOException("root node name is not 'rsa'");
throw new IOException("Root node name is not 'rsa'.");
}
XmlNode modulusNode = rootNode.getChild("modulus");
if (modulusNode == null) {
throw new IOException("no node named 'modulus' beneath root node");
throw new IOException("No node named 'modulus' beneath root node.");
}
XmlNode exponentNode = rootNode.getChild("private-exponent");
if (exponentNode == null) {
throw new IOException("no node named 'private-exponent' beneath root node");
throw new IOException("No node named 'private-exponent' beneath root node.");
}
NetworkConstants.RSA_MODULUS = new BigInteger(modulusNode.getValue());
@@ -28,7 +28,7 @@ public final class PlayerLoaderResponse {
*/
public PlayerLoaderResponse(int status) {
if (status == LoginConstants.STATUS_OK || status == LoginConstants.STATUS_RECONNECTION_OK) {
throw new IllegalArgumentException("player required for this status code");
throw new IllegalArgumentException("Player required for this status code.");
}
this.status = status;
player = null;
@@ -43,7 +43,7 @@ public final class PlayerLoaderResponse {
*/
public PlayerLoaderResponse(int status, Player player) {
if (status != LoginConstants.STATUS_OK && status != LoginConstants.STATUS_RECONNECTION_OK) {
throw new IllegalArgumentException("player required for this status code");
throw new IllegalArgumentException("Player not required for this status code.");
}
this.status = status;
this.player = player;
+3 -3
View File
@@ -74,17 +74,17 @@ public final class LoginService extends Service {
}
if (!rootNode.getName().equals("login")) {
throw new IOException("unexpected root node name");
throw new IOException("Unexpected root node name.");
}
XmlNode loaderNode = rootNode.getChild("loader");
if (loaderNode == null || !loaderNode.hasValue()) {
throw new IOException("no loader child node or value");
throw new IOException("No loader child node or value.");
}
XmlNode saverNode = rootNode.getChild("saver");
if (saverNode == null || !saverNode.hasValue()) {
throw new IOException("no saver child node or value");
throw new IOException("No saver child node or value.");
}
Class<?> loaderClazz = Class.forName(loaderNode.getValue());
+1 -1
View File
@@ -76,7 +76,7 @@ public final class ApolloHandler extends ChannelInboundHandlerAdapter {
ctx.attr(NetworkConstants.SESSION_KEY).set(new UpdateSession(ctx.channel(), serverContext));
break;
default:
throw new IllegalStateException("Invalid service id");
throw new IllegalStateException("Invalid service id.");
}
}
} else {
@@ -73,7 +73,7 @@ public final class GamePacketBuilder {
*/
private void checkBitAccess() {
if (mode != AccessMode.BIT_ACCESS) {
throw new IllegalStateException("For bit-based calls to work, the mode must be bit access");
throw new IllegalStateException("For bit-based calls to work, the mode must be bit access.");
}
}
@@ -84,7 +84,7 @@ public final class GamePacketBuilder {
*/
private void checkByteAccess() {
if (mode != AccessMode.BYTE_ACCESS) {
throw new IllegalStateException("For byte-based calls to work, the mode must be byte access");
throw new IllegalStateException("For byte-based calls to work, the mode must be byte access.");
}
}
@@ -121,7 +121,7 @@ public final class GamePacketBuilder {
} else if (transformation == DataTransformation.SUBTRACT) {
buffer.writeByte((byte) (128 - longValue));
} else {
throw new IllegalArgumentException("unknown transformation");
throw new IllegalArgumentException("Unknown transformation.");
}
} else {
buffer.writeByte((byte) (longValue >> i * 8));
@@ -137,7 +137,7 @@ public final class GamePacketBuilder {
} else if (transformation == DataTransformation.SUBTRACT) {
buffer.writeByte((byte) (128 - longValue));
} else {
throw new IllegalArgumentException("unknown transformation");
throw new IllegalArgumentException("Unknown transformation.");
}
} else {
buffer.writeByte((byte) (longValue >> i * 8));
@@ -145,10 +145,10 @@ public final class GamePacketBuilder {
}
} else if (order == DataOrder.MIDDLE) {
if (transformation != DataTransformation.NONE) {
throw new IllegalArgumentException("middle endian cannot be transformed");
throw new IllegalArgumentException("Middle endian cannot be transformed.");
}
if (type != DataType.INT) {
throw new IllegalArgumentException("middle endian can only be used with an integer");
throw new IllegalArgumentException("Middle endian can only be used with an integer,");
}
buffer.writeByte((byte) (longValue >> 8));
buffer.writeByte((byte) longValue);
@@ -156,17 +156,17 @@ public final class GamePacketBuilder {
buffer.writeByte((byte) (longValue >> 16));
} else if (order == DataOrder.INVERSED_MIDDLE) {
if (transformation != DataTransformation.NONE) {
throw new IllegalArgumentException("inversed middle endian cannot be transformed");
throw new IllegalArgumentException("Inversed middle endian cannot be transformed,");
}
if (type != DataType.INT) {
throw new IllegalArgumentException("inversed middle endian can only be used with an integer");
throw new IllegalArgumentException("Inversed middle endian can only be used with an integer,");
}
buffer.writeByte((byte) (longValue >> 16));
buffer.writeByte((byte) (longValue >> 24));
buffer.writeByte((byte) longValue);
buffer.writeByte((byte) (longValue >> 8));
} else {
throw new IllegalArgumentException("unknown order");
throw new IllegalArgumentException("Unknown order.");
}
}
@@ -230,7 +230,7 @@ public final class GamePacketBuilder {
*/
public void putBits(int numBits, int value) {
if (numBits < 0 || numBits > 32) {
throw new IllegalArgumentException("Number of bits must be between 1 and 32 inclusive");
throw new IllegalArgumentException("Number of bits must be between 1 and 32 inclusive.");
}
checkBitAccess();
@@ -357,7 +357,7 @@ public final class GamePacketBuilder {
public void putRawBuilder(GamePacketBuilder builder) {
checkByteAccess();
if (builder.type != PacketType.RAW) {
throw new IllegalArgumentException("Builder must be raw!");
throw new IllegalArgumentException("Builder must be raw.");
}
builder.checkByteAccess();
putBytes(builder.buffer);
@@ -372,7 +372,7 @@ public final class GamePacketBuilder {
public void putRawBuilderReverse(GamePacketBuilder builder) {
checkByteAccess();
if (builder.type != PacketType.RAW) {
throw new IllegalArgumentException("Builder must be raw!");
throw new IllegalArgumentException("Builder must be raw.");
}
builder.checkByteAccess();
putBytesReverse(builder.buffer);
@@ -413,7 +413,7 @@ public final class GamePacketBuilder {
*/
public void switchToBitAccess() {
if (mode == AccessMode.BIT_ACCESS) {
throw new IllegalStateException("Already in bit access mode");
throw new IllegalStateException("Already in bit access mode.");
}
mode = AccessMode.BIT_ACCESS;
bitIndex = buffer.writerIndex() * 8;
@@ -426,7 +426,7 @@ public final class GamePacketBuilder {
*/
public void switchToByteAccess() {
if (mode == AccessMode.BYTE_ACCESS) {
throw new IllegalStateException("Already in byte access mode");
throw new IllegalStateException("Already in byte access mode.");
}
mode = AccessMode.BYTE_ACCESS;
buffer.writerIndex((bitIndex + 7) / 8);
@@ -440,10 +440,10 @@ public final class GamePacketBuilder {
*/
public GamePacket toGamePacket() {
if (type == PacketType.RAW) {
throw new IllegalStateException("Raw packets cannot be converted to a game packet");
throw new IllegalStateException("Raw packets cannot be converted to a game packet.");
}
if (mode != AccessMode.BYTE_ACCESS) {
throw new IllegalStateException("Must be in byte access mode to convert to a packet");
throw new IllegalStateException("Must be in byte access mode to convert to a packet.");
}
return new GamePacket(opcode, type, buffer);
}
@@ -72,7 +72,7 @@ public final class GamePacketDecoder extends StatefulFrameDecoder<GameDecoderSta
decodePayload(ctx, in, out);
break;
default:
throw new IllegalStateException("Invalid game decoder state");
throw new IllegalStateException("Invalid game decoder state.");
}
}
@@ -113,7 +113,7 @@ public final class GamePacketDecoder extends StatefulFrameDecoder<GameDecoderSta
PacketMetaData metaData = release.getIncomingPacketMetaData(opcode);
if (metaData == null) {
throw new IOException("Illegal opcode: " + opcode);
throw new IOException("Illegal opcode: " + opcode + ".");
}
type = metaData.getType();
@@ -130,7 +130,7 @@ public final class GamePacketDecoder extends StatefulFrameDecoder<GameDecoderSta
setState(GameDecoderState.GAME_LENGTH);
break;
default:
throw new IOException("Illegal packet type: " + type);
throw new IOException("Illegal packet type: " + type + ".");
}
}
}
@@ -41,12 +41,12 @@ public final class GamePacketEncoder extends MessageToMessageEncoder<GamePacket>
if (type == PacketType.VARIABLE_BYTE) {
headerLength++;
if (payloadLength >= 256) {
throw new Exception("Payload too long for variable byte packet");
throw new Exception("Payload too long for variable byte packet.");
}
} else if (type == PacketType.VARIABLE_SHORT) {
headerLength += 2;
if (payloadLength >= 65536) {
throw new Exception("Payload too long for variable short packet");
throw new Exception("Payload too long for variable short packet.");
}
}
@@ -42,7 +42,7 @@ public final class GamePacketReader {
*/
private void checkBitAccess() {
if (mode != AccessMode.BIT_ACCESS) {
throw new IllegalStateException("For bit-based calls to work, the mode must be bit access");
throw new IllegalStateException("For bit-based calls to work, the mode must be bit access.");
}
}
@@ -53,7 +53,7 @@ public final class GamePacketReader {
*/
private void checkByteAccess() {
if (mode != AccessMode.BYTE_ACCESS) {
throw new IllegalStateException("For byte-based calls to work, the mode must be byte access");
throw new IllegalStateException("For byte-based calls to work, the mode must be byte access.");
}
}
@@ -81,7 +81,7 @@ public final class GamePacketReader {
} else if (transformation == DataTransformation.SUBTRACT) {
longValue |= 128 - buffer.readByte() & 0xFFL;
} else {
throw new IllegalArgumentException("unknown transformation");
throw new IllegalArgumentException("Unknown transformation.");
}
} else {
longValue |= (buffer.readByte() & 0xFFL) << i * 8;
@@ -97,7 +97,7 @@ public final class GamePacketReader {
} else if (transformation == DataTransformation.SUBTRACT) {
longValue |= 128 - buffer.readByte() & 0xFFL;
} else {
throw new IllegalArgumentException("unknown transformation");
throw new IllegalArgumentException("Unknown transformation.");
}
} else {
longValue |= (buffer.readByte() & 0xFFL) << i * 8;
@@ -105,10 +105,10 @@ public final class GamePacketReader {
}
} else if (order == DataOrder.MIDDLE) {
if (transformation != DataTransformation.NONE) {
throw new IllegalArgumentException("middle endian cannot be transformed");
throw new IllegalArgumentException("Middle endian cannot be transformed.");
}
if (type != DataType.INT) {
throw new IllegalArgumentException("middle endian can only be used with an integer");
throw new IllegalArgumentException("Middle endian can only be used with an integer.");
}
longValue |= (buffer.readByte() & 0xFF) << 8;
longValue |= buffer.readByte() & 0xFF;
@@ -116,17 +116,17 @@ public final class GamePacketReader {
longValue |= (buffer.readByte() & 0xFF) << 16;
} else if (order == DataOrder.INVERSED_MIDDLE) {
if (transformation != DataTransformation.NONE) {
throw new IllegalArgumentException("inversed middle endian cannot be transformed");
throw new IllegalArgumentException("Inversed middle endian cannot be transformed.");
}
if (type != DataType.INT) {
throw new IllegalArgumentException("inversed middle endian can only be used with an integer");
throw new IllegalArgumentException("Inversed middle endian can only be used with an integer.");
}
longValue |= (buffer.readByte() & 0xFF) << 16;
longValue |= (buffer.readByte() & 0xFF) << 24;
longValue |= buffer.readByte() & 0xFF;
longValue |= (buffer.readByte() & 0xFF) << 8;
} else {
throw new IllegalArgumentException("unknown order");
throw new IllegalArgumentException("Unknown order.");
}
return longValue;
}
@@ -151,7 +151,7 @@ public final class GamePacketReader {
*/
public int getBits(int numBits) {
if (numBits < 0 || numBits > 32) {
throw new IllegalArgumentException("Number of bits must be between 1 and 32 inclusive");
throw new IllegalArgumentException("Number of bits must be between 1 and 32 inclusive.");
}
checkBitAccess();
@@ -365,7 +365,7 @@ public final class GamePacketReader {
public long getUnsigned(DataType type, DataOrder order, DataTransformation transformation) {
long longValue = get(type, order, transformation);
if (type == DataType.LONG) {
throw new IllegalArgumentException("due to java restrictions, longs must be read as signed types");
throw new IllegalArgumentException("Due to java restrictions, longs must be read as signed types.");
}
return longValue & 0xFFFFFFFFFFFFFFFFL;
}
@@ -406,7 +406,7 @@ public final class GamePacketReader {
*/
public void switchToBitAccess() {
if (mode == AccessMode.BIT_ACCESS) {
throw new IllegalStateException("Already in bit access mode");
throw new IllegalStateException("Already in bit access mode.");
}
mode = AccessMode.BIT_ACCESS;
bitIndex = buffer.readerIndex() * 8;
@@ -419,7 +419,7 @@ public final class GamePacketReader {
*/
public void switchToByteAccess() {
if (mode == AccessMode.BYTE_ACCESS) {
throw new IllegalStateException("Already in byte access mode");
throw new IllegalStateException("Already in byte access mode.");
}
mode = AccessMode.BYTE_ACCESS;
buffer.readerIndex((bitIndex + 7) / 8);
@@ -37,7 +37,7 @@ public final class HandshakeDecoder extends ByteToMessageDecoder {
ctx.channel().writeAndFlush(buf);
break;
default:
throw new IllegalArgumentException("Invalid service id");
throw new IllegalArgumentException("Invalid service id.");
}
ctx.pipeline().remove(this);
@@ -18,7 +18,7 @@ public final class JagGrabRequestDecoder extends MessageToMessageDecoder<String>
String filePath = request.substring(8).trim();
out.add(new JagGrabRequest(filePath));
} else {
throw new IllegalArgumentException("corrupted request line");
throw new IllegalArgumentException("Corrupted request line.");
}
}
@@ -71,7 +71,7 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
decodePayload(ctx, in, out);
break;
default:
throw new IllegalStateException("Invalid login decoder state");
throw new IllegalStateException("Invalid login decoder state.");
}
}
@@ -113,7 +113,7 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
int loginType = buffer.readUnsignedByte();
if (loginType != LoginConstants.TYPE_STANDARD && loginType != LoginConstants.TYPE_RECONNECTION) {
throw new IOException("Invalid login type");
throw new IOException("Invalid login type.");
}
reconnecting = loginType == LoginConstants.TYPE_RECONNECTION;
@@ -136,14 +136,14 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
if (buffer.readableBytes() >= loginLength) {
ByteBuf payload = buffer.readBytes(loginLength);
if (payload.readUnsignedByte() != 0xFF) {
throw new Exception("Invalid magic id");
throw new Exception("Invalid magic id.");
}
int releaseNumber = payload.readUnsignedShort();
int lowMemoryFlag = payload.readUnsignedByte();
if (lowMemoryFlag != 0 && lowMemoryFlag != 1) {
throw new Exception("Invalid value for low memory flag");
throw new Exception("Invalid value for low memory flag.");
}
boolean lowMemory = lowMemoryFlag == 1;
@@ -155,7 +155,7 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
int securePayloadLength = payload.readUnsignedByte();
if (securePayloadLength != loginLength - 41) {
throw new Exception("Secure payload length mismatch");
throw new Exception("Secure payload length mismatch.");
}
ByteBuf securePayload = payload.readBytes(securePayloadLength);
@@ -167,13 +167,13 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
int secureId = securePayload.readUnsignedByte();
if (secureId != 10) {
throw new Exception("Invalid secure payload id");
throw new Exception("Invalid secure payload id.");
}
long clientSeed = securePayload.readLong();
long reportedServerSeed = securePayload.readLong();
if (reportedServerSeed != serverSeed) {
throw new Exception("Server seed mismatch");
throw new Exception("Server seed mismatch.");
}
int uid = securePayload.readInt();
@@ -48,7 +48,7 @@ public final class OnDemandRequest implements Comparable<OnDemandRequest> {
case 2:
return LOW;
default:
throw new IllegalArgumentException("priority out of range");
throw new IllegalArgumentException("Priority out of range.");
}
}
+2 -2
View File
@@ -16,7 +16,7 @@ public final class PacketMetaData {
*/
public static PacketMetaData createFixed(int length) {
if (length < 0) {
throw new IllegalArgumentException("packet length cannot be less than 0");
throw new IllegalArgumentException("Packet length cannot be less than 0.");
}
return new PacketMetaData(PacketType.FIXED, length);
}
@@ -69,7 +69,7 @@ public final class PacketMetaData {
*/
public int getLength() {
if (type != PacketType.FIXED) {
throw new IllegalStateException("can only get the length of a fixed length packet");
throw new IllegalStateException("Can only get the length of a fixed length packet.");
}
return length;
}
@@ -17,14 +17,14 @@ public final class PacketMetaDataGroup {
*/
public static PacketMetaDataGroup createFromArray(int[] lengthArray) {
if (lengthArray.length != 256) {
throw new IllegalArgumentException("length array must be 256");
throw new IllegalArgumentException("Array length must be 256.");
}
PacketMetaDataGroup grp = new PacketMetaDataGroup();
for (int i = 0; i < lengthArray.length; i++) {
int length = lengthArray[i];
PacketMetaData metaData = null;
if (length < -3) {
throw new IllegalArgumentException("no packet length can have a value less than -3");
throw new IllegalArgumentException("No packet length can have a value less than -3.");
} else if (length == -2) {
metaData = PacketMetaData.createVariableShort();
} else if (length == -1) {
@@ -58,7 +58,7 @@ public final class PacketMetaDataGroup {
*/
public PacketMetaData getMetaData(int opcode) {
if (opcode < 0 || opcode >= packets.length) {
throw new IllegalArgumentException("opcode is out of bounds");
throw new IllegalArgumentException("Opcode is out of bounds.");
}
return packets[opcode];
}
+2 -2
View File
@@ -53,7 +53,7 @@ public abstract class Release {
*/
public final EventDecoder<?> getEventDecoder(int opcode) {
if (opcode < 0 || opcode >= decoders.length) {
throw new IndexOutOfBoundsException("opcode is out of bounds");
throw new IndexOutOfBoundsException("Opcode is out of bounds.");
}
return decoders[opcode];
}
@@ -106,7 +106,7 @@ public abstract class Release {
*/
public final <E extends Event> void register(int opcode, EventDecoder<E> decoder) {
if (opcode < 0 || opcode >= decoders.length) {
throw new IndexOutOfBoundsException("opcode is out of bounds");
throw new IndexOutOfBoundsException("Opcode is out of bounds.");
}
decoders[opcode] = decoder;
}
@@ -47,7 +47,7 @@ public final class UpdateSession extends Session {
} else if (message instanceof HttpRequest) {
dispatcher.dispatch(getChannel(), (HttpRequest) message);
} else {
throw new IllegalArgumentException("unknown message type");
throw new IllegalArgumentException("Unknown message type.");
}
}
+1 -1
View File
@@ -1166,7 +1166,7 @@ public final class EquipmentUpdater {
*/
public static void main(String[] args) throws Exception {
if (args.length != 1) {
throw new IllegalArgumentException("Usage:\njava -cp ... org.apollo.tools.EquipmentUpdater [release]");
throw new IllegalArgumentException("Usage:\njava -cp ... org.apollo.tools.EquipmentUpdater [release].");
}
String release = args[0];
+1 -1
View File
@@ -26,7 +26,7 @@ public final class NoteUpdater {
*/
public static void main(String[] args) throws Exception {
if (args.length != 1) {
throw new IllegalArgumentException("Usage:\njava -cp ... org.apollo.tools.NoteUpdater [release]");
throw new IllegalArgumentException("Usage:\njava -cp ... org.apollo.tools.NoteUpdater [release].");
}
String release = args[0];
+1 -1
View File
@@ -33,7 +33,7 @@ public final class EnumerationUtil {
@Override
public void remove() {
throw new UnsupportedOperationException("cannot remove an element using this wrapper");
throw new UnsupportedOperationException("Cannot remove an element using this wrapper.");
}
};
+2 -2
View File
@@ -53,7 +53,7 @@ public final class MobRepository<T extends Mob> implements Iterable<T> {
}
}
if (mob == null) {
throw new NoSuchElementException("mob does not exist");
throw new NoSuchElementException("Mob does not exist.");
}
previousIndex = index;
index++;
@@ -64,7 +64,7 @@ public final class MobRepository<T extends Mob> implements Iterable<T> {
@Override
public void remove() {
if (previousIndex == -1) {
throw new IllegalStateException("cannot remove as the repository is empty");
throw new IllegalStateException("Cannot remove as the repository is empty.");
}
MobRepository.this.remove((T) mobs[previousIndex]);
previousIndex = -1;
+1 -1
View File
@@ -40,7 +40,7 @@ public final class NameUtil {
*/
public static long encodeBase37(String name) {
if (name.length() > 12) {
throw new IllegalArgumentException("name too long");
throw new IllegalArgumentException("Name too long.");
}
long l = 0L;
for (int i = 0; i < name.length(); i++) {
+1 -1
View File
@@ -119,7 +119,7 @@ public final class XmlParser {
rootNode = null;
xmlReader.parse(source);
if (rootNode == null) {
throw new SAXException("no root element!");
throw new SAXException("No root element.");
}
return rootNode;
}