## org.autoplot.jythonsupport.JythonToJavaConverter

experiment with code which converts the Jython AST (syntax tree) into Java code. See also https://cottagesystems.com/JavaJythonConverter/ which goes the other way.

## JythonToJavaConverter( )

## TYPE_INT

## TYPE_LONG

## TYPE_FLOAT

## TYPE_STRING

## TYPE_STRING_ARRAY

## TYPE_OBJECT

## TYPE_MAP

## addImport

addImport( javax.swing.text.Document doc, String pkg, String name ) → void

add the class to the list of imports.

### Parameters

doc - the document
pkg - the Java package
name - the Java class name.

### Returns:

void (returns nothing)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## addImport

addImport( javax.swing.text.Document doc, String pkg, String name, int cursorPosition ) → void

add the class to the list of imports.

### Parameters

doc - the document
pkg - the Java package
name - the Java class name.
cursorPosition - the cursor position.

### Returns:

void (returns nothing)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## addImport

addImport( String src, String pkg, String name ) → String

add the class to the list of imports.

### Parameters

src - the Jython source
pkg - the Java package
name - the Java class name.

### Returns:

the new version of the script.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## convert

convert( String script ) → String

convert Jython script to Java

### Parameters

script - a String

### Returns:

Java attempt
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## convertReverse

convertReverse( String javaCode ) → String

The goal is to take Java snippets and turn them into Jython code. This is all overly simplistic and should be done properly. Cheesy! More TODOs: throw IllegalArgumentException -> raise exception Character.isDigit -> string.isnumeric "".startsWith -> "".startswith "".trim() -> "".strip() || -> or && -> and ! -> not int[] d -> d System.arraycopy -> for i in range(0,6): a[i]=a[i+6]

### Parameters

javaCode - a String

### Returns:

conversion to Jython-like code.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getJavaListType

getJavaListType( org.python.parser.ast.List list ) → String

return the Java type to use for the list.

### Parameters

list - an org.python.parser.ast.List

### Returns:

a String
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## guessCompletions

guessCompletions( String clas ) → java.util.List

return a list of classes which are reasonable completions for the class provided. For example, "JP" would result in "JPanel" and "JPasswordField" TODO: what if this were to run through all the known JavaDoc

### Parameters

clas - a String

### Returns:

list of completions.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## guessPackage

guessPackage( String clas ) → String

scan through the list of imports in /importLookup.jy, to see if the symbol can be imported. This will return null (None) if there are no suggestions, or the name of the package.

### Parameters

clas - the class name, for example "JSlider"

### Returns:

the package or null, for example "javax.swing"
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## hasImport

hasImport( String src, String pkg, String name ) → boolean

return true if the class has been imported. Note this is not thorough and should be reviewed at some point.

### Parameters

src - the Jython source
pkg - the Java package
name - the Java class name.

### Returns:

true if the class has been imported already.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## main

main( String[] args ) → void

### Parameters

args - a java.lang.String[]

### Returns:

void (returns nothing)
[search for examples] [view on GitHub] [view on old javadoc] [view source]