|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.wolfram.jlink.MathLinkFactory
public class MathLinkFactory
MathLinkFactory is the class that is used to construct objects of the various link interfaces (MathLink, KernelLink, and LoopbackLink). Because these are interfaces, not classes, and the actual classes that implement them are deliberately unknown to the client, "factory" methods are needed to create the actual objects used.
Most programmers will use createKernelLink() instead of createMathLink().
These methods correspond to calling one of the MLOpen functions in the C-language MathLink API.
| Constructor Summary | |
|---|---|
MathLinkFactory()
|
|
| Method Summary | |
|---|---|
static KernelLink |
createKernelLink(MathLink ml)
Creates a KernelLink by wrapping a MathLink. |
static KernelLink |
createKernelLink(java.lang.String cmdLine)
Creates a KernelLink. |
static KernelLink |
createKernelLink(java.lang.String[] argv)
Creates a KernelLink. |
static LoopbackLink |
createLoopbackLink()
Creates a LoopbackLink, a special type of link that is written to and read by the same program. |
static MathLink |
createMathLink(java.lang.String cmdLine)
Creates a MathLink. |
static MathLink |
createMathLink(java.lang.String[] argv)
Creates a MathLink. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MathLinkFactory()
| Method Detail |
|---|
public static KernelLink createKernelLink(java.lang.String cmdLine)
throws MathLinkException
Here are some examples:
// Typical launch on Windows
KernelLink ml =
MathLinkFactory.createKernelLink("-linkmode launch -linkname 'c:\\program files\\wolfram research\\mathematica\\5.1\\mathkernel.exe'");
// Typical launch on Unix
KernelLink ml =
MathLinkFactory.createKernelLink("-linkmode launch -linkname 'math -mathlink'");
// Typical launch on Mac OS X
KernelLink ml =
MathLinkFactory.createKernelLink("-linkmode launch -linkname '\"/Applications/Mathematica 5.1.app/Contents/MacOS/MathKernel\" -mathlink'");
// Typical "listen" link on any platform:
KernelLink ml =
MathLinkFactory.createKernelLink("-linkmode listen -linkname 1234 -linkprotocol tcp");
// Windows can use the default protocol for listen/connect links:
KernelLink ml =
MathLinkFactory.createKernelLink("-linkmode listen -linkname foo");
cmdLine - a string parsed as a command line
MathLinkException - if the link fails to open
public static KernelLink createKernelLink(java.lang.String[] argv)
throws MathLinkException
Here are some example argv arrays:
// Typical launch on Windows:
String[] argv = {"-linkmode", "launch", "-linkname",
"c:\\program files\\wolfram research\\mathematica\\5.1\\mathkernel.exe"};
// Typical launch on UNIX:
String[] argv = {"-linkmode", "launch", "-linkname", "math -mathlink"};
// Typical launch on Mac OS X:
String[] argv = {"-linkmode", "launch", "-linkname",
"\"/Applications/Mathematica 5.1.app/Contents/MacOS/MathKernel\" -mathlink"};
// Typical "listen" link on any platform:
String[] argv = {"-linkmode", "listen", "-linkname", "1234", "-linkprotocol", "tcp"};
// Windows can use the default protocol for listen/connect links:
String[] argv = {"-linkmode", "listen", "-linkname", "foo"};
argv - an array of string arguments
MathLinkException - if the link fails to open
public static KernelLink createKernelLink(MathLink ml)
throws MathLinkException
You give up ownership of the MathLink you pass in, meaning that it can only be used, including being closed, by the KernelLink.
ml - the MathLink to wrap
MathLinkException
public static MathLink createMathLink(java.lang.String cmdLine)
throws MathLinkException
Most programmers will use createKernelLink() instead, because they want to work with the higher-level KernelLink interface, not MathLink.
Here is an example:
MathLinkFactory.createMathLink("-linkmode listen -linkname 1234 -linkprotocol tcp");
cmdLine - a string parsed as a command line
MathLinkException - if the link does not open correctlycreateKernelLink(String)
public static MathLink createMathLink(java.lang.String[] argv)
throws MathLinkException
Most programmers will use createKernelLink() instead, because they want to work with the higher-level KernelLink interface, not MathLink.
Here is an example:
String[] argv = {"-linkmode", "listen", "-linkname", "1234", "-linkprotocol", "tcp"};
MathLinkFactory.createMathLink(argv);
argv - an array of string arguments
MathLinkException - if the link does not open correctlycreateKernelLink(String[])
public static LoopbackLink createLoopbackLink()
throws MathLinkException
MathLinkExceptionLoopbackLink
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||