Questions tagged [value-of]

138 questions
1
vote
1 answer

Java valueOf method for generic class

Given a generic class Foo, I would like to create a static method valueOf(String s). The String s should hold the name of a class (e.g. "java.lang.Integer"). A call to valueOf("java.lang.Integer") should then return a new object Foo. In…
joe
  • 13
  • 3
1
vote
1 answer

XSLT: copy element text which is itself an xml doc without using value-of

I'm copying the text content of an element I need (which is an embedded xml doc) and creating the new doc from the text, as shown below for a file format delivered to me that I don't control. The issue is that occasionally i get large (3MB+) text…
devranred
  • 15
  • 3
1
vote
1 answer

How do I convert an alphabetic string to int and do arithmetic on it?

Everywhere I look trying to find out how to convert a String to an int, the examples use a numeric string, i.e. they show how to change "123" into 123. That is not at all what I am trying to do. My string is alphabetic. I know this because the two…
1
vote
1 answer

JTextField: avoid display "," in numbers

I'm looking for a better solution than the one I currently have: I have a textfield for which I read and right numbers in: textStiffness.setText((""+stiffness).replaceAll(",", "")); and stiffness = Float.valueOf(s1.replaceAll(",",…
Jason Rogers
  • 19,194
  • 27
  • 79
  • 112
1
vote
1 answer

String Value to set an Enum

I would like to set an enum type by using one of its values as an input : This is the code i'm using, package models; import models.crudsiena.SienaSupport; import siena.*; public class Item extends SienaSupport { @Id …
Roch
  • 21,741
  • 29
  • 77
  • 120
1
vote
1 answer

Object to primitive conversion in Javascript: Please why isn't the valueOf() method called since there is not toString() method

let obj = { valueOf() { return "2"; } }; alert(obj); I thought in the absence of toString() the valueOf() will be called when a string is expected.
Israel
  • 77
  • 7
1
vote
1 answer

Want to know reason behind NumberFormat Exception in my code

I am trying to read file with BufferedReader and at the time of spliting each line of file I want to convert string data at 8th position to be converted to float.(count starts from 0 data) below is my code : import java.io.BufferedReader; import…
Student
  • 41
  • 1
  • 6
1
vote
1 answer

How to get value of XML element using XSL

I have a XML and XSL code, products have images and description. I want to append this images in description tag. http://www.example.com.tr/ExampleData/example1.jpg
D.Dirik
  • 25
  • 6
1
vote
2 answers

Order of operations when valueOf is called

Right now I'm reading through You Don't Know JS Types & Grammar Ch 4 where I came across this example on coercion. https://repl.it/D7w2 var i = 2; Number.prototype.valueOf = function() { console.log("called"); //this logs twice return…
Gwater17
  • 2,018
  • 2
  • 19
  • 38
1
vote
1 answer

Type Coercion with valueOf Math Operations

I have the following adding function, which appeared originally here. add takes only one argument, but it may do so an 'infinite' number of times through the 'magic' of currying and closures. function add (a) { var f = b => add(a + b); …
Brad
  • 359
  • 4
  • 12
1
vote
1 answer

What does String.valueOf(View) returns?

I was using some Logs to debug some issues in my app, and when I used String.valueOf(view) in a onClick(View view). I logged Log.d("Values", "HomeFragment: onClick. view = " + String.valueOf(view)); The result of the Log was: D/Values: HomeFragment:…
Daniel Reina
  • 5,764
  • 1
  • 37
  • 50
1
vote
1 answer

Discount method for pizza program

I am having trouble creating a mutator method for my Java class and I'm looking for a little help. These are the instructions for the method; * Mutator method that calculates the cost of a pizza. * Small pizza = $8, toppings = $1/each * Medium…
AlephZed
  • 31
  • 4
1
vote
2 answers

What expression to use with xsl:value-of to select text value from certain elements

I have this kind of XML structure and I need to print out what both paragraph sections contains. How to do that? Basically I thought about for-each loop, but what to put inside xsl:value-of construction? Thanks!
Andrei
  • 43
  • 1
  • 12
1
vote
2 answers

Selecting the value from an element attribute

I've been trying to select from the embedded XML file, to utilise for a transform. Essentially I want to get whatever value is currently "Requirements Document"
MaxRussell
  • 518
  • 1
  • 11
  • 25
1
vote
1 answer

.valueOf using another class's private variable

BaseExample Class (I am not allowed to make the variable protected on this example): public class BaseExample { private int a; public BaseExample(int inVal) { a = inVal; } public BaseExample(BaseExample other){ a =…
userb
  • 173
  • 2
  • 15