Add 'is' prefix to boolean getters if their meaning is ambiguous

- plus minor code cleanup
- ID -> Id or id
This commit is contained in:
Trustin Lee 2012-06-12 17:58:22 +09:00
parent 61e357049e
commit fdb66b6294
4 changed files with 59 additions and 60 deletions

View File

@ -36,7 +36,7 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
}
@Override
public Set<Integer> getIDs() {
public Set<Integer> getIds() {
return settingsMap.keySet();
}
@ -86,7 +86,7 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
}
@Override
public boolean persistValue(int ID) {
public boolean isPersistValue(int ID) {
Integer key = new Integer(ID);
if (settingsMap.containsKey(key)) {
return settingsMap.get(key).getPersist();
@ -167,33 +167,33 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
private boolean persist;
private boolean persisted;
public Setting(int value, boolean persist, boolean persisted) {
Setting(int value, boolean persist, boolean persisted) {
this.value = value;
this.persist = persist;
this.persisted = persisted;
}
public int getValue() {
int getValue() {
return value;
}
public void setValue(int value) {
void setValue(int value) {
this.value = value;
}
public boolean getPersist() {
boolean getPersist() {
return persist;
}
public void setPersist(boolean persist) {
void setPersist(boolean persist) {
this.persist = persist;
}
public boolean getPersisted() {
boolean getPersisted() {
return persisted;
}
public void setPersisted(boolean persisted) {
void setPersisted(boolean persisted) {
this.persisted = persisted;
}
}

View File

@ -182,7 +182,7 @@ public class SpdyFrameEncoder extends MessageToByteEncoder<Object> {
SpdySettingsFrame spdySettingsFrame = (SpdySettingsFrame) msg;
byte flags = spdySettingsFrame.clearPreviouslyPersistedSettings() ?
SPDY_SETTINGS_CLEAR : 0;
Set<Integer> IDs = spdySettingsFrame.getIDs();
Set<Integer> IDs = spdySettingsFrame.getIds();
int numEntries = IDs.size();
int length = 4 + numEntries * 8;
out.ensureWritableBytes(SPDY_HEADER_SIZE + length);
@ -194,7 +194,7 @@ public class SpdyFrameEncoder extends MessageToByteEncoder<Object> {
for (Integer ID: IDs) {
int id = ID.intValue();
byte ID_flags = (byte) 0;
if (spdySettingsFrame.persistValue(id)) {
if (spdySettingsFrame.isPersistValue(id)) {
ID_flags |= SPDY_SETTINGS_PERSIST_VALUE;
}
if (spdySettingsFrame.isPersisted(id)) {

View File

@ -33,26 +33,26 @@ final class SpdySession {
SpdySession() {
}
public int numActiveStreams() {
int numActiveStreams() {
return activeStreams.size();
}
public boolean noActiveStreams() {
boolean noActiveStreams() {
return activeStreams.isEmpty();
}
public boolean isActiveStream(int streamID) {
boolean isActiveStream(int streamID) {
return activeStreams.containsKey(new Integer(streamID));
}
// Stream-IDs should be iterated in priority order
public Set<Integer> getActiveStreams() {
Set<Integer> getActiveStreams() {
TreeSet<Integer> StreamIDs = new TreeSet<Integer>(new PriorityComparator());
StreamIDs.addAll(activeStreams.keySet());
return StreamIDs;
}
public void acceptStream(
void acceptStream(
int streamID, byte priority, boolean remoteSideClosed, boolean localSideClosed,
int sendWindowSize, int receiveWindowSize) {
if (!remoteSideClosed || !localSideClosed) {
@ -62,7 +62,7 @@ final class SpdySession {
}
}
public boolean removeStream(int streamID) {
boolean removeStream(int streamID) {
Integer StreamID = new Integer(streamID);
StreamState state = activeStreams.get(StreamID);
activeStreams.remove(StreamID);
@ -73,12 +73,12 @@ final class SpdySession {
}
}
public boolean isRemoteSideClosed(int streamID) {
boolean isRemoteSideClosed(int streamID) {
StreamState state = activeStreams.get(new Integer(streamID));
return state == null || state.isRemoteSideClosed();
}
public void closeRemoteSide(int streamID) {
void closeRemoteSide(int streamID) {
Integer StreamID = new Integer(streamID);
StreamState state = activeStreams.get(StreamID);
if (state != null) {
@ -89,12 +89,12 @@ final class SpdySession {
}
}
public boolean isLocalSideClosed(int streamID) {
boolean isLocalSideClosed(int streamID) {
StreamState state = activeStreams.get(new Integer(streamID));
return state == null || state.isLocalSideClosed();
}
public void closeLocalSide(int streamID) {
void closeLocalSide(int streamID) {
Integer StreamID = new Integer(streamID);
StreamState state = activeStreams.get(StreamID);
if (state != null) {
@ -109,30 +109,29 @@ final class SpdySession {
* hasReceivedReply and receivedReply are only called from messageReceived
* no need to synchronize access to the StreamState
*/
public boolean hasReceivedReply(int streamID) {
boolean hasReceivedReply(int streamID) {
StreamState state = activeStreams.get(new Integer(streamID));
return state != null && state.hasReceivedReply();
}
public void receivedReply(int streamID) {
void receivedReply(int streamID) {
StreamState state = activeStreams.get(new Integer(streamID));
if (state != null) {
state.receivedReply();
}
}
public int getSendWindowSize(int streamID) {
int getSendWindowSize(int streamID) {
StreamState state = activeStreams.get(new Integer(streamID));
return state != null ? state.getSendWindowSize() : -1;
}
public int updateSendWindowSize(int streamID, int deltaWindowSize) {
int updateSendWindowSize(int streamID, int deltaWindowSize) {
StreamState state = activeStreams.get(new Integer(streamID));
return state != null ? state.updateSendWindowSize(deltaWindowSize) : -1;
}
public int updateReceiveWindowSize(int streamID, int deltaWindowSize) {
int updateReceiveWindowSize(int streamID, int deltaWindowSize) {
StreamState state = activeStreams.get(new Integer(streamID));
if (deltaWindowSize > 0) {
state.setReceiveWindowSizeLowerBound(0);
@ -140,12 +139,12 @@ final class SpdySession {
return state != null ? state.updateReceiveWindowSize(deltaWindowSize) : -1;
}
public int getReceiveWindowSizeLowerBound(int streamID) {
int getReceiveWindowSizeLowerBound(int streamID) {
StreamState state = activeStreams.get(new Integer(streamID));
return state != null ? state.getReceiveWindowSizeLowerBound() : 0;
}
public void updateAllReceiveWindowSizes(int deltaWindowSize) {
void updateAllReceiveWindowSizes(int deltaWindowSize) {
for (StreamState state: activeStreams.values()) {
state.updateReceiveWindowSize(deltaWindowSize);
if (deltaWindowSize < 0) {
@ -154,17 +153,17 @@ final class SpdySession {
}
}
public boolean putPendingWrite(int streamID, Object msg) {
boolean putPendingWrite(int streamID, Object msg) {
StreamState state = activeStreams.get(Integer.valueOf(streamID));
return state != null && state.putPendingWrite(msg);
}
public Object getPendingWrite(int streamID) {
Object getPendingWrite(int streamID) {
StreamState state = activeStreams.get(Integer.valueOf(streamID));
return state != null ? state.getPendingWrite() : null;
}
public Object removePendingWrite(int streamID) {
Object removePendingWrite(int streamID) {
StreamState state = activeStreams.get(Integer.valueOf(streamID));
return state != null ? state.removePendingWrite() : null;
}
@ -180,7 +179,7 @@ final class SpdySession {
private volatile int receiveWindowSizeLowerBound;
private final BlockingQueue<Object> pendingWriteQueue = QueueFactory.createQueue();
public StreamState(
StreamState(
byte priority, boolean remoteSideClosed, boolean localSideClosed,
int sendWindowSize, int receiveWindowSize) {
this.priority = priority;
@ -190,67 +189,67 @@ final class SpdySession {
this.receiveWindowSize = new AtomicInteger(receiveWindowSize);
}
public byte getPriority() {
byte getPriority() {
return priority;
}
public boolean isRemoteSideClosed() {
boolean isRemoteSideClosed() {
return remoteSideClosed;
}
public void closeRemoteSide() {
void closeRemoteSide() {
remoteSideClosed = true;
}
public boolean isLocalSideClosed() {
boolean isLocalSideClosed() {
return localSideClosed;
}
public void closeLocalSide() {
void closeLocalSide() {
localSideClosed = true;
}
public boolean hasReceivedReply() {
boolean hasReceivedReply() {
return receivedReply;
}
public void receivedReply() {
void receivedReply() {
receivedReply = true;
}
public int getSendWindowSize() {
int getSendWindowSize() {
return sendWindowSize.get();
}
public int updateSendWindowSize(int deltaWindowSize) {
int updateSendWindowSize(int deltaWindowSize) {
return sendWindowSize.addAndGet(deltaWindowSize);
}
public int updateReceiveWindowSize(int deltaWindowSize) {
int updateReceiveWindowSize(int deltaWindowSize) {
return receiveWindowSize.addAndGet(deltaWindowSize);
}
public int getReceiveWindowSizeLowerBound() {
int getReceiveWindowSizeLowerBound() {
return receiveWindowSizeLowerBound;
}
public void setReceiveWindowSizeLowerBound(int receiveWindowSizeLowerBound) {
void setReceiveWindowSizeLowerBound(int receiveWindowSizeLowerBound) {
this.receiveWindowSizeLowerBound = receiveWindowSizeLowerBound;
}
public boolean putPendingWrite(Object msg) {
boolean putPendingWrite(Object msg) {
return pendingWriteQueue.offer(msg);
}
public Object getPendingWrite() {
Object getPendingWrite() {
return pendingWriteQueue.peek();
}
public Object removePendingWrite() {
Object removePendingWrite() {
return pendingWriteQueue.poll();
}
public boolean clearPendingWrites() {
boolean clearPendingWrites() {
if (pendingWriteQueue.isEmpty()) {
return false;
}

View File

@ -35,24 +35,24 @@ public interface SpdySettingsFrame {
* Returns a {@code Set} of the setting IDs.
* The set's iterator will return the IDs in ascending order.
*/
Set<Integer> getIDs();
Set<Integer> getIds();
/**
* Returns {@code true} if the setting ID has a value.
*/
boolean isSet(int ID);
boolean isSet(int id);
/**
* Returns the value of the setting ID.
* Returns -1 if the setting ID is not set.
*/
int getValue(int ID);
int getValue(int id);
/**
* Sets the value of the setting ID.
* The ID must be positive and cannot exceed 16777215.
*/
void setValue(int ID, int value);
void setValue(int id, int value);
/**
* Sets the value of the setting ID.
@ -60,39 +60,39 @@ public interface SpdySettingsFrame {
* Sets if the setting is persisted (should only be set by the client).
* The ID must be positive and cannot exceed 16777215.
*/
void setValue(int ID, int value, boolean persistVal, boolean persisted);
void setValue(int id, int value, boolean persistVal, boolean persisted);
/**
* Removes the value of the setting ID.
* Removes all persistance information for the setting.
* Removes all persistence information for the setting.
*/
void removeValue(int ID);
void removeValue(int id);
/**
* Returns {@code true} if this setting should be persisted.
* Returns {@code false} if this setting should not be persisted
* or if the setting ID has no value.
*/
boolean persistValue(int ID);
boolean isPersistValue(int id);
/**
* Sets if this setting should be persisted.
* Has no effect if the setting ID has no value.
*/
void setPersistValue(int ID, boolean persistValue);
void setPersistValue(int id, boolean persistValue);
/**
* Returns {@code true} if this setting is persisted.
* Returns {@code false} if this setting should not be persisted
* or if the setting ID has no value.
*/
boolean isPersisted(int ID);
boolean isPersisted(int id);
/**
* Sets if this setting is persisted.
* Has no effect if the setting ID has no value.
*/
void setPersisted(int ID, boolean persisted);
void setPersisted(int id, boolean persisted);
/**
* Returns {@code true} if previously persisted settings should be cleared.