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 * Nuxeo - initial API and implementation 011 * 012 */ 013 014package org.nuxeo.ecm.core.api.blobholder; 015 016import java.io.Serializable; 017import java.util.ArrayList; 018import java.util.Calendar; 019import java.util.List; 020import java.util.Map; 021 022import org.nuxeo.ecm.core.api.Blob; 023 024/** 025 * {@link BlobHolder} implementation that simply wraps a detached {@link Blob}. 026 * 027 * @author tiry 028 */ 029public class SimpleBlobHolder extends AbstractBlobHolder { 030 031 protected List<Blob> blobs; 032 033 protected Calendar creationDate; 034 035 public SimpleBlobHolder() { 036 // Empty constructor 037 } 038 039 public SimpleBlobHolder(List<Blob> blobs) { 040 init(blobs); 041 } 042 043 public SimpleBlobHolder(Blob blob) { 044 blobs = new ArrayList<Blob>(); 045 blobs.add(blob); 046 init(blobs); 047 } 048 049 protected void init(List<Blob> blobs) { 050 this.blobs = blobs; 051 creationDate = Calendar.getInstance(); 052 } 053 054 @Override 055 public Blob getBlob() { 056 if (blobs == null || blobs.size() == 0) { 057 return null; 058 } else { 059 return blobs.get(0); 060 } 061 } 062 063 @Override 064 public List<Blob> getBlobs() { 065 return blobs; 066 } 067 068 @Override 069 protected String getBasePath() { 070 return ""; 071 } 072 073 @Override 074 public Calendar getModificationDate() { 075 return creationDate; 076 } 077 078 @Override 079 public Serializable getProperty(String name) { 080 return null; 081 } 082 083 @Override 084 public Map<String, Serializable> getProperties() { 085 return null; 086 } 087 088}