Author: sdumitriu Date: 2007-10-24 18:12:46 +0200 (Wed, 24 Oct 2007) New Revision: 5490
Added: xwiki-platform/xwiki-plugins/trunk/jodatime/ xwiki-platform/xwiki-plugins/trunk/jodatime/pom.xml xwiki-platform/xwiki-plugins/trunk/jodatime/src/ xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/ xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/java/ xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/java/com/ xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/java/com/xpn/ xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/java/com/xpn/xwiki/ xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/java/com/xpn/xwiki/plugin/ xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/java/com/xpn/xwiki/plugin/jodatime/ xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/java/com/xpn/xwiki/plugin/jodatime/JodaTimePlugin.java xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/java/com/xpn/xwiki/plugin/jodatime/JodaTimePluginApi.java Modified: xwiki-platform/xwiki-plugins/trunk/pom.xml Log: XWIKI-1820: Joda Time Plugin Initial implementation Patch submitted by Marius Florea, applied with changes. Added: xwiki-platform/xwiki-plugins/trunk/jodatime/pom.xml =================================================================== --- xwiki-platform/xwiki-plugins/trunk/jodatime/pom.xml (rev 0) +++ xwiki-platform/xwiki-plugins/trunk/jodatime/pom.xml 2007-10-24 16:12:46 UTC (rev 5490) @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + * + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * 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. + * +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <parent> + <artifactId>xwiki-plugins</artifactId> + <groupId>com.xpn.xwiki.platform.plugins</groupId> + <version>2-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>xwiki-plugin-jodatime</artifactId> + <name>XWiki Platform - Plugins - Joda Time</name> + <version>0.1-SNAPSHOT</version> + <description>XWiki Platform - Plugins - Joda Time</description> + <dependencies> + <dependency> + <groupId>com.xpn.xwiki.platform</groupId> + <artifactId>xwiki-core</artifactId> + <version>1.2-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>joda-time</groupId> + <artifactId>joda-time</artifactId> + <version>1.4</version> + </dependency> + </dependencies> +</project> \ No newline at end of file Added: xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/java/com/xpn/xwiki/plugin/jodatime/JodaTimePlugin.java =================================================================== --- xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/java/com/xpn/xwiki/plugin/jodatime/JodaTimePlugin.java (rev 0) +++ xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/java/com/xpn/xwiki/plugin/jodatime/JodaTimePlugin.java 2007-10-24 16:12:46 UTC (rev 5490) @@ -0,0 +1,84 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * 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 com.xpn.xwiki.plugin.jodatime; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.xpn.xwiki.XWikiContext; +import com.xpn.xwiki.api.Api; +import com.xpn.xwiki.plugin.XWikiDefaultPlugin; +import com.xpn.xwiki.plugin.XWikiPluginInterface; + +/** + * Plugin for manipulating dates from velocity scripts inside xwiki documents. It is based on the + * JodaTime framework ([EMAIL PROTECTED] http://joda-time.sourceforge.net/}), a quality replacement for the + * Java date and time classes. + * + * @see JodaTimePluginApi + */ +public class JodaTimePlugin extends XWikiDefaultPlugin +{ + /** + * Log object to log messages in this class. + */ + private static final Log LOG = LogFactory.getLog(JodaTimePlugin.class); + + /** + * [EMAIL PROTECTED] + * + * @see XWikiDefaultPlugin#XWikiDefaultPlugin(String,String,com.xpn.xwiki.XWikiContext) + */ + public JodaTimePlugin(String name, String className, XWikiContext context) + { + super(name, className, context); + init(context); + } + + /** + * [EMAIL PROTECTED] + * + * @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#getName() + */ + public String getName() + { + LOG.debug("getName()"); + return "jodatime"; + } + + /** + * [EMAIL PROTECTED] + * + * @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#getPluginApi + */ + public Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context) + { + return new JodaTimePluginApi((JodaTimePlugin) plugin, context); + } + + /** + * [EMAIL PROTECTED] + */ + public void init(XWikiContext context) + { + super.init(context); + } +} Property changes on: xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/java/com/xpn/xwiki/plugin/jodatime/JodaTimePlugin.java ___________________________________________________________________ Name: svn:eol-style + native Added: xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/java/com/xpn/xwiki/plugin/jodatime/JodaTimePluginApi.java =================================================================== --- xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/java/com/xpn/xwiki/plugin/jodatime/JodaTimePluginApi.java (rev 0) +++ xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/java/com/xpn/xwiki/plugin/jodatime/JodaTimePluginApi.java 2007-10-24 16:12:46 UTC (rev 5490) @@ -0,0 +1,144 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * 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 com.xpn.xwiki.plugin.jodatime; + +import java.util.Locale; + +import org.joda.time.DateTime; +import org.joda.time.MutableDateTime; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + +import com.xpn.xwiki.XWikiContext; +import com.xpn.xwiki.api.Api; + +/** + * Api for the JodaTimePlugin + */ +public class JodaTimePluginApi extends Api +{ + /** + * the plugin instance + */ + private JodaTimePlugin plugin; + + public JodaTimePluginApi(JodaTimePlugin plugin, XWikiContext context) + { + super(context); + setPlugin(plugin); + } + + /** + * @see #plugin + */ + public JodaTimePlugin getPlugin() + { + return plugin; + } + + /** + * @see #plugin + */ + public void setPlugin(JodaTimePlugin plugin) + { + this.plugin = plugin; + } + + /** + * @see org.joda.time.DateTime#DateTime() + */ + public DateTime getDateTime() + { + return new DateTime(); + } + + /** + * @see org.joda.time.DateTime#DateTime(int, int, int, int, int, int, int) + */ + public DateTime getDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, + int minuteOfHour, int secondOfMinute, int millisOfSecond) + { + return new DateTime(year, + monthOfYear, + dayOfMonth, + hourOfDay, + minuteOfHour, + secondOfMinute, + millisOfSecond); + } + + /** + * @see org.joda.time.DateTime#DateTime(long) + */ + public DateTime getDateTime(long instant) + { + return new DateTime(instant); + } + + /** + * @see org.joda.time.MutableDateTime#MutableDateTime() + */ + public MutableDateTime getMutableDateTime() + { + return new MutableDateTime(); + } + + /** + * @see org.joda.time.MutableDateTime#MutableDateTime(int, int, int, int, int, int, int) + */ + public MutableDateTime getMutableDateTime(int year, int monthOfYear, int dayOfMonth, + int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) + { + return new MutableDateTime(year, + monthOfYear, + dayOfMonth, + hourOfDay, + minuteOfHour, + secondOfMinute, + millisOfSecond); + } + + /** + * @see org.joda.time.MutableDateTime#MutableDateTime(long) + */ + public MutableDateTime getMutableDateTime(long instant) + { + return new MutableDateTime(instant); + } + + /** + * @see org.joda.time.format.DateTimeFormat#forPattern(String) + */ + public DateTimeFormatter getDateTimeFormatterForPattern(String pattern) + { + return DateTimeFormat.forPattern(pattern).withLocale( + (Locale) getXWikiContext().get("locale")); + } + + /** + * @see org.joda.time.format.DateTimeFormat#forStyle(String) + */ + public DateTimeFormatter getDateTimeFormatterForStyle(String style) + { + return DateTimeFormat.forStyle(style) + .withLocale((Locale) getXWikiContext().get("locale")); + } +} Property changes on: xwiki-platform/xwiki-plugins/trunk/jodatime/src/main/java/com/xpn/xwiki/plugin/jodatime/JodaTimePluginApi.java ___________________________________________________________________ Name: svn:eol-style + native Modified: xwiki-platform/xwiki-plugins/trunk/pom.xml =================================================================== --- xwiki-platform/xwiki-plugins/trunk/pom.xml 2007-10-24 12:53:19 UTC (rev 5489) +++ xwiki-platform/xwiki-plugins/trunk/pom.xml 2007-10-24 16:12:46 UTC (rev 5490) @@ -52,6 +52,7 @@ <module>adwords</module> <module>alexa</module> <module>exoplatform</module> + <module>jodatime</module> <module>scheduler</module> <module>application-manager</module> <module>wiki-manager</module> _______________________________________________ notifications mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/notifications
