NumberFormatException Trim Variable - trim

TITLE = Float.parseFloat(dataRecord.get("TITLE"));
String trimmed = TITLE.substring(0,40); // get the first 40 chars.
"Title" can be a numerical and nonnumerical variable. Trying to trim my string "TITLE" to 40 characters
The error message was: NumberFormatException (line 4): For input string: "New Travel 3PC 28"/24"/20" Rolling Expandable Upright Luggage Set"-- Method Invocation Float.parseFloat

The error message says the value resulted from dataRecord.get("TITLE") is not a number as Float.parseFloat() method expects. In fact, the value that is passed to this function which has caused error has also been shown which is "New Travel 3PC 28"/24"/20" Rolling Expandable Upright Luggage Set".
So, this error has nothing to do with trimming the string. You must check why the value in "TITLE" field of your record is not what you expect to be.

Related

rkafka.read() doesn't return a message (Returns double quotes only)

Trying to return a message through rkafka library in R.
Followed the same rkafka documentation # https://cran.r-project.org/web/packages/rkafka/vignettes/rkafka.pdf
Output returns "" without the actual message in it. Kafka tool confirms that the message is sent by the producer.
CODE:
prod1=rkafka.createProducer("127.0.0.1:9092")
rkafka.send(prod1,"test","127.0.0.1:9092","Testing once")
rkafka.closeProducer(prod1)
consumer1=rkafka.createConsumer("127.0.0.1:2181","test")
print(rkafka.read(consumer1))
Output:
[1] ""
Desired Output would return "Testing once".
In order to read the messages of a topic that have already been written to the topic (before the consumer has been started) you need to set offset value to the smallest possible (equivalent to --from-beginning). According to rkafka docs autoOffseetReset argument defaults to largest
autoOffsetReset
smallest : automatically reset the offset to the
smallest offset largest : automatically reset the offset to the
largest offset anything else: throw exception to the consumer
Required:Optional Type:String default:largest
In order to be able to consume messages you need to set autoOffsetReset to "smallest".
consumer1=rkafka.createConsumer("127.0.0.1:2181","test", autoOffsetReset="smallest")
Update: This Code Works:
library(rkafka)
prod1=rkafka.createProducer("127.0.0.1:9092")
rkafka.send(prod1,"test","127.0.0.1:9092","Testing once")
rkafka.send(prod1,"test","127.0.0.1:9092","Testing twice")
rkafka.closeProducer(prod1)
consumer1=rkafka.createConsumer("127.0.0.1:2181","test",groupId = "test-consumer-
group",zookeeperConnectionTimeoutMs = "100000",autoCommitEnable = "NULL",
autoCommitInterval = "NULL",autoOffsetReset = "NULL")
print(rkafka.read(consumer1))
print(rkafka.readPoll(consumer1))
rkafka.closeConsumer(consumer1)
The key is to restart Kafka after deleting the logs it generates.

Out of range error by segmented entry

I have new table. In which I created two new fields
1) Name --> Dimension, EDT--> DimensionDynamicAccount
2) Name --> AccountType, EDT--> LedgerJournalACType
Now I want look up same as in "LedgerJournalTransDaily" form. i.e When Accounttype == Ledger then Lookup from LedgerAccount
When Accounttype == Customer then Lookup from CustTable.
For This I have followed the step in Page 19 in white paper"Implementing_the_Account_and_Financial_Dimensions_Framework_AX2012" which you find here: http://download.microsoft.com/download/4/e/3/4e36b655-568e-4d4a-b161-152b28baaf30/implementing_the_account_and_financial_dimensions_framework_ax2012.pdf
Always when i go into my form, the error message "Argument to method getFieldValue out of range." is shown.
So i set an debug point in "loadSegments" in the row "ledgerDimAccContr.parmControl(this);"
i run into this method and there is a line "if(this.isNonLedgerAccount())" and when i step into this method the call "DimensionHierarchyType hierarchyType = this.getHierarchyType();" throws the error.
Have anybody a idea how to solve this?
You can find my Code here: https://community.dynamics.com/ax/f/33/t/231980
BG James

How does the assignment part work in the following line of code in Angular2?

I am learning from the project angular2-rxjs-chat application ong github. In the code here there is a line of code given below:
threads[message.thread.id] = threads[message.thread.id] ||
message.thread;
where threads has earlier been defined on line 29 in the code as shown below:
let threads: {[key: string]: Thread} = {};
The comments in the code states that "store the message's thread in our acuuculator 'threads'. I need a little bit explanation of how does the assignment works on line 31 as on both sides of the assignment operator we have the same thing i.e., threads[message.thread.id]. If the statement on line 31 was like
(threads[message.thread.id] = message.thread;)
then I would explain it as a value is being assigned to a key in the map "threads". But I don't understand the full line.
This means if threads[message.thread.id] already has a value then keep it, otherwise set the value to meassage.thread.
If the part before || evaluates to a value that is truthy (not null, undefined, false, ...)then the part after||is not evaluated and the result from the part before||is returned otherwise the result from the expression after||` is returned.
You could also write it as
if(!threads[message.thread.id]) {
threads[message.thread.id] = message.thread;
}

org.springframework.validation.Errors.rejectValue doesn't escape values

I am trying to add escaped values to an error message in a Spring MVC Validator
final Object[] vatErrorArray = new String[2];
vatErrorArray[0] = "aaa";
vatErrorArray[1] = "bbb";
errors.rejectValue("vatfield", "vendor.vat.number.invalid.pattern.generic", vatErrorArray, "Invalid VAT");
where vendor.vat.number.invalid.pattern.generic is as follows:
vendor.vat.number.invalid.pattern.generic=VAT Number's pattern is invalid for {0}. Valid pattern: {1}.
Unfortunately, the displayed error message doesn't contain the escaped values:
VAT Numbers pattern is invalid for {0}. Valid pattern: {1}.
What am I doing wrong?
PS I am using Spring MVC version 4.2.1.RELEASE
I think you need to change the single quote in Number's to two single quotes ('').
I haven't tried it myself but am basing this mostly on the content of this question, and the MessageFormat docs it links to, plus the fact that your single quote seems to be disappearing.

Trim function usage

I have one label field max characters allowed is 200. If the string in the label goes above 30 means, I need to trim the value and display the trimmed value.
If I go for editing means, all the 200 characters should be passed in the text box for edit.
label.Text = label.Text.Substring(0, 30) + "..."; //This is displayed in the label
After that i want to edit, for that i need to recover the full string(200 char) in the label, is it possible?
TRIM function
Trim eliminates leading and trailing whitespace. We need to remove whitespace from the beginning or ending of a string. We use the .NET Framework's Trim method to do this efficiently. This method removes any characters specified.
Trim input and output
String input: " This is an example string. "<br>
Trim method result: "This is an example string."
String input: "This is an example string.\r\n\r\n"<br>
Trim method result: "This is an example string."
So it's depend upon your label strings

Resources