本文整理汇总了Java中org.alfresco.service.cmr.repository.datatype.Duration类的典型用法代码示例。如果您正苦于以下问题:Java Duration类的具体用法?Java Duration怎么用?Java Duration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Duration类属于org.alfresco.service.cmr.repository.datatype包,在下文中一共展示了Duration类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getModel
import org.alfresco.service.cmr.repository.datatype.Duration; //导入依赖的package包/类
/**
* Get the non-contextual model.
*
* This defines:
* <ol>
* <li>dates: date, today, yesterday, tomorrow
* <li>functions: luceneDateRange, selectSingleNode
* </ol>
*/
public Map<String, Object> getModel()
{
GregorianCalendar cal = new GregorianCalendar();
cal.set(Calendar.HOUR, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
HashMap<String, Object> model = new HashMap<String, Object>();
model.put("date", new Date());
Date today = cal.getTime();
model.put("today", today);
model.put("yesterday", Duration.add(today, new Duration("-P1D")));
model.put("tomorrow", Duration.add(today, new Duration("P1D")));
model.put("luceneDateRange", new LuceneDateRangeFunction());
model.put("selectSingleNode", new QueryForSingleNodeFunction());
return model;
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:35,代码来源:FreeMarkerWithLuceneExtensionsModelFactory.java
示例2: getOrderProperties
import org.alfresco.service.cmr.repository.datatype.Duration; //导入依赖的package包/类
/**
* @return properties
*/
public Map<QName, Serializable> getOrderProperties()
{
Map<QName, Serializable> testProperties = new HashMap<QName, Serializable>();
testProperties.put(CREATED_DATE, orderDate);
testProperties.put(ORDER_DOUBLE, orderDoubleCount);
testProperties.put(ORDER_FLOAT, orderFloatCount);
testProperties.put(ORDER_LONG, orderLongCount);
testProperties.put(ORDER_INT, orderIntCount);
testProperties.put(ORDER_TEXT, new String(new char[] { (char) ('a' + orderTextCount) }) + " cabbage");
MLText mlText = new MLText();
mlText.addValue(Locale.ENGLISH, new String(new char[] { (char) ('a' + orderTextCount) }) + " banana");
mlText.addValue(Locale.FRENCH, new String(new char[] { (char) ('Z' - orderTextCount) }) + " banane");
mlText.addValue(Locale.CHINESE, new String(new char[] { (char) ('香' + orderTextCount) }) + " 香蕉");
testProperties.put(ORDER_ML_TEXT, mlText);
orderDate = Duration.subtract(orderDate, new Duration("P1D"));
orderDoubleCount += 0.1d;
orderFloatCount += 0.82f;
orderLongCount += 299999999999999l;
orderIntCount += 8576457;
orderTextCount++;
return testProperties;
}
示例3: getNewTicket
import org.alfresco.service.cmr.repository.datatype.Duration; //导入依赖的package包/类
@Override
public String getNewTicket(String userName) throws AuthenticationException
{
Ticket ticket = null;
if(useSingleTicketPerUser)
{
ticket = findNonExpiredUserTicket(userName);
}
if(ticket == null)
{
Date expiryDate = null;
if (ticketsExpire)
{
expiryDate = Duration.add(new Date(), validDuration);
}
ticket = new Ticket(ticketsExpire ? expiryMode : ExpiryMode.DO_NOT_EXPIRE, expiryDate, userName, validDuration);
ticketsCache.put(ticket.getTicketId(), ticket);
}
String ticketString = GRANTED_AUTHORITY_TICKET_PREFIX + ticket.getTicketId();
currentTicket.set(ticketString);
return ticketString;
}
示例4: getOrderProperties
import org.alfresco.service.cmr.repository.datatype.Duration; //导入依赖的package包/类
/**
* @return properties
*/
public Map<QName, Serializable> getOrderProperties()
{
Map<QName, Serializable> testProperties = new HashMap<QName, Serializable>();
testProperties.put(createdDate, orderDate);
testProperties.put(orderDouble, orderDoubleCount);
testProperties.put(orderFloat, orderFloatCount);
testProperties.put(orderLong, orderLongCount);
testProperties.put(orderInt, orderIntCount);
testProperties.put(orderText, new String(new char[] { (char) ('a' + orderTextCount) }) + " cabbage");
MLText mlText = new MLText();
mlText.addValue(Locale.ENGLISH, new String(new char[] { (char) ('a' + orderTextCount) }) + " banana");
mlText.addValue(Locale.FRENCH, new String(new char[] { (char) ('Z' - orderTextCount) }) + " banane");
mlText.addValue(Locale.CHINESE, new String(new char[] { (char) ('香' + orderTextCount) }) + " 香蕉");
testProperties.put(orderMLText, mlText);
orderDate = Duration.subtract(orderDate, new Duration("P1D"));
orderDoubleCount += 0.1d;
orderFloatCount += 0.82f;
orderLongCount += 299999999999999l;
orderIntCount += 8576457;
orderTextCount++;
return testProperties;
}
示例5: Ticket
import org.alfresco.service.cmr.repository.datatype.Duration; //导入依赖的package包/类
private Ticket(ExpiryMode expires, Date expiryDate, String userName, Duration validDuration, String ticketId)
{
this.expires = expires;
this.expiryDate = expiryDate;
this.userName = userName;
this.validDuration = validDuration;
Duration tenPercent = validDuration.divide(10);
this.testDuration = validDuration.subtract(tenPercent);
this.ticketId = ticketId;
}
示例6: getNewEntry
import org.alfresco.service.cmr.repository.datatype.Duration; //导入依赖的package包/类
Ticket getNewEntry()
{
switch (expires)
{
case AFTER_FIXED_TIME:
if (hasExpired(new Date()))
{
return null;
}
else
{
return this;
}
case AFTER_INACTIVITY:
Date now = new Date();
if (hasExpired(now))
{
return null;
}
else
{
Duration remaining = new Duration(now, expiryDate);
if(remaining.compareTo(testDuration) < 0)
{
return new Ticket(expires, Duration.add(now, validDuration), userName, validDuration, ticketId);
}
else
{
return this;
}
}
case DO_NOT_EXPIRE:
default:
return this;
}
}
示例7: getNextDate
import org.alfresco.service.cmr.repository.datatype.Duration; //导入依赖的package包/类
public Date getNextDate(Date date, String expression)
{
Duration d = new Duration(expression);
return Duration.add(date, d);
}
示例8: setValidDuration
import org.alfresco.service.cmr.repository.datatype.Duration; //导入依赖的package包/类
/**
* How long are tickets valid (XML duration as a string)
*/
public void setValidDuration(String validDuration)
{
this.validDuration = new Duration(validDuration);
}
示例9: getOrderProperties
import org.alfresco.service.cmr.repository.datatype.Duration; //导入依赖的package包/类
private Map<QName, PropertyValue> getOrderProperties()
{
double orderDoubleCount = -0.11d + orderTextCount * ((orderTextCount % 2 == 0) ? 0.1d : -0.1d);
float orderFloatCount = -3.5556f + orderTextCount * ((orderTextCount % 2 == 0) ? 0.82f : -0.82f);
long orderLongCount = -1999999999999999l + orderTextCount
* ((orderTextCount % 2 == 0) ? 299999999999999l : -299999999999999l);
int orderIntCount = -45764576 + orderTextCount * ((orderTextCount % 2 == 0) ? 8576457 : -8576457);
Map<QName, PropertyValue> testProperties = new HashMap<QName, PropertyValue>();
testProperties.put(createdDate,
new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderDate)));
testProperties.put(createdTime,
new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderDate)));
testProperties.put(orderDouble,
new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderDoubleCount)));
testProperties.put(orderFloat,
new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderFloatCount)));
testProperties.put(orderLong,
new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderLongCount)));
testProperties.put(orderInt,
new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderIntCount)));
testProperties.put(
orderText,
new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, new String(
new char[] { (char) ('l' + ((orderTextCount % 2 == 0) ? orderTextCount
: -orderTextCount)) })
+ " cabbage")));
testProperties.put(ContentModel.PROP_NAME, new StringPropertyValue(orderNames[orderTextCount]));
testProperties.put(orderLocalisedText, new StringPropertyValue(orderLocalisedNames[orderTextCount]));
MLTextPropertyValue mlTextPropLocalisedOrder = new MLTextPropertyValue();
if (orderLocaliseMLText_en[orderTextCount].length() > 0)
{
mlTextPropLocalisedOrder.addValue(Locale.ENGLISH, orderLocaliseMLText_en[orderTextCount]);
}
if (orderLocaliseMLText_fr[orderTextCount].length() > 0)
{
mlTextPropLocalisedOrder.addValue(Locale.FRENCH, orderLocaliseMLText_fr[orderTextCount]);
}
if (orderLocaliseMLText_es[orderTextCount].length() > 0)
{
mlTextPropLocalisedOrder.addValue(new Locale("es"), orderLocaliseMLText_es[orderTextCount]);
}
if (orderLocaliseMLText_de[orderTextCount].length() > 0)
{
mlTextPropLocalisedOrder.addValue(Locale.GERMAN, orderLocaliseMLText_de[orderTextCount]);
}
testProperties.put(orderLocalisedMLText, mlTextPropLocalisedOrder);
MLTextPropertyValue mlTextPropVal = new MLTextPropertyValue();
mlTextPropVal.addValue(Locale.ENGLISH, new String(
new char[] { (char) ('l' + ((orderTextCount % 2 == 0) ? orderTextCount : -orderTextCount)) })
+ " banana");
mlTextPropVal.addValue(Locale.FRENCH, new String(
new char[] { (char) ('L' + ((orderTextCount % 2 == 0) ? -orderTextCount : orderTextCount)) })
+ " banane");
mlTextPropVal.addValue(Locale.CHINESE, new String(
new char[] { (char) ('香' + ((orderTextCount % 2 == 0) ? orderTextCount : -orderTextCount)) })
+ " 香蕉");
testProperties.put(orderMLText, mlTextPropVal);
orderDate = Duration.subtract(orderDate, new Duration("P1D"));
orderTextCount++;
return testProperties;
}
示例10: exec
import org.alfresco.service.cmr.repository.datatype.Duration; //导入依赖的package包/类
public Object exec(List args) throws TemplateModelException
{
if (args.size() == 2)
{
Object arg0 = args.get(0);
Object arg1 = args.get(1);
Date startDate = null;
Date endDate = null;
if (arg0 instanceof TemplateDateModel)
{
startDate = (Date) ((TemplateDateModel) arg0).getAsDate();
}
else if (arg0 instanceof TemplateScalarModel)
{
String startDateString = ((TemplateScalarModel) arg0).getAsString();
startDate = ISO8601DateFormat.parse(startDateString);
}
else
{
throw new TemplateModelException("Invalid date entry");
}
if (arg1 instanceof TemplateDateModel)
{
endDate = (Date) ((TemplateDateModel) arg0).getAsDate();
}
else if (arg1 instanceof TemplateScalarModel)
{
String valueString = ((TemplateScalarModel) arg1).getAsString();
try
{
Duration duration = new Duration(valueString);
endDate = Duration.add(startDate, duration);
}
catch (Exception e)
{
endDate = ISO8601DateFormat.parse(valueString);
}
}
else
{
throw new TemplateModelException("Invalid date entry");
}
if (startDate.compareTo(endDate) > 0)
{
Date temp = startDate;
startDate = endDate;
endDate = temp;
}
StringBuilder builder = new StringBuilder();
builder.append("[");
builder.append(DefaultTypeConverter.INSTANCE.convert(String.class, startDate));
builder.append(" TO ");
builder.append(DefaultTypeConverter.INSTANCE.convert(String.class, endDate));
builder.append("]");
return builder.toString();
}
else
{
throw new TemplateModelException("Invalid date entry");
}
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:72,代码来源:FreeMarkerWithLuceneExtensionsModelFactory.java
示例11: getOrderProperties
import org.alfresco.service.cmr.repository.datatype.Duration; //导入依赖的package包/类
private Map<QName, PropertyValue> getOrderProperties()
{
double orderDoubleCount = -0.11d + orderTextCount * ((orderTextCount % 2 == 0) ? 0.1d : -0.1d);
float orderFloatCount = -3.5556f + orderTextCount * ((orderTextCount % 2 == 0) ? 0.82f : -0.82f);
long orderLongCount = -1999999999999999l + orderTextCount * ((orderTextCount % 2 == 0) ? 299999999999999l : -299999999999999l);
int orderIntCount = -45764576 + orderTextCount * ((orderTextCount % 2 == 0) ? 8576457 : -8576457);
Map<QName, PropertyValue> testProperties = new HashMap<QName, PropertyValue>();
testProperties.put(createdDate, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderDate)));
testProperties.put(createdTime, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderDate)));
testProperties.put(orderDouble, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderDoubleCount)));
testProperties.put(orderFloat, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderFloatCount)));
testProperties.put(orderLong, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderLongCount)));
testProperties.put(orderInt, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderIntCount)));
testProperties.put(
orderText,
new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, new String(new char[] { (char) ('l' + ((orderTextCount % 2 == 0) ? orderTextCount
: -orderTextCount)) }) + " cabbage")));
testProperties.put(ContentModel.PROP_NAME, new StringPropertyValue(orderNames[orderTextCount]));
testProperties.put(orderLocalisedText, new StringPropertyValue(orderLocalisedNames[orderTextCount]));
MLTextPropertyValue mlTextPropLocalisedOrder = new MLTextPropertyValue();
if (orderLocaliseMLText_en[orderTextCount].length() > 0)
{
mlTextPropLocalisedOrder.addValue(Locale.ENGLISH, orderLocaliseMLText_en[orderTextCount]);
}
if (orderLocaliseMLText_fr[orderTextCount].length() > 0)
{
mlTextPropLocalisedOrder.addValue(Locale.FRENCH, orderLocaliseMLText_fr[orderTextCount]);
}
if (orderLocaliseMLText_es[orderTextCount].length() > 0)
{
mlTextPropLocalisedOrder.addValue(new Locale("es"), orderLocaliseMLText_es[orderTextCount]);
}
if (orderLocaliseMLText_de[orderTextCount].length() > 0)
{
mlTextPropLocalisedOrder.addValue(Locale.GERMAN, orderLocaliseMLText_de[orderTextCount]);
}
testProperties.put(orderLocalisedMLText, mlTextPropLocalisedOrder);
MLTextPropertyValue mlTextPropVal = new MLTextPropertyValue();
mlTextPropVal.addValue(Locale.ENGLISH, new String(new char[] { (char) ('l' + ((orderTextCount % 2 == 0) ? orderTextCount : -orderTextCount)) }) + " banana");
mlTextPropVal.addValue(Locale.FRENCH, new String(new char[] { (char) ('L' + ((orderTextCount % 2 == 0) ? -orderTextCount : orderTextCount)) }) + " banane");
mlTextPropVal.addValue(Locale.CHINESE, new String(new char[] { (char) ('香' + ((orderTextCount % 2 == 0) ? orderTextCount : -orderTextCount)) }) + " 香蕉");
testProperties.put(orderMLText, mlTextPropVal);
orderDate = Duration.subtract(orderDate, new Duration("P1D"));
orderTextCount++;
return testProperties;
}