diff options
author | Jean-Philippe Lesot <jplesot@google.com> | 2015-03-05 23:58:20 +0100 |
---|---|---|
committer | Jean-Philippe Lesot <jplesot@google.com> | 2015-03-06 13:05:08 +0000 |
commit | 6ed461d24dea889a408f7e326c2598af24e4f410 (patch) | |
tree | dd47ea8455c5a243c4cef0ebc7bccf580b5e169c /sched | |
parent | 4d1fa0045be86fc3bc8deadb81b757dcb95aac24 (diff) | |
download | toolchain_jack-6ed461d24dea889a408f7e326c2598af24e4f410.tar.gz toolchain_jack-6ed461d24dea889a408f7e326c2598af24e4f410.tar.bz2 toolchain_jack-6ed461d24dea889a408f7e326c2598af24e4f410.zip |
Add support of configurable standard input/output/error
Add API to set a dedicated standard input/output/error to a
ConfigBuilder. By this way, if defined, the parsing of '-' and
'--' take this standard definition instead of System.in/out/err.
Add also support of standard error in AbstractStreamFile hierarchy
and associated codec.
Change-Id: I1ca9521743d3ba286bd115aa24dbafd74bf693e9
Diffstat (limited to 'sched')
17 files changed, 304 insertions, 108 deletions
diff --git a/sched/src/com/android/sched/scheduler/PlanPrinterFactory.java b/sched/src/com/android/sched/scheduler/PlanPrinterFactory.java index de809282..fc0fe3b4 100644 --- a/sched/src/com/android/sched/scheduler/PlanPrinterFactory.java +++ b/sched/src/com/android/sched/scheduler/PlanPrinterFactory.java @@ -42,7 +42,7 @@ public class PlanPrinterFactory { @Nonnull public static final PropertyId<OutputStreamFile> PLAN_PRINTER_FILE = PropertyId.create( "sched.plan.printer.file", "The file where to print the plan", - new OutputStreamCodec(Existence.MAY_EXIST).allowStandard()) + new OutputStreamCodec(Existence.MAY_EXIST).allowStandardOutputOrError()) .addDefaultValue("-"); public static PlanPrinter getPlanPrinter() { diff --git a/sched/src/com/android/sched/util/codec/CodecContext.java b/sched/src/com/android/sched/util/codec/CodecContext.java index f6deebd2..e8884dee 100644 --- a/sched/src/com/android/sched/util/codec/CodecContext.java +++ b/sched/src/com/android/sched/util/codec/CodecContext.java @@ -18,6 +18,9 @@ package com.android.sched.util.codec; import com.android.sched.util.RunnableHooks; +import java.io.InputStream; +import java.io.PrintStream; + import javax.annotation.CheckForNull; import javax.annotation.Nonnull; @@ -31,6 +34,15 @@ public class CodecContext { private RunnableHooks hooks; @Nonnull + private InputStream standardInput = System.in; + + @Nonnull + private PrintStream standardOutput = System.out; + + @Nonnull + private PrintStream standardError = System.err; + + @Nonnull public CodecContext setDebug() { this.debug = true; @@ -52,4 +64,31 @@ public class CodecContext { public RunnableHooks getRunnableHooks() { return hooks; } + + @Nonnull + public InputStream getStandardInput() { + return standardInput; + } + + public void setStandardInput(@Nonnull InputStream standardInput) { + this.standardInput = standardInput; + } + + @Nonnull + public PrintStream getStandardOutput() { + return standardOutput; + } + + public void setStandardOutput(@Nonnull PrintStream standardOutput) { + this.standardOutput = standardOutput; + } + + @Nonnull + public PrintStream getStandardError() { + return standardError; + } + + public void setStandardError(@Nonnull PrintStream standardError) { + this.standardError = standardError; + } } diff --git a/sched/src/com/android/sched/util/codec/InputStreamCodec.java b/sched/src/com/android/sched/util/codec/InputStreamCodec.java index 0d86110f..de5c3fc6 100644 --- a/sched/src/com/android/sched/util/codec/InputStreamCodec.java +++ b/sched/src/com/android/sched/util/codec/InputStreamCodec.java @@ -17,10 +17,11 @@ package com.android.sched.util.codec; import com.android.sched.util.config.ConfigurationError; -import com.android.sched.util.file.AbstractStreamFile; import com.android.sched.util.file.FileOrDirectory.Existence; import com.android.sched.util.file.FileOrDirectory.Permission; import com.android.sched.util.file.InputStreamFile; +import com.android.sched.util.location.Location; +import com.android.sched.util.location.StandardInputLocation; import java.io.IOException; @@ -36,8 +37,8 @@ public class InputStreamCodec extends StreamCodec } @Nonnull - public InputStreamCodec allowStandard() { - this.allowStandard = true; + public InputStreamCodec allowStandardInput() { + this.allowStandardIO = true; return this; } @@ -45,13 +46,19 @@ public class InputStreamCodec extends StreamCodec @Override @Nonnull public String formatValue(@Nonnull InputStreamFile stream) { - return formatValue((AbstractStreamFile) stream); + if (stream.isStandard()) { + return STANDARD_IO_NAME; + } else { + return stream.getPath(); + } } @Override public void checkValue(@Nonnull CodecContext context, @Nonnull InputStreamFile stream) throws CheckingException { - checkValue(context, (AbstractStreamFile) stream); + if (stream.isStandard() && !allowStandardIO) { + throw new CheckingException("Standard input is not allowed"); + } } @Override @@ -64,14 +71,19 @@ public class InputStreamCodec extends StreamCodec } } + @Nonnull + private static final Location STANDARD_INPUT_LOCATION = new StandardInputLocation(); + @Override @Nonnull public InputStreamFile checkString(@Nonnull CodecContext context, @Nonnull String string) throws ParsingException { - super.checkString(context, string); - if (string.equals(STANDARD_IO_NAME)) { - return new InputStreamFile(); + if (!allowStandardIO) { + throw new ParsingException("Standard input can not be used"); + } + + return new InputStreamFile(context.getStandardInput(), STANDARD_INPUT_LOCATION); } else { try { return new InputStreamFile(string); diff --git a/sched/src/com/android/sched/util/codec/OutputStreamCodec.java b/sched/src/com/android/sched/util/codec/OutputStreamCodec.java index 86c3e3d2..c642f7dc 100644 --- a/sched/src/com/android/sched/util/codec/OutputStreamCodec.java +++ b/sched/src/com/android/sched/util/codec/OutputStreamCodec.java @@ -17,11 +17,12 @@ package com.android.sched.util.codec; import com.android.sched.util.config.ConfigurationError; -import com.android.sched.util.file.AbstractStreamFile; import com.android.sched.util.file.FileOrDirectory.ChangePermission; import com.android.sched.util.file.FileOrDirectory.Existence; import com.android.sched.util.file.FileOrDirectory.Permission; import com.android.sched.util.file.OutputStreamFile; +import com.android.sched.util.file.OutputStreamFile.StandardOutputKind; +import com.android.sched.util.location.Location; import java.io.IOException; @@ -53,8 +54,23 @@ public class OutputStreamCodec extends StreamCodec } @Nonnull - public OutputStreamCodec allowStandard() { - this.allowStandard = true; + public OutputStreamCodec allowStandardOutputOrError() { + this.allowStandardIO = true; + this.allowStandardError = true; + + return this; + } + + @Nonnull + public OutputStreamCodec allowStandardOutput() { + this.allowStandardIO = true; + + return this; + } + + @Nonnull + public OutputStreamCodec allowStandardError() { + this.allowStandardError = true; return this; } @@ -66,17 +82,33 @@ public class OutputStreamCodec extends StreamCodec return this; } - @Override @Nonnull public String formatValue(@Nonnull OutputStreamFile stream) { - return formatValue((AbstractStreamFile) stream); + if (stream.isStandard()) { + if (stream.getLocation().equals(StandardOutputKind.STANDARD_OUTPUT.getLocation())) { + return STANDARD_IO_NAME; + } else { + assert stream.getLocation().equals(StandardOutputKind.STANDARD_ERROR.getLocation()); + + return STANDARD_ERROR_NAME; + } + } else { + return stream.getPath(); + } } @Override public void checkValue(@Nonnull CodecContext context, @Nonnull OutputStreamFile stream) throws CheckingException { - checkValue(context, (AbstractStreamFile) stream); + Location location = stream.getLocation(); + + if (location.equals(StandardOutputKind.STANDARD_OUTPUT.getLocation()) && !allowStandardIO) { + throw new CheckingException("Standard output is not allowed"); + } else if (location.equals(StandardOutputKind.STANDARD_ERROR.getLocation()) + && !allowStandardError) { + throw new CheckingException("Standard error is not allowed"); + } } @Override @@ -93,10 +125,20 @@ public class OutputStreamCodec extends StreamCodec @Nonnull public OutputStreamFile checkString(@Nonnull CodecContext context, @Nonnull String string) throws ParsingException { - super.checkString(context, string); - if (string.equals(STANDARD_IO_NAME)) { - return new OutputStreamFile(); + if (!allowStandardIO) { + throw new ParsingException("Standard output can not be used"); + } + + return new OutputStreamFile(context.getStandardOutput(), + StandardOutputKind.STANDARD_OUTPUT.getLocation()); + } else if (string.equals(STANDARD_ERROR_NAME)) { + if (!allowStandardError) { + throw new ParsingException("Standard error can not be used"); + } + + return new OutputStreamFile(context.getStandardError(), + StandardOutputKind.STANDARD_ERROR.getLocation()); } else { try { return new OutputStreamFile(string, context.getRunnableHooks(), existence, change, append); diff --git a/sched/src/com/android/sched/util/codec/StreamCodec.java b/sched/src/com/android/sched/util/codec/StreamCodec.java index c8776eb3..47087967 100644 --- a/sched/src/com/android/sched/util/codec/StreamCodec.java +++ b/sched/src/com/android/sched/util/codec/StreamCodec.java @@ -16,12 +16,10 @@ package com.android.sched.util.codec; -import com.android.sched.util.file.AbstractStreamFile; import com.android.sched.util.file.FileOrDirectory.Existence; import com.android.sched.util.file.FileOrDirectory.Permission; import com.android.sched.util.file.StreamFile; -import javax.annotation.CheckForNull; import javax.annotation.Nonnull; /** @@ -31,8 +29,11 @@ import javax.annotation.Nonnull; public abstract class StreamCodec extends FileOrDirCodec { @Nonnull protected static final String STANDARD_IO_NAME = "-"; + @Nonnull + protected static final String STANDARD_ERROR_NAME = "--"; - protected boolean allowStandard; + protected boolean allowStandardIO = false; + protected boolean allowStandardError = false; protected StreamCodec(@Nonnull Existence existence, int permissions) { super(existence, permissions); @@ -43,65 +44,30 @@ public abstract class StreamCodec extends FileOrDirCodec { @Nonnull public String getUsage() { - StringBuilderAppender sb = new StringBuilderAppender(", "); + StringBuilder sb = new StringBuilder(); sb.append("a path to a file ("); - sb.append(getUsageDetails()); - if (allowStandard) { - StringBuilderAppender ssb = new StringBuilderAppender("/"); - - ssb.append("can be '"); - ssb.append(STANDARD_IO_NAME); - ssb.append("' for standard "); - ssb.append((permissions & Permission.READ) != 0, "input"); - ssb.append((permissions & Permission.WRITE) != 0, "output"); - - sb.append(true, ssb.toString()); - } - sb.append(")"); - return sb.toString(); - } - - @CheckForNull - protected AbstractStreamFile checkString(@Nonnull CodecContext context, @Nonnull String value) - throws ParsingException { - if (value.equals(STANDARD_IO_NAME)) { - if (!allowStandard) { - throw new ParsingException(getStandardStreamDescription() + " can not be used"); - } - } + if (allowStandardIO) { + StringBuilderAppender sbSlash = new StringBuilderAppender("/"); - return null; - } + sbSlash.append(", can be '"); + sbSlash.append(STANDARD_IO_NAME); + sbSlash.append("' for standard "); + sbSlash.append((permissions & Permission.READ) != 0, "input"); + sbSlash.append((permissions & Permission.WRITE) != 0, "output"); - protected void checkValue(@Nonnull CodecContext context, @Nonnull AbstractStreamFile stream) - throws CheckingException { - if (stream.isStandard() && !allowStandard) { - throw new CheckingException(getStandardStreamDescription() + " is not allowed"); + sb.append(sbSlash.toString()); } - } - - @Nonnull - private String getStandardStreamDescription() { - StringBuilderAppender sb = new StringBuilderAppender("/"); - - sb.append("Standard "); - sb.append((permissions & Permission.READ) != 0, "input"); - sb.append((permissions & Permission.WRITE) != 0, "output"); + if (allowStandardError) { + sb.append(", can be '"); + sb.append(STANDARD_ERROR_NAME); + sb.append("' for standard error"); + } return sb.toString(); } - - @Nonnull - protected String formatValue(@Nonnull AbstractStreamFile stream) { - if (stream.isStandard()) { - return STANDARD_IO_NAME; - } else { - return stream.getPath(); - } - } } diff --git a/sched/src/com/android/sched/util/config/AsapConfigBuilder.java b/sched/src/com/android/sched/util/config/AsapConfigBuilder.java index 421fd994..5c623eb2 100644 --- a/sched/src/com/android/sched/util/config/AsapConfigBuilder.java +++ b/sched/src/com/android/sched/util/config/AsapConfigBuilder.java @@ -39,6 +39,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.LineNumberReader; +import java.io.PrintStream; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; @@ -296,6 +297,27 @@ public class AsapConfigBuilder { } @Nonnull + public AsapConfigBuilder setStandardInput(@Nonnull InputStream in) { + context.setStandardInput(in); + + return this; + } + + @Nonnull + public AsapConfigBuilder setStandardOutput(@Nonnull PrintStream printer) { + context.setStandardOutput(printer); + + return this; + } + + @Nonnull + public AsapConfigBuilder setStandardError(@Nonnull PrintStream printer) { + context.setStandardError(printer); + + return this; + } + + @Nonnull public AsapConfigBuilder setStrictMode() { this.strict = true; diff --git a/sched/src/com/android/sched/util/config/ConfigPrinterFactory.java b/sched/src/com/android/sched/util/config/ConfigPrinterFactory.java index dbfe23ed..29c4bc25 100644 --- a/sched/src/com/android/sched/util/config/ConfigPrinterFactory.java +++ b/sched/src/com/android/sched/util/config/ConfigPrinterFactory.java @@ -38,7 +38,7 @@ public class ConfigPrinterFactory { @Nonnull public static final PropertyId<OutputStreamFile> CONFIG_PRINTER_FILE = PropertyId.create( "config.printer.file", "The file where to print the config", - new OutputStreamCodec(Existence.MAY_EXIST).allowStandard()) + new OutputStreamCodec(Existence.MAY_EXIST).allowStandardOutputOrError()) .addDefaultValue("-"); @Nonnull diff --git a/sched/src/com/android/sched/util/config/GatherConfigBuilder.java b/sched/src/com/android/sched/util/config/GatherConfigBuilder.java index 9baf7da4..a9276696 100644 --- a/sched/src/com/android/sched/util/config/GatherConfigBuilder.java +++ b/sched/src/com/android/sched/util/config/GatherConfigBuilder.java @@ -25,6 +25,7 @@ import com.android.sched.util.location.Location; import java.io.IOException; import java.io.InputStream; +import java.io.PrintStream; import java.util.Collection; import javax.annotation.CheckForNull; @@ -188,6 +189,27 @@ public class GatherConfigBuilder { } @Nonnull + public GatherConfigBuilder setStandardInput(@Nonnull InputStream in) { + builder.setStandardInput(in); + + return this; + } + + @Nonnull + public GatherConfigBuilder setStandardOutput(@Nonnull PrintStream printer) { + builder.setStandardOutput(printer); + + return this; + } + + @Nonnull + public GatherConfigBuilder setStandardError(@Nonnull PrintStream printer) { + builder.setStandardError(printer); + + return this; + } + + @Nonnull public GatherConfigBuilder setStrictMode() { builder.setStrictMode(); diff --git a/sched/src/com/android/sched/util/file/AbstractStreamFile.java b/sched/src/com/android/sched/util/file/AbstractStreamFile.java index 9b20b403..2a680d4b 100644 --- a/sched/src/com/android/sched/util/file/AbstractStreamFile.java +++ b/sched/src/com/android/sched/util/file/AbstractStreamFile.java @@ -18,10 +18,7 @@ package com.android.sched.util.file; import com.android.sched.util.RunnableHooks; import com.android.sched.util.location.FileLocation; -import com.android.sched.util.location.FileOrDirLocation; import com.android.sched.util.location.Location; -import com.android.sched.util.location.StandardInputLocation; -import com.android.sched.util.location.StandardOutputLocation; import com.android.sched.util.log.LoggerFactory; import java.io.File; @@ -49,18 +46,10 @@ public abstract class AbstractStreamFile extends FileOrDirectory { this.location = new FileLocation(file); } - protected AbstractStreamFile(int permissions) { + protected AbstractStreamFile(@Nonnull Location location) { super(null); - - assert permissions == Permission.READ || permissions == Permission.WRITE; - this.file = null; - - if (permissions == Permission.READ) { - this.location = new StandardInputLocation(); - } else { - this.location = new StandardOutputLocation(); - } + this.location = location; } protected void performChecks(@Nonnull Existence existence, int permissions, @@ -83,7 +72,7 @@ public abstract class AbstractStreamFile extends FileOrDirectory { switch (existence) { case MUST_EXIST: - AbstractStreamFile.check(file, (FileOrDirLocation) location); + AbstractStreamFile.check(file, (FileLocation) location); FileOrDirectory.checkPermissions(file, location, permissions); break; case NOT_EXIST: @@ -129,7 +118,7 @@ public abstract class AbstractStreamFile extends FileOrDirectory { } } - public static void check(@Nonnull File file, @Nonnull FileOrDirLocation location) + public static void check(@Nonnull File file, @Nonnull FileLocation location) throws NoSuchFileException, NotFileException { assert file != null; @@ -140,7 +129,7 @@ public abstract class AbstractStreamFile extends FileOrDirectory { // Check it is a file if (!file.isFile()) { - throw new NotFileException((FileLocation) location); + throw new NotFileException(location); } } diff --git a/sched/src/com/android/sched/util/file/Directory.java b/sched/src/com/android/sched/util/file/Directory.java index 28c6e4c6..55b30dac 100644 --- a/sched/src/com/android/sched/util/file/Directory.java +++ b/sched/src/com/android/sched/util/file/Directory.java @@ -18,7 +18,6 @@ package com.android.sched.util.file; import com.android.sched.util.RunnableHooks; import com.android.sched.util.location.DirectoryLocation; -import com.android.sched.util.location.FileOrDirLocation; import com.android.sched.util.location.Location; import com.android.sched.util.log.LoggerFactory; @@ -61,7 +60,7 @@ public class Directory extends FileOrDirectory { switch (existence) { case MUST_EXIST: - Directory.check(file, (FileOrDirLocation) location); + Directory.check(file, (DirectoryLocation) location); FileOrDirectory.checkPermissions(file, location, permissions); break; case NOT_EXIST: @@ -88,7 +87,7 @@ public class Directory extends FileOrDirectory { return location.getDescription(); } - public static void check(@Nonnull File file, @Nonnull FileOrDirLocation location) + public static void check(@Nonnull File file, @Nonnull DirectoryLocation location) throws NoSuchFileException, NotDirectoryException { assert file != null; @@ -99,7 +98,7 @@ public class Directory extends FileOrDirectory { // Check directory if (!file.isDirectory()) { - throw new NotDirectoryException((DirectoryLocation) location); + throw new NotDirectoryException(location); } } diff --git a/sched/src/com/android/sched/util/file/InputStreamFile.java b/sched/src/com/android/sched/util/file/InputStreamFile.java index 9f5a6d65..a693e56a 100644 --- a/sched/src/com/android/sched/util/file/InputStreamFile.java +++ b/sched/src/com/android/sched/util/file/InputStreamFile.java @@ -17,18 +17,24 @@ package com.android.sched.util.file; import com.android.sched.util.ConcurrentIOException; +import com.android.sched.util.location.Location; +import com.android.sched.util.location.StandardInputLocation; import com.android.sched.util.stream.UncloseableInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; +import javax.annotation.CheckForNull; import javax.annotation.Nonnull; /** * Class representing a input stream from a file path or a standard input. */ public class InputStreamFile extends AbstractStreamFile { + @CheckForNull + private InputStream in; + public InputStreamFile(@Nonnull String name) throws WrongPermissionException, NotFileException, NoSuchFileException { super(name, null /* hooks */); @@ -45,13 +51,19 @@ public class InputStreamFile extends AbstractStreamFile { } public InputStreamFile() { - super(Permission.READ); + super(new StandardInputLocation()); + in = System.in; + } + + public InputStreamFile(@Nonnull InputStream in, @Nonnull Location location) { + super(location); + this.in = in; } @Nonnull public InputStream getInputStream() { - if (file == null) { - return new UncloseableInputStream(System.in); + if (in != null) { + return new UncloseableInputStream(in); } else { clearRemover(); try { diff --git a/sched/src/com/android/sched/util/file/InputZipFile.java b/sched/src/com/android/sched/util/file/InputZipFile.java index 7dccb58e..670d7126 100644 --- a/sched/src/com/android/sched/util/file/InputZipFile.java +++ b/sched/src/com/android/sched/util/file/InputZipFile.java @@ -48,6 +48,7 @@ public class InputZipFile extends StreamFile { zipFile = processZip(file); } + @Nonnull private ZipFile processZip(File file) throws ZipException { try { return new ZipFile(file); diff --git a/sched/src/com/android/sched/util/file/OutputStreamFile.java b/sched/src/com/android/sched/util/file/OutputStreamFile.java index 59fa2474..055869b1 100644 --- a/sched/src/com/android/sched/util/file/OutputStreamFile.java +++ b/sched/src/com/android/sched/util/file/OutputStreamFile.java @@ -18,6 +18,9 @@ package com.android.sched.util.file; import com.android.sched.util.ConcurrentIOException; import com.android.sched.util.RunnableHooks; +import com.android.sched.util.location.Location; +import com.android.sched.util.location.StandardErrorLocation; +import com.android.sched.util.location.StandardOutputLocation; import com.android.sched.util.stream.UncloseableOutputStream; import com.android.sched.util.stream.UncloseablePrintStream; @@ -35,6 +38,9 @@ import javax.annotation.Nonnull; public class OutputStreamFile extends AbstractStreamFile { private final boolean append; + @CheckForNull + private PrintStream printer; + public OutputStreamFile(@Nonnull String name, @CheckForNull RunnableHooks hooks, @Nonnull Existence existence, @@ -77,16 +83,67 @@ public class OutputStreamFile extends AbstractStreamFile { this.append = false; } - public OutputStreamFile() { - super(Permission.WRITE); + @Nonnull + private static final Location STANDARD_OUTPUT_LOCATION = new StandardOutputLocation(); + @Nonnull + private static final Location STANDARD_ERROR_LOCATION = new StandardErrorLocation(); + + /** + * Standard output stream kinds + */ + public enum StandardOutputKind { + + STANDARD_OUTPUT { + @Override + @Nonnull + public PrintStream getPrintStream() { + return System.out; + } + + @Override + @Nonnull + public Location getLocation() { + return STANDARD_OUTPUT_LOCATION; + } + }, + + STANDARD_ERROR { + @Override + @Nonnull + public PrintStream getPrintStream() { + return System.err; + } + + @Override + @Nonnull + public Location getLocation() { + return STANDARD_ERROR_LOCATION; + } + }; + + @Nonnull + public abstract PrintStream getPrintStream(); + + @Nonnull + public abstract Location getLocation(); + } + + public OutputStreamFile(@Nonnull StandardOutputKind standardOutputKind) { + super(standardOutputKind.getLocation()); + this.printer = standardOutputKind.getPrintStream(); + this.append = true; + } + public OutputStreamFile(@Nonnull PrintStream printer, @Nonnull Location location) { + super(location); + this.printer = printer; this.append = true; } @Nonnull public OutputStream getOutputStream() { - if (file == null) { - return new UncloseableOutputStream(System.out); + if (printer != null) { + return new UncloseableOutputStream(printer); } else { clearRemover(); try { @@ -99,8 +156,8 @@ public class OutputStreamFile extends AbstractStreamFile { @Nonnull public PrintStream getPrintStream() { - if (file == null) { - return new UncloseablePrintStream(System.out); + if (printer != null) { + return new UncloseablePrintStream(printer); } else { clearRemover(); try { diff --git a/sched/src/com/android/sched/util/file/StreamFile.java b/sched/src/com/android/sched/util/file/StreamFile.java index 863b7ca4..3903dce5 100644 --- a/sched/src/com/android/sched/util/file/StreamFile.java +++ b/sched/src/com/android/sched/util/file/StreamFile.java @@ -42,10 +42,4 @@ public class StreamFile extends AbstractStreamFile { performChecks(existence, permissions, change); } - - public StreamFile(int permissions) { - super(permissions); - } - - }
\ No newline at end of file diff --git a/sched/src/com/android/sched/util/location/NoLocation.java b/sched/src/com/android/sched/util/location/NoLocation.java index bbdbd719..e158c49b 100644 --- a/sched/src/com/android/sched/util/location/NoLocation.java +++ b/sched/src/com/android/sched/util/location/NoLocation.java @@ -36,6 +36,6 @@ public class NoLocation extends Location { @Override public final int hashCode() { - return 0x12345678; + return NoLocation.class.hashCode(); } } diff --git a/sched/src/com/android/sched/util/location/StandardErrorLocation.java b/sched/src/com/android/sched/util/location/StandardErrorLocation.java new file mode 100644 index 00000000..c42cf517 --- /dev/null +++ b/sched/src/com/android/sched/util/location/StandardErrorLocation.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.sched.util.location; + +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + +/** + * Class describing a standard error. + */ +public class StandardErrorLocation extends Location { + @Override + @Nonnull + public String getDescription() { + return "standard error"; + } + + @Override + public final boolean equals(@CheckForNull Object obj) { + return obj instanceof StandardErrorLocation; + } + + @Override + public final int hashCode() { + return StandardErrorLocation.class.hashCode(); + } +} diff --git a/sched/src/com/android/sched/util/table/ReportPrinterFactory.java b/sched/src/com/android/sched/util/table/ReportPrinterFactory.java index 7a0c1e0f..50be05c7 100644 --- a/sched/src/com/android/sched/util/table/ReportPrinterFactory.java +++ b/sched/src/com/android/sched/util/table/ReportPrinterFactory.java @@ -41,7 +41,7 @@ public class ReportPrinterFactory{ @Nonnull public static final PropertyId<OutputStreamFile> REPORT_PRINTER_FILE = PropertyId.create( "sched.report.printer.file", "The file where to print the report", - new OutputStreamCodec(Existence.MAY_EXIST).allowStandard()) + new OutputStreamCodec(Existence.MAY_EXIST).allowStandardOutputOrError()) .addDefaultValue("-"); public static ReportPrinter getReportPrinter() { |