[FIX: These files were missing from the 'file hook' patch. cadmium@x9c.fr**20071118170329] { addfile ./src/fr/x9c/cadmium/kernel/FileHook.java hunk ./src/fr/x9c/cadmium/kernel/FileHook.java 1 +/* + * This file is part of Cadmium. + * Copyright (C) 2007 Xavier Clerc. + * + * Cadmium is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Cadmium is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package fr.x9c.cadmium.kernel; + +import java.io.InputStream; +import java.net.URL; + +/** + * This interface define a hook called when an attempt is made to open an + * input stream over a file. + * + * @author Xavier Clerc + * @version 1.0 + * @since 1.0 + */ +public interface FileHook { + + /** + * Called when an attempt is made to open an input stream. + * @param file file to be opened + * @return an input stream over the passed file + */ + InputStream getInputStream(final String file); + +} // end interface 'FileHook' addfile ./src/fr/x9c/cadmium/util/MemoryInputStream.java hunk ./src/fr/x9c/cadmium/util/MemoryInputStream.java 1 +/* + * This file is part of Cadmium. + * Copyright (C) 2007 Xavier Clerc. + * + * Cadmium is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Cadmium is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package fr.x9c.cadmium.util; + +import java.io.ByteArrayInputStream; + +/** + * This class implements an input stream whose data is read from a byte array. + * + * @author Xavier Clerc + * @version 1.0 + * @since 1.0 + */ +public final class MemoryInputStream extends ByteArrayInputStream { + + /** + * Creates a stream that uses the passed array as its buffer. + * @param buf input buffer + */ + public MemoryInputStream(byte[] buf) { + super(buf); + } // end constructor(byte[]) + + /** + * Returns the length of the underlying buffer. + * @return the length of the underlying buffer + */ + public int length() { + return this.buf.length; + } // end method 'length()' + + /** + * Returns the index of the next character to read. + * @return the index of the next character to read + */ + public int getPosition() { + return this.pos; + } // end method 'getPosition()' + + /** + * Changes the index of the next character to read. + * @param p the index of the next character to read + */ + public void setPosition(final int p) { + this.pos = p; + } // end method 'setPosition(int)' + +} // end class 'MemoryInputStream' }