[Webfunds-commits] java/webfunds/ricardian SSDFields.java IniFileReader.java

Ian Grigg iang@cypherpunks.ai
Fri, 6 Apr 2001 18:44:03 -0400 (AST)


iang        01/04/06 18:44:03

  Added:       webfunds/ricardian SSDFields.java
  Removed:     webfunds/ricardian IniFileReader.java
  Log:
  SSDFields now does access to the SSD tags in the contract.
  IniFileReader has been moved to webfunds.util;

Revision  Changes    Path
1.1                  java/webfunds/ricardian/SSDFields.java

Index: SSDFields.java
===================================================================
/*
 * $Id: SSDFields.java,v 1.1 2001/04/06 22:44:02 iang Exp $
 *
 * Copyright (c) Systemics Ltd 1995-1999 on behalf of
 * the WebFunds Development Team.  All Rights Reserved.
 */
package webfunds.ricardian;

/**
 *  Get the names and URLs for the SSD from a Contract.
 *
 */
public class SSDFields
{
    private SSDFields() {}


    /**
     *  Get the urls for the SSD from the contract.
     *  @return array of urls
     */
    public static String[] getLocation(Contract contract)
    {
        String urls[];

        urls = contract.getArray("local", "server_file_url");
        if (urls.length != 0)
            return urls ;

        // XXX: Deprecated, was used with x.509 contracts.
        urls = new String[1];
        urls[0] = contract.getField("local", "issuer_url");
        if (urls[0] == null || urls[0].length() == 0)
            urls = new String[0] ;
   
        return urls ;
    }

    /**
     *  Get the name of the SOX Server that this contract indicates.
     *
     *  @return name of SSD, or null if no name found in Contract
     */
    public static String getName(Contract contract)
    {  
      
        String name = contract.getField("local", "sox_server_name");
        if (name != null && name.length() > 0)
            return name ;
   
        String[] urls = getLocation(contract);
        if (urls.length == 0)
            return null;
       
        for (int i = 0; i < urls.length; i++)
        {             
            String s = urls[0];
            int slash = s.lastIndexOf('/');        // find last '/'
            if (slash < 0)
                continue ;
            name = s.substring(slash);          // take last thing after '/'
            if ((name != null) && (name.length() > 0))
                return name;

        }
        return null;
    }

}