001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     bstefanescu
011 */
012package org.nuxeo.ecm.automation.client.model;
013
014import java.util.ArrayList;
015
016/**
017 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
018 */
019public class DocRefs extends ArrayList<DocRef> implements OperationInput {
020
021    private static final long serialVersionUID = 1L;
022
023    public DocRefs() {
024    }
025
026    public DocRefs(int size) {
027        super(size);
028    }
029
030    public DocRefs(DocRefs docs) {
031        super(docs);
032    }
033
034    public String getInputType() {
035        return "documents";
036    }
037
038    public String getInputRef() {
039        StringBuilder buf = new StringBuilder("docs:");
040        int size = size();
041        if (size == 0) {
042            return buf.toString();
043        }
044        buf.append(get(0).ref);
045        for (int i = 1; i < size; i++) {
046            buf.append(",").append(get(i).ref);
047        }
048        return buf.toString();
049    }
050
051    public boolean isBinary() {
052        return false;
053    }
054
055    public String toString() {
056        StringBuilder buf = new StringBuilder();
057        int size = size();
058        if (size == 0) {
059            return buf.toString();
060        }
061        buf.append(get(0).ref);
062        for (int i = 1; i < size; i++) {
063            buf.append(",").append(get(i).ref);
064        }
065        return buf.toString();
066    }
067
068    public String dump() {
069        return super.toString();
070    }
071}