Skip to content

Commit

Permalink
#1 Ocket.Text#write(text, type) added
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegor Bugayenko committed Nov 11, 2013
1 parent 2d9f570 commit 2db49fd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
15 changes: 9 additions & 6 deletions src/main/java/com/jcabi/s3/Bucket.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,31 @@ public interface Bucket {
* Get region we're in.
* @return Region
*/
@NotNull
@NotNull(message = "region is never NULL")
Region region();

/**
* Get bucket name.
* @return Bucket name
*/
@NotNull
@NotNull(message = "bucket name is never NULL")
String name();

/**
* Get object.
* @param key Name of it in the bucket
* @return Ocket
*/
@NotNull
Ocket ocket(@NotNull String key);
@NotNull(message = "ocket is never NULL")
Ocket ocket(@NotNull(message = "S3 key can't be NULL") String key);

/**
* Delete object from bucket.
* @param key Name of it in the bucket
* @throws OcketNotFoundException If not found
*/
void remove(@NotNull String key) throws OcketNotFoundException;
void remove(@NotNull(message = "S3 key can't be NULL") String key)
throws OcketNotFoundException;

/**
* Prefixed.
Expand All @@ -94,7 +95,9 @@ final class Prefixed implements Bucket {
* @param bucket Original bucket
* @param pfx Prefix
*/
public Prefixed(final Bucket bucket, final String pfx) {
public Prefixed(
@NotNull(message = "bucket can't be NULL") final Bucket bucket,
@NotNull(message = "prefix can't be NULL") final String pfx) {
this.origin = bucket;
this.prefix = pfx;
}
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/com/jcabi/s3/Ocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,23 @@ public String read() throws IOException {
return baos.toString(CharEncoding.UTF_8);
}
/**
* Read content as string.
* Write content as string.
* @param text Text to write
* @throws IOException If fails
*/
public void write(@NotNull final String text) throws IOException {
this.write(text, "text/plain");
}
/**
* Write content as string, with a specified content type.
* @param text Text to write
* @param type Content type
* @throws IOException If fails
*/
public void write(@NotNull final String text,
@NotNull final String type) throws IOException {
final ObjectMetadata meta = new ObjectMetadata();
meta.setContentType("text/plain");
meta.setContentType(type);
meta.setContentLength((long) text.getBytes(Charsets.UTF_8).length);
meta.setContentEncoding(CharEncoding.UTF_8);
this.origin.write(
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/jcabi/s3/Region.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ public interface Region {
* @param name Name of the bucket to get
* @return Bucket
*/
Bucket bucket(String name);
@NotNull(message = "bucket is never NULL")
Bucket bucket(@NotNull(message = "bucket name can't be NULL") String name);

/**
* Get a client.
* @return Amazon S3
*/
@NotNull(message = "AWS client is never NULL")
AmazonS3 aws();

/**
Expand Down

0 comments on commit 2db49fd

Please sign in to comment.