From b926296901ce9c088cf3a376a3bc809306a5a556 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 23 May 2008 13:34:46 +0000 Subject: [PATCH] add some properties make setters package-private git-svn-id: http://trooper/svn/projects/jSite/trunk@935 c3eda9e8-030b-0410-8277-bc7414b0a119 --- src/net/pterodactylus/jsite/core/Request.java | 108 +++++++++++++++++++++++--- 1 file changed, 99 insertions(+), 9 deletions(-) diff --git a/src/net/pterodactylus/jsite/core/Request.java b/src/net/pterodactylus/jsite/core/Request.java index 82df6f8..6f05e7b 100644 --- a/src/net/pterodactylus/jsite/core/Request.java +++ b/src/net/pterodactylus/jsite/core/Request.java @@ -57,6 +57,15 @@ public class Request extends AbstractBean { /** Name of the “client token” property. */ public static final String PROPERTY_CLIENT_TOKEN = "clientToken"; + /** Name of the “finished” property. */ + public static final String PROPERTY_FINISHED = "finished"; + + /** Name of the “successful” property. */ + public static final String PROPERTY_SUCCESSFUL = "successful"; + + /** Name of the “fetchable” property. */ + public static final String PROPERTY_FETCHABLE = "fetchable"; + /** Name of the “total blocks” property. */ public static final String PROPERTY_TOTAL_BLOCKS = "totalBlocks"; @@ -87,6 +96,15 @@ public class Request extends AbstractBean { /** The client token of the request. */ private String clientToken; + /** Whether the request is finished. */ + private boolean finished; + + /** Whether the request was finished successfully. */ + private boolean successful; + + /** Whether the data is already fetchable (in case of put requests). */ + private boolean fetchable; + /** The total number of blocks. */ private int totalBlocks; @@ -156,8 +174,7 @@ public class Request extends AbstractBean { * @param type * The type of the request */ - - public void setType(Type type) { + void setType(Type type) { Type oldType = this.type; this.type = type; fireIfPropertyChanged(PROPERTY_TYPE, oldType, type); @@ -178,13 +195,86 @@ public class Request extends AbstractBean { * @param clientToken * The client token of the request */ - public void setClientToken(String clientToken) { + void setClientToken(String clientToken) { String oldClientToken = this.clientToken; this.clientToken = clientToken; fireIfPropertyChanged(PROPERTY_CLIENT_TOKEN, oldClientToken, clientToken); } /** + * Returns whether the request has finished. + * + * @see #isSuccessful() + * @return true if the request is finished, + * false otherwise + */ + public boolean isFinished() { + return finished; + } + + /** + * Sets whether the request has finished. + * + * @param finished + * true if the request has finished, + * false otherwise + */ + void setFinished(boolean finished) { + boolean oldFinished = this.finished; + this.finished = finished; + firePropertyChange(PROPERTY_FINISHED, oldFinished, finished); + } + + /** + * Returns whether the request finished successfully. This value will only + * have meaning if {@link #isFinished()} returns true. + * + * @return true if the request finished successfully, + * false otherwise + */ + public boolean isSuccessful() { + return successful; + } + + /** + * Sets whether this request finished successfully. + * + * @param successful + * true if the request finished successfully, + * false otherwise + */ + void setSuccessful(boolean successful) { + boolean oldSuccessful = this.successful; + this.successful = successful; + firePropertyChange(PROPERTY_SUCCESSFUL, oldSuccessful, successful); + } + + /** + * Returns whether the data inserted by this {@link Type#put} or + * {@link Type#putDir} request is already fetchable by other clients. + * + * @return true if the data is already fetchable, + * false otherwise + */ + public boolean isFetchable() { + return fetchable; + } + + /** + * Sets whether the data inserted by this {@link Type#put} or + * {@link Type#putDir} request is already fetchable by other clients. + * + * @param fetchable + * true if the data is already fetchable, + * false otherwise + */ + void setFetchable(boolean fetchable) { + boolean oldFetchable = this.fetchable; + this.fetchable = fetchable; + firePropertyChange(PROPERTY_FETCHABLE, oldFetchable, fetchable); + } + + /** * Returns the total number of blocks of a request. Until * {@link #isTotalFinalized()} returns true this value may * change! @@ -201,7 +291,7 @@ public class Request extends AbstractBean { * @param totalBlocks * The total number of blocks */ - public void setTotalBlocks(int totalBlocks) { + void setTotalBlocks(int totalBlocks) { int oldTotalBlocks = this.totalBlocks; this.totalBlocks = totalBlocks; fireIfPropertyChanged(PROPERTY_TOTAL_BLOCKS, oldTotalBlocks, totalBlocks); @@ -218,7 +308,7 @@ public class Request extends AbstractBean { * @param requiredBlocks * the requiredBlocks to set */ - public void setRequiredBlocks(int requiredBlocks) { + void setRequiredBlocks(int requiredBlocks) { int oldRequiredBlocks = this.requiredBlocks; this.requiredBlocks = requiredBlocks; fireIfPropertyChanged(PROPERTY_REQUIRED_BLOCKS, oldRequiredBlocks, requiredBlocks); @@ -235,7 +325,7 @@ public class Request extends AbstractBean { * @param successfulBlocks * the successfulBlocks to set */ - public void setSuccessfulBlocks(int successfulBlocks) { + void setSuccessfulBlocks(int successfulBlocks) { int oldSuccessfulBlocks = this.successfulBlocks; this.successfulBlocks = successfulBlocks; fireIfPropertyChanged(PROPERTY_SUCCESSFUL_BLOCKS, oldSuccessfulBlocks, successfulBlocks); @@ -252,7 +342,7 @@ public class Request extends AbstractBean { * @param failedBlocks * the failedBlocks to set */ - public void setFailedBlocks(int failedBlocks) { + void setFailedBlocks(int failedBlocks) { int oldFailedBlocks = this.failedBlocks; this.failedBlocks = failedBlocks; fireIfPropertyChanged(PROPERTY_FAILED_BLOCKS, oldFailedBlocks, failedBlocks); @@ -269,7 +359,7 @@ public class Request extends AbstractBean { * @param fatallyFailedBlocks * the fatallyFailedBlocks to set */ - public void setFatallyFailedBlocks(int fatallyFailedBlocks) { + void setFatallyFailedBlocks(int fatallyFailedBlocks) { int oldFatallyFailedBlocks = this.fatallyFailedBlocks; this.fatallyFailedBlocks = fatallyFailedBlocks; fireIfPropertyChanged(PROPERTY_FATALLY_FAILED_BLOCKS, oldFatallyFailedBlocks, fatallyFailedBlocks); @@ -286,7 +376,7 @@ public class Request extends AbstractBean { * @param totalFinalized * the totalFinalized to set */ - public void setTotalFinalized(boolean totalFinalized) { + void setTotalFinalized(boolean totalFinalized) { boolean oldTotalFinalized = this.totalFinalized; this.totalFinalized = totalFinalized; fireIfPropertyChanged(PROPERTY_TOTAL_FINALIZED, oldTotalFinalized, totalFinalized); -- 2.7.4