B4J Question EDN-Java

B4JExplorer

Active Member
Licensed User
Longtime User
I'm still partly fuzzy on parts of the JReflections library and JavaObject.


Based on https://github.com/bpsm/edn-java

, what am I doing wrong here?

B4X:
	Private jo_DefaultConfiguration As JavaObject
	jo_DefaultConfiguration.InitializeStatic( "us.bpsm.edn.parser.Parsers.defaultConfiguration" )

It's returning a Class not found error.

edn-java-0.5.0.jar is properly included as an additional jar, and I'm able to run some of its methods by using inline java, e.g. parsing out EDN strings and determining their types. But I'm trying to do as much as possible, inside of B4J.
 
Last edited:

B4JExplorer

Active Member
Licensed User
Longtime User
I think this is close, to how it should be done. The only problem is, the final map object jo_m_Value, doesn't contain all of the elements. It's a Delegating List, which seems right. But it converts :five keyword to the string 'five'.

Does this look right, overall?

B4X:
	Private s_EDN As String
	s_EDN = "( + :five (* 7 9 ) )"


	Private jo_EDN As JavaObject
	Private jr_EDN As Reflector
	Private jo_DefaultConfiguration As JavaObject
	Private jo_Parseable As JavaObject
	Private jo_Parsers As JavaObject
	Private jo_Parser As JavaObject


	jo_Parsers.InitializeStatic( "us.bpsm.edn.parser.Parsers" )
	jo_Parseable = jo_Parsers.RunMethod( "newParseable", Array( s_EDN ) )
	
	jo_DefaultConfiguration = jo_Parsers.RunMethod( "defaultConfiguration", Null )
	
	jo_Parser = jo_Parsers.RunMethod( "newParser", Array( jo_DefaultConfiguration ) )
	
	
	Private jo_Value As JavaObject
	
	jo_Value = jo_Parser.RunMethod( "nextValue", Array( jo_Parseable ) )
	
	Log( jo_Value.RunMethod( "getClass", Null ) )
 
Last edited:
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
I think this is close, to how it should be done. The only problem is, the final map object jo_m_Value, doesn't contain all of the elements. It's a Delegating List, which seems right. But it converts :five keyword to the string 'five'.

Does this look right, overall?

B4X:
	Private s_EDN As String
	s_EDN = "( + :five (* 7 9 ) )"


	Private jo_EDN As JavaObject
	Private jr_EDN As Reflector
	Private jo_DefaultConfiguration As JavaObject
	Private jo_Parseable As JavaObject
	Private jo_Parsers As JavaObject
	Private jo_Parser As JavaObject


	jo_Parsers.InitializeStatic( "us.bpsm.edn.parser.Parsers" )
	jo_Parseable = jo_Parsers.RunMethod( "newParseable", Array( s_EDN ) )
	
	jo_DefaultConfiguration = jo_Parsers.RunMethod( "defaultConfiguration", Null )
	
	jo_Parser = jo_Parsers.RunMethod( "newParser", Array( jo_DefaultConfiguration ) )
	
	
	Private jo_Value As JavaObject
	
	jo_Value = jo_Parser.RunMethod( "nextValue", Array( jo_Parseable ) )
	
	Log( jo_Value.RunMethod( "getClass", Null ) )
Ok, I'm gonna stop editing and replying. It makes sense, now. The 'five' is returned as a symbol type, which means that the symbol is :five.

Everything's good. If anyone has comments or suggestions or would like to make use of any of this, feel free.

Thanks for all the conveniences, Erel.
 
Upvote 0
Top