Java Doc for Stock.java in  » IDE-Netbeans » mobility » example » stock » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » mobility » example.stock 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   example.stock.Stock

Stock
final public class Stock (Code)

This is a utility class that is used to parse data obtained from either the quote server or the database and break it into fields for easy use rather than spreading the parsing code around to a thousand different places through out the program.





Method Summary
public static  Stringconvert(int intNum)
    
public static  intgetChange(String quoteString)
    
public static  intgetHigh(String quoteString)
    
public static  intgetLow(String quoteString)
    
public static  StringgetName(String quoteString)
    
public static  intgetOpen(String quoteString)
    
public static  intgetPrevious(String quoteString)
    
public static  intgetPrice(String quoteString)
    
public static  StringgetStringChange(String quoteString)
    
public static  StringgetStringHigh(String quoteString)
    
public static  StringgetStringLow(String quoteString)
    
public static  StringgetStringOpen(String quoteString)
    
public static  StringgetStringPrevious(String quoteString)
    
public static  StringgetStringPrice(String quoteString)
    
public static  StringgetTime(String quoteString)
    
public static  intmakeInt(String str)
    

Take a String representation of an int and the number of decimal places that the String carries and make an int out of it

Since there is no floating point support in MIDP/CLDC, we have to convert the decimal numbers into Integers. We do this by:

  • Looking at only the first 7 significant characters which, because of the decimal, means the first 6 numbers from left to right.
  • Looking at a maximum of 4 decimal places
  • We remove the decimal character (if there is one) and concatenate the numbers before and after the decimal so that we can convert to an integer and manipulate the value as a number
  • After doing this for each number, we have int values but no notion of where the decimal place was.
  • public static  voidparse(String quoteString)
        

    Takes a String from the quote server or database and parses the string into each field.




    Method Detail
    convert
    public static String convert(int intNum)(Code)

    Convert an int into a String with the decimal placed back in

    The String value of the int
    Parameters:
      intNum - the int value to convertto a String



    getChange
    public static int getChange(String quoteString)(Code)

    Return the $ change in the stock

    $ change in the stock today
    Parameters:
      quoteString - String to parse for the field data



    getHigh
    public static int getHigh(String quoteString)(Code)

    Return the 52-week high for the stock

    52-week high of the stock
    Parameters:
      quoteString - String to parse for the field data



    getLow
    public static int getLow(String quoteString)(Code)

    Return the 52-week low of the stock

    52-week low of the stock
    Parameters:
      quoteString - String to parse for the field data



    getName
    public static String getName(String quoteString)(Code)

    Return the name of the stock

    name (ticker symbol) of the stock
    Parameters:
      quoteString - String to parse for the field data



    getOpen
    public static int getOpen(String quoteString)(Code)

    Return the opening price of the stock

    opening price of the stock today
    Parameters:
      quoteString - String to parse for the field data



    getPrevious
    public static int getPrevious(String quoteString)(Code)

    Return the previous high for the stock

    previous high for the stock
    Parameters:
      quoteString - String to parse for the field data



    getPrice
    public static int getPrice(String quoteString)(Code)

    Return the price of the last trade of the stock

    price of the last trade of the stock
    Parameters:
      quoteString - String to parse for the field data



    getStringChange
    public static String getStringChange(String quoteString)(Code)

    String representation of change with decimal placed back in the correct spot

    change in stock price today
    Parameters:
      quoteString - String to parse for the field data



    getStringHigh
    public static String getStringHigh(String quoteString)(Code)

    String representation of the 52-week high with decimal placed back in the correct spot

    52-week high
    Parameters:
      quoteString - String to parse for the field data



    getStringLow
    public static String getStringLow(String quoteString)(Code)

    String representation of the 52-week low with decimal placed back in the correct spot

    52-week low
    Parameters:
      quoteString - String to parse for the field data



    getStringOpen
    public static String getStringOpen(String quoteString)(Code)

    String representation of the opening price with decimal placed back in the correct spot

    opening stock price
    Parameters:
      quoteString - String to parse for the field data



    getStringPrevious
    public static String getStringPrevious(String quoteString)(Code)

    String representation of previous with decimal placed back in the correct spot

    previous high for the stock
    Parameters:
      quoteString - String to parse for the field data



    getStringPrice
    public static String getStringPrice(String quoteString)(Code)

    String representation of price with decimal placed back in the correct spot

    current stock price
    Parameters:
      quoteString - String to parse for the field data



    getTime
    public static String getTime(String quoteString)(Code)

    Return the time of the last trade

    time of the last trade of the stock
    Parameters:
      quoteString - String to parse for the field data



    makeInt
    public static int makeInt(String str) throws NumberFormatException, StringIndexOutOfBoundsException(Code)

    Take a String representation of an int and the number of decimal places that the String carries and make an int out of it

    Since there is no floating point support in MIDP/CLDC, we have to convert the decimal numbers into Integers. We do this by:

  • Looking at only the first 7 significant characters which, because of the decimal, means the first 6 numbers from left to right.
  • Looking at a maximum of 4 decimal places
  • We remove the decimal character (if there is one) and concatenate the numbers before and after the decimal so that we can convert to an integer and manipulate the value as a number
  • After doing this for each number, we have int values but no notion of where the decimal place was. To alleviate this, we make sure that each number has EXACTLY 4 decimal place holders. Therefore, we can divide by 10000 to put the decimal place back in the same spot.
     Example: 100    -> 1000000 ->            /10000 = 100
     Example: 345.67 -> 34567   -> 3456700 -> /10000 = 345.67
     Example: 3.4526 -> 34526   ->            /10000 = 3.4526
     
  • the int value of the string
    Parameters:
      length -
    Parameters:
      source - the String value to convertto an int



    parse
    public static void parse(String quoteString) throws NumberFormatException, StringIndexOutOfBoundsException(Code)

    Takes a String from the quote server or database and parses the string into each field. We first have to split it into small strings and then parse each string that should be a number.
    Parameters:
      quoteString - the String to parse into the fields NumberFormatException is thrown ifdata that is not of the correct format is passed in -- wherethe number parts of the string cannot be converted to Integers because there are non-numeric charactersin positions where numbers are expected StringIndexOutOfBoundsException isthrown if data that is not of the correct format is passedin -- where the delimiters between the fields are not inthe right spots, or the data is not of the correct length




    Methods inherited from java.lang.Object
    native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
    public boolean equals(Object obj)(Code)(Java Doc)
    protected void finalize() throws Throwable(Code)(Java Doc)
    final native public Class getClass()(Code)(Java Doc)
    native public int hashCode()(Code)(Java Doc)
    final native public void notify()(Code)(Java Doc)
    final native public void notifyAll()(Code)(Java Doc)
    public String toString()(Code)(Java Doc)
    final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
    final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
    final public void wait() throws InterruptedException(Code)(Java Doc)

    www.java2java.com | Contact Us
    Copyright 2009 - 12 Demo Source and Support. All rights reserved.
    All other trademarks are property of their respective owners.