Java Doc for ScriptParser.java in  » Science » Cougaar12_4 » org » cougaar » core » examples » mobility » ldm » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » Cougaar12_4 » org.cougaar.core.examples.mobility.ldm 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.cougaar.core.examples.mobility.ldm.ScriptParser

ScriptParser
class ScriptParser (Code)
Package-private script parser.

Note that, at this time, the scripting language is rather limited. Future enhancements will include variables, conditionals, loops, math, etc.

Expects lines of text:

  • Empty lines are ignored
  • Lines starting with "#" are ignored
  • Lines starting with "label " are goto labels, and require a name (e.g. "label X").
  • Lines starting with "goto " are goto commands, and require a name (e.g. "goto X"). They may branch forward or backwards in the script, but the label name must be contained in the script.
  • Lines starting with "move " are mobility step commands, and are detailed below.

"move" commands, also called "step"s, look like: (example)

 move ActorAgent, ^0:30, +1:20, MobileAgent, OrigNode, DestNode, true
 

and require 7 comma-separated parameters:
  1. actor
    The agent that should run the step. If an empty value is specified then the script runner's agent is assumed.
  2. [+^@]pauseTime with ":" time dividers
    The pause time before starting the move. See the notes below on time formats.

    If no value or a negative value is specified, then there will be zero pause.

  3. [+^@]timeoutTime with ":" time dividers
    The timeout time for the move, relative to before the above (optional) pause time. See the notes below on time formats.

    If no value or a negative value is specified, then there will be no timeout.

  4. mobileAgent
    Agent that should be moved, or the script runner's agent if an empty value is specified.
  5. origNode
    Node that the mobile agent should be on when the move is started, or an empty value if any node is allowed.
  6. destNode
    Node that the mobile agent should be on when the move has completed, or an empty value if the agent should move to its current node. See the "forceRestart" option below.
  7. forceRestart
    Specify "true" if the mobile agent should be fully restarted, even if the destination node is the same as that agent's starting node.

Time is formatted as [+^@]time, where the time is further separated with : and .characters:

  1. If + is specified then the time is relative to the runtime start of the current step. This can be used to create a sequence of moves where you're not counting the time to do the agent move.
  2. If ^ is specified then the time is relative to the runtime start of the prior step excluding the pause time (same as + on the first step). This can be used to create a sequence of moves where you want to count the move as part of the pause time.
  3. If @ is specified then the time is relative to the start time of first step in the script (same as + on the first step)
  4. If no [+^@] modifier is used an absolute system time in millseconds since Jan 1st 1970 is assumed.
  5. If no ":" or "." is present in the time, then milliseconds is assumed.
  6. If one ":" is present and no ".", then the time is the addition of the value before the ":" as minutes, and the value after the ":" as milliseconds, i.e.:
     (v[1] + 1000 * (v[0]))
     
  7. If one ":" and one "." is present, then the formula yields minutes:seconds.millis
     (v[3] + 1000 * (v[1] * 60 * (v[0])))
     

Ugly example script:

 # my comment
 # pause until it's 20 seconds after the script launch
 # move agent A from node X to node Y
 # no timeout for this move
 move , @0:20, , A, X, Y,
 # pause until it's 60 seconds after script launch
 # move agent A from whichever node it happens to be to node Z
 # timeout if the move doesn't complete within
 #    30 seconds (which is equivalent to @(60+30) == @90
 move , @0:60, +:30, A, , Z,
 # pause until at least 50 seconds have passed since the
 #   prior move was started (excluding the above 60 second
 #   pause).  If the above agent move took 10 seconds, this
 #   would be equivalent to @(60+50-10) == @100
 # have agent B request that agent A move to node X
 # timeout if the move doesn't complete before it's 
 #   1 minute 5 seconds 100 milliseconds after the script
 #   launch
 move B, ^0:50, @1:5.1, A, , X,
 # pause for 30 seconds
 # move A to X
 # no timeout for this move
 # force a restart even if agent A is already on node X
 move , +:30, , A, , X, true
 # begin an infinite loop
 label foo
 # pause for 30 seconds
 # move B from X to Y
 # timeout after 60 seconds
 move , +:30, +:60, B, X, Y,
 # pause until it's 1 minute 20 seconds after the prior 
 #   started its move (after its 30 second pause)
 # move B back
 # timeout after 1 minute
 move , ^1:20, +1:, B, Y, X,
 # note that we can't use "@" times in a loop
 # keep moving B back and forth forever
 goto foo
 # never reach here!
 




Method Summary
public static  Listparse(String text)
    



Method Detail
parse
public static List parse(String text)(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.