File Source: UserEntrySet.java

         /* 
    P/P   *  Method: org.apache.roller.weblogger.webservices.adminprotocol.sdk.UserEntrySet__static_init
          */
     1  /*
     2  * Licensed to the Apache Software Foundation (ASF) under one or more
     3  *  contributor license agreements.  The ASF licenses this file to You
     4  * under the Apache License, Version 2.0 (the "License"); you may not
     5  * use this file except in compliance with the License.
     6  * You may obtain a copy of the License at
     7  *
     8  *     http://www.apache.org/licenses/LICENSE-2.0
     9  *
    10  * Unless required by applicable law or agreed to in writing, software
    11  * distributed under the License is distributed on an "AS IS" BASIS,
    12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  * See the License for the specific language governing permissions and
    14  * limitations under the License.  For additional information regarding
    15  * copyright in this work, please see the NOTICE file in the top level
    16  * directory of this distribution.
    17  */
    18  /*
    19   * UserEntrySet.java
    20   *
    21   * Created on January 17, 2006, 12:44 PM
    22   */
    23  
    24  package org.apache.roller.weblogger.webservices.adminprotocol.sdk;
    25  
    26  import java.io.IOException;
    27  import java.io.InputStream;
    28  import java.util.ArrayList;
    29  import java.util.Iterator;
    30  import java.util.List;
    31  import org.jdom.Document;
    32  import org.jdom.Element;
    33  import org.jdom.JDOMException;
    34  import org.jdom.input.SAXBuilder;
    35  import org.apache.roller.weblogger.webservices.adminprotocol.sdk.EntrySet.Types;
    36  
    37  /**
    38   * This class describes a set of user entries. 
    39   * @author jtb
    40   */
    41  public class UserEntrySet extends EntrySet {
    42      /** XML tags that describe a set of user entries. */
    43      private static interface Tags {
    44          public static final String USERS = "users";
    45      }       
    46          
    47      /** Construct based on an array of Roller UserData objects. */
             /* 
    P/P       *  Method: void org.apache.roller.weblogger.webservices.adminprotocol.sdk.UserEntrySet(String)
              * 
              *  Postconditions:
              *    java.lang.StringBuilder:toString(...)._tainted == urlPrefix._tainted
              *    init'ed(java.lang.StringBuilder:toString(...)._tainted)
              *    this.entries == null
              *    this.href == &java.lang.StringBuilder:toString(...)
              */
    48      public UserEntrySet(String urlPrefix) {
    49          setHref(urlPrefix + "/" + Types.USERS);
    50      }
    51      
    52      /** Construct based on a JDOM Document object. */
             /* 
    P/P       *  Method: void org.apache.roller.weblogger.webservices.adminprotocol.sdk.UserEntrySet(Document, String)
              * 
              *  Preconditions:
              *    d != null
              * 
              *  Postconditions:
              *    init'ed(java.lang.StringBuilder:toString(...)._tainted)
              *    init'ed(this.entries)
              *    this.href == &java.lang.StringBuilder:toString(...)
              */
    53      public UserEntrySet(Document d, String urlPrefix) throws UnexpectedRootElementException {
    54          populate(d, urlPrefix);
    55      }
    56      
             /* 
    P/P       *  Method: void org.apache.roller.weblogger.webservices.adminprotocol.sdk.UserEntrySet(InputStream, String)
              * 
              *  Presumptions:
              *    org.jdom.input.SAXBuilder:build(...)@59 != null
              * 
              *  Postconditions:
              *    init'ed(java.lang.StringBuilder:toString(...)._tainted)
              *    init'ed(this.entries)
              *    this.href == &java.lang.StringBuilder:toString(...)
              */
    57      public UserEntrySet(InputStream stream, String urlPrefix) throws JDOMException, IOException, UnexpectedRootElementException {               
    58          SAXBuilder sb = new SAXBuilder();
    59          Document d = sb.build(stream);
    60  
    61          populate(d, urlPrefix);        
    62      }        
    63      
    64      private void populate(Document d, String urlPrefix) throws UnexpectedRootElementException {
                 /* 
    P/P           *  Method: void populate(Document, String)
                  * 
                  *  Preconditions:
                  *    d != null
                  * 
                  *  Presumptions:
                  *    java.lang.String:equals(...)@67 == 1
                  *    java.util.Iterator:next(...)@74 != null
                  *    org.jdom.Document:getRootElement(...)@65 != null
                  *    org.jdom.Element:getName(...)@66 != null
                  * 
                  *  Postconditions:
                  *    init'ed(java.lang.StringBuilder:toString(...)._tainted)
                  *    possibly_updated(this.entries)
                  *    this.href == &java.lang.StringBuilder:toString(...)
                  * 
                  *  Test Vectors:
                  *    java.util.Iterator:hasNext(...)@73: {0}, {1}
                  *    org.jdom.Element:getChildren(...)@70: Addr_Set{null}, Inverse{null}
                  */
    65          Element root = d.getRootElement();
    66          String rootName = root.getName();
    67          if (!rootName.equals(Tags.USERS)) {
    68              throw new UnexpectedRootElementException("ERROR: Unexpected root element", Tags.USERS, rootName);
    69          }
    70          List users = root.getChildren(UserEntry.Tags.USER, NAMESPACE);
    71          if (users != null) {
    72              List entries = new ArrayList();
    73              for (Iterator i = users.iterator(); i.hasNext(); ) {
    74                  Element user = (Element)i.next();
    75                  UserEntry entry = new UserEntry(user, urlPrefix);
    76                  entries.add(entry);
    77              }
    78              setEntries((Entry[])entries.toArray(new Entry[0]));
    79          }
    80          setHref(urlPrefix + "/" + Types.USERS);
    81      }    
    82          
    83      public String getType() {
                 /* 
    P/P           *  Method: String getType()
                  * 
                  *  Postconditions:
                  *    return_value == &"users"
                  */
    84          return Types.USERS;
    85      }    
    86  }








SofCheck Inspector Build Version : 2.18479
UserEntrySet.java 2009-Jan-02 14:25:38
UserEntrySet.class 2009-Sep-04 03:12:46
UserEntrySet$Tags.class 2009-Sep-04 03:12:46