001 /****************************************************************
002 * Licensed to the Apache Software Foundation (ASF) under one *
003 * or more contributor license agreements. See the NOTICE file *
004 * distributed with this work for additional information *
005 * regarding copyright ownership. The ASF licenses this file *
006 * to you under the Apache License, Version 2.0 (the *
007 * "License"); you may not use this file except in compliance *
008 * with the License. You may obtain a copy of the License at *
009 * *
010 * http://www.apache.org/licenses/LICENSE-2.0 *
011 * *
012 * Unless required by applicable law or agreed to in writing, *
013 * software distributed under the License is distributed on an *
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015 * KIND, either express or implied. See the License for the *
016 * specific language governing permissions and limitations *
017 * under the License. *
018 ****************************************************************/
019
020 package org.apache.hupa.shared.rpc;
021
022 import java.io.Serializable;
023 import java.util.ArrayList;
024 import java.util.List;
025
026 import org.apache.hupa.shared.data.IMAPFolder;
027
028 import net.customware.gwt.dispatch.shared.Result;
029
030 public class FetchFoldersResult implements Result, Serializable {
031
032 /**
033 *
034 */
035 private static final long serialVersionUID = -6215610133650989605L;
036 private List<IMAPFolder> folders;
037
038 public FetchFoldersResult(List<IMAPFolder> folders) {
039 this.folders=folders;
040 }
041
042 @SuppressWarnings("unused")
043 private FetchFoldersResult() {
044 }
045
046 public List<IMAPFolder> getFolders() {
047 return folders;
048 }
049
050 public String toString() {
051 StringBuffer ret = new StringBuffer("");
052 for (IMAPFolder folder : folders) {
053 ret.append(folder.getFullName()).append("\n");
054 for (IMAPFolder f : folder.getChildIMAPFolders()) {
055 childFolder(f, ret);
056 }
057 }
058 return ret.toString();
059 }
060
061 private void childFolder(IMAPFolder child, StringBuffer ret) {
062 ret.append(child.getFullName()).append("\n");
063 for (IMAPFolder folder : child.getChildIMAPFolders()) {
064 childFolder(folder, ret);
065 }
066 }
067
068 }