Annotation of java/classes/org/w3c/rdf/RDFSource.java, revision 1.1

1.1     ! jsaarela    1: /**
        !             2:  * Copyright © World Wide Web Consortium, (Massachusetts Institute of
        !             3:  * Technology, Institut National de Recherche en Informatique et en
        !             4:  * Automatique, Keio University).
        !             5:  *
        !             6:  * All Rights Reserved.
        !             7:  *
        !             8:  * Please see the full Copyright clause at
        !             9:  * <http://www.w3.org/Consortium/Legal/copyright-software.html>
        !            10:  *
        !            11:  * RDFSource class
        !            12:  *
        !            13:  * $Log$
        !            14:  *
        !            15:  * @author     Janne Saarela <jsaarela@w3.org>
        !            16:  */
        !            17: package org.w3c.rdf;
        !            18: 
        !            19: import java.io.InputStream;
        !            20: import java.io.Reader;
        !            21: import java.io.IOException;
        !            22: import java.net.URL;
        !            23: 
        !            24: public class RDFSource
        !            25: {
        !            26:     private String     m_sContent = null;
        !            27:     private String     m_sURL = null;
        !            28: 
        !            29:     public RDFSource (URL url) {
        !            30:        m_sURL = url.toString();
        !            31:        try {
        !            32:            fetchByteStream (url.openStream());
        !            33:        } catch (IOException ex) {
        !            34:            m_sContent = null;
        !            35:        }
        !            36:     }
        !            37: 
        !            38:     public RDFSource (InputStream is) {
        !            39:        fetchByteStream(is);
        !            40:     }
        !            41: 
        !            42:     public RDFSource (String sContent) {
        !            43:        m_sContent = sContent;
        !            44:     }
        !            45: 
        !            46:     public String content () {
        !            47:        return m_sContent;
        !            48:     }
        !            49: 
        !            50:     public String url() {
        !            51:        return m_sURL;
        !            52:     }
        !            53: 
        !            54:     public void fetchByteStream (InputStream is) {
        !            55:        m_sContent = new String();
        !            56:        try {
        !            57:            int len = is.available();
        !            58:            is.mark(len);
        !            59:            int c;
        !            60: 
        !            61:            while ((c = is.read()) != -1) {
        !            62:                m_sContent += (char)c;
        !            63:            }
        !            64:        } catch (IOException ex) {
        !            65:            m_sContent = null;
        !            66:        }
        !            67:     }
        !            68: }

Webmaster