Doubles/strings ahhh!

I have a data class which store the info about an item, one of these elements is a Double.
so what I want to do is make this editable in a textfield.
to get is showing I need to use toString()
BUT my issue is that when it is 0 I have an issue because the toString gives me an error.
SO I try to check to see if it is a 0 and then just show blank.
I figure I should use the compareTo method, then give it a Double as 0.0
why does this not work
Double myamtval = thisitem.getitemamt();
String myamtstr = new String("0.0");
Double mychk = new Double(myamtstr);
if (myamtval.compareTo(mychk) != 0)
myamtstr = myamtval.toString();
I even broke it down when I send just a blank string it is fine, what is wrong with my check?
Thanks

    double amountValue = 2.20;
    String amountString = "0.0";
    double check = Double.parseDouble(amountString);
    System.out.println("amountValue = " + amountValue + "\n" +
                       "check = " + check);
    if(new Double(amountValue).compareTo(new Double(check)) != 0)
      amountString = String.valueOf(amountValue);
    System.out.println("amountString = " + amountString + "\n" +
                       "check = " + check);
    System.out.println("*******");
    double doubleFromSomeMethod = 25.33;
    Double amountDouble = new Double(doubleFromSomeMethod);
    amountString = "55.19";
    Double checkDouble = new Double(amountString);
    System.out.println("amountDouble = " + amountDouble + "\n" +
                       "checkDouble = " + checkDouble);
    if(amountDouble.compareTo(checkDouble) != 0)
      amountString = String.valueOf(amountDouble);
    System.out.println("amountString = " + amountString + "\n" +
                       "checkDouble = " + checkDouble + "\n" +
                       "amountDouble.toString() = " +
                        amountDouble.toString());

