From: <fd...@us...> - 2008-05-03 18:17:08
|
Revision: 4050 http://jnode.svn.sourceforge.net/jnode/?rev=4050&view=rev Author: fduminy Date: 2008-05-03 11:17:04 -0700 (Sat, 03 May 2008) Log Message: ----------- AnnotateTask improvement : using faster method for timestamps (no more need for a properties file for that) Modified Paths: -------------- trunk/all/build.xml trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java Modified: trunk/all/build.xml =================================================================== --- trunk/all/build.xml 2008-05-03 15:37:04 UTC (rev 4049) +++ trunk/all/build.xml 2008-05-03 18:17:04 UTC (rev 4050) @@ -180,8 +180,9 @@ <!-- Initialize timestamp --> <tstamp/> + <property name="hotswap.class.tstamp.pattern" value="MM/dd/yyyy kk:mm:ss"/> <tstamp> - <format property="hotswap.class.tstamp" pattern="MM/dd/yyyy kk:mm:ss" /> + <format property="hotswap.class.tstamp" pattern="${hotswap.class.tstamp.pattern}" /> </tstamp> @@ -728,8 +729,8 @@ classpathref="cp-jnode"/> <oj-annotate annotationFile="${root.dir}/all/conf/openjdk-annotations.properties" - timestampFile="${build.dir}/timestamps.properties" - trace="false" failonerror="true"> + buildStartTime="${hotswap.class.tstamp}" pattern="${hotswap.class.tstamp.pattern}" + trace="false" failonerror="true"> <fileset dir="${root.dir}/core/build/classes"> <patternset includes="**/*.class"/> </fileset> Modified: trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java =================================================================== --- trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java 2008-05-03 15:37:04 UTC (rev 4049) +++ trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java 2008-05-03 18:17:04 UTC (rev 4050) @@ -27,6 +27,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -63,22 +64,25 @@ private static final String MAGICPERMISSION_TYPE_DESC = Type.getDescriptor(MagicPermission.class); private File annotationFile; - private File timestampFile; private String[] classesFiles; - private Properties timestamps = new Properties(); + + private String buildStartTime = ""; + private String pattern = ""; + private long startTime = 0; + private Properties annotations = new Properties(); protected void doExecute() throws BuildException { - try - { - if(readProperties()) - { - processFiles(); - } + try { + SimpleDateFormat format = new SimpleDateFormat(pattern); + startTime = format.parse(buildStartTime).getTime(); + } catch (Exception e) { + throw new BuildException("invalid buildStartTime or pattern", e); } - finally + + if(readProperties()) { - saveTimestamps(); + processFiles(); } } @@ -89,44 +93,23 @@ public final void setAnnotationFile(File annotationFile) { this.annotationFile = annotationFile; } - + /** - * Defines the timestamp property file that is used to know if a class file - * has been recompiled since the annotation has been added - * (in such case, the annotation is lost and must be added again) - * - * @param timestampFile + * Define the time at which build started + * @param annotationFile */ - public final void setTimestampFile(File timestampFile) { - this.timestampFile = timestampFile; + public final void setBuildStartTime(String buildStartTime) { + this.buildStartTime = buildStartTime; } - + /** - * Save the new timestamps in a property file + * Define the pattern with which buildStartTime is defined + * @param annotationFile */ - private void saveTimestamps() - { - FileOutputStream fos = null; - try - { - fos = new FileOutputStream(timestampFile); - timestamps.store(fos, "Here are the timestamps for classes with added annotations"); - } catch (IOException e) { - throw new BuildException(e); - } - finally - { - if(fos != null) - { - try { - fos.close(); - } catch (IOException e) { - throw new BuildException(e); - } - } - } + public final void setPattern(String pattern) { + this.pattern = pattern; } - + /** * Read the properties file. For now, it simply contains a list of * classes that need the SharedStatics annotation. @@ -136,8 +119,6 @@ */ private boolean readProperties() throws BuildException { - readProperties("timestampFile", timestampFile, timestamps); - readProperties("annotationFile", annotationFile, annotations); if(annotations.isEmpty()) { @@ -229,9 +210,8 @@ { return; } - - long timestamp = Long.valueOf(timestamps.getProperty(classFile.getName(), "0")).longValue(); - if(classFile.lastModified() <= timestamp) + + if(classFile.lastModified() < startTime) { System.out.println("Skipping already annotated file "+classFile.getName()); return; @@ -273,8 +253,6 @@ throw new IOException("can't rename "+tmpFile.getAbsolutePath()); } } - - timestamps.setProperty(classFile.getName(), Long.toString(classFile.lastModified())); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2008-05-04 06:19:20
|
Revision: 4052 http://jnode.svn.sourceforge.net/jnode/?rev=4052&view=rev Author: crawley Date: 2008-05-03 23:19:17 -0700 (Sat, 03 May 2008) Log Message: ----------- Converted SMBusCommand, and moved it from the "org.jnode.shell.command.driver.system.acpi" plugin to a new one called: "org.jnode.shell.command.driver.system.bus" Modified Paths: -------------- trunk/all/conf/default-plugin-list.xml trunk/shell/descriptors/org.jnode.shell.command.driver.system.acpi.xml trunk/shell/descriptors/org.jnode.shell.command.system.xml Added Paths: ----------- trunk/shell/descriptors/org.jnode.shell.command.driver.system.bus.xml trunk/shell/src/shell/org/jnode/shell/command/driver/system/bus/ trunk/shell/src/shell/org/jnode/shell/command/driver/system/bus/SMBusCommand.java Removed Paths: ------------- trunk/shell/src/shell/org/jnode/shell/command/driver/system/acpi/SMBusCommand.java Modified: trunk/all/conf/default-plugin-list.xml =================================================================== --- trunk/all/conf/default-plugin-list.xml 2008-05-04 05:21:52 UTC (rev 4051) +++ trunk/all/conf/default-plugin-list.xml 2008-05-04 06:19:17 UTC (rev 4052) @@ -161,6 +161,7 @@ <plugin id="org.jnode.shell.command.debug"/> <plugin id="org.jnode.shell.command.driver"/> <plugin id="org.jnode.shell.command.driver.system.acpi"/> + <plugin id="org.jnode.shell.command.driver.system.bus"/> <plugin id="org.jnode.shell.command.driver.console"/> <plugin id="org.jnode.shell.command.log4j"/> <plugin id="org.jnode.shell.command.plugin"/> Modified: trunk/shell/descriptors/org.jnode.shell.command.driver.system.acpi.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.driver.system.acpi.xml 2008-05-04 05:21:52 UTC (rev 4051) +++ trunk/shell/descriptors/org.jnode.shell.command.driver.system.acpi.xml 2008-05-04 06:19:17 UTC (rev 4052) @@ -9,7 +9,6 @@ <requires> <import plugin="org.jnode.driver.system.acpi"/> - <import plugin="org.jnode.driver.bus.smbus"/> <import plugin="org.jnode.shell.help"/> </requires> @@ -21,7 +20,6 @@ <extension point="org.jnode.shell.aliases"> <alias name="acpi" class="org.jnode.shell.command.driver.system.acpi.AcpiCommand"/> - <alias name="smbus" class="org.jnode.shell.command.driver.system.acpi.SMBusCommand"/> </extension> <extension point="org.jnode.shell.syntaxes"> Added: trunk/shell/descriptors/org.jnode.shell.command.driver.system.bus.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.driver.system.bus.xml (rev 0) +++ trunk/shell/descriptors/org.jnode.shell.command.driver.system.bus.xml 2008-05-04 06:19:17 UTC (rev 4052) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plugin SYSTEM "jnode.dtd"> + +<plugin id="org.jnode.shell.command.driver.system.bus" + name="JNode System bus commands" + version="@VERSION@" + license-name="lgpl" + provider-name="JNode.org"> + + <requires> + <import plugin="org.jnode.driver.bus.smbus"/> + <import plugin="org.jnode.shell.help"/> + </requires> + + <runtime> + <library name="jnode-shell.jar"> + <export name="org.jnode.shell.command.driver.system.bus.*"/> + </library> + </runtime> + + <extension point="org.jnode.shell.aliases"> + <alias name="smbus" class="org.jnode.shell.command.driver.system.bus.SMBusCommand"/> + </extension> + + <extension point="org.jnode.shell.syntaxes"> + <syntax alias="smbus" description="dump information from the system's SMBus controller"/> + </extension> +</plugin> \ No newline at end of file Modified: trunk/shell/descriptors/org.jnode.shell.command.system.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.system.xml 2008-05-04 05:21:52 UTC (rev 4051) +++ trunk/shell/descriptors/org.jnode.shell.command.system.xml 2008-05-04 06:19:17 UTC (rev 4052) @@ -25,7 +25,7 @@ </extension> <extension point="org.jnode.shell.syntaxes"> - <syntax alias="cpuid"/> + <syntax alias="cpuid" description="dump the system's CPU ID information"/> </extension> </plugin> Deleted: trunk/shell/src/shell/org/jnode/shell/command/driver/system/acpi/SMBusCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/driver/system/acpi/SMBusCommand.java 2008-05-04 05:21:52 UTC (rev 4051) +++ trunk/shell/src/shell/org/jnode/shell/command/driver/system/acpi/SMBusCommand.java 2008-05-04 06:19:17 UTC (rev 4052) @@ -1,79 +0,0 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library 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 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.shell.command.driver.system.acpi; - -/** - * <p>Title: </p> - * <p>Description: </p> - * <p>Licence: GNU LGPL</p> - * <p> </p> - * @author Francois-Frederic Ozog - * @version 1.0 - */ - - -import java.io.IOException; - -import javax.naming.NameNotFoundException; - -import org.jnode.driver.bus.smbus.SMBusControler; -import org.jnode.naming.InitialNaming; -import org.jnode.shell.help.Help; - -public class SMBusCommand { - - - public static Help.Info HELP_INFO = - new Help.Info( - "smbus", - "test smbus" - ); - - public static void main(String[] args) throws Exception { - //ParsedArguments cmdLine = HELP_INFO.parse(args); - SMBusControler smbusctrl=null; - - try { - smbusctrl = InitialNaming.lookup(SMBusControler.NAME); - } - catch (NameNotFoundException ex2) { - System.out.println("Could not connect to SMBusControler:" + ex2.getMessage()); - return; - } - - byte res=0; - for (byte i=0;i<8; i++) { - - try { - res = smbusctrl.readByte( (byte) (0xa0 |( i<<1)), (byte) 2); - System.out.println("DIMM " + i + " type :" + Integer.toHexString(res)); - } - catch (IOException ex) { - System.out.println("DIMM " + i + " not present"); - } - - - } - } - -} - Added: trunk/shell/src/shell/org/jnode/shell/command/driver/system/bus/SMBusCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/driver/system/bus/SMBusCommand.java (rev 0) +++ trunk/shell/src/shell/org/jnode/shell/command/driver/system/bus/SMBusCommand.java 2008-05-04 06:19:17 UTC (rev 4052) @@ -0,0 +1,73 @@ +/* + * $Id: SMBusCommand.java 2224 2006-01-01 12:49:03Z epr $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library 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 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.shell.command.driver.system.bus; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; + +import javax.naming.NameNotFoundException; + +import org.jnode.driver.bus.smbus.SMBusControler; +import org.jnode.naming.InitialNaming; +import org.jnode.shell.AbstractCommand; +import org.jnode.shell.CommandLine; + +/** + * @author Francois-Frederic Ozog + */ +public class SMBusCommand extends AbstractCommand { + + public SMBusCommand() { + super("Dump information about the SMBus"); + } + + public static void main(String[] args) throws Exception { + new SMBusCommand().execute(args); + } + + @Override + public void execute(CommandLine commandLine, InputStream in, + PrintStream out, PrintStream err) { + SMBusControler smbusctrl = null; + + try { + smbusctrl = InitialNaming.lookup(SMBusControler.NAME); + } + catch (NameNotFoundException ex) { + out.println("Could not find the SMBusControler: " + ex.getMessage()); + exit(1); + } + + for (byte i = 0; i < 8; i++) { + try { + // TODO - can someone explain why we are shifting and ORing? It looks like a bug to me. + byte res = smbusctrl.readByte((byte) (0xa0 | (i << 1)), (byte) 2); + out.println("DIMM " + i + " : type = " + Integer.toHexString(res)); + } + catch (IOException ex) { + out.println("DIMM " + i + " : not present"); + } + } + } +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2008-05-06 11:33:22
|
Revision: 4065 http://jnode.svn.sourceforge.net/jnode/?rev=4065&view=rev Author: crawley Date: 2008-05-06 04:33:20 -0700 (Tue, 06 May 2008) Log Message: ----------- Removed the hacky 'main' method from the Vm class and turned it into a normal command class. Modified Paths: -------------- trunk/core/src/core/org/jnode/vm/Vm.java trunk/shell/descriptors/org.jnode.shell.command.system.xml Added Paths: ----------- trunk/shell/src/shell/org/jnode/shell/command/system/VmInfoCommand.java Modified: trunk/core/src/core/org/jnode/vm/Vm.java =================================================================== --- trunk/core/src/core/org/jnode/vm/Vm.java 2008-05-06 10:48:39 UTC (rev 4064) +++ trunk/core/src/core/org/jnode/vm/Vm.java 2008-05-06 11:33:20 UTC (rev 4065) @@ -242,33 +242,34 @@ public final int availableProcessors() { return processors.size(); } + + // The following code has been moved to org.jnode.shell.command.system.VmInfoCommand +// /** +// * Show VM info. +// * +// * @param args +// */ +// public static void main(String[] args) { +// final Vm vm = getVm(); +// if ((vm != null) && !vm.isBootstrap()) { +// final PrintStream out = System.out; +// out.println("JNode VM " + vm.getVersion()); +// vm.dumpStatistics(out); +// vm.getSharedStatics().dumpStatistics(out); +// vm.heapManager.dumpStatistics(out); +// final SecurityManager sm = System.getSecurityManager(); +// out.println("Security manager: " + sm); +// for (VmProcessor cpu : vm.processors) { +// out.println("Processor " + vm.processors.indexOf(cpu) + " (" + cpu.getIdString() + ")"); +// cpu.dumpStatistics(out); +// } +// if ((args.length > 0) && args[0].equals("reset")) { +// vm.resetCounters(); +// } +// } +// } /** - * Show VM info. - * - * @param args - */ - public static void main(String[] args) { - final Vm vm = getVm(); - if ((vm != null) && !vm.isBootstrap()) { - final PrintStream out = System.out; - out.println("JNode VM " + vm.getVersion()); - vm.dumpStatistics(out); - vm.getSharedStatics().dumpStatistics(out); - vm.heapManager.dumpStatistics(out); - final SecurityManager sm = System.getSecurityManager(); - out.println("Security manager: " + sm); - for (VmProcessor cpu : vm.processors) { - out.println("Processor " + vm.processors.indexOf(cpu) + " (" + cpu.getIdString() + ")"); - cpu.dumpStatistics(out); - } - if ((args.length > 0) && args[0].equals("reset")) { - vm.resetCounters(); - } - } - } - - /** * Does this VM run in debug mode. * * @return Returns the debugMode. @@ -395,7 +396,7 @@ } } - protected final void resetCounters() { + public final void resetCounters() { if (statistics != null) { final Statistic[] stats = getStatistics(); for (int i = 0; i < stats.length; i++) { @@ -502,4 +503,11 @@ this.scheduler = scheduler; } } + + /** + * @return a copy of the processors list + */ + public final List<VmProcessor> getProcessors() { + return new BootableArrayList<VmProcessor>(processors); + } } Modified: trunk/shell/descriptors/org.jnode.shell.command.system.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.system.xml 2008-05-06 10:48:39 UTC (rev 4064) +++ trunk/shell/descriptors/org.jnode.shell.command.system.xml 2008-05-06 11:33:20 UTC (rev 4065) @@ -21,7 +21,7 @@ <alias name="cpuid" class="org.jnode.shell.command.system.CpuIDCommand"/> <alias name="kdb" class="org.jnode.shell.command.system.KdbCommand"/> <alias name="lsirq" class="org.jnode.shell.command.system.LsIRQCommand"/> - <alias name="vminfo" class="org.jnode.vm.Vm"/> + <alias name="vminfo" class="org.jnode.shell.command.system.VmInfoCommand"/> </extension> <extension point="org.jnode.shell.syntaxes"> @@ -31,7 +31,11 @@ <option argLabel="off" longName="off" description="Turn kernel debugging off"/> <option argLabel="on" longName="on" description="Turn kernel debugging on"/> </syntax> - <syntax alias="lsirq" description="dump IRQ handler information"/> + <syntax alias="vminfo"> + <optional description="dump IRQ handler information"> + <option argLabel="reset" longName="reset"/> + </optional> + </syntax> </extension> </plugin> Added: trunk/shell/src/shell/org/jnode/shell/command/system/VmInfoCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/system/VmInfoCommand.java (rev 0) +++ trunk/shell/src/shell/org/jnode/shell/command/system/VmInfoCommand.java 2008-05-06 11:33:20 UTC (rev 4065) @@ -0,0 +1,74 @@ +/* + * $Id: LsIRQ.java 2491 2006-04-23 11:31:22Z epr $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library 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 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.shell.command.system; + +import java.io.InputStream; +import java.io.PrintStream; +import java.util.List; + +import org.jnode.shell.AbstractCommand; +import org.jnode.shell.CommandLine; +import org.jnode.shell.syntax.Argument; +import org.jnode.shell.syntax.FlagArgument; +import org.jnode.vm.Vm; +import org.jnode.vm.scheduler.VmProcessor; + +/** + * @author Ewout Prangsma (ep...@us...) + * @author cr...@jn... + */ +public class VmInfoCommand extends AbstractCommand { + + private final FlagArgument FLAG_RESET = + new FlagArgument("reset", Argument.OPTIONAL, "if set, reset the JNode VM counters"); + + public VmInfoCommand() { + super("prints JNode VM info"); + registerArguments(FLAG_RESET); + } + + public static void main(String[] args) throws Exception { + new VmInfoCommand().execute(args); + } + + @Override + public void execute(CommandLine commandLine, InputStream in, + PrintStream out, PrintStream err) { + final Vm vm = Vm.getVm(); + if (vm != null && !vm.isBootstrap()) { + out.println("JNode VM " + vm.getVersion()); + vm.dumpStatistics(out); + vm.getSharedStatics().dumpStatistics(out); + Vm.getHeapManager().dumpStatistics(out); + final SecurityManager sm = System.getSecurityManager(); + out.println("Security manager: " + sm); + List<VmProcessor> processors = vm.getProcessors(); + for (VmProcessor cpu : processors) { + out.println("Processor " + processors.indexOf(cpu) + " (" + cpu.getIdString() + ")"); + cpu.dumpStatistics(out); + } + if (FLAG_RESET.isSet()) { + vm.resetCounters(); + } + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2008-05-06 14:01:12
|
Revision: 4067 http://jnode.svn.sourceforge.net/jnode/?rev=4067&view=rev Author: crawley Date: 2008-05-06 07:01:01 -0700 (Tue, 06 May 2008) Log Message: ----------- Created a plugin for the shell JUnit tests Modified Paths: -------------- trunk/all/conf/tests-plugin-list.xml trunk/shell/build.xml Added Paths: ----------- trunk/shell/descriptors/org.jnode.test.shell.xml Modified: trunk/all/conf/tests-plugin-list.xml =================================================================== --- trunk/all/conf/tests-plugin-list.xml 2008-05-06 13:59:51 UTC (rev 4066) +++ trunk/all/conf/tests-plugin-list.xml 2008-05-06 14:01:01 UTC (rev 4067) @@ -21,6 +21,7 @@ <plugin id="org.jnode.test"/> <plugin id="org.jnode.test.fs"/> <plugin id="org.jnode.test.net"/> + <plugin id="org.jnode.test.shell"/> <plugin id="org.jnode.shell.command.test"/> <!-- JUnit extensions --> Modified: trunk/shell/build.xml =================================================================== --- trunk/shell/build.xml 2008-05-06 13:59:51 UTC (rev 4066) +++ trunk/shell/build.xml 2008-05-06 14:01:01 UTC (rev 4067) @@ -25,7 +25,8 @@ <!-- Compile all subproject java files --> <target name="compile" depends="prepare"> <jnode.compile> - <src path="${my-src.dir}/shell"/> + <src path="${my-src.dir}/shell"/> + <src path="${my-src.dir}/test"/> <classpath refid="my-cp"/> </jnode.compile> </target> Added: trunk/shell/descriptors/org.jnode.test.shell.xml =================================================================== --- trunk/shell/descriptors/org.jnode.test.shell.xml (rev 0) +++ trunk/shell/descriptors/org.jnode.test.shell.xml 2008-05-06 14:01:01 UTC (rev 4067) @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plugin SYSTEM "jnode.dtd"> + +<plugin id="org.jnode.test.shell" + name="JNode Shell Test classes" + version="@VERSION@" + license-name="lgpl" + provider-name="JNode.org"> + + <requires> + <import plugin="org.jnode.runtime.core"/> + <import plugin="org.jnode.shell"/> + <import plugin="org.jnode.shell.help"/> + <import plugin="org.jnode.shell.syntax"/> + <import plugin="org.junit" version="3.8"/> + <import plugin="org.jnode.shell.help"/> + <import plugin="org.jnode.testrunner"/> + </requires> + + <runtime> + <library name="jnode-shell.jar"> + <export name="org.jnode.test.shell.*"/> + <export name="org.jnode.test.shell.help.*"/> + <export name="org.jnode.test.shell.syntax.*"/> + </library> + </runtime> + + <extension point="org.jnode.testrunner.tests"> + <test class="org.jnode.test.shell.help.AllTests" category="shell"/> + <test class="org.jnode.test.shell.syntax.AllTests" category="shell"/> + </extension> +</plugin> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-05-24 16:03:13
|
Revision: 4124 http://jnode.svn.sourceforge.net/jnode/?rev=4124&view=rev Author: lsantha Date: 2008-05-24 09:03:05 -0700 (Sat, 24 May 2008) Log Message: ----------- BDF font rending improvements + getRGBPixel() & getRGBPixels() implementation. Modified Paths: -------------- trunk/JNode.ipr trunk/JNode.iws trunk/gui/src/awt/org/jnode/awt/font/bdf/BDFTextRenderer.java trunk/gui/src/awt/org/jnode/awt/font/spi/AbstractFontProvider.java trunk/gui/src/awt/org/jnode/awt/image/BufferedImageSurface.java trunk/gui/src/driver/org/jnode/driver/video/ati/mach64/Mach64Surface.java trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonSurface.java trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaCore.java trunk/gui/src/driver/org/jnode/driver/video/vesa/VESACore.java trunk/gui/src/driver/org/jnode/driver/video/vga/VGASurface.java trunk/gui/src/driver/org/jnode/driver/video/vmware/VMWareCore.java Added Paths: ----------- trunk/gui/src/test/org/jnode/test/gui/Graphics2DSurface.java Modified: trunk/JNode.ipr =================================================================== --- trunk/JNode.ipr 2008-05-24 13:36:45 UTC (rev 4123) +++ trunk/JNode.ipr 2008-05-24 16:03:05 UTC (rev 4124) @@ -312,9 +312,5 @@ <jarDirectory url="file://$PROJECT_DIR$/distr/lib" recursive="false" /> </library> </component> - <component name="uidesigner-configuration"> - <option name="INSTRUMENT_CLASSES" value="true" /> - <option name="COPY_FORMS_RUNTIME_TO_OUTPUT" value="true" /> - </component> </project> Modified: trunk/JNode.iws =================================================================== --- trunk/JNode.iws 2008-05-24 13:36:45 UTC (rev 4123) +++ trunk/JNode.iws 2008-05-24 16:03:05 UTC (rev 4124) @@ -30,18 +30,19 @@ </component> <component name="ChangeListManager"> <list default="true" name="Default" comment=""> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/core/core.iml" afterPath="$PROJECT_DIR$/core/core.iml" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/distr/distr.iml" afterPath="$PROJECT_DIR$/distr/distr.iml" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/all/all.iml" afterPath="$PROJECT_DIR$/all/all.iml" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/fs/fs.iml" afterPath="$PROJECT_DIR$/fs/fs.iml" /> + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/vga/VGASurface.java" afterPath="$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/vga/VGASurface.java" /> + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/JNode.ipr" afterPath="$PROJECT_DIR$/JNode.ipr" /> + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/gui/src/awt/org/jnode/awt/font/bdf/BDFTextRenderer.java" afterPath="$PROJECT_DIR$/gui/src/awt/org/jnode/awt/font/bdf/BDFTextRenderer.java" /> + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/jnode.properties.dist" afterPath="$PROJECT_DIR$/jnode.properties.dist" /> + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/vmware/VMWareCore.java" afterPath="$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/vmware/VMWareCore.java" /> + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/gui/src/awt/org/jnode/awt/font/spi/AbstractFontProvider.java" afterPath="$PROJECT_DIR$/gui/src/awt/org/jnode/awt/font/spi/AbstractFontProvider.java" /> + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/ati/mach64/Mach64Surface.java" afterPath="$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/ati/mach64/Mach64Surface.java" /> + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaCore.java" afterPath="$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaCore.java" /> + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonSurface.java" afterPath="$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonSurface.java" /> + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/vesa/VESACore.java" afterPath="$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/vesa/VESACore.java" /> + <change type="MODIFICATION" beforePath="$PROJECT_DIR$/gui/src/awt/org/jnode/awt/image/BufferedImageSurface.java" afterPath="$PROJECT_DIR$/gui/src/awt/org/jnode/awt/image/BufferedImageSurface.java" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/JNode.iws" afterPath="$PROJECT_DIR$/JNode.iws" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/net/net.iml" afterPath="$PROJECT_DIR$/net/net.iml" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/jnode.iml" afterPath="$PROJECT_DIR$/jnode.iml" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/JNode.ipr" afterPath="$PROJECT_DIR$/JNode.ipr" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/gui/gui.iml" afterPath="$PROJECT_DIR$/gui/gui.iml" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/textui/textui.iml" afterPath="$PROJECT_DIR$/textui/textui.iml" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/builder/builder.iml" afterPath="$PROJECT_DIR$/builder/builder.iml" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/shell/shell.iml" afterPath="$PROJECT_DIR$/shell/shell.iml" /> + <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/gui/src/test/org/jnode/test/gui/Graphics2DSurface.java" /> </list> <ignored path="JNode.iws" /> <ignored path=".idea/workspace.xml" /> @@ -52,12 +53,6 @@ <rightPanel /> <splitter proportion="0.5" /> </component> - <component name="CompilerWorkspaceConfiguration"> - <option name="COMPILE_IN_BACKGROUND" value="false" /> - <option name="AUTO_SHOW_ERRORS_IN_EDITOR" value="true" /> - <option name="CLOSE_MESSAGE_VIEW_IF_SUCCESS" value="true" /> - <option name="COMPILE_DEPENDENT_FILES" value="false" /> - </component> <component name="CreatePatchCommitExecutor"> <option name="PATCH_PATH" value="" /> <option name="REVERSE_PATCH" value="false" /> @@ -170,8 +165,8 @@ </component> <component name="FileEditorManager"> <leaf> - <file leaf-file-name="build.xml" pinned="false" current="true" current-in-tab="true"> - <entry file="file://$PROJECT_DIR$/all/build.xml"> + <file leaf-file-name="jnode.properties.dist" pinned="false" current="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/jnode.properties.dist"> <provider selected="true" editor-type-id="text-editor"> <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0"> <folding /> @@ -179,11 +174,92 @@ </provider> </entry> </file> + <file leaf-file-name="NVidiaCore.java" pinned="false" current="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaCore.java"> + <provider selected="true" editor-type-id="text-editor"> + <state line="745" column="0" selection-start="24132" selection-end="24132" vertical-scroll-proportion="0.4857143"> + <folding /> + </state> + </provider> + </entry> + </file> + <file leaf-file-name="RadeonSurface.java" pinned="false" current="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonSurface.java"> + <provider selected="true" editor-type-id="text-editor"> + <state line="125" column="0" selection-start="4138" selection-end="4138" vertical-scroll-proportion="0.49836066"> + <folding /> + </state> + </provider> + </entry> + </file> + <file leaf-file-name="VESACore.java" pinned="false" current="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/vesa/VESACore.java"> + <provider selected="true" editor-type-id="text-editor"> + <state line="647" column="0" selection-start="19318" selection-end="19318" vertical-scroll-proportion="0.54285717"> + <folding /> + </state> + </provider> + </entry> + </file> + <file leaf-file-name="VGASurface.java" pinned="false" current="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/vga/VGASurface.java"> + <provider selected="true" editor-type-id="text-editor"> + <state line="154" column="0" selection-start="4906" selection-end="4906" vertical-scroll-proportion="0.4857143"> + <folding /> + </state> + </provider> + </entry> + </file> + <file leaf-file-name="VMWareCore.java" pinned="false" current="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/vmware/VMWareCore.java"> + <provider selected="true" editor-type-id="text-editor"> + <state line="935" column="8" selection-start="26808" selection-end="26808" vertical-scroll-proportion="0.25714287"> + <folding /> + </state> + </provider> + </entry> + </file> + <file leaf-file-name="Mach64Surface.java" pinned="false" current="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/ati/mach64/Mach64Surface.java"> + <provider selected="true" editor-type-id="text-editor"> + <state line="24" column="0" selection-start="933" selection-end="933" vertical-scroll-proportion="-0.18852459"> + <folding /> + </state> + </provider> + </entry> + </file> + <file leaf-file-name="BDFTextRenderer.java" pinned="false" current="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/gui/src/awt/org/jnode/awt/font/bdf/BDFTextRenderer.java"> + <provider selected="true" editor-type-id="text-editor"> + <state line="135" column="54" selection-start="4802" selection-end="4802" vertical-scroll-proportion="1.1147541"> + <folding /> + </state> + </provider> + </entry> + </file> + <file leaf-file-name="Graphics2DSurface.java" pinned="false" current="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/gui/src/test/org/jnode/test/gui/Graphics2DSurface.java"> + <provider selected="true" editor-type-id="text-editor"> + <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0"> + <folding /> + </state> + </provider> + </entry> + </file> + <file leaf-file-name="BufferedImageSurface.java" pinned="false" current="true" current-in-tab="true"> + <entry file="file://$PROJECT_DIR$/gui/src/awt/org/jnode/awt/image/BufferedImageSurface.java"> + <provider selected="true" editor-type-id="text-editor"> + <state line="74" column="0" selection-start="2396" selection-end="2396" vertical-scroll-proportion="0.114285715"> + <folding /> + </state> + </provider> + </entry> + </file> </leaf> </component> <component name="FindManager"> <FindUsagesManager> - <setting name="OPEN_NEW_TAB" value="false" /> + <setting name="OPEN_NEW_TAB" value="true" /> </FindUsagesManager> </component> <component name="HierarchyBrowserManager"> @@ -207,70 +283,6 @@ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageViewProjectNode" /> </PATH_ELEMENT> </PATH> - <PATH> - <PATH_ELEMENT> - <option name="myItemId" value="JNode" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageViewProjectNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="core" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageViewModuleNode" /> - </PATH_ELEMENT> - </PATH> - <PATH> - <PATH_ELEMENT> - <option name="myItemId" value="JNode" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageViewProjectNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="core" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageViewModuleNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="org" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageElementNode" /> - </PATH_ELEMENT> - </PATH> - <PATH> - <PATH_ELEMENT> - <option name="myItemId" value="JNode" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageViewProjectNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="core" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageViewModuleNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="org" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageElementNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="jnode" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageElementNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="work" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageElementNode" /> - </PATH_ELEMENT> - </PATH> - <PATH> - <PATH_ELEMENT> - <option name="myItemId" value="JNode" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageViewProjectNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="core" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageViewModuleNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="org" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageElementNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="jnode" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageElementNode" /> - </PATH_ELEMENT> - </PATH> </subPane> </component> <component name="PerforceChangeBrowserSettings"> @@ -302,13 +314,37 @@ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> </PATH_ELEMENT> </PATH> + <PATH> + <PATH_ELEMENT> + <option name="myItemId" value="JNode" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> + </PATH_ELEMENT> + <PATH_ELEMENT> + <option name="myItemId" value="jnode" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" /> + </PATH_ELEMENT> + </PATH> + <PATH> + <PATH_ELEMENT> + <option name="myItemId" value="JNode" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> + </PATH_ELEMENT> + <PATH_ELEMENT> + <option name="myItemId" value="jnode" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" /> + </PATH_ELEMENT> + <PATH_ELEMENT> + <option name="myItemId" value="PsiDirectory:/mnt/sda6/devel/jnode3" /> + <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> + </PATH_ELEMENT> + </PATH> </subPane> </component> <component name="ProjectReloadState"> <option name="STATE" value="0" /> </component> <component name="ProjectView"> - <navigator currentView="ProjectPane" proportions="0.5" version="1" splitterProportion="0.5"> + <navigator currentView="ProjectPane" proportions="0.16666667" version="1" splitterProportion="0.5"> <flattenPackages /> <showMembers /> <showModules /> @@ -327,25 +363,21 @@ <property name="cvs_file_history_treeOrder5" value="5" /> <property name="cvs_file_history_treeOrder2" value="2" /> <property name="cvs_file_history_treeOrder1" value="1" /> + <property name="RunManagerConfig.showSettingsBeforeRunnig" value="false" /> <property name="cvs_file_history_treeOrder4" value="4" /> <property name="cvs_file_history_treeOrder3" value="3" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_treeWidth2" value="96" /> <property name="vcs_file_view_treeOrder2" value="2" /> <property name="MemberChooser.sorted" value="false" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_treeWidth1" value="102" /> <property name="vcs_file_view_treeOrder3" value="3" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_treeWidth0" value="102" /> <property name="vcs_file_view_treeOrder0" value="0" /> <property name="vcs_file_view_treeOrder1" value="1" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_treeWidth4" value="754" /> <property name="vcs_file_view_treeOrder4" value="4" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_treeWidth3" value="101" /> <property name="vcs_file_view_flatWidth5" value="50" /> <property name="cvs_file_history_flatWidth6" value="170" /> <property name="cvs_file_history_flatWidth4" value="170" /> <property name="cvs_file_history_flatWidth5" value="171" /> + <property name="vcs_file_view_flatOrder0" value="0" /> <property name="cvs_file_history_flatWidth2" value="171" /> - <property name="vcs_file_view_flatOrder0" value="0" /> <property name="cvs_file_history_treeOrder0" value="0" /> <property name="cvs_file_history_flatWidth3" value="171" /> <property name="vcs_file_view_flatWidth0" value="147" /> @@ -362,50 +394,152 @@ <property name="vcs_file_view_flatWidth4" value="51" /> <property name="GoToFile.includeJavaFiles" value="false" /> <property name="MemberChooser.copyJavadoc" value="false" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_flatWidth1" value="125" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_flatWidth0" value="98" /> <property name="vcs_file_view_treeWidth4" value="77" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_flatWidth3" value="31" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_flatWidth2" value="122" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_flatOrder1" value="1" /> <property name="vcs_file_view_treeWidth1" value="78" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_flatOrder0" value="0" /> <property name="vcs_file_view_treeWidth0" value="77" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_flatOrder3" value="3" /> <property name="vcs_file_view_treeWidth3" value="78" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_flatOrder2" value="2" /> <property name="vcs_file_view_treeWidth2" value="77" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_flatOrder4" value="4" /> - <property name="GoToClass.includeJavaFiles" value="false" /> <property name="GoToClass.toSaveIncludeLibraries" value="false" /> <property name="cvs_file_history_treeWidth0" value="171" /> <property name="cvs_file_history_treeWidth1" value="171" /> <property name="cvs_file_history_treeWidth2" value="171" /> <property name="cvs_file_history_treeWidth3" value="171" /> + <property name="MemberChooser.showClasses" value="true" /> <property name="cvs_file_history_treeWidth4" value="170" /> - <property name="MemberChooser.showClasses" value="true" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_flatWidth4" value="779" /> <property name="cvs_file_history_treeWidth5" value="171" /> <property name="cvs_file_history_treeWidth6" value="170" /> <property name="cvs_file_history_flatOrder4" value="4" /> <property name="cvs_file_history_flatOrder5" value="5" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_treeOrder3" value="3" /> <property name="cvs_file_history_flatOrder2" value="2" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_treeOrder4" value="4" /> <property name="cvs_file_history_flatOrder3" value="3" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_treeOrder1" value="1" /> <property name="cvs_file_history_flatOrder0" value="0" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_treeOrder2" value="2" /> <property name="cvs_file_history_flatOrder1" value="1" /> - <property name="FileHistory.org.jetbrains.idea.svn.history.SvnHistoryProvider_treeOrder0" value="0" /> <property name="cvs_file_history_flatOrder6" value="6" /> </component> - <component name="RecentsManager"> - <key name="CopyClassDialog.RECENTS_KEY"> - <recent name="org.jnode.apps.derby" /> - </key> + <component name="RestoreUpdateTree"> + <UpdateInfo date="5/24/08 11:52 AM" ActionInfo="_Update"> + <UpdatedFiles> + <FILE-GROUP> + <option name="myUpdateName" value="Updated from server" /> + <option name="myStatusName" value="Changed on server" /> + <option name="mySupportsDeletion" value="false" /> + <option name="myCanBeAbsent" value="false" /> + <option name="myId" value="CHANGED_ON_SERVER" /> + <FILE-GROUP> + <option name="myUpdateName" value="Updated" /> + <option name="myStatusName" value="Changed" /> + <option name="mySupportsDeletion" value="false" /> + <option name="myCanBeAbsent" value="false" /> + <option name="myId" value="UPDATED" /> + <PATH vcs="svn" revision="4121">$PROJECT_DIR$/fs/descriptors/org.jnode.fs.fat.command.xml</PATH> + <PATH vcs="svn" revision="4121">$PROJECT_DIR$/fs/descriptors/org.jnode.fs.jfat.command.xml</PATH> + <PATH vcs="svn" revision="4121">$PROJECT_DIR$/fs/descriptors/org.jnode.fs.ext2.command.xml</PATH> + <PATH vcs="svn" revision="4121">$PROJECT_DIR$/fs/descriptors/org.jnode.fs.command.xml</PATH> + <PATH vcs="svn" revision="4121">$PROJECT_DIR$/fs/src/fs/org/jnode/fs/ext2/command/FormatExt2Command.java</PATH> + <PATH vcs="svn" revision="4121">$PROJECT_DIR$/fs/src/fs/org/jnode/fs/jfat/command/FatFormatCommand.java</PATH> + <PATH vcs="svn" revision="4121">$PROJECT_DIR$/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java</PATH> + <PATH vcs="svn" revision="4121">$PROJECT_DIR$/fs/src/fs/org/jnode/fs/fat/command/FormatFatCommand.java</PATH> + <PATH vcs="svn" revision="4121">$PROJECT_DIR$/fs/src/fs/org/jnode/fs/command/DeleteCommand.java</PATH> + <PATH vcs="svn" revision="4121">$PROJECT_DIR$/fs/src/fs/org/jnode/fs/command/AbstractFormatCommand.java</PATH> + </FILE-GROUP> + <FILE-GROUP> + <option name="myUpdateName" value="Created" /> + <option name="myStatusName" value="Created" /> + <option name="mySupportsDeletion" value="false" /> + <option name="myCanBeAbsent" value="false" /> + <option name="myId" value="CREATED" /> + </FILE-GROUP> + <FILE-GROUP> + <option name="myUpdateName" value="Deleted" /> + <option name="myStatusName" value="Deleted" /> + <option name="mySupportsDeletion" value="false" /> + <option name="myCanBeAbsent" value="true" /> + <option name="myId" value="REMOVED_FROM_REPOSITORY" /> + </FILE-GROUP> + <FILE-GROUP> + <option name="myUpdateName" value="Restored" /> + <option name="myStatusName" value="Will be restored" /> + <option name="mySupportsDeletion" value="false" /> + <option name="myCanBeAbsent" value="false" /> + <option name="myId" value="RESTORED" /> + </FILE-GROUP> + </FILE-GROUP> + <FILE-GROUP> + <option name="myUpdateName" value="Modified" /> + <option name="myStatusName" value="Modified" /> + <option name="mySupportsDeletion" value="false" /> + <option name="myCanBeAbsent" value="false" /> + <option name="myId" value="MODIFIED" /> + </FILE-GROUP> + <FILE-GROUP> + <option name="myUpdateName" value="Skipped" /> + <option name="myStatusName" value="Skipped" /> + <option name="mySupportsDeletion" value="false" /> + <option name="myCanBeAbsent" value="false" /> + <option name="myId" value="SKIPPED" /> + </FILE-GROUP> + <FILE-GROUP> + <option name="myUpdateName" value="Merged with conflicts" /> + <option name="myStatusName" value="Will be merged with conflicts" /> + <option name="mySupportsDeletion" value="false" /> + <option name="myCanBeAbsent" value="false" /> + <option name="myId" value="MERGED_WITH_CONFLICTS" /> + </FILE-GROUP> + <FILE-GROUP> + <option name="myUpdateName" value="Merged" /> + <option name="myStatusName" value="Will be merged" /> + <option name="mySupportsDeletion" value="false" /> + <option name="myCanBeAbsent" value="false" /> + <option name="myId" value="MERGED" /> + </FILE-GROUP> + <FILE-GROUP> + <option name="myUpdateName" value="Not in repository" /> + <option name="myStatusName" value="Not in repository" /> + <option name="mySupportsDeletion" value="true" /> + <option name="myCanBeAbsent" value="false" /> + <option name="myId" value="UNKNOWN" /> + </FILE-GROUP> + <FILE-GROUP> + <option name="myUpdateName" value="Locally added" /> + <option name="myStatusName" value="Locally added" /> + <option name="mySupportsDeletion" value="false" /> + <option name="myCanBeAbsent" value="false" /> + <option name="myId" value="LOCALLY_ADDED" /> + </FILE-GROUP> + <FILE-GROUP> + <option name="myUpdateName" value="Locally removed" /> + <option name="myStatusName" value="Locally removed" /> + <option name="mySupportsDeletion" value="false" /> + <option name="myCanBeAbsent" value="false" /> + <option name="myId" value="LOCALLY_REMOVED" /> + </FILE-GROUP> + </UpdatedFiles> + </UpdateInfo> </component> - <component name="RunManager"> + <component name="RunManager" selected="Remote.Remote"> + <configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false"> + <option name="MAIN_CLASS_NAME" /> + <option name="VM_PARAMETERS" /> + <option name="PROGRAM_PARAMETERS" /> + <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" /> + <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> + <option name="ALTERNATIVE_JRE_PATH" /> + <option name="ENABLE_SWING_INSPECTOR" value="false" /> + <option name="ENV_VARIABLES" /> + <option name="PASS_PARENT_ENVS" value="true" /> + <module name="" /> + <envs /> + <method> + <option name="Make" value="true" /> + </method> + </configuration> + <configuration default="true" type="Remote" factoryName="Remote"> + <option name="USE_SOCKET_TRANSPORT" value="true" /> + <option name="SERVER_MODE" value="false" /> + <option name="SHMEM_ADDRESS" value="javadebug" /> + <option name="HOST" value="localhost" /> + <option name="PORT" value="5005" /> + </configuration> <configuration default="true" type="TestNG" factoryName="TestNG" enabled="false" merge="false"> <module name="" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> @@ -447,6 +581,33 @@ <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> <option name="ALTERNATIVE_JRE_PATH" /> </configuration> + <configuration default="true" type="GWT.ConfigurationType" factoryName="GWT Configuration"> + <module name="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="SHELL_PARAMETERS" value="" /> + <option name="RUN_PAGE" value="" /> + </configuration> + <configuration default="true" type="JBossConfiguration" factoryName="Remote"> + <option name="WORKING_DIRECTORY" /> + <option name="HOST" value="localhost" /> + <option name="PORT" value="8080" /> + <option name="LOCAL" value="false" /> + <option name="OPEN_IN_BROWSER" value="true" /> + <option name="OPEN_IN_BROWSER_URL" value="/" /> + <option name="COMMON_VM_ARGUMENTS" value="" /> + <option name="JNDI_PORT" value="1099" /> + <option name="USERNAME" value="" /> + <option name="PASSWORD" value="" /> + <predefined_log_file id="JBoss" enabled="true" /> + <RunnerSettings RunnerId="Debug"> + <option name="DEBUG_PORT" value="32786" /> + <option name="TRANSPORT" value="0" /> + <option name="LOCAL" value="false" /> + </RunnerSettings> + <RunnerSettings RunnerId="Run" /> + <ConfigurationWrapper RunnerId="Debug" /> + <ConfigurationWrapper RunnerId="Run" /> + </configuration> <configuration default="true" type="JUnit" factoryName="JUnit" enabled="false" merge="false"> <module name="" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> @@ -469,29 +630,281 @@ <option name="Make" value="true" /> </method> </configuration> - <configuration default="true" type="Remote" factoryName="Remote"> - <option name="USE_SOCKET_TRANSPORT" value="true" /> - <option name="SERVER_MODE" value="false" /> - <option name="SHMEM_ADDRESS" value="javadebug" /> + <configuration default="true" type="JBossConfiguration" factoryName="Local"> + <option name="WORKING_DIRECTORY" /> <option name="HOST" value="localhost" /> - <option name="PORT" value="5005" /> + <option name="PORT" value="8080" /> + <option name="LOCAL" value="true" /> + <option name="OPEN_IN_BROWSER" value="true" /> + <option name="OPEN_IN_BROWSER_URL" value="/" /> + <option name="COMMON_VM_ARGUMENTS" value="" /> + <option name="SERVER" value="" /> + <option name="USERNAME" value="" /> + <option name="PASSWORD" value="" /> + <predefined_log_file id="JBoss" enabled="true" /> + <RunnerSettings RunnerId="Debug"> + <option name="DEBUG_PORT" value="32785" /> + <option name="TRANSPORT" value="0" /> + <option name="LOCAL" value="true" /> + </RunnerSettings> + <RunnerSettings RunnerId="Run" /> + <ConfigurationWrapper VM_VAR="JAVA_OPTS" RunnerId="Debug"> + <option name="USE_ENV_VARIABLES" value="true" /> + <STARTUP> + <option name="USE_DEFAULT" value="true" /> + <option name="SCRIPT" value="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="PROGRAM_PARAMETERS" value="" /> + </STARTUP> + <SHUTDOWN> + <option name="USE_DEFAULT" value="true" /> + <option name="SCRIPT" value="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="PROGRAM_PARAMETERS" value="" /> + </SHUTDOWN> + </ConfigurationWrapper> + <ConfigurationWrapper VM_VAR="JAVA_OPTS" RunnerId="Run"> + <option name="USE_ENV_VARIABLES" value="true" /> + <STARTUP> + <option name="USE_DEFAULT" value="true" /> + <option name="SCRIPT" value="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="PROGRAM_PARAMETERS" value="" /> + </STARTUP> + <SHUTDOWN> + <option name="USE_DEFAULT" value="true" /> + <option name="SCRIPT" value="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="PROGRAM_PARAMETERS" value="" /> + </SHUTDOWN> + </ConfigurationWrapper> </configuration> - <configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false"> - <option name="MAIN_CLASS_NAME" /> - <option name="VM_PARAMETERS" /> - <option name="PROGRAM_PARAMETERS" /> - <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" /> - <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> - <option name="ALTERNATIVE_JRE_PATH" /> - <option name="ENABLE_SWING_INSPECTOR" value="false" /> - <option name="ENV_VARIABLES" /> - <option name="PASS_PARENT_ENVS" value="true" /> + <configuration default="true" type="GeronimoConfiguration" factoryName="Remote"> + <option name="WORKING_DIRECTORY" /> + <option name="HOST" value="localhost" /> + <option name="PORT" value="8080" /> + <option name="LOCAL" value="false" /> + <option name="OPEN_IN_BROWSER" value="true" /> + <option name="OPEN_IN_BROWSER_URL" value="/" /> + <option name="COMMON_VM_ARGUMENTS" value="" /> + <option name="JNDI_PORT" value="1099" /> + <option name="USERNAME" value="system" /> + <option name="PASSWORD" value="manager" /> + <predefined_log_file id="Geronimo" enabled="true" /> + <RunnerSettings RunnerId="Debug"> + <option name="DEBUG_PORT" value="32774" /> + <option name="TRANSPORT" value="0" /> + <option name="LOCAL" value="false" /> + </RunnerSettings> + <RunnerSettings RunnerId="Run" /> + <ConfigurationWrapper RunnerId="Debug" /> + <ConfigurationWrapper RunnerId="Run" /> + </configuration> + <configuration default="true" type="GlassfishConfiguration" factoryName="Remote"> + <option name="WORKING_DIRECTORY" /> + <option name="HOST" value="localhost" /> + <option name="PORT" value="8080" /> + <option name="LOCAL" value="false" /> + <option name="OPEN_IN_BROWSER" value="true" /> + <option name="OPEN_IN_BROWSER_URL" value="/" /> + <option name="COMMON_VM_ARGUMENTS" value="" /> + <option name="ADMIN_PORT" value="4848" /> + <option name="USERNAME" value="admin" /> + <option name="PASSWORD" value="adminadmin" /> + <predefined_log_file id="Glassfish" enabled="true" /> + <RunnerSettings RunnerId="Debug"> + <option name="DEBUG_PORT" value="32780" /> + <option name="TRANSPORT" value="0" /> + <option name="LOCAL" value="false" /> + </RunnerSettings> + <RunnerSettings RunnerId="Run" /> + <ConfigurationWrapper RunnerId="Debug" /> + <ConfigurationWrapper RunnerId="Run" /> + </configuration> + <configuration default="true" type="GeronimoConfiguration" factoryName="Local"> + <option name="WORKING_DIRECTORY" /> + <option name="HOST" value="localhost" /> + <option name="PORT" value="8080" /> + <option name="LOCAL" value="true" /> + <option name="OPEN_IN_BROWSER" value="true" /> + <option name="OPEN_IN_BROWSER_URL" value="/" /> + <option name="COMMON_VM_ARGUMENTS" value="" /> + <option name="USERNAME" value="system" /> + <option name="PASSWORD" value="manager" /> + <predefined_log_file id="Geronimo" enabled="true" /> + <RunnerSettings RunnerId="Debug"> + <option name="DEBUG_PORT" value="32773" /> + <option name="TRANSPORT" value="0" /> + <option name="LOCAL" value="true" /> + </RunnerSettings> + <RunnerSettings RunnerId="Run" /> + <ConfigurationWrapper VM_VAR="JAVA_OPTS" RunnerId="Debug"> + <option name="USE_ENV_VARIABLES" value="true" /> + <STARTUP> + <option name="USE_DEFAULT" value="true" /> + <option name="SCRIPT" value="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="PROGRAM_PARAMETERS" value="" /> + </STARTUP> + <SHUTDOWN> + <option name="USE_DEFAULT" value="true" /> + <option name="SCRIPT" value="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="PROGRAM_PARAMETERS" value="" /> + </SHUTDOWN> + </ConfigurationWrapper> + <ConfigurationWrapper VM_VAR="JAVA_OPTS" RunnerId="Run"> + <option name="USE_ENV_VARIABLES" value="true" /> + <STARTUP> + <option name="USE_DEFAULT" value="true" /> + <option name="SCRIPT" value="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="PROGRAM_PARAMETERS" value="" /> + </STARTUP> + <SHUTDOWN> + <option name="USE_DEFAULT" value="true" /> + <option name="SCRIPT" value="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="PROGRAM_PARAMETERS" value="" /> + </SHUTDOWN> + </ConfigurationWrapper> + </configuration> + <configuration default="true" type="#com.intellij.j2ee.web.jsr45.JSR45ConfigurationFactory" factoryName="Local"> + <option name="WORKING_DIRECTORY" /> + <option name="HOST" value="localhost" /> + <option name="PORT" value="80" /> + <option name="LOCAL" value="true" /> + <option name="OPEN_IN_BROWSER" value="true" /> + <option name="OPEN_IN_BROWSER_URL" value="/" /> + <option name="COMMON_VM_ARGUMENTS" value="" /> + <option name="JSP_PACKAGE" value="" /> + <option name="VM_OPTS" value="" /> + <option name="USE_WEBSPHERE51_LINEMAPPING_MODEL" value="false" /> + <option name="LOCAL_PORT" value="80" /> + <RunnerSettings RunnerId="Debug"> + <option name="DEBUG_PORT" value="32791" /> + <option name="TRANSPORT" value="0" /> + <option name="LOCAL" value="true" /> + </RunnerSettings> + <RunnerSettings RunnerId="Run" /> + <ConfigurationWrapper VM_VAR="" RunnerId="Debug"> + <option name="USE_ENV_VARIABLES" value="true" /> + <STARTUP> + <option name="USE_DEFAULT" value="true" /> + <option name="SCRIPT" value="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="PROGRAM_PARAMETERS" value="" /> + </STARTUP> + <SHUTDOWN> + <option name="USE_DEFAULT" value="true" /> + <option name="SCRIPT" value="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="PROGRAM_PARAMETERS" value="" /> + </SHUTDOWN> + </ConfigurationWrapper> + <ConfigurationWrapper VM_VAR="" RunnerId="Run"> + <option name="USE_ENV_VARIABLES" value="true" /> + <STARTUP> + <option name="USE_DEFAULT" value="true" /> + <option name="SCRIPT" value="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="PROGRAM_PARAMETERS" value="" /> + </STARTUP> + <SHUTDOWN> + <option name="USE_DEFAULT" value="true" /> + <option name="SCRIPT" value="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="PROGRAM_PARAMETERS" value="" /> + </SHUTDOWN> + </ConfigurationWrapper> + </configuration> + <configuration default="true" type="#com.intellij.j2ee.web.jsr45.JSR45ConfigurationFactory" factoryName="Remote"> + <option name="WORKING_DIRECTORY" /> + <option name="HOST" value="localhost" /> + <option name="PORT" value="80" /> + <option name="LOCAL" value="false" /> + <option name="OPEN_IN_BROWSER" value="true" /> + <option name="OPEN_IN_BROWSER_URL" value="/" /> + <option name="COMMON_VM_ARGUMENTS" value="" /> + <option name="JSP_PACKAGE" value="" /> + <option name="VM_OPTS" value="" /> + <option name="USE_WEBSPHERE51_LINEMAPPING_MODEL" value="false" /> + <option name="LOCAL_PORT" value="80" /> + <RunnerSettings RunnerId="Debug"> + <option name="DEBUG_PORT" value="32792" /> + <option name="TRANSPORT" value="0" /> + <option name="LOCAL" value="false" /> + </RunnerSettings> + <RunnerSettings RunnerId="Run" /> + <ConfigurationWrapper RunnerId="Debug" /> + <ConfigurationWrapper RunnerId="Run" /> + </configuration> + <configuration default="true" type="#com.intellij.j2meplugin.run.J2MEConfigurationType" factoryName="J2ME"> <module name="" /> - <envs /> - <method> - <option name="Make" value="true" /> - </method> + <USER_OPTIONS /> + <option name="TARGET_DEVICE_NAME" /> + <option name="COMMAND_LINE_PARAMETERS" /> + <option name="MAIN_CLASS_NAME" value="" /> + <option name="JAD_NAME" value="" /> + <option name="IS_CLASSES" value="false" /> + <option name="IS_OTA" value="false" /> + <option name="INSTALL" /> + <option name="REMOVE" /> + <option name="RUN" /> + <option name="TRANSIENT" /> + <option name="FORCE" /> + <option name="TO_START" /> + <option name="SELECTION" value="0" /> </configuration> + <configuration default="true" type="GlassfishConfiguration" factoryName="Local"> + <option name="WORKING_DIRECTORY" /> + <option name="HOST" value="localhost" /> + <option name="PORT" value="8080" /> + <option name="LOCAL" value="true" /> + <option name="OPEN_IN_BROWSER" value="true" /> + <option name="OPEN_IN_BROWSER_URL" value="/" /> + <option name="COMMON_VM_ARGUMENTS" value="" /> + <option name="DOMAIN" value="" /> + <option name="USERNAME" value="admin" /> + <option name="PASSWORD" value="adminadmin" /> + <predefined_log_file id="Glassfish" enabled="true" /> + <RunnerSettings RunnerId="Debug"> + <option name="DEBUG_PORT" value="32779" /> + <option name="TRANSPORT" value="0" /> + <option name="LOCAL" value="true" /> + </RunnerSettings> + <RunnerSettings RunnerId="Run" /> + <ConfigurationWrapper VM_VAR="JAVA_OPTS" RunnerId="Debug"> + <option name="USE_ENV_VARIABLES" value="true" /> + <STARTUP> + <option name="USE_DEFAULT" value="true" /> + <option name="SCRIPT" value="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="PROGRAM_PARAMETERS" value="" /> + </STARTUP> + <SHUTDOWN> + <option name="USE_DEFAULT" value="true" /> + <option name="SCRIPT" value="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="PROGRAM_PARAMETERS" value="" /> + </SHUTDOWN> + </ConfigurationWrapper> + <ConfigurationWrapper VM_VAR="JAVA_OPTS" RunnerId="Run"> + <option name="USE_ENV_VARIABLES" value="true" /> + <STARTUP> + <option name="USE_DEFAULT" value="true" /> + <option name="SCRIPT" value="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="PROGRAM_PARAMETERS" value="" /> + </STARTUP> + <SHUTDOWN> + <option name="USE_DEFAULT" value="true" /> + <option name="SCRIPT" value="" /> + <option name="VM_PARAMETERS" value="" /> + <option name="PROGRAM_PARAMETERS" value="" /> + </SHUTDOWN> + </ConfigurationWrapper> + </configuration> <configuration default="true" type="WebLogic Instance" factoryName="Local"> <option name="WORKING_DIRECTORY" /> <option name="HOST" value="localhost" /> @@ -508,7 +921,25 @@ <predefined_log_file id="WEBLOGIC_DOMAIN_LOG_FILE" enabled="true" /> <predefined_log_file id="WEBLOGIC_SERVER_LOG_FILE" enabled="true" /> </configuration> - <list size="0" /> + <configuration default="false" name="Remote" type="Remote" factoryName="Remote"> + <option name="USE_SOCKET_TRANSPORT" value="true" /> + <option name="SERVER_MODE" value="false" /> + <option name="SHMEM_ADDRESS" value="javadebug" /> + <option name="HOST" value="localhost" /> + <option name="PORT" value="5005" /> + <RunnerSettings RunnerId="Debug"> + <option name="DEBUG_PORT" value="5005" /> + <option name="TRANSPORT" value="0" /> + <option name="LOCAL" value="false" /> + </RunnerSettings> + <ConfigurationWrapper RunnerId="Debug" /> + <method> + <option name="Make" value="true" /> + </method> + </configuration> + <list size="1"> + <item index="0" class="java.lang.String" itemvalue="Remote.Remote" /> + </list> </component> <component name="SQL"> <general /> @@ -572,42 +1003,41 @@ </todo-panel> </component> <component name="ToolWindowManager"> - <frame x="4" y="5" width="1260" height="989" extended-state="0" /> + <frame x="163" y="15" width="1631" height="1081" extended-state="0" /> <editor active="false" /> <layout> <window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" /> - <window_info id="Changes" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.31942788" order="8" /> - <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="10" /> - <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.21161826" order="1" /> - <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32894737" order="1" /> - <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" order="4" /> - <window_info id="IDEtalk Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="16" /> + <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.30115426" order="8" /> + <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" /> + <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.124681935" order="1" /> + <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.29171038" order="1" /> + <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.41972718" order="4" /> + <window_info id="IDEtalk Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" /> <window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" /> - <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32777116" order="9" /> - <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32777116" order="10" /> - <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="7" /> - <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.17676349" order="1" /> + <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.38419318" order="8" /> + <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32843652" order="8" /> + <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3297244" order="7" /> + <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.17748092" order="1" /> <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" order="0" /> - <window_info id="Maven projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="4" /> - <window_info id="Module Dependencies" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="9" /> - <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.19585063" order="0" /> - <window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="13" /> + <window_info id="Maven projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" /> + <window_info id="Module Dependencies" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" /> + <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.19274808" order="0" /> + <window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" /> <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="2" /> <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" order="6" /> - <window_info id="Duplicates" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="15" /> + <window_info id="Duplicates" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="2" /> - <window_info id="IDE talk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="5" /> + <window_info id="IDE talk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" /> <window_info id="simpleUML" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32927817" order="3" /> - <window_info id="File View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="6" /> - <window_info id="Sequence" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="11" /> - <window_info id="CVS File View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32980457" order="7" /> + <window_info id="File View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" /> + <window_info id="Sequence" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" /> + <window_info id="CVS File View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32980457" order="3" /> <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="5" /> <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="0" /> - <window_info id="IntelliJad Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32894737" order="12" /> - <window_info id="Favorites" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" /> + <window_info id="Favorites" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" /> <window_info id="Web" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="2" /> <window_info id="EJB" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="3" /> - <window_info id="CVS" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3291536" order="14" /> + <window_info id="CVS" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3291536" order="8" /> </layout> </component> <component name="VCS.FileViewConfiguration"> @@ -625,7 +1055,7 @@ <option name="PERFORM_EDIT_IN_BACKGROUND" value="true" /> <option name="PERFORM_ADD_REMOVE_IN_BACKGROUND" value="true" /> <option name="FORCE_NON_EMPTY_COMMENT" value="false" /> - <option name="LAST_COMMIT_MESSAGE" value="increased heap" /> + <option name="LAST_COMMIT_MESSAGE" value="Fixed build issue where bogus directories were created." /> <option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false" /> <option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="false" /> <option name="REFORMAT_BEFORE_FILE_COMMIT" value="false" /> @@ -636,21 +1066,10 @@ <option name="UPDATE_GROUP_BY_CHANGELIST" value="false" /> <option name="SHOW_FILE_HISTORY_AS_TREE" value="false" /> <option name="FILE_HISTORY_SPLITTER_PROPORTION" value="0.6" /> - <MESSAGE value="test" /> - <MESSAGE value="Brushed up the javadoc" /> - <MESSAGE value="Brushed up the javadoc generation" /> - <MESSAGE value="started add of apache.db.Derby" /> - <MESSAGE value="Fixed rerun of assemble-plugins due to Derby under build without any need. Overlapping packages in the two jar file coursed this." /> - <MESSAGE value="Pleasing Eclipse users" /> - <MESSAGE value="fixed division bug" /> - <MESSAGE value="a little step on the way to have derby running" /> - <MESSAGE value="org.apache.derby.impl.store.raw.data.BaseDataFileFactory line 2053 has a throw has been replaced with a system out untill jnode locks mecanisme has been checked" /> - <MESSAGE value="shifting the order of org.jnode.fs and org.jnode.fs.service as org.jnode.fs requires org.jnode.fs.service" /> - <MESSAGE value="added needed permissions" /> - <MESSAGE value="avoiding array out of bound exception" /> - <MESSAGE value="As jnode still don't have lock mechanisme and in the fact it's rare used we" /> - <MESSAGE value="As jnode still don't have lock mechanisme and in the fact it's rare used there should be little problems returning true. Note a lock should prevent other programs to achive write acccess to a given file." /> - <MESSAGE value="increased heap" /> + <MESSAGE value="Fixed exceptions thrown by the javadoc-mmtk target." /> + <MESSAGE value="Removed unneeded files." /> + <MESSAGE value="Javadoc fixes." /> + <MESSAGE value="Fixed build issue where bogus directories were created." /> </component> <component name="VssConfiguration"> <option name="CLIENT_PATH" value="" /> @@ -699,114 +1118,114 @@ </buildFile> </component> <component name="editorHistoryManager"> - <entry file="file://$PROJECT_DIR$/build.sh"> + <entry file="file://$PROJECT_DIR$/gui/src/driver/org/jnode/driver/video/util/AbstractSurface.java"> <provider selected="true" editor-type-id="text-editor"> - <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0"> + <state line="38" column="0" selection-start="1245" selection-end="1245" vertical-scroll-proportion="0.33512545"> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/build.bat"> + <entry file="file://$PROJECT_DIR$/gui/src/awt/org/jnode/awt/font/DefaultTextPipe.java"> <provider selected="true" editor-type-id="text-editor"> - <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0"> + <state line="99" column="27" selection-start="4395" selection-end="4395" vertical-scroll-proportion="1.852649"> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/all/conf/x86/menu-cdrom.lst"> + <entry file="file://$PROJECT_DIR$/core/src/openjdk/java/java/awt/geom/Point2D.java"> <provider selected="true" editor-type-id="text-editor"> - <state line="11" column="22" selection-start="218" selection-end="218" vertical-scroll-proportion="0.021518987"> + <state line="274" column="11" selection-start="7160" selection-end="7160" vertical-scroll-proportion="0.38917977"> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/core/src/core/org/jnode/vm/MemoryBlockManager.java"> + <entry file="file://$PROJECT_DIR$/gui/src/test/org/jnode/test/gui/Tetris.java"> <provider selected="true" editor-type-id="text-editor"> - <state line="96" column="55" selection-start="3084" selection-end="3084" vertical-scroll-proportion="0.021518987"> + <state line="43" column="69" selection-start="1558" selection-end="1558" vertical-scroll-proportion="0.38568935"> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/core/src/core/org/jnode/vm/memmgr/def/DefaultHeapManager.java"> + <entry file="file://$PROJECT_DIR$/gui/src/awt/org/jnode/awt/font/spi/AbstractFontProvider.java"> <provider selected="true" editor-type-id="text-editor"> - <state line="303" column="19" selection-start="9036" selection-end="9036" vertical-scroll-proportion="0.021518987"> + <state line="198" column="0" selection-start="5926" selection-end="5926" vertical-scroll-proportion="0.33333334"> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/fs/src/fs/org/jnode/fs/service/def/FileSystemPlugin.java"> + <entry file="file://$PROJECT_DIR$/JNode.ipr"> <provider selected="true" editor-type-id="text-editor"> - <state line="193" column="41" selection-start="5759" selection-end="5759" vertical-scroll-proportion="0.12623274"> + <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0"> ... [truncated message content] |
From: <ls...@us...> - 2008-05-29 16:35:05
|
Revision: 4141 http://jnode.svn.sourceforge.net/jnode/?rev=4141&view=rev Author: lsantha Date: 2008-05-29 09:35:01 -0700 (Thu, 29 May 2008) Log Message: ----------- Added checkstyle. Modified Paths: -------------- trunk/all/build.xml Added Paths: ----------- trunk/all/jnode_checks.xml trunk/core/lib/checkstyle-all-4.4.jar Modified: trunk/all/build.xml =================================================================== --- trunk/all/build.xml 2008-05-29 13:47:51 UTC (rev 4140) +++ trunk/all/build.xml 2008-05-29 16:35:01 UTC (rev 4141) @@ -869,7 +869,16 @@ </target> - <!-- Create a patch --> + <target name="checkstyle" description="Generates a report of code convention violations."> + <taskdef resource="checkstyletask.properties" classpath="../core/lib/checkstyle-all-4.4.jar"/> + <checkstyle config="jnode_checks.xml"> + <fileset dir="../gui/src/test" includes="**/*.java"/> + <fileset dir="../gui/src/desktop" includes="**/*.java"/> + <fileset dir="../gui/src/awt" includes="**/*.java"/> + </checkstyle> + </target> + + <!-- Create a patch --> <!-- TODO create replacement SVN task <target name="create-patch"> <property name="patch.file" value="${root.dir}/patch.txt"/> Added: trunk/all/jnode_checks.xml =================================================================== --- trunk/all/jnode_checks.xml (rev 0) +++ trunk/all/jnode_checks.xml 2008-05-29 16:35:01 UTC (rev 4141) @@ -0,0 +1,202 @@ +<?xml version="1.0"?> +<!DOCTYPE module PUBLIC + "-//Puppy Crawl//DTD Check Configuration 1.2//EN" + "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> + +<!-- + + Checkstyle configuration that checks the sun coding conventions from: + + - the Java Language Specification at + http://java.sun.com/docs/books/jls/second_edition/html/index.html + + - the Sun Code Conventions at http://java.sun.com/docs/codeconv/ + + - the Javadoc guidelines at + http://java.sun.com/j2se/javadoc/writingdoccomments/index.html + + - the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html + + - some best practices + + Checkstyle is very configurable. Be sure to read the documentation at + http://checkstyle.sf.net (or in your downloaded distribution). + + Most Checks are configurable, be sure to consult the documentation. + + To completely disable a check, just comment it out or delete it from the file. + + Finally, it is worth reading the documentation. + +--> + +<module name="Checker"> + + <!-- Checks that a package.html file exists for each package. --> + <!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml --> +<!-- <module name="PackageHtml"/> --> + + <!-- Checks whether files end with a new line. --> + <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile --> + <module name="NewlineAtEndOfFile"/> + + <!-- Checks that property files contain the same keys. --> + <!-- See http://checkstyle.sf.net/config_misc.html#Translation --> +<!-- <module name="Translation"/> --> + + + <module name="TreeWalker"> + + <!-- Checks for Javadoc comments. --> + <!-- See http://checkstyle.sf.net/config_javadoc.html --> +<!-- <module name="JavadocMethod"/> + <module name="JavadocType"/> + <module name="JavadocVariable"/> + <module name="JavadocStyle"/> --> + + + <!-- Checks for Naming Conventions. --> + <!-- See http://checkstyle.sf.net/config_naming.html --> +<!-- <module name="ConstantName"/> + <module name="LocalFinalVariableName"/> + <module name="LocalVariableName"/> + <module name="MemberName"/> + <module name="MethodName"/> + <module name="PackageName"/> + <module name="ParameterName"/> + <module name="StaticVariableName"/> + <module name="TypeName"/> --> + + + <!-- Checks for Headers --> + <!-- See http://checkstyle.sf.net/config_header.html --> + <!-- <module name="Header"> --> + <!-- The follow property value demonstrates the ability --> + <!-- to have access to ANT properties. In this case it uses --> + <!-- the ${basedir} property to allow Checkstyle to be run --> + <!-- from any directory within a project. See property --> + <!-- expansion, --> + <!-- http://checkstyle.sf.net/config.html#properties --> + <!-- <property --> + <!-- name="headerFile" --> + <!-- value="${basedir}/java.header"/> --> + <!-- </module> --> + + <!-- Following interprets the header file as regular expressions. --> + <!-- <module name="RegexpHeader"/> --> + + + <!-- Checks for imports --> + <!-- See http://checkstyle.sf.net/config_import.html --> + <module name="AvoidStarImport"/> +<!-- <module name="IllegalImport"/> --><!-- defaults to sun.* packages --> + <module name="RedundantImport"/> + <module name="UnusedImports"/> + + + <!-- Checks for Size Violations. --> + <!-- See http://checkstyle.sf.net/config_sizes.html --> +<!-- <module name="FileLength"/> + <module name="LineLength"/> + <module name="MethodLength"/> + <module name="ParameterNumber"/> --> + <module name="LineLength"> + <property name="max" value="120"/> + </module> + + + <!-- Checks for whitespace --> + <!-- See http://checkstyle.sf.net/config_whitespace.html --> +<!-- <module name="EmptyForIteratorPad"/> + <module name="MethodParamPad"/> + <module name="NoWhitespaceAfter"/> + <module name="NoWhitespaceBefore"/> + <module name="OperatorWrap"/> + <module name="ParenPad"/> + <module name="TypecastParenPad"/> + <module name="WhitespaceAfter"/> + <module name="WhitespaceAround"/> + --> + <module name="MethodParamPad"/> + <module name="NoWhitespaceAfter"/> + <module name="NoWhitespaceBefore"/> + <module name="OperatorWrap"> + <property name="option" value="eol"/> + </module> + <module name="ParenPad"/> + <module name="TypecastParenPad"/> + <module name="WhitespaceAfter"/> + <module name="WhitespaceAround"> + <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, + BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, + EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, + LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, + LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, + LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, + PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, + STAR, STAR_ASSIGN"/> + <property name="allowEmptyConstructors" value="true"/> + <property name="allowEmptyMethods" value="true"/> + </module> + + <module name="Indentation"/> + <module name="TabCharacter"/> + + + + <!-- Modifier Checks --> + <!-- See http://checkstyle.sf.net/config_modifiers.html --> +<!-- <module name="ModifierOrder"/> + <module name="RedundantModifier"/> --> + + + <!-- Checks for blocks. You know, those {}'s --> + <!-- See http://checkstyle.sf.net/config_blocks.html --> + <module name="EmptyBlock"> + <property name="option" value="text" /> + </module> + <module name="LeftCurly"/> + <module name="RightCurly"/> + <!--module name="NeedBraces"/--> + <module name="AvoidNestedBlocks"> + <property name="allowInSwitchCase" value="true" /> + </module> + + <!-- Checks for common coding problems --> + <!-- See http://checkstyle.sf.net/config_coding.html --> +<!-- <module name="AvoidInlineConditionals"/> + <module name="DoubleCheckedLocking"/> + <module name="EmptyStatement"/> + <module name="EqualsHashCode"/> + <module name="HiddenField"/> + <module name="IllegalInstantiation"/> + <module name="InnerAssignment"/> + <module name="MagicNumber"/> + <module name="MissingSwitchDefault"/> + <module name="RedundantThrows"/> + <module name="SimplifyBooleanExpression"/> + <module name="SimplifyBooleanReturn"/> --> + + <!-- Checks for class design --> + <!-- See http://checkstyle.sf.net/config_design.html --> +<!-- <module name="DesignForExtension"/> + <module name="FinalClass"/> + <module name="HideUtilityClassConstructor"/> + <module name="InterfaceIsType"/> + <module name="VisibilityModifier"/> --> + + + <!-- Miscellaneous other checks. --> + <!-- See http://checkstyle.sf.net/config_misc.html --> +<!-- <module name="ArrayTypeStyle"/> + <module name="FinalParameters"/> + <module name="GenericIllegalRegexp"> + <property name="format" value="\s+$"/> + <property name="message" value="Line has trailing spaces."/> + </module> + <module name="TodoComment"/> + <module name="UpperEll"/> --> + + </module> + +</module> Added: trunk/core/lib/checkstyle-all-4.4.jar =================================================================== (Binary files differ) Property changes on: trunk/core/lib/checkstyle-all-4.4.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-05-31 12:45:11
|
Revision: 4167 http://jnode.svn.sourceforge.net/jnode/?rev=4167&view=rev Author: lsantha Date: 2008-05-31 05:45:06 -0700 (Sat, 31 May 2008) Log Message: ----------- Moved nanoxml to endrosed sources. Modified Paths: -------------- trunk/all/build.xml trunk/builder/src/builder/org/jnode/build/AbstractPluginTask.java trunk/builder/src/builder/org/jnode/build/PluginList.java trunk/builder/src/builder/org/jnode/build/PluginTask.java trunk/core/core.iml trunk/core/descriptors/nanoxml.xml trunk/core/src/test/org/jnode/test/NanoXmlTest.java trunk/net/src/net/org/jnode/net/ipv4/bootp/BOOTPServer.java Modified: trunk/all/build.xml =================================================================== --- trunk/all/build.xml 2008-05-31 12:43:00 UTC (rev 4166) +++ trunk/all/build.xml 2008-05-31 12:45:06 UTC (rev 4167) @@ -443,7 +443,7 @@ <pathelement location="${root.dir}/core/src/openjdk/org"/> <pathelement location="${root.dir}/core/src/openjdk/sun"/> <pathelement location="${root.dir}/core/src/openjdk/vm"/> - <pathelement location="${root.dir}/core/src/nanoxml"/> + <pathelement location="${root.dir}/core/src/endorsed/nanoxml"/> <pathelement location="${root.dir}/core/src/core"/> <pathelement location="${root.dir}/core/src/vmmagic"/> <pathelement location="${root.dir}/core/src/driver"/> @@ -468,7 +468,7 @@ <pathelement location="${root.dir}/core/src/classpath/vm"/> <pathelement location="${root.dir}/core/src/openjdk/sun"/> <pathelement location="${root.dir}/core/src/openjdk/vm"/> - <pathelement location="${root.dir}/core/src/nanoxml"/> + <pathelement location="${root.dir}/core/src/endorsed/nanoxml"/> </sourcepath> <package name="org.mmtk.*"/> <package name="org.jnode.vm.memmgr.mmtk.*"/> @@ -496,7 +496,7 @@ <pathelement location="${root.dir}/core/src/core"/> <pathelement location="${root.dir}/core/src/driver"/> <pathelement location="${root.dir}/core/src/mmtk-vm"/> - <pathelement location="${root.dir}/core/src/nanoxml"/> + <pathelement location="${root.dir}/core/src/endorsed/nanoxml"/> <pathelement location="${root.dir}/core/src/test"/> <pathelement location="${root.dir}/core/src/vmmagic"/> <pathelement location="${root.dir}/distr/src/install"/> Modified: trunk/builder/src/builder/org/jnode/build/AbstractPluginTask.java =================================================================== --- trunk/builder/src/builder/org/jnode/build/AbstractPluginTask.java 2008-05-31 12:43:00 UTC (rev 4166) +++ trunk/builder/src/builder/org/jnode/build/AbstractPluginTask.java 2008-05-31 12:45:06 UTC (rev 4167) @@ -27,8 +27,8 @@ import java.util.HashMap; import java.util.Hashtable; import java.util.LinkedList; -import nanoxml.XMLElement; -import nanoxml.XMLParseException; +import org.jnode.nanoxml.XMLElement; +import org.jnode.nanoxml.XMLParseException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.Jar; Modified: trunk/builder/src/builder/org/jnode/build/PluginList.java =================================================================== --- trunk/builder/src/builder/org/jnode/build/PluginList.java 2008-05-31 12:43:00 UTC (rev 4166) +++ trunk/builder/src/builder/org/jnode/build/PluginList.java 2008-05-31 12:45:06 UTC (rev 4167) @@ -33,7 +33,7 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.List; -import nanoxml.XMLElement; +import org.jnode.nanoxml.XMLElement; import org.apache.tools.ant.taskdefs.Manifest; import org.apache.tools.ant.taskdefs.ManifestException; import org.jnode.plugin.PluginException; Modified: trunk/builder/src/builder/org/jnode/build/PluginTask.java =================================================================== --- trunk/builder/src/builder/org/jnode/build/PluginTask.java 2008-05-31 12:43:00 UTC (rev 4166) +++ trunk/builder/src/builder/org/jnode/build/PluginTask.java 2008-05-31 12:45:06 UTC (rev 4167) @@ -32,8 +32,8 @@ import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import nanoxml.XMLElement; -import nanoxml.XMLParseException; +import org.jnode.nanoxml.XMLElement; +import org.jnode.nanoxml.XMLParseException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.taskdefs.Jar; Modified: trunk/core/core.iml =================================================================== --- trunk/core/core.iml 2008-05-31 12:43:00 UTC (rev 4166) +++ trunk/core/core.iml 2008-05-31 12:45:06 UTC (rev 4167) @@ -13,9 +13,9 @@ <sourceFolder url="file://$MODULE_DIR$/src/classpath/vm" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/core" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/driver" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/endorsed/nanoxml" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/icedtea" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/mmtk-vm" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/src/nanoxml" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/openjdk/com" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/openjdk/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/openjdk/javax" isTestSource="false" /> Modified: trunk/core/descriptors/nanoxml.xml =================================================================== --- trunk/core/descriptors/nanoxml.xml 2008-05-31 12:43:00 UTC (rev 4166) +++ trunk/core/descriptors/nanoxml.xml 2008-05-31 12:45:06 UTC (rev 4167) @@ -10,7 +10,7 @@ <runtime> <library name="jnode-core.jar"> - <export name="nanoxml.*"/> + <export name="org.jnode.nanoxml.*"/> </library> </runtime> Modified: trunk/core/src/test/org/jnode/test/NanoXmlTest.java =================================================================== --- trunk/core/src/test/org/jnode/test/NanoXmlTest.java 2008-05-31 12:43:00 UTC (rev 4166) +++ trunk/core/src/test/org/jnode/test/NanoXmlTest.java 2008-05-31 12:45:06 UTC (rev 4167) @@ -24,7 +24,7 @@ import java.io.FileReader; import java.io.IOException; import java.util.Hashtable; -import nanoxml.XMLElement; +import org.jnode.nanoxml.XMLElement; /** * @author Ewout Prangsma (ep...@us...) Modified: trunk/net/src/net/org/jnode/net/ipv4/bootp/BOOTPServer.java =================================================================== --- trunk/net/src/net/org/jnode/net/ipv4/bootp/BOOTPServer.java 2008-05-31 12:43:00 UTC (rev 4166) +++ trunk/net/src/net/org/jnode/net/ipv4/bootp/BOOTPServer.java 2008-05-31 12:45:06 UTC (rev 4167) @@ -33,7 +33,7 @@ import java.util.List; import java.util.Map; -import nanoxml.XMLElement; +import org.jnode.nanoxml.XMLElement; import org.apache.log4j.Logger; import org.jnode.net.ipv4.IPv4Address; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2008-06-01 15:50:15
|
Revision: 4173 http://jnode.svn.sourceforge.net/jnode/?rev=4173&view=rev Author: crawley Date: 2008-06-01 08:50:10 -0700 (Sun, 01 Jun 2008) Log Message: ----------- Converted FdiskCommand, tidied up and fixed some minor bugs. Renamed Decimal/BinaryPrefix to Decimal/BinaryScaleFactor and added a supertype. Modified Paths: -------------- trunk/core/src/core/org/jnode/util/NumberUtils.java trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/DeviceView.java trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/PartitionView.java trunk/fs/descriptors/org.jnode.partitions.command.xml trunk/fs/src/fs/org/jnode/fs/ext2/BlockSize.java trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemFormatter.java trunk/fs/src/fs/org/jnode/fs/jfat/ClusterSize.java trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java trunk/fs/src/fs/org/jnode/partitions/help/argument/IBMPartitionTypeArgument.java Added Paths: ----------- trunk/core/src/core/org/jnode/util/BinaryScaleFactor.java trunk/core/src/core/org/jnode/util/DecimalScaleFactor.java trunk/core/src/core/org/jnode/util/ScaleFactor.java trunk/shell/src/shell/org/jnode/shell/syntax/SizeArgument.java Removed Paths: ------------- trunk/core/src/core/org/jnode/util/BinaryPrefix.java trunk/core/src/core/org/jnode/util/DecimalPrefix.java Deleted: trunk/core/src/core/org/jnode/util/BinaryPrefix.java =================================================================== --- trunk/core/src/core/org/jnode/util/BinaryPrefix.java 2008-06-01 15:45:59 UTC (rev 4172) +++ trunk/core/src/core/org/jnode/util/BinaryPrefix.java 2008-06-01 15:50:10 UTC (rev 4173) @@ -1,67 +0,0 @@ -/* - * $Id$ - */ -package org.jnode.util; - -import org.jnode.vm.annotation.SharedStatics; - -@SharedStatics -public enum BinaryPrefix { - B(1l, ""), - K(1024l, "K"), - M(1024l * 1024l, "M"), - G(1024l * 1024l * 1024l, "G"), - T(1024l * 1024l * 1024l * 1024l, "T"), - P(1024l * 1024l * 1024l * 1024l * 1024l, "P"), - E(1024l * 1024l * 1024l * 1024l * 1024l * 1024l, "E"); - //these units have too big multipliers to fit in a long - // (aka they are greater than 2^64) : - //Z(1024l*1024l*1024l*1024l*1024l*1024l*1024l, "Z"), - //Y(1024l*1024l*1024l*1024l*1024l*1024l*1024l*1024l, "Y"); - - public static final BinaryPrefix MIN = B; - public static final BinaryPrefix MAX = E; - - final private long multiplier; - final private String unit; - - private BinaryPrefix(long multiplier, String unit) { - this.multiplier = multiplier; - this.unit = unit; - } - - public long getMultiplier() { - return multiplier; - } - - public String getUnit() { - return unit; - } - - public String toString() { - return multiplier + ", " + unit; - } - - /** - * Convert the given value to a size string like 64K - * - * @param value the size to convert - * @param nbDecimals number of significant figures to display after dot. use Integer.MAX_VALUE for all. - * @return the text for the size - */ - public static String apply(final long value, final int nbDecimals) { - long v = value; - BinaryPrefix unit = null; - for (BinaryPrefix u : values()) { - if ((v < 1024) && (v >= 0)) { - unit = u; - break; - } - - v = v >>> 10; - } - unit = (unit == null) ? MAX : unit; - float dv = ((float) value) / unit.getMultiplier(); - return NumberUtils.toString(dv, nbDecimals) + " " + unit.getUnit(); - } -} Added: trunk/core/src/core/org/jnode/util/BinaryScaleFactor.java =================================================================== --- trunk/core/src/core/org/jnode/util/BinaryScaleFactor.java (rev 0) +++ trunk/core/src/core/org/jnode/util/BinaryScaleFactor.java 2008-06-01 15:50:10 UTC (rev 4173) @@ -0,0 +1,67 @@ +/* + * $Id$ + */ +package org.jnode.util; + +import org.jnode.vm.annotation.SharedStatics; + +@SharedStatics +public enum BinaryScaleFactor implements ScaleFactor { + B(1l, ""), + K(1024l, "K"), + M(1024l * 1024l, "M"), + G(1024l * 1024l * 1024l, "G"), + T(1024l * 1024l * 1024l * 1024l, "T"), + P(1024l * 1024l * 1024l * 1024l * 1024l, "P"), + E(1024l * 1024l * 1024l * 1024l * 1024l * 1024l, "E"); + //these units have too big multipliers to fit in a long + // (aka they are greater than 2^64) : + //Z(1024l*1024l*1024l*1024l*1024l*1024l*1024l, "Z"), + //Y(1024l*1024l*1024l*1024l*1024l*1024l*1024l*1024l, "Y"); + + public static final BinaryScaleFactor MIN = B; + public static final BinaryScaleFactor MAX = E; + + final private long multiplier; + final private String unit; + + private BinaryScaleFactor(long multiplier, String unit) { + this.multiplier = multiplier; + this.unit = unit; + } + + public long getMultiplier() { + return multiplier; + } + + public String getUnit() { + return unit; + } + + public String toString() { + return multiplier + ", " + unit; + } + + /** + * Convert the given value to a size string like 64K + * + * @param value the size to convert + * @param nbDecimals number of significant figures to display after dot. use Integer.MAX_VALUE for all. + * @return the text for the size + */ + public static String apply(final long value, final int nbDecimals) { + long v = value; + BinaryScaleFactor unit = null; + for (BinaryScaleFactor u : values()) { + if ((v < 1024) && (v >= 0)) { + unit = u; + break; + } + + v = v >>> 10; + } + unit = (unit == null) ? MAX : unit; + float dv = ((float) value) / unit.getMultiplier(); + return NumberUtils.toString(dv, nbDecimals) + " " + unit.getUnit(); + } +} Deleted: trunk/core/src/core/org/jnode/util/DecimalPrefix.java =================================================================== --- trunk/core/src/core/org/jnode/util/DecimalPrefix.java 2008-06-01 15:45:59 UTC (rev 4172) +++ trunk/core/src/core/org/jnode/util/DecimalPrefix.java 2008-06-01 15:50:10 UTC (rev 4173) @@ -1,67 +0,0 @@ -/* - * $Id$ - */ -package org.jnode.util; - -import org.jnode.vm.annotation.SharedStatics; - -@SharedStatics -public enum DecimalPrefix { - B(1l, ""), - K(1000l, "k"), - M(1000l * 1000l, "M"), - G(1000l * 1000l * 1000l, "G"), - T(1000l * 1000l * 1000l * 1000l, "T"), - P(1000l * 1000l * 1000l * 1000l * 1000l, "P"), - E(1000l * 1000l * 1000l * 1000l * 1000l * 1000l, "E"); - //these units have too big multipliers to fit in a long - // (aka they are greater than 2^64) : - //Z(1000l*1000l*1000l*1000l*1000l*1000l*1000l, "Z"), - //Y(1000l*1000l*1000l*1000l*1000l*1000l*1000l*1000l, "Y"); - - public static final DecimalPrefix MIN = B; - public static final DecimalPrefix MAX = E; - - final private long multiplier; - final private String unit; - - private DecimalPrefix(long multiplier, String unit) { - this.multiplier = multiplier; - this.unit = unit; - } - - public long getMultiplier() { - return multiplier; - } - - public String getUnit() { - return unit; - } - - public String toString() { - return multiplier + ", " + unit; - } - - /** - * Convert the given value to a size string like 64K - * - * @param v the size to convert - * @param nbDecimals number of significant figures to display after dot. use Integer.MAX_VALUE for all. - * @return the text for the size - */ - public static String apply(final long value, final int nbDecimals) { - long v = value; - DecimalPrefix unit = null; - for (DecimalPrefix u : values()) { - if ((v < 1000l) && (v >= 0l)) { - unit = u; - break; - } - - v = v / 1000l; - } - unit = (unit == null) ? MAX : unit; - float dv = ((float) value) / unit.getMultiplier(); - return NumberUtils.toString(dv, nbDecimals) + " " + unit.getUnit(); - } -} Added: trunk/core/src/core/org/jnode/util/DecimalScaleFactor.java =================================================================== --- trunk/core/src/core/org/jnode/util/DecimalScaleFactor.java (rev 0) +++ trunk/core/src/core/org/jnode/util/DecimalScaleFactor.java 2008-06-01 15:50:10 UTC (rev 4173) @@ -0,0 +1,67 @@ +/* + * $Id$ + */ +package org.jnode.util; + +import org.jnode.vm.annotation.SharedStatics; + +@SharedStatics +public enum DecimalScaleFactor implements ScaleFactor { + B(1l, ""), + K(1000l, "k"), + M(1000l * 1000l, "M"), + G(1000l * 1000l * 1000l, "G"), + T(1000l * 1000l * 1000l * 1000l, "T"), + P(1000l * 1000l * 1000l * 1000l * 1000l, "P"), + E(1000l * 1000l * 1000l * 1000l * 1000l * 1000l, "E"); + //these units have too big multipliers to fit in a long + // (aka they are greater than 2^64) : + //Z(1000l*1000l*1000l*1000l*1000l*1000l*1000l, "Z"), + //Y(1000l*1000l*1000l*1000l*1000l*1000l*1000l*1000l, "Y"); + + public static final DecimalScaleFactor MIN = B; + public static final DecimalScaleFactor MAX = E; + + final private long multiplier; + final private String unit; + + private DecimalScaleFactor(long multiplier, String unit) { + this.multiplier = multiplier; + this.unit = unit; + } + + public long getMultiplier() { + return multiplier; + } + + public String getUnit() { + return unit; + } + + public String toString() { + return multiplier + ", " + unit; + } + + /** + * Convert the given value to a size string like 64K + * + * @param v the size to convert + * @param nbDecimals number of significant figures to display after dot. use Integer.MAX_VALUE for all. + * @return the text for the size + */ + public static String apply(final long value, final int nbDecimals) { + long v = value; + DecimalScaleFactor unit = null; + for (DecimalScaleFactor u : values()) { + if ((v < 1000l) && (v >= 0l)) { + unit = u; + break; + } + + v = v / 1000l; + } + unit = (unit == null) ? MAX : unit; + float dv = ((float) value) / unit.getMultiplier(); + return NumberUtils.toString(dv, nbDecimals) + " " + unit.getUnit(); + } +} Modified: trunk/core/src/core/org/jnode/util/NumberUtils.java =================================================================== --- trunk/core/src/core/org/jnode/util/NumberUtils.java 2008-06-01 15:45:59 UTC (rev 4172) +++ trunk/core/src/core/org/jnode/util/NumberUtils.java 2008-06-01 15:50:10 UTC (rev 4173) @@ -255,7 +255,7 @@ * @return the text for of the size */ public static String toDecimalByte(long v, int nbDecimals) { - return DecimalPrefix.apply(v, nbDecimals) + "B"; + return DecimalScaleFactor.apply(v, nbDecimals) + "B"; } /** @@ -266,7 +266,7 @@ * @return the text for of the size */ public static String toBinaryByte(long v, int nbDecimals) { - return BinaryPrefix.apply(v, nbDecimals) + "B"; + return BinaryScaleFactor.apply(v, nbDecimals) + "B"; } /** Added: trunk/core/src/core/org/jnode/util/ScaleFactor.java =================================================================== --- trunk/core/src/core/org/jnode/util/ScaleFactor.java (rev 0) +++ trunk/core/src/core/org/jnode/util/ScaleFactor.java 2008-06-01 15:50:10 UTC (rev 4173) @@ -0,0 +1,7 @@ +package org.jnode.util; + +public interface ScaleFactor { + public long getMultiplier(); + + public String getUnit(); +} Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/DeviceView.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/DeviceView.java 2008-06-01 15:45:59 UTC (rev 4172) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/DeviceView.java 2008-06-01 15:50:10 UTC (rev 4173) @@ -11,7 +11,7 @@ import org.jnode.apps.jpartition.model.Device; import org.jnode.apps.jpartition.model.Partition; import org.jnode.apps.jpartition.model.UserFacade; -import org.jnode.util.BinaryPrefix; +import org.jnode.util.BinaryScaleFactor; import org.jnode.util.NumberUtils; public class DeviceView extends DiskAreaView<Device> Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/PartitionView.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/PartitionView.java 2008-06-01 15:45:59 UTC (rev 4172) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/swingview/PartitionView.java 2008-06-01 15:50:10 UTC (rev 4173) @@ -14,7 +14,7 @@ import org.jnode.apps.jpartition.swingview.actions.AddPartitionAction; import org.jnode.apps.jpartition.swingview.actions.FormatPartitionAction; import org.jnode.apps.jpartition.swingview.actions.RemovePartitionAction; -import org.jnode.util.BinaryPrefix; +import org.jnode.util.BinaryScaleFactor; import org.jnode.util.NumberUtils; public class PartitionView extends DiskAreaView<Partition> Modified: trunk/fs/descriptors/org.jnode.partitions.command.xml =================================================================== --- trunk/fs/descriptors/org.jnode.partitions.command.xml 2008-06-01 15:45:59 UTC (rev 4172) +++ trunk/fs/descriptors/org.jnode.partitions.command.xml 2008-06-01 15:50:10 UTC (rev 4173) @@ -24,5 +24,37 @@ <extension point="org.jnode.shell.aliases"> <alias name="fdisk" class="org.jnode.partitions.command.FdiskCommand"/> </extension> + + <extension point="org.jnode.shell.syntaxes"> + <syntax alias="fdisk"> + <empty description="list all block devices"/> + <argument argLabel="deviceId" description="show a device's partition table"/> + <sequence description="initialize a device's master boot record"> + <option argLabel="initMBR" shortName="i" longName="initMBR"/> + <argument argLabel="deviceId"/> + </sequence> + <sequence description="modify (or create) a partition"> + <option argLabel="modify" shortName="m" longName="modify"/> + <argument argLabel="deviceId"/> + <argument argLabel="partition"/> + <argument argLabel="start"/> + <alternatives> + <argument argLabel="sectors"/> + <argument argLabel="bytes"/> + </alternatives> + <argument argLabel="type"/> + </sequence> + <sequence description="toggle a partition's bootable flag"> + <option argLabel="bootable" shortName="b" longName="bootable"/> + <argument argLabel="deviceId"/> + <argument argLabel="partition"/> + </sequence> + <sequence description="delete a partition"> + <option argLabel="delete" shortName="d" longName="delete"/> + <argument argLabel="deviceId"/> + <argument argLabel="partition"/> + </sequence> + </syntax> + </extension> </plugin> \ No newline at end of file Modified: trunk/fs/src/fs/org/jnode/fs/ext2/BlockSize.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ext2/BlockSize.java 2008-06-01 15:45:59 UTC (rev 4172) +++ trunk/fs/src/fs/org/jnode/fs/ext2/BlockSize.java 2008-06-01 15:50:10 UTC (rev 4173) @@ -1,6 +1,6 @@ package org.jnode.fs.ext2; -import org.jnode.util.BinaryPrefix; +import org.jnode.util.BinaryScaleFactor; public enum BlockSize { @@ -12,7 +12,7 @@ private BlockSize(int blockSizeKb) { - this.size = (int) (blockSizeKb * BinaryPrefix.K.getMultiplier()); //Converted into KB + this.size = (int) (blockSizeKb * BinaryScaleFactor.K.getMultiplier()); //Converted into KB } final public int getSize() { Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemFormatter.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemFormatter.java 2008-06-01 15:45:59 UTC (rev 4172) +++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemFormatter.java 2008-06-01 15:50:10 UTC (rev 4173) @@ -25,7 +25,7 @@ import org.jnode.fs.FileSystemException; import org.jnode.fs.Formatter; import org.jnode.fs.service.FileSystemService; -import org.jnode.util.BinaryPrefix; +import org.jnode.util.BinaryScaleFactor; import org.jnode.naming.InitialNaming; import javax.naming.NameNotFoundException; Modified: trunk/fs/src/fs/org/jnode/fs/jfat/ClusterSize.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/jfat/ClusterSize.java 2008-06-01 15:45:59 UTC (rev 4172) +++ trunk/fs/src/fs/org/jnode/fs/jfat/ClusterSize.java 2008-06-01 15:50:10 UTC (rev 4173) @@ -1,6 +1,6 @@ package org.jnode.fs.jfat; -import org.jnode.util.BinaryPrefix; +import org.jnode.util.BinaryScaleFactor; public enum ClusterSize { @@ -16,7 +16,7 @@ private ClusterSize(int sizeInKb) { - size = (int) (sizeInKb * BinaryPrefix.K.getMultiplier()); //Converted into KB + size = (int) (sizeInKb * BinaryScaleFactor.K.getMultiplier()); //Converted into KB } final public int getSize() Modified: trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java 2008-06-01 15:45:59 UTC (rev 4172) +++ trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java 2008-06-01 15:50:10 UTC (rev 4173) @@ -22,6 +22,8 @@ package org.jnode.partitions.command; import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; import java.nio.ByteBuffer; import java.util.Collection; import java.util.List; @@ -43,278 +45,187 @@ import org.jnode.partitions.ibm.IBMPartitionTableEntry; import org.jnode.partitions.ibm.IBMPartitionTableType; import org.jnode.partitions.ibm.IBMPartitionTypes; -import org.jnode.shell.help.Help; -import org.jnode.shell.help.Parameter; -import org.jnode.shell.help.ParsedArguments; -import org.jnode.shell.help.Syntax; -import org.jnode.shell.help.SyntaxErrorException; -import org.jnode.shell.help.argument.DeviceArgument; -import org.jnode.shell.help.argument.IntegerArgument; -import org.jnode.shell.help.argument.LongArgument; -import org.jnode.shell.help.argument.OptionArgument; -import org.jnode.shell.help.argument.SizeArgument; +import org.jnode.shell.AbstractCommand; +import org.jnode.shell.CommandLine; +import org.jnode.shell.syntax.*; +import com.sun.org.apache.xml.internal.utils.ObjectPool; + /** * @author gbin * @author Trickkiste + * @author cr...@jn... */ -public class FdiskCommand { +public class FdiskCommand extends AbstractCommand { + // FIXME ... this is a dangerous command and it needs some extra checking to help + // avoid catastrophic errors. At the very least, it needs a mode that shows the + // user what would happen but does nothing. + private final FlagArgument FLAG_INIT_MBR = new FlagArgument( + "initMBR", Argument.OPTIONAL, "if set, init the device's Master Boot Record"); - static final OptionArgument INITMBR = - new OptionArgument( - "init. MBR", - "Type parameter", - new OptionArgument.Option[] { - new OptionArgument.Option("--initmbr", "initialize the Master Boot Record of the device")}); + private final FlagArgument FLAG_DELETE = new FlagArgument( + "delete", Argument.OPTIONAL, "if set, delete a partition"); + + private final FlagArgument FLAG_BOOTABLE = new FlagArgument( + "bootable", Argument.OPTIONAL, "if set, toggle the partition's bootable flag"); + + private final FlagArgument FLAG_MODIFY = new FlagArgument( + "modify", Argument.OPTIONAL, "if set, modify or create a partition"); - static final OptionArgument ACTION = - new OptionArgument( - "action", - "Action on a specified partition", - new OptionArgument.Option[] { - new OptionArgument.Option("-d", "Delete a partition"), - new OptionArgument.Option("-b", "Switch the bootable flag of a partition")}); - - static final OptionArgument ACTION_MODIFY = - new OptionArgument( - "action", - "Action on a specified partition", - new OptionArgument.Option[] { - new OptionArgument.Option("-m", "Modify/create a partition")}); - - static final IntegerArgument PARTITION = new IntegerArgument("partition number", "Targeted partition"); - static final LongArgument START = new LongArgument("start", "Sector where the partition starts"); - static final SizeArgument SIZE = new SizeArgument("size", "Size of the partition in sectors or in bytes(use prefixes K, M, G, ...)"); - static final IBMPartitionTypeArgument PARTITION_TYPE = new IBMPartitionTypeArgument( - "partition type", "partition type code"); + private final IntegerArgument ARG_PARTITION = new IntegerArgument( + "partition", Argument.OPTIONAL, "Target partition number (0..3)"); - static final DeviceArgument ARG_DEVICE = - new DeviceArgument("device-id", "the device on which you want to change/create the partition"); + private final LongArgument ARG_START = new LongArgument( + "start", Argument.OPTIONAL, "Partition start sector"); + + private final LongArgument ARG_SECTORS = new LongArgument( + "sectors", Argument.OPTIONAL, "Partition size in sectors"); + + private final SizeArgument ARG_BYTES = new SizeArgument( + "bytes", Argument.OPTIONAL, "Partition size in bytes (300K, 45M, etc)"); + + private final IBMPartitionTypeArgument ARG_TYPE = new IBMPartitionTypeArgument( + "type", Argument.OPTIONAL, "IBM partition type code"); + + private final DeviceArgument ARG_DEVICE = new DeviceArgument( + "deviceId", Argument.OPTIONAL, "Target device", BlockDeviceAPI.class); + - static final Parameter PARAM_INITMBR = new Parameter(INITMBR, Parameter.MANDATORY); - static final Parameter PARAM_ACTION = new Parameter(ACTION, Parameter.MANDATORY); - static final Parameter PARAM_ACTION_MODIFY = new Parameter(ACTION_MODIFY, Parameter.MANDATORY); - static final Parameter PARAM_DEVICE = new Parameter(ARG_DEVICE, Parameter.MANDATORY); - static final Parameter PARAM_PARTITION = new Parameter(PARTITION, Parameter.MANDATORY); - static final Parameter PARAM_START = new Parameter(START, Parameter.MANDATORY); - static final Parameter PARAM_SIZE = new Parameter(SIZE, Parameter.MANDATORY); - static final Parameter PARAM_PARTITION_TYPE = new Parameter(PARTITION_TYPE, Parameter.MANDATORY); + public FdiskCommand() { + super("perform disk partition management tasks"); + registerArguments(FLAG_BOOTABLE, FLAG_DELETE, FLAG_INIT_MBR, FLAG_MODIFY, + ARG_DEVICE, ARG_PARTITION, ARG_START, ARG_SECTORS, ARG_BYTES, ARG_TYPE); + } - public static Help.Info HELP_INFO = - new Help.Info( - "fdisk", - new Syntax[] { - new Syntax("Lists the available devices"), - new Syntax("Print the partition table of a device", - new Parameter[] { - PARAM_DEVICE }), - new Syntax("Initialize the MBR of a device", - new Parameter[] { - PARAM_INITMBR, PARAM_DEVICE }), - new Syntax("Change a partition", - new Parameter[] { - PARAM_ACTION_MODIFY, PARAM_PARTITION, PARAM_START, - PARAM_SIZE, PARAM_PARTITION_TYPE, - PARAM_DEVICE }), - new Syntax("Delete a partition / switch bootable flag", - new Parameter[] { - PARAM_ACTION, PARAM_PARTITION, PARAM_DEVICE }), - }); - - public static void main(String[] args) throws SyntaxErrorException { - ParsedArguments cmdLine = HELP_INFO.parse(args); - - DeviceManager dm; - try { - dm = InitialNaming.lookup(DeviceManager.NAME); - - boolean isAction = PARAM_ACTION.isSet(cmdLine); - boolean isActionModify = PARAM_ACTION_MODIFY.isSet(cmdLine); - boolean isInitMBR = PARAM_INITMBR.isSet(cmdLine); - boolean isDevice = PARAM_DEVICE.isSet(cmdLine); - - // no parameters - if (!isDevice) { - listAvailableDevice(dm); - return; - } - - // only device is set - if (!isAction && !isActionModify && !isInitMBR && isDevice) { - printTable(ARG_DEVICE.getValue(cmdLine), dm); - return; - } - - final String deviceId = ARG_DEVICE.getValue(cmdLine); - final PartitionHelper helper = new PartitionHelper(deviceId); - - // initMBR - if (isInitMBR) { - helper.initMbr(); - helper.write(); - return; - } - - int partNumber = getPartitionNumber(helper, cmdLine); - - // modify a partition ? - if (ACTION_MODIFY.getValue(cmdLine).intern() == "-m") { - modifyPartition(helper, partNumber, cmdLine); - helper.write(); - return; - } - - // delete a partition ? - if (ACTION.getValue(cmdLine).intern() == "-d") { - helper.deletePartition(partNumber); - helper.write(); - return; - } - - // toggle boot flag for a partition ? - if (ACTION.getValue(cmdLine).intern() == "-b") { - helper.toggleBootable(partNumber); - helper.write(); - } - } catch (IOException e) { - e.printStackTrace(); - } catch (NameNotFoundException e) { - e.printStackTrace(); - } catch (ApiNotFoundException e) { - e.printStackTrace(); - } catch (DeviceNotFoundException e) { - e.printStackTrace(); - } + public static void main(String[] args) throws Exception { + new FdiskCommand().execute(args); } - - private static int getPartitionNumber(PartitionHelper helper, ParsedArguments cmdLine) - { - int partNumber = PARTITION.getInteger(cmdLine); + + public void execute(CommandLine commandLine, InputStream in, + PrintStream out, PrintStream err) throws Exception { + final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME); + + if (!ARG_DEVICE.isSet()) { + // Show all devices. + listAvailableDevices(dm, out); + return; + } + + Device dev = ARG_DEVICE.getValue(); + // FIXME PartitionHelper assumes that the device is an IDE device !?! + if (!(dev instanceof IDEDevice)) { + err.println(dev.getId() + " is not an IDE device"); + exit(1); + } + final PartitionHelper helper = new PartitionHelper(dev.getId()); - if ((partNumber >= helper.getNbPartitions()) || - (partNumber < 0) ) + if (FLAG_BOOTABLE.isSet()) { + helper.toggleBootable(getPartitionNumber(helper)); + helper.write(); + } + else if (FLAG_DELETE.isSet()) { + helper.deletePartition(getPartitionNumber(helper)); + helper.write(); + } + else if (FLAG_MODIFY.isSet()) { + modifyPartition(helper, getPartitionNumber(helper), out); + helper.write(); + } + else if (FLAG_INIT_MBR.isSet()) { + helper.initMbr(); + helper.write(); + } + else { + printPartitionTable(dev, out); + } + } + + private int getPartitionNumber(PartitionHelper helper) { + int partNumber = ARG_PARTITION.getValue(); + if (partNumber >= helper.getNbPartitions() || partNumber < 0) { throw new IllegalArgumentException("Partition number is invalid"); - + } return partNumber; } - private static void modifyPartition(PartitionHelper helper, - int id, - ParsedArguments cmdLine) - throws IOException - { - long start = START.getLong(cmdLine); - long size = SIZE.getLong(cmdLine); - IBMPartitionTypes type = PARTITION_TYPE.getArgValue(cmdLine); - -// try { - System.out.println("D"); - System.out.println("Init " + id + " with start = " + start - + ", size = " + size + ", fs = " - + Integer.toHexString(type.getCode() & 0xff)); - System.out.println("E"); - boolean sizeUnit = SIZE.hasSizeUnit(cmdLine) ? - PartitionHelper.BYTES : PartitionHelper.SECTORS; - helper.modifyPartition(id, false, start, size, sizeUnit, type); - System.out.println("F"); -// } -// catch (NumberFormatException nfe) -// { -// System.err.println("not an integer"); -// System.err.println(helpMsg); -// } -// catch (NoSuchElementException nsee) -// { -// System.err.println("not enough elements"); -// System.err.println(helpMsg); -// } -// catch (IllegalArgumentException iae) -// { -// System.err.println(iae.getMessage()); -// System.err.println(helpMsg); -// } + private void modifyPartition(PartitionHelper helper, int id, PrintStream out) + throws IOException { + long start = ARG_START.getValue(); + long size = ARG_SECTORS.isSet() ? ARG_SECTORS.getValue() : ARG_BYTES.getValue(); + IBMPartitionTypes type = ARG_TYPE.getValue(); + + out.println("Init " + id + " with start = " + start + + ", size = " + size + ", fs = " + + Integer.toHexString(type.getCode())); + boolean sizeUnit = ARG_BYTES.isSet() ? + PartitionHelper.BYTES : PartitionHelper.SECTORS; + helper.modifyPartition(id, false, start, size, sizeUnit, type); } - private static void printTable(String deviceName, DeviceManager dm) - throws DeviceNotFoundException, ApiNotFoundException, IOException { - { - IDEDevice current = (IDEDevice)dm.getDevice(deviceName); - BlockDeviceAPI api = current.getAPI(BlockDeviceAPI.class); - IDEDriveDescriptor descriptor = current.getDescriptor(); - ByteBuffer MBR = ByteBuffer.allocate(IDEConstants.SECTOR_SIZE); - api.read(0, MBR); - if (IBMPartitionTable.containsPartitionTable(MBR.array())) { - IBMPartitionTable partitionTable = new IBMPartitionTable(new IBMPartitionTableType(), MBR.array(), current); + private void printPartitionTable(Device dev, PrintStream out) + throws DeviceNotFoundException, ApiNotFoundException, IOException { + IDEDevice ideDev = null; + // FIXME ... this needs to be generalized to other disc device types. + if (dev instanceof IDEDevice) { + ideDev = (IDEDevice) dev; + } + BlockDeviceAPI api = dev.getAPI(BlockDeviceAPI.class); + IDEDriveDescriptor descriptor = ideDev.getDescriptor(); + ByteBuffer MBR = ByteBuffer.allocate(IDEConstants.SECTOR_SIZE); + api.read(0, MBR); + if (IBMPartitionTable.containsPartitionTable(MBR.array())) { + IBMPartitionTable partitionTable = + new IBMPartitionTable(new IBMPartitionTableType(), MBR.array(), dev); + if (ideDev != null) { + out.println( "IDE Disk : " + dev.getId() + ": " + + descriptor.getSectorsIn28bitAddressing() * 512 + " bytes"); + } + out.println("Device Boot Start End Blocks System"); - System.out.println( - "Disk : " + current.getId() + ": " + descriptor.getSectorsIn28bitAddressing() * 512 + " bytes"); - System.out.println("Device Boot Start End Blocks System"); - - int i = 0; - for (IBMPartitionTableEntry entry : partitionTable) { - //IBMPartitionTableEntry entry = (IBMPartitionTableEntry)partitionTable.getEntry(i); - IBMPartitionTypes si = entry.getSystemIndicator(); - if (si != IBMPartitionTypes.PARTTYPE_EMPTY) - System.out.println( - "ID " - + i - + " " - + (entry.getBootIndicator() ? "Boot" : "No") - + " " - + entry.getStartLba() - + " " - + (entry.getStartLba() + entry.getNrSectors()) - + " " - + entry.getNrSectors() - + " " - + si); - if(entry.isExtended()) { - final List<IBMPartitionTableEntry> exPartitions = partitionTable.getExtendedPartitions(); - int j = 0; - for (IBMPartitionTableEntry exEntry : exPartitions) { - si = exEntry.getSystemIndicator(); - System.out.println( - "ID " - + i - + " " - + (exEntry.getBootIndicator() ? "Boot" : "No") - + " " - + exEntry.getStartLba() - + " " - + "-----"//(exEntry.getStartLba() + entry.getNrSectors()) - + " " - + "-----"//exEntry.getNrSectors() - + " " - + si); - j++; - } - } - i++; - } - - } else { - System.out.println(" No valid MBR found on this device. Use --initmbr to initialize it."); - } - } + int i = 0; + for (IBMPartitionTableEntry entry : partitionTable) { + //IBMPartitionTableEntry entry = (IBMPartitionTableEntry)partitionTable.getEntry(i); + IBMPartitionTypes si = entry.getSystemIndicator(); + if (si != IBMPartitionTypes.PARTTYPE_EMPTY) { + out.println("ID " + i + " " + + (entry.getBootIndicator() ? "Boot" : "No") + " " + + entry.getStartLba() + " " + + (entry.getStartLba() + entry.getNrSectors()) + " " + + entry.getNrSectors() + " " + si); + } + if (entry.isExtended()) { + final List<IBMPartitionTableEntry> exPartitions = partitionTable.getExtendedPartitions(); + int j = 0; + for (IBMPartitionTableEntry exEntry : exPartitions) { + si = exEntry.getSystemIndicator(); + // FIXME ... this needs work + out.println("ID " + i + " " + + (exEntry.getBootIndicator() ? "Boot" : "No") + " " + + exEntry.getStartLba() + " " + + "-----" /* (exEntry.getStartLba() + entry.getNrSectors()) */ + " " + + "-----" /* exEntry.getNrSectors() */ + " " + si); + j++; + } + } + i++; + } + } + else { + out.println(" No valid MBR found on this device. Use --initMBR to initialize it."); + } } - private static void listAvailableDevice(DeviceManager dm) { + private void listAvailableDevices(DeviceManager dm, PrintStream out) { final Collection<Device> allDevices = dm.getDevicesByAPI(BlockDeviceAPI.class); - for (Device current : allDevices) { - System.out.println("Found device : " + current.getId() + "[" + current.getClass() + "]"); - - if (current instanceof IDEDevice) { - IDEDevice ideDevice = (IDEDevice)current; - IDEDriveDescriptor currentDescriptor = ideDevice.getDescriptor(); - if (currentDescriptor.isDisk()) { - System.out.println( - " IDE Disk : " - + ideDevice.getId() - + "(" - + currentDescriptor.getModel() - + " " - + currentDescriptor.getSectorsIn28bitAddressing() * IDEConstants.SECTOR_SIZE - + ")"); + for (Device dev : allDevices) { + out.println("Found device : " + dev.getId() + "[" + dev.getClass() + "]"); + if (dev instanceof IDEDevice) { + IDEDevice ideDevice = (IDEDevice) dev; + IDEDriveDescriptor desc = ideDevice.getDescriptor(); + if (desc.isDisk()) { + out.println(" IDE Disk : " + ideDevice.getId() + + "(" + desc.getModel() + " " + + desc.getSectorsIn28bitAddressing() * IDEConstants.SECTOR_SIZE + ")"); } } } Modified: trunk/fs/src/fs/org/jnode/partitions/help/argument/IBMPartitionTypeArgument.java =================================================================== --- trunk/fs/src/fs/org/jnode/partitions/help/argument/IBMPartitionTypeArgument.java 2008-06-01 15:45:59 UTC (rev 4172) +++ trunk/fs/src/fs/org/jnode/partitions/help/argument/IBMPartitionTypeArgument.java 2008-06-01 15:50:10 UTC (rev 4173) @@ -1,43 +1,72 @@ +/* + * $Id$ + * + * JNode.org + * Copyright (C) 2008 JNode.org + * + * This library 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 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ package org.jnode.partitions.help.argument; -import java.util.Arrays; -import java.util.Collection; - +import org.jnode.driver.console.CompletionInfo; import org.jnode.partitions.ibm.IBMPartitionTypes; -import org.jnode.shell.help.ParsedArguments; -import org.jnode.shell.help.argument.ListArgument; +import org.jnode.shell.CommandLine.Token; +import org.jnode.shell.syntax.Argument; +import org.jnode.shell.syntax.CommandSyntaxException; - -public class IBMPartitionTypeArgument extends ListArgument<IBMPartitionTypes> +/** + * Argument close for partition type codes. Input is in hexadecimal, and + * completion is supported. + * + * @author cr...@jn... + */ +public class IBMPartitionTypeArgument extends Argument<IBMPartitionTypes> { - public IBMPartitionTypeArgument(String name, String description) - { - super(name, description, false); - } - - public IBMPartitionTypes getArgValue(String value) - { - int fs = Integer.parseInt(value, 16); - return IBMPartitionTypes.valueOf(fs); - } + + public IBMPartitionTypeArgument(String label, int flags, String description) { + super(label, flags, new IBMPartitionTypes[0], description); + } - @Override - protected String toStringArgument(IBMPartitionTypes arg) { - return Integer.toHexString(arg.getCode()); - } + @Override + protected IBMPartitionTypes doAccept(Token value) throws CommandSyntaxException { + try { + int code = Integer.parseInt(value.token, 16); + return IBMPartitionTypes.valueOf(code); + } + catch (NumberFormatException ex) { + throw new CommandSyntaxException("Not a valid hexadecimal number"); + } + catch (IllegalArgumentException ex) { + throw new CommandSyntaxException(ex.getMessage()); + } + } + + @Override + public void complete(CompletionInfo completion, String partial) { + partial = partial.toLowerCase(); + for (IBMPartitionTypes pt : IBMPartitionTypes.values()) { + String code = Integer.toHexString(pt.getCode()); + if (code.startsWith(partial)) { + completion.addCompletion(code); + } + } + } + + @Override + protected String argumentKind() { + return "partition type"; + } - @Override - protected Collection<IBMPartitionTypes> getValues() { - return Arrays.asList(IBMPartitionTypes.values()); - } - - @Override - public int compare(IBMPartitionTypes choice1, IBMPartitionTypes choice2) { - return choice1.getCode() - choice2.getCode(); - } - - @Override - protected boolean isPartOfArgument(IBMPartitionTypes argument, String part) { - return toStringArgument(argument).startsWith(part); - } } Added: trunk/shell/src/shell/org/jnode/shell/syntax/SizeArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/SizeArgument.java (rev 0) +++ trunk/shell/src/shell/org/jnode/shell/syntax/SizeArgument.java 2008-06-01 15:50:10 UTC (rev 4173) @@ -0,0 +1,90 @@ +/* + * $Id$ + * + * JNode.org + * Copyright (C) 2007-2008 JNode.org + * + * This library 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 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.shell.syntax; + +import org.jnode.driver.console.CompletionInfo; +import org.jnode.shell.CommandLine.Token; +import org.jnode.util.BinaryScaleFactor; +import org.jnode.util.DecimalScaleFactor; +import org.jnode.util.ScaleFactor; + +/** + * This Argument class accepts size values. These are integers with an optional decimal + * or binary scaling suffix; e.g. 1K means 1000 or 1024 + * + * @author cr...@jn... + */ +public class SizeArgument extends Argument<Long> { + private final boolean binaryScaling; + + public SizeArgument(String label, int flags, String description) { + this(label, flags, true, description); + } + + public SizeArgument(String label, int flags, boolean binaryScaling, String description) { + super(label, flags, new Long[0], description); + this.binaryScaling = binaryScaling; + } + + @Override + protected Long doAccept(Token token) throws CommandSyntaxException { + String str = token.token; + ScaleFactor factor = scaleFactor(str); + if (factor != null) { + str = str.substring(0, str.length() - factor.getUnit().length()); + } + try { + long tmp = Long.parseLong(str); + return new Long(tmp * factor.getMultiplier()); + } + catch (NumberFormatException ex) { + throw new CommandSyntaxException("invalid number '" + token.token + "'"); + } + } + + private ScaleFactor scaleFactor(String str) { + ScaleFactor[] prefixes = binaryScaling ? + BinaryScaleFactor.values() : DecimalScaleFactor.values(); + for (ScaleFactor unit : prefixes) { + String unitStr = unit.getUnit(); + if (str.endsWith(unitStr)) { + return unit; + } + } + return null; + } + + @Override + public void complete(CompletionInfo completion, String partial) { + // No completion for now + } + + @Override + protected String state() { + return super.state() + "binaryScaling=" + binaryScaling; + } + + @Override + protected String argumentKind() { + return "size"; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-06-04 08:26:40
|
Revision: 4187 http://jnode.svn.sourceforge.net/jnode/?rev=4187&view=rev Author: lsantha Date: 2008-06-04 01:26:35 -0700 (Wed, 04 Jun 2008) Log Message: ----------- Code style fixes. Modified Paths: -------------- trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java trunk/builder/src/builder/org/jnode/ant/taskdefs/FileSetTask.java trunk/builder/src/builder/org/jnode/build/documentation/PluginDocumentationTask.java trunk/fs/src/driver/org/jnode/driver/block/BlockAlignmentSupport.java trunk/fs/src/driver/org/jnode/driver/block/floppy/support/FloppyDriverUtils.java trunk/fs/src/driver/org/jnode/driver/block/usb/storage/USBStorageConstants.java trunk/fs/src/test/org/jnode/test/fs/driver/BlockDeviceAPIContext.java trunk/fs/src/test/org/jnode/test/fs/driver/BlockDeviceAPITestConfig.java trunk/fs/src/test/org/jnode/test/fs/driver/context/FileDeviceContext.java trunk/fs/src/test/org/jnode/test/fs/driver/factories/AbstractMockDeviceFactory.java trunk/fs/src/test/org/jnode/test/fs/driver/stubs/StubDeviceManager.java trunk/fs/src/test/org/jnode/test/fs/filesystem/AbstractFSTest.java trunk/fs/src/test/org/jnode/test/fs/filesystem/config/DeviceParam.java trunk/fs/src/test/org/jnode/test/fs/filesystem/config/FS.java trunk/fs/src/test/org/jnode/test/fs/filesystem/config/FSTestConfig.java trunk/fs/src/test/org/jnode/test/fs/filesystem/config/FSType.java trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/ConcurrentAccessFSTest.java trunk/fs/src/test/org/jnode/test/support/AbstractTest.java trunk/fs/src/test/org/jnode/test/support/AbstractTestSuite.java trunk/fs/src/test/org/jnode/test/support/ConfigManager.java trunk/fs/src/test/org/jnode/test/support/Context.java trunk/fs/src/test/org/jnode/test/support/ContextManager.java trunk/fs/src/test/org/jnode/test/support/MockUtils.java trunk/fs/src/test/org/jnode/test/support/TestUtils.java trunk/gui/src/awt/org/jnode/awt/JNodeRobotPeer.java trunk/gui/src/awt/org/jnode/awt/JNodeToolkit.java trunk/gui/src/awt/org/jnode/awt/font/bdf/BDFTextRenderer.java trunk/gui/src/awt/org/jnode/awt/font/renderer/RenderCache.java trunk/gui/src/awt/org/jnode/awt/font/spi/AbstractFontProvider.java trunk/gui/src/awt/org/jnode/awt/font/spi/AbstractTextRenderer.java trunk/gui/src/awt/org/jnode/awt/font/spi/Glyph.java trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingToolkit.java trunk/gui/src/awt/org/jnode/awt/util/AbstractBitmapGraphics.java trunk/gui/src/awt/org/jnode/awt/util/BitmapGraphics.java trunk/gui/src/desktop/org/jnode/desktop/ApplicationBar.java trunk/gui/src/desktop/org/jnode/desktop/Desktop.java trunk/gui/src/desktop/org/jnode/desktop/WindowBar.java trunk/gui/src/desktop/org/jnode/desktop/classic/Desktop.java trunk/gui/src/desktop/org/jnode/desktop/classic/TaskBar.java trunk/gui/src/desktop/org/jnode/desktop/classic/WindowBar.java trunk/gui/src/test/org/jnode/test/gui/AWTDemo.java trunk/gui/src/test/org/jnode/test/gui/Emu.java trunk/gui/src/test/org/jnode/test/gui/ImageTest.java trunk/gui/src/test/org/jnode/test/gui/Tetris.java trunk/shell/src/test/org/jnode/test/shell/DeviceManager.java Modified: trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java =================================================================== --- trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -320,7 +320,7 @@ * @author fabien */ private static class MarkerClassVisitor extends ClassAdapter { - final private List<String> annotationTypeDescs; + private final List<String> annotationTypeDescs; private boolean classIsModified = false; Modified: trunk/builder/src/builder/org/jnode/ant/taskdefs/FileSetTask.java =================================================================== --- trunk/builder/src/builder/org/jnode/ant/taskdefs/FileSetTask.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/builder/src/builder/org/jnode/ant/taskdefs/FileSetTask.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -36,7 +36,7 @@ * * @author Fabien DUMINY (fduminy at jnode.org) */ -abstract public class FileSetTask extends Task { +public abstract class FileSetTask extends Task { protected boolean trace = false; protected boolean failOnError = true; @@ -54,7 +54,7 @@ fileSets.add(fs); } - final public void execute() throws BuildException { + public final void execute() throws BuildException { try { doExecute(); } catch (BuildException be) { @@ -77,7 +77,7 @@ processFiles(); } - final protected void processFiles() throws BuildException { + protected final void processFiles() throws BuildException { final Project project = getProject(); try { for (FileSet fs : fileSets) { @@ -93,5 +93,5 @@ } } - abstract protected void processFile(File file) throws IOException; + protected abstract void processFile(File file) throws IOException; } Modified: trunk/builder/src/builder/org/jnode/build/documentation/PluginDocumentationTask.java =================================================================== --- trunk/builder/src/builder/org/jnode/build/documentation/PluginDocumentationTask.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/builder/src/builder/org/jnode/build/documentation/PluginDocumentationTask.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -57,9 +57,9 @@ private final SortedMap<String, PluginData> descriptors = new TreeMap<String, PluginData>(); - private final static String DOCHEADER = "JNode plugin documentation"; + private static final String DOCHEADER = "JNode plugin documentation"; - private final static String PLUGINS_SUBDIR = "plugins"; + private static final String PLUGINS_SUBDIR = "plugins"; private static final String EXT = ".html"; @@ -67,19 +67,15 @@ private static final String ALL_FILE = "all-frame" + EXT; - private static final String OVERVIEW_SUMMARY_FILE = "overview-summary" - + EXT; + private static final String OVERVIEW_SUMMARY_FILE = "overview-summary" + EXT; private static final String OVERVIEW_SUMMARY_FRAME = "overviewSummary"; - private static final String OVERVIEW_PACKAGE_FILE = "overview-package" - + EXT; + private static final String OVERVIEW_PACKAGE_FILE = "overview-package" + EXT; - private static final String OVERVIEW_LICENSE_FILE = "overview-license" - + EXT; + private static final String OVERVIEW_LICENSE_FILE = "overview-license" + EXT; - private static final String OVERVIEW_TREE_FILE = "overview-tree" - + EXT; + private static final String OVERVIEW_TREE_FILE = "overview-tree" + EXT; private static final String OVERVIEW_TREE_DOTFILE = "overview-tree.dot"; private static final String OVERVIEW_TREE_PNGFILE = "overview-tree.png"; Modified: trunk/fs/src/driver/org/jnode/driver/block/BlockAlignmentSupport.java =================================================================== --- trunk/fs/src/driver/org/jnode/driver/block/BlockAlignmentSupport.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/driver/org/jnode/driver/block/BlockAlignmentSupport.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -240,10 +240,10 @@ */ private static final Logger log = Logger.getLogger(BlockAlignmentSupport.class); - static private final int EMPTY = 0; - static private final int CONTAINED = 1; - static private final int CROSSED = 2; - static private final int ALIGNED = 3; + private static final int EMPTY = 0; + private static final int CONTAINED = 1; + private static final int CROSSED = 2; + private static final int ALIGNED = 3; private final BlockDeviceAPI parentApi; private int alignment; Modified: trunk/fs/src/driver/org/jnode/driver/block/floppy/support/FloppyDriverUtils.java =================================================================== --- trunk/fs/src/driver/org/jnode/driver/block/floppy/support/FloppyDriverUtils.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/driver/org/jnode/driver/block/floppy/support/FloppyDriverUtils.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -30,7 +30,7 @@ */ public class FloppyDriverUtils { - static public final FloppyDeviceFactory getFloppyDeviceFactory() throws NamingException { + public static final FloppyDeviceFactory getFloppyDeviceFactory() throws NamingException { try { return InitialNaming.lookup(FloppyDeviceFactory.NAME); } catch (NameNotFoundException ex) { Modified: trunk/fs/src/driver/org/jnode/driver/block/usb/storage/USBStorageConstants.java =================================================================== --- trunk/fs/src/driver/org/jnode/driver/block/usb/storage/USBStorageConstants.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/driver/org/jnode/driver/block/usb/storage/USBStorageConstants.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -31,48 +31,48 @@ */ public interface USBStorageConstants extends USBConstants { /* Sub Classes */ - public final static int US_SC_RBC = 0x01; /* Typically, flash devices */ - public final static int US_SC_8020 = 0x02; /* CD-ROM */ - public final static int US_SC_QIC = 0x03; /* QIC-157 Tapes */ - public final static int US_SC_UFI = 0x04; /* Floppy */ - public final static int US_SC_8070 = 0x05; /* Removable media */ - public final static int US_SC_SCSI = 0x06; /* Transparent */ - public final static int US_SC_ISD200 = 0x07; /* ISD200 ATA */ + public static final int US_SC_RBC = 0x01; /* Typically, flash devices */ + public static final int US_SC_8020 = 0x02; /* CD-ROM */ + public static final int US_SC_QIC = 0x03; /* QIC-157 Tapes */ + public static final int US_SC_UFI = 0x04; /* Floppy */ + public static final int US_SC_8070 = 0x05; /* Removable media */ + public static final int US_SC_SCSI = 0x06; /* Transparent */ + public static final int US_SC_ISD200 = 0x07; /* ISD200 ATA */ - public final static int US_SC_MIN = US_SC_RBC; - public final static int US_SC_MAX = US_SC_ISD200; - public final static int US_SC_DEVICE = 0xff; /* Use device's value */ + public static final int US_SC_MIN = US_SC_RBC; + public static final int US_SC_MAX = US_SC_ISD200; + public static final int US_SC_DEVICE = 0xff; /* Use device's value */ /* Protocols */ - public final static int US_PR_CBI = 0x00; /* Control/Bulk/Interrupt */ - public final static int US_PR_CB = 0x01; /* Control/Bulk w/o interrupt */ - public final static int US_PR_BULK = 0x50; /* bulk only */ + public static final int US_PR_CBI = 0x00; /* Control/Bulk/Interrupt */ + public static final int US_PR_CB = 0x01; /* Control/Bulk w/o interrupt */ + public static final int US_PR_BULK = 0x50; /* bulk only */ - public final static int US_PR_SCM_ATAPI = 0x80; /* SCM-ATAPI bridge */ - public final static int US_PR_EUSB_SDDR09 = 0x81; /* SCM-SCSI bridge for SDDR-09 */ - public final static int US_PR_SDDR55 = 0x82; /* SDDR-55 (made up) */ - public final static int US_PR_DPCM_USB = 0xf0; /* Combination CB/SDDR09 */ - public final static int US_PR_FREECOM = 0xf1; /* Freecom */ - public final static int US_PR_DATAFAB = 0xf2; /* Datafab chipsets */ - public final static int US_PR_JUMPSHOT = 0xf3; /* Lexar Jumpshot */ - public final static int US_PR_DEVICE = 0xff; /* Use device's value */ + public static final int US_PR_SCM_ATAPI = 0x80; /* SCM-ATAPI bridge */ + public static final int US_PR_EUSB_SDDR09 = 0x81; /* SCM-SCSI bridge for SDDR-09 */ + public static final int US_PR_SDDR55 = 0x82; /* SDDR-55 (made up) */ + public static final int US_PR_DPCM_USB = 0xf0; /* Combination CB/SDDR09 */ + public static final int US_PR_FREECOM = 0xf1; /* Freecom */ + public static final int US_PR_DATAFAB = 0xf2; /* Datafab chipsets */ + public static final int US_PR_JUMPSHOT = 0xf3; /* Lexar Jumpshot */ + public static final int US_PR_DEVICE = 0xff; /* Use device's value */ /* Transport */ - public final static int CB_RESET_CMD_SIZE = 12; + public static final int CB_RESET_CMD_SIZE = 12; - public final static int US_BULK_CB_SIGN = 0x43425355; /*spells out USBC */ - public final static int US_BULK_CB_WRAP_LEN = 31; - public final static int US_BULK_CB_LUN_MASK = 0x07; - public final static int US_BULK_FLAG_OUT = 0x00; - public final static int US_BULK_FLAG_IN = 0x80; + public static final int US_BULK_CB_SIGN = 0x43425355; /*spells out USBC */ + public static final int US_BULK_CB_WRAP_LEN = 31; + public static final int US_BULK_CB_LUN_MASK = 0x07; + public static final int US_BULK_FLAG_OUT = 0x00; + public static final int US_BULK_FLAG_IN = 0x80; - public final static int US_BULK_CS_SIGN = 0x53425355; /*spells out USBS */ - public final static int US_BULK_CS_WRAP_LEN = 13; + public static final int US_BULK_CS_SIGN = 0x53425355; /*spells out USBS */ + public static final int US_BULK_CS_WRAP_LEN = 13; - public final static int US_BULK_CS_CMD_NO_ERROR = 0x00; // No error occurs - public final static int US_BULK_CS_CMD_FAILED = 0x01; - public final static int US_BULK_CS_CMD_WRONG_SEQUENCE = 0x02; + public static final int US_BULK_CS_CMD_NO_ERROR = 0x00; // No error occurs + public static final int US_BULK_CS_CMD_FAILED = 0x01; + public static final int US_BULK_CS_CMD_WRONG_SEQUENCE = 0x02; } Modified: trunk/fs/src/test/org/jnode/test/fs/driver/BlockDeviceAPIContext.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/driver/BlockDeviceAPIContext.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/fs/driver/BlockDeviceAPIContext.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -38,7 +38,7 @@ import org.jnode.test.support.Context; import org.jnode.test.support.TestConfig; -abstract public class BlockDeviceAPIContext extends Context { +public abstract class BlockDeviceAPIContext extends Context { protected static final Logger log = Logger .getLogger(BlockDeviceAPIContext.class); @@ -54,7 +54,7 @@ this.name = name; } - final public String getName() { + public final String getName() { return name; } @@ -139,7 +139,7 @@ } } - final public BlockDeviceAPI getApi() { + public final BlockDeviceAPI getApi() { return api; } Modified: trunk/fs/src/test/org/jnode/test/fs/driver/BlockDeviceAPITestConfig.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/driver/BlockDeviceAPITestConfig.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/fs/driver/BlockDeviceAPITestConfig.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -33,11 +33,10 @@ * @author Fabien DUMINY */ public class BlockDeviceAPITestConfig implements TestConfig { - final private static String DEVICE_SIZE_STR = "1M"; // may use multipliers + private static final String DEVICE_SIZE_STR = "1M"; // may use multipliers // (K, M, G) - final private static int DEVICE_SIZE = (int) NumberUtils - .getSize(DEVICE_SIZE_STR); + private static final int DEVICE_SIZE = (int) NumberUtils.getSize(DEVICE_SIZE_STR); private Class<?> contextClass; @@ -59,11 +58,11 @@ /** * @return */ - final public BlockDeviceAPI getBlockDeviceAPI() { + public final BlockDeviceAPI getBlockDeviceAPI() { return ((BlockDeviceAPIContext) ContextManager.getInstance().getContext()).getApi(); } - final public Class<?> getContextClass() { + public final Class<?> getContextClass() { return contextClass; } Modified: trunk/fs/src/test/org/jnode/test/fs/driver/context/FileDeviceContext.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/driver/context/FileDeviceContext.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/fs/driver/context/FileDeviceContext.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -30,7 +30,7 @@ import org.jnode.test.support.TestUtils; public class FileDeviceContext extends BlockDeviceAPIContext { - final private File f; + private final File f; public FileDeviceContext() throws IOException { super("FileDevice"); Modified: trunk/fs/src/test/org/jnode/test/fs/driver/factories/AbstractMockDeviceFactory.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/driver/factories/AbstractMockDeviceFactory.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/fs/driver/factories/AbstractMockDeviceFactory.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -32,7 +32,7 @@ public AbstractMockDeviceFactory() { } - final public void setTestCase(MockObjectTestCase testCase) { + public final void setTestCase(MockObjectTestCase testCase) { this.testCase = testCase; } } Modified: trunk/fs/src/test/org/jnode/test/fs/driver/stubs/StubDeviceManager.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/driver/stubs/StubDeviceManager.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/fs/driver/stubs/StubDeviceManager.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -82,7 +82,7 @@ /** * Start this manager */ - final public void start() { + public final void start() { // Thread thread = new Thread() // { // public void run() Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/AbstractFSTest.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/AbstractFSTest.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/AbstractFSTest.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -43,7 +43,7 @@ * @author Fabien DUMINY */ public abstract class AbstractFSTest extends JFuncTestCase { - final protected Logger log = Logger.getLogger(getClass()); + protected final Logger log = Logger.getLogger(getClass()); //public static final int FILE_SIZE_IN_WORDS = 256 * 1024; // 512 Ko = 256 K Words public static final int FILE_SIZE_IN_WORDS = 128; // 512 Ko = 128 K Words @@ -63,7 +63,7 @@ super(name); } - final protected void setUp(FSTestConfig config) throws NameNotFoundException, FileSystemException, IOException, + protected final void setUp(FSTestConfig config) throws NameNotFoundException, FileSystemException, IOException, InstantiationException, IllegalAccessException, Exception { super.setUp(); @@ -72,7 +72,7 @@ this.fs = config.getFileSystem().mount(this.device); } - final public void tearDown() throws Exception { + public final void tearDown() throws Exception { config.getDeviceParam().tearDown(device); super.tearDown(); } @@ -93,7 +93,7 @@ /** * @return Returns the fs. */ - final protected FileSystem getFs() { + protected final FileSystem getFs() { return fs; } @@ -125,7 +125,7 @@ * @param isRoot * @return */ - final protected String[] getEmptyDirNames(FSTestConfig config, boolean isRoot) { + protected final String[] getEmptyDirNames(FSTestConfig config, boolean isRoot) { return config.getFileSystem().getType().getEmptyDirNames(isRoot); } @@ -182,7 +182,7 @@ * @throws IllegalAccessException * @throws InstantiationException */ - final protected void remountFS(FSTestConfig config, boolean readOnly) + protected final void remountFS(FSTestConfig config, boolean readOnly) throws NameNotFoundException, IOException, FileSystemException, InstantiationException, IllegalAccessException { fs.close(); fs = config.getFileSystem().getType().mount(fs.getDevice(), readOnly); @@ -196,7 +196,7 @@ * @throws IOException * @throws FileSystemException */ - final protected byte[] addTestFile(String fileName, int fileSizeInWords) + protected final byte[] addTestFile(String fileName, int fileSizeInWords) throws Exception, IOException, FileSystemException { boolean oldReadOnly = config.isReadOnly(); Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/config/DeviceParam.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/config/DeviceParam.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/config/DeviceParam.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -41,13 +41,13 @@ * @return @throws * Exception */ - abstract public Device createDevice() throws Exception; + public abstract Device createDevice() throws Exception; /** * @param device * @throws Exception */ - abstract public void tearDown(Device device) throws Exception; + public abstract void tearDown(Device device) throws Exception; /** * @return Returns the input. @@ -59,7 +59,7 @@ /** * @param input The input to set. */ - final public void setInput(boolean input) { + public final void setInput(boolean input) { this.input = input; } } Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/config/FS.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/config/FS.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/config/FS.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -32,9 +32,9 @@ * @author Fabien DUMINY */ public class FS { - final private FSType type; - final private boolean readOnly; - final private Formatter<? extends FileSystem> formatter; + private final FSType type; + private final boolean readOnly; + private final Formatter<? extends FileSystem> formatter; public FS(FSType type, boolean readOnly, Formatter<? extends FileSystem> formatter) { this.type = type; Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/config/FSTestConfig.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/config/FSTestConfig.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/config/FSTestConfig.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -28,11 +28,11 @@ */ public class FSTestConfig { - final private DeviceParam deviceParam; + private final DeviceParam deviceParam; - final private OsType os; + private final OsType os; - final private FS fs; + private final FS fs; /** * Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/config/FSType.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/config/FSType.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/config/FSType.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -50,12 +50,12 @@ NTFS("ntfs", NTFSFileSystem.class, NTFSFileSystemType.class, new String[]{"."}); - final private Class<? extends FileSystem> fsClass; + private final Class<? extends FileSystem> fsClass; - final private Class<? extends FileSystemType> fsTypeClass; + private final Class<? extends FileSystemType> fsTypeClass; - final private String name; - final private String[] emptyDirNames; + private final String name; + private final String[] emptyDirNames; private FSType(String name, Class<? extends FileSystem> fsClass, Class<? extends FileSystemType> fsTypeClass, Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/ConcurrentAccessFSTest.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/ConcurrentAccessFSTest.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/ConcurrentAccessFSTest.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -217,7 +217,7 @@ protected abstract void doRun(long offset) throws IOException; - final public void run() { + public final void run() { long length = file.getLength(); try { for (int i = start; i < (length - 1); i += step) { Modified: trunk/fs/src/test/org/jnode/test/support/AbstractTest.java =================================================================== --- trunk/fs/src/test/org/jnode/test/support/AbstractTest.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/support/AbstractTest.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -86,7 +86,7 @@ log.info("END " + testName); // marker for log4j traces } - final protected TestConfig getTestConfig() { + protected final TestConfig getTestConfig() { if (testConfig == null) { testConfig = ConfigManager.getInstance().getConfig(configClazz, getClass(), getName()); } @@ -94,7 +94,7 @@ return testConfig; } - final public void runTest() throws Throwable { + public final void runTest() throws Throwable { try { super.runTest(); } catch (Throwable t) { @@ -116,14 +116,14 @@ // return name; // } - final public void setName(String name) { + public final void setName(String name) { if (testConfig != null) { name += "[" + testConfig.getName() + "]"; } super.setName(name); } - final protected String getTestName() { + protected final String getTestName() { return getClass().getName() + "." + getName(); // className.methodName } } Modified: trunk/fs/src/test/org/jnode/test/support/AbstractTestSuite.java =================================================================== --- trunk/fs/src/test/org/jnode/test/support/AbstractTestSuite.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/support/AbstractTestSuite.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -25,7 +25,7 @@ import junit.framework.TestSuite; import org.apache.log4j.Logger; -abstract public class AbstractTestSuite extends TestSuite { +public abstract class AbstractTestSuite extends TestSuite { public AbstractTestSuite() { ContextManager.getInstance().init(); init(); @@ -35,7 +35,7 @@ * Add a TestSuite containing TestSuites * (for each couple (config, TestSuite class)) */ - final public void init() { + public final void init() { List<TestConfig> configs = getConfigs(); Class[] testSuites = getTestSuites(); log.info(configs.size() + " configs, " + @@ -55,12 +55,12 @@ /** * @return a list of TestConfig(s) */ - abstract public List<TestConfig> getConfigs(); + public abstract List<TestConfig> getConfigs(); /** * @return an array of TestSuite classes */ - abstract public Class[] getTestSuites(); + public abstract Class[] getTestSuites(); protected final Logger log = Logger.getLogger(getClass().getName()); } Modified: trunk/fs/src/test/org/jnode/test/support/ConfigManager.java =================================================================== --- trunk/fs/src/test/org/jnode/test/support/ConfigManager.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/support/ConfigManager.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -32,13 +32,13 @@ public class ConfigManager { private static final Logger log = Logger.getLogger(ConfigManager.class); - static private ConfigManager instance; - static private boolean log4jInitialized = false; + private static ConfigManager instance; + private static boolean log4jInitialized = false; private Map<Class, List<TestConfig>> configs; private Map<TestKey, Iterator<TestConfig>> iterators; - static public ConfigManager getInstance() { + public static ConfigManager getInstance() { if (instance == null) { instance = new ConfigManager(); } @@ -78,7 +78,7 @@ ContextManager.getInstance().init(); } - static private class TestKey { + private static class TestKey { private Class clazz; private String testName; Modified: trunk/fs/src/test/org/jnode/test/support/Context.java =================================================================== --- trunk/fs/src/test/org/jnode/test/support/Context.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/support/Context.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -23,8 +23,8 @@ import org.jmock.MockObjectTestCase; -abstract public class Context { - abstract public void init(TestConfig config, MockObjectTestCase testCase) throws Exception; +public abstract class Context { + public abstract void init(TestConfig config, MockObjectTestCase testCase) throws Exception; - abstract public void destroy() throws Exception; + public abstract void destroy() throws Exception; } Modified: trunk/fs/src/test/org/jnode/test/support/ContextManager.java =================================================================== --- trunk/fs/src/test/org/jnode/test/support/ContextManager.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/support/ContextManager.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -47,7 +47,7 @@ private boolean initialized = false; private Context context; - static public ContextManager getInstance() { + public static ContextManager getInstance() { if (instance == null) { instance = new ContextManager(); } Modified: trunk/fs/src/test/org/jnode/test/support/MockUtils.java =================================================================== --- trunk/fs/src/test/org/jnode/test/support/MockUtils.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/support/MockUtils.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -27,11 +27,11 @@ public class MockUtils { private static final Logger log = Logger.getLogger(MockUtils.class); - static public <T> T createMockObject(Class<T> name) { + public static <T> T createMockObject(Class<T> name) { return createMockObject(name, null); } - static public <T> T createMockObject(Class<T> name, MockInitializer initializer) { + public static <T> T createMockObject(Class<T> name, MockInitializer initializer) { String shortName = getShortName(name); Mock mock = new Mock(name, shortName); log.info("created a Mock for " + shortName); @@ -43,11 +43,11 @@ return name.cast(mock.proxy()); } - static public Object createMockObject(Class name, Class[] clsArgs, Object[] args) { + public static Object createMockObject(Class name, Class[] clsArgs, Object[] args) { return createMockObject(name, null, clsArgs, args); } - static public Object createMockObject(Class name, MockInitializer initializer, Class[] clsArgs, Object[] args) { + public static Object createMockObject(Class name, MockInitializer initializer, Class[] clsArgs, Object[] args) { String shortName = getShortName(name); CGLibCoreMockExt cglibMock = new CGLibCoreMockExt(name, shortName); Mock mock = new Mock(cglibMock); @@ -60,7 +60,7 @@ return cglibMock.createProxy(clsArgs, args); } - static public String getShortName(Class<?> clazz) { + public static String getShortName(Class<?> clazz) { String name = clazz.getName(); int idx = name.lastIndexOf('.'); return (idx >= 0) ? name.substring(idx + 1) : name; Modified: trunk/fs/src/test/org/jnode/test/support/TestUtils.java =================================================================== --- trunk/fs/src/test/org/jnode/test/support/TestUtils.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/fs/src/test/org/jnode/test/support/TestUtils.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -57,7 +57,7 @@ * @return * @throws IOException */ - static public File makeTempFile(String filename, String size) + public static File makeTempFile(String filename, String size) throws IOException { File tempFile = File.createTempFile(filename, ""); tempFile.deleteOnExit(); @@ -65,7 +65,7 @@ return makeFile(tempFile.getAbsolutePath(), NumberUtils.getSize(size)); } - static public File makeFile(String filename, long size) throws IOException { + public static File makeFile(String filename, long size) throws IOException { byte[] buf = new byte[1024]; File file = new File(filename); FileOutputStream output = new FileOutputStream(file); @@ -85,7 +85,7 @@ return file; } - static public void listEntries(Iterator<? extends FSEntry> iterator) throws Exception { + public static void listEntries(Iterator<? extends FSEntry> iterator) throws Exception { log.debug("<<< BEGIN listEntries >>>"); int i = 0; log.debug("------- entries ------"); @@ -98,7 +98,7 @@ log.debug("<<< END listEntries >>>"); } - static public List<String> getEntryNames(Iterator<? extends FSEntry> it) { + public static List<String> getEntryNames(Iterator<? extends FSEntry> it) { List<String> names = new ArrayList<String>(); while (it.hasNext()) { FSEntry entry = it.next(); @@ -107,7 +107,7 @@ return names; } - static public String toString(String filename, int offset, int length) + public static String toString(String filename, int offset, int length) throws IOException { // byte[] buf = new byte[1024]; File file = new File(filename); @@ -119,7 +119,7 @@ return dump; } - static public String toString(String[] array) { + public static String toString(String[] array) { StringBuffer sb = new StringBuffer("["); if (array != null) { @@ -136,7 +136,7 @@ return sb.toString(); } - static public String toString(List<String> list) { + public static String toString(List<String> list) { StringBuffer sb = new StringBuffer("["); for (int i = 0; i < list.size(); i++) { @@ -151,13 +151,13 @@ return sb.toString(); } - static public File copyFile(String srcFile, String destFile) + public static File copyFile(String srcFile, String destFile) throws SecurityException, IOException { return copyInputStreamToFile(new FileInputStream(new File(srcFile)), destFile); } - static public File copyInputStreamToFile(InputStream src, String destFile) + public static File copyInputStreamToFile(InputStream src, String destFile) throws SecurityException, IOException { File dest = new File(destFile); @@ -190,7 +190,7 @@ return dest; } - static public File copyDeviceToFile(Device imageDevice, String destFile) + public static File copyDeviceToFile(Device imageDevice, String destFile) throws SecurityException, IOException, ApiNotFoundException { File dest = new File(destFile); BlockDeviceAPI imgApi = imageDevice @@ -303,10 +303,10 @@ * null) fs.close(); } return imageFile; } */ /* - * static public void deleteFile(TestConfig config, FileDevice device) { new + * public static void deleteFile(TestConfig config, FileDevice device) { new * File(device.getFileName()).delete(); } */ - static public String[] append(String[] a1, String[] a2) { + public static String[] append(String[] a1, String[] a2) { if (a1 == null) return a2; if (a2 == null) @@ -319,7 +319,7 @@ return a; } - static public byte[] getTestData(int lengthInWords) { + public static byte[] getTestData(int lengthInWords) { byte[] data = new byte[lengthInWords * 2]; int index = 0; for (int i = 0; i < lengthInWords; i++) { @@ -333,7 +333,7 @@ return data; } - static public boolean equals(byte[] origData, byte[] data) { + public static boolean equals(byte[] origData, byte[] data) { // return Arrays.equals(origData, data); if (origData == data) return true; @@ -360,7 +360,7 @@ return true; } - static public RamDiskDevice createRamDisk(int size) { + public static RamDiskDevice createRamDisk(int size) { RamDiskDevice dev = null; try { final DeviceManager dm = InitialNaming @@ -393,7 +393,7 @@ * @return * @throws Exception */ - static public Object newInstance(String className, Class<?> cls) + public static Object newInstance(String className, Class<?> cls) throws Exception { Class<?> clazz = Class.forName(className); Object instance = clazz.newInstance(); @@ -404,5 +404,5 @@ return instance; } - static private final Logger log = Logger.getLogger(TestUtils.class); + private static final Logger log = Logger.getLogger(TestUtils.class); } Modified: trunk/gui/src/awt/org/jnode/awt/JNodeRobotPeer.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/JNodeRobotPeer.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/awt/org/jnode/awt/JNodeRobotPeer.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -174,7 +174,7 @@ * @param keycode * @param pressed true=key pressed, false=key released */ - final private void sendKeyboardEvent(int keycode, boolean pressed) { + private void sendKeyboardEvent(int keycode, boolean pressed) { final KeyboardHandler kbHandler = getToolkitImpl().getKeyboardHandler(); final KeyboardAPI api = kbHandler.getKeyboardAPI(); final KeyboardInterpreter kbInt = api.getKbInterpreter(); Modified: trunk/gui/src/awt/org/jnode/awt/JNodeToolkit.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/JNodeToolkit.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/awt/org/jnode/awt/JNodeToolkit.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -985,19 +985,19 @@ return new ImageProducer() { Set<ImageConsumer> consumers = new HashSet<ImageConsumer>(); - synchronized public void addConsumer(ImageConsumer ic) { + public synchronized void addConsumer(ImageConsumer ic) { consumers.add(ic); } - synchronized public boolean isConsumer(ImageConsumer ic) { + public synchronized boolean isConsumer(ImageConsumer ic) { return consumers.contains(ic); } - synchronized public void removeConsumer(ImageConsumer ic) { + public synchronized void removeConsumer(ImageConsumer ic) { consumers.remove(ic); } - synchronized public void startProduction(ImageConsumer ic) { + public synchronized void startProduction(ImageConsumer ic) { consumers.add(ic); for (ImageConsumer c : consumers) { c.imageComplete(ImageConsumer.IMAGEERROR); Modified: trunk/gui/src/awt/org/jnode/awt/font/bdf/BDFTextRenderer.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/font/bdf/BDFTextRenderer.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/awt/org/jnode/awt/font/bdf/BDFTextRenderer.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -64,7 +64,7 @@ * @param color string color * @see java.awt.Graphics */ - final public void render(Surface surface, Shape clip, AffineTransform tx, + public final void render(Surface surface, Shape clip, AffineTransform tx, CharSequence str, int x, int y, Color color) { if (str == null || str.length() == 0) return; Modified: trunk/gui/src/awt/org/jnode/awt/font/renderer/RenderCache.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/font/renderer/RenderCache.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/awt/org/jnode/awt/font/renderer/RenderCache.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -28,7 +28,7 @@ /** * @author Ewout Prangsma (ep...@us...) */ -final public class RenderCache { +public final class RenderCache { /** * The current rendering context Modified: trunk/gui/src/awt/org/jnode/awt/font/spi/AbstractFontProvider.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/font/spi/AbstractFontProvider.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/awt/org/jnode/awt/font/spi/AbstractFontProvider.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -39,7 +39,7 @@ * @author epr * @author Fabien DUMINY (fd...@jn...) */ -abstract public class AbstractFontProvider implements FontProvider { +public abstract class AbstractFontProvider implements FontProvider { /** * My logger @@ -83,7 +83,7 @@ * Give the name of the font (used for setting the first provider to use * among all available ones) */ - final public String getName() { + public final String getName() { return name; } @@ -94,7 +94,7 @@ * @param font * @return True if this provider provides the given font, false otherwise */ - final public boolean provides(Font font) { + public final boolean provides(Font font) { if (font == null) return false; // don't provide default (null) fonts if (!fontsLoaded) { @@ -117,7 +117,7 @@ * * @return The set containing all fonts provides by this provider. */ - final public Set<Font> getAllFonts() { + public final Set<Font> getAllFonts() { if (!fontsLoaded) { loadFonts(); } @@ -130,7 +130,7 @@ * @param font * @return The renderer */ - final public TextRenderer getTextRenderer(Font font) { + public final TextRenderer getTextRenderer(Font font) { TextRenderer r = (TextRenderer) renderers.get(font); if (r == null) { r = createTextRenderer(renderCache, font); @@ -139,7 +139,7 @@ return r; } - abstract protected TextRenderer createTextRenderer(RenderCache renderCache, Font font); + protected abstract TextRenderer createTextRenderer(RenderCache renderCache, Font font); /** * Gets the font metrics for the given font. @@ -147,7 +147,7 @@ * @param font * @return The metrics */ - final public FontMetrics getFontMetrics(Font font) { + public final FontMetrics getFontMetrics(Font font) { FontMetrics fm = (FontMetrics) metrics.get(font); /* if(log.isDebugEnabled()) log.debug("FontMetrics got from cache: "+fm+" font="+font); @@ -166,13 +166,13 @@ return fm; } - abstract protected FontMetrics createFontMetrics(Font font) throws IOException; + protected abstract FontMetrics createFontMetrics(Font font) throws IOException; - abstract protected String[] getSystemFonts(); + protected abstract String[] getSystemFonts(); - abstract protected Font loadFont(URL url) throws IOException; + protected abstract Font loadFont(URL url) throws IOException; - final protected Font getCompatibleFont(Font font) { + protected final Font getCompatibleFont(Font font) { Font f = null; try { f = fontsByName.get(font.getFamily()); Modified: trunk/gui/src/awt/org/jnode/awt/font/spi/AbstractTextRenderer.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/font/spi/AbstractTextRenderer.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/awt/org/jnode/awt/font/spi/AbstractTextRenderer.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -40,7 +40,7 @@ * @author epr * @author Fabien DUMINY (fd...@jn...) */ -abstract public class AbstractTextRenderer implements TextRenderer { +public abstract class AbstractTextRenderer implements TextRenderer { /** * My logger @@ -76,7 +76,7 @@ * * @return */ - final protected WritableRaster createAlphaRaster() { + protected final WritableRaster createAlphaRaster() { final RenderContext ctx = renderCache.getContext(); WritableRaster r = (WritableRaster) ctx.getObject(ALPHA_RASTER); final int fontSizeUp = (int) (fontMetrics.getFont().getSize() + 0.5); Modified: trunk/gui/src/awt/org/jnode/awt/font/spi/Glyph.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/font/spi/Glyph.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/awt/org/jnode/awt/font/spi/Glyph.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -46,7 +46,7 @@ this.yMax = yMax; } - final public Rectangle getBBox() { + public final Rectangle getBBox() { return new Rectangle(xMin, yMin, xMax - xMin, yMax - yMin); } Modified: trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingToolkit.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingToolkit.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingToolkit.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -117,7 +117,7 @@ * @param awtComponent * @param peer */ - final static void copyAwtProperties(Component awtComponent, Component peer) { + static void copyAwtProperties(Component awtComponent, Component peer) { Color c; Font f; if ((c = awtComponent.getForeground()) != null) { Modified: trunk/gui/src/awt/org/jnode/awt/util/AbstractBitmapGraphics.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/util/AbstractBitmapGraphics.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/awt/org/jnode/awt/util/AbstractBitmapGraphics.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -55,7 +55,7 @@ this.height = height; } - abstract protected int getOffset(int x, int y); + protected abstract int getOffset(int x, int y); /** @@ -256,7 +256,7 @@ } } - abstract protected int getBytesForWidth(int width); + protected abstract int getBytesForWidth(int width); protected abstract void doDrawAlphaRaster(Raster raster, int srcX, int srcY, int dstX, int dstY, int width, int height, int color); Modified: trunk/gui/src/awt/org/jnode/awt/util/BitmapGraphics.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/util/BitmapGraphics.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/awt/org/jnode/awt/util/BitmapGraphics.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -41,9 +41,9 @@ */ public abstract class BitmapGraphics { - abstract public int getWidth(); + public abstract int getWidth(); - abstract public int getHeight(); + public abstract int getHeight(); /** * @see org.jnode.driver.video.Surface#copyArea(int, int, int, int, int, Modified: trunk/gui/src/desktop/org/jnode/desktop/ApplicationBar.java =================================================================== --- trunk/gui/src/desktop/org/jnode/desktop/ApplicationBar.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/desktop/org/jnode/desktop/ApplicationBar.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -42,11 +42,11 @@ */ public class ApplicationBar extends JPanel { - final static Logger log = Logger.getLogger(ApplicationBar.class); + static final Logger log = Logger.getLogger(ApplicationBar.class); private final ExtensionPoint ep; - private final static Class[] mainTypes = {String[].class}; + private static final Class[] mainTypes = {String[].class}; public ApplicationBar(ExtensionPoint ep) { this.ep = ep; Modified: trunk/gui/src/desktop/org/jnode/desktop/Desktop.java =================================================================== --- trunk/gui/src/desktop/org/jnode/desktop/Desktop.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/desktop/org/jnode/desktop/Desktop.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -47,7 +47,7 @@ */ public class Desktop implements Runnable { - final static Logger log = Logger.getLogger(Desktop.class); + static final Logger log = Logger.getLogger(Desktop.class); ControlBar controlBar; Modified: trunk/gui/src/desktop/org/jnode/desktop/WindowBar.java =================================================================== --- trunk/gui/src/desktop/org/jnode/desktop/WindowBar.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/desktop/org/jnode/desktop/WindowBar.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -40,7 +40,7 @@ */ public class WindowBar extends JPanel { - private final static Logger log = Logger.getLogger(WindowBar.class); + private static final Logger log = Logger.getLogger(WindowBar.class); private final JList list; private final DefaultListModel model; Modified: trunk/gui/src/desktop/org/jnode/desktop/classic/Desktop.java =================================================================== --- trunk/gui/src/desktop/org/jnode/desktop/classic/Desktop.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/desktop/org/jnode/desktop/classic/Desktop.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -62,7 +62,7 @@ */ public class Desktop implements Runnable { - final static Logger log = Logger.getLogger(Desktop.class); + static final Logger log = Logger.getLogger(Desktop.class); TaskBar taskBar; JPopupMenu desktopMenu; Modified: trunk/gui/src/desktop/org/jnode/desktop/classic/TaskBar.java =================================================================== --- trunk/gui/src/desktop/org/jnode/desktop/classic/TaskBar.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/desktop/org/jnode/desktop/classic/TaskBar.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -59,8 +59,8 @@ * @author Levente S\u00e1ntha */ public class TaskBar extends JPanel { - final static Logger log = Logger.getLogger(TaskBar.class); - private final static Class[] mainTypes = {String[].class}; + static final Logger log = Logger.getLogger(TaskBar.class); + private static final Class[] mainTypes = {String[].class}; JButton startButton; JPopupMenu startMenu; WindowBar windowBar; Modified: trunk/gui/src/desktop/org/jnode/desktop/classic/WindowBar.java =================================================================== --- trunk/gui/src/desktop/org/jnode/desktop/classic/WindowBar.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/desktop/org/jnode/desktop/classic/WindowBar.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -50,7 +50,7 @@ * @author Levente S\u00e1ntha */ public class WindowBar extends JPanel { - private final static Logger log = Logger.getLogger(WindowBar.class); + private static final Logger log = Logger.getLogger(WindowBar.class); private final Map<JInternalFrame, FrameWrapper> wrappers; public WindowBar() { Modified: trunk/gui/src/test/org/jnode/test/gui/AWTDemo.java =================================================================== --- trunk/gui/src/test/org/jnode/test/gui/AWTDemo.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/test/org/jnode/test/gui/AWTDemo.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -88,7 +88,7 @@ } } - static abstract class PrettyFrame extends Frame { + abstract static class PrettyFrame extends Frame { public PrettyFrame() { ((BorderLayout) getLayout()).setHgap(5); ((BorderLayout) getLayout()).setVgap(5); @@ -101,7 +101,7 @@ } } - static abstract class SubFrame extends PrettyFrame implements SubWindow { + abstract static class SubFrame extends PrettyFrame implements SubWindow { boolean initted = false; public void setVisible(boolean visible) { Modified: trunk/gui/src/test/org/jnode/test/gui/Emu.java =================================================================== --- trunk/gui/src/test/org/jnode/test/gui/Emu.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/test/org/jnode/test/gui/Emu.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -139,7 +139,7 @@ /** * Start this manager */ - final public void start() { + public final void start() { // Thread thread = new Thread() // { // public void run() Modified: trunk/gui/src/test/org/jnode/test/gui/ImageTest.java =================================================================== --- trunk/gui/src/test/org/jnode/test/gui/ImageTest.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/test/org/jnode/test/gui/ImageTest.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -35,7 +35,7 @@ */ public class ImageTest { - final static String IMAGE_PATH = "/org/zaval/lw/rs/img/tree.gif"; + static final String IMAGE_PATH = "/org/zaval/lw/rs/img/tree.gif"; static class TestComponent extends Component implements ImageObserver { Modified: trunk/gui/src/test/org/jnode/test/gui/Tetris.java =================================================================== --- trunk/gui/src/test/org/jnode/test/gui/Tetris.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/gui/src/test/org/jnode/test/gui/Tetris.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -98,7 +98,7 @@ private static final int HEIGHT_C = 20; - private final static Color[] COLORS = {Color.BLACK, Color.YELLOW, + private static final Color[] COLORS = {Color.BLACK, Color.YELLOW, Color.RED, Color.CYAN, Color.BLUE, Color.MAGENTA, Color.ORANGE, Color.LIGHT_GRAY, Color.DARK_GRAY}; Modified: trunk/shell/src/test/org/jnode/test/shell/DeviceManager.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/DeviceManager.java 2008-06-03 14:02:38 UTC (rev 4186) +++ trunk/shell/src/test/org/jnode/test/shell/DeviceManager.java 2008-06-04 08:26:35 UTC (rev 4187) @@ -62,7 +62,7 @@ /** * Start this manager */ - final public void start() { + public final void start() { // Thread thread = new Thread() // { // public void run() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2008-06-07 13:20:43
|
Revision: 4210 http://jnode.svn.sourceforge.net/jnode/?rev=4210&view=rev Author: crawley Date: 2008-06-07 06:20:39 -0700 (Sat, 07 Jun 2008) Log Message: ----------- checkstyle changes Modified Paths: -------------- trunk/all/build.xml trunk/fs/src/fs/org/jnode/fs/ramfs/RAMDirectory.java trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFile.java trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystem.java trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystemType.java trunk/fs/src/fs/org/jnode/fs/ramfs/def/RAMFSPlugin.java trunk/fs/src/fs/org/jnode/fs/service/FileSystemService.java trunk/fs/src/fs/org/jnode/fs/service/def/FSEntryCache.java trunk/fs/src/fs/org/jnode/fs/service/def/FileHandleImpl.java trunk/fs/src/fs/org/jnode/fs/service/def/FileHandleManager.java trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemManager.java trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemMounter.java trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemPlugin.java trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemTypeManager.java trunk/fs/src/fs/org/jnode/fs/service/def/VirtualDirEntry.java trunk/fs/src/fs/org/jnode/fs/service/def/VirtualFS.java trunk/fs/src/fs/org/jnode/fs/service/def/VirtualFSDevice.java trunk/fs/src/fs/org/jnode/fs/service/def/VirtualMountEntry.java trunk/fs/src/fs/org/jnode/fs/smbfs/Format.java trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSDriver.java trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java trunk/fs/src/fs/org/jnode/fs/smbfs/SmbShell.java trunk/fs/src/fs/org/jnode/fs/spi/AbstractFSDirectory.java trunk/fs/src/fs/org/jnode/fs/spi/AbstractFSEntry.java trunk/fs/src/fs/org/jnode/fs/spi/AbstractFSFile.java trunk/fs/src/fs/org/jnode/fs/spi/AbstractFSObject.java trunk/fs/src/fs/org/jnode/fs/spi/AbstractFileSystem.java trunk/fs/src/fs/org/jnode/fs/spi/FSEntryTable.java trunk/fs/src/fs/org/jnode/fs/spi/UnixFSAccessRights.java trunk/fs/src/fs/org/jnode/fs/util/DosUtils.java trunk/fs/src/fs/org/jnode/fs/util/FSUtils.java trunk/fs/src/fs/org/jnode/partitions/PartitionTable.java trunk/fs/src/fs/org/jnode/partitions/PartitionTableEntry.java trunk/fs/src/fs/org/jnode/partitions/PartitionTableException.java trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java trunk/fs/src/fs/org/jnode/partitions/command/PartitionHelper.java trunk/fs/src/fs/org/jnode/partitions/ibm/IBMPartitionTable.java trunk/fs/src/fs/org/jnode/partitions/ibm/IBMPartitionTableEntry.java trunk/fs/src/fs/org/jnode/partitions/ibm/IBMPartitionTypes.java trunk/fs/src/fs/org/jnode/partitions/ibm/MasterBootRecord.java trunk/fs/src/fs/org/jnode/partitions/service/def/PartitionTablePlugin.java trunk/fs/src/fs/org/jnode/partitions/service/def/PartitionTableTypeManager.java Added Paths: ----------- trunk/fs/src/fs/org/jnode/partitions/command/IBMPartitionTypeArgument.java Removed Paths: ------------- trunk/fs/src/fs/org/jnode/partitions/help/ Modified: trunk/all/build.xml =================================================================== --- trunk/all/build.xml 2008-06-07 11:48:31 UTC (rev 4209) +++ trunk/all/build.xml 2008-06-07 13:20:39 UTC (rev 4210) @@ -884,6 +884,7 @@ <fileset dir="../core/src/core" includes="**/*.java"/> <fileset dir="../core/src/driver" includes="**/*.java"/> <fileset dir="../core/src/test" includes="**/*.java"/> + <fileset dir="../fs/src/fs" includes="**/*.java"/> <fileset dir="../fs/src/driver" includes="**/*.java"/> <fileset dir="../fs/src/test" includes="**/*.java"/> <fileset dir="../gui/src/test" includes="**/*.java"/> Modified: trunk/fs/src/fs/org/jnode/fs/ramfs/RAMDirectory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ramfs/RAMDirectory.java 2008-06-07 11:48:31 UTC (rev 4209) +++ trunk/fs/src/fs/org/jnode/fs/ramfs/RAMDirectory.java 2008-06-07 13:20:39 UTC (rev 4210) @@ -4,7 +4,6 @@ import java.util.HashMap; import java.util.Iterator; -import org.apache.log4j.Logger; import org.jnode.fs.FSAccessRights; import org.jnode.fs.FSDirectory; import org.jnode.fs.FSEntry; @@ -18,232 +17,247 @@ */ public class RAMDirectory implements FSEntry, FSDirectory { - /** Logger */ - private static final Logger log = Logger.getLogger(RAMDirectory.class); + private RAMFileSystem filesystem; - private RAMFileSystem filesystem; - - private RAMDirectory parent; - private String directoryName; - - private long lastModified; - private FSAccessRights accessRights; + private RAMDirectory parent; + private String directoryName; - /* if file is deleted, it is no longer valid */ - private boolean isValid = true; - - private HashMap<String, FSEntry> entries; - - /** - * Constructor for a new RAMDirectory - * - * @param fs - * @param parent - * @param name - */ - public RAMDirectory(final RAMFileSystem fs, final RAMDirectory parent, final String name) { - - this.filesystem = fs; - this.parent = parent; - - this.directoryName = name; - this.lastModified = System.currentTimeMillis(); - - // TODO: accessRights - - entries = new HashMap<String, FSEntry>(); - } + private long lastModified; + private FSAccessRights accessRights; - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#getName() - */ - public String getName() { - return directoryName; - } + /* if file is deleted, it is no longer valid */ + private boolean isValid = true; - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#getParent() - */ - public FSDirectory getParent() { - return parent; - } + private HashMap<String, FSEntry> entries; - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#getLastModified() - */ - public long getLastModified() throws IOException { - return lastModified; - } + /** + * Constructor for a new RAMDirectory + * + * @param fs + * @param parent + * @param name + */ + public RAMDirectory(final RAMFileSystem fs, final RAMDirectory parent, final String name) { - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#isFile() - */ - public boolean isFile() { - return false; - } + this.filesystem = fs; + this.parent = parent; - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#isDirectory() - */ - public boolean isDirectory() { - return true; - } + this.directoryName = name; + this.lastModified = System.currentTimeMillis(); - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#setName(java.lang.String) - */ - public void setName(String newName) throws IOException { - // TODO: check for special chars / normalize name - directoryName = newName; - } + // TODO: accessRights - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#setLastModified(long) - */ - public void setLastModified(long lastModified) throws IOException { - this.lastModified = lastModified; - } + entries = new HashMap<String, FSEntry>(); + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#getFile() - */ - public FSFile getFile() throws IOException { - throw new IOException("Not a file"); - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#getName() + */ + public String getName() { + return directoryName; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#getDirectory() - */ - public FSDirectory getDirectory() throws IOException { - return this; - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#getParent() + */ + public FSDirectory getParent() { + return parent; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#getAccessRights() - */ - public FSAccessRights getAccessRights() throws IOException { - return accessRights; - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#getLastModified() + */ + public long getLastModified() throws IOException { + return lastModified; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#isDirty() - */ - public boolean isDirty() throws IOException { - return false; - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#isFile() + */ + public boolean isFile() { + return false; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSObject#isValid() - */ - public boolean isValid() { - return isValid; - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#isDirectory() + */ + public boolean isDirectory() { + return true; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSObject#getFileSystem() - */ - public FileSystem getFileSystem() { - return filesystem; - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#setName(java.lang.String) + */ + public void setName(String newName) throws IOException { + // TODO: check for special chars / normalize name + directoryName = newName; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSDirectory#iterator() - */ - public Iterator<? extends FSEntry> iterator() throws IOException { - return entries.values().iterator(); - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#setLastModified(long) + */ + public void setLastModified(long lastModified) throws IOException { + this.lastModified = lastModified; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSDirectory#getEntry(java.lang.String) - */ - public FSEntry getEntry(String name) throws IOException { - return entries.get(name); - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#getFile() + */ + public FSFile getFile() throws IOException { + throw new IOException("Not a file"); + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSDirectory#addFile(java.lang.String) - */ - public FSEntry addFile(String name) throws IOException { - RAMFile file = new RAMFile(this, name); - entries.put(name, file); + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#getDirectory() + */ + public FSDirectory getDirectory() throws IOException { + return this; + } + + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#getAccessRights() + */ + public FSAccessRights getAccessRights() throws IOException { + return accessRights; + } + + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#isDirty() + */ + public boolean isDirty() throws IOException { + return false; + } + + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSObject#isValid() + */ + public boolean isValid() { + return isValid; + } + + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSObject#getFileSystem() + */ + public FileSystem getFileSystem() { + return filesystem; + } + + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSDirectory#iterator() + */ + public Iterator<? extends FSEntry> iterator() throws IOException { + return entries.values().iterator(); + } + + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSDirectory#getEntry(java.lang.String) + */ + public FSEntry getEntry(String name) throws IOException { + return entries.get(name); + } + + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSDirectory#addFile(java.lang.String) + */ + public FSEntry addFile(String name) throws IOException { + RAMFile file = new RAMFile(this, name); + entries.put(name, file); setLastModified(System.currentTimeMillis()); return file; - } + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSDirectory#addDirectory(java.lang.String) - */ - public FSEntry addDirectory(String name) throws IOException { - RAMDirectory dir = new RAMDirectory(filesystem, this, name); - entries.put(name, dir); + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSDirectory#addDirectory(java.lang.String) + */ + public FSEntry addDirectory(String name) throws IOException { + RAMDirectory dir = new RAMDirectory(filesystem, this, name); + entries.put(name, dir); setLastModified(System.currentTimeMillis()); return dir; - } + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSDirectory#remove(java.lang.String) - */ - public void remove(String name) throws IOException { + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSDirectory#remove(java.lang.String) + */ + public void remove(String name) throws IOException { - FSEntry entry = entries.remove(name); + FSEntry entry = entries.remove(name); - if (entry == null) - throw new IOException("Entry not found"); - - if (entry instanceof RAMFile) { - RAMFile file = (RAMFile) entry; - file.remove(); + if (entry == null) + throw new IOException("Entry not found"); + + if (entry instanceof RAMFile) { + RAMFile file = (RAMFile) entry; + file.remove(); setLastModified(System.currentTimeMillis()); } else { - RAMDirectory dir = (RAMDirectory) entry; - dir.remove(); + RAMDirectory dir = (RAMDirectory) entry; + dir.remove(); setLastModified(System.currentTimeMillis()); } - } - - /** - * removes the directory and all entries inside that directory - * - * @throws IOException - */ - private void remove() throws IOException { - Iterator<FSEntry> itr = entries.values().iterator(); - while (itr.hasNext()) { - FSEntry entry = itr.next(); - if (entry instanceof RAMFile) { - RAMFile file = (RAMFile) entry; - file.remove(); - } else { - RAMDirectory dir = (RAMDirectory) entry; - dir.remove(); - } - } - parent = null; - } + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSDirectory#flush() - */ - public void flush() throws IOException { - // nothing todo here - } + /** + * removes the directory and all entries inside that directory + * + * @throws IOException + */ + private void remove() throws IOException { + Iterator<FSEntry> itr = entries.values().iterator(); + while (itr.hasNext()) { + FSEntry entry = itr.next(); + if (entry instanceof RAMFile) { + RAMFile file = (RAMFile) entry; + file.remove(); + } else { + RAMDirectory dir = (RAMDirectory) entry; + dir.remove(); + } + } + parent = null; + } + + /** + * (non-Javadoc) + * @see org.jnode.fs.FSDirectory#flush() + */ + public void flush() throws IOException { + // nothing todo here + } } Modified: trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFile.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFile.java 2008-06-07 11:48:31 UTC (rev 4209) +++ trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFile.java 2008-06-07 13:20:39 UTC (rev 4210) @@ -3,7 +3,6 @@ import java.io.IOException; import java.nio.ByteBuffer; -import org.apache.log4j.Logger; import org.jnode.fs.FSAccessRights; import org.jnode.fs.FSDirectory; import org.jnode.fs.FSEntry; @@ -18,259 +17,273 @@ */ public class RAMFile implements FSEntry, FSFile { - /** Logger*/ - private static final Logger log = Logger.getLogger(RAMFile.class); + private RAMFileSystem fileSystem; + private RAMDirectory parent; - private RAMFileSystem fileSystem; - private RAMDirectory parent; + private String filename; + private ByteBuffer buffer; - private String filename; - private ByteBuffer buffer; + private long lastModified; + private FSAccessRights accessRights; - private long lastModified; - private FSAccessRights accessRights; + private boolean isValid = true; - private boolean isValid = true; - - /** - * Constructor for a new RAMFile - * @param parent - * @param filename - */ - public RAMFile(RAMDirectory parent, String filename) { - this.parent = parent; - this.filename = filename; - this.lastModified = System.currentTimeMillis(); - - // TODO accessRights - - buffer = ByteBuffer.allocate(128); - buffer.limit(0); - - fileSystem = (RAMFileSystem) parent.getFileSystem(); - - fileSystem.addSummmedBufferSize(128); - } + /** + * Constructor for a new RAMFile + * + * @param parent + * @param filename + */ + public RAMFile(RAMDirectory parent, String filename) { + this.parent = parent; + this.filename = filename; + this.lastModified = System.currentTimeMillis(); - - private void enlargeBuffer() throws FileSystemFullException { - - int oldCapacity = buffer.capacity(); - - if (oldCapacity > fileSystem.getFreeSpace()) - throw new FileSystemFullException("RAMFileSystem reached maxSize"); - - ByteBuffer temp = ByteBuffer.allocate(oldCapacity * 2); - buffer.position(0); - temp.put(buffer); - buffer = temp; - buffer.position(0); + // TODO accessRights - // update fileSystem values - fileSystem.addSummmedBufferSize(oldCapacity); - } - - private void shrinkBuffer() { - - int toShrink = buffer.capacity() / 2; - - ByteBuffer temp = ByteBuffer.allocate(toShrink); - temp.put(buffer.array(), 0, toShrink); - buffer = temp; - buffer.position(0); - - // update fileSystem counter - fileSystem.addSummmedBufferSize(-toShrink); - } + buffer = ByteBuffer.allocate(128); + buffer.limit(0); - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#getName() - */ - public String getName() { - return filename; - } + fileSystem = (RAMFileSystem) parent.getFileSystem(); - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#getParent() - */ - public FSDirectory getParent() { - return parent; - } + fileSystem.addSummmedBufferSize(128); + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#getLastModified() - */ - public long getLastModified() throws IOException { - return lastModified; - } + private void enlargeBuffer() throws FileSystemFullException { - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#isFile() - */ - public boolean isFile() { - return true; - } + int oldCapacity = buffer.capacity(); - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#isDirectory() - */ - public boolean isDirectory() { - return false; - } + if (oldCapacity > fileSystem.getFreeSpace()) + throw new FileSystemFullException("RAMFileSystem reached maxSize"); - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#setName(java.lang.String) - */ - public void setName(String newName) throws IOException { - // TODO check for special chars / normalize name - filename = newName; + ByteBuffer temp = ByteBuffer.allocate(oldCapacity * 2); + buffer.position(0); + temp.put(buffer); + buffer = temp; + buffer.position(0); + + // update fileSystem values + fileSystem.addSummmedBufferSize(oldCapacity); + } + + private void shrinkBuffer() { + + int toShrink = buffer.capacity() / 2; + + ByteBuffer temp = ByteBuffer.allocate(toShrink); + temp.put(buffer.array(), 0, toShrink); + buffer = temp; + buffer.position(0); + + // update fileSystem counter + fileSystem.addSummmedBufferSize(-toShrink); + } + + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#getName() + */ + public String getName() { + return filename; + } + + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#getParent() + */ + public FSDirectory getParent() { + return parent; + } + + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#getLastModified() + */ + public long getLastModified() throws IOException { + return lastModified; + } + + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#isFile() + */ + public boolean isFile() { + return true; + } + + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#isDirectory() + */ + public boolean isDirectory() { + return false; + } + + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#setName(java.lang.String) + */ + public void setName(String newName) throws IOException { + // TODO check for special chars / normalize name + filename = newName; setLastModified(System.currentTimeMillis()); } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#setLastModified(long) - */ - public void setLastModified(long lastModified) throws IOException { - this.lastModified = lastModified; - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#setLastModified(long) + */ + public void setLastModified(long lastModified) throws IOException { + this.lastModified = lastModified; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#getFile() - */ - public FSFile getFile() throws IOException { - return this; - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#getFile() + */ + public FSFile getFile() throws IOException { + return this; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#getDirectory() - */ - public FSDirectory getDirectory() throws IOException { - throw new IOException("Not a directory"); - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#getDirectory() + */ + public FSDirectory getDirectory() throws IOException { + throw new IOException("Not a directory"); + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#getAccessRights() - */ - public FSAccessRights getAccessRights() throws IOException { - return accessRights; - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#getAccessRights() + */ + public FSAccessRights getAccessRights() throws IOException { + return accessRights; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSEntry#isDirty() - */ - public boolean isDirty() throws IOException { - return false; - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSEntry#isDirty() + */ + public boolean isDirty() throws IOException { + return false; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSObject#isValid() - */ - public boolean isValid() { - return isValid; - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSObject#isValid() + */ + public boolean isValid() { + return isValid; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSObject#getFileSystem() - */ - public FileSystem getFileSystem() { - return fileSystem; - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSObject#getFileSystem() + */ + public FileSystem getFileSystem() { + return fileSystem; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSFile#getLength() - */ - public long getLength() { - return buffer.limit(); - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSFile#getLength() + */ + public long getLength() { + return buffer.limit(); + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSFile#setLength(long) - */ - public void setLength(long length) throws IOException { + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSFile#setLength(long) + */ + public void setLength(long length) throws IOException { - if (length > Integer.MAX_VALUE) - throw new IOException("Filesize too large"); - - while (buffer.capacity() < length) - enlargeBuffer(); - - long toEnlarge = length - buffer.limit(); + if (length > Integer.MAX_VALUE) + throw new IOException("Filesize too large"); - while (length < buffer.capacity() / 2) - shrinkBuffer(); - - buffer.limit((int) length); - - // update fileSystem counters - fileSystem.addSummedFileSize(toEnlarge); + while (buffer.capacity() < length) + enlargeBuffer(); + + long toEnlarge = length - buffer.limit(); + + while (length < buffer.capacity() / 2) + shrinkBuffer(); + + buffer.limit((int) length); + + // update fileSystem counters + fileSystem.addSummedFileSize(toEnlarge); setLastModified(System.currentTimeMillis()); } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSFile#read(long, java.nio.ByteBuffer) - */ - public void read(long fileOffset, ByteBuffer dest) throws IOException { - - long currentSize = buffer.limit(); - long toRead = dest.limit(); - - if (fileOffset + toRead > currentSize) - throw new IOException ("FileOffest outside file"); + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSFile#read(long, java.nio.ByteBuffer) + */ + public void read(long fileOffset, ByteBuffer dest) throws IOException { - buffer.position((int) fileOffset); - buffer.get(dest.array(), 0, dest.limit()); - } + long currentSize = buffer.limit(); + long toRead = dest.limit(); - /** - * (non-Javadoc) - * @see org.jnode.fs.FSFile#write(long, java.nio.ByteBuffer) - */ - public void write(long fileOffset, ByteBuffer src) throws IOException { - - long currentSize = buffer.limit(); - long toWrite = src.limit(); - - if (fileOffset + toWrite >= currentSize) - setLength(fileOffset + toWrite); - - buffer.position((int) fileOffset); - buffer.put(src); + if (fileOffset + toRead > currentSize) + throw new IOException("FileOffest outside file"); + + buffer.position((int) fileOffset); + buffer.get(dest.array(), 0, dest.limit()); + } + + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FSFile#write(long, java.nio.ByteBuffer) + */ + public void write(long fileOffset, ByteBuffer src) throws IOException { + + long currentSize = buffer.limit(); + long toWrite = src.limit(); + + if (fileOffset + toWrite >= currentSize) + setLength(fileOffset + toWrite); + + buffer.position((int) fileOffset); + buffer.put(src); setLastModified(System.currentTimeMillis()); } - /** - * (non-Javadoc) - * @see org.jnode.fs.FSFile#flush() - */ - public void flush() throws IOException { - // nothing todo here - } - - void remove() throws IOException { - - long capacity = buffer.capacity(); - long filesize = getLength(); - - this.parent = null; - this.buffer = null; - - fileSystem.addSummedFileSize(-filesize); - fileSystem.addSummmedBufferSize(-capacity); - } + /** + * (non-Javadoc) + * @see org.jnode.fs.FSFile#flush() + */ + public void flush() throws IOException { + // nothing todo here + } + + void remove() throws IOException { + + long capacity = buffer.capacity(); + long filesize = getLength(); + + this.parent = null; + this.buffer = null; + + fileSystem.addSummedFileSize(-filesize); + fileSystem.addSummmedBufferSize(-capacity); + } } Modified: trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystem.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystem.java 2008-06-07 11:48:31 UTC (rev 4209) +++ trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystem.java 2008-06-07 13:20:39 UTC (rev 4210) @@ -3,122 +3,130 @@ import java.io.IOException; import org.jnode.driver.Device; -import org.jnode.fs.FSEntry; import org.jnode.fs.FileSystem; import org.jnode.fs.FileSystemException; -import org.jnode.fs.smbfs.SMBFileSystemType; /** * A Filesystem implementation in the system RAM. - * + * * @author peda */ public class RAMFileSystem implements FileSystem<RAMDirectory> { - private Device device; - private boolean readOnly; + private Device device; + private boolean readOnly; - private RAMDirectory root; + private RAMDirectory root; - private final long maxSize; - private long summedBufferSize; - private long summedFileSize; + private final long maxSize; + private long summedBufferSize; + private long summedFileSize; private final RAMFileSystemType type; /** - * Constructor for RAMFileSystem - * @param device - * @param readOnly - * @param maxSize - * @throws FileSystemException - */ - public RAMFileSystem(Device device, boolean readOnly, long maxSize, RAMFileSystemType type) throws FileSystemException { + * Constructor for RAMFileSystem + * + * @param device + * @param readOnly + * @param maxSize + * @throws FileSystemException + */ + public RAMFileSystem(Device device, boolean readOnly, long maxSize, RAMFileSystemType type) + throws FileSystemException { this.type = type; this.device = device; - this.readOnly = readOnly; + this.readOnly = readOnly; - this.maxSize = maxSize; - summedBufferSize = 0; - summedFileSize = 0; + this.maxSize = maxSize; + summedBufferSize = 0; + summedFileSize = 0; - root = new RAMDirectory(this, null, ""); - } + root = new RAMDirectory(this, null, ""); + } - final public RAMFileSystemType getType() { - return this.type; - } + public final RAMFileSystemType getType() { + return this.type; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FileSystem#getDevice() - */ - public Device getDevice() { - return device; - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FileSystem#getDevice() + */ + public Device getDevice() { + return device; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FileSystem#getRootEntry() - */ - public RAMDirectory getRootEntry() throws IOException { - if (isClosed()) - throw new IOException("Filesystem closed"); - return root; - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FileSystem#getRootEntry() + */ + public RAMDirectory getRootEntry() throws IOException { + if (isClosed()) + throw new IOException("Filesystem closed"); + return root; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FileSystem#isReadOnly() - */ - public boolean isReadOnly() { - return readOnly; - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FileSystem#isReadOnly() + */ + public boolean isReadOnly() { + return readOnly; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FileSystem#close() - */ - public void close() throws IOException { - root = null; - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FileSystem#close() + */ + public void close() throws IOException { + root = null; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FileSystem#isClosed() - */ - public boolean isClosed() { - return (root == null); - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FileSystem#isClosed() + */ + public boolean isClosed() { + return (root == null); + } - /** + /** * (non-Javadoc) + * * @see org.jnode.fs.FileSystem#getTotalSpace() */ public long getTotalSpace() { - return maxSize; + return maxSize; } /** * (non-Javadoc) + * * @see org.jnode.fs.FileSystem#getFreeSpace() */ public long getFreeSpace() { - return maxSize - summedBufferSize; + return maxSize - summedBufferSize; } /** * (non-Javadoc) + * * @see org.jnode.fs.FileSystem#getUsableSpace() */ public long getUsableSpace() { - return maxSize - summedFileSize; + return maxSize - summedFileSize; } - synchronized void addSummmedBufferSize(long toAdd) { - summedBufferSize += toAdd; - } + synchronized void addSummmedBufferSize(long toAdd) { + summedBufferSize += toAdd; + } - synchronized void addSummedFileSize(long toAdd) { - summedFileSize += toAdd; - } + synchronized void addSummedFileSize(long toAdd) { + summedFileSize += toAdd; + } } Modified: trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystemType.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystemType.java 2008-06-07 11:48:31 UTC (rev 4209) +++ trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystemType.java 2008-06-07 13:20:39 UTC (rev 4210) @@ -3,36 +3,34 @@ import org.jnode.driver.Device; import org.jnode.fs.FileSystemException; import org.jnode.fs.FileSystemType; -import org.jnode.fs.util.FSUtils; /** * FileSystemType for RAMFS, a filesystem implementation in system RAM - * + * * @author peda */ public class RAMFileSystemType implements FileSystemType<RAMFileSystem> { public static final Class<RAMFileSystemType> ID = RAMFileSystemType.class; - private static final int DEFAULT_SIZE = 104857600; + private static final int DEFAULT_SIZE = 104857600; /** Virtual Device name for this filesystem */ - public static final String VIRTUAL_DEVICE_NAME = "ramfsdevice"; + public static final String VIRTUAL_DEVICE_NAME = "ramfsdevice"; + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FileSystemType#getName() + */ + public String getName() { + return "RAMFS"; + } - /** - * (non-Javadoc) - * @see org.jnode.fs.FileSystemType#getName() - */ - public String getName() { - return "RAMFS"; - } - - /** - * (non-Javadoc) - * @see org.jnode.fs.FileSystemType#create(org.jnode.driver.Device, boolean) - */ - public RAMFileSystem create(Device device, boolean readOnly) - throws FileSystemException { - - return new RAMFileSystem(device, readOnly, DEFAULT_SIZE, this); - } + /** + * (non-Javadoc) + * + * @see org.jnode.fs.FileSystemType#create(org.jnode.driver.Device, boolean) + */ + public RAMFileSystem create(Device device, boolean readOnly) throws FileSystemException { + return new RAMFileSystem(device, readOnly, DEFAULT_SIZE, this); + } } Modified: trunk/fs/src/fs/org/jnode/fs/ramfs/def/RAMFSPlugin.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ramfs/def/RAMFSPlugin.java 2008-06-07 11:48:31 UTC (rev 4209) +++ trunk/fs/src/fs/org/jnode/fs/ramfs/def/RAMFSPlugin.java 2008-06-07 13:20:39 UTC (rev 4210) @@ -1,25 +1,27 @@ package org.jnode.fs.ramfs.def; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.ByteArrayOutputStream; import java.nio.ByteBuffer; import javax.naming.NameNotFoundException; import org.apache.log4j.Logger; import org.jnode.driver.DeviceAlreadyRegisteredException; +import org.jnode.driver.DeviceException; import org.jnode.driver.DeviceManager; import org.jnode.driver.DeviceNotFoundException; import org.jnode.driver.DeviceUtils; import org.jnode.driver.DriverException; -import org.jnode.driver.DeviceException; import org.jnode.driver.virtual.VirtualDevice; import org.jnode.driver.virtual.VirtualDeviceFactory; -import org.jnode.fs.*; -import org.jnode.fs.service.FileSystemService; +import org.jnode.fs.FSDirectory; +import org.jnode.fs.FSFile; +import org.jnode.fs.FileSystemException; import org.jnode.fs.ramfs.RAMFileSystem; import org.jnode.fs.ramfs.RAMFileSystemType; +import org.jnode.fs.service.FileSystemService; import org.jnode.naming.InitialNaming; import org.jnode.plugin.Plugin; import org.jnode.plugin.PluginDescriptor; @@ -27,58 +29,51 @@ /** * This plugin creates a new Ram filesystem and mounts it to /jnode/ - * + * * @author peda */ public class RAMFSPlugin extends Plugin { + /** RAMFS logger */ + private static final Logger log = Logger.getLogger(RAMFSPlugin.class); - /** RAMFS logger */ - private static final Logger log = Logger.getLogger(RAMFSPlugin.class); - - /** - * @param descriptor - */ - public RAMFSPlugin(PluginDescriptor descriptor) { - super(descriptor); + /** + * @param descriptor + */ + public RAMFSPlugin(PluginDescriptor descriptor) { + super(descriptor); log.debug("RAMFSPlugin created."); - } + } - @Override - protected void startPlugin() throws PluginException { - - log.info("start ramfs"); - + @Override + protected void startPlugin() throws PluginException { + log.info("start ramfs"); try { + FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME); + RAMFileSystemType type = fSS.getFileSystemType(RAMFileSystemType.ID); - FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME); - RAMFileSystemType type = fSS.getFileSystemType(RAMFileSystemType.ID); - try { - - VirtualDevice dev = VirtualDeviceFactory.createDevice(RAMFileSystemType.VIRTUAL_DEVICE_NAME); - + VirtualDevice dev = + VirtualDeviceFactory.createDevice(RAMFileSystemType.VIRTUAL_DEVICE_NAME); log.info(dev.getId() + " registered"); - final RAMFileSystem fs = type.create(dev, true); + final RAMFileSystem fs = type.create(dev, true); fSS.registerFileSystem(fs); final String mountPath = "jnode"; - fSS.mount(mountPath, fs, null); - log.info("Mounted " + type.getName() + " on " + mountPath); FSDirectory root_dir = fs.getRootEntry().getDirectory(); root_dir.addDirectory("home"); root_dir.addDirectory("tmp"); - //adding files to /jnode/lib/ required by thecore classes + // adding files to /jnode/lib/ required by thecore classes FSDirectory libDir = (FSDirectory) root_dir.addDirectory("lib"); InputStream is = RAMFSPlugin.class.getResourceAsStream("flavormap.properties"); - if(is != null){ + if (is != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buf = new byte[1024]; int c; - while((c = is.read(buf)) > -1) + while ((c = is.read(buf)) > -1) baos.write(buf, 0, c); is.close(); @@ -86,52 +81,43 @@ baos.close(); ByteBuffer data = ByteBuffer.wrap(baos.toByteArray()); - FSFile fmp = (FSFile)libDir.addFile("flavormap.properties"); + FSFile fmp = (FSFile) libDir.addFile("flavormap.properties"); fmp.write(0, data); - fmp.flush(); + fmp.flush(); } - } catch (DeviceAlreadyRegisteredException ex){ - log.error("RAMFS is allready running."); + } catch (DeviceAlreadyRegisteredException ex) { + log.error("RAMFS is allready running."); } catch (FileSystemException ex) { - log.error("Cannot mount " + type.getName() + " filesystem ", ex); - } catch (DeviceException ex){ - log.debug("DeviceExeption.", ex); + log.error("Cannot mount " + type.getName() + " filesystem ", ex); + } catch (DeviceException ex) { + log.debug("DeviceExeption.", ex); } catch (IOException ex) { - log.error("Cannot mount RAMFS", ex); + log.error("Cannot mount RAMFS", ex); } - } catch (NameNotFoundException e){ - log.error("Filsystemservice not found"); - } catch (FileSystemException e){ + } catch (NameNotFoundException e) { + log.error("Filsystemservice not found"); + } catch (FileSystemException e) { log.error("Filesystemtype not found"); } - } + } - @Override - protected void stopPlugin() throws PluginException { - - log.info("stop RAMFS"); - - try { - - FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME); - - final DeviceManager dm = DeviceUtils.getDeviceManager(); - + @Override + protected void stopPlugin() throws PluginException { + log.info("stop RAMFS"); + try { + FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME); + final DeviceManager dm = DeviceUtils.getDeviceManager(); VirtualDevice dev = (VirtualDevice) dm.getDevice(RAMFileSystemType.VIRTUAL_DEVICE_NAME); fSS.unregisterFileSystem(dev); - - log.info("RAMFS unmounted"); - - dm.unregister(dev); - - log.info("RAMFS unregistered"); - - } catch (NameNotFoundException e){ - log.error("filsystemservice / filesystemtype not found"); - } catch (DeviceNotFoundException ex){ - log.info("no ramfs present"); - } catch (DriverException ex){ - log.error(ex); + log.info("RAMFS unmounted"); + dm.unregister(dev); + log.info("RAMFS unregistered"); + } catch (NameNotFoundException e) { + log.error("filsystemservice / filesystemtype not found"); + } catch (DeviceNotFoundException ex) { + log.info("no ramfs present"); + } catch (DriverException ex) { + log.error(ex); } - } + } } Modified: trunk/fs/src/fs/org/jnode/fs/service/FileSystemService.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/service/FileSystemService.java 2008-06-07 11:48:31 UTC (rev 4209) +++ trunk/fs/src/fs/org/jnode/fs/service/FileSystemService.java 2008-06-07 13:20:39 UTC (rev 4210) @@ -21,12 +21,11 @@ package org.jnode.fs.service; -import java.io.*; +import java.io.IOException; +import java.io.VMFileSystemAPI; import java.util.Collection; import java.util.Map; -import javax.naming.NameNotFoundException; - import org.jnode.driver.Device; import org.jnode.fs.FileSystem; import org.jnode.fs.FileSystemException; @@ -37,86 +36,89 @@ */ public interface FileSystemService { - /** - * Name used to lookup a FileSystemTypeManager in the initial namespace. - */ - public static final Class<FileSystemService> NAME = FileSystemService.class; //"system/FileSystemService"; + /** + * Name used to lookup a FileSystemTypeManager in the initial namespace. + */ + public static final Class<FileSystemService> NAME = FileSystemService.class; // "system/FileSystemService"; - /** - * Gets all registered file system types. All instances of the returned - * collection are instanceof FileSystemType. - */ - public Collection<FileSystemType<?>> fileSystemTypes(); + /** + * Gets all registered file system types. + */ + public Collection<FileSystemType<?>> fileSystemTypes(); - /** - * Gets registered file system types with the gicen name. - * - * @param name the name of the FSType you want - * @return the fileSystemType - */ - public <T extends FileSystemType<?>> T getFileSystemType(Class<T> name) throws FileSystemException; + /** + * Gets registered file system types with the given name. + * + * @param name the name of the FSType you want + * @return the fileSystemType + */ + public <T extends FileSystemType<?>> T getFileSystemType(Class<T> name) + throws FileSystemException; - /** - * Register a mounted filesystem - * - * @param fs - */ - public void registerFileSystem(FileSystem fs) throws FileSystemException; + /** + * Register a mounted filesystem + * + * @param fs + */ + public void registerFileSystem(FileSystem<?> fs) throws FileSystemException; - /** - * Unregister a mounted filesystem - * - * @param device - * @return The filesystem that was registered for the device, or null if not found. - */ - public FileSystem unregisterFileSystem(Device device); + /** + * Unregister a mounted filesystem + * + * @param device + * @return The filesystem that was registered for the device, or null if not + * found. + */ + public FileSystem<?> unregisterFileSystem(Device device); - /** - * Gets the filesystem registered on the given device. - * - * @param device - * @return null if no filesystem was found. - */ - public FileSystem getFileSystem(Device device); + /** + * Gets the filesystem registered on the given device. + * + * @param device + * @return null if no filesystem was found. + */ + public FileSystem<?> getFileSystem(Device device); - /** - * Gets all registered filesystems. All instances of the returned collection - * are instanceof FileSystem. - */ - public Collection<FileSystem> fileSystems(); + /** + * Gets all registered filesystems. All instances of the returned collection + * are instanceof FileSystem. + */ + public Collection<FileSystem<?>> fileSystems(); /** * Mount the given filesystem at the fullPath, using the fsPath as root of * the to be mounted filesystem. - * + * * @param fullPath * @param fs * @param fsPath Null or empty to use the root of the filesystem. */ - public void mount(String fullPath, FileSystem fs, String fsPath) - throws IOException; + public void mount(String fullPath, FileSystem<?> fs, String fsPath) throws IOException; /** * Return a map (fullPath -> FileSystem) of mount points + * * @return a copy of the internal map, sorted by fullPath */ public Map<String, FileSystem<?>> getMountPoints(); /** * Return a map of devices and their mount points. + * * @return */ public Map<String, String> getDeviceMountPoints(); - + /** * Is the given directory a mount. + * * @param fullPath * @return */ public boolean isMount(String fullPath); - /** - * Gets the filesystem API. - */ - public VMFileSystemAPI getApi(); + /** + * Gets the filesystem API. + */ + public VMFileSystemAPI getApi(); } Modified: trunk/fs/src/fs/org/jnode/fs/service/def/FSEntryCache.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/service/def/FSEntryCache.java 2008-06-07 11:48:31 UTC (rev 4209) +++ trunk/fs/src/fs/org/jnode/fs/service/def/FSEntryCache.java 2008-06-07 13:20:39 UTC (rev 4210) @@ -31,68 +31,70 @@ /** * @author epr */ +@SuppressWarnings("serial") final class FSEntryCache { - /** The actual cache */ - private final Map<String, FSEntry> entries = new LinkedHashMap<String, FSEntry>(){ + /** The actual cache */ + private final Map<String, FSEntry> entries = new LinkedHashMap<String, FSEntry>() { + @Override + protected boolean removeEldestEntry(Entry<String, FSEntry> eldest) { + return size() > 100; + } + }; - @Override - protected boolean removeEldestEntry(Entry<String, FSEntry> eldest) { - return size() > 100; - } - - }; - - /** - * Create a new instance - * @param fsm - */ - public FSEntryCache() { - } - - /** - * Gets a cached entry for a given path. - * @param path must be an absolute path - */ - public synchronized FSEntry getEntry(String path) { - final FSEntry entry = entries.get(path); - if (entry != null) { - if (entry.isValid()) { - return entry; - } else { - entries.remove(path); - return null; - } - } else { - return null; - } - } - - /** - * Puts an entry in the cache. Any existing entry for the given path - * will be removed. - * @param path must be an absolute path - * @param entry - */ - public synchronized void setEntry(String path, FSEntry entry) { - entries.put(path, entry); - } - - /** - * Remove any entry bound to the given path or a path below the given - * path. - * @param rootPathStr must be an absolute path - */ - public synchronized void removeEntries(String rootPathStr) { - entries.remove(rootPathStr); - final ArrayList<String> removePathList = new ArrayList<String>(); - for (String pathStr : entries.keySet()) { - if (pathStr.startsWith(rootPathStr)) { - removePathList.add(pathStr); - } - } - for (String path : removePathList) { - entries.remove(path); - } - } + /** + * Create a new instance + * + * @param fsm + */ + public FSEntryCache() { + } + + /** + * Gets a cached entry for a given path. + * + * @param path must be an absolute path + */ + public synchronized FSEntry getEntry(String path) { + final FSEntry entry = entries.get(path); + if (entry != null) { + if (entry.isValid()) { + return entry; + } else { + entries.remove(path); + return null; + } + } else { + return null; + } + } + + /** + * Puts an entry in the cache. Any existing entry for the given path will be + * removed. + * + * @param path must be an absolute path + * @param entry + */ + public synchronized void setEntry(String path, FSEntry entry) { + entries.put(path, entry); + } + + /** + * Remove any entry bound to the given path or a path below the given path. + * + * @param rootPathStr must be an absolute path + */ + public synchronized void removeEntries(String rootPathStr) { + entries.remove(rootPathStr); + final ArrayList<String> removePathList = new ArrayList<String>(); + for (String pathStr : entries.keySet()) { + if (pathStr.startsWith(rootPathStr)) { + removePathList.add(pathStr); + } + } + for (String path : removePathList) { + entries.remove(path); + } + } } Modified: trunk/fs/src/fs/org/jnode/fs/service/def/FileHandleImpl.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/service/def/FileHandleImpl.java 2008-06-07 11:48:31 UTC (rev 4209) +++ trunk/fs/src/fs/org/jnode/fs/service/def/FileHandleImpl.java 2008-06-07 13:20:39 UTC (rev 4210) @@ -26,7 +26,6 @@ import java.nio.ByteBuffer; import java.nio.MappedByteBuffer; -import org.apache.log4j.Logger; import org.jnode.fs.FSFile; import org.jnode.java.io.VMFileHandle; @@ -35,257 +34,243 @@ */ final class FileHandleImpl implements VMFileHandle { - /** The open mode of this filehandle */ - private final VMOpenMode mode; - /** The actual file on the filesystem */ - private final FSFile file; - /** Is this a readonly connection? */ - private final boolean readOnly; - /** The manager i'll use to close me */ - private final FileHandleManager fhm; - /** Am i closed? */ - private boolean closed; - /** Position within this file */ - private long fileOffset; + /** The open mode of this filehandle */ + private final VMOpenMode mode; + /** The actual file on the filesystem */ + private final FSFile file; + /** Is this a readonly connection? */ + private final boolean readOnly; + /** The manager i'll use to close me */ + private final FileHandleManager fhm; + /** Am i closed? */ + private boolean closed; + /** Position within this file */ + private long fileOffset; - /** - * Create a new instance - * - * @param file - * @param mode - * @param fhm - */ - public FileHandleImpl(FSFile file, VMOpenMode mode, FileHandleManager fhm) { - this.mode = mode; - this.file = file; - this.readOnly = (mode == VMOpenMode.READ); - this.fhm = fhm; - this.closed = false; + /** + * Create a new instance + * + * @param file + * @param mode + * @param fhm + */ + public FileHandleImpl(FSFile file, VMOpenMode mode, FileHandleManager fhm) { + this.mode = mode; + this.file = file; + this.readOnly = (mode == VMOpenMode.READ); + this.fhm = fhm; + this.closed = false; - // WRITE only mode, i.e. NOT APPEND mode. Thus we have to set the filesize to 0 - if (!mode.canRead() && mode.canWrite()) { - try { - file.setLength(0); - } catch (IOException e) { - //todo improve it - RuntimeException is not the best choice here + // WRITE only mode, i.e. NOT APPEND mode. Thus we have to set the + // filesize to 0 + if (!mode.canRead() && mode.canWrite()) { + try { + file.setLength(0); + } catch (IOException e) { + // todo improve it - RuntimeException is not the best choice + // here throw new RuntimeException(e); } - } - } + } + } - /** - * Gets the length (in bytes) of this file - * - * @return long - */ - public synchronized long getLength() { - if (closed) { - return 0; - } - return file.getLength(); - } + /** + * Gets the length (in bytes) of this file + * + * @return long + */ + public synchronized long getLength() { + if (closed) { + return 0; + } + return file.getLength(); + } - /** - * Sets the length of this file. - * - * @param length - * @throws IOException - */ - public synchronized void setLength(long length) throws IOException { -// System.err.println("FileHandleImpl.setLength(" + length + ");"); + /** + * Sets the length of this file. + * + * @param length + * @throws IOException + */ + public synchronized void setLength(long length) throws IOException { + if (closed) { + throw new IOException("File closed"); + } + if (readOnly) { + throw new IOException("Cannot write"); + } + file.setLength(length); + // todo check this + // if (length > fileOffset) { + fileOffset = length; + // } + } - if (closed) { - throw new IOException("File closed"); - } - if (readOnly) { - throw new IOException("Cannot write"); - } - file.setLength(length); - //todo check this - //if (length > fileOffset) { - fileOffset = length; - //} - } + /** + * Gets the current position in the file + * + * @return long + */ + public long getPosition() { + return fileOffset; + } - - /** - * Gets the current position in the file - * - * @return long - */ - public long getPosition() { - return fileOffset; - } - - /** - * Sets the position in the file. - * - * @param position - * @throws IOException - */ - public void setPosition(long position) throws IOException { - if (position < 0) { - throw new IOException("Position < 0"); - } + /** + * Sets the position in the file. + * + * @param position + * @throws IOException + */ + public void setPosition(long position) throws IOException { + if (position < 0) { + throw new IOException("Position < 0"); + } if (position > getLength()) { - //allow seeking beyond the end of file by extending the file - //TODO Investigate this decision - the classpath implementations of - //TODO RandomAccessFile (which is currently used) requires this. - //TODO Review it when the RandomAccessFile of OpenJDK is integrated. + // allow seeking beyond the end of file by extending the file + // TODO Investigate this decision - the classpath implementations of + // TODO RandomAccessFile (which is currently used) requires this. + // TODO Review it when the RandomAccessFile of OpenJDK is + // integrated. setLength(position); - //throw new IOException("Position > file size"); - } - this.fileOffset = position; - } + // throw new IOException("Position > file size"); + } + this.fileOffset = position; + } - /** - * Read <code>len</code> bytes from the given position. The read data is - * read fom this file starting at offset <code>fileOffset</code> and - * stored in <code>dest</code> starting at offset <code>ofs</code>. - * - * @param dest - * @param off - * @param len - * @throws IOException - */ -// public synchronized int read(byte[] dest, int off, int len) throws IOException { - public synchronized int read(ByteBuffer dest) throws IOException { - if (closed) { - throw new IOException("File closed"); - } + /** + * Read <code>len</code> bytes from the given position. The read data is + * read fom this file starting at offset <code>fileOffset</code> and + * stored in <code>dest</code> starting at offset <code>ofs</code>. + * + * @param dest + * @param off + * @param len + * @throws IOException + */ + public synchronized int read(ByteBuffer dest) throws IOException { + if (closed) { + throw new IOException("File closed"); + } int avail = available(); - if(avail < 1) - { + if (avail < 1) { return -1; // eof } - + int nbRead = Math.min(dest.remaining(), avail); dest.limit(dest.position() + nbRead); - + // TODO file.read should return the number of read bytes - //file.read(fileOffset, dest, off, nbRead); + // file.read(fileOffset, dest, off, nbRead); file.read(fileOffset, dest); - - fileOffset += nbRead; - + fileOffset += nbRead; return nbRead; - } + } - /** - * Write <code>len</code> bytes to the given position. The data is read - * from <code>src</code> starting at offset <code>ofs</code> and written - * to this file starting at offset <code>fileOffset</code>. - * - * @param src - * @param off - * @param len - * @throws IOException - */ - //public synchronized void write(byte[] src, int off, int len) throws IOException { - public synchronized void write(ByteBuffer src) throws IOException { - if (closed) { - throw new IOException("File closed"); - } - if (readOnly) { - throw new IOException("Cannot write"); - } - - // TODO file.write should return the number of written bytes + /** + * Write <code>len</code> bytes to the given position. The data is read + * from <code>src</code> starting at offset <code>ofs</code> and written + * to this file starting at offset <code>fileOffset</code>. + * + * @param src + * @param off + * @param len + * @throws IOException + */ + // public synchronized void write(byte[] src, int off, int len) throws + // IOException { + public synchronized void write(ByteBuffer src) throws IOException { + if (closed) { + throw new IOException("File closed"); + } + if (readOnly) { + throw new IOException("Cannot write"); + } + + // TODO file.write should return the number of written bytes final int len = src.remaining(); - file.write(fileOffset, src); - fileOffset += len; - } + file.write(fileOffset, src); + fileOffset += len; + } - /** - * Close this file. - */ - public synchronized void close() - throws IOException { - file.flush(); - closed = true; - fhm.close(this); - } + /** + * Close this file. + */ + public synchronized void close() throws IOException { + file.flush(); + closed = true; + fhm.close(this); + } - /** - * Has this handle been closed? - */ - public boolean isClosed() { - return closed; - } + /** + * Has this handle been closed? + */ + public boolean isClosed() { + return closed; + } - /** - * Duplicate this handle - * - * @throws IOException - */ - public VMFileHandle dup(VMOpenMode newMode) throws IOException { - return fhm.dup(this, newMode); - } + /** + * Duplicate this handle + * + * @throws IOException + */ + public VMFileHandle dup(VMOpenMode newMode) throws IOException { + return fhm.dup(this, newMode); + } - /** - * Gets the file of this handle - */ - public FSFile getFile() { - return file; - } + /** + * Gets the file of this handle + */ + public FSFile getFile() { + return file; + } - /** - * Gets the mode of this handle - */ - public VMOpenMode getMode() { - return mode; - } + /** + * Gets the mode of this handle + */... [truncated message content] |
From: <cr...@us...> - 2008-06-07 23:47:35
|
Revision: 4212 http://jnode.svn.sourceforge.net/jnode/?rev=4212&view=rev Author: crawley Date: 2008-06-07 16:47:31 -0700 (Sat, 07 Jun 2008) Log Message: ----------- Tweak code to work around CheckStyle crashes Modified Paths: -------------- trunk/all/build.xml trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java Modified: trunk/all/build.xml =================================================================== --- trunk/all/build.xml 2008-06-07 23:44:34 UTC (rev 4211) +++ trunk/all/build.xml 2008-06-07 23:47:31 UTC (rev 4212) @@ -891,10 +891,7 @@ <fileset dir="../gui/src/desktop" includes="**/*.java"/> <fileset dir="../gui/src/awt" includes="**/*.java"/> <fileset dir="../shell/src/test" includes="**/*.java"/> - <!-- todo: the two excluded files make checkstyle fail, investigate it! --> - <fileset dir="../shell/src/shell" - includes="**/*.java" - excludes="**/BjorneContext.java,**/BjorneTokenizer.java"/> + <fileset dir="../shell/src/shell" includes="**/*.java"/> </checkstyle> </target> Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2008-06-07 23:44:34 UTC (rev 4211) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2008-06-07 23:47:31 UTC (rev 4212) @@ -425,6 +425,7 @@ break; default: sb = accumulate(sb, ch); + break; } } if (sb != null) { @@ -513,6 +514,7 @@ default: sb.append((char) ch); + break; } ch = ci.nextCh(); } @@ -597,6 +599,8 @@ } break; default: + // Nothing to do + break; } if (ch != -1) { sb.append((char) ch); @@ -632,6 +636,7 @@ break LOOP; default: // Include this in the parameter name for now. + break; } } @@ -693,6 +698,7 @@ break; default: i++; + break; } // Extract the word if (i >= sb.length()) { @@ -877,6 +883,7 @@ break; default: fd = 1; + break; } } else { try { Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java 2008-06-07 23:44:34 UTC (rev 4211) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneTokenizer.java 2008-06-07 23:47:31 UTC (rev 4212) @@ -232,6 +232,7 @@ break; default: /* empty */ + break; } sb.append((char) ch); ch = nextCh(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2008-06-08 13:08:18
|
Revision: 4218 http://jnode.svn.sourceforge.net/jnode/?rev=4218&view=rev Author: crawley Date: 2008-06-08 06:08:16 -0700 (Sun, 08 Jun 2008) Log Message: ----------- Last style fixes for Net (apart from via_rhine) Modified Paths: -------------- trunk/all/build.xml trunk/net/src/driver/org/jnode/driver/net/rtl8139/RTL8139Core.java trunk/net/src/driver/org/jnode/driver/net/rtl8139/RTL8139RxRing.java trunk/net/src/driver/org/jnode/driver/net/rtl8139/RTL8139TxBuffer.java trunk/net/src/driver/org/jnode/driver/net/usb/UsbNetConstant.java trunk/net/src/driver/org/jnode/driver/net/usb/UsbNetDeviceToDriverMapper.java trunk/net/src/driver/org/jnode/driver/net/usb/bluetooth/UsbBluetoothDevice.java trunk/net/src/driver/org/jnode/driver/net/usb/bluetooth/UsbBluetoothDriver.java trunk/net/src/driver/org/jnode/driver/net/wireless/spi/WirelessEthernetDriver.java trunk/net/src/test/org/jnode/test/net/ARPTest.java trunk/net/src/test/org/jnode/test/net/ChecksumTest.java trunk/net/src/test/org/jnode/test/net/CvsTest.java trunk/net/src/test/org/jnode/test/net/DnsTest.java trunk/net/src/test/org/jnode/test/net/NetTest.java trunk/net/src/test/org/jnode/test/net/TCPTest.java trunk/net/src/test/org/jnode/test/net/UDPSendTest.java trunk/net/src/test/org/jnode/test/net/UDPTest.java trunk/net/src/test/org/jnode/test/net/URLTest.java trunk/net/src/test/org/jnode/test/net/ethernet/EthernetAddressTest.java Modified: trunk/all/build.xml =================================================================== --- trunk/all/build.xml 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/all/build.xml 2008-06-08 13:08:16 UTC (rev 4218) @@ -890,6 +890,10 @@ <fileset dir="../gui/src/test" includes="**/*.java"/> <fileset dir="../gui/src/desktop" includes="**/*.java"/> <fileset dir="../gui/src/awt" includes="**/*.java"/> + <fileset dir="../net/src/net" includes="**/*.java"/> + <fileset dir="../net/src/driver" includes="**/*.java" + excludes="**/via_rhine/*.java"/> + <fileset dir="../net/src/test" includes="**/*.java"/> <fileset dir="../shell/src/test" includes="**/*.java"/> <fileset dir="../shell/src/shell" includes="**/*.java"/> </checkstyle> Modified: trunk/net/src/driver/org/jnode/driver/net/rtl8139/RTL8139Core.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/rtl8139/RTL8139Core.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/driver/org/jnode/driver/net/rtl8139/RTL8139Core.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -50,11 +50,12 @@ /** * Build with help of the donation from WebSprocket LLC - * + * * @author Martin Husted Hartvig */ -public class RTL8139Core extends AbstractDeviceCore implements RTL8139Constants, IRQHandler, EthernetConstants { +public class RTL8139Core extends AbstractDeviceCore implements RTL8139Constants, IRQHandler, + EthernetConstants { /** * Start of IO address space */ @@ -90,7 +91,7 @@ /** * Is a transmission active? */ - //private boolean tx_active; + // private boolean tx_active; private int txIndex; private int txAborted; private int txNumberOfPackets; @@ -98,7 +99,7 @@ /** * Create a new instance - * + * * @param flags */ public RTL8139Core(RTL8139Driver driver, ResourceOwner owner, PCIDevice device, Flags flags) @@ -115,7 +116,7 @@ this.iobase = getIOBase(device, this.flags); final int iolength = getIOLength(device, this.flags); - // log.debug("RTL8139 driver iobase "+iobase+" irq "+irq); + // log.debug("RTL8139 driver iobase "+iobase+" irq "+irq); final ResourceManager rm; @@ -162,8 +163,8 @@ setReg32(REG_MAR0, 0); setReg32(REG_MAR0 + 4, 0); - log.debug("Found " + flags.getName() + " IRQ=" + irq + ", IOBase=0x" + NumberUtils.hex(iobase) + - ", MAC Address=" + hwAddress); + log.debug("Found " + flags.getName() + " IRQ=" + irq + ", IOBase=0x" + + NumberUtils.hex(iobase) + ", MAC Address=" + hwAddress); } private void powerUpDevice() { @@ -183,12 +184,14 @@ try { Thread.sleep(200); } catch (InterruptedException ex) { + // FIXME } for (i = 0; i < REPEAT_TIMEOUT_COUNT; i++) { try { Thread.sleep(GENERIC_WAIT_TIME); } catch (InterruptedException ex) { + // FIXME } if ((getReg8(REG_CHIPCMD) & CMD_RESET) == 0) @@ -203,12 +206,14 @@ try { Thread.sleep(200); } catch (InterruptedException ex) { + // FIXME } for (i = 0; i < REPEAT_TIMEOUT_COUNT; i++) { try { Thread.sleep(GENERIC_WAIT_TIME); } catch (InterruptedException ex) { + // FIXME } if ((getReg16(BMCR) & BMCR_RESET) == 0) @@ -224,12 +229,14 @@ try { Thread.sleep(200); } catch (InterruptedException ex) { + // FIXME } for (i = 0; i < REPEAT_TIMEOUT_COUNT; i++) { try { Thread.sleep(GENERIC_WAIT_TIME); } catch (InterruptedException ex) { + // FIXME } if ((getReg8(REG_CFG9346) & 0xc0) == 0) @@ -253,7 +260,7 @@ private void autoNegotiate() { - //boolean fullDuplex = false; + // boolean fullDuplex = false; // start auto negotiating setReg16(REG_INTR_MASK, INTR_MASK); @@ -277,11 +284,13 @@ try { Thread.sleep(1000); } catch (InterruptedException ex) { + // FIXME } bogusCount++; if (bogusCount >= AUTO_NEGOTIATE_TIMEOUT) { - log.debug("Bogus count: autonegotiating taking too long: " + Integer.toHexString(status)); + log.debug("Bogus count: autonegotiating taking too long: " + + Integer.toHexString(status)); break; } status = getReg16(BMSR); @@ -299,24 +308,26 @@ /* int lpar = */ getReg16(NWAY_LPAR); - log.debug("MSR: " + Integer.toHexString(getReg8(MSR)) + " BMCR: " + Integer.toHexString(getReg16(BMCR)) + - " LPAR: " + Integer.toHexString(getReg16(NWAY_LPAR))); + log.debug("MSR: " + Integer.toHexString(getReg8(MSR)) + " BMCR: " + + Integer.toHexString(getReg16(BMCR)) + " LPAR: " + + Integer.toHexString(getReg16(NWAY_LPAR))); - // if (lpar == 0xffff) { - // } else if (((lpar & 0x0100) == 0x0100) || ((lpar & 0x00C0) == 0x0040)) { - // fullDuplex = true; - // } + // if (lpar == 0xffff) { + // } else if (((lpar & 0x0100) == 0x0100) || ((lpar & 0x00C0) == + // 0x0040)) { + // fullDuplex = true; + // } - // if (fullDuplex) rtl8139.write8(REG_CONFIG1, 0x60); // check - // else rtl8139.write8(REG_CONFIG1, 0x20); + // if (fullDuplex) rtl8139.write8(REG_CONFIG1, 0x60); // check + // else rtl8139.write8(REG_CONFIG1, 0x20); setReg8(REG_CFG9346, 0x00); - // if (fullDuplex) System.out.print("AutoNegotiation: Full Duplex "); - // else System.out.print("AutoNegotiation: Half Duplex "); + // if (fullDuplex) System.out.print("AutoNegotiation: Full Duplex "); + // else System.out.print("AutoNegotiation: Half Duplex "); - // if ((lpar & 0x0180) != 0) System.out.println("100 Mbps Mode"); - // else System.out.println("10 Mbps Mode"); + // if ((lpar & 0x0180) != 0) System.out.println("100 Mbps Mode"); + // else System.out.println("10 Mbps Mode"); return; } @@ -397,7 +408,7 @@ /** * Transmit the given buffer - * + * * @param buf * @param timeout * @throws InterruptedException @@ -407,24 +418,26 @@ throws InterruptedException, TimeoutException { // Set the source address hwAddress.writeTo(buf, 6); - //tx_active = true; + // tx_active = true; txNumberOfPackets++; // Set the address of the txBuffer setReg32(REG_CFG9346, CFG9346_WE); - // this should be a bug fix, but looking (in Ethereal) at the packes send + // this should be a bug fix, but looking (in Ethereal) at the packes + // send // indicate on my card that this is not true // Martin /* - * if (txIndex == 0) { txBuffers[0].initialize(buf); setReg32(REG_TX_STATUS0, txFlag | - * buf.getSize()); - * - * txBuffers[1].initialize(buf); setReg32(REG_TX_STATUS0 + 4, txFlag | buf.getSize()); - * - * txIndex = 2; } else { - */ + * if (txIndex == 0) { txBuffers[0].initialize(buf); + * setReg32(REG_TX_STATUS0, txFlag | buf.getSize()); + * + * txBuffers[1].initialize(buf); setReg32(REG_TX_STATUS0 + 4, txFlag | + * buf.getSize()); + * + * txIndex = 2; } else { + */ txBuffers[txIndex].initialize(buf); setReg32(REG_TX_STATUS0 + 4 * txIndex, txFlag | buf.getSize()); @@ -432,14 +445,14 @@ // Point to the next empty descriptor txIndex++; txIndex &= 3; - // } + // } setReg32(REG_CFG9346, CFG9346_NORMAL); } /** - * Handle a given hardware interrupt. This method is called from the kernel with interrupts - * disabled. So keep and handling here as short as possible! + * Handle a given hardware interrupt. This method is called from the kernel + * with interrupts disabled. So keep and handling here as short as possible! */ public void handleInterrupt(int irq) { int bogusCount = 20; @@ -454,10 +467,9 @@ } // See if anything needs servicing - if ((status - & (INTR_RX_OK | INTR_RX_ERR | INTR_TX_OK | INTR_TX_ERR | INTR_RX_BUF_OVRFLO | INTR_RX_FIFO_OVRFLO | - INTR_TIMEOUT | INTR_SYS_ERR | INTR_RX_UNDERRUN | INTR_LEN_CHG)) - == 0) { + if ((status & (INTR_RX_OK | INTR_RX_ERR | INTR_TX_OK | INTR_TX_ERR | + INTR_RX_BUF_OVRFLO | INTR_RX_FIFO_OVRFLO | INTR_TIMEOUT | INTR_SYS_ERR | + INTR_RX_UNDERRUN | INTR_LEN_CHG)) == 0) { break; } @@ -485,11 +497,11 @@ } // Process the other errors - if ((status & (INTR_RX_ERR | INTR_TX_ERR | INTR_RX_BUF_OVRFLO | INTR_RX_FIFO_OVRFLO | INTR_TIMEOUT | - INTR_SYS_ERR | INTR_RX_UNDERRUN)) != 0) { + if ((status & (INTR_RX_ERR | INTR_TX_ERR | INTR_RX_BUF_OVRFLO | INTR_RX_FIFO_OVRFLO | + INTR_TIMEOUT | INTR_SYS_ERR | INTR_RX_UNDERRUN)) != 0) { errorInterrupt(status); - // log.debug(" error Interupt "+status); + // log.debug(" error Interupt "+status); } if (--bogusCount < 0) { setReg16(REG_INTR_STATUS, 0xffff); @@ -504,33 +516,34 @@ setReg32(REG_RX_MISSED, 0); if ((status & (INTR_RX_UNDERRUN | INTR_RX_BUF_OVRFLO | INTR_RX_FIFO_OVRFLO | INTR_RX_ERR)) != 0) { - // rxErrors++; + // rxErrors++; } if ((status & INTR_RX_FIFO_OVRFLO) != 0) { - // rxFifoOverflow++; + // rxFifoOverflow++; } if ((status & INTR_RX_UNDERRUN) != 0) { - // rxUnderRun++; + // rxUnderRun++; } if ((status & INTR_RX_BUF_OVRFLO) != 0) { - // rxBufferOverflow++; - // rxBufferOverflow++; + // rxBufferOverflow++; + // rxBufferOverflow++; // following is needed to clear this interrupt - // rxIndex = getReg16(REG_RX_BUF_CNT) % RX_BUF_SIZE; + // rxIndex = getReg16(REG_RX_BUF_CNT) % RX_BUF_SIZE; rxRing.setIndex(getReg16(REG_RX_BUF_CNT) % RX_BUF_SIZE); setReg16(REG_RX_BUF_PTR, rxRing.getIndex() - 16); } if ((status & INTR_SYS_ERR) != 0) { + // FIXME } if ((status & INTR_TIMEOUT) != 0) { - // timeoutError++; + // timeoutError++; } } /* - * private void rxError(int status) { - */ + * private void rxError(int status) { + */ private void rxProcess(int status) { // Read all packets @@ -568,9 +581,11 @@ if (skbuf.getSize() > 0) driver.onReceive(skbuf); } catch (NetworkException e) { - e.printStackTrace(); //To change body of catch statement use Options | File + e.printStackTrace(); // To change body of catch statement + // use Options | File // Templates. } finally { + // FIXME } } @@ -588,7 +603,7 @@ return; } if ((txStatus & (TX_OWC | TX_TABT)) != 0) { - // txErrors++; + // txErrors++; if ((txStatus & TX_TABT) != 0) { txAborted++; // Setting clear abort bit will make the 8139 @@ -597,19 +612,19 @@ return; } if ((txStatus & TX_CRS) != 0) { - // txCarrierErrors++; + // txCarrierErrors++; } if ((txStatus & TX_OWC) != 0) { - // System.out.println("TX window error"); - // txWindowErrors++; + // System.out.println("TX window error"); + // txWindowErrors++; } } else { if ((txStatus & TX_TUN) != 0) { - // txFifoErrors++; + // txFifoErrors++; } - // txCollisions += ((txStatus & TX_NCC) >> 24); - // txBytes += txStatus & 0x7ff; - // txPackets++; + // txCollisions += ((txStatus & TX_NCC) >> 24); + // txBytes += txStatus & 0x7ff; + // txPackets++; } // txPendingQueue[txPending].free(); txNumberOfPackets--; @@ -621,7 +636,7 @@ /** * Gets the first IO-Address used by the given device - * + * * @param device * @param flags */ @@ -641,7 +656,7 @@ /** * Gets the number of IO-Addresses used by the given device - * + * * @param device * @param flags */ @@ -662,7 +677,7 @@ /** * Gets the IRQ used by the given device - * + * * @param device * @param flags */ @@ -675,7 +690,7 @@ /** * Reads a 8-bit NIC register - * + * * @param reg */ protected final int getReg8(int reg) { @@ -684,7 +699,7 @@ /** * Reads a 16-bit NIC register - * + * * @param reg */ protected final int getReg16(int reg) { @@ -693,7 +708,7 @@ /** * Reads a 32-bit NIC register - * + * * @param reg */ @@ -703,7 +718,7 @@ /** * Writes a 8-bit NIC register - * + * * @param reg * @param value */ @@ -714,7 +729,7 @@ /** * Writes a 16-bit NIC register - * + * * @param reg * @param value */ @@ -725,7 +740,7 @@ /** * Writes a 32-bit NIC register - * + * * @param reg * @param value */ @@ -734,18 +749,19 @@ io.outPortDword(iobase + reg, value); } - private IOResource claimPorts(final ResourceManager rm, final ResourceOwner owner, final int low, final int length) - throws ResourceNotFreeException, DriverException { + private IOResource claimPorts(final ResourceManager rm, final ResourceOwner owner, + final int low, final int length) throws ResourceNotFreeException, DriverException { try { - return (IOResource) AccessControllerUtils.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws ResourceNotFreeException { + return AccessControllerUtils.doPrivileged(new PrivilegedExceptionAction<IOResource>() { + public IOResource run() throws ResourceNotFreeException { return rm.claimIOResource(owner, low, length); - }}); - } catch (ResourceNotFreeException ex) { - throw ex; + } + }); + } catch (ResourceNotFreeException ex) { + throw ex; } catch (Exception ex) { throw new DriverException("Unknown exception", ex); } - - } + + } } Modified: trunk/net/src/driver/org/jnode/driver/net/rtl8139/RTL8139RxRing.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/rtl8139/RTL8139RxRing.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/driver/org/jnode/driver/net/rtl8139/RTL8139RxRing.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -29,7 +29,6 @@ /** * @author Martin Husted Hartvig */ - public class RTL8139RxRing implements RTL8139Constants { private static final int UPD_SIZE = 16; @@ -65,16 +64,14 @@ /** * Create a new instance - * + * * @param nrFrames The number of complete ethernet frames in this ring. * @param rm */ public RTL8139RxRing(int nrFrames, ResourceManager rm) { - // Create a large enough buffer - final int size = TOTAL_RX_BUF_SIZE;// (nrFrames * (UPD_SIZE + - // FRAME_SIZE)) + 16/*alignment*/; + final int size = TOTAL_RX_BUF_SIZE; this.data = new byte[size]; this.nrFrames = nrFrames; this.mem = rm.asMemoryResource(data); @@ -105,7 +102,7 @@ /** * Sets the packet status of the UPD at the given index - * + * * @param index * @param value The new pkt status value */ @@ -130,7 +127,6 @@ */ public SocketBuffer getPacket(int _length) { - final int updOffset = firstUPDOffset + index; final SocketBuffer skbuf = new SocketBuffer(); @@ -154,9 +150,9 @@ /** * Gets the number of frames of this ring - */ + */ - public int getNrFrames() { - return nrFrames; - } + public int getNrFrames() { + return nrFrames; + } } Modified: trunk/net/src/driver/org/jnode/driver/net/rtl8139/RTL8139TxBuffer.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/rtl8139/RTL8139TxBuffer.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/driver/org/jnode/driver/net/rtl8139/RTL8139TxBuffer.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -64,7 +64,6 @@ */ public RTL8139TxBuffer(ResourceManager rm) { - // Create a large enough buffer final int size = (DPD_SIZE + FRAME_SIZE) + 16 /* alignment */; this.data = new byte[size]; @@ -87,8 +86,7 @@ // Copy the data from the buffer final int len = src.getSize(); if (len > FRAME_SIZE) { - throw new IllegalArgumentException( - "Length must be <= ETH_FRAME_LEN"); + throw new IllegalArgumentException("Length must be <= ETH_FRAME_LEN"); } src.get(data, firstDPDOffset, 0, len); @@ -98,6 +96,6 @@ * Gets the address of the first DPD in this buffer. */ public Address getFirstDPDAddress() { - return firstDPDAddress; - } + return firstDPDAddress; + } } Modified: trunk/net/src/driver/org/jnode/driver/net/usb/UsbNetConstant.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/usb/UsbNetConstant.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/driver/org/jnode/driver/net/usb/UsbNetConstant.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -4,7 +4,8 @@ public interface UsbNetConstant extends USBConstants { /* Subclass */ - public final static int US_SC_RF = 0x01; + public static final int US_SC_RF = 0x01; + /* Protocols */ - public final static int US_PR_BLUETOOTH = 0x01; /* Control/Bulk/Interrupt */ + public static final int US_PR_BLUETOOTH = 0x01; /* Control/Bulk/Interrupt */ } Modified: trunk/net/src/driver/org/jnode/driver/net/usb/UsbNetDeviceToDriverMapper.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/usb/UsbNetDeviceToDriverMapper.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/driver/org/jnode/driver/net/usb/UsbNetDeviceToDriverMapper.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -12,7 +12,7 @@ /** * This class define driver finder for USB Wireless device. - * + * * @author fabien L. */ public class UsbNetDeviceToDriverMapper implements DeviceToDriverMapper, UsbNetConstant { Modified: trunk/net/src/driver/org/jnode/driver/net/usb/bluetooth/UsbBluetoothDevice.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/usb/bluetooth/UsbBluetoothDevice.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/driver/org/jnode/driver/net/usb/bluetooth/UsbBluetoothDevice.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -3,7 +3,6 @@ import org.jnode.driver.bus.usb.SetupPacket; import org.jnode.driver.bus.usb.USBConstants; import org.jnode.driver.bus.usb.USBControlPipe; -import org.jnode.driver.bus.usb.USBDataPipe; import org.jnode.driver.bus.usb.USBDevice; import org.jnode.driver.bus.usb.USBEndPoint; import org.jnode.driver.bus.usb.USBException; @@ -46,8 +45,8 @@ public void testCommand() throws USBException { final USBControlPipe pipe = usbDevice.getDefaultControlPipe(); - final USBRequest req = - pipe.createRequest(new SetupPacket(USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_DEVICE, 0x20, 0, 0, 0), null); + final USBRequest req = pipe.createRequest( + new SetupPacket(USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_DEVICE, 0x20, 0, 0, 0), null); pipe.syncSubmit(req, GET_TIMEOUT); } Modified: trunk/net/src/driver/org/jnode/driver/net/usb/bluetooth/UsbBluetoothDriver.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/usb/bluetooth/UsbBluetoothDriver.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/driver/org/jnode/driver/net/usb/bluetooth/UsbBluetoothDriver.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -65,8 +65,9 @@ } } if ((num_bulk_intr != 1) || (num_bulk_intr != 1) || (num_bulk_intr != 1)) { - throw new DriverException("Must have one bulk-in (" + num_bulk_in + "), one bulk out (" + num_bulk_out + - ") and one interrupt (" + num_bulk_intr + ") endpoints. Driver not bound."); + throw new DriverException("Must have one bulk-in (" + num_bulk_in + + "), one bulk out (" + num_bulk_out + ") and one interrupt (" + num_bulk_intr + + ") endpoints. Driver not bound."); } UsbBtDevice.setBulkInEndpoint(bulkInEndpoint[0]); UsbBtDevice.setBulkOutEndpoint(bulkOutEndpoint[0]); @@ -76,7 +77,9 @@ intPipe.addListener(this); try { intPipe.open(); - intData = new USBPacket(UsbBtDevice.getIntrInEndpoint().getDescriptor().getMaxPacketSize()); + intData = + new USBPacket(UsbBtDevice.getIntrInEndpoint().getDescriptor() + .getMaxPacketSize()); final USBRequest req = intPipe.createRequest(intData); intPipe.asyncSubmit(req); } catch (USBException e1) { @@ -102,7 +105,7 @@ } public void requestCompleted(USBRequest request) { -// log.debug("Bluetooth Completed"); + // log.debug("Bluetooth Completed"); final byte[] data = intData.getData(); StringBuffer buffer = new StringBuffer(); buffer.append("Data received : "); Modified: trunk/net/src/driver/org/jnode/driver/net/wireless/spi/WirelessEthernetDriver.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/wireless/spi/WirelessEthernetDriver.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/driver/org/jnode/driver/net/wireless/spi/WirelessEthernetDriver.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -86,7 +86,8 @@ } /** - * @see org.jnode.driver.net.ethernet.spi.BasicEthernetDriver#newCore(org.jnode.driver.Device, org.jnode.driver.net.ethernet.spi.Flags) + * @see org.jnode.driver.net.ethernet.spi.BasicEthernetDriver#newCore(org.jnode.driver.Device, + * org.jnode.driver.net.ethernet.spi.Flags) */ protected final AbstractDeviceCore newCore(Device device, Flags flags) throws DriverException, ResourceNotFreeException { @@ -100,7 +101,8 @@ throws DriverException, ResourceNotFreeException; /** - * @see org.jnode.driver.net.WirelessNetDeviceAPI#setAuthenticationMode(org.jnode.net.wireless.AuthenticationMode) + * @see org.jnode.driver.net.WirelessNetDeviceAPI#setAuthenticationMode( + * org.jnode.net.wireless.AuthenticationMode) */ public void setAuthenticationMode(AuthenticationMode mode) throws NetworkException { try { Modified: trunk/net/src/test/org/jnode/test/net/ARPTest.java =================================================================== --- trunk/net/src/test/org/jnode/test/net/ARPTest.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/test/org/jnode/test/net/ARPTest.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -34,27 +34,26 @@ * @author epr */ public class ARPTest { - - /** - * Perform an ARP request - * @param args - * @throws Exception - */ - public static void main(String[] args) - throws Exception { - - final ARPNetworkLayer arp = (ARPNetworkLayer)NetUtils.getNLM().getNetworkLayer(EthernetConstants.ETH_P_ARP); - final DeviceManager dm = (DeviceManager)InitialNaming.lookup(DeviceManager.NAME); - final IPv4Address addr = new IPv4Address(args[0]); - final IPv4Address myAddr = new IPv4Address(args[1]); - final Device dev = dm.getDevice(args[2]); - final long timeout = 5000; - - final HardwareAddress hwAddr; - hwAddr = arp.getHardwareAddress(addr, myAddr, dev, timeout); - - System.out.println("Found hwaddress:" + hwAddr); - - } + /** + * Perform an ARP request + * + * @param args + * @throws Exception + */ + public static void main(String[] args) throws Exception { + final ARPNetworkLayer arp = + (ARPNetworkLayer) NetUtils.getNLM().getNetworkLayer(EthernetConstants.ETH_P_ARP); + final DeviceManager dm = (DeviceManager) InitialNaming.lookup(DeviceManager.NAME); + final IPv4Address addr = new IPv4Address(args[0]); + final IPv4Address myAddr = new IPv4Address(args[1]); + final Device dev = dm.getDevice(args[2]); + final long timeout = 5000; + + final HardwareAddress hwAddr; + hwAddr = arp.getHardwareAddress(addr, myAddr, dev, timeout); + + System.out.println("Found hwaddress:" + hwAddr); + } + } Modified: trunk/net/src/test/org/jnode/test/net/ChecksumTest.java =================================================================== --- trunk/net/src/test/org/jnode/test/net/ChecksumTest.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/test/org/jnode/test/net/ChecksumTest.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -30,20 +30,20 @@ */ public class ChecksumTest { - public static void main(String[] args) { - - SocketBuffer skbuf = new SocketBuffer(); - skbuf.insert(20); - for (int i = 0; i < 20; i++) { - skbuf.set(i, i); - } - skbuf.set16(10, 0); - - final int ccs = IPv4Utils.calcChecksum(skbuf, 0, 20); - skbuf.set16(10, ccs); - final int ccs2 = IPv4Utils.calcChecksum(skbuf, 0, 20); - - System.out.println("ccs=0x" + NumberUtils.hex(ccs) + ", ccs2=0x" + NumberUtils.hex(ccs2)); - - } + public static void main(String[] args) { + + SocketBuffer skbuf = new SocketBuffer(); + skbuf.insert(20); + for (int i = 0; i < 20; i++) { + skbuf.set(i, i); + } + skbuf.set16(10, 0); + + final int ccs = IPv4Utils.calcChecksum(skbuf, 0, 20); + skbuf.set16(10, ccs); + final int ccs2 = IPv4Utils.calcChecksum(skbuf, 0, 20); + + System.out.println("ccs=0x" + NumberUtils.hex(ccs) + ", ccs2=0x" + NumberUtils.hex(ccs2)); + + } } Modified: trunk/net/src/test/org/jnode/test/net/CvsTest.java =================================================================== --- trunk/net/src/test/org/jnode/test/net/CvsTest.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/test/org/jnode/test/net/CvsTest.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -22,27 +22,19 @@ package org.jnode.test.net; /** - * Created by IntelliJ IDEA. - * User: mh - * Date: 23-05-2004 - * Time: 21:45:15 - * To change this template use File | Settings | File Templates. + * @author Martin Hartvig */ - import com.jcraft.jsch.JSch; import javax.crypto.NullCipher; -public class CvsTest -{ +public class CvsTest { - public static void main(String[] args) - { - NullCipher nullCipher = new NullCipher(); - System.out.println(nullCipher); + public static void main(String[] args) { + NullCipher nullCipher = new NullCipher(); + System.out.println(nullCipher); - - JSch jsch = new JSch(); - System.out.println(jsch); - } + JSch jsch = new JSch(); + System.out.println(jsch); + } } Modified: trunk/net/src/test/org/jnode/test/net/DnsTest.java =================================================================== --- trunk/net/src/test/org/jnode/test/net/DnsTest.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/test/org/jnode/test/net/DnsTest.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -28,31 +28,22 @@ /** * @author Martin Hartvig */ +public class DnsTest { -public class DnsTest -{ + public static void main(String[] args) { + if (args.length == 1) { + try { + System.out.println("inetAddress find " + args[0]); - public static void main(String[] args) - { - if (args.length == 1) - { - try - { - System.out.println("inetAddress find "+args[0]); + InetAddress inetAddress = InetAddress.getByName(args[0]); - InetAddress inetAddress = InetAddress.getByName(args[0]); - - System.out.println("inetAddress "+inetAddress.getHostAddress()); - } - catch (UnknownHostException e) - { - e.printStackTrace(); //To change body of catch statement use Options | File Templates. - } + System.out.println("inetAddress " + inetAddress.getHostAddress()); + } catch (UnknownHostException e) { + e.printStackTrace(); // To change body of catch statement use + // Options | File Templates. + } + } else { + System.out.println("insert url as arg."); + } } - else - { - System.out.println("insert url as arg."); - } - } } - Modified: trunk/net/src/test/org/jnode/test/net/NetTest.java =================================================================== --- trunk/net/src/test/org/jnode/test/net/NetTest.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/test/org/jnode/test/net/NetTest.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -33,42 +33,40 @@ */ public class NetTest { - public static void main(String[] args) { - - String devId = (args.length > 0) ? args[0] : "eth0"; - - try { - final DeviceManager dm = (DeviceManager)InitialNaming.lookup(DeviceManager.NAME); - final Device dev = dm.getDevice(devId); - final NetDeviceAPI api = (NetDeviceAPI)dev.getAPI(NetDeviceAPI.class); - final EthernetAddress mac = (EthernetAddress)api.getAddress(); - - SocketBuffer skbuf = new SocketBuffer(); - skbuf.insert(28); - skbuf.set16(0, 0x0001); // Hardware type - skbuf.set16(2, 0x0800); // Protocol type - skbuf.set(4, 6); // Hardware address size - skbuf.set(5, 4); // Protocol address size - skbuf.set16(6, 0x01); // Operation APR request - mac.writeTo(skbuf, 8); // Source mac - skbuf.set32(14, 0xc0a8c853); // Source IP - skbuf.set32(14, 0xc0a8c801); // Target IP - - // Prefix ethernet header - skbuf.insert(14); - // Set dest address - EthernetAddress dst = new EthernetAddress("ff-ff-ff-ff-ff-ff"); - dst.writeTo(skbuf, 0); - - // Set packet type - skbuf.set16(12, 0x0806); - - //api.transmit(skbuf); - - } catch (Throwable ex) { - ex.printStackTrace(); - } - - } + public static void main(String[] args) { + String devId = (args.length > 0) ? args[0] : "eth0"; + + try { + final DeviceManager dm = (DeviceManager) InitialNaming.lookup(DeviceManager.NAME); + final Device dev = dm.getDevice(devId); + final NetDeviceAPI api = (NetDeviceAPI) dev.getAPI(NetDeviceAPI.class); + final EthernetAddress mac = (EthernetAddress) api.getAddress(); + + SocketBuffer skbuf = new SocketBuffer(); + skbuf.insert(28); + skbuf.set16(0, 0x0001); // Hardware type + skbuf.set16(2, 0x0800); // Protocol type + skbuf.set(4, 6); // Hardware address size + skbuf.set(5, 4); // Protocol address size + skbuf.set16(6, 0x01); // Operation APR request + mac.writeTo(skbuf, 8); // Source mac + skbuf.set32(14, 0xc0a8c853); // Source IP + skbuf.set32(14, 0xc0a8c801); // Target IP + + // Prefix ethernet header + skbuf.insert(14); + // Set dest address + EthernetAddress dst = new EthernetAddress("ff-ff-ff-ff-ff-ff"); + dst.writeTo(skbuf, 0); + + // Set packet type + skbuf.set16(12, 0x0806); + + //api.transmit(skbuf); + + } catch (Throwable ex) { + ex.printStackTrace(); + } + } } Modified: trunk/net/src/test/org/jnode/test/net/TCPTest.java =================================================================== --- trunk/net/src/test/org/jnode/test/net/TCPTest.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/test/org/jnode/test/net/TCPTest.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -28,40 +28,39 @@ import java.net.Socket; /** - * A very trivial HTTP server, which actually only receives the HTTP - * request and then closes the connection. - * + * A very trivial HTTP server, which actually only receives the HTTP request and + * then closes the connection. + * * @author Ewout Prangsma (ep...@us...) */ public class TCPTest { - public static void main(String[] args) - throws Exception { - // Listen to http messages - final ServerSocket socket = new ServerSocket(80); - try { - for (int i = 0; i < 5; i++) { - Socket s = socket.accept(); - System.out.println("Received call on port 80 from " + s.getRemoteSocketAddress()); - - final InputStream is = s.getInputStream(); - final BufferedReader in = new BufferedReader(new InputStreamReader(is)); - - String line; - while ((line = in.readLine()) != null) { - System.out.println(line); - if (line.length() == 0) { - break; - } - } - System.out.println("Got EOF or blank line"); - - s.close(); - } - - System.out.println("I'm stopping now"); - } finally { - socket.close(); - } - } + public static void main(String[] args) throws Exception { + // Listen to http messages + final ServerSocket socket = new ServerSocket(80); + try { + for (int i = 0; i < 5; i++) { + Socket s = socket.accept(); + System.out.println("Received call on port 80 from " + s.getRemoteSocketAddress()); + + final InputStream is = s.getInputStream(); + final BufferedReader in = new BufferedReader(new InputStreamReader(is)); + + String line; + while ((line = in.readLine()) != null) { + System.out.println(line); + if (line.length() == 0) { + break; + } + } + System.out.println("Got EOF or blank line"); + + s.close(); + } + + System.out.println("I'm stopping now"); + } finally { + socket.close(); + } + } } Modified: trunk/net/src/test/org/jnode/test/net/UDPSendTest.java =================================================================== --- trunk/net/src/test/org/jnode/test/net/UDPSendTest.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/test/org/jnode/test/net/UDPSendTest.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -31,29 +31,28 @@ */ public class UDPSendTest { - public static void main(String[] args) - throws Exception { - - final DatagramSocket socket = new DatagramSocket(); - try { - final int size; - if (args.length > 1) { - size = Integer.parseInt(args[1]); - } else { - size = 5000; - } - - System.out.println("SendBufferSize=" + socket.getSendBufferSize()); - final byte[] buf = new byte[size]; - final DatagramPacket dp = new DatagramPacket(buf, buf.length); - - dp.setPort(2237); - dp.setAddress(new IPv4Address(args[0]).toInetAddress()); - - System.out.println("Sending packet of size " + dp.getLength()); - socket.send(dp); - } finally { - socket.close(); - } - } + public static void main(String[] args) throws Exception { + + final DatagramSocket socket = new DatagramSocket(); + try { + final int size; + if (args.length > 1) { + size = Integer.parseInt(args[1]); + } else { + size = 5000; + } + + System.out.println("SendBufferSize=" + socket.getSendBufferSize()); + final byte[] buf = new byte[size]; + final DatagramPacket dp = new DatagramPacket(buf, buf.length); + + dp.setPort(2237); + dp.setAddress(new IPv4Address(args[0]).toInetAddress()); + + System.out.println("Sending packet of size " + dp.getLength()); + socket.send(dp); + } finally { + socket.close(); + } + } } Modified: trunk/net/src/test/org/jnode/test/net/UDPTest.java =================================================================== --- trunk/net/src/test/org/jnode/test/net/UDPTest.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/test/org/jnode/test/net/UDPTest.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -28,27 +28,25 @@ * @author epr */ public class UDPTest { - - public static void main(String[] args) - throws Exception { - - // Listen to netbios messages - final DatagramSocket socket = new DatagramSocket(2237); - try { - final byte[] buf = new byte[256]; - final DatagramPacket dp = new DatagramPacket(buf, buf.length); - - System.out.println("Starting to listen for netbios messages now..."); - - for (int i = 0; i < 5; i++) { - socket.receive(dp); - System.out.println("Received datagram packet from " + dp.getAddress() + ":" + dp.getPort()); - } - - System.out.println("I'm stopping now"); - } finally { - socket.close(); - } - } + public static void main(String[] args) throws Exception { + // Listen to netbios messages + final DatagramSocket socket = new DatagramSocket(2237); + try { + final byte[] buf = new byte[256]; + final DatagramPacket dp = new DatagramPacket(buf, buf.length); + + System.out.println("Starting to listen for netbios messages now..."); + + for (int i = 0; i < 5; i++) { + socket.receive(dp); + System.out.println("Received datagram packet from " + dp.getAddress() + ":" + + dp.getPort()); + } + + System.out.println("I'm stopping now"); + } finally { + socket.close(); + } + } } Modified: trunk/net/src/test/org/jnode/test/net/URLTest.java =================================================================== --- trunk/net/src/test/org/jnode/test/net/URLTest.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/test/org/jnode/test/net/URLTest.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -29,19 +29,19 @@ */ public class URLTest { - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws Exception { - final URL url = new URL((args.length > 0) ? args[0] : "http://192.168.200.1"); - final InputStream is = url.openConnection().getInputStream(); - try { - int ch; - final StringBuffer buf = new StringBuffer(); - while ((ch = is.read()) >= 0) { - buf.append((char) ch); - } - System.out.println("Result:\n" + buf); - } finally { - is.close(); - } - } + final URL url = new URL((args.length > 0) ? args[0] : "http://192.168.200.1"); + final InputStream is = url.openConnection().getInputStream(); + try { + int ch; + final StringBuffer buf = new StringBuffer(); + while ((ch = is.read()) >= 0) { + buf.append((char) ch); + } + System.out.println("Result:\n" + buf); + } finally { + is.close(); + } + } } Modified: trunk/net/src/test/org/jnode/test/net/ethernet/EthernetAddressTest.java =================================================================== --- trunk/net/src/test/org/jnode/test/net/ethernet/EthernetAddressTest.java 2008-06-08 09:38:54 UTC (rev 4217) +++ trunk/net/src/test/org/jnode/test/net/ethernet/EthernetAddressTest.java 2008-06-08 13:08:16 UTC (rev 4218) @@ -8,129 +8,121 @@ public class EthernetAddressTest extends TestCase { - - private static final String TEST_MAC_ADDRESS_STRING = "00-14-22-49-DD-2B"; - private static final String TEST_MAC_ADDRESS_STRING_DISPLAY = "00:14:22:49:DD:2B"; - private static final byte TEST_MAC_ADDRESS_BYTE_0 = (byte)0x00; - private static final byte TEST_MAC_ADDRESS_BYTE_1 = (byte)0x14; - private static final byte TEST_MAC_ADDRESS_BYTE_2 = (byte)0x22; - private static final byte TEST_MAC_ADDRESS_BYTE_3 = (byte)0x49; - private static final byte TEST_MAC_ADDRESS_BYTE_4 = (byte)0xDD; - private static final byte TEST_MAC_ADDRESS_BYTE_5 = (byte)0x2B; - private static final String TEST_MAC_ADDRESS_STRING_WRONG = "00-14-22-49-XX-2B"; - private static final String TEST_MAC_ADDRESS_STRING_WRONG_LENGTH = "00-14-22-49-DD-2B-32"; - public void testEqualsObject() { - fail("Not yet implemented"); - } + private static final String TEST_MAC_ADDRESS_STRING = "00-14-22-49-DD-2B"; + private static final String TEST_MAC_ADDRESS_STRING_DISPLAY = "00:14:22:49:DD:2B"; + private static final byte TEST_MAC_ADDRESS_BYTE_0 = (byte) 0x00; + private static final byte TEST_MAC_ADDRESS_BYTE_1 = (byte) 0x14; + private static final byte TEST_MAC_ADDRESS_BYTE_2 = (byte) 0x22; + private static final byte TEST_MAC_ADDRESS_BYTE_3 = (byte) 0x49; + private static final byte TEST_MAC_ADDRESS_BYTE_4 = (byte) 0xDD; + private static final byte TEST_MAC_ADDRESS_BYTE_5 = (byte) 0x2B; + private static final String TEST_MAC_ADDRESS_STRING_WRONG = "00-14-22-49-XX-2B"; + private static final String TEST_MAC_ADDRESS_STRING_WRONG_LENGTH = "00-14-22-49-DD-2B-32"; - public void testHashCode() { - fail("Not yet implemented"); - } + public void testEqualsObject() { + fail("Not yet implemented"); + } - public void testToString() { - EthernetAddress mac = new EthernetAddress(TEST_MAC_ADDRESS_BYTE_0, - TEST_MAC_ADDRESS_BYTE_1, - TEST_MAC_ADDRESS_BYTE_2, - TEST_MAC_ADDRESS_BYTE_3, - TEST_MAC_ADDRESS_BYTE_4, - TEST_MAC_ADDRESS_BYTE_5); - assertEquals(TEST_MAC_ADDRESS_STRING_DISPLAY, mac.toString()); - } + public void testHashCode() { + fail("Not yet implemented"); + } - public void testEthernetAddressByteArrayInt() { - fail("Not yet implemented"); - } + public void testToString() { + EthernetAddress mac = + new EthernetAddress(TEST_MAC_ADDRESS_BYTE_0, TEST_MAC_ADDRESS_BYTE_1, + TEST_MAC_ADDRESS_BYTE_2, TEST_MAC_ADDRESS_BYTE_3, TEST_MAC_ADDRESS_BYTE_4, + TEST_MAC_ADDRESS_BYTE_5); + assertEquals(TEST_MAC_ADDRESS_STRING_DISPLAY, mac.toString()); + } - public void testEthernetAddressSocketBufferInt() { - fail("Not yet implemented"); - } + public void testEthernetAddressByteArrayInt() { + fail("Not yet implemented"); + } - public void testEthernetAddressString() { - EthernetAddress mac = new EthernetAddress(TEST_MAC_ADDRESS_STRING); - assertNotNull(mac); - try{ - mac = new EthernetAddress(TEST_MAC_ADDRESS_STRING_WRONG_LENGTH); - fail(); - } catch (IllegalArgumentException e) { - assertTrue(e.getMessage().startsWith("Invalid address")); - } - try{ - mac = new EthernetAddress(TEST_MAC_ADDRESS_STRING_WRONG); - fail(); - } catch (IllegalArgumentException e) { - assertTrue(e.getMessage().startsWith("Not an ethernet address")); - } - } + public void testEthernetAddressSocketBufferInt() { + fail("Not yet implemented"); + } - public void testEthernetAddressByteByteByteByteByteByte() { - EthernetAddress mac = new EthernetAddress(TEST_MAC_ADDRESS_BYTE_0, - TEST_MAC_ADDRESS_BYTE_1, - TEST_MAC_ADDRESS_BYTE_2, - TEST_MAC_ADDRESS_BYTE_3, - TEST_MAC_ADDRESS_BYTE_4, - TEST_MAC_ADDRESS_BYTE_5); - assertNotNull(mac); - } + public void testEthernetAddressString() { + EthernetAddress mac = new EthernetAddress(TEST_MAC_ADDRESS_STRING); + assertNotNull(mac); + try { + mac = new EthernetAddress(TEST_MAC_ADDRESS_STRING_WRONG_LENGTH); + fail(); + } catch (IllegalArgumentException e) { + assertTrue(e.getMessage().startsWith("Invalid address")); + } + try { + mac = new EthernetAddress(TEST_MAC_ADDRESS_STRING_WRONG); + fail(); + } catch (IllegalArgumentException e) { + assertTrue(e.getMessage().startsWith("Not an ethernet address")); + } + } - public void testEqualsEthernetAddress() { - EthernetAddress mac = new EthernetAddress(TEST_MAC_ADDRESS_BYTE_0, - TEST_MAC_ADDRESS_BYTE_1, - TEST_MAC_ADDRESS_BYTE_2, - TEST_MAC_ADDRESS_BYTE_3, - TEST_MAC_ADDRESS_BYTE_4, - TEST_MAC_ADDRESS_BYTE_5); - assertTrue(mac.equals(new EthernetAddress(TEST_MAC_ADDRESS_STRING))); - } + public void testEthernetAddressByteByteByteByteByteByte() { + EthernetAddress mac = + new EthernetAddress(TEST_MAC_ADDRESS_BYTE_0, TEST_MAC_ADDRESS_BYTE_1, + TEST_MAC_ADDRESS_BYTE_2, TEST_MAC_ADDRESS_BYTE_3, TEST_MAC_ADDRESS_BYTE_4, + TEST_MAC_ADDRESS_BYTE_5); + assertNotNull(mac); + } - public void testEqualsHardwareAddress() { - EthernetAddress mac = new EthernetAddress(TEST_MAC_ADDRESS_BYTE_0, - TEST_MAC_ADDRESS_BYTE_1, - TEST_MAC_ADDRESS_BYTE_2, - TEST_MAC_ADDRESS_BYTE_3, - TEST_MAC_ADDRESS_BYTE_4, - TEST_MAC_ADDRESS_BYTE_5); - HardwareAddress mac2 = new EthernetAddress(TEST_MAC_ADDRESS_STRING); - assertTrue(mac.equals(mac2)); - } + public void testEqualsEthernetAddress() { + EthernetAddress mac = + new EthernetAddress(TEST_MAC_ADDRESS_BYTE_0, TEST_MAC_ADDRESS_BYTE_1, + TEST_MAC_ADDRESS_BYTE_2, TEST_MAC_ADDRESS_BYTE_3, TEST_MAC_ADDRESS_BYTE_4, + TEST_MAC_ADDRESS_BYTE_5); + assertTrue(mac.equals(new EthernetAddress(TEST_MAC_ADDRESS_STRING))); + } - public void testGetLength() { - EthernetAddress mac = new EthernetAddress(TEST_MAC_ADDRESS_STRING); - assertEquals(EthernetConstants.ETH_ALEN, mac.getLength()); - } + public void testEqualsHardwareAddress() { + EthernetAddress mac = + new EthernetAddress(TEST_MAC_ADDRESS_BYTE_0, TEST_MAC_ADDRESS_BYTE_1, + TEST_MAC_ADDRESS_BYTE_2, TEST_MAC_ADDRESS_BYTE_3, TEST_MAC_ADDRESS_BYTE_4, + TEST_MAC_ADDRESS_BYTE_5); + HardwareAddress mac2 = new EthernetAddress(TEST_MAC_ADDRESS_STRING); + assertTrue(mac.equals(mac2)); + } - public void testGet() { - EthernetAddress mac = new EthernetAddress(TEST_MAC_ADDRESS_STRING); - assertEquals(TEST_MAC_ADDRESS_BYTE_0, mac.get(0)); - assertEquals(TEST_MAC_ADDRESS_BYTE_1, mac.get(1)); - assertEquals(TEST_MAC_ADDRESS_BYTE_2, mac.get(2)); - assertEquals(TEST_MAC_ADDRESS_BYTE_3, mac.get(3)); - assertEquals(TEST_MAC_ADDRESS_BYTE_4, mac.get(4)); - assertEquals(TEST_MAC_ADDRESS_BYTE_5, mac.get(5)); - } + public void testGetLength() { + EthernetAddress mac = new EthernetAddress(TEST_MAC_ADDRESS_STRING); + assertEquals(EthernetConstants.ETH_ALEN, mac.getLength()); + } - public void testWriteToSocketBufferInt() { - fail("Not yet implemented"); - } + public void testGet() { + EthernetAddress mac = new EthernetAddress(TEST_MAC_ADDRESS_STRING); + assertEquals(TEST_MAC_ADDRESS_BYTE_0, mac.get(0)); + assertEquals(TEST_MAC_ADDRESS_BYTE_1, mac.get(1)); + assertEquals(TEST_MAC_ADDRESS_BYTE_2, mac.get(2)); + assertEquals(TEST_MAC_ADDRESS_BYTE_3, mac.get(3)); + assertEquals(TEST_MAC_ADDRESS_BYTE_4, mac.get(4)); + assertEquals(TEST_MAC_ADDRESS_BYTE_5, mac.get(5)); + } - public void testWriteToByteArrayInt() { - fail("Not yet implemented"); - } + public void testWriteToSocketBufferInt() { + fail("Not yet implemented"); + } - public void testIsBroadcast() { - EthernetAddress mac = new EthernetAddress(TEST_MAC_ADDRESS_STRING); - assertFalse(mac.isBroadcast()); - EthernetAddress broadcast = new EthernetAddress("FF-FF-FF-FF-FF-FF"); - assertTrue(broadcast.isBroadcast()); - } + public void testWriteToByteArrayInt() { + fail("Not yet implemented"); + } - public void testGetDefaultBroadcastAddress() { - fail("Not yet implemented"); - } + public void testIsBroadcast() { + EthernetAddress mac = new EthernetAddress(TEST_MAC_ADDRESS_STRING); + assertFalse(mac.isBroadcast()); + EthernetAddress broadcast = new EthernetAddress("FF-FF-FF-FF-FF-FF"); + assertTrue(broadcast.isBroadcast()); + } - public void testGetType() { - EthernetAddress mac = new EthernetAddress(TEST_MAC_ADDRESS_STRING); - assertEquals(1, mac.getType()); - } + public void testGetDefaultBroadcastAddress() { + fail("Not yet implemented"); + } + public void testGetType() { + EthernetAddress mac = new EthernetAddress(TEST_MAC_ADDRESS_STRING); + assertEquals(1, mac.getType()); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-06-14 13:24:17
|
Revision: 4237 http://jnode.svn.sourceforge.net/jnode/?rev=4237&view=rev Author: lsantha Date: 2008-06-14 06:24:10 -0700 (Sat, 14 Jun 2008) Log Message: ----------- Moved Tetris, BoxWorld, Rubik to distr games. Modified Paths: -------------- trunk/all/conf/default-plugin-list.xml trunk/gui/descriptors/org.jnode.test.gui.xml trunk/gui/src/desktop/org/jnode/desktop/classic/TaskBar.java Added Paths: ----------- trunk/distr/descriptors/org.jnode.games.xml trunk/distr/src/apps/org/jnode/games/ trunk/distr/src/apps/org/jnode/games/boxworld/ trunk/distr/src/apps/org/jnode/games/boxworld/BoxWorld.java trunk/distr/src/apps/org/jnode/games/rubik/ trunk/distr/src/apps/org/jnode/games/rubik/Rubik.java trunk/distr/src/apps/org/jnode/games/tetris/ trunk/distr/src/apps/org/jnode/games/tetris/Tetris.java Removed Paths: ------------- trunk/gui/src/test/org/jnode/test/gui/Rubik.java trunk/gui/src/test/org/jnode/test/gui/Tetris.java Modified: trunk/all/conf/default-plugin-list.xml =================================================================== --- trunk/all/conf/default-plugin-list.xml 2008-06-14 12:15:05 UTC (rev 4236) +++ trunk/all/conf/default-plugin-list.xml 2008-06-14 13:24:10 UTC (rev 4237) @@ -175,6 +175,7 @@ <plugin id="org.jnode.font.bdf"/> <plugin id="org.jnode.awt.font.bdf"/> + <plugin id="org.jnode.games"/> <plugin id="org.jnode.test.gui"/> <plugin id="org.jnode.apps.console"/> </plugin-list> Copied: trunk/distr/descriptors/org.jnode.games.xml (from rev 4231, trunk/gui/descriptors/org.jnode.test.gui.xml) =================================================================== --- trunk/distr/descriptors/org.jnode.games.xml (rev 0) +++ trunk/distr/descriptors/org.jnode.games.xml 2008-06-14 13:24:10 UTC (rev 4237) @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plugin SYSTEM "jnode.dtd"> + +<plugin id="org.jnode.games" + name="JNode Games" + version="@VERSION@" + license-name="lgpl" + provider-name="JNode.org"> + + <requires> + <import plugin="org.jnode.awt"/> + <import plugin="org.jnode.awt.font.truetype"/> + <import plugin="org.jnode.desktop"/> + </requires> + + <runtime> + <library name="jnode-distr.jar"> + <export name="org.jnode.games.boxworld.*"/> + <export name="org.jnode.games.rubik.*"/> + <export name="org.jnode.games.tetris.*"/> + </library> + </runtime> + + <extension point="org.jnode.desktop.apps"> + <application name="BoxWorld" class="org.jnode.games.boxworld.BoxWorld"/> + <application name="Rubik" class="org.jnode.games.rubik.Rubik"/> + <application name="Tetris" class="org.jnode.games.tetris.Tetris"/> + </extension> + + <extension point="org.jnode.security.permissions"> + <permission class="java.lang.RuntimePermission" name="setIO"/> + <permission class="java.lang.RuntimePermission" name="exitVM" actions="*" /> + <permission class="java.awt.AWTPermission" name="createRobot"/> + <permission class="java.awt.AWTPermission" name="readDisplayPixels"/> + <permission class="java.util.PropertyPermission" name="user.home" actions="read"/> + <permission class="java.util.PropertyPermission" name="gnu.awt.dispatchthread.priority" actions="read"/> + <permission class="java.util.PropertyPermission" name="gnu.javax.swing.DebugGraphics" actions="read"/> + </extension> + + <extension point="org.jnode.shell.aliases"> + <alias name="BoxWorld" class="org.jnode.games.boxworld.BoxWorld"/> + <alias name="Rubik" class="org.jnode.games.rubik.Rubik"/> + <alias name="Tetris" class="org.jnode.games.tetris.Tetris"/> + </extension> + +</plugin> Copied: trunk/distr/src/apps/org/jnode/games/boxworld/BoxWorld.java (from rev 4236, trunk/gui/src/test/org/jnode/test/gui/BoxWorld.java) =================================================================== --- trunk/distr/src/apps/org/jnode/games/boxworld/BoxWorld.java (rev 0) +++ trunk/distr/src/apps/org/jnode/games/boxworld/BoxWorld.java 2008-06-14 13:24:10 UTC (rev 4237) @@ -0,0 +1,1377 @@ +/* + * $Id$ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library 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 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.games.boxworld; + +import java.awt.AWTEvent; +import java.awt.CheckboxMenuItem; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Point; +import java.awt.PopupMenu; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; +import java.util.Stack; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +/** + * @author Levente S\u00e1ntha + */ +public class BoxWorld extends JComponent implements WindowListener, KeyListener, + MouseListener, MouseMotionListener, ActionListener, ItemListener { + + // ***************** WORLD DATA **************************** + private int[][] vecs = { + {81, -766241563, -831219482, -696967897, -863854201, -896130840, + -661281463, -828168022, -793433846, -758894261, 1073742156, + 10, -829120249, 20, -795533048, 1073742122, 19, -862609146, + 1073742123, 2382}, + // 1 + {105, -834465628, -900427516, -765290203, -630843034, -697000793, + -863854169, -729505560, -862543512, -861494039, -860444342, + -659182261, -826068565, -725307124, 50, -865856283, + -796648249, -728455927, -794580631, -660231894, -759943957, + 12, -831252250, 11, -661249657, 1582}, + // 2 + {97, -867003259, -766241563, -731768507, -965338778, -831316857, + -964289273, -829315704, -962189975, -693917558, -860705653, + -759943957, -2147111605, 58, -832366426, -764110586, + -930767545, -763092792, -795728536, -760993463, 1073742154, + 20, -729571161, 1073742121, 19, -895277911, 1073742026, + 1350}, + // 3 + {73, -732654331, -798779035, -697066138, -695983896, -795630200, + -660362871, -825873173, -725307124, -2147077780, 26, + -730523354, -694901432, -2147112630, 20, -728456921, + -2147144406, 19, -759943926, -2147111605, 2110}, + // 4 + {89, -767291164, -732719804, -832170651, -831316602, -663413497, + -796712537, -862543544, -861493911, -827118166, -726356725, + -625595029, 50, -731637467, -697000602, -662331096, + -661314263, -727406326, 1073742218, 12, -693885658, 11, + -828136216, 2094}, + // 5 + {169, -801927997, -701166301, -935227005, -666693468, -766241691, + -966388411, -664561498, -898523738, -964256441, -628776792, + -694999959, -928929367, -626677462, -927487542, -793531189, + -725470741, -925388436, -825019219, -724257523, -623495827, + -2146978355, 130, -767291164, -933916348, -699198299, + -798812026, -698017498, -797762425, -863886969, -729505560, + -795728504, -895081143, -794580790, -894031542, -659182261, + -859655765, -758894356, -590958196, 20, -796615449, + -2147179287, 19, -796549915, -2147177303, 3678}, + // 6 + {105, -766241563, -665479867, -832366171, -864642746, -863593145, + -762108504, -928602807, -727504726, -927553142, -893242997, + -792481588, -691719892, 1073742220, 58, -698050298, + -764142361, -796517017, -829021880, -827972247, -726292182, + 1073742187, 20, -695951128, -2147210999, 19, -827118421, + -2147177205, 3126}, + // 7 + {89, -732654331, -631892635, -798779194, -864903770, -629826233, + -595418681, -594107223, -828168022, -727406326, -692769366, + -2147046005, 42, -698017498, -663478906, -662331096, + -661314295, -2147079830, 20, -729538265, -2147113687, 19, + -830267161, -2147244855, 3398}, + // 8 + {129, -799828795, -699067099, -598305403, -731604794, -596435514, + -729505592, -862510744, -594139895, -794613590, -559470198, + -892883797, -891834004, -791431987, -690670291, -589908595, + 1073742317, 82, -698083098, -831088250, -697000697, + -796484217, -627858040, -860444438, -692802293, -859361909, + -758894356, -590991028, 20, -628907705, -625660693, 19, + -694868695, -693819094, 3430}, + // 9 + {73, -699067099, -598305403, -831055578, -596337401, -828956440, + -827906647, -727406326, -692769366, -2147046005, 34, + -664430266, -762929754, -693885528, 1073742218, 20, + -663380665, -2147179192, 19, -728358552, -2147080855, 2118}, + // 10 + {105, -865953658, -698017562, -597255802, -831382425, -964223673, + -763092760, -963174072, -928929335, -593057494, -860705653, + -759943957, -659182261, 1073742251, 58, -697099097, + -930701945, -628743992, -695032695, -861754967, -727439126, + 1073742218, 20, -862609240, 1073742217, 19, -762043159, + 1073742153, 2902}, + // 11 + {73, -732654331, -865725083, -664528666, -629793593, -862543672, + -627825431, -626644726, -726356725, -2147078805, 42, + -831186650, -830104313, -761913080, -727406199, 1073742186, + 20, -728424153, 1073742185, 19, -695951033, 1073742153, + 2870}, + // 12 + {81, -800878396, -700116700, -665643644, -664495930, -863626041, + -661445240, -660297526, -793531189, -692769493, 1073742219, + 34, -830104345, -695918328, -828005143, -2147112694, 28, + -764142299, -795565753, -2147146455, 27, -732687131, + -798779035, -2147116730, 2646}, + // 20 + {113, -868052860, -767291164, -666529468, -967764572, -999910267, + -765224762, -998860474, -997810809, -830267288, -662363864, + -962190231, -861755254, -760993558, -660231862, 66, + -833416027, -699067099, -933127803, -664430426, -764175257, + -929718136, -829217623, -694868695, 20, -697131770, + -2147213144, 19, -797762299, -2147211961, 1086}, + // 30 + {225, -937326526, -635238238, -534279742, -835515325, -734753533, + -633991837, -968814077, -900622844, -699067163, -531196539, + -698017690, -563701370, -864969210, -562783001, -763256760, + -862902808, -995646039, -794580790, -660264662, -559470166, + -927880117, -726455125, -591187509, -589974323, -656033586, + -856213074, -755745553, -2147107505, 170, -600667005, + -868085277, -767291164, -666529468, -933785148, -766241595, + -932735547, -798779226, -797795034, -596239033, -830267256, + -662331064, -963173976, -829250423, -728455927, -594139799, + -895342486, -759943957, -625595029, -624578228, + -2147043955, 36, -865693532, -697164346, -796745305, + -2147077782, 35, -758894356, -757844755, -790382259, + -2147141330, 798} + }; + + // ************** DIMENSIONS ******************** + private static final int CELL_SIZE = 20; + + private static final int X_SIZE = 20; + + private static final int Y_SIZE = 20; + + private static final int BW_WIDTH = X_SIZE * CELL_SIZE; + + private static final int BW_HEIGHT = Y_SIZE * CELL_SIZE; + + // *************** MODE CODES ******************* + private static final int START_MODE = 0; + + private static final int PLAY_MODE = 1; + + private static final int END_MODE = 2; + + private static final int HELP_MODE = 3; + + // *********** MOVE CODES **************** + private static final int LEFT_MOVE = 1; + + private static final int RIGHT_MOVE = LEFT_MOVE + 1; + + private static final int UP_MOVE = RIGHT_MOVE + 1; + + private static final int DOWN_MOVE = UP_MOVE + 1; + + private static final int PUSH_BASE = DOWN_MOVE; + + private static final int LEFT_PUSH = PUSH_BASE + 1; + + private static final int RIGHT_PUSH = LEFT_PUSH + 1; + + private static final int UP_PUSH = RIGHT_PUSH + 1; + + private static final int DOWN_PUSH = UP_PUSH + 1; + + private static final int DRAW_BASE = DOWN_PUSH; + + private static final int LEFT_DRAW = DRAW_BASE + 1; + + private static final int RIGHT_DRAW = LEFT_DRAW + 1; + + private static final int UP_DRAW = RIGHT_DRAW + 1; + + private static final int DOWN_DRAW = UP_DRAW + 1; + + // **************** STATE CODE ***************** + private static final int NULL_ST = 0; + + private static final int WALL_ST = 1; + + private static final int BACK_ST = 2; + + private static final int GOAL_ST = 3; + + private static final int BOX_ST = 4; + + private static final int FIT_ST = 5; + + private static final int MAN_ST = 6; + + private static final int MAN_GOAL_ST = 7; + + private int gameMode = PLAY_MODE; + + // current world ID + private int worldId = 0; + + // current world data + private int[] vec = vecs[worldId]; + + // current world + private int[][] state = new int[X_SIZE][Y_SIZE]; + + // goals list + private int[] goals; + + // suspends the current movement at an obstacle + private boolean repeat = true; + + // end state + // private boolean endState = false; + + // controlls the speed of animation + private int SLEEP = 5; + + // current and previous position of the man + private int x, y, xo, yo; + + // popup menu + private PopupMenu menu; + + private CheckboxMenuItem beep; + + // **************** APPLET METHODS ************************* + // init applet + public void init() { + + setBackground(Color.lightGray); + + x = xo = 10; + y = yo = 10; + // loading the first wold in the world table + loadWorld(); + + // registering listeners + addKeyListener(this); + addMouseListener(this); + addMouseMotionListener(this); + setFocusable(true); + enableEvents(AWTEvent.FOCUS_EVENT_MASK); + + requestFocus(); + /* + // building the popup menu + menu = new PopupMenu(); + MenuItem start = new MenuItem("Start"); + start.addActionListener(this); + start.setActionCommand("start"); + menu.add(start); + MenuItem next = new MenuItem("Next"); + next.addActionListener(this); + next.setActionCommand("next"); + menu.add(next); + MenuItem previous = new MenuItem("Previous"); + previous.addActionListener(this); + previous.setActionCommand("previous"); + menu.add(previous); + + menu.addSeparator(); + + MenuItem undo = new MenuItem("Undo"); + undo.addActionListener(this); + undo.setActionCommand("undo"); + menu.add(undo); + MenuItem redo = new MenuItem("Redo"); + redo.addActionListener(this); + redo.setActionCommand("redo"); + menu.add(redo); + + menu.addSeparator(); + + beep = new CheckboxMenuItem("Beep", beepOn); + beep.addItemListener(this); + beep.setActionCommand("beep"); + menu.add(beep); + + add(menu); + */ + } + + // start applet + public void start() { + requestFocus(); + } + + private void loadWorld() { + int sh, s, n, xx, yy, ind = 0; + // int len = vec.length; + List<Integer> gv = new ArrayList<Integer>(); + for (int i = 0; i < 4; i++) { + s = 0x00000007 & vec[ind]; + n = vec[ind] >> 3; + ind++; + for (int j = 0; j < n; j++, ind++) { + sh = 0x00000003 & (vec[ind] >> 30); + // int m = 0xFFFFFFFF; + // int ssh = 0; + int v = vec[ind]; + for (int k = 0; k < sh; k++) { + xx = 0x0000001F & v; + v = v >> 5; + yy = 0x0000001F & v; + v = v >> 5; + if (xx < X_SIZE && yy < Y_SIZE) { + if (s == GOAL_ST) { + gv.add(xx | (yy << 16)); + } + if (s == BOX_ST && state[xx][yy] == GOAL_ST || + s == GOAL_ST && state[xx][yy] == BOX_ST) { + state[xx][yy] = FIT_ST; + } else if (s == MAN_ST && state[xx][yy] == GOAL_ST || + s == GOAL_ST && state[xx][yy] == MAN_ST) { + state[xx][yy] = MAN_GOAL_ST; + } else { + state[xx][yy] = s; + } + } + } + } + } + final int goal_cnt = gv.size(); + goals = new int[goal_cnt]; + int i = 0; + for (int v : gv) { + goals[i++] = v; + } + int v = vec[ind] >> 3; + xx = 0x0000001F & v; + v = v >> 5; + yy = 0x0000001F & v; + state[xx][yy] = MAN_ST; + x = xx; + y = yy; + // endState = false; + } + + // ************************************************************************************ + // ******************************* EVENT HANDLING + // ************************************* + // ************************************************************************************ + + // ----------------------------------KEY + // EVENTS---------------------------------------- + + public void keyPressed(KeyEvent e) { + if (gameMode == START_MODE) { + controlWorld(KeyEvent.VK_S); + } else if (gameMode == END_MODE) { + controlWorld(KeyEvent.VK_N); + } else { + int key = e.getKeyCode(); + int code = key == KeyEvent.VK_LEFT ? LEFT_MOVE : + key == KeyEvent.VK_RIGHT ? RIGHT_MOVE : + key == KeyEvent.VK_UP ? UP_MOVE : + key == KeyEvent.VK_DOWN ? DOWN_MOVE : -1; + if (code > 0) { + if (gameMode == PLAY_MODE) { + changeState(code); + } + } else { + controlWorld(key); + } + } + } + + // ----------------------------------MOUSE + // EVENTS--------------------------------------- + public void mousePressed(MouseEvent e) { + if (SwingUtilities.isLeftMouseButton(e)) { + if (this.contains(e.getX(), e.getY())) { + if (!this.hasFocus() && this.isRequestFocusEnabled()) { + this.requestFocus(); + } + } + } + + if (gameMode != PLAY_MODE) { + changeMode(); + } else { + if (e.isPopupTrigger()) { +// menu.show(this, e.getX(), e.getY()); + return; + } + + if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == 0) { + return; + } + + moveTo(e.getX(), e.getY()); + } + } + + public void mouseClicked(MouseEvent e) { // changeMode() ; + } + + public void mouseDragged(MouseEvent e) { + /* + * if(e.isPopupTrigger()){ menu.show(this,e.getX(),e.getY()); return; } + * if((e.getModifiers()& e.BUTTON1_MASK) == 0) + */ + moveTo2(e.getX(), e.getY()); + } + + public void mouseReleased(MouseEvent e) { + if (e.isPopupTrigger()) { +// menu.show(this, e.getX(), e.getY()); + } + } + + // ----------------------------------ACTION + // EVENTS------------------------------------- + // FROM MENU + public void actionPerformed(ActionEvent e) { + String command = e.getActionCommand(); + if ("start".equals(command)) { + startWorld(); + } else if ("next".equals(command)) { + nextWorld(); + } else if ("previous".equals(command)) { + previousWorld(); + } else if ("undo".equals(command)) { + undo(); + } else if ("redo".equals(command)) { + redo(); + } + } + + // ----------------------------------ITEM + // EVENTS---------------------------------------- + // CHECKBOX MENUITEM + public void itemStateChanged(ItemEvent e) { + toggleBeep(); + } + + // ************************************************************************************* + // ****************GAME CONTROL WITH + // MOUSE********************************************** + // ************************************************************************************* + private void moveTo(int xpos, int ypos) { + repeat = true; + int x1 = ypos / CELL_SIZE; + int y1 = xpos / CELL_SIZE; + int d; + boolean valid = true; + int st, bc = 0; + if (x1 == x && y1 != y) { + if (y1 > y) { + for (int i = y; i <= y1; i++) { + st = state[x][i]; + if (st == WALL_ST || st == NULL_ST) { + valid = false; + break; + } else if (st == BOX_ST || st == FIT_ST) { + bc++; + if (bc > 1) { + valid = false; + break; + } + } + } + } else { + for (int i = y1; i <= y; i++) { + st = state[x][i]; + if (st == WALL_ST || st == NULL_ST) { + valid = false; + break; + } else if (st == BOX_ST || st == FIT_ST) { + bc++; + if (bc > 1) { + valid = false; + break; + } + } + } + } + } else if (x1 != x && y1 == y) { + if (x1 > x) { + for (int i = x; i <= x1; i++) { + st = state[i][y]; + if (st == WALL_ST || st == NULL_ST) { + valid = false; + break; + } else if (st == BOX_ST || st == FIT_ST) { + bc++; + if (bc > 1) { + valid = false; + break; + } + } + } + } else { + for (int i = x1; i <= x; i++) { + st = state[i][y]; + if (st == WALL_ST || st == NULL_ST) { + valid = false; + break; + } else if (st == BOX_ST || st == FIT_ST) { + bc++; + if (bc > 1) { + valid = false; + break; + } + } + } + } + } else { + valid = false; + } + + if (valid) { + if (x1 == x && y1 != y) { + if (y1 > y) { + d = y1 - y; + for (int i = 0; i < d && repeat; i++) { + changeState(RIGHT_MOVE); + try { + Thread.sleep(SLEEP); + } catch (InterruptedException e1) { + //empty + } + } + } else { + d = y - y1; + for (int i = 0; i < d && repeat; i++) { + changeState(LEFT_MOVE); + try { + Thread.sleep(SLEEP); + } catch (InterruptedException e1) { + //empty + } + } + } + } else if (x1 != x && y1 == y) { + if (x1 > x) { + d = x1 - x; + for (int i = 0; i < d && repeat; i++) { + changeState(DOWN_MOVE); + try { + Thread.sleep(SLEEP); + } catch (InterruptedException e1) { + //empty + } + } + } else { + d = x - x1; + for (int i = 0; i < d && repeat; i++) { + changeState(UP_MOVE); + try { + Thread.sleep(SLEEP); + } catch (InterruptedException e1) { + //empty + } + } + } + } + } else { + List<Point> path = findPath(new Point(y, x), new Point(y1, x1)); + + if (path.size() > 1) { + Point cpnt, opnt; + opnt = (Point) path.get(0); + int psize = path.size(); + for (int i = 1; i < psize && repeat; i++) { + cpnt = (Point) path.get(i); + moveOne(cpnt.y, cpnt.x, opnt.y, opnt.x); + opnt = cpnt; + try { + Thread.sleep(SLEEP); + } catch (InterruptedException e1) { + //empty + } + } + } + } + } + + private void moveOne(int x1, int y1, int x, int y) { + + int dx = x - x1, dy = y - y1; + + if (Math.abs(dx) + Math.abs(dy) != 1) { + return; + } + + if (dx == -1) { + changeState(DOWN_MOVE); + } else if (dx == 1) { + changeState(UP_MOVE); + } else if (dy == -1) { + changeState(RIGHT_MOVE); + } else if (dy == 1) { + changeState(LEFT_MOVE); + } + } + + private List<Point> findPath(Point p1, Point p2) { + List<Point> nlist = new ArrayList<Point>(); + List<Point> path = new ArrayList<Point>(); + Hashtable<Point, Point> vmap = new Hashtable<Point, Point>(); + nlist.add(p1); + + Point pp = p1, pp2 = null; + int xx, yy, vi = 0; + while (!(pp.equals(p2) || nlist.size() == vi)) { + + pp = (Point) nlist.get(vi++); + + xx = pp.x - 1; + yy = pp.y; + if (xx >= 0 && + (state[yy][xx] == BACK_ST || state[yy][xx] == GOAL_ST || state[yy][xx] == GOAL_ST) && + !vmap.containsKey(pp2 = new Point(xx, yy)) && + !nlist.contains(pp2)) { + nlist.add(pp2); + vmap.put(pp2, pp); + } + + xx = pp.x + 1; + if (xx < X_SIZE && + (state[yy][xx] == BACK_ST || state[yy][xx] == GOAL_ST || state[yy][xx] == GOAL_ST) && + !vmap.containsKey(pp2 = new Point(xx, yy)) && + !nlist.contains(pp2)) { + nlist.add(pp2); + vmap.put(pp2, pp); + } + + xx = pp.x; + yy = pp.y - 1; + if (yy >= 0 && + (state[yy][xx] == BACK_ST || state[yy][xx] == GOAL_ST || state[yy][xx] == GOAL_ST) && + !vmap.containsKey(pp2 = new Point(xx, yy)) && + !nlist.contains(pp2)) { + nlist.add(pp2); + vmap.put(pp2, pp); + } + + yy = pp.y + 1; + if (yy < Y_SIZE && + (state[yy][xx] == BACK_ST || state[yy][xx] == GOAL_ST || state[yy][xx] == GOAL_ST) && + !vmap.containsKey(pp2 = new Point(xx, yy)) && + !nlist.contains(pp2)) { + nlist.add(pp2); + vmap.put(pp2, pp); + } + } + if (pp.equals(p2)) { + do { + path.add(0, pp); + pp2 = pp; + pp = (Point) vmap.get(pp); + } while (pp2 != pp && pp != null); + } + return path; + } + + public void moveTo2(int xpos, int ypos) { + repeat = true; + int x1 = ypos / CELL_SIZE; + int y1 = xpos / CELL_SIZE; + int d; + + if (state[x1][y1] == NULL_ST || state[x1][y1] == WALL_ST) + return; + if (x1 == x && y1 != y) { + if (y1 > y) { + d = y1 - y; + for (int i = 0; i < d && repeat; i++) { + changeState(RIGHT_MOVE); + } + } else { + d = y - y1; + for (int i = 0; i < d && repeat; i++) { + changeState(LEFT_MOVE); + } + } + } else if (x1 != x && y1 == y) { + if (x1 > x) { + d = x1 - x; + for (int i = 0; i < d && repeat; i++) { + changeState(DOWN_MOVE); + } + } else { + d = x - x1; + for (int i = 0; i < d && repeat; i++) { + changeState(UP_MOVE); + } + } + } + } + + private void changeMode() { + switch (gameMode) { + case START_MODE: { + gameMode = PLAY_MODE; + break; + } + case PLAY_MODE: { + break; + } + case HELP_MODE: { + break; + } + case END_MODE: { + nextWorld(); + gameMode = PLAY_MODE; + break; + } + } + update(getGraphics()); + + } + + private void controlWorld(int key) { + switch (key) { + case KeyEvent.VK_N: + // next world + nextWorld(); + break; + case KeyEvent.VK_P: + // previous world + previousWorld(); + break; + case KeyEvent.VK_S: + // restart + startWorld(); + break; + case KeyEvent.VK_U: + // undo + if (gameMode == PLAY_MODE) + undo(); + break; + case KeyEvent.VK_R: + // redo + if (gameMode == PLAY_MODE) + redo(); + break; + case KeyEvent.VK_B: + // toggle beep + toggleBeep(); + break; + case KeyEvent.VK_H: + // show help + help(); + break; + case KeyEvent.VK_C: + // continue the game + continueGame(); + break; + } + } + + private void nextWorld() { + worldId++; + if (worldId == 5) { + // int x = worldId * 100; + } + if (worldId == vecs.length) + worldId = 0; + vec = vecs[worldId]; + controlWorld(KeyEvent.VK_S); + } + + private void previousWorld() { + worldId--; + if (worldId < 0) + worldId = vecs.length - 1; + vec = vecs[worldId]; + controlWorld(KeyEvent.VK_S); + } + + private void startWorld() { + ereaseWorld(); + loadWorld(); + repaint(); + undoStack.removeAllElements(); + redoStack.removeAllElements(); + gameMode = PLAY_MODE; + } + + private void toggleBeep() { + beepOn = !beepOn; +// beep.setState(beepOn); + } + + private void help() { + gameMode = HELP_MODE; + changeMode(); + } + + private void continueGame() { + gameMode = PLAY_MODE; + update(getGraphics()); + } + + private void ereaseWorld() { + for (int i = 0; i < X_SIZE; i++) { + for (int j = 0; j < Y_SIZE; j++) { + state[i][j] = 0; + } + } + } + + // ******************* UNDO ******************** + + private Stack<Integer> undoStack = new Stack<Integer>(); + + private Stack<Integer> redoStack = new Stack<Integer>(); + + private boolean isUndo = false; + + private boolean isRedo = false; + + private void undo() { + isUndo = true; + if (undoStack.empty()) { + beep(); + } else { + changeState(((Integer) undoStack.pop()).intValue()); + } + isUndo = false; + } + + private void redo() { + isRedo = true; + if (redoStack.empty()) { + beep(); + } else { + changeState(((Integer) redoStack.pop()).intValue()); + } + isRedo = false; + } + + private boolean checkEnd() { + int v, x, y; + boolean ret = true; + for (int i = 0; i < goals.length; i++) { + v = goals[i]; + x = 0xFFFF & v; + y = 0xFFFF & (v >> 16); + if (state[x][y] != FIT_ST) { + ret = false; + break; + } + } + return ret; + } + + // ****************** GRAPHICS ********************************* + + // private Image[] imgVec = new Image[8]; + + // private int ISIZE = CELL_SIZE; + // STATE PAINTING + + /** + * Paints the NULL state + */ + private void paintNull(Graphics g, int j, int i) { + // Image img=imgVec[NULL_ST]; + // if(img==null){ + // img=createImage(ISIZE,ISIZE); + // imgVec[NULL_ST]=img; + // Graphics ig=img.getGraphics(); + g.setColor(Color.black); + g.fillRect(j * CELL_SIZE, i * CELL_SIZE, CELL_SIZE, CELL_SIZE); + // } + // g.drawImage(img,j * DIM, i * DIM,this); + } + + private void paintWall(Graphics g, int j, int i) { + // Image img=imgVec[WALL_ST]; + // if(img==null){ + // img=createImage(ISIZE,ISIZE); + // imgVec[WALL_ST]=img; + // Graphics ig=img.getGraphics(); + g.setColor(Color.gray); + g.fillRect(j * CELL_SIZE, i * CELL_SIZE, CELL_SIZE, CELL_SIZE); + g.setColor(Color.lightGray); + g.drawRect(j * CELL_SIZE + 1, i * CELL_SIZE + 1, CELL_SIZE - 2, + CELL_SIZE - 2); + // } + // g.drawImage(img,j * CELL_SIZE, i * CELL_SIZE,this); + } + + private void paintBack(Graphics g, int j, int i) { + // Image img=imgVec[BACK_ST]; + // if(img==null){ + // img=createImage(ISIZE,ISIZE); + // imgVec[BACK_ST]=img; + // Graphics ig=img.getGraphics(); + g.setColor(Color.blue); + g.fillRect(j * CELL_SIZE, i * CELL_SIZE, CELL_SIZE, CELL_SIZE); + // } + // g.drawImage(img,j * CELL_SIZE, i * CELL_SIZE,this); + } + + private void paintGoal(Graphics g, int j, int i) { + // Image img=imgVec[GOAL_ST]; + // if(img==null){ + // img=createImage(ISIZE,ISIZE); + // imgVec[GOAL_ST]=img; + // Graphics ig=img.getGraphics(); + g.setColor(Color.green); + g.fillOval(j * CELL_SIZE + CELL_SIZE / 4, + i * CELL_SIZE + CELL_SIZE / 4, CELL_SIZE / 2, CELL_SIZE / 2); + // } + // g.drawImage(img,j * CELL_SIZE, i * CELL_SIZE,this); + } + + private void paintBox(Graphics g, int j, int i, Color c) { + g.setColor(c); + g.fillRect(j * CELL_SIZE, i * CELL_SIZE, CELL_SIZE, CELL_SIZE); + g.setColor(Color.lightGray); + g.drawRect(j * CELL_SIZE + 1, i * CELL_SIZE + 1, CELL_SIZE - 2, + CELL_SIZE - 2); + g.drawLine(j * CELL_SIZE + 1, i * CELL_SIZE + 1, (j + 1) * CELL_SIZE - 1, + (i + 1) * CELL_SIZE - 1); + g.drawLine(j * CELL_SIZE + 1, (i + 1) * CELL_SIZE - 1, (j + 1) * CELL_SIZE - 1, + i * CELL_SIZE + 1); + } + + private void paintBox(Graphics g, int j, int i) { + // Image img=imgVec[BOX_ST]; + // if(img==null){ + // img=createImage(ISIZE,ISIZE); + // imgVec[BOX_ST]=img; + // Graphics ig=img.getGraphics(); + paintBox(g, j, i, Color.yellow); + // } + // g.drawImage(img,j * CELL_SIZE, i * CELL_SIZE,this); + + } + + private void paintFit(Graphics g, int j, int i) { + paintBox(g, j, i, Color.red); + } + + private void paintMan(Graphics g, int j, int i) { + g.setColor(Color.cyan); + + // head + g.fillOval(j * CELL_SIZE + CELL_SIZE / 2 - CELL_SIZE / 8, i * CELL_SIZE + + CELL_SIZE / 16, CELL_SIZE / 4, CELL_SIZE / 4); + + // g.drawLine(j * CELL_SIZE + CELL_SIZE / 2, i * CELL_SIZE + 2, j * + // CELL_SIZE + CELL_SIZE / 2, i * CELL_SIZE + 13); + + // body + g.fillRect(j * CELL_SIZE + CELL_SIZE / 2 - CELL_SIZE / 16, i * + CELL_SIZE + CELL_SIZE / 4, CELL_SIZE / 8, CELL_SIZE / 3 + + CELL_SIZE / 12); + + // g.drawLine(j * CELL_SIZE + CELL_SIZE / 2 + 1, i * CELL_SIZE + 8, j * + // CELL_SIZE + CELL_SIZE / 2 + 1, i * CELL_SIZE + 13); + + // arms + g.fillRect(j * CELL_SIZE + CELL_SIZE / 8, i * CELL_SIZE + CELL_SIZE * 5 / 16, + CELL_SIZE * 3 / 4, CELL_SIZE / 16); + + // legs + g.drawLine(j * CELL_SIZE + CELL_SIZE / 2, i * CELL_SIZE + CELL_SIZE * 7 / 12, + j * CELL_SIZE + 4, (i + 1) * CELL_SIZE - 2); + g.drawLine(j * CELL_SIZE + CELL_SIZE / 2, i * CELL_SIZE + CELL_SIZE * 7 / 12, + (j + 1) * CELL_SIZE - 4, (i + 1) * CELL_SIZE - 2); + + g.drawLine(j * CELL_SIZE + CELL_SIZE / 2 + 1, i * CELL_SIZE + CELL_SIZE * 7 / 12, + j * CELL_SIZE + 4 + 1, (i + 1) * CELL_SIZE - 2); + g.drawLine(j * CELL_SIZE + CELL_SIZE / 2 - 1, i * CELL_SIZE + CELL_SIZE * 7 / 12, + (j + 1) * CELL_SIZE - 4 - 1, (i + 1) * CELL_SIZE - 2); + + g.drawLine(j * CELL_SIZE + CELL_SIZE / 2 + 2, i * CELL_SIZE + CELL_SIZE * 7 / 12, + j * CELL_SIZE + 4 + 2, (i + 1) * CELL_SIZE - 2); + g.drawLine(j * CELL_SIZE + CELL_SIZE / 2 - 2, i * CELL_SIZE + CELL_SIZE * 7 / 12, + (j + 1) * CELL_SIZE - 4 - 2, (i + 1) * CELL_SIZE - 2); + + g.drawLine(j * CELL_SIZE + CELL_SIZE / 2 + 3, i * CELL_SIZE + CELL_SIZE * 7 / 12, + j * CELL_SIZE + 4 + 3, (i + 1) * CELL_SIZE - 2); + g.drawLine(j * CELL_SIZE + CELL_SIZE / 2 - 3, i * CELL_SIZE + CELL_SIZE * 7 / 12, + (j + 1) * CELL_SIZE - 4 - 3, (i + 1) * CELL_SIZE - 2); + } + + private void paintManGoal(Graphics g, int j, int i) { + paintGoal(g, j, i); + paintMan(g, j, i); + } + + private void paintStart(Graphics g) { + g.setColor(Color.black); + int dx = 200; + int dy = 100; + int x = (BW_WIDTH - dx) / 2; + int y = (BW_HEIGHT - dy) / 2; + g.fillRect(x, y, dx, dy); + g.setColor(Color.white); + g.drawRect(x + 2, y + 2, dx - 4, dy - 4); + g.drawRect(x + 3, y + 3, dx - 6, dy - 6); + g.drawRect(x + 4, y + 4, dx - 8, dy - 8); + g.drawString("CLICK HERE!", x + 70, y + 50); + } + + private void paintEnd(Graphics g) { + g.setColor(Color.black); + int dx = 200; + int dy = 100; + int x = (BW_WIDTH - dx) / 2; + int y = (BW_HEIGHT - dy) / 2; + g.fillRect(x, y, dx, dy); + g.setColor(Color.white); + g.drawRect(x + 2, y + 2, dx - 4, dy - 4); + g.drawRect(x + 3, y + 3, dx - 6, dy - 6); + g.drawRect(x + 4, y + 4, dx - 8, dy - 8); + g.drawString("GOOD JOB!", x + 70, y + 50); + } + + private static String[] help = {"s - start game", "n - next world", + "p - previous world", "u - undo", "r - redo", "b - toggle beep", + "h - help", " ", "Press C to continue", " ", "Created by", + "Levente S\u00e1ntha, 2002", + + }; + + private void paintHelp(Graphics g) { + g.setColor(Color.black); + int dx = 200; + int dy = 320; + int x = (BW_WIDTH - dx) / 2; + int y = (BW_HEIGHT - dy) / 2; + g.fillRect(x, y, dx, dy); + g.setColor(Color.white); + g.drawRect(x + 2, y + 2, dx - 4, dy - 4); + g.drawRect(x + 3, y + 3, dx - 6, dy - 6); + g.drawRect(x + 4, y + 4, dx - 8, dy - 8); + g.drawString("H E L P", x + 80, y + 40); + for (int i = 0; i < help.length; i++) { + g.drawString(help[i], x + 40, y + 70 + 20 * i); + } + } + + private void paintShape(Graphics g, int j, int i) { + int c = state[i][j]; + if (c > NULL_ST) + switch (c) { + case NULL_ST: + paintNull(g, j, i); + break; + case WALL_ST: + paintWall(g, j, i); + break; + case BACK_ST: + paintBack(g, j, i); + break; + case GOAL_ST: + paintBack(g, j, i); + paintGoal(g, j, i); + break; + case BOX_ST: + paintBox(g, j, i); + break; + case FIT_ST: + paintFit(g, j, i); + break; + case MAN_ST: + paintBack(g, j, i); + paintMan(g, j, i); + break; + case MAN_GOAL_ST: + paintBack(g, j, i); + paintManGoal(g, j, i); + break; + } + } + + private Image iBuff = null; + + public void paint(Graphics gr) { + if (iBuff == null) { + iBuff = createImage(BW_WIDTH, BW_HEIGHT); + } + + Graphics g = iBuff.getGraphics(); + g.setColor(Color.black); + g.fillRect(0, 0, BW_WIDTH, BW_HEIGHT); + switch (gameMode) { + case START_MODE: { + paintStart(g); + break; + } + case PLAY_MODE: { + for (int j = 0; j < X_SIZE; j++) { + for (int i = 0; i < Y_SIZE; i++) { + paintShape(g, j, i); + } + } + break; + } + case HELP_MODE: { + paintHelp(g); + break; + } + case END_MODE: { + paintEnd(g); + break; + } + } + g.dispose(); + gr.drawImage(iBuff, 0, 0, this); + } + + public void update(Graphics g) { + paint(g); + } + + private int invert(int key) { + int inv = -1; + switch (key) { + case LEFT_MOVE: + inv = RIGHT_MOVE; + break; + case RIGHT_MOVE: + inv = LEFT_MOVE; + break; + case UP_MOVE: + inv = DOWN_MOVE; + break; + case DOWN_MOVE: + inv = UP_MOVE; + break; + case LEFT_PUSH: + inv = RIGHT_DRAW; + break; + case RIGHT_PUSH: + inv = LEFT_DRAW; + break; + case UP_PUSH: + inv = DOWN_DRAW; + break; + case DOWN_PUSH: + inv = UP_DRAW; + break; + case LEFT_DRAW: + inv = RIGHT_MOVE; + break; + case RIGHT_DRAW: + inv = LEFT_MOVE; + break; + case UP_DRAW: + inv = DOWN_MOVE; + break; + case DOWN_DRAW: + inv = UP_MOVE; + break; + } + return inv; + } + + private void undoController(int key) { + if (isUndo) { + redoStack.push(new Integer(invert(key))); + } else { + if (redoStack.size() > 0 && !isRedo) + redoStack.removeAllElements(); + undoStack.push(new Integer(invert(key))); + } + } + + private void changeState(int key) { + Graphics g = getGraphics(); + int xt = x, yt = y, ct; + xo = x; + yo = y; + boolean isDraw = false; + switch (key) { + case LEFT_MOVE: + y--; + yt = y - 1; + break; + case RIGHT_MOVE: + y++; + yt = y + 1; + break; + case UP_MOVE: + x--; + xt = x - 1; + break; + case DOWN_MOVE: + x++; + xt = x + 1; + break; + case LEFT_DRAW: + yt = y + 1; + y--; + isDraw = true; + break; + case RIGHT_DRAW: + yt = y - 1; + y++; + isDraw = true; + break; + case UP_DRAW: + xt = x + 1; + x--; + isDraw = true; + break; + case DOWN_DRAW: + xt = x - 1; + x++; + isDraw = true; + break; + } + int c = state[x][y]; + if (isDraw) { + undoController(key); + cellExited(xo, yo); + cellExited(xt, yt); + cellEntered(x, y, MAN_ST); + cellEntered(xo, yo, BOX_ST); + paintShape(g, yt, xt); + paintShape(g, y, x); + paintShape(g, yo, xo); + } else if (c == BACK_ST || c == GOAL_ST) { + undoController(key); + cellExited(xo, yo); + cellEntered(x, y, MAN_ST); + paintShape(g, y, x); + paintShape(g, yo, xo); + } else if (c == BOX_ST || c == FIT_ST) { + ct = state[xt][yt]; + if (ct == BACK_ST || ct == GOAL_ST) { + undoController(PUSH_BASE + key); + cellExited(xo, yo); + cellExited(x, y); + cellEntered(x, y, MAN_ST); + cellEntered(xt, yt, BOX_ST); + paintShape(g, yt, xt); + paintShape(g, y, x); + paintShape(g, yo, xo); + } else { + block(); + } + } else { + block(); + } + if (checkEnd()) { + gameMode = END_MODE; + paintEnd(g); + } + } + + private void cellEntered(int x, int y, int mst) { + int st = state[x][y]; + if (st == BACK_ST) { + state[x][y] = mst; + } else if (st == GOAL_ST) { + state[x][y] = mst == MAN_ST ? MAN_GOAL_ST : FIT_ST; + } + } + + private void cellExited(int x, int y) { + int st = state[x][y]; + if (st == MAN_ST || st == BOX_ST) { + state[x][y] = BACK_ST; + } else if (st == FIT_ST || st == MAN_GOAL_ST) { + state[x][y] = GOAL_ST; + } + } + + private void block() { + x = xo; + y = yo; + repeat = false; + beep(); + } + + private boolean beepOn = true; + + private void beep() { + // if (beepOn) getToolkit().beep(); + } + + public Dimension getPreferredSize() { + return new Dimension(BW_WIDTH, BW_HEIGHT); + } + + public void windowClosing(WindowEvent e) { + System.exit(0); + } + + // *********** MAIN ************************ + public static void main(String[] argv) { + BoxWorld bw = new BoxWorld(); + bw.init(); + Frame frame = new JFrame("Boxworld"); + frame.setResizable(false); + frame.add(bw); + frame.addWindowListener(bw); + frame.pack(); + frame.setSize(400, 400); + frame.setLocation(40, 40); + frame.setVisible(true); + bw.requestFocus(); + // frame.setVisible(true); + } + + // ************ EMPTY METHODS ********************* + public void windowActivated(WindowEvent e) { + } + + public void windowDeactivated(WindowEvent e) { + } + + public void windowIconified(WindowEvent e) { + } + + public void windowDeiconified(WindowEvent e) { + } + + public void windowOpened(WindowEvent e) { + } + + public void windowClosed(WindowEvent e) { + } + + public void keyReleased(KeyEvent e) { + } + + public void keyTyped(KeyEvent e) { + } + + public void mouseEntered(MouseEvent e) { + } + + public void mouseExited(MouseEvent e) { + } + + public void mouseMoved(MouseEvent e) { + } +} Property changes on: trunk/distr/src/apps/org/jnode/games/boxworld/BoxWorld.java ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Copied: trunk/distr/src/apps/org/jnode/games/rubik/Rubik.java (from rev 4236, trunk/gui/src/test/org/jnode/test/gui/Rubik.java) =================================================================== --- trunk/distr/src/apps/org/jnode/games/rubik/Rubik.java (rev 0) +++ trunk/distr/src/apps/org/jnode/games/rubik/Rubik.java 2008-06-14 13:24:10 UTC (rev 4237) @@ -0,0 +1,676 @@ +/* + * $Id$ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library 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 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.games.rubik; +// Rubik's Cube 3D simulator +// Karl H\u00f6rnell, March 11 1996 +// Last modified October 6 +// Adapted to JNode by Levente S\u00e1ntha + +import java.awt.AWTEvent; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +public final class Rubik extends JComponent { + int i, j, k, n, o, p, q, lastX, lastY, dx, dy; + int rectX[], rectY[]; + Color colList[], bgcolor; + final double sideVec[] = {0, 0, 1, 0, 0, -1, 0, -1, 0, 1, 0, 0, 0, 1, 0, -1, 0, 0}; // Normal vectors + final double corners[] = {-1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, + -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1}; // Vertex co-ordinates + double topCorners[], botCorners[]; + final int sides[] = {4, 5, 6, 7, 3, 2, 1, 0, 0, 1, 5, 4, 1, 2, 6, 5, 2, 3, 7, 6, 0, 4, 7, 3}; + final int nextSide[] = {2, 3, 4, 5, 4, 3, 2, 5, 1, 3, 0, 5, 1, 4, 0, 2, 1, 5, 0, 3, 2, 0, 4, 1}; + final int mainBlocks[] = {0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3}; + final int twistDir[] = {-1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1}; + final int colDir[] = {-1, -1, 1, -1, 1, -1}; + final int circleOrder[] = {0, 1, 2, 5, 8, 7, 6, 3}; + int topBlocks[], botBlocks[]; + int sideCols[], sideW, sideH; + int dragReg, twistSide = -1; + int nearSide[], buffer[]; // Which side belongs to dragCorn + double dragCorn[], dragDir[]; + double eye[] = {0.3651, 0.1826, -0.9129}; // Initial observer co-ordinate axes (view) + double eX[] = {0.9309, -0.0716, 0.3581}; // (sideways) + double eY[]; // (vertical) + double Teye[], TeX[], TeY[]; + double light[], temp[] = {0, 0, 0}, temp2[] = {0, 0, 0}, newCoord[]; + double sx, sy, sdxh, sdyh, sdxv, sdyv, d, t1, t2, t3, t4, t5, t6; + double phi, phibase = 0, Cphi, Sphi, currDragDir[]; + + boolean naturalState = true, twisting = false, OKtoDrag = false; + Math m; + Graphics offGraphics; + Image offImage; + + public void init() { + enableEvents(AWTEvent.KEY_EVENT_MASK); + setFocusable(true); + enableEvents(AWTEvent.FOCUS_EVENT_MASK); + addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent event) { + if (SwingUtilities.isLeftMouseButton(event)) { + if (Rubik.this.contains(event.getX(), event.getY())) { + if (!Rubik.this.hasFocus() && Rubik.this.isRequestFocusEnabled()) { + Rubik.this.requestFocus(); + } + } + } + Rubik.this.mousePressed(event.getX(), event.getY()); + } + + public void mouseReleased(MouseEvent event) { + Rubik.this.mouseReleased(event.getX(), event.getY()); + } + }); + addMouseMotionListener(new MouseMotionAdapter() { + public void mouseDragged(MouseEvent event) { + Rubik.this.mouseDragged(event.getX(), event.getY()); + } + }); + addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent event) { + Rubik.this.keyPressed(event.getKeyChar()); + } + }); + // Double buffer + offImage = createImage(120, 120); + offGraphics = offImage.getGraphics(); + rectX = new int[4]; + rectY = new int[4]; + // Projected co-ordinates (on screen) + newCoord = new double[16]; + dragDir = new double[24]; + dragCorn = new double[96]; + // Vertex co-ordinate storage + topCorners = new double[24]; + // for sub-cubes during twist + botCorners = new double[24]; + topBlocks = new int[24]; + botBlocks = new int[24]; + buffer = new int[12]; + nearSide = new int[12]; + light = new double[3]; + Teye = new double[3]; + TeX = new double[3]; + TeY = new double[3]; + currDragDir = new double[2]; + eY = new double[3]; + vecProd(eye, 0, eX, 0, eY, 0); // Fix y axis of observer co-ordinate system + normalize(eY, 0); + colList = new Color[120]; + for (i = 0; i < 20; i++) { + colList[i] = new Color(103 + i * 8, 103 + i * 8, 103 + i * 8); // White + colList[i + 20] = new Color(i * 6, i * 6, 84 + i * 9); // Blue + colList[i + 40] = new Color(84 + i * 9, i * 5, i * 5); // Red + colList[i + 60] = new Color(i * 6, 84 + i * 9, i * 6); // Green + colList[i + 80] = new Color(84 + i * 9, 84 + i * 9, i * 6); // Yellow + colList[i + 100] = new Color(84 + i * 9, 55 + i * 8, i * 3); // Orange + } + sideCols = new int[54]; + for (i = 0; i < 54; i++) + sideCols[i] = i / 9; + bgcolor = findBGColor(); + setSize(125, 125); + repaint(); + } + + // Convert hexadecimal RGB parameter to color + public Color findBGColor() { + int hex[]; + String s, h = "0123456789abcdef"; + Color c; + hex = new int[6]; + s = null; //getParameter("bgcolor"); + if ((s != null) && (s.length() == 6)) { + for (i = 0; i < 6; i++) + for (j = 0; j < 16; j++) + if (Character.toLowerCase(s.charAt(i)) == h.charAt(j)) + hex[i] = j; + c = new Color(hex[0] * 16 + hex[1], hex[2] * 16 + hex[3], hex[4] * 16 + hex[5]); + } else + c = Color.lightGray; // Default + return c; + } + +// Various vector manipulation functions + + public double scalProd(double v1[], int ix1, double v2[], int ix2) { + return v1[ix1] * v2[ix2] + v1[ix1 + 1] * v2[ix2 + 1] + v1[ix1 + 2] * v2[ix2 + 2]; + } + + public double vNorm(double v[], int ix) { + return m.sqrt(v[ix] * v[ix] + v[ix + 1] * v[ix + 1] + v[ix + 2] * v[ix + 2]); + } + + public double cosAng(double v1[], int ix1, double v2[], int ix2) { + return scalProd(v1, ix1, v2, ix2) / (vNorm(v1, ix1) * vNorm(v2, ix2)); + } + + public void normalize(double v[], int ix) { + double t = vNorm(v, ix); + v[ix] = v[ix] / t; + v[ix + 1] = v[ix + 1] / t; + v[ix + 2] = v[ix + 2] / t; + } + + public void scalMult(double v[], int ix, double a) { + v[ix] = v[ix] * a; + v[ix + 1] = v[ix + 1] * a; + v[ix + 2] = v[ix + 2] * a; + } + + public void addVec(double v1[], int ix1, double v2[], int ix2) { + v2[ix2] += v1[ix1]; + v2[ix2 + 1] += v1[ix1 + 1]; + v2[ix2 + 2] += v1[ix1 + 2]; + } + + public void subVec(double v1[], int ix1, double v2[], int ix2) { + v2[ix2] -= v1[ix1]; + v2[ix2 + 1] -= v1[ix1 + 1]; + v2[ix2 + 2] -= v1[ix1 + 2]; + } + + public void copyVec(double v1[], int ix1, double v2[], int ix2) { + v2[ix2] = v1[ix1]; + v2[ix2 + 1] = v1[ix1 + 1]; + v2[ix2 + 2] = v1[ix1 + 2]; + } + + public void vecProd(double v1[], int ix1, double v2[], int ix2, + double v3[], int ix3) { + v3[ix3] = v1[ix1 + 1] * v2[ix2 + 2] - v1[ix1 + 2] * v2[ix2 + 1]; + v3[ix3 + 1] = v1[ix1 + 2] * v2[ix2] - v1[ix1] * v2[ix2 + 2]; + v3[ix3 + 2] = v1[ix1] * v2[ix2 + 1] - v1[ix1 + 1] * v2[ix2]; + } + + // Produce large and small sub-cube for twisting + public void cutUpCube() { + boolean check; + // Copy main coordinate data + for (i = 0; i < 24; i++) { + topCorners[i] = corners[i]; + botCorners[i] = corners[i]; + } + copyVec(sideVec, 3 * twistSide, temp, 0); // Start manipulating and build new parts + copyVec(temp, 0, temp2, 0); // Fix new co-ordinates. Some need to be altered. + scalMult(temp, 0, 1.3333); + scalMult(temp2, 0, 0.6667); + for (i = 0; i < 8; i++) { + check = false; + for (j = 0; j < 4; j++) + if (i == sides[twistSide * 4 + j]) + check = true; + if (check) + subVec(temp2, 0, botCorners, i * 3); + else + addVec(temp, 0, topCorners, i * 3); + } + +// The sub-cubes need information about which colored fields belong to them. + // Fix the sub-cube blockings. First copy data from main + for (i = 0; i < 24; i++) { + topBlocks[i] = mainBlocks[i]; // Large sub-cube data + botBlocks[i] = mainBlocks[i]; // Small sub-cube data + } + for (i = 0; i < 6; i++) { + if (i == twistSide) { + botBlocks[i * 4 + 1] = 0; // Large sub-cube is blank on top + botBlocks[i * 4 + 3] = 0; + } else { + k = -1; + for (j = 0; j... [truncated message content] |
From: <ls...@us...> - 2008-06-15 13:19:33
|
Revision: 4244 http://jnode.svn.sourceforge.net/jnode/?rev=4244&view=rev Author: lsantha Date: 2008-06-15 06:19:31 -0700 (Sun, 15 Jun 2008) Log Message: ----------- Codestyle fixes. Modified Paths: -------------- trunk/all/build.xml trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineConstants.java trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineCore.java trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineDesc.java trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineDriver.java trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineFlags.java trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineRing.java trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineRxRing.java trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineTxRing.java Modified: trunk/all/build.xml =================================================================== --- trunk/all/build.xml 2008-06-15 13:01:47 UTC (rev 4243) +++ trunk/all/build.xml 2008-06-15 13:19:31 UTC (rev 4244) @@ -891,8 +891,7 @@ <fileset dir="../gui/src/desktop" includes="**/*.java"/> <fileset dir="../gui/src/awt" includes="**/*.java"/> <fileset dir="../net/src/net" includes="**/*.java"/> - <fileset dir="../net/src/driver" includes="**/*.java" - excludes="**/via_rhine/*.java"/> + <fileset dir="../net/src/driver" includes="**/*.java"/> <fileset dir="../net/src/test" includes="**/*.java"/> <fileset dir="../shell/src/test" includes="**/*.java"/> <fileset dir="../shell/src/shell" includes="**/*.java"/> Modified: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineConstants.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineConstants.java 2008-06-15 13:01:47 UTC (rev 4243) +++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineConstants.java 2008-06-15 13:19:31 UTC (rev 4244) @@ -359,32 +359,61 @@ int MODE3_MIION = 0x04; /* in PCI_REG_MOD3 OF PCI space */ /* Offsets to the device registers. */ - int StationAddr = 0x00, RxConfig = 0x06, TxConfig = 0x07, ChipCmd = 0x08, - IntrStatus = 0x0C, IntrEnable = 0x0E, - MulticastFilter0 = 0x10, MulticastFilter1 = 0x14, - RxRingPtr = 0x18, TxRingPtr = 0x1C, GFIFOTest = 0x54, - MIIPhyAddr = 0x6C, MIIStatus = 0x6D, PCIBusConfig = 0x6E, - MIICmd = 0x70, MIIRegAddr = 0x71, MIIData = 0x72, MACRegEEcsr = 0x74, - ConfigA = 0x78, ConfigB = 0x79, ConfigC = 0x7A, ConfigD = 0x7B, - RxMissed = 0x7C, RxCRCErrs = 0x7E, MiscCmd = 0x81, - StickyHW = 0x83, IntrStatus2 = 0x84, WOLcrClr = 0xA4, WOLcgClr = 0xA7, - PwrcsrClr = 0xAC; + int StationAddr = 0x00; + int RxConfig = 0x06; + int TxConfig = 0x07; + int ChipCmd = 0x08; + int IntrStatus = 0x0C; + int IntrEnable = 0x0E; + int MulticastFilter0 = 0x10; + int MulticastFilter1 = 0x14; + int RxRingPtr = 0x18; + int TxRingPtr = 0x1C; + int GFIFOTest = 0x54; + int MIIPhyAddr = 0x6C; + int MIIStatus = 0x6D; + int PCIBusConfig = 0x6E; + int MIICmd = 0x70; + int MIIRegAddr = 0x71; + int MIIData = 0x72; + int MACRegEEcsr = 0x74; + int ConfigA = 0x78; + int ConfigB = 0x79; + int ConfigC = 0x7A; + int ConfigD = 0x7B; + int RxMissed = 0x7C; + int RxCRCErrs = 0x7E; + int MiscCmd = 0x81; + int StickyHW = 0x83; + int IntrStatus2 = 0x84; + int WOLcrClr = 0xA4; + int WOLcgClr = 0xA7; + int PwrcsrClr = 0xAC; /* Bits in the interrupt status/mask registers. */ - int IntrRxDone = 0x0001, IntrRxErr = 0x0004, IntrRxEmpty = 0x0020, - IntrTxDone = 0x0002, IntrTxError = 0x0008, IntrTxUnderrun = 0x0210, - IntrPCIErr = 0x0040, - IntrStatsMax = 0x0080, IntrRxEarly = 0x0100, - IntrRxOverflow = 0x0400, IntrRxDropped = 0x0800, IntrRxNoBuf = 0x1000, - IntrTxAborted = 0x2000, IntrLinkChange = 0x4000, - IntrRxWakeUp = 0x8000, - IntrNormalSummary = 0x0003, IntrAbnormalSummary = 0xC260, - IntrTxDescRace = 0x080000, // mapped from IntrStatus2 - IntrTxErrSummary = 0x082218; + int IntrRxDone = 0x0001; + int IntrRxErr = 0x0004; + int IntrRxEmpty = 0x0020; + int IntrTxDone = 0x0002; + int IntrTxError = 0x0008; + int IntrTxUnderrun = 0x0210; + int IntrPCIErr = 0x0040; + int IntrStatsMax = 0x0080; + int IntrRxEarly = 0x0100; + int IntrRxOverflow = 0x0400; + int IntrRxDropped = 0x0800; + int IntrRxNoBuf = 0x1000; + int IntrTxAborted = 0x2000; + int IntrLinkChange = 0x4000; + int IntrRxWakeUp = 0x8000; + int IntrNormalSummary = 0x0003; + int IntrAbnormalSummary = 0xC260; + int IntrTxDescRace = 0x080000; // mapped from IntrStatus2 + int IntrTxErrSummary = 0x082218; int DEFAULT_INTR = IntrRxDone | IntrRxErr | IntrRxEmpty | - IntrRxOverflow | IntrRxDropped | IntrRxNoBuf; + IntrRxOverflow | IntrRxDropped | IntrRxNoBuf; //enum rhine_revs int VT86C100A = 0x00; @@ -401,4 +430,4 @@ int VT6107 = 0x8C; int VTunknown2 = 0x8E; int VT6105M = 0x90; -} \ No newline at end of file +} Modified: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineCore.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineCore.java 2008-06-15 13:01:47 UTC (rev 4243) +++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineCore.java 2008-06-15 13:19:31 UTC (rev 4244) @@ -3,53 +3,108 @@ */ package org.jnode.driver.net.via_rhine; -import org.jnode.driver.net.spi.AbstractDeviceCore; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import javax.naming.NameNotFoundException; +import org.jnode.driver.Device; import org.jnode.driver.DriverException; -import org.jnode.driver.Device; +import org.jnode.driver.bus.pci.PCIBaseAddress; +import org.jnode.driver.bus.pci.PCIDevice; import org.jnode.driver.bus.pci.PCIHeaderType0; -import org.jnode.driver.bus.pci.PCIDevice; -import org.jnode.driver.bus.pci.PCIBaseAddress; +import org.jnode.driver.net.ethernet.spi.Flags; +import org.jnode.driver.net.spi.AbstractDeviceCore; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.CFGD_CFDX; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.CR1_SFRST; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.CR1_TDMD1; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.CR_DPOLL; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.CR_FDX; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.CR_RXON; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.CR_STOP; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.CR_STRT; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.CR_TXON; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.DEFAULT_INTR; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IMRShadow; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrEnable; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrLinkChange; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrPCIErr; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrRxDone; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrRxDropped; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrRxEarly; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrRxEmpty; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrRxErr; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrRxNoBuf; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrRxOverflow; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrRxWakeUp; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrStatsMax; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrStatus; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrStatus2; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrTxAborted; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrTxDescRace; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrTxDone; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrTxErrSummary; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrTxError; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.IntrTxUnderrun; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.MIISR_SPEED; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.RX_RING_SIZE; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.TX_RING_SIZE; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.byBCR0; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.byBCR1; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.byCFGD; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.byCR0; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.byCR1; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.byEECSR; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.byIMR0; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.byMAR0; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.byMAR4; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.byMIIAD; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.byMIICR; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.byPAR0; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.byRCR; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.byTCR; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.dwCurrentRxDescAddr; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.dwCurrentTxDescAddr; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.wMIIDATA; +import org.jnode.naming.InitialNaming; import org.jnode.net.HardwareAddress; import org.jnode.net.SocketBuffer; import org.jnode.net.ethernet.EthernetAddress; +import static org.jnode.net.ethernet.EthernetConstants.ETH_ALEN; +import org.jnode.system.IOResource; +import org.jnode.system.IRQHandler; +import org.jnode.system.IRQResource; +import org.jnode.system.ResourceManager; +import org.jnode.system.ResourceNotFreeException; +import org.jnode.system.ResourceOwner; +import org.jnode.util.NumberUtils; import org.jnode.util.TimeoutException; -import org.jnode.util.NumberUtils; -import org.jnode.system.*; -import org.jnode.naming.InitialNaming; -import javax.naming.NameNotFoundException; -import static org.jnode.net.ethernet.EthernetConstants.*; -import static org.jnode.driver.net.via_rhine.ViaRhineConstants.*; -import org.jnode.driver.net.ethernet.spi.Flags; -import java.io.*; - /** * @author Levente S\u00e1ntha */ class ViaRhineCore extends AbstractDeviceCore implements IRQHandler { private final int ioBase; private final IOResource io; - private final IRQResource irq; - private EthernetAddress hwAddress; + private final IRQResource irq; + private EthernetAddress hwAddress; private ViaRhineDriver driver; private ViaRhineRxRing rxRing; private ViaRhineTxRing txRing; - - /* - // temporary Rx buffers. + // temporary Rx buffers. - int chip_id; - int chip_revision; + int chip_id; + int chip_revision; - unsigned int dirty_rx, dirty_tx; - // The saved address of a sent-in-place packet/buffer, for skfree(). - struct sk_buff *tx_skbuff[TX_RING_SIZE]; - unsigned char mc_filter[8]; // Current multicast filter. - char phys[4]; // MII device addresses. + unsigned int dirty_rx, dirty_tx; + // The saved address of a sent-in-place packet/buffer, for skfree(). + struct sk_buff *tx_skbuff[TX_RING_SIZE]; + unsigned char mc_filter[8]; // Current multicast filter. + char phys[4]; // MII device addresses. - */ + */ //ViaRhineRxDescriptor[] rx_ring = new ViaRhineRxDescriptor[RX_RING_SIZE]; //ViaRhineTxDescriptor[] tx_ring = new ViaRhineTxDescriptor[TX_RING_SIZE]; @@ -59,21 +114,21 @@ int chip_id; int chip_revision; short ioaddr; - int cur_rx, cur_tx; // The next free and used entries + int cur_rx, cur_tx; // The next free and used entries int dirty_rx, dirty_tx; // The saved address of a sent-in-place packet/buffer, for skfree(). SocketBuffer[] tx_skbuff = new SocketBuffer[TX_RING_SIZE]; - char[] mc_filter = new char[8]; // Current multicast filter. - char[] phys = new char[4]; // MII device addresses. - int tx_full =1; // The Tx queue is full. - int full_duplex = 1; // Full-duplex operation requested. - int default_port = 4; // Last dev->if_port value. - int media2 = 4; // Secondary monitored media port. - int medialock = 1; // Don't sense media type. - int mediasense = 1; // Media sensing in progress. + char[] mc_filter = new char[8]; // Current multicast filter. + char[] phys = new char[4]; // MII device addresses. + int tx_full = 1; // The Tx queue is full. + int full_duplex = 1; // Full-duplex operation requested. + int default_port = 4; // Last dev->if_port value. + int media2 = 4; // Secondary monitored media port. + int medialock = 1; // Don't sense media type. + int mediasense = 1; // Media sensing in progress. public ViaRhineCore(ViaRhineDriver driver, Device device, ResourceOwner owner, Flags flags) - throws DriverException, ResourceNotFreeException{ + throws DriverException, ResourceNotFreeException { this.driver = driver; final int irq_nr = getIRQ(device, flags); PCIBaseAddress addr = getIOBaseAddress(device, flags); @@ -98,38 +153,39 @@ final byte[] hwAddrArr = new byte[ETH_ALEN]; for (int i = 0; i < ETH_ALEN; i++) - hwAddrArr[i] = (byte) getReg8(byPAR0 + i); + hwAddrArr[i] = (byte) getReg8(byPAR0 + i); this.hwAddress = new EthernetAddress(hwAddrArr, 0); log.debug("Found " + flags.getName() + " IRQ = " + irq.getIRQ() - + ", IO Base = 0x" + NumberUtils.hex(ioBase) - + ", IO Length = " + io_length - + ", MAC Address = "+ hwAddress); + + ", IO Base = 0x" + NumberUtils.hex(ioBase) + + ", IO Length = " + io_length + + ", MAC Address = " + hwAddress); } protected PCIBaseAddress getIOBaseAddress(Device device, Flags flags) - throws DriverException { - final PCIHeaderType0 config = ((PCIDevice)device).getConfig().asHeaderType0(); - final PCIBaseAddress[] addrs = config.getBaseAddresses(); - if (addrs.length < 1) { - throw new DriverException("Cannot find iobase: no base address"); - } - if (!addrs[0].isIOSpace()) { - throw new DriverException("Cannot find iobase: first address is not I/O"); - } - return addrs[0]; - } + throws DriverException { + final PCIHeaderType0 config = ((PCIDevice) device).getConfig().asHeaderType0(); + final PCIBaseAddress[] addrs = config.getBaseAddresses(); + if (addrs.length < 1) { + throw new DriverException("Cannot find iobase: no base address"); + } + if (!addrs[0].isIOSpace()) { + throw new DriverException("Cannot find iobase: first address is not I/O"); + } + return addrs[0]; + } /** - * Gets the IRQ used by the given device - * @param device - * @param flags - */ - protected int getIRQ(Device device, Flags flags) throws DriverException { - final PCIHeaderType0 config = ((PCIDevice)device).getConfig().asHeaderType0(); - return config.getInterruptLine(); - } + * Gets the IRQ used by the given device + * + * @param device + * @param flags + */ + protected int getIRQ(Device device, Flags flags) throws DriverException { + final PCIHeaderType0 config = ((PCIDevice) device).getConfig().asHeaderType0(); + return config.getInterruptLine(); + } public void handleInterrupt(int irq) { log.debug("handleInterrupt()"); @@ -138,15 +194,15 @@ setIRQEnabled(false); int intr_status = getIntrStatus(); - if((intr_status & (IntrRxDone | IntrRxNoBuf | IntrRxOverflow | - IntrRxDropped | IntrRxEarly | IntrRxEmpty | IntrRxErr | IntrRxWakeUp)) != 0){ + if ((intr_status & (IntrRxDone | IntrRxNoBuf | IntrRxOverflow | + IntrRxDropped | IntrRxEarly | IntrRxEmpty | IntrRxErr | IntrRxWakeUp)) != 0) { /* Acknowledge all of the current interrupt sources ASAP. */ //outw(DEFAULT_INTR & ~IntrRxDone, nic->ioaddr + IntrStatus); //IOSYNC; try { Thread.sleep(50); - if(!rxRing.currentDesc().isOwnBit()){ + if (!rxRing.currentDesc().isOwnBit()) { SocketBuffer packet = rxRing.currentDesc().getPacket(); driver.onReceive(packet); log.debug("New packet"); @@ -157,28 +213,28 @@ rxRing.next(); } - } catch(Exception e ){ + } catch (Exception e) { log.error("error in irq handler", e); } //setReg16(IntrStatus, DEFAULT_INTR & ~IntrRxDone); setReg16(IntrStatus, DEFAULT_INTR); } - if((intr_status & (IntrTxDone | IntrTxAborted | IntrTxDescRace | - IntrTxError | IntrTxErrSummary | IntrTxUnderrun)) != 0) { + if ((intr_status & (IntrTxDone | IntrTxAborted | IntrTxDescRace | + IntrTxError | IntrTxErrSummary | IntrTxUnderrun)) != 0) { try { - if((intr_status & IntrTxError) != 0){ + if ((intr_status & IntrTxError) != 0) { reset(); return; } Thread.sleep(50); - } catch(Exception e ){ + } catch (Exception e) { log.error("error in irq handler", e); } - setReg16(IntrStatus, DEFAULT_INTR | my_INTR); + setReg16(IntrStatus, DEFAULT_INTR | my_INTR); } @@ -188,62 +244,62 @@ private static final int my_INTR = IntrTxDone | IntrTxError | IntrTxUnderrun; - private void printIntrStatus(){ + private void printIntrStatus() { int intr_status = getIntrStatus(); log.debug("Interrupt status word: 0x" + NumberUtils.hex(intr_status)); - if((intr_status & IntrRxDone) != 0) + if ((intr_status & IntrRxDone) != 0) log.debug("Interrupt status: " + "IntrRxDone"); - if((intr_status & IntrRxErr) != 0) + if ((intr_status & IntrRxErr) != 0) log.debug("Interrupt status: " + "IntrRxErr"); - if((intr_status & IntrRxEmpty) != 0) - log.debug("Interrupt status: " + "IntrRxEmpty"); + if ((intr_status & IntrRxEmpty) != 0) + log.debug("Interrupt status: " + "IntrRxEmpty"); - if((intr_status & IntrTxDone) != 0) - log.debug("Interrupt status: " + "IntrTxDone"); + if ((intr_status & IntrTxDone) != 0) + log.debug("Interrupt status: " + "IntrTxDone"); - if((intr_status & IntrTxError) != 0) - log.debug("Interrupt status: " + "IntrTxError"); + if ((intr_status & IntrTxError) != 0) + log.debug("Interrupt status: " + "IntrTxError"); - if((intr_status & IntrTxUnderrun) != 0) - log.debug("Interrupt status: " + "IntrTxUnderrun"); + if ((intr_status & IntrTxUnderrun) != 0) + log.debug("Interrupt status: " + "IntrTxUnderrun"); - if((intr_status & IntrPCIErr) != 0) - log.debug("Interrupt status: " + "IntrPCIErr"); + if ((intr_status & IntrPCIErr) != 0) + log.debug("Interrupt status: " + "IntrPCIErr"); - if((intr_status & IntrStatsMax) != 0) - log.debug("Interrupt status: " + "IntrStatsMax"); + if ((intr_status & IntrStatsMax) != 0) + log.debug("Interrupt status: " + "IntrStatsMax"); - if((intr_status & IntrRxEarly) != 0) - log.debug("Interrupt status: " + "IntrRxEarly"); + if ((intr_status & IntrRxEarly) != 0) + log.debug("Interrupt status: " + "IntrRxEarly"); - if((intr_status & IntrRxOverflow) != 0) - log.debug("Interrupt status: " + "IntrRxOverflow"); + if ((intr_status & IntrRxOverflow) != 0) + log.debug("Interrupt status: " + "IntrRxOverflow"); - if((intr_status & IntrRxDropped) != 0) - log.debug("Interrupt status: " + "IntrRxDropped"); + if ((intr_status & IntrRxDropped) != 0) + log.debug("Interrupt status: " + "IntrRxDropped"); - if((intr_status & IntrRxNoBuf) != 0) - log.debug("Interrupt status: " + "IntrRxNoBuf"); + if ((intr_status & IntrRxNoBuf) != 0) + log.debug("Interrupt status: " + "IntrRxNoBuf"); - if((intr_status & IntrTxAborted) != 0) - log.debug("Interrupt status: " + "IntrTxAborted"); + if ((intr_status & IntrTxAborted) != 0) + log.debug("Interrupt status: " + "IntrTxAborted"); - if((intr_status & IntrLinkChange) != 0) - log.debug("Interrupt status: " + "IntrLinkChange"); + if ((intr_status & IntrLinkChange) != 0) + log.debug("Interrupt status: " + "IntrLinkChange"); - if((intr_status & IntrRxWakeUp) != 0) - log.debug("Interrupt status: " + "IntrRxWakeUp"); + if ((intr_status & IntrRxWakeUp) != 0) + log.debug("Interrupt status: " + "IntrRxWakeUp"); - if((intr_status & IntrTxDescRace) != 0) - log.debug("Interrupt status: " + "IntrTxDescRace"); + if ((intr_status & IntrTxDescRace) != 0) + log.debug("Interrupt status: " + "IntrTxDescRace"); } - private void setIRQEnabled(boolean enable){ + private void setIRQEnabled(boolean enable) { int intr_status = getIntrStatus(); if (enable) @@ -290,7 +346,7 @@ setReg16(byCR0, CR_STOP); } - private void reset(){ + private void reset() { /* software reset */ setReg8(byCR1, CR1_SFRST); MIIDelay(); @@ -298,13 +354,12 @@ //init ring initRing(); - /*write TD RD Descriptor to MAC */ setReg32(dwCurrentRxDescAddr, rxRing.ringAddr); setReg32(dwCurrentTxDescAddr, txRing.ringAddr); /* close IMR */ - setReg16 (byIMR0, 0x0000); + setReg16(byIMR0, 0x0000); /* Setup Multicast */ //set_rx_mode(nic); @@ -321,7 +376,7 @@ setReg8(byTCR, 0x60); /* Set Fulldupex */ - int FDXFlag = queryAuto (); + int FDXFlag = queryAuto(); if (FDXFlag == 1) { setReg8(byCFGD, CFGD_CFDX); setReg16(byCR0, CR_FDX); @@ -329,7 +384,7 @@ /* KICK NIC to WORK */ //CRbak = inw (byCR0); - //CRbak = CRbak & 0xFFFB; /* not CR_STOP */ + //CRbak = CRbak & 0xFFFB; /* not CR_STOP */ //outw ((CRbak | CR_STRT | CR_TXON | CR_RXON | CR_DPOLL), byCR0); int cr = getReg8(byCR0); cr = cr & 0xFFFB; @@ -339,13 +394,12 @@ //outw (0, byIMR0); //setReg16(byIMR0, 0); - //-------------------- //outw (IMRShadow, byIMR0); setReg16(byIMR0, IMRShadow); } - private void setRxMode(){ + private void setRxMode() { /* ! IFF_PROMISC */ //outl(0xffffffff, byMAR0); //outl(0xffffffff, byMAR4); @@ -361,11 +415,11 @@ setReg8(byEECSR, 0x20); /* Typically 2 cycles to reload. */ for (int i = 0; i < 150; i++) - if ( (getReg8(byEECSR) & 0x20) == 0) + if ((getReg8(byEECSR) & 0x20) == 0) break; } - void initRing () { + void initRing() { try { final ResourceManager rm = InitialNaming.lookup(ResourceManager.NAME); rxRing = new ViaRhineRxRing(rm); @@ -377,24 +431,24 @@ } } - private int queryAuto () { + private int queryAuto() { int byMIIIndex; int MIIReturn; - int advertising,mii_reg5; + int advertising, mii_reg5; int negociated; byMIIIndex = 0x04; - MIIReturn = ReadMII (byMIIIndex); - advertising=MIIReturn; + MIIReturn = ReadMII(byMIIIndex); + advertising = MIIReturn; byMIIIndex = 0x05; - MIIReturn = ReadMII (byMIIIndex); - mii_reg5=MIIReturn; + MIIReturn = ReadMII(byMIIIndex); + mii_reg5 = MIIReturn; - negociated=mii_reg5 & advertising; + negociated = mii_reg5 & advertising; - if ( (negociated & 0x100) != 0 || (negociated & 0x1C0) == 0x40 ) + if ((negociated & 0x100) != 0 || (negociated & 0x1C0) == 0x40) return 1; else return 0; @@ -409,11 +463,11 @@ byMIIAdrbak = getReg8(byMIIAD); byMIICRbak = getReg8(byMIICR); - setReg8 (byMIICR, byMIICRbak & 0x7f); - MIIDelay (); + setReg8(byMIICR, byMIICRbak & 0x7f); + MIIDelay(); setReg8(byMIIAD, byMIIIndex); - MIIDelay (); + MIIDelay(); setReg8(byMIICR, getReg8(byMIICR) | 0x40); @@ -424,18 +478,18 @@ byMIItemp = getReg8(byMIICR); byMIItemp = byMIItemp & 0x40; } - MIIDelay (); + MIIDelay(); ReturnMII = getReg16(wMIIDATA); setReg8(byMIIAD, byMIIAdrbak); setReg8(byMIICR, byMIICRbak); - MIIDelay (); + MIIDelay(); return (ReturnMII); } - void WriteMII (int byMIISetByte, int byMIISetBit, int byMIIOP) { + void WriteMII(int byMIISetByte, int byMIISetBit, int byMIIOP) { int ReadMIItmp; int MIIMask; int byMIIAdrbak; @@ -447,9 +501,9 @@ byMIICRbak = getReg8(byMIICR); setReg8(byMIICR, byMIICRbak & 0x7f); - MIIDelay (); + MIIDelay(); setReg8(byMIIAD, byMIISetByte); - MIIDelay (); + MIIDelay(); setReg8(byMIICR, getReg8(byMIICR) | 0x40); @@ -460,7 +514,7 @@ byMIItemp = getReg8(byMIICR); byMIItemp = byMIItemp & 0x40; } - MIIDelay (); + MIIDelay(); ReadMIItmp = getReg16(wMIIDATA); MIIMask = 0x0001; @@ -475,7 +529,7 @@ } setReg16(wMIIDATA, ReadMIItmp); - MIIDelay (); + MIIDelay(); setReg8(byMIICR, getReg8(byMIICR) | 0x20); byMIItemp = getReg8(byMIICR); @@ -486,15 +540,15 @@ byMIItemp = byMIItemp & 0x20; } - MIIDelay (); + MIIDelay(); setReg8(byMIIAD, byMIIAdrbak & 0x7f); setReg8(byMIICR, byMIICRbak); - MIIDelay (); + MIIDelay(); } - private void MIIDelay (){ + private void MIIDelay() { for (int i = 0; i < 0x7fff; i++) { getReg8(0x61); getReg8(0x61); @@ -505,7 +559,7 @@ void probe() { int options = -1; - int did_version = 0; /* Already printed version info. */ + int did_version = 0; /* Already printed version info. */ int i; int timeout; int FDXFlag; @@ -520,14 +574,14 @@ //--printf ("IO address %hX Ethernet Address: %!\n", ioaddr, nic->node_addr); /* restart MII auto-negotiation */ - WriteMII (0, 9, 1); - log.info ("Analyzing Media type,this will take several seconds........"); + WriteMII(0, 9, 1); + log.info("Analyzing Media type,this will take several seconds........"); for (i = 0; i < 5; i++) { /* need to wait 1 millisecond - we will round it up to 50-100ms */ try { Thread.sleep(70); - } catch(InterruptedException x){ + } catch (InterruptedException x) { //ignore } @@ -537,7 +591,7 @@ log.info("OK\n"); /* - #if 0 + #if 0 //* JJM : for Debug printf("MII : Address %hhX ",inb(ioaddr+0x6c)); { @@ -556,7 +610,7 @@ /* query MII to know LineSpeed,duplex mode */ byMIIvalue = getReg8(0x6d); LineSpeed = byMIIvalue & MIISR_SPEED; - if (LineSpeed != 0){ //JJM + if (LineSpeed != 0) { //JJM log.info("Linespeed=10Mbs"); } else { log.info("Linespeed=100Mbs"); @@ -570,21 +624,19 @@ log.info(" Halfduplex\n"); } - /* set MII 10 FULL ON */ - WriteMII (17, 1, 1); + WriteMII(17, 1, 1); /* turn on MII link change */ MIICRbak = getReg8(byMIICR); setReg8(byMIICR, MIICRbak & 0x7F); - MIIDelay (); + MIIDelay(); setReg8(byMIIAD, 0x41); - MIIDelay (); + MIIDelay(); /* while((inb(byMIIAD)&0x20)==0) ; */ setReg8(byMIICR, MIICRbak | 0x80); - /* The lower four bits are the media type. */ if (options > 0) { full_duplex = (options & 16) != 0 ? 1 : 0; @@ -597,12 +649,13 @@ public void release() { log.debug("release()"); io.release(); - log.debug("irq.release"); - irq.release(); - log.debug("end of release"); + log.debug("irq.release"); + irq.release(); + log.debug("end of release"); } - public void transmit(SocketBuffer buf, HardwareAddress destination, long timeout) throws InterruptedException, TimeoutException { + public void transmit(SocketBuffer buf, HardwareAddress destination, long timeout) + throws InterruptedException, TimeoutException { log.debug("transmit(): to " + destination); // destination.writeTo(buf, 0); // hwAddress.writeTo(buf, 6); @@ -617,15 +670,15 @@ // do { - int i = 0; - while(txRing.currentDesc().isOwnBit()) { - try{ - Thread.sleep(10); - } catch(InterruptedException x){ - // - } - if(i++ > 5) break; + int i = 0; + while (txRing.currentDesc().isOwnBit()) { + try { + Thread.sleep(10); + } catch (InterruptedException x) { + // } + if (i++ > 5) break; + } // if(tp->tx_ring[entry].tx_status.bits.terr == 0) // break; @@ -637,7 +690,7 @@ // CR0bak = CR0bak | CR_TXON; // setReg8(byCR0, CR0bak); // } - // } while(true); + // } while(true); txRing.next(); } @@ -646,30 +699,29 @@ } private int getReg16(int reg) { - return io.inPortWord(ioBase + reg); - } + return io.inPortWord(ioBase + reg); + } - private int getReg32(int reg) { - return io.inPortDword(ioBase + reg); - } + private int getReg32(int reg) { + return io.inPortDword(ioBase + reg); + } - private void setReg8(int reg, int value) { - io.outPortByte(ioBase + reg, value); - } + private void setReg8(int reg, int value) { + io.outPortByte(ioBase + reg, value); + } - private void setReg16(int reg, int value) { - io.outPortWord(ioBase + reg, value); - } + private void setReg16(int reg, int value) { + io.outPortWord(ioBase + reg, value); + } - private void setReg32(int reg, int value) { - io.outPortDword(ioBase + reg, value); - } + private void setReg32(int reg, int value) { + io.outPortDword(ioBase + reg, value); + } - - String hexDump(byte[] data){ + String hexDump(byte[] data) { try { - InputStream is = new ByteArrayInputStream(data); + InputStream is = new ByteArrayInputStream(data); StringWriter swriter = new StringWriter(); PrintWriter out = new PrintWriter(swriter); @@ -730,7 +782,7 @@ return swriter.toString(); - } catch(Exception e){ + } catch (Exception e) { throw new RuntimeException(e); } } Modified: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineDesc.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineDesc.java 2008-06-15 13:01:47 UTC (rev 4243) +++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineDesc.java 2008-06-15 13:19:31 UTC (rev 4244) @@ -3,10 +3,10 @@ */ package org.jnode.driver.net.via_rhine; +import org.apache.log4j.Logger; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.PKT_BUF_SZ; import org.jnode.system.MemoryResource; import org.jnode.system.ResourceManager; -import static org.jnode.driver.net.via_rhine.ViaRhineConstants.PKT_BUF_SZ; -import org.apache.log4j.Logger; import org.vmmagic.unboxed.Address; /** @@ -33,34 +33,35 @@ dataMr = rm.asMemoryResource(data); Address datma = dataMr.getAddress(); dataOffs = align32(datma); - descMr.setInt(descOffs + 8, datma.add(dataOffs).toInt()); + descMr.setInt(descOffs + 8, datma.add(dataOffs).toInt()); } - void setOwnBit(){ + void setOwnBit() { descMr.setInt(descOffs, descMr.getInt(descOffs) | OWN_BIT_MASK); } - boolean isOwnBit(){ + boolean isOwnBit() { return (descMr.getInt(descOffs) & OWN_BIT_MASK) != 0; } - void setNextDescAddr(int addr){ + void setNextDescAddr(int addr) { descMr.setInt(descOffs + 12, addr); } /** * Align an addres on 32-byte boundary. + * * @param addr the address * @return the the aligned address offset relative to addr */ - private int align32(Address addr){ + private int align32(Address addr) { int i_addr = addr.toInt(); - int offs = 0; + int offs = 0; - while ((i_addr & 31) != 0) { - i_addr++; - offs++; - } + while ((i_addr & 31) != 0) { + i_addr++; + offs++; + } return offs; } Modified: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineDriver.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineDriver.java 2008-06-15 13:01:47 UTC (rev 4243) +++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineDriver.java 2008-06-15 13:19:31 UTC (rev 4244) @@ -3,14 +3,14 @@ */ package org.jnode.driver.net.via_rhine; +import java.security.PrivilegedExceptionAction; +import org.jnode.driver.Device; +import org.jnode.driver.DriverException; import org.jnode.driver.net.ethernet.spi.BasicEthernetDriver; import org.jnode.driver.net.ethernet.spi.Flags; -import org.jnode.driver.DriverException; -import org.jnode.driver.Device; import org.jnode.plugin.ConfigurationElement; import org.jnode.system.ResourceNotFreeException; import org.jnode.util.AccessControllerUtils; -import java.security.PrivilegedExceptionAction; /** * @author Levente S\u00e1ntha @@ -18,6 +18,7 @@ public class ViaRhineDriver extends BasicEthernetDriver { /** * Create a new instance + * * @param config configuartion desc */ public ViaRhineDriver(ConfigurationElement config) { @@ -32,9 +33,9 @@ * Create a new ViaRhineCore instance */ protected ViaRhineCore newCore(final Device device, final Flags flags) - throws DriverException, ResourceNotFreeException { + throws DriverException, ResourceNotFreeException { try { - return AccessControllerUtils.doPrivileged(new PrivilegedExceptionAction<ViaRhineCore>(){ + return AccessControllerUtils.doPrivileged(new PrivilegedExceptionAction<ViaRhineCore>() { public ViaRhineCore run() throws Exception { return new ViaRhineCore(ViaRhineDriver.this, device, device, flags); } Modified: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineFlags.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineFlags.java 2008-06-15 13:01:47 UTC (rev 4243) +++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineFlags.java 2008-06-15 13:19:31 UTC (rev 4244) @@ -15,15 +15,16 @@ public ViaRhineFlags(ConfigurationElement config) { this(config.getAttribute("name")); } - - /** - * Create a new instance - * @param name - */ - public ViaRhineFlags(String name) { - this.name = name; - } + /** + * Create a new instance + * + * @param name + */ + public ViaRhineFlags(String name) { + this.name = name; + } + public String getName() { return name; } Modified: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineRing.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineRing.java 2008-06-15 13:01:47 UTC (rev 4243) +++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineRing.java 2008-06-15 13:19:31 UTC (rev 4244) @@ -4,23 +4,22 @@ package org.jnode.driver.net.via_rhine; import org.jnode.system.ResourceManager; -import java.util.Arrays; /** * @author Levente S\u00e1ntha */ -abstract class ViaRhineRing<T extends ViaRhineDesc> { +abstract class ViaRhineRing<T extends ViaRhineDesc> { final int RING_SIZE; ViaRhineDesc[] ring; int ringAddr; int current; - ViaRhineRing(ResourceManager rm, int size){ + ViaRhineRing(ResourceManager rm, int size) { this.RING_SIZE = size; ring = new ViaRhineDesc[RING_SIZE]; - for(int i = 0; i < RING_SIZE; i++){ + for (int i = 0; i < RING_SIZE; i++) { ring[i] = createDescr(rm); - if(i == 0) + if (i == 0) ringAddr = ring[0].descAddr; else ring[i - 1].setNextDescAddr(ring[i].descAddr); @@ -32,11 +31,11 @@ abstract ViaRhineDesc createDescr(ResourceManager rm); - T currentDesc(){ + T currentDesc() { return (T) ring[current]; } - void next(){ + void next() { current = (current + 1) % RING_SIZE; } } Modified: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineRxRing.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineRxRing.java 2008-06-15 13:01:47 UTC (rev 4243) +++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineRxRing.java 2008-06-15 13:19:31 UTC (rev 4244) @@ -3,15 +3,16 @@ */ package org.jnode.driver.net.via_rhine; -import static org.jnode.driver.net.via_rhine.ViaRhineConstants.*; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.PKT_BUF_SZ; +import static org.jnode.driver.net.via_rhine.ViaRhineConstants.RX_RING_SIZE; +import org.jnode.net.SocketBuffer; import org.jnode.system.ResourceManager; -import org.jnode.net.SocketBuffer; /** * @author Levente S\u00e1ntha */ class ViaRhineRxRing extends ViaRhineRing<ViaRhineRxRing.RxDesc> { - ViaRhineRxRing(ResourceManager rm){ + ViaRhineRxRing(ResourceManager rm) { super(rm, RX_RING_SIZE); } @@ -19,8 +20,8 @@ return new RxDesc(rm); } - static class RxDesc extends ViaRhineDesc{ - RxDesc(ResourceManager rm){ + static class RxDesc extends ViaRhineDesc { + RxDesc(ResourceManager rm) { super(rm); setOwnBit(); setDataBufferSize(PKT_BUF_SZ); @@ -30,11 +31,11 @@ descMr.setInt(descOffs + 4, size); } - int getFrameLength(){ + int getFrameLength() { return descMr.getChar(descOffs + 2) & 0x000007FF; } - SocketBuffer getPacket(){ + SocketBuffer getPacket() { int ln = getFrameLength(); log.debug("packetlength: " + ln); byte[] buf = new byte[ln]; Modified: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineTxRing.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineTxRing.java 2008-06-15 13:01:47 UTC (rev 4243) +++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineTxRing.java 2008-06-15 13:19:31 UTC (rev 4244) @@ -4,7 +4,6 @@ package org.jnode.driver.net.via_rhine; import java.util.Arrays; -import static org.jnode.driver.net.via_rhine.ViaRhineConstants.PKT_BUF_SZ; import static org.jnode.driver.net.via_rhine.ViaRhineConstants.TX_RING_SIZE; import org.jnode.net.SocketBuffer; import static org.jnode.net.ethernet.EthernetConstants.ETH_ZLEN; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-06-15 15:49:29
|
Revision: 4248 http://jnode.svn.sourceforge.net/jnode/?rev=4248&view=rev Author: lsantha Date: 2008-06-15 08:47:01 -0700 (Sun, 15 Jun 2008) Log Message: ----------- Improvements to file times. Patch by Daniel Noll. Modified Paths: -------------- trunk/fs/fs.iml trunk/fs/src/fs/org/jnode/fs/FSEntry.java trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java trunk/fs/src/fs/org/jnode/fs/fat/FatDirEntry.java trunk/fs/src/fs/org/jnode/fs/fat/FatRootEntry.java trunk/fs/src/fs/org/jnode/fs/fat/LfnEntry.java trunk/fs/src/fs/org/jnode/fs/iso9660/EntryRecord.java trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Entry.java trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java trunk/fs/src/fs/org/jnode/fs/jfat/FatRootDirectory.java trunk/fs/src/fs/org/jnode/fs/jifs/JIFSDirectory.java trunk/fs/src/fs/org/jnode/fs/jifs/JIFSFile.java trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Entry.java trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSEntry.java trunk/fs/src/fs/org/jnode/fs/ramfs/RAMDirectory.java trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFile.java trunk/fs/src/fs/org/jnode/fs/service/def/VirtualDirEntry.java trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSEntry.java trunk/fs/src/fs/org/jnode/fs/spi/AbstractFSEntry.java trunk/net/src/net/org/jnode/net/nfs/nfs2/Time.java Added Paths: ----------- trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660DTime.java Modified: trunk/fs/fs.iml =================================================================== --- trunk/fs/fs.iml 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/fs.iml 2008-06-15 15:47:01 UTC (rev 4248) @@ -35,6 +35,16 @@ <SOURCES /> </library> </orderEntry> + <orderEntry type="module-library"> + <library> + <CLASSES> + <root url="jar://$MODULE_DIR$/lib/edtftpj-1.5.2.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + </orderEntry> + <orderEntry type="module" module-name="net" /> <orderEntryProperties /> </component> </module> Modified: trunk/fs/src/fs/org/jnode/fs/FSEntry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/FSEntry.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/FSEntry.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -46,10 +46,11 @@ /** * Gets the last modification time of this entry. - * - * @throws IOException + * + * @return the last modification time of the entry as milliseconds since 1970, or {@code 0} + * if this filesystem does not support getting the last modified time. + * @throws IOException if an error occurs retrieving the timestamp. */ - public long getLastModified() throws IOException; /** Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -53,13 +53,30 @@ (isFile() ? " is a file " : "")); } - /** - * @see org.jnode.fs.FSEntry#getLastModified() - */ + public long getLastChanged() throws IOException { + return iNode.getCtime(); + } + public long getLastModified() throws IOException { return iNode.getMtime(); } + public long getLastAccessed() throws IOException { + return iNode.getAtime(); + } + + public void setLastChanged(long lastChanged) throws IOException { + iNode.setCtime(lastChanged); + } + + public void setLastModified(long lastModified) throws IOException { + iNode.setMtime(lastModified); + } + + public void setLastAccessed(long lastAccessed) throws IOException { + iNode.setAtime(lastAccessed); + } + /** * Returns the type. * Modified: trunk/fs/src/fs/org/jnode/fs/fat/FatDirEntry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/fat/FatDirEntry.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/fat/FatDirEntry.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -52,10 +52,16 @@ /** Flags of this entry */ private int flags; - - /** Modification date */ + + /** Time of creation. */ + private long created; + + /** Time of last modification. */ private long lastModified; - + + /** Time of last access. */ + private long lastAccessed; + /** First cluster of the data of this entry */ private int startCluster; @@ -109,7 +115,7 @@ setName(name); setExt(ext); this.flags = F_ARCHIVE; - this.lastModified = System.currentTimeMillis(); + this.created = this.lastModified = this.lastAccessed = System.currentTimeMillis(); this._dirty = false; this.rights = new UnixFSAccessRights(getFileSystem()); } @@ -144,9 +150,14 @@ setExt(new String(extArr).trim()); this.flags = LittleEndian.getUInt8(src, offset + 0x0b); + this.created = + DosUtils.decodeDateTime(LittleEndian.getUInt16(src, offset + 0x10), + LittleEndian.getUInt16(src, offset + 0x0e)); this.lastModified = - DosUtils.decodeDateTime(LittleEndian.getUInt16(src, offset + 0x18), LittleEndian - .getUInt16(src, offset + 0x16)); + DosUtils.decodeDateTime(LittleEndian.getUInt16(src, offset + 0x18), + LittleEndian.getUInt16(src, offset + 0x16)); + this.lastAccessed = + DosUtils.decodeDateTime(LittleEndian.getUInt16(src, offset + 0x12), 0); // time not stored this.startCluster = LittleEndian.getUInt16(src, offset + 0x1a); this.length = LittleEndian.getUInt32(src, offset + 0x1c); this._dirty = false; @@ -162,15 +173,18 @@ return flags; } - /** - * Returns the changeDate. - * - * @return long - */ + public long getCreated() { + return created; + } + public long getLastModified() { return lastModified; } + public long getLastAccessed() { + return lastAccessed; + } + /** * Returns the deleted. * @@ -243,16 +257,21 @@ setDirty(); } - /** - * Sets the last modification date. - * - * @param lastModified - */ + public void setCreated(long created) { + this.created = created; + setDirty(); + } + public void setLastModified(long lastModified) { this.lastModified = lastModified; setDirty(); } + public void setLastAccessed(long lastAccessed) { + this.lastAccessed = lastAccessed; + setDirty(); + } + /** * Sets the deleted. * @@ -454,6 +473,9 @@ } LittleEndian.setInt8(dest, offset + 0x0b, flags); + LittleEndian.setInt16(dest, offset + 0x0e, DosUtils.encodeTime(created)); + LittleEndian.setInt16(dest, offset + 0x10, DosUtils.encodeDate(created)); + LittleEndian.setInt16(dest, offset + 0x12, DosUtils.encodeDate(lastAccessed)); LittleEndian.setInt16(dest, offset + 0x16, DosUtils.encodeTime(lastModified)); LittleEndian.setInt16(dest, offset + 0x18, DosUtils.encodeDate(lastModified)); LittleEndian.setInt16(dest, offset + 0x1a, startCluster); @@ -489,8 +511,12 @@ b.append(NumberUtils.hex(flags, 2)); b.append(")"); - b.append(" date="); + b.append(" created="); + b.append(new Date(getCreated())); + b.append(" lastModified="); b.append(new Date(getLastModified())); + b.append(" lastAccessed="); + b.append(new Date(getLastAccessed())); b.append(" startCluster="); b.append(getStartCluster()); b.append(" length="); Modified: trunk/fs/src/fs/org/jnode/fs/fat/FatRootEntry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/fat/FatRootEntry.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/fat/FatRootEntry.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -55,12 +55,8 @@ return null; } - /** - * Gets the last modification time of this entry. - */ - public long getLastModified() { - return System.currentTimeMillis(); + return 0; } /** Modified: trunk/fs/src/fs/org/jnode/fs/fat/LfnEntry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/fat/LfnEntry.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/fat/LfnEntry.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -117,10 +117,18 @@ return realEntry.getParent(); } + public long getCreated() { + return realEntry.getCreated(); + } + public long getLastModified() { return realEntry.getLastModified(); } + public long getLastAccessed() { + return realEntry.getLastAccessed(); + } + public boolean isFile() { return realEntry.isFile(); } @@ -134,10 +142,18 @@ realEntry.setName(parent.generateShortNameFor(newName)); } + public void setCreated(long created) { + realEntry.setCreated(created); + } + public void setLastModified(long lastModified) { realEntry.setLastModified(lastModified); } + public void setLastAccessed(long lastAccessed) { + realEntry.setLastAccessed(lastAccessed); + } + public FSFile getFile() throws IOException { return realEntry.getFile(); } Modified: trunk/fs/src/fs/org/jnode/fs/iso9660/EntryRecord.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/iso9660/EntryRecord.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/iso9660/EntryRecord.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -34,6 +34,7 @@ private final int extAttributeLength; private final long extentLocation; private final int dataLength; + private final ISO9660DTime recordingTime; private final int fileUnitSize; private final int flags; private final int interleaveSize; @@ -56,9 +57,10 @@ this.extAttributeLength = getUInt8(buff, offset + 2); this.extentLocation = getUInt32LE(buff, offset + 3); this.dataLength = (int) getUInt32LE(buff, offset + 11); + this.recordingTime = new ISO9660DTime(buff, offset + 19); + this.flags = getUInt8(buff, offset + 26); this.fileUnitSize = getUInt8(buff, offset + 27); this.interleaveSize = getUInt8(buff, offset + 28); - this.flags = getUInt8(buff, offset + 26); // This must be after flags, because of isDirectory. this.identifier = getFileIdentifier(buff, offset, isDirectory(), encoding); } @@ -90,6 +92,10 @@ return dataLength; } + public ISO9660DTime getRecordingTime() { + return recordingTime; + } + public final boolean isDirectory() { return (flags & 0x03) != 0; } Added: trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660DTime.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660DTime.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660DTime.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -0,0 +1,75 @@ +package org.jnode.fs.iso9660; + +import org.jnode.util.LittleEndian; +import java.util.Calendar; +import java.util.TimeZone; +import java.util.GregorianCalendar; + +/** + * ISO9660 datetime structure. + * + * @author Daniel Noll + */ +public class ISO9660DTime { + + /** Length of the structure. */ + static final int LENGTH = 7; + + /** Number of years since 1900. */ + private final int/*uint8*/ year; + + /** Month of the year from 1 to 12. */ + private final int/*uint8*/ month; + + /** Day of the month from 1 to 31. */ + private final int/*uint8*/ day; + + /** Hour of the day from 0 to 23. */ + private final int/*uint8*/ hour; + + /** Minute of the hour from 0 to 59. */ + private final int/*uint8*/ minute; + + /** Second of the minute from 0 to 59. */ + private final int/*uint8*/ second; + + /** GMT values -48 .. + 52 in 15 minute intervals (e.g. -48 = GMT-12, +48=GMT+12, 0=UTC.) */ + private final int/*int8*/ gmtOffset; + + /** + * Constructs an ISO9660 datetime structure by reading from the provided byte array. + * + * @param buff the byte array from which to read. + * @param off offset into the byte array at which to read the struct. + */ + public ISO9660DTime(byte[] buff, int off) + { + year = LittleEndian.getUInt8(buff, off); + month = LittleEndian.getUInt8(buff, off + 1); + day = LittleEndian.getUInt8(buff, off + 2); + hour = LittleEndian.getUInt8(buff, off + 3); + minute = LittleEndian.getUInt8(buff, off + 4); + second = LittleEndian.getUInt8(buff, off + 5); + gmtOffset = LittleEndian.getInt8(buff, off + 6); + } + + /** + * Converts to a Java date, milliseconds since 1970. + * + * @return the date as millis since 1970. + */ + public long toJavaMillis() + { + // Force use of the Gregorian calendar in UTC and manually offset hours later. + // Mainly because it isn't convenient to create a TimeZone from a UTC/GMT offset. + Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC")); + cal.clear(); // kills milliseconds or any other partial crap. + cal.set(year + 1900, month - 1, day, hour, minute, second); + + // GMT offset in 15 minute intervals. + // Example, if offset is GMT+10, the value will be +40, and we need to subtract 600 minutes. + cal.add(Calendar.MINUTE, -gmtOffset * 15); + + return cal.getTimeInMillis(); + } +} Modified: trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Entry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Entry.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Entry.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -22,7 +22,6 @@ package org.jnode.fs.iso9660; import java.io.IOException; -import java.util.Date; import org.jnode.fs.FSAccessRights; import org.jnode.fs.FSDirectory; @@ -62,10 +61,7 @@ * @see org.jnode.fs.FSEntry#getLastModified() */ public long getLastModified() throws IOException { - // FIXME Correct implementation to return real last modified time for - // ISO9660 entry. - Date now = new Date(); - return now.getTime(); + return entryRecord.getRecordingTime().toJavaMillis(); } /** Modified: trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -105,14 +105,30 @@ return entry.getIndex(); } + public long getCreated() throws IOException { + return entry.getCreated(); + } + public long getLastModified() throws IOException { return entry.getLastModified(); } + public long getLastAccessed() throws IOException { + return entry.getLastAccessed(); + } + + public void setCreated(long created) throws IOException { + entry.setCreated(created); + } + public void setLastModified(long lastModified) throws IOException { entry.setLastModified(lastModified); } + public void setLastAccessed(long lastAccessed) throws IOException { + entry.setLastAccessed(lastAccessed); + } + public FatShortDirEntry getEntry() { return entry; } Modified: trunk/fs/src/fs/org/jnode/fs/jfat/FatRootDirectory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/jfat/FatRootDirectory.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/jfat/FatRootDirectory.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -54,19 +54,33 @@ return ""; } + public long getCreated() throws IOException { + FatShortDirEntry label = getEntry(); + return label == null ? 0 : label.getCreated(); + } + public long getLastModified() throws IOException { FatShortDirEntry label = getEntry(); + return label == null ? 0 : label.getLastModified(); + } - if (label != null) - return label.getLastModified(); - else - return FatUtils.getMinDateTime(); + public long getLastAccessed() throws IOException { + FatShortDirEntry label = getEntry(); + return label == null ? 0 : label.getLastAccessed(); } + public void setCreated(long created) throws IOException { + throw new UnsupportedOperationException("cannot change root time"); + } + public void setLastModified(long lastModified) throws IOException { throw new UnsupportedOperationException("cannot change root time"); } + public void setLastAccessed(long lastAccessed) throws IOException { + throw new UnsupportedOperationException("cannot change root time"); + } + public String toString() { StrWriter out = new StrWriter(); Modified: trunk/fs/src/fs/org/jnode/fs/jifs/JIFSDirectory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/jifs/JIFSDirectory.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/jifs/JIFSDirectory.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -122,12 +122,11 @@ return null; } - public void setLastModified(long l) { - return; + public long getLastModified() { + return 0; } - public long getLastModified() { - return System.currentTimeMillis(); + public void setLastModified(long lastModified) { } public void setName(String name) { Modified: trunk/fs/src/fs/org/jnode/fs/jifs/JIFSFile.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/jifs/JIFSFile.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/jifs/JIFSFile.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -135,12 +135,11 @@ return this; } - public void setLastModified(long l) { - return; + public long getLastModified() { + return 0; } - public long getLastModified() { - return System.currentTimeMillis(); + public void setLastModified(long lastModified) { } public void setName(String name) { Modified: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Entry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Entry.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Entry.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -95,10 +95,18 @@ return file; } + public long getLastChanged() throws IOException { + return fileAttribute.getLastStatusChanged().toJavaMillis(); + } + public long getLastModified() throws IOException { - return (long) fileAttribute.getLastModified().getSeconds() * 1000; + return fileAttribute.getLastModified().toJavaMillis(); } + public long getLastAccessed() throws IOException { + return fileAttribute.getLastAccessed().toJavaMillis(); + } + public boolean isDirectory() { if (fileAttribute.getType() == FileAttribute.DIRECTORY) { return true; @@ -114,16 +122,30 @@ return fileAttribute.getType() == FileAttribute.FILE; } + public void setLastChanged(long lastChanged) throws IOException { + // TODO: The setAttribute API appears to have no way to do this. + } + public void setLastModified(long lastModified) throws IOException { NFS2Client client = getNFS2Client(); try { - client.setAttribute(getFileHandle(), -1, -1, -1, -1, new Time(-1, -1), - new Time((int) (lastModified / 1000), -1)); + client.setAttribute(getFileHandle(), -1, -1, -1, -1, + new Time(-1, -1), new Time(lastModified)); } catch (NFS2Exception e) { throw new IOException(e.getMessage(), e); } } + public void setLastAccessed(long lastAccessed) throws IOException { + NFS2Client client = getNFS2Client(); + try { + client.setAttribute(getFileHandle(), -1, -1, -1, -1, + new Time(lastAccessed), new Time(-1, -1)); + } catch (NFS2Exception e) { + throw new IOException(e.getMessage(), e); + } + } + public void setName(String newName) throws IOException { NFS2Client client = getNFS2Client(); NFS2Directory parentDirectory = (NFS2Directory) getParent(); Modified: trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSEntry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSEntry.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSEntry.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -69,14 +69,21 @@ return null; } - /** - * @see org.jnode.fs.FSEntry#getLastModified() - */ + public long getCreated() throws IOException { + return NTFSUTIL.filetimeToMillis(getFileRecord().getFileNameAttribute() + .getCreationTime()); + } + public long getLastModified() throws IOException { return NTFSUTIL.filetimeToMillis(getFileRecord().getFileNameAttribute() .getModificationTime()); } + public long getLastAccessed() throws IOException { + return NTFSUTIL.filetimeToMillis(getFileRecord().getFileNameAttribute() + .getAccessTime()); + } + /** * @see org.jnode.fs.FSEntry#isFile() */ @@ -99,12 +106,16 @@ } - /** - * @see org.jnode.fs.FSEntry#setLastModified(long) - */ + public void setCreated(long created) { + // TODO: Implement write support. + } + public void setLastModified(long lastModified) { - // TODO Auto-generated method stub + // TODO: Implement write support. + } + public void setLastAccessed(long lastAccessed) { + // TODO: Implement write support. } /** Modified: trunk/fs/src/fs/org/jnode/fs/ramfs/RAMDirectory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ramfs/RAMDirectory.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/ramfs/RAMDirectory.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -22,7 +22,9 @@ private RAMDirectory parent; private String directoryName; + private long created; private long lastModified; + private long lastAccessed; private FSAccessRights accessRights; /* if file is deleted, it is no longer valid */ @@ -43,7 +45,7 @@ this.parent = parent; this.directoryName = name; - this.lastModified = System.currentTimeMillis(); + this.created = this.lastModified = this.lastAccessed = System.currentTimeMillis(); // TODO: accessRights @@ -68,15 +70,18 @@ return parent; } - /** - * (non-Javadoc) - * - * @see org.jnode.fs.FSEntry#getLastModified() - */ + public long getCreated() throws IOException { + return created; + } + public long getLastModified() throws IOException { return lastModified; } + public long getLastAccessed() throws IOException { + return lastAccessed; + } + /** * (non-Javadoc) * @@ -105,15 +110,18 @@ directoryName = newName; } - /** - * (non-Javadoc) - * - * @see org.jnode.fs.FSEntry#setLastModified(long) - */ + public void setCreated(long created) throws IOException { + this.created = created; + } + public void setLastModified(long lastModified) throws IOException { this.lastModified = lastModified; } + public void setLastAccessed(long lastAccessed) throws IOException { + this.lastAccessed = lastAccessed; + } + /** * (non-Javadoc) * Modified: trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFile.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFile.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFile.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -23,7 +23,9 @@ private String filename; private ByteBuffer buffer; + private long created; private long lastModified; + private long lastAccessed; private FSAccessRights accessRights; private boolean isValid = true; @@ -37,7 +39,7 @@ public RAMFile(RAMDirectory parent, String filename) { this.parent = parent; this.filename = filename; - this.lastModified = System.currentTimeMillis(); + this.created = this.lastModified = this.lastAccessed = System.currentTimeMillis(); // TODO accessRights @@ -97,15 +99,18 @@ return parent; } - /** - * (non-Javadoc) - * - * @see org.jnode.fs.FSEntry#getLastModified() - */ + public long getCreated() throws IOException { + return created; + } + public long getLastModified() throws IOException { return lastModified; } + public long getLastAccessed() throws IOException { + return lastAccessed; + } + /** * (non-Javadoc) * @@ -135,15 +140,18 @@ setLastModified(System.currentTimeMillis()); } - /** - * (non-Javadoc) - * - * @see org.jnode.fs.FSEntry#setLastModified(long) - */ + public void setCreated(long created) throws IOException { + this.created = created; + } + public void setLastModified(long lastModified) throws IOException { this.lastModified = lastModified; } + public void setLastAccessed(long lastAccessed) throws IOException { + this.lastAccessed = lastAccessed; + } + /** * (non-Javadoc) * Modified: trunk/fs/src/fs/org/jnode/fs/service/def/VirtualDirEntry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/service/def/VirtualDirEntry.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/service/def/VirtualDirEntry.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -45,9 +45,15 @@ /** The filesystem */ private final VirtualFS fs; - /** The last modification time of this entry */ + /** The creation time of this entry. */ + private long created; + + /** The last modification time of this entry. */ private long lastModified; + /** The last access time of this entry. */ + private long lastAccessed; + /** The name of this entry */ private final String name; @@ -67,7 +73,7 @@ */ VirtualDirEntry(VirtualFS fs, String name, VirtualDirEntry parent) throws IOException { this.fs = fs; - this.lastModified = System.currentTimeMillis(); + this.created = this.lastModified = this.lastAccessed = System.currentTimeMillis(); this.name = name; this.parent = (parent != null) ? parent.getDirectory() : null; this.entries = new TreeMap<String, FSEntry>(); @@ -95,13 +101,18 @@ throw new IOException("Not a file"); } - /** - * @see org.jnode.fs.FSEntry#getLastModified() - */ + public long getCreated() throws IOException { + return created; + } + public long getLastModified() throws IOException { return lastModified; } + public long getLastAccessed() throws IOException { + return lastAccessed; + } + /** * @see org.jnode.fs.FSEntry#getName() */ @@ -137,13 +148,18 @@ return false; } - /** - * @see org.jnode.fs.FSEntry#setLastModified(long) - */ + public void setCreated(long created) throws IOException { + this.created = created; + } + public void setLastModified(long lastModified) throws IOException { this.lastModified = lastModified; } + public void setLastAccessed(long lastAccessed) throws IOException { + this.lastAccessed = lastAccessed; + } + /** * @see org.jnode.fs.FSEntry#setName(java.lang.String) */ @@ -273,23 +289,14 @@ this.i = entries.iterator(); } - /** - * @see org.jnode.fs.FSEntryIterator#hasNext() - */ public boolean hasNext() { return i.hasNext(); } - /** - * @see org.jnode.fs.FSEntryIterator#next() - */ public FSEntry next() { return i.next(); } - /** - * @see java.util.Iterator#remove() - */ public void remove() { throw new UnsupportedOperationException(); } Modified: trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSEntry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSEntry.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSEntry.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -61,9 +61,9 @@ return (SMBFSFile) this; } - /** - * @see org.jnode.fs.FSEntry#getLastModified() - */ + public long getCreated() throws IOException { + return smbFile.createTime(); + } public long getLastModified() throws IOException { return smbFile.getLastModified(); @@ -120,9 +120,10 @@ } } - /** - * @see org.jnode.fs.FSEntry#setLastModified(long) - */ + public void setCreated(long created) throws IOException { + smbFile.setCreateTime(created); + } + public void setLastModified(long lastModified) throws IOException { smbFile.setLastModified(lastModified); } Modified: trunk/fs/src/fs/org/jnode/fs/spi/AbstractFSEntry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/spi/AbstractFSEntry.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/fs/src/fs/org/jnode/fs/spi/AbstractFSEntry.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -192,13 +192,7 @@ log.debug("<<< END setName newName=" + newName + " >>>"); } - /** - * Change the date of the last modification of this entry - * - * @param lastModified - * @throws IOException - */ - public final void setLastModified(long lastModified) throws IOException { + public void setLastModified(long lastModified) throws IOException { /* * if(isRoot()) { throw new IOException("Cannot change last modified of * root directory"); } Modified: trunk/net/src/net/org/jnode/net/nfs/nfs2/Time.java =================================================================== --- trunk/net/src/net/org/jnode/net/nfs/nfs2/Time.java 2008-06-15 13:57:27 UTC (rev 4247) +++ trunk/net/src/net/org/jnode/net/nfs/nfs2/Time.java 2008-06-15 15:47:01 UTC (rev 4248) @@ -12,10 +12,25 @@ this(0, 0); } + /** + * Constructs the time from a Java date object. + * + * @param date the date. + */ public Time(Date date) { - this((int) (date.getTime() / 1000), 0); + this(date.getTime()); } + /** + * Constructs the time from milliseconds since 1970. + * + * @param javaMillis the time in milliseconds since 1970. + */ + public Time(long javaMillis) { + this((int) (javaMillis / 1000L), + (int) (1000 * (javaMillis % 1000))); + } + public Time(int seconds, int microSeconds) { this.seconds = seconds; this.microSeconds = microSeconds; @@ -37,6 +52,15 @@ return this.microSeconds; } + /** + * Converts the time to milliseconds since 1970. + * + * @return the time in milliseconds since 1970. + */ + public long toJavaMillis() { + return seconds * 1000L + microSeconds / 1000; + } + @Override public String toString() { Date date = new Date((long) seconds * 1000); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-06-16 08:14:16
|
Revision: 4254 http://jnode.svn.sourceforge.net/jnode/?rev=4254&view=rev Author: lsantha Date: 2008-06-16 01:14:14 -0700 (Mon, 16 Jun 2008) Log Message: ----------- Codestyle fixes. Modified Paths: -------------- trunk/all/build.xml trunk/gui/src/driver/org/jnode/driver/ps2/PS2Bus.java trunk/gui/src/driver/org/jnode/driver/sound/speaker/pc/PCSpeakerDriver.java trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbScrollableTextScreen.java trunk/gui/src/driver/org/jnode/driver/textscreen/swing/SwingPcTextScreen.java trunk/gui/src/driver/org/jnode/driver/textscreen/swing/SwingTextScreenManager.java trunk/gui/src/driver/org/jnode/driver/video/ati/mach64/Mach64Core.java trunk/gui/src/driver/org/jnode/driver/video/ati/mach64/Mach64Driver.java trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/CrtcRegs.java trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/FpRegs.java trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/PllRegs.java trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonConstants.java trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonCore.java trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonDriver.java trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonHardwareCursor.java trunk/gui/src/driver/org/jnode/driver/video/ddc/EDIDConstants.java trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaConfiguration.java trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaCore.java trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaDriver.java trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaHardwareCursor.java trunk/gui/src/driver/org/jnode/driver/video/vga/StandardVGA.java trunk/gui/src/driver/org/jnode/driver/video/vga/VGADriver.java trunk/gui/src/driver/org/jnode/driver/video/vgahw/VgaConstants.java trunk/gui/src/driver/org/jnode/driver/video/vmware/VMWareCore.java trunk/gui/src/driver/org/jnode/driver/video/vmware/VMWareDriver.java Modified: trunk/all/build.xml =================================================================== --- trunk/all/build.xml 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/all/build.xml 2008-06-16 08:14:14 UTC (rev 4254) @@ -884,8 +884,7 @@ <fileset dir="../core/src/core" includes="**/*.java"/> <fileset dir="../core/src/driver" includes="**/*.java"/> <fileset dir="../core/src/test" includes="**/*.java"/> - <fileset dir="../distr/src/apps" includes="**/*.java" - excludes="**/jpartition/**/*.java,**/telnetd/**/*.java,**/vmware/**/*.java"/> + <fileset dir="../distr/src/apps" includes="**/*.java" excludes="**/telnetd/**/*.java"/> <fileset dir="../distr/src/emu" includes="**/*.java"/> <fileset dir="../distr/src/install" includes="**/*.java"/> <fileset dir="../fs/src/fs" includes="**/*.java"/> @@ -893,6 +892,7 @@ <fileset dir="../fs/src/test" includes="**/*.java"/> <fileset dir="../gui/src/test" includes="**/*.java"/> <fileset dir="../gui/src/desktop" includes="**/*.java"/> + <fileset dir="../gui/src/driver" includes="**/*.java" excludes="**/vesa/**/*.java,**/console/swing/**/*.java"/> <fileset dir="../gui/src/awt" includes="**/*.java"/> <fileset dir="../net/src/net" includes="**/*.java"/> <fileset dir="../net/src/driver" includes="**/*.java"/> Modified: trunk/gui/src/driver/org/jnode/driver/ps2/PS2Bus.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/ps2/PS2Bus.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/ps2/PS2Bus.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -110,7 +110,7 @@ * * @see org.jnode.system.IRQHandler#handleInterrupt(int) */ - public synchronized final void handleInterrupt(int irq) { + public final synchronized void handleInterrupt(int irq) { processQueues(); } Modified: trunk/gui/src/driver/org/jnode/driver/sound/speaker/pc/PCSpeakerDriver.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/sound/speaker/pc/PCSpeakerDriver.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/sound/speaker/pc/PCSpeakerDriver.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -47,16 +47,16 @@ // ********** constants **********// /** The port for the speaker * */ - public final static int SPEAKER_PORT = 0x61; + public static final int SPEAKER_PORT = 0x61; /** The PIT Control Port * */ - public final static int CONTROL_PORT = 0x43; + public static final int CONTROL_PORT = 0x43; /** The PIT Channel 2 Port * */ - public final static int CHANNEL2_PORT = 0x42; + public static final int CHANNEL2_PORT = 0x42; /** The base frequency for the PIT * */ - public final static int BASE_FREQUENCY = 1193100; + public static final int BASE_FREQUENCY = 1193100; // ********** private variables **********// @@ -104,6 +104,7 @@ try { Thread.sleep(125); } catch (InterruptedException iex) { + //empty } // restore the speaker port @@ -135,6 +136,7 @@ try { Thread.sleep(length); } catch (InterruptedException iex) { + //empty } // restore the speaker port Modified: trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbScrollableTextScreen.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbScrollableTextScreen.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbScrollableTextScreen.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -99,7 +99,7 @@ * @see org.jnode.driver.textscreen.TextScreen#set(int, char[], int, int, int) */ public void set(int offset, char[] ch, int chOfs, int length, int color) { - maxValidY = Math.max(maxValidY, (offset + length-1) / getWidth()); + maxValidY = Math.max(maxValidY, (offset + length - 1) / getWidth()); super.set(offset, ch, chOfs, length, color); } /** @@ -107,7 +107,7 @@ */ public void set(int offset, char[] ch, int chOfs, int length, int[] colors, int colorsOfs) { - maxValidY = Math.max(maxValidY, (offset + length-1) / getWidth()); + maxValidY = Math.max(maxValidY, (offset + length - 1) / getWidth()); super.set(offset, ch, chOfs, length, colors, colorsOfs); } } Modified: trunk/gui/src/driver/org/jnode/driver/textscreen/swing/SwingPcTextScreen.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/textscreen/swing/SwingPcTextScreen.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/textscreen/swing/SwingPcTextScreen.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -82,8 +82,10 @@ Font font = new Font( "-FontForge-Bitstream Vera Sans Mono-Book-R-Normal-SansMono--12-120-75-75-P-69-ISO10646", Font.PLAIN, 12); - //Font font = new Font("-FontForge-Bitstream Vera Sans Mono-Book-R-Normal-SansMono--12-120-75-75-P-69-FontSpecific", Font.PLAIN, 12); - //Font font = new Font("-FontForge-Bitstream Vera Sans Mono-Book-R-Normal-SansMono--14-100-100-100-P-79-FontSpecific", Font.PLAIN, 12); + //Font font = new Font("-FontForge-Bitstream Vera Sans + // Mono-Book-R-Normal-SansMono--12-120-75-75-P-69-FontSpecific", Font.PLAIN, 12); + //Font font = new Font("-FontForge-Bitstream Vera Sans + // Mono-Book-R-Normal-SansMono--14-100-100-100-P-79-FontSpecific", Font.PLAIN, 12); //Font font = Font.decode("MONOSPACED-PLAIN-14"); setFont(font); enableEvents(AWTEvent.KEY_EVENT_MASK); @@ -314,7 +316,7 @@ } private static class MyPointerDriver extends Driver implements PointerAPI { - final private ArrayList<PointerListener> listeners = new ArrayList<PointerListener>(); + private final ArrayList<PointerListener> listeners = new ArrayList<PointerListener>(); protected synchronized void startDevice() throws DriverException { getDevice().registerAPI(PointerAPI.class, this); @@ -343,7 +345,7 @@ } private static class MyKeyboardDriver extends Driver implements KeyboardAPI { - final private ArrayList<KeyboardListener> listeners = new ArrayList<KeyboardListener>(); + private final ArrayList<KeyboardListener> listeners = new ArrayList<KeyboardListener>(); protected synchronized void startDevice() throws DriverException { getDevice().registerAPI(KeyboardAPI.class, this); Modified: trunk/gui/src/driver/org/jnode/driver/textscreen/swing/SwingTextScreenManager.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/textscreen/swing/SwingTextScreenManager.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/textscreen/swing/SwingTextScreenManager.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -12,7 +12,7 @@ * @see org.jnode.driver.textscreen.TextScreenManager#getSystemScreen() */ public SwingPcTextScreen getSystemScreen() { - if(systemScreen == null){ + if (systemScreen == null) { systemScreen = new SwingPcTextScreen(); } return systemScreen; Modified: trunk/gui/src/driver/org/jnode/driver/video/ati/mach64/Mach64Core.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/ati/mach64/Mach64Core.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/ati/mach64/Mach64Core.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -76,7 +76,7 @@ * @throws DriverException */ public Mach64Core(Mach64Driver driver, String model, PCIDevice device) - throws ResourceNotFreeException, DriverException { + throws ResourceNotFreeException, DriverException { this.driver = driver; final PCIDeviceConfig pciCfg = device.getConfig(); @@ -91,7 +91,7 @@ log.info("Found ATI " + model + ", pci " + pciCfg); try { - final ResourceManager rm = (ResourceManager) InitialNaming.lookup(ResourceManager.NAME); + final ResourceManager rm = InitialNaming.lookup(ResourceManager.NAME); final int fbBase = (int) fbAddr.getMemoryBase() /* & 0xFF800000 */; final int memSize = fbAddr.getSize(); Modified: trunk/gui/src/driver/org/jnode/driver/video/ati/mach64/Mach64Driver.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/ati/mach64/Mach64Driver.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/ati/mach64/Mach64Driver.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -103,7 +103,7 @@ /** * @see org.jnode.driver.video.FrameBufferAPI#isOpen() */ - public synchronized final boolean isOpen() { + public final synchronized boolean isOpen() { return (currentConfig != null); } Modified: trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/CrtcRegs.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/CrtcRegs.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/CrtcRegs.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -226,7 +226,7 @@ /** * round virtual width up to next valid size */ - final static int roundVWidth(int virtual_width, int bpp) { + static int roundVWidth(int virtual_width, int bpp) { // we have to make both the CRTC and the accelerator happy: // - the CRTC wants virtual width in pixels to be a multiple of 8 // - the accelerator expects width in bytes to be a multiple of 64 Modified: trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/FpRegs.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/FpRegs.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/FpRegs.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -125,8 +125,8 @@ fp_vert_stretch &= ~(VERT_AUTO_RATIO_EN | VERT_PANEL_SIZE); fp_vert_stretch |= ((yres - 1) << 12); } else { - fp_vert_stretch = - (((((int) (vRatio * VERT_STRETCH_RATIO_MAX + 0.5)) & VERT_STRETCH_RATIO_MASK)) | (fp_vert_stretch & (VERT_PANEL_SIZE | VERT_STRETCH_RESERVED))); + fp_vert_stretch = (((((int) (vRatio * VERT_STRETCH_RATIO_MAX + 0.5)) & VERT_STRETCH_RATIO_MASK)) | + (fp_vert_stretch & (VERT_PANEL_SIZE | VERT_STRETCH_RESERVED))); fp_vert_stretch |= (VERT_STRETCH_ENABLE | VERT_STRETCH_BLEND); fp_vert_stretch &= ~(VERT_AUTO_RATIO_EN | VERT_PANEL_SIZE); @@ -134,11 +134,8 @@ } - fp_gen_cntl &= - ~(FP_SEL_CRTC2 | FP_RMX_HVSYNC_CONTROL_EN | FP_DFP_SYNC_SEL | FP_CRT_SYNC_SEL | /* - * FP_CRTC_LOCK_8DOT | - * FP_USE_SHADOW_EN | - */FP_CRTC_USE_SHADOW_VEND | FP_CRT_SYNC_ALT); + fp_gen_cntl &= ~(FP_SEL_CRTC2 | FP_RMX_HVSYNC_CONTROL_EN | FP_DFP_SYNC_SEL | FP_CRT_SYNC_SEL | + /* FP_CRTC_LOCK_8DOT | FP_USE_SHADOW_EN | */ FP_CRTC_USE_SHADOW_VEND | FP_CRT_SYNC_ALT); fp_gen_cntl |= (FP_CRTC_DONT_SHADOW_VPAR | FP_CRTC_DONT_SHADOW_HEND); Modified: trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/PllRegs.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/PllRegs.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/PllRegs.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -33,7 +33,7 @@ private final boolean crtc2; - private static final int[] DIVIDERS = {1, 2, 4, 8, 3, 16, 6, 12,}; + private static final int[] DIVIDERS = {1, 2, 4, 8, 3, 16, 6, 12}; /* PLL regs */ private int ppll_div_3; Modified: trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonConstants.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonConstants.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonConstants.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -50,11 +50,11 @@ public static class MonitorType { public static final int NONE = 0; - public static final int CRT = 1;/* CRT */ - public static final int LCD = 2;/* LCD */ - public static final int DFP = 3;/* DVI */ - public static final int CTV = 4;/* composite TV */ - public static final int STV = 5;/* S-Video out */ + public static final int CRT = 1; /* CRT */ + public static final int LCD = 2; /* LCD */ + public static final int DFP = 3; /* DVI */ + public static final int CTV = 4; /* composite TV */ + public static final int STV = 5; /* S-Video out */ private static final String[] NAMES = {"NONE", "CRT", "LCD", "DFP", "CTV", "STV"}; Modified: trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonCore.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonCore.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonCore.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -90,7 +90,7 @@ * @param device */ public RadeonCore(RadeonDriver driver, int architecture, String model, PCIDevice device) - throws ResourceNotFreeException, DriverException { + throws ResourceNotFreeException, DriverException { this.driver = driver; this.fbinfo = new FBInfo(architecture); Modified: trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonDriver.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonDriver.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonDriver.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -105,7 +105,7 @@ /** * @see org.jnode.driver.video.FrameBufferAPI#isOpen() */ - public synchronized final boolean isOpen() { + public final synchronized boolean isOpen() { return (currentConfig != null); } Modified: trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonHardwareCursor.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonHardwareCursor.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonHardwareCursor.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -55,7 +55,7 @@ * @param io */ public RadeonHardwareCursor(RadeonCore kernel, RadeonVgaIO io) - throws IndexOutOfBoundsException, ResourceNotFreeException { + throws IndexOutOfBoundsException, ResourceNotFreeException { this.io = io; this.cursorMem = kernel.claimDeviceMemory(4096, 16); log.debug("Cursor memory at offset 0x" + NumberUtils.hex(cursorMem.getOffset().toInt())); Modified: trunk/gui/src/driver/org/jnode/driver/video/ddc/EDIDConstants.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/ddc/EDIDConstants.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/ddc/EDIDConstants.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -33,9 +33,8 @@ public static final int STD_TIMINGS = 8; public static final int DET_TIMINGS = 4; - public static final byte[] HEADER_SIGNATURE = - {0x00, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, - 0x00}; + public static final byte[] HEADER_SIGNATURE = {0x00, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, 0x00}; /* header: 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x00 */ public static final int HEADER_SECTION = 0; Modified: trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaConfiguration.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaConfiguration.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaConfiguration.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -52,12 +52,13 @@ * 0, 14 }, 43 } */ public static final NVidiaConfiguration VESA_115 = - new NVidiaConfiguration(32, 0, 0, 3, 16, 162571, new NVidiaVgaState(new int[] {3, 1, - 15, 0, 14}, new int[] {127, 99, 99, 131, 106, 26, 114, 240, 0, 96, 0, 0, 0, 0, 0, - 0, 89, 13, 87, 144, 0, 87, 115, 227, 255}, - new int[] {0, 0, 0, 0, 0, 64, 5, 15, 255}, new int[] {0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, 65, 0, 15, 0, 0}, 0x2B), new DisplayMode( - "40000 800 840 968 1056 600 601 605 628")); + new NVidiaConfiguration(32, 0, 0, 3, 16, 162571, + new NVidiaVgaState(new int[]{3, 1, 15, 0, 14}, + new int[]{127, 99, 99, 131, 106, 26, 114, 240, 0, 96, 0, 0, 0, 0, 0, + 0, 89, 13, 87, 144, 0, 87, 115, 227, 255}, + new int[]{0, 0, 0, 0, 0, 64, 5, 15, 255}, + new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 65, 0, 15, 0, 0}, 0x2B), + new DisplayMode("40000 800 840 968 1056 600 601 605 628")); /* * { 0x118, 32, 1024, 768, 0, 0, 3, 17, 95757, { crt { 163, 127, 127, 135, @@ -68,11 +69,13 @@ * */ public static final NVidiaConfiguration VESA_118 = - new NVidiaConfiguration(32, 0, 0, 3, 17, 95757, new NVidiaVgaState(new int[] {3, 1, 15, - 0, 14}, new int[] {163, 127, 127, 135, 132, 149, 36, 245, 0, 96, 0, 0, 0, 0, 0, 0, - 3, 9, 255, 0, 0, 255, 37, 227, 255}, new int[] {0, 0, 0, 0, 0, 64, 5, 15, 255}, - new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 65, 0, 15, 0, - 0}, 0xEB), new DisplayMode("65000 1024 1048 1184 1344 768 771 777 806")); + new NVidiaConfiguration(32, 0, 0, 3, 17, 95757, + new NVidiaVgaState(new int[]{3, 1, 15, 0, 14}, + new int[]{163, 127, 127, 135, 132, 149, 36, 245, 0, 96, 0, 0, 0, 0, 0, 0, 3, 9, 255, 0, + 0, 255, 37, 227, 255}, + new int[]{0, 0, 0, 0, 0, 64, 5, 15, 255}, + new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 65, 0, 15, 0, 0}, 0xEB), + new DisplayMode("65000 1024 1048 1184 1344 768 771 777 806")); /** * @param bpp Modified: trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaCore.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaCore.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaCore.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -82,7 +82,7 @@ * @param device */ public NVidiaCore(NVidiaDriver driver, int architecture, String model, PCIDevice device) - throws ResourceNotFreeException, DriverException { + throws ResourceNotFreeException, DriverException { super(640, 480); this.driver = driver; this.architecture = architecture; Modified: trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaDriver.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaDriver.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaDriver.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -108,7 +108,7 @@ /** * @see org.jnode.driver.video.FrameBufferAPI#isOpen() */ - public synchronized final boolean isOpen() { + public final synchronized boolean isOpen() { return (currentConfig != null); } Modified: trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaHardwareCursor.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaHardwareCursor.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaHardwareCursor.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -49,7 +49,7 @@ final void initCursor() { /* set cursor bitmap adress ... */ - if (architecture <= NV04A) /* or laptop */{ + if (architecture <= NV04A) { /* or laptop */ /* must be used this way on pre-NV10 and on all 'Go' cards! */ /* cursorbitmap must start on 2Kbyte boundary: */ /* set adress bit11-16, and set 'no doublescan' (registerbit 1 = 0) */ Modified: trunk/gui/src/driver/org/jnode/driver/video/vga/StandardVGA.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/vga/StandardVGA.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/vga/StandardVGA.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -44,14 +44,12 @@ * The SEQuencer, CRT, GRA, and ATTribute register sets for 640x480x16 color * mode. */ - private final static int[] seq = {0x03, 0x01, 0x0F, 0x00, 0x06}; - private final static int[] crt = - {0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xEA, 0x8C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF}; - private final static int[] gra = {0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF}; - private final static int[] att = - {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, - 0x0E, 0x0F, 0x01, 0x00, 0x0F, 0x00, 0x00}; + private static final int[] seq = {0x03, 0x01, 0x0F, 0x00, 0x06}; + private static final int[] crt = {0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00, 0x40, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xEA, 0x8C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF}; + private static final int[] gra = {0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF}; + private static final int[] att = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, + 0x0D, 0x0E, 0x0F, 0x01, 0x00, 0x0F, 0x00, 0x00}; private final MemoryResource vgaMem; private final VgaState state640x480x16; @@ -59,10 +57,9 @@ public StandardVGA(ResourceOwner owner, IndexColorModel cm) throws ResourceNotFreeException { try { - ResourceManager rm = (ResourceManager) InitialNaming.lookup(ResourceManager.NAME); - vgaMem = - rm.claimMemoryResource(owner, Address.fromIntZeroExtend(0xa0000), 0x9600, - ResourceManager.MEMMODE_NORMAL); + ResourceManager rm = InitialNaming.lookup(ResourceManager.NAME); + vgaMem = rm.claimMemoryResource(owner, Address.fromIntZeroExtend(0xa0000), 0x9600, + ResourceManager.MEMMODE_NORMAL); state640x480x16 = new VgaState(seq, crt, gra, att, 0xe3, cm); oldState = new VgaState(); } catch (NameNotFoundException ex) { @@ -91,14 +88,11 @@ vgaMem.release(); } - private final void cls(VgaIO io) { + private void cls(VgaIO io) { io.setGRAF(0x08, 0xFF); - vgaMem.clear(0, (int) vgaMem.getSize().toInt()); + vgaMem.clear(0, vgaMem.getSize().toInt()); } - /** - * @return - */ final MemoryResource getVgaMem() { return this.vgaMem; } Modified: trunk/gui/src/driver/org/jnode/driver/video/vga/VGADriver.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/vga/VGADriver.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/vga/VGADriver.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -116,8 +116,7 @@ } }; - private static final FrameBufferConfiguration[] CONFIGS = - {new VGAConfiguration(640, 480, COLOR_MODEL)}; + private static final FrameBufferConfiguration[] CONFIGS = {new VGAConfiguration(640, 480, COLOR_MODEL)}; private FrameBufferConfiguration currentConfig; private VGASurface vga; @@ -183,7 +182,7 @@ /** * @see org.jnode.driver.video.FrameBufferAPI#isOpen() */ - public synchronized final boolean isOpen() { + public final synchronized boolean isOpen() { return (currentConfig != null); } @@ -191,7 +190,6 @@ * The given surface is closed. */ synchronized void close(VGASurface vga) { - vga = null; currentConfig = null; } } Modified: trunk/gui/src/driver/org/jnode/driver/video/vgahw/VgaConstants.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/vgahw/VgaConstants.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/vgahw/VgaConstants.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -26,15 +26,12 @@ */ public interface VgaConstants { - public static final byte[] REDS = - {0, 0, 0, 0, (byte) 168, (byte) 168, (byte) 168, (byte) 168, (byte) 84, (byte) 84, - (byte) 84, (byte) 84, (byte) 255, (byte) 255, (byte) 255, (byte) 255}; - public static final byte[] GREENS = - {0, 0, (byte) 168, (byte) 168, 0, 0, (byte) 84, (byte) 168, (byte) 84, (byte) 84, - (byte) 255, (byte) 255, (byte) 84, (byte) 84, (byte) 255, (byte) 255}; - public static final byte[] BLUES = - {0, (byte) 168, 0, (byte) 168, 0, (byte) 168, 0, (byte) 168, (byte) 84, (byte) 255, - (byte) 84, (byte) 255, (byte) 84, (byte) 255, (byte) 84, (byte) 255}; + public static final byte[] REDS = {0, 0, 0, 0, (byte) 168, (byte) 168, (byte) 168, (byte) 168, (byte) 84, (byte) 84, + (byte) 84, (byte) 84, (byte) 255, (byte) 255, (byte) 255, (byte) 255}; + public static final byte[] GREENS = {0, 0, (byte) 168, (byte) 168, 0, 0, (byte) 84, (byte) 168, (byte) 84, + (byte) 84, (byte) 255, (byte) 255, (byte) 84, (byte) 84, (byte) 255, (byte) 255}; + public static final byte[] BLUES = {0, (byte) 168, 0, (byte) 168, 0, (byte) 168, 0, (byte) 168, (byte) 84, + (byte) 255, (byte) 84, (byte) 255, (byte) 84, (byte) 255, (byte) 84, (byte) 255}; public static final int VGA_FIRST_PORT = 0x3b0; public static final int VGA_LAST_PORT = VGA_FIRST_PORT + 0x2f; Modified: trunk/gui/src/driver/org/jnode/driver/video/vmware/VMWareCore.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/vmware/VMWareCore.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/vmware/VMWareCore.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -549,7 +549,8 @@ // + ReadFIFO (SVGA_FIFO_NEXT_CMD)); /* Need to sync? */ if ((getFIFO(SVGA_FIFO_NEXT_CMD) + 4 == getFIFO(SVGA_FIFO_STOP)) || - (getFIFO(SVGA_FIFO_NEXT_CMD) == getFIFO(SVGA_FIFO_MAX) - 4 && getFIFO(SVGA_FIFO_STOP) == getFIFO(SVGA_FIFO_MIN))) { + (getFIFO(SVGA_FIFO_NEXT_CMD) == getFIFO(SVGA_FIFO_MAX) - 4 && + getFIFO(SVGA_FIFO_STOP) == getFIFO(SVGA_FIFO_MIN))) { log.debug("VMWare::WriteWordToFIFO() syncing FIFO"); setReg32(SVGA_REG_SYNC, 1); while (getReg32(SVGA_REG_BUSY) != 0) { Modified: trunk/gui/src/driver/org/jnode/driver/video/vmware/VMWareDriver.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/vmware/VMWareDriver.java 2008-06-15 19:47:24 UTC (rev 4253) +++ trunk/gui/src/driver/org/jnode/driver/video/vmware/VMWareDriver.java 2008-06-16 08:14:14 UTC (rev 4254) @@ -93,7 +93,7 @@ /** * @see org.jnode.driver.video.FrameBufferAPI#isOpen() */ - public synchronized final boolean isOpen() { + public final synchronized boolean isOpen() { return (currentConfig != null); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2008-06-19 19:11:13
|
Revision: 4263 http://jnode.svn.sourceforge.net/jnode/?rev=4263&view=rev Author: fduminy Date: 2008-06-19 12:10:50 -0700 (Thu, 19 Jun 2008) Log Message: ----------- optimizations of TextScreen(Console) operations (sync/copy/update) Modified Paths: -------------- trunk/core/src/driver/org/jnode/driver/console/textscreen/ScrollableTextScreenConsole.java trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsole.java trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsoleManager.java trunk/core/src/driver/org/jnode/driver/textscreen/TextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcBufferTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcBufferTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcScrollableTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreen.java trunk/distr/src/apps/org/jnode/apps/telnetd/JNodeCommandShell.java trunk/distr/src/apps/org/jnode/apps/telnetd/JNodeShell.java trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteConsoleInputStream.java trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteConsoleManager.java trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteConsoleOutputStream.java trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteTextScreen.java trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteTextScreenManager.java trunk/distr/src/apps/org/jnode/apps/telnetd/TelnetServerCommand.java trunk/distr/src/apps/org/jnode/apps/telnetd/TelnetUtils.java trunk/distr/src/apps/org/jnode/apps/telnetd/telnetd.properties trunk/gui/descriptors/org.jnode.driver.video.vesa.xml trunk/gui/src/driver/org/jnode/driver/console/swing/JTextAreaTextScreen.java trunk/gui/src/driver/org/jnode/driver/console/swing/SwingTextScreenConsoleManager.java trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbScrollableTextScreen.java trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbTextScreen.java trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbTextScreenPlugin.java trunk/gui/src/driver/org/jnode/driver/textscreen/swing/SwingPcTextScreen.java trunk/gui/src/test/org/jnode/test/gui/FBConsole.java trunk/shell/src/shell/org/jnode/shell/CommandShell.java Added Paths: ----------- trunk/core/src/driver/org/jnode/driver/console/textscreen/DefaultKeyboardHandler.java trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardHandler.java trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteKeyboardHandler.java trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FBConsole.java Added: trunk/core/src/driver/org/jnode/driver/console/textscreen/DefaultKeyboardHandler.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/textscreen/DefaultKeyboardHandler.java (rev 0) +++ trunk/core/src/driver/org/jnode/driver/console/textscreen/DefaultKeyboardHandler.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -0,0 +1,112 @@ +package org.jnode.driver.console.textscreen; + +import java.io.IOException; + +import javax.naming.NameNotFoundException; + +import org.jnode.driver.ApiNotFoundException; +import org.jnode.driver.Device; +import org.jnode.driver.DeviceListener; +import org.jnode.driver.DeviceManager; +import org.jnode.driver.input.KeyboardAPI; +import org.jnode.driver.input.KeyboardEvent; +import org.jnode.driver.input.KeyboardListener; +import org.jnode.naming.InitialNaming; +import org.jnode.system.BootLog; +import org.jnode.system.event.FocusEvent; +import org.jnode.system.event.FocusListener; +import org.jnode.util.Queue; + + +/** + * @author cr...@jn... + * + */ +public class DefaultKeyboardHandler extends KeyboardHandler +implements KeyboardListener, FocusListener, DeviceListener { + + private KeyboardAPI api; + private final DeviceManager devMan; + + private boolean hasFocus; + + public DefaultKeyboardHandler(KeyboardAPI api) { + if (api != null) { + this.devMan = null; + this.api = api; + this.api.addKeyboardListener(this); + } + else { + DeviceManager dm = null; + try { + dm = InitialNaming.lookup(DeviceManager.NAME); + dm.addListener(this); + } + catch (NameNotFoundException ex) { + BootLog.error("DeviceManager not found", ex); + } + this.devMan = dm; + } + } + + private void registerKeyboardApi(Device device) { + if (this.api == null) { + try { + this.api = device.getAPI(KeyboardAPI.class); + this.api.addKeyboardListener(this); + } + catch (ApiNotFoundException ex) { + BootLog.error("KeyboardAPI not found", ex); + } + this.devMan.removeListener(this); + } + } + + /** + * @see org.jnode.driver.input.KeyboardListener#keyPressed(org.jnode.driver.input.KeyboardEvent) + */ + public void keyPressed(KeyboardEvent event) { + if (hasFocus) { + postEvent(event); + } + } + + /** + * @see org.jnode.driver.input.KeyboardListener#keyReleased(org.jnode.driver.input.KeyboardEvent) + */ + public void keyReleased(KeyboardEvent event) { + } + + /** + * @see java.io.InputStream#close() + */ + public void close() throws IOException { + if (api != null) { + api.removeKeyboardListener(this); + } + } + + /** + * @see org.jnode.driver.DeviceListener#deviceStarted(org.jnode.driver.Device) + */ + public void deviceStarted(Device device) { + if (device.implementsAPI(KeyboardAPI.class)) { + registerKeyboardApi(device); + } + } + + /** + * @see org.jnode.driver.DeviceListener#deviceStop(org.jnode.driver.Device) + */ + public void deviceStop(Device device) { + /* Do nothing */ + } + + public void focusGained(FocusEvent event) { + hasFocus = true; + } + + public void focusLost(FocusEvent event) { + hasFocus = false; + } +} Added: trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardHandler.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardHandler.java (rev 0) +++ trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardHandler.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -0,0 +1,70 @@ +package org.jnode.driver.console.textscreen; + +import java.io.IOException; + +import javax.naming.NameNotFoundException; + +import org.jnode.driver.ApiNotFoundException; +import org.jnode.driver.Device; +import org.jnode.driver.DeviceListener; +import org.jnode.driver.DeviceManager; +import org.jnode.driver.input.KeyboardAPI; +import org.jnode.driver.input.KeyboardEvent; +import org.jnode.driver.input.KeyboardListener; +import org.jnode.naming.InitialNaming; +import org.jnode.system.BootLog; +import org.jnode.system.event.FocusEvent; +import org.jnode.system.event.FocusListener; +import org.jnode.util.Queue; + + +/** + * KeyInputStream maps keyboard events into a stream of characters. Current functionality includes: + * <ul> + * <li>line buffering and line editing, using a text console, + * <li>integrated input history and completion, + * <li>CTRL-D is interpretted as a 'soft' EOF mark,KeyboardInputStream + * <li>listens to keyboard focus events. + * </ul> + * + * Future enhancements include: + * <ul> + * <li>a "raw" mode in which characters and other keyboard events are delivered without line editing, + * <li>a "no echo" mode in which line editting occurs without echoing of input characters, + * <li>making the active characters and keycodes "soft", + * <li>making completion and history context sensitive; e.g. when switching between a shell and + * an application, and + * <li>code refactoring to support classical terminal devices and remote consoles. + * </ul> + * + * Bugs: + * <ul> + * <li>The current method of echoing the input is suboptimal, and is broken in the case where an + * application outputs a prompt string to stdout or stderr. + * </ul> + * + * @author cr...@jn... + * + */ +abstract public class KeyboardHandler { + + /** The queue of keyboard events */ + private final Queue<KeyboardEvent> queue = new Queue<KeyboardEvent>(); + + protected void postEvent(KeyboardEvent event) + { + queue.add(event); + } + + /** + * Get the next KeyboardEvent from the internal queue (and wait if none is available). + * + * @return + */ + public final KeyboardEvent getEvent() + { + return queue.get(); + } + + abstract public void close() throws IOException; +} Modified: trunk/core/src/driver/org/jnode/driver/console/textscreen/ScrollableTextScreenConsole.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/textscreen/ScrollableTextScreenConsole.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/console/textscreen/ScrollableTextScreenConsole.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,11 +18,12 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.console.textscreen; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; + import org.jnode.driver.console.ConsoleManager; import org.jnode.driver.input.KeyboardEvent; import org.jnode.driver.input.PointerEvent; @@ -39,58 +40,60 @@ * @param screen */ public ScrollableTextScreenConsole(ConsoleManager mgr, String name, - ScrollableTextScreen screen, int options) { + ScrollableTextScreen screen, int options) { super(mgr, name, screen, options); } - + /** * Scroll a given number of rows up. * * @param rows */ public void scrollUp(int rows) { - final ScrollableTextScreen screen = (ScrollableTextScreen) getScreen(); + final ScrollableTextScreen screen = (ScrollableTextScreen)getScreen(); screen.scrollUp(rows); - screen.sync(); + + final int length = rows * screen.getWidth(); + screen.sync(screen.getHeight() * screen.getWidth() - length, length); } - + /** * Scroll a given number of rows down. * * @param rows */ public void scrollDown(int rows) { - final ScrollableTextScreen screen = (ScrollableTextScreen) getScreen(); - screen.scrollDown(rows); - screen.sync(); + final ScrollableTextScreen screen = (ScrollableTextScreen)getScreen(); + screen.scrollDown(rows); + screen.sync(0, rows * screen.getWidth()); } - + /** * @see org.jnode.driver.input.KeyboardListener#keyPressed(org.jnode.driver.input.KeyboardEvent) */ public void keyPressed(KeyboardEvent event) { if (isFocused() && !event.isConsumed()) { - final int modifiers = event.getModifiers(); - if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { - switch (event.getKeyCode()) { - case KeyEvent.VK_PAGE_UP: - scrollUp(10); - event.consume(); - break; - case KeyEvent.VK_PAGE_DOWN: - scrollDown(10); - event.consume(); - break; - case KeyEvent.VK_UP: - scrollUp(1); - event.consume(); - break; - case KeyEvent.VK_DOWN: - scrollDown(1); - event.consume(); - break; - } - } + final int modifiers = event.getModifiers(); + if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { + switch (event.getKeyCode()) { + case KeyEvent.VK_PAGE_UP : + scrollUp(10); + event.consume(); + break; + case KeyEvent.VK_PAGE_DOWN : + scrollDown(10); + event.consume(); + break; + case KeyEvent.VK_UP : + scrollUp(1); + event.consume(); + break; + case KeyEvent.VK_DOWN : + scrollDown(1); + event.consume(); + break; + } + } } if (!event.isConsumed()) { super.keyPressed(event); @@ -104,7 +107,7 @@ if (isFocused() && (event.getZ() != 0)) { final int z = event.getZ(); if (z < 0) { - scrollUp(Math.abs(z)); + scrollUp(Math.abs(z)); } else { scrollDown(Math.abs(z)); } Modified: trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsole.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsole.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsole.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,13 +18,14 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.console.textscreen; import java.io.InputStream; import java.io.PrintStream; import java.security.AccessController; import java.security.PrivilegedAction; + import org.jnode.driver.console.ConsoleManager; import org.jnode.driver.console.InputCompleter; import org.jnode.driver.console.TextConsole; @@ -46,336 +47,337 @@ /** * The screen I'm writing on */ - private final TextScreen screen; + private final TextScreen screen; /** * Width of the screen */ - private final int scrWidth; + private final int scrWidth; /** * Height of the screen */ - private final int scrHeight; + private final int scrHeight; /** * Current tab size */ - private int tabSize = 4; + private int tabSize = 4; /** * Current X position */ - private int curX; + private int curX; /** * Current Y position */ - private int curY; + private int curY; + + private InputStream in; - private InputStream in; + private final ConsolePrintStream out; - private final ConsolePrintStream out; + private final ConsolePrintStream err; - private final ConsolePrintStream err; + private PrintStream savedOut; - private PrintStream savedOut; + private PrintStream savedErr; - private PrintStream savedErr; + private boolean cursorVisible = true; - private boolean cursorVisible = true; + private final boolean claimSystemOutErr; - private final boolean claimSystemOutErr; - private VmIsolate myIsolate; /** - * @param mgr - * @param name - * @param screen - */ - public TextScreenConsole(ConsoleManager mgr, String name, - TextScreen screen, int options) { - super(mgr, name); - this.screen = screen; - this.scrWidth = screen.getWidth(); - this.scrHeight = screen.getHeight(); - this.savedOut = this.out = new ConsolePrintStream(new ConsoleOutputStream( - this, 0x07)); - this.savedErr = this.err = new ConsolePrintStream(new ConsoleOutputStream( - this, 0x04)); + * @param mgr + * @param name + * @param screen + */ + public TextScreenConsole(ConsoleManager mgr, String name, + TextScreen screen, int options) { + super(mgr, name); + this.screen = screen; + this.scrWidth = screen.getWidth(); + this.scrHeight = screen.getHeight(); + this.savedOut = this.out = new ConsolePrintStream(new ConsoleOutputStream( + this, 0x07)); + this.savedErr = this.err = new ConsolePrintStream(new ConsoleOutputStream( + this, 0x04)); //todo crawley, will the console not set System.out/err any more? -// this.claimSystemOutErr = ((options & ConsoleManager.CreateOptions.NO_SYSTEM_OUT_ERR) == 0); - this.claimSystemOutErr = false; +// this.claimSystemOutErr = ((options & ConsoleManager.CreateOptions.NO_SYSTEM_OUT_ERR) == 0); + this.claimSystemOutErr = false; this.myIsolate = VmIsolate.currentIsolate(); } - /** - * Clear the console - * - * @see org.jnode.driver.console.TextConsole#clear() - */ - public void clear() { - final int size = screen.getWidth() * screen.getHeight(); - screen.set(0, ' ', size, 0x07); - syncScreen(); - } + /** + * Clear the console + * + * @see org.jnode.driver.console.TextConsole#clear() + */ + public void clear() { + final int size = screen.getWidth() * screen.getHeight(); + screen.set(0, ' ', size, 0x07); + syncScreen(0, size); + } - /** - * Clear a given row - */ - public void clearRow(int row) { - final int size = screen.getWidth(); - screen.set(screen.getOffset(0, row), ' ', size, 0x07); - syncScreen(); - } + /** + * Clear a given row + */ + public void clearRow(int row) { + final int size = screen.getWidth(); + final int offset = screen.getOffset(0, row); + screen.set(offset, ' ', size, 0x07); + syncScreen(offset, size); + } - /** - * Append characters to the current line. - * - * @param v + /** + * Append characters to the current line. + * + * @param v * @param offset * @param lenght - * @param color - */ + * @param color + */ public void putChar(char v[], int offset, int lenght, int color) { int mark = 0; - for (int i = 0; i < lenght; i++) { + for(int i = 0; i < lenght; i++){ char c = v[i + offset]; - if (c == '\n' || c == '\b' || c == '\t' || - curX + i == scrWidth - 1 || i == lenght - 1) { + if(c == '\n' || c =='\b' || c == '\t' || + curX + i == scrWidth - 1 || i == lenght - 1){ final int ln = i - mark; - if (ln > 0) { + if(ln > 0){ screen.set(screen.getOffset(curX, curY), v, offset + mark, ln, color); curX += ln; if (curX >= scrWidth) { curY++; curX = curX - scrWidth; - } + } } mark = i + 1; doPutChar(c, color); } } - screen.ensureVisible(curY); - syncScreen(); + screen.ensureVisible(curY, isFocused()); // synchronize if focused } - /** - * Append a character to the current line. - * - * @param v - * @param color - */ - public void putChar(char v, int color) { - doPutChar(v, color); - screen.ensureVisible(curY); - syncScreen(); - } - - private void doPutChar(char v, int color) { - if (v == '\n') { - // Goto next line - // Clear till eol + /** + * Append a character to the current line. + * + * @param v + * @param color + */ + public void putChar(char v, int color) { + doPutChar(v, color); + screen.ensureVisible(curY, isFocused()); // synchronize if focused + } + + private void doPutChar(char v, int color) { + if (v == '\n') { + // Goto next line + // Clear till eol screen.set(screen.getOffset(curX, curY), ' ', scrWidth - curX, color); - curX = 0; - curY++; - } else if (v == '\b') { - if (curX > 0) { - curX--; - } else if (curY > 0) { - curX = scrWidth - 1; - curY--; - } - setChar(curX, curY, ' ', color); - } else if (v == '\t') { - putChar(' ', color); - while ((curX % tabSize) != 0) { - putChar(' ', color); - } - } else { - setChar(curX, curY, v, color); - curX++; - if (curX >= scrWidth) { - curY++; - curX = 0; - } - } - while (curY >= scrHeight) { - screen.copyContent(scrWidth, 0, (scrHeight - 1) * scrWidth); - curY--; - clearRow(curY); - } - } + curX = 0; + curY++; + } else if (v == '\b') { + if (curX > 0) { + curX--; + } else if (curY > 0) { + curX = scrWidth - 1; + curY--; + } + setChar(curX, curY, ' ', color); + } else if (v == '\t') { + putChar(' ', color); + while ((curX % tabSize) != 0) { + putChar(' ', color); + } + } else { + setChar(curX, curY, v, color); + curX++; + if (curX >= scrWidth) { + curY++; + curX = 0; + } + } + while (curY >= scrHeight) { + screen.copyContent(scrWidth, 0, (scrHeight - 1) * scrWidth); + curY--; + clearRow(curY); + } + } - /** - * @return Returns the tabSize. - */ - public int getTabSize() { - return tabSize; - } + /** + * @return Returns the tabSize. + */ + public int getTabSize() { + return tabSize; + } - /** + /** * @param tabSize The tabSize to set. - */ - public void setTabSize(int tabSize) { - this.tabSize = tabSize; - } + */ + public void setTabSize(int tabSize) { + this.tabSize = tabSize; + } - /** - * @see org.jnode.driver.console.TextConsole#getColor(int, int) - */ - public int getColor(int x, int y) { - return screen.getColor(screen.getOffset(x, y)); - } + /** + * @see org.jnode.driver.console.TextConsole#getColor(int, int) + */ + public int getColor(int x, int y) { + return screen.getColor(screen.getOffset(x, y)); + } - /** - * @see org.jnode.driver.console.TextConsole#getChar(int, int) - */ - public char getChar(int x, int y) { - return screen.getChar(screen.getOffset(x, y)); - } + /** + * @see org.jnode.driver.console.TextConsole#getChar(int, int) + */ + public char getChar(int x, int y) { + return screen.getChar(screen.getOffset(x, y)); + } - /** - * @see org.jnode.driver.console.TextConsole#getCursorX() - */ - public int getCursorX() { - return curX; - } + /** + * @see org.jnode.driver.console.TextConsole#getCursorX() + */ + public int getCursorX() { + return curX; + } - /** - * @see org.jnode.driver.console.TextConsole#getCursorY() - */ - public int getCursorY() { - return curY; - } + /** + * @see org.jnode.driver.console.TextConsole#getCursorY() + */ + public int getCursorY() { + return curY; + } - /** - * @see org.jnode.driver.console.TextConsole#getHeight() - */ - public int getHeight() { - return screen.getHeight(); - } + /** + * @see org.jnode.driver.console.TextConsole#getHeight() + */ + public int getHeight() { + return screen.getHeight(); + } - /** - * @see org.jnode.driver.console.TextConsole#getWidth() - */ - public int getWidth() { - return screen.getWidth(); - } + /** + * @see org.jnode.driver.console.TextConsole#getWidth() + */ + public int getWidth() { + return screen.getWidth(); + } - /** - * @see org.jnode.driver.console.TextConsole#setChar(int, int, char, int) - */ - public void setChar(int x, int y, char ch, int color) { - screen.set(screen.getOffset(x, y), ch, 1, color); - syncScreen(); - } + /** + * @see org.jnode.driver.console.TextConsole#setChar(int, int, char, int) + */ + public void setChar(int x, int y, char ch, int color) { + int offset = screen.getOffset(x, y); + screen.set(offset, ch, 1, color); + syncScreen(offset, 1); + } - public void setChar(int x, int y, char[] ch, int color) { - screen.set(screen.getOffset(x, y), ch, 0, ch.length, color); - syncScreen(); - } + public void setChar(int x, int y, char[] ch, int color) { + int offset = screen.getOffset(x, y); + screen.set(offset, ch, 0, ch.length, color); + syncScreen(offset, ch.length); + } - public void setChar(int x, int y, char[] ch, int cOfset, int cLength, - int color) { - screen.set(screen.getOffset(x, y), ch, cOfset, cLength, color); - syncScreen(); - } + public void setChar(int x, int y, char[] ch, int cOfset, int cLength, + int color) { + int offset = screen.getOffset(x, y); + screen.set(offset, ch, cOfset, cLength, color); + syncScreen(offset, cLength); + } - /** - * @see org.jnode.driver.console.TextConsole#setCursor(int, int) - */ - public void setCursor(int x, int y) { - this.curX = x; - this.curY = y; - screen.setCursor(x, y); - syncScreen(); - } + /** + * @see org.jnode.driver.console.TextConsole#setCursor(int, int) + */ + public void setCursor(int x, int y) { + this.curX = x; + this.curY = y; + int offset = screen.setCursor(x,y); + syncScreen(offset, 1); + } - protected final void syncScreen() { - if (isFocused()) { - screen.sync(); - } - } + private void syncScreen(int offset, int size) { + if (isFocused()) { + screen.sync(offset, size); + } + } - /** - * Ensure that the given row is visible. - * - * @param row - */ - public void ensureVisible(int row) { - screen.ensureVisible(row); - syncScreen(); - } + /** + * Ensure that the given row is visible. + * + * @param row + */ + public void ensureVisible(int row) { + screen.ensureVisible(row, isFocused()); // synchronize if focused + } - public InputCompleter getCompleter() { - if (in instanceof KeyboardInputStream) { - return ((KeyboardInputStream) in).getCompleter(); + public InputCompleter getCompleter() { + if (in instanceof KeyboardInputStream) { + return ((KeyboardInputStream) in).getCompleter(); } else { - return null; - } - } + return null; + } + } - public void setCompleter(InputCompleter completer) { - if (in instanceof KeyboardInputStream) { - ((KeyboardInputStream) in).setCompleter(completer); - } - } + public void setCompleter(InputCompleter completer) { + if (in instanceof KeyboardInputStream) { + ((KeyboardInputStream) in).setCompleter(completer); + } + } - /** - * @see org.jnode.driver.console.TextConsole#getIn() - */ - public InputStream getIn() { - return in; - } + /** + * @see org.jnode.driver.console.TextConsole#getIn() + */ + public InputStream getIn() { + return in; + } - void setIn(InputStream in) { - this.in = in; - } + void setIn(InputStream in) { + this.in = in; + } - /** - * @see org.jnode.driver.console.TextConsole#getErr() - */ - public PrintStream getErr() { - return err; - } + /** + * @see org.jnode.driver.console.TextConsole#getErr() + */ + public PrintStream getErr() { + return err; + } - /** - * @see org.jnode.driver.console.TextConsole#getOut() - */ - public PrintStream getOut() { - return out; - } + /** + * @see org.jnode.driver.console.TextConsole#getOut() + */ + public PrintStream getOut() { + return out; + } - /** - * Is the cursor visible. - */ - public boolean isCursorVisible() { - return cursorVisible; - } + /** + * Is the cursor visible. + */ + public boolean isCursorVisible() { + return cursorVisible; + } - /** - * Make the cursor visible or not visible. - * - * @param visible - */ - public void setCursorVisible(boolean visible) { - this.cursorVisible = visible; - screen.setCursorVisible(visible); - syncScreen(); - } + /** + * Make the cursor visible or not visible. + * + * @param visible + */ + public void setCursorVisible(boolean visible) { + this.cursorVisible = visible; + int offset = screen.setCursorVisible(visible); + syncScreen(offset, 1); + } - /** - * @see org.jnode.system.event.FocusListener#focusGained(org.jnode.system.event.FocusEvent) - */ - public void focusGained(FocusEvent event) { - super.focusGained(event); - syncScreen(); - if (in instanceof FocusListener) { - ((FocusListener) in).focusGained(event); - } - if (claimSystemOutErr && VmSystem.hasVmIOContext()) { + /** + * @see org.jnode.system.event.FocusListener#focusGained(org.jnode.system.event.FocusEvent) + */ + public void focusGained(FocusEvent event) { + super.focusGained(event); + syncScreen(0, screen.getWidth() * screen.getHeight()); + if (in instanceof FocusListener) { + ((FocusListener) in).focusGained(event); + } + if (claimSystemOutErr && VmSystem.hasVmIOContext()) { myIsolate.invokeAndWait(new Runnable() { public void run() { AccessController.doPrivileged(new PrivilegedAction<Object>() { @@ -387,31 +389,31 @@ }); } }); - } - } + } + } - /** - * @see org.jnode.system.event.FocusListener#focusLost(org.jnode.system.event.FocusEvent) - */ - public void focusLost(FocusEvent event) { - if (in instanceof FocusListener) { - ((FocusListener) in).focusLost(event); - } - if (claimSystemOutErr && VmSystem.hasVmIOContext()) { + /** + * @see org.jnode.system.event.FocusListener#focusLost(org.jnode.system.event.FocusEvent) + */ + public void focusLost(FocusEvent event) { + if (in instanceof FocusListener) { + ((FocusListener) in).focusLost(event); + } + if (claimSystemOutErr && VmSystem.hasVmIOContext()) { myIsolate.invokeAndWait(new Runnable() { public void run() { savedOut = System.out; savedErr = System.err; } }); - } - super.focusLost(event); - } + } + super.focusLost(event); + } - /** - * @return Returns the screen. - */ - protected final TextScreen getScreen() { - return this.screen; - } + /** + * @return Returns the screen. + */ + protected final TextScreen getScreen() { + return this.screen; + } } Modified: trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsoleManager.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsoleManager.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsoleManager.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,11 +18,13 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.console.textscreen; import java.io.InputStream; + import javax.naming.NameNotFoundException; + import org.jnode.driver.console.ConsoleException; import org.jnode.driver.console.spi.AbstractConsoleManager; import org.jnode.driver.textscreen.ScrollableTextScreen; @@ -36,22 +38,22 @@ public class TextScreenConsoleManager extends AbstractConsoleManager { private int SCROLLABLE_HEIGHT = 500; - + /** * Initialize this instance. * * @throws ConsoleException */ public TextScreenConsoleManager() - throws ConsoleException { + throws ConsoleException { } - - + + /** * @see org.jnode.driver.console.ConsoleManager#createConsole(String, int) */ public TextScreenConsole createConsole(String name, int options) { - if ((options & CreateOptions.TEXT) != 0) { + if ((options & CreateOptions.TEXT) != 0) { final TextScreenManager tsm; tsm = getTextScreenManager(); final TextScreenConsole console; @@ -67,12 +69,9 @@ screen = tsm.getSystemScreen().createCompatibleBufferScreen(); console = new TextScreenConsole(this, name, screen, options); } - InputStream in = System.in; - if ((options & CreateOptions.NO_LINE_EDITTING) == 0) { - in = new KeyboardInputStream(getKeyboardApi(), console); - } - console.setIn(in); - if ((options & CreateOptions.STACKED) != 0) { + InputStream in = getInputStream(options, console); + console.setIn(in); + if ((options & CreateOptions.STACKED) != 0){ stackConsole(console); } else { setAccelerator(console); @@ -84,7 +83,18 @@ throw new IllegalArgumentException("Unknown option " + options); } } - + + protected InputStream getInputStream(int options, TextScreenConsole console) + { + InputStream in = System.in; + if ((options & CreateOptions.NO_LINE_EDITTING) == 0) { + KeyboardHandler kbHandler = new DefaultKeyboardHandler(getKeyboardApi()); + in = new KeyboardInputStream(kbHandler, console); + } + + return in; + } + protected TextScreenManager getTextScreenManager() { TextScreenManager tsm; try { Modified: trunk/core/src/driver/org/jnode/driver/textscreen/TextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/TextScreen.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/textscreen/TextScreen.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,7 +18,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.textscreen; /** @@ -26,7 +26,7 @@ * (video memory) - buffered screen (system memory, faster that video memory) - * remote screen, shared screen, multiple screens ... - recording screen (movies * for demos or tutorials) - * + * * @author epr */ public interface TextScreen { @@ -44,7 +44,7 @@ /** * Set a series of of the same character with a given color at a given * offset. - * + * * @param offset * @param ch * @param color @@ -53,59 +53,61 @@ /** * Set an series of characters with a given color at a given offset. - * + * * @param offset * @param ch * @param color */ public abstract void set(int offset, char[] ch, int chOfs, int length, - int color); + int color); /** * Set an series of characters with a given series of colors at a given * offset. - * + * * @param offset * @param ch * @param colors * @param colorsOfs */ public abstract void set(int offset, char[] ch, int chOfs, int length, - int[] colors, int colorsOfs); + int[] colors, int colorsOfs); /** * Copy the content of the screen from a given source to a given - * destionation offset. - * + * destination offset. + * * @param srcOffset * @param destOffset * @param length */ public abstract void copyContent(int srcOffset, int destOffset, int length); - + /** * Copies the entire screen to the given destination. * For this operation to succeed, the screens involved must be * compatible. * * @param dst + * @param offset + * @param length */ - public abstract void copyTo(TextScreen dst); + public abstract void copyTo(TextScreen dst, int offset, int length); /** * Gets the height of the screen in letters. - * + * * @return Returns the height. */ public int getHeight(); /** * Gets the width of the screen in letters. - * + * * @return Returns the width. */ public int getWidth(); - + /** * Calculate the offset for a given x,y coordinate. * @@ -114,12 +116,14 @@ * @return */ public int getOffset(int x, int y); - + /** * Synchronize the state with the actual device. + * @param offset + * @param length */ - public void sync(); - + public void sync(int offset, int length); + /** * Create an in-memory buffer text screen that is compatible * with this screen. @@ -127,7 +131,7 @@ * @return */ public TextScreen createCompatibleBufferScreen(); - + /** * Create an in-memory buffer text screen that is compatible * with this, but larger and supports scrolling. @@ -135,15 +139,27 @@ * @return */ public ScrollableTextScreen createCompatibleScrollableBufferScreen(int height); - + /** * Ensure that the given row is visible. * * @param row + * @param sync true if screen should synchronize */ - public void ensureVisible(int row); + public void ensureVisible(int row, boolean sync); - void setCursor(int x, int y); + /** + * + * @param x + * @param y + * @return offset of the cursor + */ + public int setCursor( int x, int y ); - void setCursorVisible(boolean visible); + /** + * + * @param visible + * @return offset of the cursor + */ + int setCursorVisible( boolean visible ); } Modified: trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcBufferTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcBufferTextScreen.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcBufferTextScreen.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,7 +18,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.textscreen.x86; import org.jnode.driver.textscreen.TextScreen; @@ -28,7 +28,7 @@ * @author Ewout Prangsma (ep...@us...) * @author Fabien DUMINY (fduminy at jnode.org) */ -public abstract class AbstractPcBufferTextScreen extends AbstractPcTextScreen implements TextScreen { +public abstract class AbstractPcBufferTextScreen extends AbstractPcTextScreen { /** * Actual content buffer @@ -40,9 +40,9 @@ * Slower, but more likely to be correct than a temporary pointer to the last character * the cursor was over, as in previous versions. */ - private final char[] screenBuffer; - private int cursorIndex = 0; - private boolean cursorVisible = true; + private final char[]screenBuffer; + private int cursorIndex=0; + private boolean cursorVisible=true; /** * Initialize this instance. @@ -53,7 +53,7 @@ public AbstractPcBufferTextScreen(int width, int height) { super(width, height); this.buffer = new char[width * height]; - this.screenBuffer = new char[buffer.length]; + this.screenBuffer=new char[buffer.length]; } /** @@ -67,24 +67,24 @@ * @see org.jnode.driver.textscreen.TextScreen#getChar(int) */ public char getChar(int offset) { - return (char) (buffer[offset] & 0xFF); + return (char)(buffer[offset] & 0xFF); } /** * @see org.jnode.driver.textscreen.TextScreen#getColor(int) */ public int getColor(int offset) { - return (char) ((buffer[offset] >> 8) & 0xFF); + return (char)((buffer[offset] >> 8) & 0xFF); } /** * @see org.jnode.driver.textscreen.TextScreen#set(int, char, int, int) */ public void set(int offset, char ch, int count, int color) { - final char v = (char) ((ch & 0xFF) | ((color & 0xFF) << 8)); + final char v = (char)((ch & 0xFF) | ((color & 0xFF) << 8)); count = Math.min(count, buffer.length - offset); for (int i = 0; i < count; i++) { - buffer[offset + i] = v; + buffer[offset+i] = v; } } @@ -95,7 +95,7 @@ color = (color & 0xFF) << 8; length = Math.min(length, buffer.length - offset); for (int i = 0; i < length; i++) { - buffer[offset + i] = (char) ((ch[chOfs + i] & 0xFF) | color); + buffer[offset+i] = (char)((ch[chOfs+i] & 0xFF) | color); } } @@ -103,10 +103,10 @@ * @see org.jnode.driver.textscreen.TextScreen#set(int, char[], int, int, int[], int) */ public void set(int offset, char[] ch, int chOfs, int length, int[] colors, - int colorsOfs) { + int colorsOfs) { length = Math.min(length, buffer.length - offset); for (int i = 0; i < length; i++) { - buffer[offset + i] = (char) ((ch[chOfs + i] & 0xFF) | (colors[colorsOfs + i] & 0xFF) << 8); + buffer[offset+i] = (char)((ch[chOfs+i] & 0xFF) | (colors[colorsOfs+i] & 0xFF) << 8); } } @@ -117,26 +117,26 @@ * * @param dst */ - public void copyTo(TextScreen dst) { - if (dst instanceof AbstractPcTextScreen) { + public void copyTo( TextScreen dst, int offset, int length ) { + if( dst instanceof AbstractPcTextScreen ) { char[] toScreen = buffer; - if (cursorVisible && cursorIndex < buffer.length && cursorIndex >= 0) { - System.arraycopy(buffer, 0, screenBuffer, 0, buffer.length); + if( cursorVisible&&cursorIndex<buffer.length&&cursorIndex>=0 ) { + System.arraycopy( buffer, 0, screenBuffer, 0, buffer.length ); char origValue = buffer[cursorIndex]; //origValue |= 0x7000;//from december 2003 jnode code. //exchange the background with the foreground - int color = (origValue >> 8) & 0xFF; + int color = (origValue >>8) & 0xFF; color = ((color >> 4) & 0xF) | ((color << 4) & 0xF0); origValue &= 0x00FF; origValue |= (color << 8) & 0xFF00; - + screenBuffer[cursorIndex] = origValue; toScreen = screenBuffer; } - ((AbstractPcTextScreen) dst).copyFrom(toScreen, getTopOffset()); + ( (AbstractPcTextScreen)dst ).copyFrom( toScreen, getTopOffset() ); } else { - throw new IllegalArgumentException("Unknown destination type " + dst.getClass().getName()); + throw new IllegalArgumentException( "Unknown destination type " + dst.getClass().getName() ); } } @@ -165,16 +165,18 @@ /** * Synchronize the state with the actual device. */ - public abstract void sync(); + public abstract void sync(int offset, int length); - public void setCursor(int x, int y) { - this.cursorIndex = getOffset(x, y); + public int setCursor( int x, int y ) { + this.cursorIndex=getOffset( x,y); setParentCursor(x, y); + return cursorIndex; } + + protected abstract void setParentCursor( int x, int y ); - protected abstract void setParentCursor(int x, int y); - - public void setCursorVisible(boolean visible) { - this.cursorVisible = visible; + public int setCursorVisible(boolean visible) { + this.cursorVisible=visible; + return cursorIndex; } } Modified: trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcTextScreen.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcTextScreen.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,7 +18,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.textscreen.x86; import org.jnode.driver.textscreen.ScrollableTextScreen; @@ -42,25 +42,25 @@ this.width = width; this.height = height; } - + /** * Gets the height of the screen in letters. - * + * * @return Returns the height. */ public int getHeight() { - return height; + return height; } /** * Gets the width of the screen in letters. - * + * * @return Returns the width. */ public int getWidth() { return width; } - + /** * Calculate the offset for a given x,y coordinate. * @@ -86,7 +86,7 @@ public TextScreen createCompatibleBufferScreen() { return new PcBufferTextScreen(getWidth(), getHeight(), this); } - + /** * Create an in-memory buffer text screen that is compatible * with the system screen, but larges and supports scrolling. @@ -97,15 +97,15 @@ if (height < getHeight()) { throw new IllegalArgumentException("Invalid height " + height); } - return new PcScrollableTextScreen(getWidth(), height, this); + return new PcScrollableTextScreen(getWidth(), height, this); } - + /** * Ensure that the given row is visible. * * @param row */ - public void ensureVisible(int row) { + public void ensureVisible(int row, boolean sync) { // do nothing by default } } Modified: trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcBufferTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcBufferTextScreen.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcBufferTextScreen.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,7 +18,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.textscreen.x86; import org.jnode.driver.textscreen.TextScreen; @@ -26,7 +26,7 @@ /** * @author Ewout Prangsma (ep...@us...) */ -public class PcBufferTextScreen extends AbstractPcBufferTextScreen implements TextScreen { +public class PcBufferTextScreen extends AbstractPcBufferTextScreen { /** * My parent @@ -47,11 +47,11 @@ /** * Synchronize the state with the actual device. */ - public void sync() { - copyTo(parent); + public void sync(int offset, int length) { + copyTo(parent, offset, length); } - protected void setParentCursor(int x, int y) { + protected void setParentCursor( int x, int y ) { parent.setCursor(x, y); } Modified: trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcScrollableTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcScrollableTextScreen.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcScrollableTextScreen.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,7 +18,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.textscreen.x86; import org.jnode.driver.textscreen.ScrollableTextScreen; @@ -27,18 +27,18 @@ * @author Ewout Prangsma (ep...@us...) */ class PcScrollableTextScreen extends PcBufferTextScreen implements - ScrollableTextScreen { + ScrollableTextScreen { /** * Offset of top visible row */ private int ofsY; - + /** * Height of the parent screen */ private final int parentHeight; - + /** * Maximum row that has valid data */ @@ -54,9 +54,9 @@ } /** - * @see org.jnode.driver.textscreen.ScrollableTextScreen#ensureVisible(int) + * @see org.jnode.driver.textscreen.ScrollableTextScreen#ensureVisible(int, boolean) */ - public void ensureVisible(int row) { + public void ensureVisible(int row, boolean sync) { if (row < ofsY) { ofsY = row; } else if (row >= ofsY + parentHeight) { @@ -91,13 +91,13 @@ /** * Return the offset in the buffer of the first visible row. - * + * * @return */ protected int getTopOffset() { return ofsY * getWidth(); - } - + } + /** * @see org.jnode.driver.textscreen.TextScreen#set(int, char, int, int) */ @@ -105,21 +105,19 @@ maxValidY = Math.max(maxValidY, offset / getWidth()); super.set(offset, ch, count, color); } - /** * @see org.jnode.driver.textscreen.TextScreen#set(int, char[], int, int, int) */ public void set(int offset, char[] ch, int chOfs, int length, int color) { - maxValidY = Math.max(maxValidY, (offset + length - 1) / getWidth()); + maxValidY = Math.max(maxValidY, (offset + length-1) / getWidth()); super.set(offset, ch, chOfs, length, color); } - /** * @see org.jnode.driver.textscreen.TextScreen#set(int, char[], int, int, int[], int) */ public void set(int offset, char[] ch, int chOfs, int length, int[] colors, - int colorsOfs) { - maxValidY = Math.max(maxValidY, (offset + length - 1) / getWidth()); + int colorsOfs) { + maxValidY = Math.max(maxValidY, (offset + length-1) / getWidth()); super.set(offset, ch, chOfs, length, colors, colorsOfs); } } Modified: trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreen.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreen.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,10 +18,11 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.textscreen.x86; import javax.naming.NameNotFoundException; + import org.jnode.driver.textscreen.TextScreen; import org.jnode.naming.InitialNaming; import org.jnode.system.BootLog; @@ -36,7 +37,7 @@ /** * @author Ewout Prangsma (ep...@us...) */ -public class PcTextScreen extends AbstractPcTextScreen implements TextScreen { +public class PcTextScreen extends AbstractPcTextScreen { /** * The MemoryResource we use to store (and display) characters. @@ -57,10 +58,10 @@ Address ptr = Address.fromIntZeroExtend(0xb8000); try { final ResourceManager rm = (ResourceManager) InitialNaming - .lookup(ResourceManager.NAME); + .lookup(ResourceManager.NAME); final ResourceOwner owner = new SimpleResourceOwner("Screen"); memory = rm.claimMemoryResource(owner, ptr, getWidth() - * getHeight() * 2, ResourceManager.MEMMODE_NORMAL); + * getHeight() * 2, ResourceManager.MEMMODE_NORMAL); } catch (NameNotFoundException ex) { throw new ResourceNotFreeException("ResourceManager not found", ex); } @@ -68,7 +69,7 @@ /** * Get the singleton instance and create it if necessary. - * + * * @return @throws * PragmaUninterruptible */ @@ -132,17 +133,17 @@ * int[], int) */ public void set(int offset, char[] ch, int chOfs, int length, int[] colors, - int colorsOfs) { + int colorsOfs) { for (int i = 0; i < length; i++) { final int v = (ch[chOfs + i] & 0xFF) - | ((colors[colorsOfs + i] & 0xFF) << 8); + | ((colors[colorsOfs + i] & 0xFF) << 8); memory.setChar((offset + i) * 2, (char) v); } } /** * Copy the content of the given rawData into this screen. - * + * * @param rawData * @param rawDataOffset */ @@ -156,25 +157,26 @@ /** * Copies the entire screen to the given destination. For this operation to * succeed, the screens involved must be compatible. - * + * * @param dst */ - public void copyTo(TextScreen dst) { + public void copyTo(TextScreen dst, int offset, int length) { throw new UnsupportedOperationException(); } /** * Synchronize the state with the actual device. */ - public void sync() { + public void sync(int offset, int length) { // Nothing to do here } - public void setCursor(int x, int y) { + public int setCursor( int x, int y ) { //instance.setCursor( x,y); + return 0; // TODO what should we return if we don't call instance.setCursor ? } - public void setCursorVisible(boolean visible) { - instance.setCursorVisible(visible); + public int setCursorVisible( boolean visible ) { + return instance.setCursorVisible( visible ); } } Modified: trunk/distr/src/apps/org/jnode/apps/telnetd/JNodeCommandShell.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/telnetd/JNodeCommandShell.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/distr/src/apps/org/jnode/apps/telnetd/JNodeCommandShell.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -1,29 +1,33 @@ package org.jnode.apps.telnetd; -import java.io.InputStream; -import java.io.PrintStream; - import org.jnode.driver.console.TextConsole; import org.jnode.shell.CommandShell; import org.jnode.shell.ShellException; /** -* -* @author Fabien DUMINY (fduminy at jnode.org) -* -*/ + * + * @author Fabien DUMINY (fduminy at jnode.org) + * + */ public class JNodeCommandShell extends CommandShell { - private final JNodeShell shell; + private final JNodeShell shell; - public JNodeCommandShell(JNodeShell shell, TextConsole console, InputStream in, PrintStream out, PrintStream err) - throws ShellException { - super(console, in, out, err); - this.shell = shell; - } + // public JNodeCommandShell(JNodeShell shell, TextConsole console, + // InputStream in, PrintStream out, PrintStream err) + // throws ShellException { + // super(console, in, out, err); + // this.shell = shell; + // } - @Override - public void exit(){ - shell.close(); - super.exit(); - } + public JNodeCommandShell(TextConsole cons, JNodeShell shell) throws ShellException { + super(cons); + this.shell = shell; + System.err.println("JNodeCommandShell"); + } + + @Override + public void exit() { + shell.close(); + super.exit(); + } } Modified: trunk/distr/src/apps/org/jnode/apps/telnetd/JNodeShell.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/telnetd/JNodeShell.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/distr/src/apps/org/jnode/apps/telnetd/JNodeShell.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -1,8 +1,5 @@ package org.jnode.apps.telnetd; -import java.io.InputStream; -import java.io.PrintStream; - import net.wimpi.telnetd.io.TerminalIO; import net.wimpi.telnetd.net.Connection; import net.wimpi.telnetd.net.ConnectionEvent; @@ -11,340 +8,278 @@ import org.apache.log4j.Logger; import org.jnode.driver.console.ConsoleException; import org.jnode.driver.console.ConsoleManager; -import org.jnode.driver.console.TextConsole; import org.jnode.driver.console.textscreen.ScrollableTextScreenConsole; -import org.jnode.driver.textscreen.ScrollableTextScreen; import org.jnode.shell.CommandShell; /** - * + * * @author Fabien DUMINY (fduminy at jnode.org) - * + * */ public class JNodeShell implements Shell { - private static final RemoteConsoleManager CONSOLE_MANAGER; + private static final RemoteConsoleManager CONSOLE_MANAGER; - static - { - try { - CONSOLE_MANAGER = new RemoteConsoleManager(); - } catch (ConsoleException e) { - throw new RuntimeException("can't create RemoteConsoleManager", e); - } - } + static { + try { + CONSOLE_MANAGER = new RemoteConsoleManager(); + } catch (ConsoleException e) { + throw new RuntimeException("can't create RemoteConsoleManager", e); + } + } - private static final Logger log = Logger.getLogger(JNodeShell.class); + private static final Logger log = Logger.getLogger(JNodeShell.class); - private CommandShell commandShell; - private Connection connection; - private TerminalIO terminalIO; - private ScrollableTextScreenConsole console; + private CommandShell commandShell; + private Connection connection; + private TerminalIO terminalIO; + private ScrollableTextScreenConsole console; -// private Editfield m_EF; + // private Editfield m_EF; - /** - * Method that runs a shell - * - * @param con Connection that runs the shell. - */ - public void run(Connection con) { - try { - connection = con; - //mycon.setNextShell("nothing"); - terminalIO = (TerminalIO) connection.getTerminalIO(); + /** + * Method that runs a shell + * + * @param con Connection that runs the shell. + */ + public void run(Connection con) { + try { + connection = con; + // mycon.setNextShell("nothing"); + terminalIO = (TerminalIO) connection.getTerminalIO(); - //dont forget to register listener - connection.addConnectionListener(this); + // dont forget to register listener + connection.addConnectionListener(this); - //clear the screen and start from zero - terminalIO.eraseScreen(); - terminalIO.homeCursor(); + // clear the screen and start from zero + terminalIO.eraseScreen(); + terminalIO.homeCursor(); - //We just read any key - terminalIO.write("Welcome to JNode telnet server. Thanks for connecting.\r\n" + - "You can type any jnode command and press enter **2 times**(it's a bug!!!) to execute it.\r\n" + - "Use the exit command to logout!\r\n"); // some output - terminalIO.flush(); + // We just read any key + terminalIO + .write("Welcome to JNode telnet server. Thanks for connecting.\r\n" + + "You can type any jnode command and " + + "press enter **2 times**(it's a bug!!!) to execute it.\r\n" + + "Use the exit command to logout!\r\n"); // some + // output + terminalIO.flush(); - final String name = connection.getConnectionData().getHostName(); -// synchronized (CONSOLE_MANAGER) { -// CONSOLE_MANAGER.setTerminalIO(terminalIO); -// console = (ScrollableTextScreenConsole) CONSOLE_MANAGER.createConsole(name, ConsoleManager.CreateOptions.TEXT -// | ConsoleManager.CreateOptions.SCROLLABLE); -// } + final String name = connection.getConnectionData().getHostName(); + synchronized (CONSOLE_MANAGER) { + CONSOLE_MANAGER.setTerminalIO(terminalIO); + console = + (ScrollableTextScreenConsole) CONSOLE_MANAGER.createConsole(name, + ConsoleManager.CreateOptions.TEXT | + ConsoleManager.CreateOptions.SCROLLABLE); + } + CONSOLE_MANAGER.focus(console); - final RemoteTextScreen screen = new RemoteTextScreen(terminalIO); - final ScrollableTextScreen scrollScreen = screen.createCompatibleScrollableBufferScreen(terminalIO.getRows()*10); - console = new ScrollableTextScreenConsole(CONSOLE_MANAGER, name, - scrollScreen, ConsoleManager.CreateOptions.TEXT - | ConsoleManager.CreateOptions.SCROLLABLE); - CONSOLE_MANAGER.registerConsole(console); + // final RemoteTextScreen screen = new RemoteTextScreen(terminalIO); + // final ScrollableTextScreen scrollScreen = + // screen.createCompatibleScrollableBufferScreen(terminalIO.getRows()*10); + // console = new ScrollableTextScreenConsole(CONSOLE_MANAGER, name, + // scrollScreen, ConsoleManager.Create... [truncated message content] |
From: <fd...@us...> - 2008-06-22 08:16:35
|
Revision: 4277 http://jnode.svn.sourceforge.net/jnode/?rev=4277&view=rev Author: fduminy Date: 2008-06-21 10:57:00 -0700 (Sat, 21 Jun 2008) Log Message: ----------- added config for checkstyle eclipse plugin Modified Paths: -------------- trunk/fs/.project trunk/gui/.project trunk/net/.project trunk/shell/.project Added Paths: ----------- trunk/fs/.checkstyle trunk/gui/.checkstyle trunk/net/.checkstyle trunk/shell/.checkstyle Added: trunk/fs/.checkstyle =================================================================== --- trunk/fs/.checkstyle (rev 0) +++ trunk/fs/.checkstyle 2008-06-21 17:57:00 UTC (rev 4277) @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<fileset-config file-format-version="1.2.0" simple-config="true"> + <local-check-config name="JNode checkstyle" location="/JNode-All/jnode_checks.xml" type="project" description=""> + <additional-data name="protect-config-file" value="true"/> + </local-check-config> + <fileset name="tous" enabled="true" check-config-name="JNode checkstyle" local="true"> + <file-match-pattern match-pattern="." include-pattern="true"/> + </fileset> + <filter name="NonSrcDirs" enabled="true"/> +</fileset-config> Modified: trunk/fs/.project =================================================================== --- trunk/fs/.project 2008-06-21 17:56:05 UTC (rev 4276) +++ trunk/fs/.project 2008-06-21 17:57:00 UTC (rev 4277) @@ -12,8 +12,14 @@ <arguments> </arguments> </buildCommand> + <buildCommand> + <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name> + <arguments> + </arguments> + </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> + <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature> </natures> </projectDescription> Added: trunk/gui/.checkstyle =================================================================== --- trunk/gui/.checkstyle (rev 0) +++ trunk/gui/.checkstyle 2008-06-21 17:57:00 UTC (rev 4277) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<fileset-config file-format-version="1.2.0" simple-config="true"> + <local-check-config name="JNode checkstyle" location="/JNode-All/jnode_checks.xml" type="project" description=""> + <additional-data name="protect-config-file" value="true"/> + </local-check-config> + <fileset name="tous" enabled="true" check-config-name="JNode checkstyle" local="true"> + <file-match-pattern match-pattern="." include-pattern="true"/> + </fileset> + <filter name="FilesFromPackage" enabled="true"> + <filter-data value="src/font"/> + <filter-data value="src/thinlet"/> + </filter> + <filter name="NonSrcDirs" enabled="true"/> +</fileset-config> Modified: trunk/gui/.project =================================================================== --- trunk/gui/.project 2008-06-21 17:56:05 UTC (rev 4276) +++ trunk/gui/.project 2008-06-21 17:57:00 UTC (rev 4277) @@ -12,8 +12,14 @@ <arguments> </arguments> </buildCommand> + <buildCommand> + <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name> + <arguments> + </arguments> + </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> + <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature> </natures> </projectDescription> Added: trunk/net/.checkstyle =================================================================== --- trunk/net/.checkstyle (rev 0) +++ trunk/net/.checkstyle 2008-06-21 17:57:00 UTC (rev 4277) @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<fileset-config file-format-version="1.2.0" simple-config="true"> + <local-check-config name="JNode checkstyle" location="/JNode-All/jnode_checks.xml" type="project" description=""> + <additional-data name="protect-config-file" value="true"/> + </local-check-config> + <fileset name="tous" enabled="true" check-config-name="JNode checkstyle" local="true"> + <file-match-pattern match-pattern="." include-pattern="true"/> + </fileset> + <filter name="NonSrcDirs" enabled="true"/> +</fileset-config> Modified: trunk/net/.project =================================================================== --- trunk/net/.project 2008-06-21 17:56:05 UTC (rev 4276) +++ trunk/net/.project 2008-06-21 17:57:00 UTC (rev 4277) @@ -12,8 +12,14 @@ <arguments> </arguments> </buildCommand> + <buildCommand> + <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name> + <arguments> + </arguments> + </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> + <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature> </natures> </projectDescription> Added: trunk/shell/.checkstyle =================================================================== --- trunk/shell/.checkstyle (rev 0) +++ trunk/shell/.checkstyle 2008-06-21 17:57:00 UTC (rev 4277) @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<fileset-config file-format-version="1.2.0" simple-config="true"> + <local-check-config name="JNode checkstyle" location="/JNode-All/jnode_checks.xml" type="project" description=""> + <additional-data name="protect-config-file" value="true"/> + </local-check-config> + <fileset name="tous" enabled="true" check-config-name="JNode checkstyle" local="true"> + <file-match-pattern match-pattern="." include-pattern="true"/> + </fileset> + <filter name="NonSrcDirs" enabled="true"/> +</fileset-config> Modified: trunk/shell/.project =================================================================== --- trunk/shell/.project 2008-06-21 17:56:05 UTC (rev 4276) +++ trunk/shell/.project 2008-06-21 17:57:00 UTC (rev 4277) @@ -11,8 +11,14 @@ <arguments> </arguments> </buildCommand> + <buildCommand> + <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name> + <arguments> + </arguments> + </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> + <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature> </natures> </projectDescription> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-06-27 19:27:51
|
Revision: 4280 http://jnode.svn.sourceforge.net/jnode/?rev=4280&view=rev Author: lsantha Date: 2008-06-27 12:27:49 -0700 (Fri, 27 Jun 2008) Log Message: ----------- Improved annotation support including annotation defaults. Modified Paths: -------------- trunk/builder/src/builder/org/jnode/build/ObjectEmitter.java trunk/core/descriptors/org.classpath.core.xml trunk/core/src/classpath/vm/java/lang/Class.java trunk/core/src/classpath/vm/java/lang/reflect/Method.java trunk/core/src/core/org/jnode/vm/VmSystem.java trunk/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java trunk/core/src/core/org/jnode/vm/classmgr/VmAnnotation.java trunk/core/src/core/org/jnode/vm/classmgr/VmMethod.java trunk/core/src/openjdk/vm/java/lang/reflect/NativeProxy.java Added Paths: ----------- trunk/core/src/core/org/jnode/vm/classmgr/VmConstantPool.java Modified: trunk/builder/src/builder/org/jnode/build/ObjectEmitter.java =================================================================== --- trunk/builder/src/builder/org/jnode/build/ObjectEmitter.java 2008-06-26 20:11:32 UTC (rev 4279) +++ trunk/builder/src/builder/org/jnode/build/ObjectEmitter.java 2008-06-27 19:27:49 UTC (rev 4280) @@ -243,6 +243,8 @@ bis.writeObjectRef(null); // enumConstantsDirectory bis.writeObjectRef(null); + // annotationType + bis.writeObjectRef(null); } } catch (ClassNotFoundException ex) { throw new BuildException("emitting object: [" + c + "]", ex); Modified: trunk/core/descriptors/org.classpath.core.xml =================================================================== --- trunk/core/descriptors/org.classpath.core.xml 2008-06-26 20:11:32 UTC (rev 4279) +++ trunk/core/descriptors/org.classpath.core.xml 2008-06-27 19:27:49 UTC (rev 4280) @@ -11,6 +11,8 @@ <runtime> <library name="jnode-core.jar"> + <export name="com.sun.beans.*"/> + <export name="com.sun.beans.finder.*"/> <export name="com.sun.java.util.jar.pack.*"/> <export name="com.sun.naming.internal.*"/> <export name="com.sun.security.auth.UserPrincipal"/> @@ -20,6 +22,15 @@ <export name="sun.misc.*"/> <export name="sun.reflect.*"/> <export name="sun.reflect.annotation.*"/> + <export name="sun.reflect.generics.*"/> + <export name="sun.reflect.generics.factory.*"/> + <export name="sun.reflect.generics.parser.*"/> + <export name="sun.reflect.generics.reflectiveObjects.*"/> + <export name="sun.reflect.generics.repository.*"/> + <export name="sun.reflect.generics.scope.*"/> + <export name="sun.reflect.generics.tree.*"/> + <export name="sun.reflect.generics.visitor.*"/> + <export name="sun.reflect.misc.*"/> <export name="sun.net.InetAddressCachePolicy"/> <export name="sun.net.util.IPAddressUtil"/> <export name="sun.net.www.ParseUtil"/> Modified: trunk/core/src/classpath/vm/java/lang/Class.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/Class.java 2008-06-26 20:11:32 UTC (rev 4279) +++ trunk/core/src/classpath/vm/java/lang/Class.java 2008-06-27 19:27:49 UTC (rev 4280) @@ -73,6 +73,7 @@ import org.jnode.vm.classmgr.VmMethod; import org.jnode.vm.classmgr.VmType; import org.jnode.vm.classmgr.VmClassLoader; +import sun.reflect.annotation.AnnotationType; /** * A Class represents a Java type. There will never be multiple Class @@ -161,8 +162,8 @@ } public static Class forName(String className, boolean initialize, - ClassLoader loader) throws ClassNotFoundException { - return VmSystem.forName(className); + ClassLoader loader) throws ClassNotFoundException { + return (loader == null) ? VmSystem.forName(className) : loader.loadClass(className, initialize); } /** @@ -1295,30 +1296,29 @@ */ public boolean isAnnotation() { - //todo implement it - throw new UnsupportedOperationException(); + return vmClass.isAnnotation(); } public String getCanonicalName() { - //todo implement it - throw new UnsupportedOperationException(); - /* - if (vmClass.isArray()) - { - String componentName = vmClass.getComponentType().getCanonicalName(); - if (componentName != null) - return componentName + "[]"; + if (isArray()) { + String canonicalName = getComponentType().getCanonicalName(); + if (canonicalName != null) + return canonicalName + "[]"; + else + return null; } - if (vmClass.isMemberClass(klass)) - { - String memberName = getDeclaringClass(klass).getCanonicalName(); - if (memberName != null) - return memberName + "." + getSimpleName(klass); + if (isLocalOrAnonymousClass()) + return null; + Class<?> enclosingClass = getEnclosingClass(); + if (enclosingClass == null) { // top level class + return getName(); + } else { + String enclosingName = enclosingClass.getCanonicalName(); + if (enclosingName == null) + return null; + return enclosingName + "." + getSimpleName(); } - if (isLocalClass(klass) || vmClass.isAnonymousClass(klass)) - return null; - return getName(klass); - */ + } /** @@ -1420,7 +1420,8 @@ * identical to getEnumConstantsShared except that * the result is uncloned, cached, and shared by all callers. */ - T[] getEnumConstantsShared() { + //todo make it package private + public T[] getEnumConstantsShared() { if (enumConstants == null) { if (!isEnum()) return null; try { @@ -1602,4 +1603,17 @@ public boolean isSynthetic() { return vmClass.isSynthetic(); } + + // Annotation types cache their internal (AnnotationType) form + private AnnotationType annotationType; + + //todo change this to package private + public void setAnnotationType(AnnotationType type) { + annotationType = type; + } + + //todo change this to package private + public AnnotationType getAnnotationType() { + return annotationType; + } } Modified: trunk/core/src/classpath/vm/java/lang/reflect/Method.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/reflect/Method.java 2008-06-26 20:11:32 UTC (rev 4279) +++ trunk/core/src/classpath/vm/java/lang/reflect/Method.java 2008-06-27 19:27:49 UTC (rev 4280) @@ -40,6 +40,7 @@ import gnu.java.lang.ClassHelper; import java.lang.annotation.Annotation; +import java.lang.annotation.AnnotationFormatError; import java.util.ArrayList; import org.jnode.vm.VmReflection; @@ -48,7 +49,12 @@ import gnu.java.lang.reflect.MethodSignatureParser; import java.util.Arrays; +import java.util.Map; +import java.nio.ByteBuffer; import sun.reflect.MethodAccessor; +import sun.reflect.annotation.AnnotationParser; +import sun.reflect.annotation.AnnotationType; +import sun.misc.SharedSecrets; /** * The Method class represents a member method of a class. It also allows @@ -95,14 +101,17 @@ | Modifier.STATIC | Modifier.STRICT | Modifier.SYNCHRONIZED; /** - * This class is uninstantiable. + * */ public Method(VmMethod vmMethod) { this.vmMethod = vmMethod; + this.annotationDefault = vmMethod.getRawAnnotationDefault(); + this.annotations = vmMethod.getRawAnnotations(); + this.parameterAnnotations = vmMethod.getRawParameterAnnotations(); } public Method(Class declaringClass, String name, Class[] parameterTypes, Class returnType, Class[] checkedExceptions, int modifiers, int slot, String signature, byte[] annotations, byte[] parameterAnnotations, byte[] annotationDefault) { - //todo implement it + throw new UnsupportedOperationException(); } @@ -471,32 +480,90 @@ * @see java.lang.reflect.AnnotatedElement#getAnnotation(java.lang.Class) */ public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { - return vmMethod.getAnnotation(annotationClass); + if(annotationClass.getName().equals(org.jnode.vm.annotation.AllowedPackages.class.getName())) { + return vmMethod.getAnnotation(annotationClass); + } else { + return _getAnnotation(annotationClass); + } } + //jnode openjdk + public MethodAccessor getMethodAccessor() { + //todo implement it + throw new UnsupportedOperationException(); + } + public void setMethodAccessor(MethodAccessor accessor) { + //todo implement it + throw new UnsupportedOperationException(); + } + + public Method copy() { + //todo implement it + throw new UnsupportedOperationException(); + } + + private transient Map<Class, Annotation> declaredAnnotations; + private byte[] annotations; + private byte[] parameterAnnotations; + private byte[] annotationDefault; + + private synchronized Map<Class, Annotation> declaredAnnotations() { + + if (declaredAnnotations == null) { + declaredAnnotations = AnnotationParser.parseAnnotations(annotations, + SharedSecrets.getJavaLangAccess().getConstantPool(getDeclaringClass()), getDeclaringClass()); + } + + return declaredAnnotations; + } + /** - * @see java.lang.reflect.AnnotatedElement#getAnnotations() + * If this method is an annotation method, returns the default + * value for the method. If there is no default value, or if the + * method is not a member of an annotation type, returns null. + * Primitive types are wrapped. + * + * @throws TypeNotPresentException if the method returns a Class, + * and the class cannot be found + * + * @since 1.5 */ - public Annotation[] getAnnotations() { - return vmMethod.getAnnotations(); + public Object getDefaultValue() { + if (annotationDefault == null) + return null; + + Class memberType = AnnotationType.invocationHandlerReturnType(getReturnType()); + + Object result = AnnotationParser.parseMemberValue(memberType, ByteBuffer.wrap(annotationDefault), + SharedSecrets.getJavaLangAccess().getConstantPool(getDeclaringClass()), getDeclaringClass()); + + if (result instanceof sun.reflect.annotation.ExceptionProxy) + throw new AnnotationFormatError("Invalid default: " + this); + + return result; } /** - * @see java.lang.reflect.AnnotatedElement#getDeclaredAnnotations() + * @throws NullPointerException {@inheritDoc} + * @since 1.5 */ - public Annotation[] getDeclaredAnnotations() { - return vmMethod.getDeclaredAnnotations(); + public <T extends Annotation> T _getAnnotation(Class<T> annotationClass) { + if (annotationClass == null) + throw new NullPointerException(); + + return (T) declaredAnnotations().get(annotationClass); } /** - * @see java.lang.reflect.AnnotatedElement#isAnnotationPresent(java.lang.Class) + * @since 1.5 */ - public boolean isAnnotationPresent(Class< ? extends Annotation> annotationClass) { - return vmMethod.isAnnotationPresent(annotationClass); + public Annotation[] getDeclaredAnnotations() { + return declaredAnnotations().values().toArray(EMPTY_ANNOTATION_ARRAY); } - //jnode openjdk + private static final Annotation[] EMPTY_ANNOTATION_ARRAY=new Annotation[0]; + /** * Returns an array of arrays that represent the annotations on the formal * parameters, in declaration order, of the method represented by @@ -514,37 +581,19 @@ * @since 1.5 */ public Annotation[][] getParameterAnnotations() { - return new Annotation[vmMethod.getNoArguments()][]; - } - /** - * If this method is an annotation method, returns the default - * value for the method. If there is no default value, or if the - * method is not a member of an annotation type, returns null. - * Primitive types are wrapped. - * - * @throws TypeNotPresentException if the method returns a Class, - * and the class cannot be found - * - * @since 1.5 - */ - public Object getDefaultValue(){ - //todo implement it - return null; - } + int numParameters = vmMethod.getNoArguments(); - public MethodAccessor getMethodAccessor() { - //todo implement it - throw new UnsupportedOperationException(); - } + if (parameterAnnotations == null) + return new Annotation[numParameters][0]; - public void setMethodAccessor(MethodAccessor accessor) { - //todo implement it - throw new UnsupportedOperationException(); + Annotation[][] result = AnnotationParser.parseParameterAnnotations(parameterAnnotations, + SharedSecrets.getJavaLangAccess().getConstantPool(getDeclaringClass()), getDeclaringClass()); + + if (result.length != numParameters) + throw new AnnotationFormatError("Parameter annotations don't match number of parameters"); + + return result; } - public Method copy() { - //todo implement it - throw new UnsupportedOperationException(); - } } Modified: trunk/core/src/core/org/jnode/vm/VmSystem.java =================================================================== --- trunk/core/src/core/org/jnode/vm/VmSystem.java 2008-06-26 20:11:32 UTC (rev 4279) +++ trunk/core/src/core/org/jnode/vm/VmSystem.java 2008-06-27 19:27:49 UTC (rev 4280) @@ -57,6 +57,7 @@ import org.jnode.vm.classmgr.VmMethod; import org.jnode.vm.classmgr.VmStaticField; import org.jnode.vm.classmgr.VmType; +import org.jnode.vm.classmgr.VmConstantPool; import org.jnode.vm.isolate.VmIsolate; import org.jnode.vm.memmgr.VmWriteBarrier; import org.jnode.vm.scheduler.VmProcessor; @@ -123,8 +124,7 @@ VmSystem.out = getSystemOut(); /* Initialize the system classloader */ - VmSystemClassLoader loader = (VmSystemClassLoader) (getVmClass(VmProcessor - .current()).getLoader()); + VmSystemClassLoader loader = (VmSystemClassLoader) (getVmClass(VmProcessor.current()).getLoader()); systemLoader = loader; loader.initialize(); @@ -166,8 +166,7 @@ // Initialize log4j final Logger root = Logger.getRootLogger(); - final ConsoleAppender infoApp = new ConsoleAppender( - new PatternLayout(LAYOUT)); + final ConsoleAppender infoApp = new ConsoleAppender(new PatternLayout(LAYOUT)); root.addAppender(infoApp); initOpenJDKSpeciffics(); @@ -178,24 +177,19 @@ //todo this will be moved to java.lang.System during openjdk integration sun.misc.SharedSecrets.setJavaLangAccess(new sun.misc.JavaLangAccess() { public sun.reflect.ConstantPool getConstantPool(Class klass) { - //return klass.getConstantPool(); - throw new UnsupportedOperationException(); + return new VmConstantPool(klass.getVmClass()); } public void setAnnotationType(Class klass, AnnotationType type) { - //klass.setAnnotationType(type); - throw new UnsupportedOperationException(); + klass.setAnnotationType(type); } public AnnotationType getAnnotationType(Class klass) { - //return klass.getAnnotationType(); - throw new UnsupportedOperationException(); + return klass.getAnnotationType(); } - public <E extends Enum<E>> - E[] getEnumConstantsShared(Class<E> klass) { - //return klass.getEnumConstantsShared(); - return klass.getEnumConstants(); + public <E extends Enum<E>> E[] getEnumConstantsShared(Class<E> klass) { + return klass.getEnumConstantsShared(); } public void blockedOn(Thread t, Interruptible b) { @@ -233,7 +227,7 @@ /** * Load the initial jarfile. * - * @param rm + * @param rm the resource manager * @return The initial jarfile resource, or null if no initial jarfile is * available. */ @@ -265,7 +259,7 @@ /** * This method adds some default system properties * - * @param res + * @param res the system properties object */ public static void insertSystemProperties(Properties res) { Modified: trunk/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java 2008-06-26 20:11:32 UTC (rev 4279) +++ trunk/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java 2008-06-27 19:27:49 UTC (rev 4280) @@ -26,6 +26,7 @@ import java.nio.ByteBuffer; import java.security.ProtectionDomain; import org.jnode.system.BootLog; +import org.jnode.vm.JvmType; import org.jnode.vm.VmUtils; import org.jnode.vm.annotation.AllowedPackages; import org.jnode.vm.annotation.CheckPermission; @@ -43,6 +44,8 @@ import org.jnode.vm.annotation.Uninterruptible; import org.vmmagic.pragma.PragmaException; import org.vmmagic.pragma.UninterruptiblePragma; +import sun.reflect.annotation.AnnotationParser; +import sun.reflect.annotation.ExceptionProxy; /** * Decoder of .class files into VmType instances. @@ -77,6 +80,8 @@ private static char[] RuntimeInvisibleParameterAnnotationsAttrName; + private static char[] AnnotationDefaultAttrName; + @SuppressWarnings("deprecation") private static final MethodPragmaException[] METHOD_PRAGMA_EXCEPTIONS = new MethodPragmaException[]{ new MethodPragmaException(UninterruptiblePragma.class, @@ -208,6 +213,7 @@ .toCharArray(); RuntimeInvisibleParameterAnnotationsAttrName = "RuntimeInvisibleParameterAnnotations" .toCharArray(); + AnnotationDefaultAttrName = "AnnotationDefault".toCharArray(); } } @@ -404,7 +410,7 @@ cls.addPragmaFlags(readInterfaces(data, cls, cp)); // Field table - final FieldData[] fieldData = readFields(data, cp, slotSize); + final FieldData[] fieldData = readFields(data, cp, slotSize, clc); // Method Table readMethods(data, rejectNatives, cls, cp, sharedStatics, clc); @@ -419,10 +425,10 @@ final String attrName = cp.getUTF8(data.getChar()); final int length = data.getInt(); if (VmArray.equals(RuntimeVisibleAnnotationsAttrName, attrName)) { - rVisAnn = readRuntimeAnnotations(data, cp, true); + rVisAnn = readRuntimeAnnotations(data, cp, true, clc); } else if (VmArray.equals(RuntimeInvisibleAnnotationsAttrName, attrName)) { - rInvisAnn = readRuntimeAnnotations(data, cp, false); + rInvisAnn = readRuntimeAnnotations(data, cp, false, clc); } else if (VmArray.equals(SourceFileAttrName, attrName)) { sourceFile = cp.getUTF8(data.getChar()); } else if (VmArray.equals(SignatureAttrName, attrName)) { @@ -621,7 +627,7 @@ * @param pragmaFlags */ private static FieldData[] readFields(ByteBuffer data, VmCP cp, - int slotSize) { + int slotSize, VmClassLoader loader) { final int fcount = data.getChar(); if (fcount > 0) { final FieldData[] ftable = new FieldData[fcount]; @@ -644,10 +650,10 @@ constantValue = cp.getAny(data.getChar()); } else if (VmArray.equals( RuntimeVisibleAnnotationsAttrName, attrName)) { - rVisAnn = readRuntimeAnnotations(data, cp, true); + rVisAnn = readRuntimeAnnotations(data, cp, true, loader); } else if (VmArray.equals( RuntimeInvisibleAnnotationsAttrName, attrName)) { - readRuntimeAnnotations(data, cp, false); + readRuntimeAnnotations(data, cp, false, loader); } else { skip(data, length); } @@ -947,18 +953,78 @@ mts.setExceptions(readExceptions(data, cls, cp)); } else if (VmArray.equals( RuntimeVisibleAnnotationsAttrName, attrName)) { - rVisAnn = readRuntimeAnnotations(data, cp, true); + + byte[] buf = new byte[length]; + data.slice().get(buf); + mts.setRawAnnotations(buf); + + //todo will get obsolate with openjdk based annotation support + //rVisAnn = readRuntimeAnnotations(data, cp, true, cl); + rVisAnn = readRuntimeAnnotations2(data, cp, true, cl, cls); + } else if (VmArray.equals( RuntimeInvisibleAnnotationsAttrName, attrName)) { - rInvisAnn = readRuntimeAnnotations(data, cp, false); + rInvisAnn = readRuntimeAnnotations(data, cp, false, cl); } else if (VmArray.equals( RuntimeVisibleParameterAnnotationsAttrName, attrName)) { - readRuntimeParameterAnnotations(data, cp, true); + + byte[] buf = new byte[length]; + data.slice().get(buf); + mts.setRawParameterAnnotations(buf); + //todo will get obsolate with openjdk based annotation support + readRuntimeParameterAnnotations(data, cp, true, cl); } else if (VmArray.equals( RuntimeInvisibleParameterAnnotationsAttrName, attrName)) { - readRuntimeParameterAnnotations(data, cp, false); + readRuntimeParameterAnnotations(data, cp, false, cl); + } else if (VmArray.equals(AnnotationDefaultAttrName, attrName)) { + //todo will get obsolate with openjdk based annotation support + byte[] buf = new byte[length]; + data.slice().get(buf); + mts.setRawAnnotationDefault(buf); + + Class r_class; + VmType vtm = mts.getReturnType(); + if (vtm.isPrimitive()) { + switch (vtm.getJvmType()) { + case JvmType.BOOLEAN: + vtm = Boolean.class.getVmClass(); + break; + case JvmType.BYTE: + vtm = Byte.class.getVmClass(); + break; + case JvmType.SHORT: + vtm = Short.class.getVmClass(); + break; + case JvmType.CHAR: + vtm = Character.class.getVmClass(); + break; + case JvmType.INT: + vtm = Integer.class.getVmClass(); + break; + case JvmType.FLOAT: + vtm = Float.class.getVmClass(); + break; + case JvmType.LONG: + vtm = Long.class.getVmClass(); + break; + case JvmType.DOUBLE: + vtm = Double.class.getVmClass(); + break; + + } + r_class = new Class(vtm); + } else { + try { + r_class = Class.forName(vtm.getName(), false, vtm.getLoader().asClassLoader()); + } catch (ClassNotFoundException cnf) { + throw new RuntimeException(cnf); + } + } + Object defo = AnnotationParser.parseMemberValue(r_class, data, new VmConstantPool(cls), + new Class(cls)); + mts.setAnnotationDefault(defo); } else { skip(data, length); } @@ -996,11 +1062,11 @@ * @param cp */ private static VmAnnotation[][] readRuntimeParameterAnnotations( - ByteBuffer data, VmCP cp, boolean visible) { + ByteBuffer data, VmCP cp, boolean visible, VmClassLoader loader) { final int numParams = data.get(); final VmAnnotation[][] arr = new VmAnnotation[numParams][]; for (int i = 0; i < numParams; i++) { - arr[i] = readRuntimeAnnotations(data, cp, visible); + arr[i] = readRuntimeAnnotations(data, cp, visible, loader); } return arr; } @@ -1012,7 +1078,7 @@ * @param cp */ private static VmAnnotation[] readRuntimeAnnotations(ByteBuffer data, - VmCP cp, boolean visible) { + VmCP cp, boolean visible, VmClassLoader loader) { final int numAnn = data.getChar(); final VmAnnotation[] arr = new VmAnnotation[numAnn]; for (int i = 0; i < numAnn; i++) { @@ -1022,6 +1088,23 @@ } /** + * Read a runtime annotations attributes. + * + * @param data + * @param cp + */ + private static VmAnnotation[] readRuntimeAnnotations2(ByteBuffer data, + VmCP cp, boolean visible, VmClassLoader loader, + VmType vmtype) { + final int numAnn = data.getChar(); + final VmAnnotation[] arr = new VmAnnotation[numAnn]; + for (int i = 0; i < numAnn; i++) { + arr[i] = readAnnotation2(data, cp, visible, loader, vmtype); + } + return arr; + } + + /** * Combine the pragma flags for a given list of annotations. * * @param annotations @@ -1092,8 +1175,7 @@ * @param data * @param cp */ - private static VmAnnotation readAnnotation(ByteBuffer data, VmCP cp, - boolean visible) { + private static VmAnnotation readAnnotation(ByteBuffer data, VmCP cp, boolean visible) { final String typeDescr = cp.getUTF8(data.getChar()); final int numElemValuePairs = data.getChar(); final VmAnnotation.ElementValue[] values; @@ -1116,7 +1198,110 @@ return new VmAnnotation(typeDescr, values); } + //todo will get obsolate with openjdk based annotation support /** + * Read a single annotation structure. + * + * @param data + * @param cp + */ + private static VmAnnotation readAnnotation2(ByteBuffer data, VmCP cp, + boolean visible, VmClassLoader loader, VmType vmType) { + final String typeDescr = cp.getUTF8(data.getChar()); + final int numElemValuePairs = data.getChar(); + final VmAnnotation.ElementValue[] values; + if (numElemValuePairs == 0) { + values = VmAnnotation.ElementValue.EMPTY_ARR; + } else if (visible) { + values = new VmAnnotation.ElementValue[numElemValuePairs]; + for (int i = 0; i < numElemValuePairs; i++) { + final String elemName = cp.getUTF8(data.getChar()); + + Object defo = null; //readElementValue(data, cp); + + try { + VmType annType = new Signature(typeDescr, loader).getType(); + + VmMethod mts = null; + int dmc = annType.getNoDeclaredMethods(); + for (int v = 0; v < dmc; v++) { + VmMethod m = annType.getDeclaredMethod(v); + if (elemName.equals(m.getName())) { + mts = m; + break; + } + } + + Class r_class; + VmType vtm = mts.getReturnType(); + if (vtm.isPrimitive()) { + switch (vtm.getJvmType()) { + case JvmType.BOOLEAN: + vtm = Boolean.class.getVmClass(); + break; + case JvmType.BYTE: + vtm = Byte.class.getVmClass(); + break; + case JvmType.SHORT: + vtm = Short.class.getVmClass(); + break; + case JvmType.CHAR: + vtm = Character.class.getVmClass(); + break; + case JvmType.INT: + vtm = Integer.class.getVmClass(); + break; + case JvmType.FLOAT: + vtm = Float.class.getVmClass(); + break; + case JvmType.LONG: + vtm = Long.class.getVmClass(); + break; + case JvmType.DOUBLE: + vtm = Double.class.getVmClass(); + break; + + } + r_class = new Class(vtm); + } else { + try { + r_class = vtm.getLoader().asClassLoader().loadClass(vtm.getName()); + } catch (ClassNotFoundException cnf) { + throw new RuntimeException(cnf); + } + } + Class container; + try { + + container = annType.getLoader().asClassLoader().loadClass(annType.getName()); + } catch (ClassNotFoundException cnf) { + throw new RuntimeException(cnf); + } + defo = AnnotationParser.parseMemberValue(r_class, data, new VmConstantPool(vmType), container); + + if (defo instanceof ExceptionProxy) + throw new RuntimeException("Error parsing annotation parameter value (annotation= " + + annType.getName() + ", parameter=" + mts.getName() + ")"); + + } catch (Exception e) { + throw new RuntimeException(e); + } + + + final Object value = defo; //readElementValue(data, cp); + values[i] = new VmAnnotation.ElementValue(elemName, value); + } + } else { + values = VmAnnotation.ElementValue.EMPTY_ARR; + for (int i = 0; i < numElemValuePairs; i++) { + data.getChar(); // Skip name ref + skipElementValue(data, cp); + } + } + return new VmAnnotation(typeDescr, values); + } + + /** * Read a single element_value structure. * * @param data Modified: trunk/core/src/core/org/jnode/vm/classmgr/VmAnnotation.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmAnnotation.java 2008-06-26 20:11:32 UTC (rev 4279) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmAnnotation.java 2008-06-27 19:27:49 UTC (rev 4280) @@ -25,7 +25,11 @@ import java.lang.annotation.Inherited; import java.lang.reflect.Array; import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; import org.jnode.vm.VmSystemObject; +import sun.reflect.annotation.AnnotationParser; /** * VM representation of a single annotation. @@ -47,7 +51,7 @@ /** * The element values */ - private final ElementValue[] values; + private ElementValue[] values; /** * The type of this annotation @@ -57,13 +61,13 @@ /** * The type implementing this annotation */ - private transient ImplBase value; + private transient Annotation value; /** - * @param runtimeVisible + * @param typeDescr the annotation type descriptor + * @param values annotation parameter name-value pairs */ - public VmAnnotation(String typeDescr, - ElementValue[] values) { + public VmAnnotation(String typeDescr, ElementValue[] values) { this.typeDescr = typeDescr; this.values = values; } @@ -95,17 +99,65 @@ throws ClassNotFoundException { if (value == null) { final VmType<? extends Annotation> annType = annotationType(loader); - final VmType<? extends ImplBase> implType = getImplClass(annType); - final ImplBase value; - try { - value = (ImplBase) implType.asClass().newInstance(); - } catch (InstantiationException ex) { - throw new RuntimeException(ex); - } catch (IllegalAccessException ex) { - throw new RuntimeException(ex); + //todo will be obsolate when annotation paring is migrated to openjdk + if (!annType.getName().equals(org.jnode.vm.annotation.AllowedPackages.class.getName())) { + int dmc = annType.getNoDeclaredMethods(); + Map vmap = new HashMap(); + for (int i = 0; i < dmc; i++) { + VmMethod met = annType.getDeclaredMethod(i); + Object o = met.getAnnotationDefault(); + if (o != null) { + String name = met.getName(); + vmap.put(name, o); + } + } + + + for (int i = 0; i < values.length; i++) { + vmap.put(values[i].name, values[i].value); + } + + Set<Map.Entry> set = vmap.entrySet(); + values = new ElementValue[set.size()]; + int i = 0; + for (Map.Entry e : set) { + values[i++] = new ElementValue((String) e.getKey(), e.getValue()); + } + + for (Map.Entry e : set) { + Object o = e.getValue(); + if (o != null && o.getClass().isArray()) { + Object[] arr = (Object[]) o; + if (arr.length > 0) { + Object el = arr[0]; + Class elc = el.getClass(); + Object[] ar2 = (Object[]) Array.newInstance(elc, arr.length); + for (int v = 0; v < arr.length; v++) { + ar2[v] = elc.cast(arr[v]); + } + e.setValue(ar2); + } + } + } + + //try { + /*value =*/ + return AnnotationParser.annotationForMap(loader.asClassLoader().loadClass(annType.getName()), vmap); + + } else { + + final VmType<? extends ImplBase> implType = getImplClass(annType); + final ImplBase value; + try { + value = implType.asClass().newInstance(); + } catch (InstantiationException ex) { + throw new RuntimeException(ex); + } catch (IllegalAccessException ex) { + throw new RuntimeException(ex); + } + value.initialize(annType, values, loader); + this.value = value; } - value.initialize(annType, values, loader); - this.value = value; } return value; } Added: trunk/core/src/core/org/jnode/vm/classmgr/VmConstantPool.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmConstantPool.java (rev 0) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmConstantPool.java 2008-06-27 19:27:49 UTC (rev 4280) @@ -0,0 +1,116 @@ +/* + * $ + */ +package org.jnode.vm.classmgr; + +import java.lang.reflect.Field; +import java.lang.reflect.Member; +import sun.reflect.ConstantPool; + +/** + * @author Levente S\u00e1ntha + */ +public class VmConstantPool extends ConstantPool { + private VmType vmt; + private VmCP cp; + private VmClassLoader loader; + + public VmConstantPool(VmType vmt) { + this.vmt = vmt; + this.cp = vmt.getCP(); + this.loader = vmt.getLoader(); + } + + @Override + public Class getClassAt(int index) { + VmConstClass cc = cp.getConstClass(index); + cc.doResolve(loader); + VmType vmt = cc.getResolvedVmClass(); + return (vmt == null) ? null : vmt.asClass(); + } + + @Override + public Class getClassAtIfLoaded(int index) { + VmConstClass cc = cp.getConstClass(index); + VmType vmt = cc.getResolvedVmClass(); + return (vmt == null) ? null : vmt.asClass(); + } + + @Override + public double getDoubleAt(int index) { + return cp.getDouble(index); + } + + @Override + public Field getFieldAt(int index) { + VmConstFieldRef f = cp.getConstFieldRef(index); + f.doResolve(loader); + VmField vmf = f.getResolvedVmField(); + return new Field(vmf); + } + + @Override + public Field getFieldAtIfLoaded(int index) { + VmConstFieldRef f = cp.getConstFieldRef(index); + try { + VmField vmf = f.getResolvedVmField(); + return new Field(vmf); + } catch (NotResolvedYetException x) { + return null; + } + } + + @Override + public float getFloatAt(int index) { + return cp.getFloat(index); + } + + @Override + public int getIntAt(int index) { + return cp.getInt(index); + } + + @Override + public long getLongAt(int index) { + return cp.getLong(index); + } + + // Fetches the class name, member (field, method or interface + // method) name, and type descriptor as an array of three Strings + @Override + public String[] getMemberRefInfoAt(int index) { + //todo implement it + throw new UnsupportedOperationException(); + } + + // Returns either a Method or Constructor. + // Static initializers are returned as Method objects. + @Override + public Member getMethodAt(int index) { + //todo implement it + throw new UnsupportedOperationException(); + } + + @Override + public Member getMethodAtIfLoaded(int index) { + //todo implement it + throw new UnsupportedOperationException(); + } + + // Number of entries in this constant pool (= maximum valid constant pool index) + @Override + public int getSize() { + return cp.getLength(); + } + + @Override + public String getStringAt(int index) { + return (vmt.isSharedStatics() ? loader.getSharedStatics() : loader.getIsolatedStatics()). + getStringEntry(cp.getString(index).getSharedStaticsIndex()); + } + + @Override + public String getUTF8At(int index) { + return cp.getUTF8(index); + } +} Modified: trunk/core/src/core/org/jnode/vm/classmgr/VmMethod.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmMethod.java 2008-06-26 20:11:32 UTC (rev 4279) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmMethod.java 2008-06-27 19:27:49 UTC (rev 4280) @@ -99,6 +99,11 @@ */ private char pragmaFlags; + private Object annotationDefault; + private byte[] rawAnnotationDefault; + private byte[] rawAnnotations; + private byte[] rawParameterAnnotations; + /** * Constructor for VmMethod. * @@ -637,4 +642,36 @@ } } } + + public Object getAnnotationDefault() { + return annotationDefault; + } + + public void setAnnotationDefault(Object annotationDefault) { + this.annotationDefault = annotationDefault; + } + + public byte[] getRawAnnotationDefault() { + return rawAnnotationDefault; + } + + public void setRawAnnotationDefault(byte[] rawAnnotationDefault) { + this.rawAnnotationDefault = rawAnnotationDefault; + } + + public byte[] getRawAnnotations() { + return rawAnnotations; + } + + public void setRawAnnotations(byte[] rawAnnotations) { + this.rawAnnotations = rawAnnotations; + } + + public byte[] getRawParameterAnnotations() { + return rawParameterAnnotations; + } + + public void setRawParameterAnnotations(byte[] rawParameterAnnotations) { + this.rawParameterAnnotations = rawParameterAnnotations; + } } Modified: trunk/core/src/openjdk/vm/java/lang/reflect/NativeProxy.java =================================================================== --- trunk/core/src/openjdk/vm/java/lang/reflect/NativeProxy.java 2008-06-26 20:11:32 UTC (rev 4279) +++ trunk/core/src/openjdk/vm/java/lang/reflect/NativeProxy.java 2008-06-27 19:27:49 UTC (rev 4280) @@ -12,6 +12,8 @@ */ private static Class defineClass0(ClassLoader loader, String name, byte[] b, int off, int len){ + if(loader == null) + loader = Thread.currentThread().getContextClassLoader(); return loader.getVmClassLoader().defineClass(name, b, off, len, Object.class.getProtectionDomain()).asClass(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2008-06-29 03:53:46
|
Revision: 4285 http://jnode.svn.sourceforge.net/jnode/?rev=4285&view=rev Author: crawley Date: 2008-06-28 20:53:45 -0700 (Sat, 28 Jun 2008) Log Message: ----------- Change URLArgument from an Argument<String> to an Argument<URL> Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java trunk/fs/src/fs/org/jnode/fs/command/HexdumpCommand.java trunk/shell/src/shell/org/jnode/shell/command/ClasspathCommand.java trunk/shell/src/shell/org/jnode/shell/command/log4j/Log4jCommand.java trunk/shell/src/shell/org/jnode/shell/command/plugin/PluginCommand.java trunk/shell/src/shell/org/jnode/shell/syntax/URLArgument.java Modified: trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java 2008-06-29 02:03:53 UTC (rev 4284) +++ trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java 2008-06-29 03:53:45 UTC (rev 4285) @@ -71,23 +71,19 @@ public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) throws IOException { File[] files = ARG_FILE.getValues(); - String[] urls = ARG_URL.getValues(); + URL[] urls = ARG_URL.getValues(); boolean ok = true; if (urls != null && urls.length > 0) { - for (String urlString : urls) { + for (URL url : urls) { InputStream is = null; - try { - URL url = new URL(urlString); - is = url.openStream(); + try {is = url.openStream(); if (is == null) { ok = false; } else { process(is, out); } - } catch (MalformedURLException ex) { - err.println("Malformed url '" + urlString + "': " + ex.getMessage()); } catch (IOException ex) { - err.println("Can't fetch url '" + urlString + "': " + ex.getMessage()); + err.println("Can't fetch url '" + url + "': " + ex.getMessage()); } finally { if (is != null) { try { Modified: trunk/fs/src/fs/org/jnode/fs/command/HexdumpCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/HexdumpCommand.java 2008-06-29 02:03:53 UTC (rev 4284) +++ trunk/fs/src/fs/org/jnode/fs/command/HexdumpCommand.java 2008-06-29 03:53:45 UTC (rev 4285) @@ -54,15 +54,11 @@ exit(1); } } else if (ARG_URL.isSet()) { - String urlStr = ARG_URL.getValue(); + URL url = ARG_URL.getValue(); try { - URL url = new URL(urlStr); is = url.openStream(); - } catch (MalformedURLException ex) { - err.println("Malformed URL '" + urlStr + "': " + ex.getMessage()); - exit(1); } catch (IOException ex) { - err.println("Cannot access URL '" + urlStr + "': " + ex.getMessage()); + err.println("Cannot access URL '" + url + "': " + ex.getMessage()); exit(1); } } else { Modified: trunk/shell/src/shell/org/jnode/shell/command/ClasspathCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/ClasspathCommand.java 2008-06-29 02:03:53 UTC (rev 4284) +++ trunk/shell/src/shell/org/jnode/shell/command/ClasspathCommand.java 2008-06-29 03:53:45 UTC (rev 4285) @@ -61,7 +61,7 @@ public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) throws Exception { if (ARG_ADD.isSet()) { - addToClassPath(ARG_ADD.getValueAsURL()); + addToClassPath(ARG_ADD.getValue()); } else if (ARG_CLEAR.isSet()) { clearClassPath(); } else if (ARG_REFRESH.isSet()) { Modified: trunk/shell/src/shell/org/jnode/shell/command/log4j/Log4jCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/log4j/Log4jCommand.java 2008-06-29 02:03:53 UTC (rev 4284) +++ trunk/shell/src/shell/org/jnode/shell/command/log4j/Log4jCommand.java 2008-06-29 03:53:45 UTC (rev 4285) @@ -26,7 +26,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; -import java.net.MalformedURLException; import java.net.URL; import java.util.Enumeration; import java.util.Properties; @@ -104,13 +103,8 @@ } } else if (ARG_URL.isSet()) { // Set configuration from a URL - try { - final URL configURL = new URL(ARG_URL.getValue()); - PropertyConfigurator.configure(configURL); - } catch (MalformedURLException ex) { - err.println("Malformed configuration URL: " + ex.getMessage()); - exit(1); - } + final URL configURL = ARG_URL.getValue(); + PropertyConfigurator.configure(configURL); } else if (FLAG_LIST.isSet()) { // List current loggers and their levels. Effective levels are shown // in parentheses. Modified: trunk/shell/src/shell/org/jnode/shell/command/plugin/PluginCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/plugin/PluginCommand.java 2008-06-29 02:03:53 UTC (rev 4284) +++ trunk/shell/src/shell/org/jnode/shell/command/plugin/PluginCommand.java 2008-06-29 03:53:45 UTC (rev 4285) @@ -74,7 +74,7 @@ private final StringArgument ARG_VERSION = new StringArgument("version", Argument.OPTIONAL, "plugin version"); - private PrintStream out, err; + private PrintStream out; private PluginManager mgr; @@ -94,7 +94,6 @@ public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) throws Exception { this.out = out; - this.err = err; try { AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { @@ -107,18 +106,13 @@ } } - private void doRun() throws NameNotFoundException, SyntaxMultiplicityException, PluginException { + private void doRun() + throws NameNotFoundException, SyntaxMultiplicityException, PluginException, MalformedURLException { mgr = (PluginManager) InitialNaming.lookup(PluginManager.NAME); final String version = ARG_VERSION.isSet() ? ARG_VERSION.getValue() : Vm.getVm().getVersion(); final String pluginId = ARG_PLUGIN_ID.getValue(); if (ARG_LOADER_URL.isSet()) { - try { - final URL url = new URL(ARG_LOADER_URL.getValue()); - addPluginLoader(url); - } catch (MalformedURLException ex) { - err.println("Malformed plugin loader URL"); - exit(1); - } + addPluginLoader(ARG_LOADER_URL.getValue()); } else if (FLAG_LOAD.isSet()) { loadPlugin(pluginId, version); } else if (FLAG_RELOAD.isSet()) { Modified: trunk/shell/src/shell/org/jnode/shell/syntax/URLArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/URLArgument.java 2008-06-29 02:03:53 UTC (rev 4284) +++ trunk/shell/src/shell/org/jnode/shell/syntax/URLArgument.java 2008-06-29 03:53:45 UTC (rev 4285) @@ -23,16 +23,18 @@ import java.net.MalformedURLException; import java.net.URL; +import org.jnode.shell.CommandLine.Token; + /** * This class implements URL-valued command line arguments. At the moment, it performs * no special syntax checking and does no completion. * * @author cr...@jn... */ -public class URLArgument extends StringArgument { +public class URLArgument extends Argument<URL> { public URLArgument(String label, int flags, String description) { - super(label, flags, description); + super(label, flags, new URL[0], description); } public URLArgument(String label, int flags) { @@ -43,12 +45,21 @@ this(label, 0, null); } - public URL getValueAsURL() throws MalformedURLException { - return new URL(getValue()); - } +// public URL getValueAsURL() throws MalformedURLException { +// return getValue(); +// } @Override protected String argumentKind() { return "url"; } + + @Override + protected URL doAccept(Token value) throws CommandSyntaxException { + try { + return new URL(value.token); + } catch (MalformedURLException ex) { + throw new CommandSyntaxException(ex.getMessage(), ex); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2008-06-29 11:20:35
|
Revision: 4287 http://jnode.svn.sourceforge.net/jnode/?rev=4287&view=rev Author: crawley Date: 2008-06-29 04:20:33 -0700 (Sun, 29 Jun 2008) Log Message: ----------- Style fixes Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java trunk/fs/src/fs/org/jnode/fs/command/HexdumpCommand.java trunk/shell/src/shell/org/jnode/shell/command/plugin/PluginCommand.java Modified: trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java 2008-06-29 11:16:36 UTC (rev 4286) +++ trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java 2008-06-29 11:20:33 UTC (rev 4287) @@ -27,7 +27,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; -import java.net.MalformedURLException; import java.net.URL; import org.jnode.shell.AbstractCommand; @@ -76,7 +75,8 @@ if (urls != null && urls.length > 0) { for (URL url : urls) { InputStream is = null; - try {is = url.openStream(); + try { + is = url.openStream(); if (is == null) { ok = false; } else { Modified: trunk/fs/src/fs/org/jnode/fs/command/HexdumpCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/HexdumpCommand.java 2008-06-29 11:16:36 UTC (rev 4286) +++ trunk/fs/src/fs/org/jnode/fs/command/HexdumpCommand.java 2008-06-29 11:20:33 UTC (rev 4287) @@ -10,7 +10,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; -import java.net.MalformedURLException; import java.net.URL; import org.jnode.shell.AbstractCommand; Modified: trunk/shell/src/shell/org/jnode/shell/command/plugin/PluginCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/plugin/PluginCommand.java 2008-06-29 11:16:36 UTC (rev 4286) +++ trunk/shell/src/shell/org/jnode/shell/command/plugin/PluginCommand.java 2008-06-29 11:20:33 UTC (rev 4287) @@ -107,7 +107,7 @@ } private void doRun() - throws NameNotFoundException, SyntaxMultiplicityException, PluginException, MalformedURLException { + throws NameNotFoundException, SyntaxMultiplicityException, PluginException, MalformedURLException { mgr = (PluginManager) InitialNaming.lookup(PluginManager.NAME); final String version = ARG_VERSION.isSet() ? ARG_VERSION.getValue() : Vm.getVm().getVersion(); final String pluginId = ARG_PLUGIN_ID.getValue(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2008-07-11 15:03:47
|
Revision: 4300 http://jnode.svn.sourceforge.net/jnode/?rev=4300&view=rev Author: lsantha Date: 2008-07-11 08:03:15 -0700 (Fri, 11 Jul 2008) Log Message: ----------- Code style fixes. Modified Paths: -------------- trunk/core/src/core/org/jnode/imageio/jpeg/JPEGDecoderAdapter.java trunk/distr/src/apps/org/jnode/games/rubik/Rubik.java trunk/gui/src/awt/org/jnode/awt/font/bdf/BDFTextRenderer.java Modified: trunk/core/src/core/org/jnode/imageio/jpeg/JPEGDecoderAdapter.java =================================================================== --- trunk/core/src/core/org/jnode/imageio/jpeg/JPEGDecoderAdapter.java 2008-07-11 14:52:37 UTC (rev 4299) +++ trunk/core/src/core/org/jnode/imageio/jpeg/JPEGDecoderAdapter.java 2008-07-11 15:03:15 UTC (rev 4300) @@ -40,7 +40,7 @@ return im; } - public void decode() throws JPEGException{ + public void decode() throws JPEGException { if (im == null) { try { dec.decode(is, this); Modified: trunk/distr/src/apps/org/jnode/games/rubik/Rubik.java =================================================================== --- trunk/distr/src/apps/org/jnode/games/rubik/Rubik.java 2008-07-11 14:52:37 UTC (rev 4299) +++ trunk/distr/src/apps/org/jnode/games/rubik/Rubik.java 2008-07-11 15:03:15 UTC (rev 4300) @@ -475,7 +475,7 @@ public void paintComponent(Graphics g) { dragReg = 0; - if(offGraphics == null) { + if (offGraphics == null) { // Double buffer offImage = createImage(120, 120); offGraphics = offImage.getGraphics(); @@ -671,7 +671,7 @@ JFrame f = new JFrame("Rubik's Cube"); Rubik rubik = new Rubik(); rubik.init(); - rubik.setPreferredSize(new Dimension(120,120)); + rubik.setPreferredSize(new Dimension(120, 120)); f.add(rubik, BorderLayout.CENTER); rubik.requestFocus(); f.pack(); Modified: trunk/gui/src/awt/org/jnode/awt/font/bdf/BDFTextRenderer.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/font/bdf/BDFTextRenderer.java 2008-07-11 14:52:37 UTC (rev 4299) +++ trunk/gui/src/awt/org/jnode/awt/font/bdf/BDFTextRenderer.java 2008-07-11 15:03:15 UTC (rev 4300) @@ -29,7 +29,6 @@ import org.jnode.driver.video.Surface; import org.jnode.font.bdf.BDFFontContainer; import org.jnode.font.bdf.BDFGlyph; -import org.jnode.font.bdf.BDFMetrics; import org.jnode.font.bdf.BDFParser; /** @@ -65,7 +64,7 @@ * @see java.awt.Graphics */ public final void render(Surface surface, Shape clip, AffineTransform tx, CharSequence str, - final int x, final int y,Color color) { + final int x, final int y, Color color) { if (str == null || str.length() == 0) return; @@ -96,7 +95,7 @@ glyph_box = glyph.getBbx(glyph_box); final int fHeight = glyph_box.height; - final int[] fData = glyph.getData(); + final int[] fData = glyph.getData(); final int scan = fData.length / fHeight; int fg_r = color.getRed(); @@ -126,29 +125,29 @@ //clip // if(clip == null || clip.contains(px, py)) { - //compute color - int bg_color = surface.getRGBPixel(px, py); + //compute color + int bg_color = surface.getRGBPixel(px, py); - int bg_r = (bg_color & 0x00FF0000) >> 16; - int bg_g = (bg_color & 0x0000FF00) >> 8; - int bg_b = (bg_color & 0x000000FF); + int bg_r = (bg_color & 0x00FF0000) >> 16; + int bg_g = (bg_color & 0x0000FF00) >> 8; + int bg_b = (bg_color & 0x000000FF); - //todo improve this pixel composition + //todo improve this pixel composition - float alpha = fPixel / f_max; + float alpha = fPixel / f_max; - int r = bg_r + ((int) ((fg_r - bg_r) * alpha)) & 0xFF; - int g = bg_g + ((int) ((fg_g - bg_g) * alpha)) & 0xFF; - int b = bg_b + ((int) ((fg_b - bg_b) * alpha)) & 0xFF; + int r = bg_r + ((int) ((fg_r - bg_r) * alpha)) & 0xFF; + int g = bg_g + ((int) ((fg_g - bg_g) * alpha)) & 0xFF; + int b = bg_b + ((int) ((fg_b - bg_b) * alpha)) & 0xFF; - fPixel = (((r << 16) + (g << 8) + b) | 0xFF000000); + fPixel = (((r << 16) + (g << 8) + b) | 0xFF000000); - surface.setRGBPixel(px, py, fPixel); + surface.setRGBPixel(px, py, fPixel); - if (x_min > px) x_min = px; - if (y_min > py) y_min = py; - if (x_max < px) x_max = px; - if (y_max < py) y_max = py; + if (x_min > px) x_min = px; + if (y_min > py) y_min = py; + if (x_max < px) x_max = px; + if (y_max < py) y_max = py; // } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2008-07-12 06:25:43
|
Revision: 4301 http://jnode.svn.sourceforge.net/jnode/?rev=4301&view=rev Author: crawley Date: 2008-07-11 23:25:41 -0700 (Fri, 11 Jul 2008) Log Message: ----------- Added first version of the JNode build configuration tool + wrapper script. Modified Paths: -------------- trunk/distr/.classpath trunk/distr/build.xml Added Paths: ----------- trunk/configure.sh trunk/distr/lib/nanoxml-2.2.3.jar trunk/distr/src/configure/ trunk/distr/src/configure/org/ trunk/distr/src/configure/org/jnode/ trunk/distr/src/configure/org/jnode/configure/ trunk/distr/src/configure/org/jnode/configure/Configure.java trunk/distr/src/configure/org/jnode/configure/ConfigureException.java trunk/distr/src/configure/org/jnode/configure/ConfigureScript.java trunk/distr/src/configure/org/jnode/configure/EnumeratedType.java trunk/distr/src/configure/org/jnode/configure/PatternType.java trunk/distr/src/configure/org/jnode/configure/PropertySet.java trunk/distr/src/configure/org/jnode/configure/PropertyType.java trunk/distr/src/configure/org/jnode/configure/Screen.java trunk/distr/src/configure/org/jnode/configure/ScriptParser.java trunk/distr/src/configure/org/jnode/configure/adapter/ trunk/distr/src/configure/org/jnode/configure/adapter/BasePropertyFileAdapter.java trunk/distr/src/configure/org/jnode/configure/adapter/DummyValueCodec.java trunk/distr/src/configure/org/jnode/configure/adapter/FileAdapter.java trunk/distr/src/configure/org/jnode/configure/adapter/FileAdapterFactory.java trunk/distr/src/configure/org/jnode/configure/adapter/JavaSourceFileAdapter.java trunk/distr/src/configure/org/jnode/configure/adapter/JavaStringLiteralCodec.java trunk/distr/src/configure/org/jnode/configure/adapter/PropertyFileAdapter.java trunk/distr/src/configure/org/jnode/configure/adapter/PropertyValueCodec.java trunk/distr/src/configure/org/jnode/configure/adapter/TextFileAdapter.java trunk/distr/src/configure/org/jnode/configure/adapter/XMLFileAdapter.java trunk/distr/src/configure/org/jnode/configure/adapter/XMLPropertyFileAdapter.java trunk/distr/src/configure/org/jnode/configure/adapter/XMLValueCodec.java Added: trunk/configure.sh =================================================================== --- trunk/configure.sh (rev 0) +++ trunk/configure.sh 2008-07-12 06:25:41 UTC (rev 4301) @@ -0,0 +1,6 @@ +#!/bin/sh +cmd=`type -p $0` +dir=`dirname $cmd` +cp=$dir/all/build/descriptors/jnode-configure.jar:$dir/distr/lib/nanoxml-2.2.3.jar + +java -cp $cp org.jnode.configure.Configure "$@" Property changes on: trunk/configure.sh ___________________________________________________________________ Name: svn:executable + * Modified: trunk/distr/.classpath =================================================================== --- trunk/distr/.classpath 2008-07-11 15:03:15 UTC (rev 4300) +++ trunk/distr/.classpath 2008-07-12 06:25:41 UTC (rev 4301) @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src/install"/> + <classpathentry kind="src" path="src/configure"/> <classpathentry kind="src" path="src/emu"/> <classpathentry kind="src" path="src/test"/> <classpathentry kind="src" path="/JNode-Core"/> @@ -20,5 +21,6 @@ <classpathentry kind="lib" path="lib/commons-logging.jar"/> <classpathentry kind="lib" path="lib/derby.jar"/> <classpathentry kind="lib" path="lib/derbynet.jar"/> + <classpathentry kind="lib" path="lib/nanoxml-2.2.3.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/distr/build.xml =================================================================== --- trunk/distr/build.xml 2008-07-11 15:03:15 UTC (rev 4300) +++ trunk/distr/build.xml 2008-07-12 06:25:41 UTC (rev 4301) @@ -29,6 +29,7 @@ <!-- Initialize all subproject directories --> <target name="prepare"> <mkdir dir="${my-classes.dir}"/> + <mkdir dir="${my-build.dir}"/> <jnode.copy-descriptors/> </target> @@ -50,8 +51,12 @@ </copy> </target> -<!-- Assemble the jarfile --> - <target name="assemble" depends="compile"/> +<!-- Assemble the jarfile(s) --> + <target name="assemble" depends="compile"> + <jar jarfile="${jnode-configure.jar}" + basedir="${my-classes.dir}" + includes="org/jnode/configure/**"/> + </target> <!-- Do it all --> <target name="all" depends="assemble"/> Added: trunk/distr/lib/nanoxml-2.2.3.jar =================================================================== (Binary files differ) Property changes on: trunk/distr/lib/nanoxml-2.2.3.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/distr/src/configure/org/jnode/configure/Configure.java =================================================================== --- trunk/distr/src/configure/org/jnode/configure/Configure.java (rev 0) +++ trunk/distr/src/configure/org/jnode/configure/Configure.java 2008-07-12 06:25:41 UTC (rev 4301) @@ -0,0 +1,124 @@ +/* + * $Id $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library 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 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jnode.configure; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintStream; + + +/** + * The main class for the JNode configuration tool (command line version). + * <p> + * The command currently does not use the JNode Command / Syntax APIs. This + * should be addressed when we have a compatibility library. A version with + * a GUI-based interface would be a good idea too. + * + * @author cr...@jn... + */ +public class Configure { + private final BufferedReader in; + private final PrintStream out; + private final PrintStream err; + private String scriptFile; + private boolean debug; + + private Configure() { + this.in = new BufferedReader(new InputStreamReader(System.in)); + this.out = System.out; + this.err = System.err; + } + + private void run(String[] args) { + try { + parseArguments(args); + ConfigureScript script = new ScriptParser().loadScript(scriptFile); + for (PropertySet propFile : script.getPropsFiles()) { + propFile.load(this); + } + script.execute(this); + for (PropertySet propFile : script.getPropsFiles()) { + saveProperties(propFile); + } + output("Done."); + } catch (ConfigureException ex) { + error(ex.getMessage()); + if (debug) { + ex.printStackTrace(err); + } + System.exit(1); + } + } + + /** + * Parse the command line. + * + * @param args + */ + private void parseArguments(String[] args) throws ConfigureException { + int i; + for (i = 0; i < args.length; i++) { + String arg = args[i]; + if (!arg.startsWith("-")) { + break; + } + if (arg.equals("--debug")) { + debug = true; + } else { + throw new ConfigureException("Unrecognized option: " + args[i]); + } + } + if (i >= args.length) { + throw new ConfigureException("Missing script file argument"); + } + scriptFile = args[i++]; + if (i < args.length) { + throw new ConfigureException("Unexpected command argument: " + scriptFile); + } + } + + public String input(String prompt) throws ConfigureException { + out.print(prompt); + try { + return in.readLine(); + } catch (IOException ex) { + throw new ConfigureException("Unexpected IO exception", ex); + } + } + + public void output(String message) { + out.println(message); + } + + public void error(String message) { + err.println(message); + } + + private void saveProperties(PropertySet propSet) throws ConfigureException { + propSet.save(this); + } + + public static void main(String[] args) { + new Configure().run(args); + } + +} Added: trunk/distr/src/configure/org/jnode/configure/ConfigureException.java =================================================================== --- trunk/distr/src/configure/org/jnode/configure/ConfigureException.java (rev 0) +++ trunk/distr/src/configure/org/jnode/configure/ConfigureException.java 2008-07-12 06:25:41 UTC (rev 4301) @@ -0,0 +1,57 @@ +/* + * $Id $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library 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 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jnode.configure; + +/** + * This exception is thrown when we have diagnosed a problem while processing a + * configure script. + * + * @author cr...@jn... + */ +public class ConfigureException extends Exception { + + private static final long serialVersionUID = 349388505334474279L; + + private ScriptParser.ParseContext[] stack; + + public ConfigureException(String message, Throwable cause) { + super(message + ": " + cause.getLocalizedMessage(), cause); + this.stack = null; + } + + public ConfigureException(String message) { + super(message); + this.stack = null; + } + + public ConfigureException(String message, ScriptParser.ParseContext[] stack) { + super(message); + this.stack = stack; + } + + public ScriptParser.ParseContext[] getStack() { + return stack; + } + + public void setStack(ScriptParser.ParseContext[] stack) { + this.stack = stack; + } +} Added: trunk/distr/src/configure/org/jnode/configure/ConfigureScript.java =================================================================== --- trunk/distr/src/configure/org/jnode/configure/ConfigureScript.java (rev 0) +++ trunk/distr/src/configure/org/jnode/configure/ConfigureScript.java 2008-07-12 06:25:41 UTC (rev 4301) @@ -0,0 +1,135 @@ +/* + * $Id $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library 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 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jnode.configure; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.jnode.configure.PropertySet.Property; + +/** + * This class provides the in-memory representation corresponding to an + * XML configure script. The 'execute' method runs the script. + * + * @author cr...@jn... + */ +public class ConfigureScript { + private final File baseDir; + private final File scriptFile; + private final ArrayList<PropertySet> propsFiles = new ArrayList<PropertySet>(); + private PropertySet controlProps; + private final ArrayList<Screen> screens = new ArrayList<Screen>(); + private final HashMap<String, PropertyType> types = new HashMap<String, PropertyType>(); + private final HashMap<String, Property> allProperties = new HashMap<String, Property>(); + + public ConfigureScript(File scriptFile) { + super(); + this.scriptFile = scriptFile; + this.baseDir = scriptFile.getAbsoluteFile().getParentFile(); + } + + public File getBaseDir() { + return baseDir; + } + + public File getScriptFile() { + return scriptFile; + } + + public PropertySet getControlProps() { + return controlProps; + } + + public void setControlProps(PropertySet controlProps) { + this.controlProps = controlProps; + } + + public List<PropertySet> getPropsFiles() { + return propsFiles; + } + + public void addPropsFile(PropertySet propsFile) { + propsFiles.add(propsFile); + } + + public void addScreen(Screen screen) { + screens.add(screen); + } + + public Map<String, PropertyType> getTypes() { + return types; + } + + public void addType(PropertyType type) { + types.put(type.getTypeName(), type); + } + + /** + * Lookup a property by name in the script's property namespace. + * + * @param propName the property name + * @return a property or <code>null</code> + */ + public Property getProperty(String propName) { + return allProperties.get(propName); + } + + /** + * Add a property to the script's property namespace + * @param prop the property to be added. + */ + public void addProperty(Property prop) { + allProperties.put(prop.getName(), prop); + } + + /** + * Execute this script using the supplied IConfigure to interact + * with the user. We create a work list of screens, then repeatedly scan + * the list looking for the first screen that is ready to be executed. + * When a screen is found, we remove it from the work list and execute + * it. The process stops when the work list is empty, or none of the + * remaining screens are executable. + * + * @param configure + */ + public void execute(Configure configure) throws ConfigureException { + List<Screen> workList = new LinkedList<Screen>(); + workList.addAll(screens); + boolean progress; + do { + progress = false; + for (Iterator<Screen> it = workList.iterator(); it.hasNext(); /**/ ) { + Screen screen = it.next(); + if (screen.isExecutable(this)) { + screen.execute(configure, this); + it.remove(); + progress = true; + break; + } + } + } while (!workList.isEmpty() && progress); + } +} Added: trunk/distr/src/configure/org/jnode/configure/EnumeratedType.java =================================================================== --- trunk/distr/src/configure/org/jnode/configure/EnumeratedType.java (rev 0) +++ trunk/distr/src/configure/org/jnode/configure/EnumeratedType.java 2008-07-12 06:25:41 UTC (rev 4301) @@ -0,0 +1,95 @@ +/* + * $Id $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library 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 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jnode.configure; + +import java.util.List; + +import org.jnode.configure.PropertySet.Value; + +/** + * This class represents a property type with a enumerated set of values. + * + * @author cr...@jn... + */ +public class EnumeratedType extends PropertyType { + + public static class Alternate { + public final String token; + public final String value; + + public Alternate(String token, String value) { + super(); + this.token = token; + this.value = value; + } + } + + private final List<Alternate> alternates; + + public EnumeratedType(String typeName, List<Alternate> alternates) { + super(typeName); + this.alternates = alternates; + } + + @Override + public Value fromInput(String token) { + for (Alternate alternate : alternates) { + if (alternate.token.equals(token)) { + return new Value(token, alternate.value); + } + } + return null; + } + + @Override + public Value fromValue(String value) { + for (Alternate alternate : alternates) { + if (alternate.value.equals(value)) { + return new Value(alternate.token, value); + } + } + return null; + } + + @Override + public String describe(Value defaultValue) { + StringBuffer sb = new StringBuffer(); + sb.append("("); + boolean first = true; + for (Alternate alternate : alternates) { + if (first) { + first = false; + } else { + sb.append(","); + } + boolean isDefault = alternate.value.equals(defaultValue.getText()); + if (isDefault) { + sb.append("["); + } + sb.append(alternate.token); + if (isDefault) { + sb.append("]"); + } + } + sb.append(")"); + return sb.toString(); + } +} Added: trunk/distr/src/configure/org/jnode/configure/PatternType.java =================================================================== --- trunk/distr/src/configure/org/jnode/configure/PatternType.java (rev 0) +++ trunk/distr/src/configure/org/jnode/configure/PatternType.java 2008-07-12 06:25:41 UTC (rev 4301) @@ -0,0 +1,92 @@ +/* + * $Id $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library 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 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jnode.configure; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.jnode.configure.PropertySet.Value; + +/** + * This class represents a property type defined by a regex. The constructor + * allows you to provide an "emptyToken" value. If provided, this value defines + * a special token that will be mapped to the empty string by the {@link fromToken} + * method. + * + * @author cr...@jn... + */ +public class PatternType extends PropertyType { + + private final Pattern pattern; + private final String emptyToken; + + /** + * Construct a Pattern type. + * @param name the type's name. + * @param pattern the Java regex that defines the type's value space + * @param emptyToken if non-null, this specifies a input token that will + * be mapped to the empty string value. You should avoid using + * characters that would require escaping in a Java regex. + */ + public PatternType(String name, Pattern pattern, String emptyToken) { + super(name); + this.pattern = pattern; + this.emptyToken = emptyToken; + } + + @Override + public Value fromInput(String token) { + if (token.equals(emptyToken)) { + return new Value(token, ""); + } else { + return fromValue(token); + } + } + + @Override + public Value fromValue(String value) { + Matcher matcher = pattern.matcher(value); + if (matcher.matches()) { + if (value.equals("") && emptyToken != null) { + return new Value(emptyToken, value); + } else { + return new Value(value, value); + } + } else { + return null; + } + } + + @Override + public String describe(Value defaultValue) { + StringBuffer sb = new StringBuffer(); + sb.append("(/").append(pattern.toString()).append("/"); + if (emptyToken != null) { + sb.append(" or '").append(emptyToken).append("'"); + } + if (defaultValue != null) { + String dv = defaultValue.getToken(); + sb.append(" [").append(dv).append("]"); + } + sb.append(")"); + return sb.toString(); + } +} Added: trunk/distr/src/configure/org/jnode/configure/PropertySet.java =================================================================== --- trunk/distr/src/configure/org/jnode/configure/PropertySet.java (rev 0) +++ trunk/distr/src/configure/org/jnode/configure/PropertySet.java 2008-07-12 06:25:41 UTC (rev 4301) @@ -0,0 +1,233 @@ +/* + * $Id $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library 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 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jnode.configure; + +import java.io.File; +import java.util.LinkedHashMap; + +import org.jnode.configure.adapter.FileAdapter; +import org.jnode.configure.adapter.FileAdapterFactory; +import org.jnode.configure.adapter.JavaSourceFileAdapter; +import org.jnode.configure.adapter.PropertyFileAdapter; +import org.jnode.configure.adapter.TextFileAdapter; +import org.jnode.configure.adapter.XMLFileAdapter; +import org.jnode.configure.adapter.XMLPropertyFileAdapter; + +import net.n3.nanoxml.XMLElement; + +/** + * A property set denotes a group of properties, typically associated with a file. + * + * @author cr...@jn... + */ +public class PropertySet { + public static class Property { + private final String name; + private final PropertyType type; + private final String description; + private Value defaultValue; + private Value value; + private final XMLElement definingElement; + private final File definingFile; + + public Property(String name, PropertyType type, String description, Value defaultValue, + XMLElement definingElement, File definingFile) { + super(); + this.name = name; + this.type = type; + this.description = description; + this.defaultValue = defaultValue; + this.definingElement = definingElement; + this.definingFile = definingFile; + } + + public Value getValue() { + return value == null ? defaultValue : value; + } + + public void setValue(Value value) { + this.value = value; + } + + public boolean isSet() { + return value != null; + } + + public String getName() { + return name; + } + + public PropertyType getType() { + return type; + } + + public String getDescription() { + return description; + } + + public XMLElement getDefiningElement() { + return definingElement; + } + + public File getDefiningFile() { + return definingFile; + } + + public boolean hasDefaultValue() { + return defaultValue != null; + } + + public Value getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(Value defaultValue) { + this.defaultValue = defaultValue; + } + } + + public static class Value { + private final String token; + private final String text; + + public Value(String token, String text) { + super(); + if (token.equals("")) { + throw new IllegalArgumentException("Empty 'token' string"); + } + this.token = token; + this.text = text; + } + + public String getToken() { + return token; + } + + public String getText() { + return text; + } + + public String toString() { + return "'" + token + "'/'" + text + "'"; + } + } + + + private final File file; + private final File defaultFile; + private final File templateFile; + private final char marker; + private final ConfigureScript script; + private final FileAdapter adapter; + private final LinkedHashMap<String, Property> properties = + new LinkedHashMap<String, Property>(); + + + public PropertySet(ConfigureScript script, File file, File defaultFile, + File templateFile, String fileFormat, char marker) + throws ConfigureException { + this.file = file; + this.defaultFile = defaultFile; + this.templateFile = templateFile; + this.marker = marker; + this.script = script; + this.adapter = fileFormat == null ? null : FileAdapterFactory.createAdapter(fileFormat); + if (adapter != null) { + if (!adapter.isLoadSupported() && defaultFile != null) { + throw new ConfigureException( + "A '" + ScriptParser.DEFAULT_FILE + "' attribute cannot be used with " + + " format '" + fileFormat + "': the format does not support property loading."); + } + if (!adapter.isSaveSupported() && templateFile == null) { + throw new ConfigureException( + "A '" + ScriptParser.TEMPLATE_FILE + "' attribute is required with " + + " format '" + fileFormat + "': the format does not support property saving."); + } + } + } + + public PropertySet(ConfigureScript script) + throws ConfigureException { + this.file = null; + this.defaultFile = null; + this.templateFile = null; + this.marker = 0; + this.script = script; + this.adapter = null; + } + + public void load(Configure configure) throws ConfigureException { + adapter.load(this, configure); + } + + public void save(Configure configure) throws ConfigureException { + adapter.save(this, configure); + } + + public File getFile() { + return file; + } + + public File getDefaultFile() { + return defaultFile; + } + + public File getTemplateFile() { + return templateFile; + } + + public char getMarker() { + return marker; + } + + public LinkedHashMap<String, Property> getProperties() { + return properties; + } + + public void addProperty(String name, PropertyType propType, String description, + Value defaultValue, XMLElement definingElement, File definingFile) + throws ConfigureException { + Property oldProp = script.getProperty(name); + if (oldProp != null) { + // FIXME ... alternatively, we could allow properties to be defined in multiple + // contexts and have them refer to the same value. + throw new ConfigureException("Property '" + name + "' already declared at line " + + oldProp.getDefiningElement().getLineNr() + " of " + oldProp.getDefiningFile()); + } + Property prop = new Property( + name, propType, description, defaultValue, definingElement, definingFile); + properties.put(name, prop); + script.addProperty(prop); + } + + public void setProperty(String name, Value value) + throws ConfigureException { + Property property = properties.get(name); + if (property == null) { + throw new ConfigureException("Property not declared: '" + name + "'"); + } + property.setValue(value); + } + + public Property getProperty(String name) { + return properties.get(name); + } +} Added: trunk/distr/src/configure/org/jnode/configure/PropertyType.java =================================================================== --- trunk/distr/src/configure/org/jnode/configure/PropertyType.java (rev 0) +++ trunk/distr/src/configure/org/jnode/configure/PropertyType.java 2008-07-12 06:25:41 UTC (rev 4301) @@ -0,0 +1,48 @@ +/* + * $Id $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library 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 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jnode.configure; + +import org.jnode.configure.PropertySet.Value; + +/** + * A property type constrains the values of a property. + * + * @author cr...@jn... + */ +public abstract class PropertyType { + private final String typeName; + + public PropertyType(String typeName) { + super(); + this.typeName = typeName; + } + + public abstract Value fromInput(String token); + + public abstract Value fromValue(String value); + + public String getTypeName() { + return typeName; + } + + public abstract String describe(Value defaultValue); + +} Added: trunk/distr/src/configure/org/jnode/configure/Screen.java =================================================================== --- trunk/distr/src/configure/org/jnode/configure/Screen.java (rev 0) +++ trunk/distr/src/configure/org/jnode/configure/Screen.java 2008-07-12 06:25:41 UTC (rev 4301) @@ -0,0 +1,149 @@ +/* + * $Id $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library 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 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jnode.configure; + +import java.util.ArrayList; +import java.util.List; + +import org.jnode.configure.PropertySet.Value; + +/** + * This class represents a 'screen' that sets a number of properties. + * + * @author cr...@jn... + */ +public class Screen { + + public static class Item { + private final ConfigureScript script; + private final String propName; + private final String text; + + public Item(ConfigureScript script, String propName, String text) { + this.script = script; + this.propName = propName; + this.text = text; + } + + public ConfigureScript getScript() { + return script; + } + + public String getPropName() { + return propName; + } + + public String getText() { + return text; + } + } + + private final String title; + private final String guardProp; + private final Value valueIs; + private final Value valueIsNot; + private final List<Item> items = new ArrayList<Item>(); + + public Screen(String title, String guardProp, Value valueIs, Value valueIsNot) { + this.title = title; + this.guardProp = guardProp; + this.valueIs = valueIs; + this.valueIsNot = valueIsNot; + } + + public String getTitle() { + return title; + } + + public String getGuardProp() { + return guardProp; + } + + public Value getValueIs() { + return valueIs; + } + + public Value getValueIsNot() { + return valueIsNot; + } + + public List<Item> getItems() { + return items; + } + + public void addItem(Item item) { + items.add(item); + } + + /** + * Test to see if this script is executable (yet). A screen is + * executable if it has no guard property, or its guard property + * is set, and has the appropriate value. Note that we test using + * the PropertyValue's 'value' attribute, not the 'token' attribute. + * + * @param script this gives us the context for property lookup + * @return <code>true</true> if the screen is executable, <code>false</code> otherwise. + */ + public boolean isExecutable(ConfigureScript script) { + if (guardProp == null) { + return true; + } + PropertySet.Property prop = script.getProperty(guardProp); + if (!prop.isSet()) { + return false; + } + Value value = prop.getValue(); + if (valueIs != null) { + return valueIs.getText().equals(value.getText()); + } else if (valueIsNot != null) { + return !valueIsNot.getText().equals(value.getText()); + } else { + return true; + } + } + + public void execute(Configure configure, ConfigureScript script) throws ConfigureException { + configure.output(title); + for (Item item : items) { + String text = item.getText(); + if (text != null) { + configure.output(text); + } + PropertySet.Property prop = script.getProperty(item.getPropName()); + Value value = null; + do { + String info = prop.getType().describe(prop.getDefaultValue()); + String input = configure.input( + prop.getDescription() + " " + info + ": "); + if (input == null) { + throw new ConfigureException("Unexpected EOF on input"); + } + value = prop.getType().fromInput(input); + if (value == null && input.length() == 0 && prop.hasDefaultValue()) { + value = prop.getDefaultValue(); + } + } while (value == null); + if (value != null) { + prop.setValue(value); + } + } + } +} Added: trunk/distr/src/configure/org/jnode/configure/ScriptParser.java =================================================================== --- trunk/distr/src/configure/org/jnode/configure/ScriptParser.java (rev 0) +++ trunk/distr/src/configure/org/jnode/configure/ScriptParser.java 2008-07-12 06:25:41 UTC (rev 4301) @@ -0,0 +1,405 @@ +/* + * $Id $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library 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 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jnode.configure; + + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.Enumeration; +import java.util.LinkedList; +import java.util.List; +import java.util.regex.Pattern; +import java.util.regex.PatternSyntaxException; + +import net.n3.nanoxml.IXMLParser; +import net.n3.nanoxml.StdXMLReader; +import net.n3.nanoxml.XMLElement; +import net.n3.nanoxml.XMLException; +import net.n3.nanoxml.XMLParserFactory; + +import org.jnode.configure.PropertySet.Property; +import org.jnode.configure.PropertySet.Value; +import org.jnode.configure.Screen.Item; +import org.jnode.configure.adapter.FileAdapter; + + +/** + * This class loads an XML configuration script and creates the in-memory + * representation. + * + * @author cr...@jn... + */ +public class ScriptParser { + public static final String SCRIPT = "configureScript"; + public static final String INCLUDE = "include"; + public static final String TYPE = "type"; + public static final String CONTROL_PROPS = "controlProps"; + public static final String PROP_FILE = "propFile"; + public static final String SCRIPT_FILE = "scriptFile"; + public static final String DEFAULT_FILE = "defaultFile"; + public static final String TEMPLATE_FILE = "templateFile"; + public static final String FILE_FORMAT = "fileFormat"; + public static final String MARKER = "marker"; + public static final String DEFAULT_MARKER = "@"; + public static final String VALIDATION_CLASS = "validationClass"; + public static final String SCREEN = "screen"; + public static final String NAME = "name"; + public static final String PATTERN = "pattern"; + public static final String ALT = "alt"; + public static final String VALUE = "value"; + public static final String TOKEN = "token"; + public static final String PROPERTY = "property"; + public static final String PROMPT = "prompt"; + public static final String DESCRIPTION = "description"; + public static final String DEFAULT = "default"; + public static final String TITLE = "title"; + public static final String ITEM = "item"; + public static final String GUARD_PROP = "guardProp"; + public static final String VALUE_IS = "valueIs"; + public static final String VALUE_IS_NOT = "valueIsNot"; + public static final String EMPTY_TOKEN = "emptyToken"; + + public static class ParseContext { + private final File file; + private final File baseDir; + private XMLElement element; + + public ParseContext(File file) { + super(); + this.file = file; + this.baseDir = file.getAbsoluteFile().getParentFile(); + } + + public XMLElement getImportElement() { + return element; + } + + void setElement(XMLElement element) { + this.element = element; + } + + public File getFile() { + return file; + } + + public File getBaseDir() { + return baseDir; + } + } + + private LinkedList<ParseContext> stack = new LinkedList<ParseContext>(); + + + public ConfigureScript loadScript(String fileName) throws ConfigureException { + final File file = new File(fileName); + stack.add(new ParseContext(file)); + try { + final XMLElement root = loadXML(file); + return parseScript(root, file); + } finally { + stack.removeLast(); + } + } + + private XMLElement loadXML(final File file) throws ConfigureException { + try { + final FileReader r = new FileReader(file); + try { + StdXMLReader xr = new StdXMLReader(r); + IXMLParser parser = XMLParserFactory.createDefaultXMLParser(); + parser.setReader(xr); + return (XMLElement) parser.parse(); + } finally { + r.close(); + } + } catch (FileNotFoundException ex) { + throw new ConfigureException("Cannot open " + file, ex); + } catch (IOException ex) { + throw new ConfigureException("IO error reading " + file, ex); + } catch (XMLException ex) { + throw new ConfigureException("XML error reading " + file, ex); + } catch (Exception ex) { + throw new ConfigureException("Unexpected error reading " + file, ex); + } + } + + private ConfigureScript parseScript(XMLElement root, File scriptFile) + throws ConfigureException { + ConfigureScript script = new ConfigureScript(scriptFile); + parseScript(root, script); + return script; + } + + private void parseScript(XMLElement root, ConfigureScript script) + throws ConfigureException { + if (!root.getName().equals(SCRIPT)) { + error("Root element of script file should be '" + SCRIPT + "'", root); + } + for (Enumeration<?> en = root.enumerateChildren(); en.hasMoreElements(); /**/ ) { + XMLElement element = (XMLElement) en.nextElement(); + String elementName = element.getName(); + if (elementName.equals(TYPE)) { + parseType(element, script); + } else if (elementName.equals(CONTROL_PROPS)) { + parseControlProps(element, script); + } else if (elementName.equals(PROP_FILE)) { + parsePropsFile(element, script); + } else if (elementName.equals(SCREEN)) { + parseScreen(element, script); + } else if (elementName.equals(INCLUDE)) { + parseInclude(element, script); + } else { + error("Unrecognized element '" + elementName + "'", element); + } + } + } + + public File resolvePath(String fileName) { + if (fileName == null) { + return null; + } + File res = new File(fileName); + if (!res.isAbsolute()) { + res = new File(stack.getLast().getBaseDir(), fileName); + } + return res; + } + + private void parseInclude(XMLElement element, ConfigureScript script) throws ConfigureException { + String includeFileName = element.getAttribute(SCRIPT_FILE, null); + if (includeFileName == null) { + error("A '" + SCRIPT_FILE + "' attribute is required for an '" + INCLUDE + "' element", element); + } + File includeFile = resolvePath(includeFileName); + XMLElement includeRoot = loadXML(includeFile); + stack.getLast().setElement(element); + stack.add(new ParseContext(includeFile)); + try { + parseScript(includeRoot, script); + } finally { + stack.removeLast(); + } + } + + private void parseType(XMLElement element, ConfigureScript script) + throws ConfigureException { + String name = element.getAttribute(NAME, null); + String patternString = element.getAttribute(PATTERN, null); + List<EnumeratedType.Alternate> alternates = + new LinkedList<EnumeratedType.Alternate>(); + for (Enumeration<?> en = element.enumerateChildren(); en.hasMoreElements(); /**/) { + XMLElement child = (XMLElement) en.nextElement(); + if (!child.getName().equals(ALT)) { + error("A '" + TYPE + "' element can only contain '" + ALT + "' elements", child); + } + String value = child.getAttribute(VALUE, null); + String token = child.getAttribute(TOKEN, value); + if (value == null) { + error("A '" + VALUE + "' attribute is required for an '" + ALT + "' element", child); + } + if (token.length() == 0) { + // An empty token is problematic because and empty input line is + // used to say "use the default value". + error("The (specified or implied) value of an '" + ALT + + "' element's '" + TOKEN + "' attribute cannot be empty", child); + } + alternates.add(new EnumeratedType.Alternate(token, value)); + } + PropertyType type = null; + if (patternString == null) { + if (alternates.isEmpty()) { + error("A '" + TYPE + "' element must have a '" + PATTERN + + "' attribute or '" + ALT + "' elements", element); + } else { + type = new EnumeratedType(name, alternates); + } + } else { + if (!alternates.isEmpty()) { + error("A '" + TYPE + "' element cannot have both a '" + PATTERN + + "' attribute and '" + ALT + "' elements", element); + } else { + try { + Pattern pattern = Pattern.compile(patternString); + String empty = element.getAttribute(EMPTY_TOKEN, null); + if (empty == null) { + if (pattern.matcher("").matches()) { + error("An '" + EMPTY_TOKEN + "' attribute is required because the '" + + PATTERN + "' attribute matches the empty string", element); + } + } else if (empty.length() == 0) { + error("The '" + EMPTY_TOKEN + "' attribute must not be an empty string", element); + } + type = new PatternType(name, pattern, empty); + } catch (PatternSyntaxException ex) { + error("Invalid '" + PATTERN + "' attribute: " + ex.getDescription(), element); + } + } + } + script.addType(type); + } + + private void parseControlProps(XMLElement element, ConfigureScript script) + throws ConfigureException { + PropertySet propSet = new PropertySet(script); + parseProperties(element, propSet, script); + script.setControlProps(propSet); + } + + private void parsePropsFile(XMLElement element, ConfigureScript script) + throws ConfigureException { + String propFileName = element.getAttribute(NAME, null); + if (propFileName == null) { + error("A '" + PROP_FILE + "' element requires a '" + NAME + "' attribute", element); + } + File propFile = resolvePath(propFileName); + String defaultPropFileName = element.getAttribute(DEFAULT_FILE, null); + File defaultPropFile = resolvePath(defaultPropFileName); + String fileFormat = element.getAttribute(FILE_FORMAT, FileAdapter.JAVA_PROPERTIES_FORMAT); + String templateFileName = element.getAttribute(TEMPLATE_FILE, null); + File templateFile = resolvePath(templateFileName); + String markerStr = element.getAttribute(MARKER, DEFAULT_MARKER); + if (markerStr.length() != 1) { + error("A '" + MARKER + "' attribute must be one character in length", element); + } + char marker = markerStr.charAt(0); + if (marker == '\n' || marker == '\r') { + error("This marker character won't work", element); + } + PropertySet propSet; + try { + propSet = new PropertySet( + script, propFile, defaultPropFile, templateFile, fileFormat, marker); + } catch (ConfigureException ex) { + addStack(ex, element); + throw ex; + } + parseProperties(element, propSet, script); + script.addPropsFile(propSet); + } + + private PropertySet parseProperties(XMLElement element, PropertySet propSet, ConfigureScript script) + throws ConfigureException { + for (Enumeration<?> en = element.enumerateChildren(); en.hasMoreElements(); /**/) { + XMLElement child = (XMLElement) en.nextElement(); + if (child.getName().equals(PROPERTY)) { + String name = child.getAttribute(NAME, null); + if (name == null) { + error("A '" + PROPERTY + "' element requires a '" + NAME + "' attribute", child); + } + String typeName = child.getAttribute(TYPE, null); + if (name == null) { + error("A '" + PROPERTY + "' element requires a '" + TYPE + "' attribute", child); + } + String description = child.getAttribute(DESCRIPTION, null); + if (name == null) { + error("A '" + PROPERTY + "' element requires a '" + DESCRIPTION + "' attribute", child); + } + String defaultValue = child.getAttribute(DEFAULT, null); + PropertyType type = script.getTypes().get(typeName); + if (type == null) { + error("Use of undeclared type '" + typeName + "'", child); + } + Value value = defaultValue == null ? null : type.fromValue(defaultValue); + try { + propSet.addProperty(name, type, description, value, child, stack.getLast().getFile()); + } catch (ConfigureException ex) { + addStack(ex, child); + throw ex; + } + } else { + error("Expected only '" + PROPERTY + "' elements in this context", element); + } + } + return propSet; + } + + private void parseScreen(XMLElement element, ConfigureScript script) + throws ConfigureException { + String title = element.getAttribute(TITLE, null); + if (title == null) { + error("A '" + SCREEN + "' element requires a '" + TITLE + "' attribute", element); + } + String guardPropName = element.getAttribute(GUARD_PROP, null); + String valueIsStr = element.getAttribute(VALUE_IS, null); + String valueIsNotStr = element.getAttribute(VALUE_IS_NOT, null); + + Value valueIs = null; + Value valueIsNot = null; + if (guardPropName != null) { + Property guardProp = script.getProperty(guardPropName); + if (guardProp == null) { + error("A guard property '" + guardPropName + "' not declared", element); + } + if (valueIsStr != null && valueIsNotStr != null) { + error("The '" + VALUE_IS + "' and '" + VALUE_IS_NOT + + "' attributes cannot be used together", element); + } + PropertyType type = guardProp.getType(); + if (valueIsStr != null) { + valueIs = type.fromValue(valueIsStr); + if (valueIs == null) { + error("The string '" + valueIsStr + "' is not a valid " + + type.getTypeName() + " instance", element); + } + } + if (valueIsNotStr != null) { + valueIsNot = type.fromValue(valueIsNotStr); + if (valueIsNot == null) { + error("The string '" + valueIsNotStr + "' is not a valid " + + type.getTypeName() + " instance", element); + } + } + } + Screen screen = new Screen(title, guardPropName, valueIs, valueIsNot); + script.addScreen(screen); + for (Enumeration<?> en = element.enumerateChildren(); en.hasMoreElements(); /**/ ) { + XMLElement child = (XMLElement) en.nextElement(); + if (!child.getName().equals(ITEM)) { + error("Expected an '" + ITEM + "' element", child); + } + String propName = child.getAttribute(PROPERTY, null); + if (propName == null) { + error("The '" + PROPERTY + "' attribute is required for an '" + + ITEM + "' element", child); + } + if (script.getProperty(propName) == null) { + error("Use of undeclared property '" + propName + "'", child); + } + String text = child.getContent(); + screen.addItem(new Item(script, propName, text)); + } + } + + private void addStack(ConfigureException ex, XMLElement element) { + stack.getLast().setElement(element); + ParseContext[] stackCopy = new ParseContext[stack.size()]; + stack.toArray(stackCopy); + ex.setStack(stackCopy); + } + + private void error(String message, XMLElement element) throws ConfigureException { + ConfigureException ex = new ConfigureException(message); + addStack(ex, element); + throw ex; + } +} Added: trunk/distr/src/configure/org/jnode/configure/adapter/BasePropertyFileAdapter.java =================================================================== --- trunk/distr/src/configure/org/jnode/configure/adapter/BasePropertyFileAdapter.java (rev 0) +++ trunk/distr/src/configure/org/jnode/configure/adapter/BasePropertyFileAdapter.java 2008-07-12 06:25:41 UTC (rev 4301) @@ -0,0 +1,235 @@ +/* + * $Id $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library 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 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jnode.configure.adapter; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.util.Map; +import java.util.Properties; + +import org.jnode.configure.Configure; +import org.jnode.configure.ConfigureException; +import org.jnode.configure.PropertySet; +import org.jnode.configure.PropertyType; +import org.jnode.configure.PropertySet.Property; + +/** + * This is a base class for File adapters that uses {@link java.util.Properties} + * objects as an intermediate representation. + * + * @author cr...@jn... + */ +public abstract class BasePropertyFileAdapter implements FileAdapter { + + interface ValueCodec { + public String encodeText(String raw) throws ConfigureException; + public String decodeText(String encoded) throws ConfigureException; + } + + private final ValueCodec codec; + private final boolean loadSupported; + private final boolean saveSupported; + + protected abstract void loadFromFile(Properties props, InputStream imput) + throws IOException; + + protected abstract void saveToFile(Properties props, OutputStream output, String comment) + throws IOException; + + public BasePropertyFileAdapter(ValueCodec codec, boolean loadSupported, boolean saveSupported) { + super(); + this.codec = codec; + this.loadSupported = loadSupported; + this.saveSupported = saveSupported; + } + + public boolean isLoadSupported() { + return loadSupported; + } + + public boolean isSaveSupported() { + return saveSupported; + } + + public void load(PropertySet propSet, Configure configure) throws ConfigureException { + File file = propSet.getFile(); + File defaultFile = propSet.getDefaultFile(); + Properties properties = new Properties(); + if (loadSupported) { + InputStream in = null; + try { + if (!file.exists() && defaultFile != null) { + if (defaultFile.exists()) { + configure.output("Taking initial values for the '" + file + + "' properties from '" + defaultFile + "'."); + file = defaultFile; + } + } + in = new BufferedInputStream(new FileInputStream(file)); + loadFromFile(properties, in); + } catch (FileNotFoundException ex) { + // Fall back to the builtin default property values + configure.output("Taking initial values for the '" + file + + "' properties from the builtin defaults."); + } catch (IOException ex) { + throw new ConfigureException( + "Problem loading properties from '" + file + "'.", ex); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException ex) { + // ignore + } + } + } + } + for (Object key : properties.keySet()) { + String value = (String) properties.get(key); + Property prop = propSet.getProperty((String) key); + if (prop != null) { + PropertyType type = prop.getType(); + prop.setDefaultValue(type.fromValue(value)); + } + } + } + + public void save(PropertySet propSet, Configure configure) throws ConfigureException { + // Harvest the properties to be written into a Properties Object + Properties properties = new Properties(); + for (Map.Entry<String, Property> entry : propSet.getProperties().entrySet()) { + Property prop = entry.getValue(); + properties.setProperty(entry.getKey(), prop.getValue().getText()); + } + OutputStream os = null; + InputStream is = null; + File toFile = propSet.getFile(); + File templateFile = propSet.getTemplateFile(); + try { + os = new FileOutputStream(toFile); + if (templateFile == null && saveSupported) { + saveToFile(properties, new BufferedOutputStream(os), + "Expanded by JNode 'configure' tool"); + } else { + try { + is = new FileInputStream(templateFile); + } catch (FileNotFoundException ex) { + throw new ConfigureException("Cannot read template file", ex); + } + expandToTemplate(properties, is, os, propSet.getMarker(), templateFile); + } + ... [truncated message content] |