[jboss-svn-commits] JBL Code SVN: r6125 - labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Sep 8 11:57:08 EDT 2006
Author: wrzep
Date: 2006-09-08 11:57:04 -0400 (Fri, 08 Sep 2006)
New Revision: 6125
Added:
labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/AddPlugin.java
labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/ConstPlugin.java
labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/DivPlugin.java
labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/MathPlugin.java
labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/MulPlugin.java
Log:
JBLAB-599
Terribly simple plugins providing basic math operations.
Pawel
Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/AddPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/AddPlugin.java 2006-09-08 15:28:32 UTC (rev 6124)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/AddPlugin.java 2006-09-08 15:57:04 UTC (rev 6125)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.forge.status.plugins.math;
+
+/**
+* @author Pawel Wrzeszcz (pawel . wrzeszcz [at] jboss . com)
+*/
+
+public class AddPlugin extends MathPlugin {
+
+ @Override
+ public long getValue(String projectId) {
+
+ long v1 = plugin1.getValue(projectId);
+ long v2 = plugin2.getValue(projectId);
+
+ return (v1 + v2);
+
+ }
+}
Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/ConstPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/ConstPlugin.java 2006-09-08 15:28:32 UTC (rev 6124)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/ConstPlugin.java 2006-09-08 15:57:04 UTC (rev 6125)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.forge.status.plugins.math;
+
+import java.util.Properties;
+
+import org.jboss.forge.common.projects.Projects;
+import org.jboss.forge.status.exceptions.InvalidPluginPropertiesException;
+import org.jboss.forge.status.plugins.Plugin;
+import org.jboss.forge.status.service.ScoresManager;
+import org.jboss.forge.status.tools.Plugins;
+
+/**
+* @author Pawel Wrzeszcz (pawel . wrzeszcz [at] jboss . com)
+*/
+
+public class ConstPlugin extends Plugin {
+
+ private long value;
+
+ @Override
+ public void init(String id, String portalName, Projects projects,
+ Plugins plugins, Properties properties, ScoresManager scoresManager)
+ throws InvalidPluginPropertiesException {
+
+ if ((properties == null) || (!properties.contains("value")) ){
+ throw new InvalidPluginPropertiesException(
+ "Missing plugin property.");
+ }
+
+ String valueString = properties.getProperty("value");
+
+ value = Long.parseLong(valueString);
+
+ super.init(id, portalName, projects, plugins,
+ properties, scoresManager);
+ }
+
+ @Override
+ public long getValue(String projectId) {
+
+ return value;
+ }
+}
Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/DivPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/DivPlugin.java 2006-09-08 15:28:32 UTC (rev 6124)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/DivPlugin.java 2006-09-08 15:57:04 UTC (rev 6125)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.forge.status.plugins.math;
+
+/**
+* @author Pawel Wrzeszcz (pawel . wrzeszcz [at] jboss . com)
+*/
+
+public class DivPlugin extends MathPlugin {
+
+ @Override
+ public long getValue(String projectId) {
+
+ long v2 = plugin2.getValue(projectId);
+
+ if (v2 == 0) {
+ return 0;
+ }
+
+ long v1 = plugin1.getValue(projectId);
+
+ return (v1 / v2);
+
+ }
+}
Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/MathPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/MathPlugin.java 2006-09-08 15:28:32 UTC (rev 6124)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/MathPlugin.java 2006-09-08 15:57:04 UTC (rev 6125)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.forge.status.plugins.math;
+
+import java.util.Properties;
+
+import org.jboss.forge.common.projects.Projects;
+import org.jboss.forge.status.exceptions.InvalidPluginPropertiesException;
+import org.jboss.forge.status.plugins.Plugin;
+import org.jboss.forge.status.service.ScoresManager;
+import org.jboss.forge.status.tools.Plugins;
+
+/**
+* @author Pawel Wrzeszcz (pawel . wrzeszcz [at] jboss . com)
+*/
+
+public abstract class MathPlugin extends Plugin {
+
+ protected Plugin plugin1;
+ protected Plugin plugin2;
+
+ @Override
+ public void init(String id, String portalName, Projects projects,
+ Plugins plugins, Properties properties, ScoresManager scoresManager)
+ throws InvalidPluginPropertiesException {
+
+ if (properties == null) {
+ throw new InvalidPluginPropertiesException(
+ "Missing plugin properties.");
+ }
+
+ String plugin1Id = properties.getProperty("plugin1");
+ String plugin2Id = properties.getProperty("plugin2");
+
+ if ((plugin1Id == null) || (plugin2Id == null)) {
+ throw new InvalidPluginPropertiesException(
+ "Invalid plugin properties.");
+ }
+
+ plugin1 = plugins.get(plugin1Id);
+ plugin2 = plugins.get(plugin2Id);
+
+ super.init(id, portalName, projects, plugins,
+ properties, scoresManager);
+ }
+
+}
Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/MulPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/MulPlugin.java 2006-09-08 15:28:32 UTC (rev 6124)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/math/MulPlugin.java 2006-09-08 15:57:04 UTC (rev 6125)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.forge.status.plugins.math;
+
+/**
+* @author Pawel Wrzeszcz (pawel . wrzeszcz [at] jboss . com)
+*/
+
+public class MulPlugin extends MathPlugin {
+
+ @Override
+ public long getValue(String projectId) {
+
+ long v1 = plugin1.getValue(projectId);
+ long v2 = plugin2.getValue(projectId);
+
+ return (v1 * v2);
+
+ }
+}
More information about the jboss-svn-commits
mailing list