1 package org.onap.sdc.dcae.checker;
3 import org.onap.sdc.common.onaplog.OnapLoggerDebug;
4 import org.onap.sdc.common.onaplog.OnapLoggerError;
6 import java.io.InputStream;
7 import java.io.InputStreamReader;
9 import java.io.BufferedReader;
10 import java.io.IOException;
14 import java.net.MalformedURLException;
17 * Represents a yaml document to be parsed/validated/checked
21 private static OnapLoggerError errLogger = OnapLoggerError.getInstance();
22 private static OnapLoggerDebug debugLogger = OnapLoggerDebug.getInstance();
25 private String name; //maintained mainly for logging
27 private Object target; //this is the parsed form of the target
29 private Report report = new Report(); //collects the errors related to this target
31 public Target(String theName, URI theLocation) {
33 this.location = theLocation;
36 public String getName() {
40 public URI getLocation() {
44 public Report getReport() {
48 public void report(Throwable theError) {
49 this.report.add(theError);
52 public void report(String theErrMsg) {
53 this.report.add(new Exception(theErrMsg));
56 public void setTarget(Object theTarget) {
57 this.target = theTarget;
60 public Object getTarget() {
65 * @return a reader for the source or null if failed
67 public Reader open() throws IOException {
69 return new BufferedReader(
70 new InputStreamReader(
71 this.location.toURL().openStream()));
74 public String toString() {
75 //return String.format("Target %s (%.20s ...)", this.location, this.target == null ? "" : this.target.toString());
76 return String.format("Target %s at %s", this.name, this.location);