当前位置: 首页>>代码示例>>Java>>正文


Java Duration.add方法代码示例

本文整理汇总了Java中org.alfresco.service.cmr.repository.datatype.Duration.add方法的典型用法代码示例。如果您正苦于以下问题:Java Duration.add方法的具体用法?Java Duration.add怎么用?Java Duration.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.service.cmr.repository.datatype.Duration的用法示例。


在下文中一共展示了Duration.add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:25,代码来源:InMemoryTicketComponentImpl.java

示例2: 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;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:39,代码来源:InMemoryTicketComponentImpl.java

示例3: 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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:6,代码来源:XMLDuration.java

示例4: 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


注:本文中的org.alfresco.service.cmr.repository.datatype.Duration.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。