View Javadoc

1   /*
2    * #%L
3    * Bitrepository Access
4    * 
5    * $Id$
6    * $HeadURL$
7    * %%
8    * Copyright (C) 2010 - 2011 The State and University Library, The Royal Library and The State Archives, Denmark
9    * %%
10   * This program is free software: you can redistribute it and/or modify
11   * it under the terms of the GNU Lesser General Public License as 
12   * published by the Free Software Foundation, either version 2.1 of the 
13   * License, or (at your option) any later version.
14   * 
15   * This program is distributed in the hope that it will be useful,
16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18   * GNU General Lesser Public License for more details.
19   * 
20   * You should have received a copy of the GNU General Lesser Public 
21   * License along with this program.  If not, see
22   * <http://www.gnu.org/licenses/lgpl-2.1.html>.
23   * #L%
24   */
25  package org.bitrepository.access.getfileids.conversation;
26  
27  import org.bitrepository.bitrepositoryelements.ResultingFileIDs;
28  import org.bitrepository.client.eventhandler.ContributorCompleteEvent;
29  
30  /**
31  * Contains the result of a GetFileIDs request sent to a single pillar.
32  */
33  public class FileIDsCompletePillarEvent extends ContributorCompleteEvent {
34      /** The result from the pillar.*/
35      private final ResultingFileIDs result;
36      private final boolean isPartialResult;
37  
38      /**
39       * @param result The result returned by the pillar.
40       * @param pillarID The pillar which generated the result
41       */
42      public FileIDsCompletePillarEvent(String pillarID, String collectionID, ResultingFileIDs result, boolean isPartialResult) {
43          super(pillarID, collectionID);
44          this.result = result;
45          this.isPartialResult = isPartialResult;
46      }
47  
48      /**
49       * @return The results from the pillar, which has completed the GetFileIDs operation.
50       */
51      public ResultingFileIDs getFileIDs() {
52          return result;
53      }
54  
55      public boolean isPartialResult() {
56          return isPartialResult;
57      }
58  
59      @Override
60      public String additionalInfo() {
61          StringBuilder infoSB = new StringBuilder(super.additionalInfo());
62  
63          if (result != null && result.getFileIDsData() != null) {
64              infoSB.append(", NumberOfFileIDs=" +
65                      result.getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size());
66          }
67  
68          infoSB.append(", PartialResult=" + isPartialResult);
69          return infoSB.toString();
70      }
71  }