BUILD FAILURE
----------------------
Compilation failure
work\AccountService\src\com\service\accountinquiry\utils\XMLUtil.java:[103,48] cannot find symbol
ymbol : method parseFloat(java.lang.String,float)
ocation: class com.service.accountinquiry.utils.DataOperationUtils.
having weird problem with maven I checked DataOperationUtils.java is already compiled in target folder same folder where XMLutil.java is so why maven is not be able to find DataOperationutils.class in XMLUtils.java
code snippet for XMLUtils.java
public static float getNodeTextAsFloat(Node node, String xpath,
float defaultValue) {
float returnValue = defaultValue;
if (node != null) {
Node tempNode = node.selectSingleNode(xpath);
if (tempNode != null) {
String nodeValue = tempNode.getText().trim();
returnValue = DataOperationUtils.parseFloat(nodeValue,
defaultValue);
}
}
return returnValue;
I appreciate for your answer thanks in advance
Looks like a compile problem. You sure that the class DataOperationUtils has a method called parseFloat that accepts the following types?
String
float
Possibly you need to typecast the parameters to match?
Related
I am working on the iOSbinding for Segment/Analytics and meeting a block on this.
The oc code I cannot find a good idea to convert to C# code.
-(SEGReachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;
when i converted code to below:
[Export("initWithReachabilityRef:")]
unsafe IntPtr Constructor(ref NetworkReachability #ref);
it happened a error:
Error CS0311: The type SystemConfiguration.NetworkReachability' cannot be used as type parameterT' in the generic type or method ObjCRuntime.Runtime.GetNSObject<T>(System.IntPtr)'. There is no implicit reference conversion fromSystemConfiguration.NetworkReachability' to `Foundation.NSObject' (CS0311) (Anayltics.IOS)
[Export ("initWithReachabilityRef:")]
[CompilerGenerated]
public SEGReachability (ref SCNetworkReachabilityRef #ref)
: base (NSObjectFlag.Empty)
{
IntPtr #refValue = IntPtr.Zero;
IsDirectBinding = GetType ().Assembly == global::ApiDefinition.Messaging.this_assembly;
if (IsDirectBinding) {
InitializeHandle (global::ApiDefinition.Messaging.IntPtr_objc_msgSend_ref_IntPtr (this.Handle, Selector.GetHandle ("initWithReachabilityRef:"), ref refValue), "initWithReachabilityRef:");
} else {
InitializeHandle (global::ApiDefinition.Messaging.IntPtr_objc_msgSendSuper_ref_IntPtr (this.SuperHandle, Selector.GetHandle ("initWithReachabilityRef:"), ref refValue), "initWithReachabilityRef:");
}
#ref = #refValue != IntPtr.Zero ? Runtime.GetNSObject<Anayltics.SCNetworkReachabilityRef> (#refValue) : null; //**--**error happened in this line.****
}
Any one can help me?
I can't find any description for this function.
Even after v8 sources analyze it is still unclear for me, because
it is ended by "RETURN_NATIVE_CALL(to_detail_string...", and I can't find to_detail_string in my sources.
Here is supposed to be a documentation about this function:
https://v8docs.nodesource.com/io.js-3.0/dc/d0a/classv8_1_1_value.html#a2f9770296dc2c8d274bc8cc0dca243e5
Copy/paste from v8 sources:
V8_WARN_UNUSED_RESULT MaybeLocal<String> ToDetailString(
Local<Context> context) const;
MaybeLocal<String> Value::ToDetailString(Local<Context> context) const {
auto obj = Utils::OpenHandle(this);
if (obj->IsString()) return ToApiHandle<String>(obj);
PREPARE_FOR_EXECUTION(context, "ToDetailString", String);
Local<String> result;
has_pending_exception =
!ToLocal<String>(i::Execution::ToDetailString(isolate, obj), &result);
RETURN_ON_FAILED_EXECUTION(String);
RETURN_ESCAPED(result);
}
MaybeHandle<Object> Execution::ToDetailString(
Isolate* isolate, Handle<Object> obj) {
RETURN_NATIVE_CALL(to_detail_string, { obj });
}
Could someone provide any hints or links to documentation?
I could just call it and see results, but I hope answers will contain some useful information and links.
This is implemented in messages.js by ToDetailString.
The function definition from v8/src/messages.js:
function ToDetailString(obj) {
if (obj != null && IS_OBJECT(obj) && obj.toString === ObjectToString) {
var constructor = obj.constructor;
if (typeof constructor == "function") {
var constructorName = constructor.name;
if (IS_STRING(constructorName) && constructorName !== "") {
return "#<" + constructorName + ">";
}
}
}
return ToStringCheckErrorObject(obj);
}
See also a fragment of a discussion from here:
http://logs.nodejs.org/v8/2013-02-05
ToDetailString prints #<constructor name> if the object to be printed
doesn't have a custom toString method.
ToString prints [object <class of object>].
ToDetailString also handles error objects differently.
Ok so i have this function in the engine
static bool
myTestFunction(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
int length = args.length();
if (length==2)
{
if (args.get(1).isObject())
{
RootedObject obj4(cx,&args.get(1).toObject());
args.rval().setObject(*obj4);
}
}
return true;
}
and this statement in the js script
var obj = {ss:"qq"};
var handler = {tt:"vv"};
var prox1 = myTestFunction(obj,handler);
print(prox1);
So the problem is in the last line basically i am just trying to return the second argument but when i print the variable it is giving me this assertion failure
Assertion failure: mStatementDone != reinterpret_cast<bool*>(uintptr_t(-1)), at ../../../dist/include/mozilla/GuardObjects.h:95
Segmentation fault (core dumped)
Now i am really new to SpiderMonkey Engine and have checked everything but haven't been able to figure out what's wrong here. Any help would be really appreciated.
I want to implement a insertion method for a Binary search tree, and come up with a solution below. I know there are plenty of code examples but I wonder what is the problem in my implementation? Or is there a problem? When I had traced it I thought I have missed something.
public void insertBST(Node<Double> head, int value){
if (head == null){
head = new Node<Double>(value);
return;
}
else {
if (head.getValue() > value)
insertBST(head.getLeft(), value);
else
insertBST(head.getRight(), value);
}
}
When you reassign a passed parameter, you're only changing the local variable, not the value passed to the function. You can read this question for more information - Is Java "pass-by-reference"? This is Java, right? Either way, a similar argument likely applies.
This is the problem with this line of code:
head = new Node<Double>(value);
You aren't changing the value passed into the function, so you never add to the tree.
You have two alternatives here, either the option presented by amdorra, or returning the current node:
public void insertBST(Node<Double> current, int value)
{
if (current == null)
{
return new Node<Double>(value);
}
else
{
if (head.getValue() > value)
head.setLeft(insertBST(head.getLeft(),value));
else
head.setRight(insertBST(head.getRight(),value));
return current;
}
}
To call the function, you can simply say:
root = insertBST(root, value);
With alternatives, the root will have to be handled as a special case.
at the beginning of you function you are adding the new Node to a part you will never have access to outside this function
so i will assume that your Node class looks like the following
Class Node{
private Node left;
private Node right;
//constructor, setters and getters and stuff
}
you could modify your code to look like the following:
if (head.getValue() > value){
if(head.getLeft == null) {
head.setLeft(new Node<Double>(value));
return;
}
insertBST(head.getLeft(),value);
}
else{
if(head.getRight == null) {
head.setRight(new Node<Double>(value));
return;
}
insertBST(head.getRight(),value);
}
you should also remove this part if (head==null) and always make sure you are sending a valid Node to the first call
I wrote a class method using STL find_if. The code is the following:
void
Simulator::CommunicateEvent (pEvent e)
{
pwEvent we (e);
std::list<pEvent> l;
for (uint32_t i = 0; i < m_simulatorObjects.size (); i++)
{
l = m_simulatorObjects[i]->ProcessEvent (we);
// no action needed if list is empty
if (l.empty ())
continue;
// sorting needed if list comprises 2+ events
if (l.size () != 1)
l.sort (Event::Compare);
std::list<pEvent>::iterator it = m_eventList.begin ();
std::list<pEvent>::iterator jt;
for (std::list<pEvent>::iterator returnedElementIt = l.begin ();
returnedElementIt != l.end ();
returnedElementIt++)
{
// loop through the array until you find an element whose time is just
// greater than the time of the element we want to insert
Simulator::m_eventTime = (*returnedElementIt)->GetTime ();
jt = find_if (it,
m_eventList.end (),
IsJustGreater);
m_eventList.insert (jt, *returnedElementIt);
it = jt;
}
}
}
Unfortunately, I later discovered that the machine that will run the code is equipped with the libstdc++ library version 4.1.1-21, which apparently is lacking find_if. Needless to say, I cannot upgrade the library, nor can I ask someone to do it.
When compiling, the error I get is:
simulator.cc: In member function ‘void sim::Simulator::CommunicateEvent(sim::pEvent)’:
simulator.cc:168: error: no matching function for call to ‘find_if(std::_List_iterator<boost::shared_ptr<sim::Event> >&, std::_List_iterator<boost::shared_ptr<sim::Event> >, sim::Simulator::<anonymous struct>&)’
simulator.cc: In static member function ‘static void sim::Simulator::InsertEvent(sim::pEvent)’:
simulator.cc:191: error: no matching function for call to ‘find_if(std::_List_iterator<boost::shared_ptr<sim::Event> >&, std::_List_iterator<boost::shared_ptr<sim::Event> >, sim::Simulator::<anonymous struct>&)’
make: *** [simulator.o] Error 1
How can I solve the problem?
I thought I could define a find_if function as described here. However, I have some concerns:
What about performance? The function that makes use of find_if needs to be as efficient as possible.
How can I do conditional compilation? I couldn't find a macro telling the version of the libstdc++ installed.
What are your thoughts about it?
TIA,
Jir
References
Source files: simulator.h and simulator.cc
Solution
Defined IsJustGreater outside the Simulator class and declared IsJustGreater_s friend of Simulator:
struct IsJustGreater_s : public std::unary_function<const pEvent, bool> {
inline bool operator() (const pEvent e1) {return (e1->GetTime () > Simulator::m_eventTime);}
} IsJustGreater;
Called IsJustGreater in find_if this way:
jt = find_if (it, m_eventList.end (), sim::IsJustGreater);
From the error, it appears that you're attempting to use an anonymous type as the argument. I do not believe anonymous types are allowed to be template arguments.
From the error, I believe you have something like this:
class Simulator {
struct {
bool operator(const pEvent& p) { ... } ;
} IsJustGreater;
}
what you want is to give it a name and then change the find_if to instantiate the class (see below)
class Simulator {
// class is now an inner named-class
struct IsJustGreater {
bool operator(const pEvent& p) { ... } ;
};
}
// This is how you use the class
jt = std::find_if(it, m_eventList.end(), IsJustGreater() );
I see that you're using the std:: qualifier before std::list but not std::find_if. Try putting the std:: in front so that the compiler can find it within the namespace.