Similar Messages

  • Can I call a function from a dll in LabVIEW that returns:double*string and int.?

    I have a function from a dll that return a double* string and an integer. How can I call this function from LabVIEW? There is a possibility to work in LabVIEW with a double* string?

    pcbv wrote:
    > Hello all,<br><br>The header of the function is:
    >
    > "HRESULT WRAPIEnumerateDevices(WRAPI_NDIS_DEVICE **ppDeviceList, long *plItems);"
    >
    > where WRAPI_NDIS_DEVICE have this form:
    >
    > typedef struct WRAPI_NDIS_DEVICE<br>{<br>
    > WCHAR *pDeviceName;<br>
    > WCHAR *pDeviceDescription;<br><br>}
    > WRAPI_NDIS_DEVICE;<br><br>
    >
    > The function is from WRAPI.dll, used for communication with wireless card.
    > For my application I need to call in LabVIEW this function.
    Two difficulties I can see with this.
    First the application seems to allocate the array of references
    internally and return a pointer to that array. In that case there must
    be another function which then deallocates that array again.
    Then you would need to setup the function call to have a pointer to an
    int32 number for the deviceList parameter and another pointer to int32
    one for the plItems parameter.
    Then create another function in your DLL similar to this:
    HRESULT WRAPIEnumExtractDevice(WRAPI_NDIS_DEVICE *lpDeviceList, long i,
    CHAR lpszDeviceName, LONG lenDeviceName,
    CHAR lpszDeviceDesc, LONG lenDeviceDesc)
    if (!lpDeviceList)
    return ERROR_INV_PARAMETER;
    if (lpDeviceList[i].pDeviceName)
    WideCharToMultiByte(CP_ACP, 0,
    pDeviceList[i].pDeviceName, -1,
    lpszDeviceName, lenDeviceName,
    NULL, NULL);
    if (lpDeviceList[i].pDeviceName)
    WideCharToMultiByte(CP_ACP, 0,
    pDeviceList[i].pDeviceDescription, -1,
    lpszDeviceDesc, lenDeviceDesc,
    NULL, NULL);
    return NO_ERROR;
    Pass the int32 you got from the first parameter of the previous call as
    a simple int32 passed by value to this function (and make sure you don't
    call this function with a higher index than (plItems - 1) returned from
    the first function.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Double to String

    How can I do that?

    Double.toString(double);
    String e = "" +double;
    Is this what you are looking for?

  • Converting a String to a Double, may I use Double constructor?

    Hello,
    I need to convert A String to a Double in my application.
    Usually I use the Double.parseDouble(String) method that works fine.
    But I have found one line in the code that use the Double class constructor: new Double(String). It has been observed that that constructor sometimes throws NullPointerException.
    My question is, are theses two methods both good practices to do the convertion? Could threre be a multi-threading problem with the Double construtor?
    I'm using JDK 1.3.1.
    Here is a sample of stack trace:
    bvsmgr: java.lang.NullPointerException
         at java.lang.FloatingDecimal.readJavaFormatString(Unknown Source)
         at java.lang.Double.valueOf(Unknown Source)
         at java.lang.Double.<init>(Unknown Source)
    Thank you for all answers,
    Florent.

    But I have found one line in the code that use the
    Double class constructor: new Double(String).
    It has been observed that that constructor sometimes
    throws NullPointerException.
    My question is, are theses two methods both good
    practices to do the convertion? Could threre be a
    multi-threading problem with the Double construtor?Both methods are the same (they both use valueOf()), and if the c'tor throws an NPE, then only because you feed it null. parseDouble would do that, too.

  • Converting hexadecimal value to double   Hlep needed!!!

    Is there a way that I can convert the following hexadecimal value into double:
    String s = "16#1234#";
    As converting this to long I am doing this
    if (s.startsWith("16#") && s.endsWith("#"))
    extractedValue = s.substring( 3, s.length()-1 );
    longValue = Long.parseLong( extractedValue, 16 );
    Is there any way I can do the same and change the above to double. If I use
    doubleValue = Double.parseDouble(s);
    gives me an error so I want to parse the above value and change it to double any tips of work arround.
    Thnaks

    double doubleValue;
    doubleValue = Integer.valueOf(s.substring( 3, s.length()-1 ), 16).intValue();
    this works because int is big enough to handle 4 hex digits (can handle 7 hex digits safely)
    then the conversion "widens" to double

  • Converting objects into Strings

    How would someone convert an object of say (String, int, double, String) into a readable string. I tried the toString() method but all I get is something like this
    Student@1f12c4e

    ..I'm not sure I understand "how" to override. The whole point of this project is to use quicksort on a list of students, unfortunately all I get is the address whenever I use the .toStrings() method.
    Here's what I have, any help would be greatly appreciated-so very close
    import cs1.Keyboard;
    import java.io.*;
    import java.util.*;
    public class StudentTraverse
    public static void main(String[] args)
    String newName;
    int newSocial;
    double newGPAs;
    String newMajors;
    System.out.println("How many Students would you like to add");
    Student newStudent;
    StudentList12 WORK = new StudentList12();
    int total = Keyboard.readInt();
    for(int number = total; number > 0; number--)
    System.out.println("Name?");
    newName = Keyboard.readString();
    System.out.println("Social?");
    newSocial = Keyboard.readInt();
    System.out.println("GPA?");
    newGPAs = Keyboard.readDouble();
    System.out.println("Major?");
    newMajors = Keyboard.readString();
    newStudent = new Student(newName, newSocial, newGPAs, newMajors);
    System.out.println("Inserting: "+newStudent.toString());
    WORK.add(newStudent);
    for(total = 0; total < WORK.size(); total++)
    System.out.println("top" total": "+WORK.top(total).toString());
    try
    BufferedReader in = new BufferedReader(new FileReader("LIST.out"));
    while (in.ready())
    // Print file line to scree
    System.out.println (in.readLine());
    in.close();
    catch (Exception e)
    System.err.println("File input error");
    public class StudentNode
    public Student student;
    public StudentNode next;
    public StudentNode()
    next = null;
    student = null;
    public StudentNode(Student d, StudentNode n)
    student = d;
    next = n;
    public void setNext(StudentNode n)
    next = n;
    public void setData(Student d)
    data = d;
    public StudentNode getNext()
    return next;
    public Student getData()
    return data;
    public String toString()
    return ""+data;
    public StudentNode(Student newStudent)
    METHOD NAME: StudentNode
    AUTHOR:
    DATE OF CREATION: Nov 20, 2004
    DATE OF UPDATES: Nov 28, 2004
    PURPOSE: Acts as a node for the Student list
    ALGORITHM:Acts as node for the list
    INSTANCE VARIABLES: none
    student = newStudent;
    next = null;
    public class Student
    private String name;
    private int social;
    private double GPA;
    private String Major;
    public Student(String newName, int newSocial, double newGPAs, String newMajors)
    METHOD NAME: Student
    AUTHOR:
    DATE OF CREATION: Nov 20, 2004
    DATE OF UPDATES: Nov 28, 2004
    PURPOSE: The actual Student class, determines what is allowed in the array
    ALGORITHM:Declare what variables will be needed for the program
    INSTANCE VARIABLES: String name, int social, double GPA, String Major
    name = newName;
    social = newSocial;
    GPA = newGPAs;
    Major = newMajors;
    import java.io.*;
    import cs1.Keyboard;
    import java.io.BufferedWriter;
    import java.util.*;
    public class StudentList12
    private StudentNode list;
    static int i = 0;
    public StudentList12()
    METHOD NAME: StudentList12
    AUTHOR:
    DATE OF CREATION: Nov 20, 2004
    DATE OF UPDATES: Nov 28, 2004
    PURPOSE: Declares the Node
    ALGORITHM:Declare the Node
    INSTANCE VARIABLES: none
    list = null;
    public boolean isEmpty()
    return list == null;
    public int size()
    return i;
    public void add(Student newStudent)
    METHOD NAME: add
    AUTHOR:
    DATE OF CREATION: Nov 20, 2004
    DATE OF UPDATES: Nov 28, 2004
    PURPOSE: Let's users add objects to the array of objects
    ALGORITHM:Traverses the current list and adds object to the end
    INSTANCE VARIABLES: none
    list = new StudentNode(newStudent, list);
    i++;
    current = current.next;
    current.next = node;
    public Student remove()
    if(isEmpty())
    return null;
    StudentNode tmp = list;
    list = tmp.getNext();
    i--;
    return tmp.getData();
    public void insertEnd(Student newStudent)
    if(isEmpty())
    add(newStudent);
    else
    StudentNode t = list;
    while(t.getNext() != null)
    t=t.getNext();
    StudentNode tmp = new StudentNode(newStudent, t.getNext());
    t.setNext(tmp);
    i++;
    public Student removeEnd()
    if(isEmpty())
    return null;
    if(list.getNext() == null)
    return remove();
    StudentNode t = list;
    while(t.getNext().getNext() != null)
    t = t.getNext();
    Student newStudent = t.getNext().getData();
    t.setNext(t.getNext().getNext());
    i--;
    return newStudent;
    public Student top(int n)
    StudentNode t = list;
    for(int i = 0; i <n && t != null; i++)
    t = t.getNext();
    return t.getData();
    public void writeToFile(int n)
    int z = n;
    try
    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("LIST.out")));
    for(int counter = z; counter >= 0; counter--)
    System.out.println(counter);
    out.close();
    catch(Exception e)
    System.err.println("Couldn't Write File");
    try
    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("LIST.out")));
    out.write(list.toString());
    out.close();
    catch(Exception e)
    System.err.println("Couldn't Write File");
    }

  • Float to byte - String to byte

    Hi All,
    I am writing a Binary file writer.
    the convertion is made from several java type (int, float, double, String, ...) to bytes equivalent.
    I have a reader that reads the files that I am generating through my prog.
    In some fields, i put 0.0f value once It is read it return some weird values like 9.66338e-13
    how can solve this problem ?
    thanks in advance

    If you take time to read it would ne better...and you can help efficiently...
    the thing i don't want to talk in depth details...
    There is a telecom system which read a binary file. with a specific format...in that format, there is some fields with float type.
    And there is whole bunch of checkin to validate the type and the format and the size of each field...
    I am writing an app that generate those files...in fact, they are generated
    and also read by the T-system...but in the float fields, the data which is supposed to be 0.0f is something else.
    So the question, should i fix something with float type to get the expected result...like precision for exampl..or i do not know...
    And none have said it's a java problem...
    it's just the matter i have missed something...
    Hope you got it...
    thanks for help...and not blabla

  • Does Logic has a divide (strings divisi) signal (midi) command?

    I am working on a string orchestra piece and use a lot of divided string parts. I was wondering if Logic knows a command or way to automatically divide a strings section like 1st violins into two.
    For example, in Finale 2010, the notation program, when I write the command "divisi" on a staff in the 1st violin staff, Finale changes somehow the sound of that track so it really sounds like a divided string group. In logic now the way I do it, it sounds like a doubled string track, so 2 groups of 1st violins what gives a doubled unrealistic sound.
    I don't know if this is just a midi command in Finale that can be used in Logic as well.
    André

    Hi André,
    In Logic you don't have those preprogramed patch changes like in Finale/Sibelius, (that's is something some of us asked and wait for some time, that the writing articulations on score could perform midi events instead being there for visually only) those patch changes can be performed via midi commands (same thing as pizz/arco), Yes.
    The simplest way to do this (only if you use / share the same sound library in Logic and Finale) is apply the divisi and the other articulations in Finale and import the midi to Logic ( I did it a lot to save me time, even with crescendos) Logic will follow/performed the articulations in the midi file, if you have the same library on both, that's it.
    If not you can see what the midi file (from finale) says in the event lists and apply it to the library you're using in Logic. (don't forget that you can copy those (and other) events in Logic.
    Cheers,
    Jorge

  • Double.parseDouble

    the user enters a premium amount and then I want to use that amount in a calcuation; can't I parseDouble it like this? apparently not, because when I try to multiply, I get an error "the operator * is undefined for argument type(s) double, String. I have done this in the past, what is wrong?
    String pAmount = JOptionPane.showInputDialog("Enter the premium amount:");
    double num = EndCancelDiffCounter;
                   double denom = counter;
                   double result = num/denom;
                   Double.parseDouble(pAmount);
                   double refund = result * pAmount;

    parseDouble returns a double, it does not change the
    String given froma String to a double. You need to
    store that result (return value) in a new double
    variable and perform your calculation with that.
    Edit: Man I'm slow. (I had to check that
    parseDouble returned a double and not a Double. I
    wasn't 100% sure, as I'm a little daft this morning.)I see, thank you

  • How use c:forEach to loop over a String[][]

    Hello,
    Is there anyone that can tell me how to use the c:forEach tag to loop over a double String[][]? I can find examples for resultsets etc....but whatever I try with my String[][], I never can get the results on the screen.
    Thanx,
    debeumers

    You need to set up a double c:forEach loop.
    ie
    <%
    // initialisation of string[][]
    String[][] sValues = new String[5][5];
    for (int i=0; i<sValues.length; i++){
      for (int j=0; j<sValues.length; j++){
         sValues[i][j] = "" + (i + j);
    pageContext.setAttribute("arrayValues", sValues);
    %>
    // And now to test print out the values
    <c:forEach var="row" items="${arrayValues}">
    <c:forEach var="col" items="${row}">
    <c:out value="${col}"/>
    </c:forEach>
    <br>
    </c:forEach>
    Hope this helps
    Cheers, evnafets

  • Converting a String to an Object

    Is there some way of converting a String (from a textfield) to an Object? What I want is something similar to the functionality offerred by a JTable. This is because I want the user to be able to input a value of any type to the textfield (e.g. String, int, boolean, etc) and get its object representation ...
    Would a simple cast do ?
    David

    dattard,
    A string is an object, when someone enters something into a JTextField, REGARDLESS of what it is (int, double, string, etc) it is stored in the string text in that text field (JTextField.getText()).
    So if someone enters in "123", its the STRING 123, not the number one hundred and twenty three... to GET the number 123, you'll need to do something like:
    int value = Integer.parseInt( myTextField.getText() );
    to have the string parsed for the value, if you want a double, same idea:
    double value = Double.parseDouble( myTextField.getText() );
    NOTE: The number wrapper classes (Integer, Double, Float, etc.) contain "parseXXXX" methods that allow you to parse a corresponding numeric value out of a String object.
    Also, when a user enters ANYTHING into a text input field of any type, its ALWAYS a String, if you want a different version of what they entered, its up to you to parse it and decide what it was.

  • Double addition

    I try to do the following, where a and b are Doubles:
    String c = "1000.00";
    a = (b + Double.valueOf(c));
    And i get this error:
    operator + cannot be applied to java.lang.Double,java.lang.Double
    Please help me I can't find the info on java.sun.com
    Thanks,
    Mike

    Double.valueOf() returns a Double, not a double. Java does not support adding of Doubles, only doubles. Instead, use Double.parseDouble() which returns a double.

  • JTextField Double java.lang.Math

    Hi,
    I need to be able to input a double into a JTextField eg. 13.5
    do some calculations on it and output its answer as a Double/String to a JLabel
    Firstly I know that the following calculation works
    double d, e, f g;
    d = 10;
    e = 14;
    f = 13.5;
    g = Math.pow(d, -(e - f));
    System.out.println(g);
    //Outputs 0.31622776601683794 Correct AnswerThe following works if I input of 13, but I get a NumberFormatException if I input 13.5.
    double dInput, calc;
    String str_calc;
    JTextField input = new JTextField();
    dInput = Double.parseDouble(input.getText());
    calc = Math.pow(d, -(e - dInput));
    str_calc = Double.toString(calc);
    JLabel label = new JLabel();
    label.setText(str_calc);Can anyone tell me where I am going wrong? How can I fix it?
    Any help would be grately appreciated

    Problem solved.
    The issue I was having was not related to changing from printf to GUI, it was elsewhere in my code.
    Thanks anyway

  • New Effective CAL essay: How do I create an abstract data type in CAL?

      <p><strong>How do I create an abstract data type in CAL?</strong></p>  <p> </p>  <p>An <em>abstract data type</em> is one whose internal representation can be changed without needing to modify the source code of client modules that make use of that type. For software maintainability, it is a good idea to make a type that is subject to change or enhancement into an abstract data type. Another reason to create an abstract data type is to enforce invariants for values of the type that can only be ensured by using <em>constructor functions</em> (i.e. functions that return values of that type).</p>  <p> </p>  <p>In principle it is simple to create an abstract data type in CAL. For an algebraic data type, make the type constructor public and all data constructors private. For a foreign data type, make the type constructor public and the implementation scope private. If a scope qualifier is omitted, the scope is taken to be private.</p>  <p> </p>  <p>For example, the Map algebraic data type has the public type constructor Map and the data constructors Tip and Bin are each private, so it is an abstract data type.</p>  <p> </p>  <p>/** A map from keys (of type {@code k@}) to values</p>  <p>   (of type {@code a@}). */</p>  <p><strong>data</strong> <strong>public</strong> Map k a <strong>=</strong></p>  <p>    <strong>private</strong> Tip <strong>|</strong></p>  <p>    <strong>private</strong> Bin</p>  <p>        size      <strong>::</strong> <strong>!</strong>Int</p>  <p>        key       <strong>::</strong> <strong>!</strong>k</p>  <p>        value     <strong>::</strong> a</p>  <p>        leftMap   <strong>::</strong> <strong>!(</strong>Map k a<strong>)</strong></p>  <p>        rightMap  <strong>::</strong> <strong>!(</strong>Map k a<strong>);</strong></p>  <p><strong> </strong></p>  <p><strong> </strong></p>  <p>There are a number of invariants of this type: the size field represents the number of elements in the map represented by its Bin value. The keys in leftMap are all less than key, which in turn is less than all the keys in rightMap.  In particular, non-empty Map values can only be created if the key parameter type is a member of the Ord type class.</p>  <p> </p>  <p>Values of the Map type can be created outside the Cal.Collections.Map module only by using constructor functions such as insert:</p>  <p> </p>  <p>insert <strong>::</strong> Ord k <strong>=></strong> k <strong>-></strong> a <strong>-></strong> Map k a <strong>-></strong> Map k a<strong>;</strong></p>  <p><strong>public</strong> insert <strong>!</strong>key value <strong>!</strong>map <strong>= ...</strong></p>  <p> </p>  <p>The owner of the Cal.Collections.Map module must ensure that all invariants of the Map type are satisfied, but if this is done, then it will automatically hold for clients using this function.</p>  <p> </p>  <p>Some examples of foreign abstract data types are Color, StringNoCase  and RelativeDate:</p>  <p> </p>  <p><strong>data</strong> <strong>foreign</strong> <strong>unsafe</strong> <strong>import</strong> <strong>jvm</strong> <strong>private</strong> "java.awt.Color"</p>  <p>    <strong>public</strong> Color<strong>;</strong></p>  <p><strong> </strong></p>  <p><strong>data</strong> <strong>foreign</strong> <strong>unsafe</strong> <strong>import</strong> <strong>jvm</strong> <strong>private</strong> "java.lang.String"</p>  <p>    <strong>public</strong> StringNoCase<strong>;</strong></p>  <p><strong> </strong></p>  <p><strong>data</strong> <strong>foreign</strong> <strong>unsafe</strong> <strong>import</strong> <strong>jvm</strong> <strong>private</strong> "int"</p>  <p>    <strong>public</strong> RelativeDate<strong>;</strong></p>  <p> </p>  <p>The private implementation scope for Color means that a foreign function whose type involves Color can only be declared in the Cal.Graphics.Color module where the Color type is defined. A foreign function declaration involving the Color type relies on the compiler knowing that the Color type corresponds to java.awt.Color to resolve the corresponding Java entity i.e. it must know about the implementation of the Color type. Having a private implementation scope means that the Color type can be changed to correspond to a different Java class, or indeed to be an algebraic type, without the risk of breaking client code.</p>  <p> </p>  <p>In all these three cases there are useful, and different, design reasons to adopt a private implementation scope:</p>  <p> </p>  <p>For RelativeDate, the Java implementation type int represents a coded Gregorian date value in the date scheme used by Crystal Reports. Not all int values correspond to valid dates, and the algorithm to map an int to a year/month/day equivalent is fairly complicated, taking into account things like Gregorian calendar reform. Thus, it is desirable to hide the implementation of this type.</p>  <p> </p>  <p>For StringNoCase, the implementation is more straightforward as a java.lang.String. The reason to adopt a private implementation scope is to ensure that all functions involving StringNoCase preserve the semantics of StringNoCase as representing a case-insensitive string value. Otherwise it is very easy for clients to declare a function such as:</p>  <p> </p>  <p><strong>foreign</strong> <strong>unsafe</strong> <strong>import</strong> <strong>jvm</strong> "method replace"</p>  <p>    replaceChar <strong>::</strong> StringNoCase <strong>-></strong> Char <strong>-></strong> Char <strong>-></strong> StringNoCase<strong>;</strong></p>  <p> </p>  <p>which does not handle case-insensitivity correctly, but is a perfectly valid declaration. This declaration results in a compilation error when it is placed outside the module in which StringNoCase is defined because of the private implementation scope of StringNoCase.</p>  <p> </p>  <p>For Color, the issue is somewhat more subtle. The java.awt.Color implementation type is semantically the same as the CAL Color type. The problem is that java.awt.Color is mutable (since it can be sub-classed to create a mutable type). It is preferable for a first-class CAL type to not be mutable, so we simply make the implementation scope private to ensure that this will be the case. </p>  <p> </p>  <p>A somewhat less encapsulated kind of abstract data type can be created using <em>friend modules </em>and <em>protected</em> scope. For example, if an algebraic type is public, and all its data constructors are protected, then the data constructors can be accessed in the friend modules of the module in which the type is defined. Effectively this means that the implementation of the semantics of the type stretches over the module in which the type is defined, and all of its friend modules. These must all be checked if the implementation of the type is modified. </p>  <p> </p>  <p>Given the merits of abstract data types discussed above, it is perhaps surprising that most of the core types defined in the Prelude module are not abstract data types. For example: Boolean, Char, Int, Double, String, List, Maybe, Either, Ordering, JObject, JList, and all record and tuple types are non-abstract types. </p>  <p> </p>  <p>There are different reasons for this, depending on the particular type involved. </p>  <p> </p>  <p>For example, Boolean, List, Maybe, Either and Ordering are all rather canonical algebraic data types with a long history in functional languages, with many standard functions using them. They are thus guaranteed never to change. In addition, their values have no particular design invariants that need to be enforced via constructor functions. Exposing the data constructors gives clients some additional syntactic flexibility in using values of the type. For example, they can pattern match on the values using case expressions or let patterns.</p>  <p> </p>  <p>Essentially the same explanation holds for record and tuple types. Although non-tuple record types are less canonical, they do correspond to the fundamental notion of an anonymous named-field product type. The "anonymous" here simply means that the programmer can create an entirely new record type simply by creating a value; the type does not have to be declared anywhere prior to use.</p>  <p> </p>  <p>Char, Int, Double, String, JObject and JList are foreign types where in fact part of the semantics of the type is that we want clients to know that the type is a foreign type. For example, we want clients to know that Prelude.Int is essentially the Java primitive unboxed int type, and has all the semantics you would expect of the Java int type i.e. this is quite different from RelativeDate which is using int as its implementation type in a very tactical way that we may choose to change. One can think of a public foreign type declaration with public implementation scope as simply introducing the Java type into the CAL namespace.</p>  <p> </p>  <p>One interesting point here is with CAL&#39;s naming convention for public foreign types. We prefix a type name by "J" (for "Java") for foreign types with public implementation type such that the underlying Java type is mutable. This is intended as mnemonic that the type is not a pure functional type and thus some caution needs to be taken when using it. For example, Prelude.JObject has public Java implementation type java.lang.Object.</p>  <p> </p>  <p>In the case where the underlying Java type is not mutable, we do not use the prefix, since even though the type is foreign; it is basically a first class functional type and can be freely used without concern. For example, Prelude.String has public Java implementation type java.lang.String.</p>  <p> </p>  <p>In the case where the implementation type is private, then the fact that the type is a foreign type, whether mutable or not, is an implementation detail and we do not hint at that detail via the name. Thus Color.Color has as its private Java implementation type the mutable Java type java.awt.Color. </p>  <p> </p>  <p>When creating abstract data types it is important to not inadvertently supply public API functions that conflict with the desired public semantics of the type. For example, if the type is publicly a pure-functional (i.e. immutable) type such as Color, it is important not to expose functions that mutate the internal Java representation.</p>  <p> </p>  <p>A more subtle case of inadvertently exposing the implementation of a type can occur with derived instances. For example, deriving the Prelude.Outputable and Prelude.Inputable type classes on a foreign type, whose implementation type is a mutable Java reference type, allows the client to gain access to the underlying Java value and mutate it
    (by calling Prelude.output, mutating, and then calling Prelude.input). The solution in this case is to not derive Inputable and Outputable instances, but rather to define a custom Inputable and Outputable instance that copies the underlying values.</p>

    Hi Pandra801,
    When you create a the external content type, please try to add a filter based on your select statement.
    http://arsalkhatri.wordpress.com/2012/01/07/external-list-with-bcs-search-filters-finders/
    Or, try to create a stored procedure based on your select statement, then create ECT using the SQL stored procedure.
    A step by step guide in designing BCS entities by using a SQL stored procedure
    http://blogs.msdn.com/b/sharepointdev/archive/2011/02/10/173-a-step-by-step-guide-in-designing-bcs-entities-by-using-a-sql-stored-procedure.aspx
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Getting error while adding field to data viewer web part

    I have custom EditItemForm for a custom list having over 100 columns. That EditItemForm contains a DataFormWebPart in edit mode having over 100
    <SharePoint:FormField controls.
    If I browse for the above page in internet explorer, I got got the generic error:
    "Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such
    as Microsoft SharePoint Designer. If the problem persists, contact your Web server administrator.
    Correlation ID:XXXXXXX"
    I went to Log, and got the exact error details as follows,
    "Error while executing web part: System.StackOverflowException: Operation caused a stack overflow.     at
    Microsoft.Xslt.NativeMethod.CheckForSufficientStack()     at <xsl:template name="dvt_1.rowedit">(XmlQueryRuntime , XPathNavigator , Double , String )     at <xsl:template name="dvt_1.body">(XmlQueryRuntime
    , IList`1 , Double , Double )     at <xsl:template name="dvt_1">(XmlQueryRuntime , XPathNavigator )     at Root(XmlQueryRuntime )     at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument,
    XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter)     at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter
    results)     at System.Xml.Xsl.XslCompiledTransform.Tr..."
    Then I thought of removing some columns from the dataFormWebpart. I removed several
    <SharePoint:FormField controls from the dataFormWebpart. Then page started working fine.
    Please let us know if there is any workaround to fix this issue.
    Note: The same page was working fine in MOSS 2007 before migrating to SharePoint
    2010.
    Sharepoint Consultant from NY, USA

    In SP1 and earlier, you could sometimes fix this by breaking the "dvt_1.rowedit" template into smaller templates and calling them sequentially. Sadly, this no longer works in many cases.
    Microsoft's "fix" for this problem appears in the August 2011 CU (Possibly earlier in the June CU - haven't checked that one). They have implemented a one-second timer that artificially throws a stack overflow exception if a transform takes longer than 1
    second.
    Reflector shows us what's going on. As the stack trace shows, it's in Microsoft.Xslt.NativeMethod.CheckForSufficientStack().
    A dateTime variable has been set to Now + 1 second when a Microsoft.Xslt.NativeMethod.SetStackBarrier() method was called, then we have this gem:
    public static unsafe void CheckForSufficientStack()
    void* stackBarrier = StackBarrier;
    if (dateTime < DateTime.Now)
    throw new StackOverflowException();
    if (&stackBarrier < stackBarrier)
    throw new StackOverflowException();
    As you can see, there has been no real stack overflow, and there isn't even any provision for allowing a SharePoint admin to adjust the now-plus-one-second hack.
    The MSFT support person we spoke with said this code was added in the August CU to "prevent long transforms from bringing down the server." So... Let's see what the SP1 version of the same method looks like:
    public static unsafe void CheckForSufficientStack()
    void* stackBarrier = StackBarrier;
    if (((++callCount & 0xffff) == 0) && (dateTime.AddSeconds(5.0) < DateTime.Now))
    throw new StackOverflowException();
    if (&stackBarrier < stackBarrier)
    throw new StackOverflowException();
    Well, at least it allowed 5 seconds instead of 1....

Maybe you are looking for