B4J Question How to obtain a final value?

B4JExplorer

Active Member
Licensed User
Longtime User
How do we retrieve the value of a final object? In this case, the object is END_OF_INPUT:


public interface Parser {

/**
* The value returned by {@link #nextValue(Parseable)} to indicate
* that no more values will can be parsed form the a given
* {@link Parseable}.
*/
public static final Object END_OF_INPUT = Token.END_OF_INPUT;

...
...
 

stevel05

Expert
Licensed User
Longtime User
In what context? Are you writing a wrapper, or do you want to access it from a B4j module?
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
In what context? Are you writing a wrapper, or do you want to access it from a B4j module?
What I'm trying to do, is continue running a method nextvalue() against an object, and compare whether it's equal to END_OF_INPUT.

When the scan of the object is complete, jo_Value = jo_Parser.RunMethod( "nextValue", Array( jo_Parseable ) ) has the following structure (from the B4J debugger):

jo_Value.name = END_OF_INPUT
jo_ordinal = 0

So, I just want to test the condition whether jo_Value.name = END_OF_INPUT. But I don't know how to represent END_OF_INPUT, inside B4J.
 

Attachments

  • B4J_ParserDebugScreen.jpg
    205.4 KB · Views: 150
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I don't recognise the library you are accessing, but it looks like you should be able to get the value using JavaObject.

You will need to access the Token object and read the value of the field from there.
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
I don't recognise the library you are accessing, but it looks like you should be able to get the value using JavaObject.

You will need to access the Token object and read the value of the field from there.
Looks like END_OF_TOKEN is the first of an enum, it'll be zero.

public enum Token {

/** Signals the end of input. */
END_OF_INPUT,

/** A '(', which begins a list */
BEGIN_LIST,
....
....

Yes, I'm using a Java object, but don't know which JO method to use, which would return this value. I don't actually need the value of END_OF_TOKEN (0), just need to know how to refer to it, in order to compare it with the value returned from nextvalue.

I'm using edn-java, btw https://github.com/bpsm/edn-java
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
Looks like the value is -1.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
The easiest way to check would be just to log the returned values and see if the last one is a -1 or a string "END_OF_INPUT" maybe.
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
The easiest way to check would be just to log the returned values and see if the last one is a -1 or a string "END_OF_INPUT" maybe.
Yep, I'm doing a -1 now.

But it looks like I'm misunderstanding the use of END_OF_INPUT, to begin with. A single nextValue() call, returns the entire structure. Afterwards, it's always END_OF_INPUT, so it doesn't really need to be tested in this context.

We can close this, thanks for the assistance and insight, Steve.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…