Skip to content

Commit

Permalink
Added PrintStream err argument to ClassMapper getInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbattle committed Jan 5, 2024
1 parent 3ff1b9b commit 4e4cbe0
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions vdmj/src/main/java/com/fujitsu/vdmj/mapper/ClassMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,25 @@ public class ClassMapper

/**
* Get an instance of a mapper, defined by the mapspec file name (resource).
* The error stream can be passed too, with a default getInstance that
* uses System.err.
*/
public static ClassMapper getInstance(String config)
public static ClassMapper getInstance(String config, PrintStream err)
{
ClassMapper mapper = mappers.get(config);

if (mapper == null)
{
mapper = new ClassMapper(config);
mapper = new ClassMapper(config, err);
mappers.put(config, mapper);
}

return mapper;
}

/**
* Set the instance error stream to be something other than System.err.
*/
public ClassMapper setErrStream(PrintStream err)

public static ClassMapper getInstance(String config)
{
errorStream = err;
return this; // Convenient for getInstance().setErrStream(...).convert(obj)
return getInstance(config, System.err);
}

/**
Expand Down Expand Up @@ -116,19 +114,20 @@ public ClassMapper init()
/**
* Fields used during the processing of the configuration file
*/
private final PrintStream errorStream;
private final String configFile;
private Field SELF;
private String srcPackage = "";
private String destPackage = "";
private int lineNo = 0;
private int errorCount = 0;
private PrintStream errorStream = System.err;

/**
* The private constructor, passed the resource name of the mapping file.
*/
private ClassMapper(String config)
private ClassMapper(String config, PrintStream err)
{
errorStream = err;
configFile = config;
long before = System.currentTimeMillis();

Expand Down

0 comments on commit 4e4cbe0

Please sign in to comment.