|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectunbbayes.io.NetIO
public class NetIO
Manipulates input/output of NET files.
Field Summary | |
---|---|
protected long |
lineno
|
static String[] |
SUPPORTED_EXTENSIONS
Single array containing "net" |
Constructor Summary | |
---|---|
NetIO()
|
Method Summary | |
---|---|
protected String |
formatString(String string)
|
String |
getName()
Gets the name of this I/O component. |
protected int |
getNext(StreamTokenizer st)
|
String[] |
getSupportedFileExtensions(boolean isLoadOnly)
Obtains an array of file extensions supported by this network window. |
String |
getSupportedFilesDescription(boolean isLoadOnly)
Gets a description of supported file extensions, which may be shown to the user through file chooser's file filter to explain what file format are supported. |
Graph |
load(File input)
Loads a NET format file using default node/network builder. |
ProbabilisticNetwork |
load(File input,
IProbabilisticNetworkBuilder networkBuilder)
Loads a NET format file using network builder |
protected void |
load(File input,
SingleEntityNetwork net,
IProbabilisticNetworkBuilder networkBuilder)
|
protected void |
loadContinuousNodeDeclaration(StreamTokenizer st,
SingleEntityNetwork net,
IProbabilisticNetworkBuilder networkBuilder)
If the current declaration is of type "continuous node", loads that node (creating new instances using networkBuilder) and adds it to net. |
protected void |
loadHierarchicTree(StringBuffer sb,
DefaultMutableTreeNode root)
|
protected void |
loadNetHeader(StreamTokenizer st,
SingleEntityNetwork net)
Start loading net{} header from .net specification file; iterating under loadNetHeaderBody(StreamTokenizer, SingleEntityNetwork)
in order to treat each declaration. |
protected void |
loadNetHeaderBody(StreamTokenizer st,
SingleEntityNetwork net)
If a declaration inside net header is treatable, treat it. |
protected void |
loadNodeDeclaration(StreamTokenizer st,
SingleEntityNetwork net,
IProbabilisticNetworkBuilder networkBuilder)
If the current declaration is of type "node" (or "decision" or "utility"), loads that node (creating new instances using networkBuilder) and adds it to net. |
protected void |
loadNodeDeclarationBody(StreamTokenizer st,
Node node)
Reads inside the node declaration. |
protected void |
loadPotentialDataContinuous(StreamTokenizer st,
Node node)
Loads potential declaration assuming it is declaring continuous distribution |
protected void |
loadPotentialDataOrdinal(StreamTokenizer st,
Node node)
Loads potential declaration's content assuming it is declaring ordinal "stateful" probability declaration |
protected void |
loadPotentialDeclaration(StreamTokenizer st,
SingleEntityNetwork net)
If the current declaration is "potential", treat that declaration and adds it to a node contained within net. |
protected void |
processTreeNode(TreeNode node,
StringBuffer sb,
TreeModel model)
|
protected void |
readTillEOL(StreamTokenizer tokenizer)
Reads and skips all tokens before next end of line token. |
void |
save(File output,
Graph graph)
Saves a network in basic NET file format. |
protected String |
saveHierarchicTree(HierarchicTree hierarchicTree)
|
protected void |
saveNetHeader(PrintStream stream,
SingleEntityNetwork net)
Fills the PrintStream with net{} header, starting with "net {" declaration and closing with "}" |
protected void |
saveNetHeaderBody(PrintStream stream,
SingleEntityNetwork net)
Stores the content of net{[CONTENT]} header to a stream. |
protected void |
saveNodeDeclaration(PrintStream stream,
Node node,
SingleEntityNetwork net)
Writes to a PrintStream a node/decision/utility{} declaration. |
protected void |
saveNodeDeclarationBody(PrintStream stream,
Node node,
SingleEntityNetwork net)
Writes to a PrintStream the body of node/decision/utility{} declaration. |
protected void |
saveNodeLabelAndPosition(PrintStream stream,
Node node)
Stores node's label = "[LABEL]"; and position = ([X], [Y]); declarations inside "node" declaration's body |
protected void |
savePotentialDeclaration(PrintStream stream,
Node node,
SingleEntityNetwork net)
Stores to PrintStream the potential{} declaration |
protected void |
savePotentialDeclarationBody(PrintStream stream,
Node node,
SingleEntityNetwork net)
Stores to PrintStream the [BODY] of potential {[BODY]} declaration |
void |
setName(String name)
Sets the name of this I/O component. |
protected void |
setUpHierarchicTree(SingleEntityNetwork net)
Sets up the hierarchic tree after the network is completely loaded |
protected void |
setUpStreamTokenizer(StreamTokenizer st)
Configures valid/invalid character ranges of stream tokenizer. |
boolean |
supports(File file,
boolean isLoadOnly)
Returns true if the file is supported by this IO class. |
boolean |
supports(String extension,
boolean isLoadOnly)
Checks if file extension is compatible to what this i/o expects. |
protected String |
unformatString(String string)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected long lineno
public static final String[] SUPPORTED_EXTENSIONS
Constructor Detail |
---|
public NetIO()
Method Detail |
---|
public Graph load(File input) throws LoadException, IOException
load
in interface BaseIO
input
- file to be read.
LoadException
- when there were errors loading the network
IOException
- in case there were errors when manipulating files.DefaultProbabilisticNodeBuilder
public ProbabilisticNetwork load(File input, IProbabilisticNetworkBuilder networkBuilder) throws LoadException, IOException
input
- file to be read.networkBuilder:
- builder to be used in order to generate expected instances
of probabilistic network, probabilistic nodes, decision nodes and utility nodes. This
is useful if you want to reuse NetIO for networks/nodes which extends ProbabilisticNetwork,
ProbabilisticNode, DecisionNode and UtilityNode (or else NetIO will be bound to those
superclasses only).
LoadException
- when there were errors loading the network
IOException
- in case there were errors when manipulating files.IProbabilisticNetworkBuilder
public void save(File output, Graph graph) throws FileNotFoundException
save
in interface BaseIO
output
- file where the net should be saved.graph
- network to be saved.
FileNotFoundException
protected void load(File input, SingleEntityNetwork net, IProbabilisticNetworkBuilder networkBuilder) throws IOException, LoadException
IOException
LoadException
protected int getNext(StreamTokenizer st) throws IOException
IOException
protected void loadHierarchicTree(StringBuffer sb, DefaultMutableTreeNode root)
protected String saveHierarchicTree(HierarchicTree hierarchicTree)
protected void processTreeNode(TreeNode node, StringBuffer sb, TreeModel model)
protected void readTillEOL(StreamTokenizer tokenizer) throws IOException
tokenizer
- Stream tokenizer
IOException
- EOF not foundprotected String formatString(String string)
protected String unformatString(String string)
protected void setUpStreamTokenizer(StreamTokenizer st) throws IOException
st:
- StreamTokenizer to set up
IOException
protected void loadNetHeader(StreamTokenizer st, SingleEntityNetwork net) throws IOException
loadNetHeaderBody(StreamTokenizer, SingleEntityNetwork)
in order to treat each declaration.
loadNetHeaderBody(StreamTokenizer, SingleEntityNetwork)
must ignore incompatible declaration.
st
- net
-
IOException
protected void loadNetHeaderBody(StreamTokenizer st, SingleEntityNetwork net) throws IOException
st
- net
-
IOException
protected void loadNodeDeclaration(StreamTokenizer st, SingleEntityNetwork net, IProbabilisticNetworkBuilder networkBuilder) throws IOException, LoadException
st
- net
- networkBuilder
-
IOException
LoadException
protected void loadContinuousNodeDeclaration(StreamTokenizer st, SingleEntityNetwork net, IProbabilisticNetworkBuilder networkBuilder) throws IOException, LoadException
st
- net
- networkBuilder
-
IOException
LoadException
protected void loadPotentialDeclaration(StreamTokenizer st, SingleEntityNetwork net) throws IOException, LoadException
st
- net
-
IOException
LoadException
protected void setUpHierarchicTree(SingleEntityNetwork net)
net
- protected void loadNodeDeclarationBody(StreamTokenizer st, Node node) throws IOException, LoadException
st
- node:
- node to be filled
IOException
LoadException
protected void loadPotentialDataOrdinal(StreamTokenizer st, Node node) throws LoadException, IOException
st
- node
-
LoadException
IOException
protected void loadPotentialDataContinuous(StreamTokenizer st, Node node) throws LoadException, IOException
st
- node
-
LoadException
IOException
protected void saveNetHeader(PrintStream stream, SingleEntityNetwork net)
stream:
- stream to write tonet:
- network to be saved to streamprotected void saveNetHeaderBody(PrintStream stream, SingleEntityNetwork net)
stream
- net
- protected void saveNodeDeclaration(PrintStream stream, Node node, SingleEntityNetwork net)
stream
- node
- net
- protected void saveNodeDeclarationBody(PrintStream stream, Node node, SingleEntityNetwork net)
stream
- node
- net
- protected void savePotentialDeclaration(PrintStream stream, Node node, SingleEntityNetwork net)
stream
- node
- net
- protected void savePotentialDeclarationBody(PrintStream stream, Node node, SingleEntityNetwork net)
stream
- node
- net
- protected void saveNodeLabelAndPosition(PrintStream stream, Node node)
stream
- node
- public boolean supports(String extension, boolean isLoadOnly)
extension
- isLoadOnly
-
supports(File, boolean)
public String[] getSupportedFileExtensions(boolean isLoadOnly)
BaseIO
getSupportedFileExtensions
in interface BaseIO
isLoadOnly
- : if set to true, it should consider file extensions for file loading (input).
If set to false, it should consider both saving and loading. Note
that not every module/plugin can implement both loading and saving, and this parameter may separate such
special behaviors.
public String getSupportedFilesDescription(boolean isLoadOnly)
BaseIO
getSupportedFilesDescription
in interface BaseIO
isLoadOnly
- : if set to true, it should consider file extensions for file loading (input).
If set to false, it should consider both saving and loading. Note
that not every module/plugin can implement both loading and saving, and this parameter may separate such
special behaviors.public boolean supports(File file, boolean isLoadOnly)
BaseIO
supports
in interface BaseIO
file
- : the file to analyze extension.isLoadOnly
- : if set to true, it should consider file extensions for file loading (input).
If set to false, it should consider both saving and loading. Note
that not every I/O class can implement both loading and saving, and this parameter may separate such
special behaviors.
public String getName()
BaseIO
getName
in interface BaseIO
public void setName(String name)
BaseIO
setName
in interface BaseIO
name
- the name to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |