Skip to content

Commit

Permalink
FORGE-1633: Introduced WriteableResource
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Mar 4, 2014
1 parent 48b8ce0 commit 78fdd2e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.jboss.forge.addon.resource;

import java.io.File;
import java.io.InputStream;
import java.nio.charset.Charset;

import org.jboss.forge.addon.resource.monitor.ResourceMonitor;

Expand All @@ -11,7 +9,7 @@
*
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
public interface FileResource<T extends FileResource<T>> extends Resource<File>
public interface FileResource<T extends FileResource<T>> extends Resource<File>, WriteableResource<T>
{
/**
* Return true if this {@link FileResource} exists and is actually a directory, otherwise return false;
Expand Down Expand Up @@ -49,31 +47,6 @@ public interface FileResource<T extends FileResource<T>> extends Resource<File>
*/
public void deleteOnExit();

/**
* Set the contents of this {@link FileResource} to the given {@link String} using UTF-8 encoding.
*/
public T setContents(String data);

/**
* Set the contents of this {@link FileResource} to the given {@link String} using the specified encoding.
*/
public T setContents(String data, Charset charset);

/**
* Set the contents of this {@link FileResource} to the given character array using UTF-8 encoding.
*/
public T setContents(final char[] data);

/**
* Set the contents of this {@link FileResource} to the given character array using the specified encoding.
*/
public T setContents(final char[] data, Charset charset);

/**
* Set the contents of this {@link FileResource} to the contents of the given {@link InputStream}.
*/
public T setContents(final InputStream data);

/**
* Create the file in the underlying resource system. Necessary directory paths will be created automatically.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.addon.resource;

import java.io.InputStream;
import java.nio.charset.Charset;

/**
* A {@link WriteableResource} allows its contents to be changed
*
* @author <a href="ggastald@redhat.com">George Gastaldi</a>
*/
public interface WriteableResource<T extends WriteableResource<T>>
{
/**
* Set the contents of this {@link WriteableResource} to the given {@link String} using UTF-8 encoding.
*/
T setContents(String data);

/**
* Set the contents of this {@link WriteableResource} to the given {@link String} using the specified encoding.
*/
T setContents(String data, Charset charset);

/**
* Set the contents of this {@link WriteableResource} to the given character array using UTF-8 encoding.
*/
T setContents(char[] data);

/**
* Set the contents of this {@link WriteableResource} to the given character array using the specified encoding.
*/
T setContents(char[] data, Charset charset);

/**
* Set the contents of this {@link WriteableResource} to the contents of the given {@link InputStream}.
*/
T setContents(InputStream data);

}

0 comments on commit 78fdd2e

Please sign in to comment.