Class ProtelisLoader


  • public final class ProtelisLoader
    extends java.lang.Object
    Main entry-point class for loading/parsing Protelis programs.
    • Method Detail

      • parse

        public static ProtelisProgram parse​(@Nonnull
                                            org.eclipse.emf.ecore.resource.Resource resource)
        Parameters:
        resource - the Resource containing the program to execute
        Returns:
        a ProtelisProgram
      • parse

        public static ProtelisProgram parse​(java.lang.String program)
        Parameters:
        program - Protelis module, program file or program to be prepared for execution. It must be one of: i) a valid Protelis qualifier name (Java like name, colon separated); ii) a valid URI string; iii) a valid Protelis program. Those possibilities are checked in order. The URI String can be in the form of a URL like "file:///home/user/protelis/myProgram" or a location relative to the classpath. In case, for instance, "/my/package/myProgram.pt" is passed, it will be automatically get converted to "classpath:/my/package/myProgram.pt". All the Protelis modules your program relies upon must be included in your Java classpath. The Java classpath scanning is done automatically by this constructor, linking is performed by Xtext transparently. URIs of type "platform:/" are supported, for those who work within an Eclipse environment.
        Returns:
        an ProtelisProgram comprising the constructed program
        Throws:
        java.lang.IllegalArgumentException - when the program has errors
      • parseAnonymousModule

        public static ProtelisProgram parseAnonymousModule​(java.lang.String program)
        Parameters:
        program - A valid Protelis program to be prepared for execution. All the Protelis modules your program relies upon must be included in your Java classpath. The Java classpath scanning is done automatically by this constructor, linking is performed by Xtext transparently. URIs of type "platform:/" are supported, for those who work within an Eclipse environment.
        Returns:
        a ProtelisProgram
        Throws:
        java.lang.IllegalArgumentException - when the program has errors
      • parseURI

        public static ProtelisProgram parseURI​(java.lang.String programURI)
                                        throws java.io.IOException
        Parameters:
        programURI - Protelis program file to be prepared for execution. It must be a either a valid URI string, for instance "file:///home/user/protelis/myProgram" or a location relative to the classpath. In case, for instance, "/my/package/myProgram.pt" is passed, it will be automatically get converted to "classpath:/my/package/myProgram.pt". All the Protelis modules your program relies upon must be included in your Java classpath. The Java classpath scanning is done automatically by this constructor, linking is performed by Xtext transparently. URIs of type "platform:/" are supported, for those who work within an Eclipse environment.
        Returns:
        a new ProtelisProgram
        Throws:
        java.io.IOException - when the resource cannot be found
        java.lang.IllegalArgumentException - when the program has errors
      • resourceFromString

        public static org.eclipse.emf.ecore.resource.Resource resourceFromString​(java.lang.String program)
        Parameters:
        program - the program in String format
        Returns:
        a dummy:/ resource that can be used to interpret the program