001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * bstefanescu 011 */ 012package org.nuxeo.ecm.automation.core.scripting; 013 014import java.util.Calendar; 015import java.util.Date; 016 017import org.apache.commons.lang.StringEscapeUtils; 018import org.nuxeo.ecm.automation.context.ContextHelper; 019 020/** 021 * The functions exposed by the core library. You may want to extend this class to expose more functions under the "Fn" 022 * context variable for scripting expressions. 023 * 024 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 025 */ 026public class CoreFunctions implements ContextHelper { 027 028 public DateWrapper date(Date date) { 029 return new DateWrapper(date); 030 } 031 032 public DateWrapper calendar(Calendar date) { 033 return new DateWrapper(date); 034 } 035 036 public String escapeHtml(Object obj) { 037 return StringEscapeUtils.escapeHtml(obj.toString()); 038 } 039 040}