public synchronized int read() throws IOException { waitForData(); if (available() == -1) { return -1; } byte b = input[outPointer]; outPointer++; if (outPointer == input.length) { outPointer = 0; } size -= 1; return b; }
@Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
public void disconnect() { synchronized (overflowLock) { document = null; partitions.clear(); connected = false; try { inputStream.close(); } catch (IOException e) { } } }
public void run() { isRunning = true; try { int readwait = LogViewerPlugin.getDefault().getPreferenceStore().getInt(ILogViewerConstants.PREF_READWAIT); inStream = getInputStream(); while(isRunning) { int available = inStream.available(); if (available > 0) { byte[] readed = new byte[available]; inStream.read(readed, 0, available); outStream.write(readed); //continue; } wait(readwait); } } catch(InterruptedException ie) { } catch(NullPointerException npe) { } catch (IOException e) { } finally { } isRunning = false; }
private int getFontStyle() { if (type.equals(INPUT_PARTITION_TYPE)) { return inputStream.getFontStyle(); } return outputStream.getFontStyle(); }
public Color getColor() { if (type.equals(INPUT_PARTITION_TYPE)) { return inputStream.getColor(); } return outputStream.getColor(); }
/** * Constructs a console with the given name, type, image, encoding and lifecycle. * * @param name name to display for this console * @param consoleType console type identifier or <code>null</code> * @param imageDescriptor image to display for this console or <code>null</code> * @param autoLifecycle whether lifecycle methods should be called automatically * when this console is added/removed from the console manager */ public IOConsole(String name, String consoleType, ImageDescriptor imageDescriptor, String encoding, boolean autoLifecycle) { super(name, consoleType, imageDescriptor, autoLifecycle); if (encoding != null) { fEncoding = encoding; } openStreams = new ArrayList(); inputStream = new IOConsoleInputStream(this); synchronized (openStreams) { openStreams.add(inputStream); } partitioner = new IOConsolePartitioner(inputStream, this); partitioner.connect(getDocument()); }
inputStream.appendData(input.toString());
/** * Returns the font of the input stream if the type of the partition * is <code>INPUT_PARTITION_TYPE</code>, otherwise it returns the output * stream font * * @return the font of one of the backing streams */ private int getFontStyle() { if (type.equals(INPUT_PARTITION_TYPE)) { return inputStream.getFontStyle(); } return outputStream.getFontStyle(); }
/** * Returns the colour of the input stream if the type of the partition * is <code>INPUT_PARTITION_TYPE</code>, otherwise it returns the output * stream colour * * @return the colour of one of the backing streams */ public Color getColor() { if (type.equals(INPUT_PARTITION_TYPE)) { return inputStream.getColor(); } return outputStream.getColor(); }
/** * Constructs a console with the given name, type, image, encoding and lifecycle. * * @param name name to display for this console * @param consoleType console type identifier or <code>null</code> * @param imageDescriptor image to display for this console or <code>null</code> * @param encoding the encoding that should be used to render the text, or <code>null</code> * if the system default encoding should be used * @param autoLifecycle whether lifecycle methods should be called automatically * when this console is added/removed from the console manager */ public IOConsole(String name, String consoleType, ImageDescriptor imageDescriptor, String encoding, boolean autoLifecycle) { super(name, consoleType, imageDescriptor, autoLifecycle); if (encoding != null) { fEncoding = encoding; } synchronized (openStreams) { inputStream = new IOConsoleInputStream(this); openStreams.add(inputStream); } if (inputStream instanceof IOConsoleInputStream) { partitioner = new IOConsolePartitioner((IOConsoleInputStream) inputStream, this); partitioner.connect(getDocument()); } }
inputStream.appendData(input.toString());
@Override public synchronized int read() throws IOException { waitForData(); if (available() == -1) { return -1; } byte b = input[outPointer]; outPointer++; if (outPointer == input.length) { outPointer = 0; } size -= 1; return b; }
public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public void disconnect() { synchronized (overflowLock) { document = null; partitions.clear(); connected = false; try { inputStream.close(); } catch (IOException e) { } } }
public synchronized int read(byte[] b, int off, int len) throws IOException { waitForData(); if (available() == -1) { return -1; } int toCopy = Math.min(len, size); if(input.length-outPointer > toCopy) { System.arraycopy(input, outPointer, b, off, toCopy); outPointer += toCopy; size -= toCopy; } else { int bytesToEnd = input.length-outPointer; System.arraycopy(input, outPointer, b, off, bytesToEnd); System.arraycopy(input, 0, b, off+bytesToEnd, toCopy-bytesToEnd); outPointer = toCopy-bytesToEnd; size -=toCopy; } return toCopy; }
/** * Disposes this console. */ protected void dispose() { super.dispose(); partitioner.disconnect(); //make a copy of the open streams and close them all //a copy is needed as close the streams results in a callback that //removes the streams from the openStreams collection (bug 152794) Object[] allStreams= openStreams.toArray(); for (int i = 0; i < allStreams.length; i++) { Object stream = allStreams[i]; if (stream instanceof IOConsoleInputStream) { IOConsoleInputStream is = (IOConsoleInputStream) stream; try { is.close(); } catch (IOException e) { } } else if (stream instanceof IOConsoleOutputStream) { IOConsoleOutputStream os = (IOConsoleOutputStream) stream; try { os.close(); } catch (IOException e) { } } } inputStream = null; }
@Override public synchronized int read(byte[] b, int off, int len) throws IOException { waitForData(); if (available() == -1) { return -1; } int toCopy = Math.min(len, size); if(input.length-outPointer > toCopy) { System.arraycopy(input, outPointer, b, off, toCopy); outPointer += toCopy; size -= toCopy; } else { int bytesToEnd = input.length-outPointer; System.arraycopy(input, outPointer, b, off, bytesToEnd); System.arraycopy(input, 0, b, off+bytesToEnd, toCopy-bytesToEnd); outPointer = toCopy-bytesToEnd; size -=toCopy; } return toCopy; }