Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FORGE-1633: Introduced WriteableResource #396

Merged
merged 1 commit into from Mar 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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
@@ -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);

}