Package org.teiid.core.types

Examples of org.teiid.core.types.InputStreamFactory


            findLength(2);
        }
          if (stream == null) {
            final File f = File.createTempFile("teiid", null); //$NON-NLS-1$
            StreamFactoryReference sfr = streams.get(streamIndex);
            sfr.setStreamFactory(new InputStreamFactory() {
         
          @Override
          public InputStream getInputStream() throws IOException {
            return new BufferedInputStream(new FileInputStream(f)) {
              @Override
View Full Code Here


  public void testLobPeristence() throws Exception{
   
    BufferManagerImpl buffMgr = BufferManagerFactory.createBufferManager();
    FileStore fs = buffMgr.createFileStore("temp");
   
    ClobType clob = new ClobType(new ClobImpl(new InputStreamFactory() {
      @Override
      public InputStream getInputStream() throws IOException {
        return new ReaderInputStream(new StringReader("Clob contents One"),  Charset.forName(Streamable.ENCODING));
      }
     
    }, -1));
   
    BlobType blob = new BlobType(new BlobImpl(new InputStreamFactory() {
      @Override
      public InputStream getInputStream() throws IOException {
        return new ReaderInputStream(new StringReader("Blob contents Two"),  Charset.forName(Streamable.ENCODING));
      }
     
View Full Code Here

 
  @Test public void testReplaceObject() throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectEncoderOutputStream out = new ObjectEncoderOutputStream(new DataOutputStream(baos), 512);
   
    ClobImpl clob = new ClobImpl(new InputStreamFactory() {
      @Override
      public InputStream getInputStream() throws IOException {
        return new ReaderInputStream(new StringReader("Clob contents"),  Charset.forName(Streamable.ENCODING)); //$NON-NLS-1$
      }
     
View Full Code Here

   
    // if this is already saved to disk just return
    if (lob.getReference() instanceof BaseLob) {
      try {
        BaseLob baseLob = (BaseLob)lob.getReference();
        InputStreamFactory isf = baseLob.getStreamFactory();
        if (isf.isPersistent()) {
          return lob;
        }
      } catch (SQLException e) {
        // go through regular persistence.
      }
    }
    long offset = store.getLength();
    int length = 0;
    Streamable<?> persistedLob;
         
    try {
      InputStreamFactory isf = new InputStreamFactory() {
        @Override
        public InputStream getInputStream() throws IOException {
            if (lob instanceof BlobType) {
              return new BlobInputStreamFactory((Blob)lob).getInputStream();
            }
            else if (lob instanceof ClobType) {
              return new ClobInputStreamFactory((Clob)lob).getInputStream();
            }
            return new SQLXMLInputStreamFactory((SQLXML)lob).getInputStream();
        }         
      };
      InputStream is = isf.getInputStream();
      OutputStream fsos = store.createOutputStream();
      length = ObjectConverterUtil.write(fsos, is, bytes, -1);
    } catch (IOException e) {
      throw new TeiidComponentException(e);
    }
   
    // re-construct the new lobs based on the file store
    final long lobOffset = offset;
    final int lobLength = length;
    InputStreamFactory isf = new InputStreamFactory() {
      @Override
      public InputStream getInputStream() throws IOException {
        return store.createInputStream(lobOffset, lobLength);
      }
     
View Full Code Here

        if (!xp.isWellFormed()) {
          Reader r = new StringReader(string);
          type = validate(xp, r);
        }
      } else {
        InputStreamFactory isf = null;
        Streamable<?> s = (Streamable<?>)value;
        isf = getInputStreamFactory(s);
        result = new SQLXMLImpl(isf);
        if (!xp.isWellFormed()) {
          Reader r = result.getCharacterStream();
View Full Code Here

  private Object serialize(XMLSerialize xs, XMLType value) throws TransformationException {
    if (xs.getType() == DataTypeManager.DefaultDataClasses.STRING) {
      return DataTypeManager.transformValue(value, xs.getType());
    }
    InputStreamFactory isf = getInputStreamFactory(value);
    return new ClobType(new ClobImpl(isf, -1));
  }
View Full Code Here

    throw SqlUtil.createFeatureNotSupportedException();
  }

  public void setAsciiStream(int parameterIndex, final InputStream x)
      throws SQLException {
    this.setObject(parameterIndex, new ClobImpl(new InputStreamFactory() {
      @Override
      public InputStream getInputStream() throws IOException {
        return x;
      }
    }, -1));
View Full Code Here

      throws SQLException {
    if (inputStream == null) {
      this.setObject(parameterIndex, null);
      return;
    }
    this.setObject(parameterIndex, new BlobImpl(new InputStreamFactory() {
      @Override
      public InputStream getInputStream() throws IOException {
        return inputStream;
      }
    }));
View Full Code Here

  public void setClob(int parameterIndex, final Reader reader) throws SQLException {
    if (reader == null) {
      this.setObject(parameterIndex, null);
      return;
    }
    this.setObject(parameterIndex, new ClobImpl(new InputStreamFactory() {
     
      @Override
      public InputStream getInputStream() throws IOException {
        return new ReaderInputStream(reader, Charset.forName(Streamable.ENCODING));
      }
View Full Code Here

          }
            if(currentValue instanceof ClobType){
              currentValue = new ClobImpl(createInputStreamFactory((ClobType)currentValue), ((ClobType)currentValue).getLength());
            }
            else if (currentValue instanceof BlobType) {
              InputStreamFactory isf = createInputStreamFactory((BlobType)currentValue);
              isf.setLength(((BlobType)currentValue).getLength());
              currentValue = new BlobImpl(isf);
            }
            else if (currentValue instanceof XMLType) {
              XMLType val = (XMLType)currentValue;
              currentValue = new SQLXMLImpl(createInputStreamFactory(val));
View Full Code Here

TOP

Related Classes of org.teiid.core.types.InputStreamFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.