View Javadoc
1   /*
2    * Copyright (C) 2003-2014 eXo Platform SAS.
3    *
4    * This is free software; you can redistribute it and/or modify it
5    * under the terms of the GNU Lesser General Public License as
6    * published by the Free Software Foundation; either version 3 of
7    * the License, or (at your option) any later version.
8    *
9    * This software is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   * Lesser General Public License for more details.
13   *
14   * You should have received a copy of the GNU Lesser General Public
15   * License along with this software; if not, write to the Free
16   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18   */
19  package org.exoplatform.singleton;
20  
21  import org.exoplatform.model.ExoFile;
22  
23  import android.os.Bundle;
24  import android.os.Parcel;
25  import android.os.Parcelable;
26  
27  /**
28   * Created by The eXo Platform SAS Author : eXoPlatform exo@exoplatform.com Jan
29   * 31, 2012
30   */
31  public class DocumentHelper implements Parcelable {
32  
33    private static DocumentHelper documentHelper = new DocumentHelper();
34  
35    private String                _urlrepositoryHome;
36  
37    public ExoFile                _fileCopied    = new ExoFile();
38  
39    public ExoFile                _fileMoved     = new ExoFile();
40  
41    public String                 repository     = null;
42  
43    public String                 workspace      = null;
44  
45    /**
46     * The dictionary for mapping a folder with its children<br/>
47     * Folder ExoFile.path (key) => List of children ExoFile (val)
48     */
49    public Bundle                 folderToChildrenMap;
50  
51    /**
52     * The dictionary for mapping a folder with its parent<br/>
53     * Folder ExoFile.path (key) => Parent ExoFile (val)
54     */
55  
56    public Bundle                 folderToParentMap;
57  
58    private DocumentHelper() {
59  
60    }
61  
62    public static DocumentHelper getInstance() {
63      return documentHelper;
64    }
65  
66    public void setInstance(DocumentHelper helper) {
67      documentHelper = helper;
68    }
69  
70    public void setRepositoryHomeUrl(String url) {
71      _urlrepositoryHome = url;
72    }
73  
74    public String getRepositoryHomeUrl() {
75      return _urlrepositoryHome;
76    }
77  
78    private DocumentHelper(Parcel in) {
79      readFromParcel(in);
80    }
81  
82    public static final Parcelable.Creator<DocumentHelper> CREATOR = new Parcelable.Creator<DocumentHelper>() {
83      public DocumentHelper createFromParcel(Parcel in) {
84        return new DocumentHelper(in);
85      }
86  
87      public DocumentHelper[] newArray(int size) {
88        return new DocumentHelper[size];
89      }
90    };
91  
92    private void readFromParcel(Parcel in) {
93      _urlrepositoryHome = in.readString();
94      _fileCopied = in.readParcelable(_fileCopied.getClass().getClassLoader());
95      _fileMoved = in.readParcelable(_fileMoved.getClass().getClassLoader());
96      repository = in.readString();
97      folderToParentMap = in.readBundle();
98      folderToChildrenMap = in.readBundle();
99    }
100 
101   /*
102    * (non-Javadoc)
103    * @see android.os.Parcelable#describeContents()
104    */
105   @Override
106   public int describeContents() {
107     return 0;
108   }
109 
110   /*
111    * (non-Javadoc)
112    * @see android.os.Parcelable#writeToParcel(android.os.Parcel, int)
113    */
114   @Override
115   public void writeToParcel(Parcel dest, int flags) {
116     dest.writeString(_urlrepositoryHome);
117     dest.writeParcelable(_fileCopied, flags);
118     dest.writeParcelable(_fileMoved, flags);
119     dest.writeString(repository);
120     dest.writeBundle(folderToParentMap);
121     dest.writeBundle(folderToChildrenMap);
122   }
123 
124 }