ObjectScript Library.FileBinaryStream convert into a string - intersystems-cache

How can I create a string a from binary stream? I tried StreamGet and OutputToDevice class methods but that is not returning the string. Is there another class I should use
Thanks :)

Assuming that stream is a %Library.FileBinaryStream:
set string = stream.Read($$$MaxStringLength)
Note that string can't be more than 7mb, while stream can be bigger.

Related

Dart - Read Keys and Values from a Map inside a Map

I have a variable with the following structure:
final Map<String, Map<double, String>> ingredients;
I need to access, as string, the "inner" map keys and values after indexing the external map:
ingredients.keys.elementAt(index)
The above code returns a "regular string", but when accessing the "inner" map:
ingredients.values.elementAt(index).keys
The result prints with round brackets around it. I suppose it occurs because the first example returns a string and the second returns an Itarable. But how do I make it a string without the round brackets?
.toString() does not work.
I can't make it a single Map<String, String> because I need the double value separated from the second string (a unit specification).
I will put the result inside a Flutter Text() widget inside a ListView.builder(), that is the reason of the indexing.
Resuming: I am getting (200)(g) and I need 200g.
Thanks for the attention. Any help is appreciated.
try this -
var _value = ingredients.values.elementAt(index).values;
print(_value.substring(1,_value.length-1));
Not a pretty solution but you can try: ingredients.values.elementAt(index).keys.toString().replaceAll(RegExp(r'[\(\)]'),'');
which will remove the parentheses anywhere in the keys.
I ran into the same problem as you did.
Hope this helps!

How to convert data in unityscript

Now I have data like this "1234567890", first it is System.Object
I want convert it to long.
I tried like this
(long) data
data as long
data as System.Int64
It seems they all not work,anyone can help me?
First got your object as string if needed:
string mystringnumber = mysystemobject as String;
You can use this:
long.parse(mystringnumber);
or:
if (long.TryParse(mystringnumber,null))
{
dosomething();
}

NTriplesParser extract textual value from string

I am using dotnetrdf and trying to parse some triples with NTriplesParser. I have my own handler RobHandler in which I process each triple in turn.
public class RobHandler : BaseRdfHandler
{
protected override bool HandleTripleInternal(Triple t)
{
string predicateUrl = ((BaseUriNode)(t.Predicate)).Uri.AbsoluteUri;
string value = t.Object.ToString();
}
}
This works fine but I want to get the object minus the language. My objects look like "Lincoln"#en. I could obviously write some code to remove the #en bit, but I'd rather use some library code rather than my own that hard-coded strings like #en. To do this I think I need to create a LiteralNode but there doesn't seem to be a way to get from a string which is what I have (my variable value) to a LiteralNode.
How can I extract just the textual value from an object string?
Actually I think I have the answer myself:
if (t.Object.NodeType == NodeType.Literal)
{
var node = (ILiteralNode)t.Object;
}

How to send list of string values as "LIST" object in Dozer (custom-converter-param)?

Currently the list is passed in the custom-converter-param as "aa,bb,cc,dd" etc., but the parameter is passed as string and we need to again split the string with comma and finally save it as a list for processing.
Is there is a way to pass the list of string object as "List" as a parameter?
Thanks,
Kathir
In every custom converter the value of the property custom-converter-param is passed to the field parameter of type String in org.dozer.DozerConverter<A, B> class, and its only getter method contract is like this:
public String getParameter()
So No, is not possible to retrieve the value as a List. The simplest/best thing to do here is to create a method getParameterAsList in your own converter to split the String value.

GWT messages interface with lookup support

I'm working on a new application and i need to make a messages interface with lookup, using the key to find the value (like ConstantsWithLookup, but capable to receive parameters). I have being investigating Dictionary class functionality but it lacks message customization through parameters.
With ConstantsWithLookup i can make the following:
myConstantsWithLookupInterface.getString("key");
and get something like:
Field must be filled with numbers
But i need to do this:
myMessagesWithLookupInterface.getString("key", "param1", "param2",...);
and get something like:
Field _param1_ must be filled with numbers greater than _param2_
I have no clue how to do this.
Use GWT regular expressions:
//fields in your class
RegEx pattern1 = RegEx.compile("_param1_");
RegEx pattern2 = RegEx.compile("_param2_");
public String getString(String key, String replace1, String replace2){
// your original getString() method
String content = getString(key);
content = pattern1.replace(content,replace1);
content = pattern2.replace(content,replace2);
return content;
}
If your data contains Field _param1_ must be filled with numbers greater than _param2_ then this will replace _param1_ with content of string replace1.