Questions tagged [value-of]
138 questions
4
votes
1 answer
How can a java.lang.float be encoded as TH3IFMw?
I need to parse some data that has encoded primitive types (ints, floats, doubles, floats) outputted by java. I'm adding this functionality to an existing set of python scripts, so rewriting it in Java isn't really an option. I'd like to…

Tom
- 41
- 2
4
votes
3 answers
How can I get just the first, higher level, string?
I have this (token of) XML file of which I want to print just the "Print this" string, ignoring what follows:
Print this
Do not print this
In my XSL file, with this command I get both the contents of…

Pietro
- 12,086
- 26
- 100
- 193
4
votes
2 answers
Recreate valueOf(double d) in Java's String class
I made an object, MyString. I can't figure out how to recreate valueOf(double d). I recreated valueOf for integers. Just to make it easier I limited the amount of decimal places to 8. How can I recreate valueOf(double d)?
public class MyString…

merhoo
- 589
- 6
- 18
4
votes
2 answers
why valueOf(null) calls the constructor valueOf(char[])
String.valueOf(null);
why valueOf(char[] c) is called and why not valueOf(Object o);
??
Why String.valueOf(null); produces a NullPointerException and
String.valueOf((Object)null); do not produce any exception?

user3190422
- 41
- 1
4
votes
2 answers
XSL value-of doesn't seem to get value from the xml
I have an xml file which contains following:

lloydh
- 395
- 2
- 5
- 16
3
votes
6 answers
Basic XML/XSLT - value-of when there are multiple elements of the same name
When I'm getting the value of an element which is used multiple times in the same parent element, I'd like to get each element of the same name and not just the first.
E.g. -
Empire Burlesque
Bob…

lionysis
- 237
- 2
- 4
- 15
3
votes
1 answer
Parsing XML with child elements that have the same name using XSLT/XSL
I am wondering if there is a way to transfer over a parent element with all of its children elements that have the same element name using XSLT.
For example, if the original xml file is like this:
1
2
…

Dale
- 33
- 1
- 3
3
votes
2 answers
What is benefit from using fromValue function instead of valueOf, java enums?
I see some programmers use in enums structure function called fromValue. What is it purpose, if we can use valueOf? For example, I found something like this:
public static FooEnum fromValue(String v) {
return valueOf(v);
}

Bartek
- 2,109
- 6
- 29
- 40
3
votes
3 answers
Calculator - setText(String) doesn't work with Doubles
So I am trying to make a calculator and I am using JFrame code and trying to use the built in Math to find the square root of a number. The code below is where I am having issues. "display.setText(Math.sqrt(Double.parseDouble(display.getText())));"…

Max E
- 43
- 2
3
votes
2 answers
What is the point of the static valueOf() method? (enumerations)
I am learning about enumerations and I don't understand the purpose this method serves.
Example:
enum Fruits{
apple, pear, orange
}
class Demo{
f = Fruits.valueOf("apple"); //returns apple... but I had to type it!
…

Sergio Gliesh
- 329
- 1
- 2
- 8
3
votes
1 answer
Scanner with Enum, Java
I'm doing an assignment for uni and am stuck on litterelly one line of code.
public static void setKind(SettlementType type) {
SettlementType t;
t = scan.nextLine();
setKind(t = type);
As you can see I am using a scanner to…

mkirito
- 33
- 5
3
votes
2 answers
xsl literal with
I have to write a simple condition in XSL:
IF column=0 AND IF result = .35
set background color to green and write $result
ELSE IF result = 0.10
set background color to white and write the word "QQQ"
I have tried this but it doesn't…

Elena
- 31
- 1
- 2
3
votes
2 answers
Fastest XPath expression for xsl:value-of
I have an XML document in the following format:
Yes
NO

I think I can code
- 647
- 1
- 6
- 18
3
votes
2 answers
Python 3.x: Java valueOf() equivalent in Python 3.x
Whilest learning Python 3 and converting some of my code from Java to Python 3.3 I came across a small problem I haven't been able to fix.
In Java I have this code (just dummy code to make it smaller):
public enum Mapping {
C11{public int…

Tim
- 2,000
- 4
- 27
- 45
3
votes
2 answers
parseInt causes android app to crash
I eventually want to turn this program into a strobe light wih an adjustable frequency. However, right now I'm just trying to get the basics worked out. Everytime I use parseInt
the app crashes. In this code i use it in the strobe() method, but I…

user1644985
- 31
- 1