Package com.ib.controller.Profile

Examples of com.ib.controller.Profile.Allocation


  static ArrayList<Profile> getProfiles_( String xml) throws IOException {
    ArrayList<Profile> list = new ArrayList<Profile>();

    Profile profile = null;
    Allocation alloc = null;

    BufferedReader reader = new BufferedReader( new StringReader( xml) );
    String line;
    int state = 0; // 0=none; 1=list of groups; 2=reading group 3=listOfAllocations 4=allocation
    for( int lc = 0; ((line=reader.readLine()) != null); lc++) {
      line = line.trim();

      switch( state) {
        // top of file
        case 0:
          if (line.equals( "<ListOfAllocationProfiles>")) {
            state = 1;
          }
          break;

        // reading profiles
        case 1:
          if (line.equals( "<AllocationProfile>")) {
            profile = new Profile();
            state = 2;
          }
          else if (line.equals( "</ListOfAllocationProfiles>")) {
            state = 0;
          }
          else {
            err( line);
          }
          break;

        // reading Profile
        case 2:
          if (line.startsWith( "<name>") ) {
            profile.name( getVal( line) );
          }
          else if (line.startsWith( "<type>")) {
            int i = Integer.parseInt( getVal( line) );
            profile.type( Type.get( i) );
          }
          else if (line.startsWith( "<ListOfAllocations")) {
            state = 3;
          }
          else if (line.equals( "</AllocationProfile>")) {
            list.add( profile);
            state = 1;
          }
          else {
            err( line);
          }
          break;

        // reading list of allocations
        case 3:
          if (line.equals( "<Allocation>")) {
            alloc = new Allocation();
            state = 4;
          }
          else if (line.equals( "</ListOfAllocations>")) {
            state = 2;
          }
          else {
            err( line);
          }
          break;

        // reading Allocation
        case 4:
          if (line.startsWith( "<acct>") ) {
            alloc.account( getVal( line) );
          }
          else if (line.startsWith( "<amount>") ) {
            alloc.amount( getVal( line) );
          }
          else if (line.startsWith( "<posEff>") ) {
            // skip this
          }
          else if (line.equals( "</Allocation>") ) {
View Full Code Here

TOP

Related Classes of com.ib.controller.Profile.Allocation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.