KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > service > cmr > repository > ContentAccessor


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.service.cmr.repository;
18
19 import org.alfresco.service.transaction.TransactionService;
20
21 /**
22  * Interface for instances that provide read and write access to content.
23  *
24  * @author Derek Hulley
25  */

26 public interface ContentAccessor
27 {
28     /**
29      * Use this method to register any interest in events against underlying
30      * content streams.
31      * {@link #getContentOutputStream() output stream}.
32      * <p>
33      * This method can only be used before the content stream has been retrieved.
34      * <p>
35      * When the stream has been closed, all listeners will be called
36      * within a {@link #setTransactionService(TransactionService) transaction} -
37      * to this end, a {@link TransactionService} must have been set as well.
38      *
39      * @param listener a listener that will be called for output stream
40      * event notification
41      *
42      * @see #setTransactionService(TransactionService)
43      */

44     public void addListener(ContentStreamListener listener);
45     
46     /**
47      * Set the transaction provider that will be used when stream listeners are called.
48      * No transactions are started unless there are listeners present to be executed.
49      * For consistency, the execution of listeners <b>will not</b> be allowed to proceed
50      * unless this property has been set OR the channel close operations are executed
51      * within the context of a live transaction.
52      *
53      * @param transactionService a transaction provider
54      */

55     public void setTransactionService(TransactionService transactionService);
56     
57     /**
58      * Gets the size of the content that this reader references.
59      *
60      * @return Returns the document byte length, or <code>OL</code> if the
61      * content doesn't {@link #exists() exist}.
62      */

63     public long getSize();
64     
65     /**
66      * Get the data representation of the content being accessed.
67      * <p>
68      * The content {@link #setMimetype(String) mimetype } must be set before this
69      * method is called as the content data requires a mimetype whenever the
70      * content URL is specified.
71      *
72      * @return Returns the content data
73      *
74      * @see ContentData#ContentData(String, String, long, String)
75      */

76     public ContentData getContentData();
77     
78     /**
79      * Retrieve the URL that this accessor references
80      *
81      * @return the content URL
82      */

83     public String JavaDoc getContentUrl();
84     
85     /**
86      * Get the content mimetype
87      *
88      * @return Returns a content mimetype
89      */

90     public String JavaDoc getMimetype();
91     
92     /**
93      * Set the mimetype that must be used for accessing the content
94      *
95      * @param mimetype the content mimetype
96      */

97     public void setMimetype(String JavaDoc mimetype);
98     
99     /**
100      * Get the encoding of the content being accessed
101      *
102      * @return Returns a valid java String encoding
103      */

104     public String JavaDoc getEncoding();
105     
106     /**
107      * Set the <code>String</code> encoding for this accessor
108      *
109      * @param encoding a java-recognised encoding format
110      */

111     public void setEncoding(String JavaDoc encoding);
112 }
113
Popular Tags