823N/A/*
823N/A * CDDL HEADER START
823N/A *
823N/A * The contents of this file are subject to the terms of the
823N/A * Common Development and Distribution License, Version 1.0 only
823N/A * (the "License"). You may not use this file except in compliance
823N/A * with the License.
823N/A *
823N/A * You can obtain a copy of the license at
823N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE
823N/A * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
823N/A * See the License for the specific language governing permissions
823N/A * and limitations under the License.
823N/A *
823N/A * When distributing Covered Code, include this CDDL HEADER in each
823N/A * file and include the License file at
823N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
823N/A * add the following below this CDDL HEADER, with the fields enclosed
873N/A * by brackets "[]" replaced with your own identifying information:
823N/A * Portions Copyright [yyyy] [name of copyright owner]
823N/A *
823N/A * CDDL HEADER END
823N/A *
823N/A *
3215N/A * Copyright 2008 Sun Microsystems, Inc.
823N/A */
823N/A
823N/Apackage org.opends.server.authorization.dseecompat;
823N/A
823N/Aimport java.util.Calendar;
823N/A
823N/A/**
823N/A * This class provides an enumeration of the allowed dayofweek types.
823N/A */
823N/Apublic enum EnumDayOfWeek {
897N/A
823N/A /**
823N/A * The enumeration type when the bind rule has specified dayofweek type of
823N/A * "mon".
823N/A */
823N/A DAY_MONDAY ("mon"),
823N/A /**
823N/A * The enumeration type when the bind rule has specified dayofweek type of
823N/A * "tue" .
823N/A */
823N/A DAY_TUESDAY ("tue"),
823N/A /**
823N/A * The enumeration type when the bind rule has specified dayofweek type of
823N/A * "wed".
823N/A */
823N/A DAY_WEDNESDAY ("wed"),
823N/A /**
823N/A * The enumeration type when the bind rule has specified dayofweek type of
823N/A * "thu".
823N/A */
823N/A DAY_THURSDAY ("thu"),
823N/A /**
823N/A * The enumeration type when the bind rule has specified dayofweek type of
823N/A * "fri".
823N/A */
823N/A DAY_FRIDAY ("fri"),
823N/A /**
823N/A * The enumeration type when the bind rule has specified dayofweek type of
823N/A * "sat".
823N/A */
823N/A DAY_SATURDAY ("sat"),
823N/A /**
823N/A * The enumeration type when the bind rule has specified dayofweek type of
823N/A * "sun".
823N/A */
823N/A DAY_SUNDAY ("sun");
823N/A
897N/A /*
823N/A * The bind rule dayofweek type name.
823N/A */
823N/A private String day = null;
823N/A
823N/A /**
823N/A * Creates a new enumeration type for the specified bind rule dayofweek
823N/A * type.
823N/A * @param day The day name.
823N/A */
823N/A EnumDayOfWeek (String day){
823N/A this.day = day;
823N/A }
823N/A
823N/A /**
823N/A * Creates a new enumeration type for the specified bind rule dayofweek
823N/A * type.
823N/A * @param day The boolean type name.
823N/A * @return True if the keyword is equal to the specified name.
823N/A */
823N/A public boolean isDayOfWeek(String day){
823N/A return day.equalsIgnoreCase(this.day);
823N/A }
823N/A
823N/A /**
823N/A * Create a new enumeration type for the specified dayofweek type name.
823N/A * @param day The name of the enumeration to create.
823N/A * @return A new enumeration type for the name or null if the name is
823N/A * not valid.
823N/A */
823N/A public static EnumDayOfWeek createDayOfWeek(String day)
823N/A {
823N/A if (day != null){
823N/A for (EnumDayOfWeek t : EnumDayOfWeek.values()){
823N/A if (t.isDayOfWeek(day)){
823N/A return t;
823N/A }
823N/A }
823N/A }
823N/A return null;
823N/A }
823N/A
823N/A /*
823N/A * TODO Evaluate supporting alternative forms for days of the week.
823N/A *
823N/A * Should we support alternate forms for the names of the days of the
823N/A * week in the isDayOfWeek() or createdayOfWeek() method? In particular,
823N/A * should we handle the case in which the user provided the full name
823N/A * (e.g., "monday" instead of "mon")?
823N/A */
823N/A /**
823N/A * Return a enumeration relating to a Calendar day of week field.
823N/A * @param day The day of week index to get.
823N/A * @return An enumeration corresponding to the wanted day of the week or
823N/A * null if the day index is invalid.
823N/A */
823N/A public static EnumDayOfWeek getDayOfWeek(int day)
823N/A {
823N/A switch(day){
823N/A case Calendar.SUNDAY:
823N/A return DAY_SUNDAY;
823N/A
823N/A case Calendar.MONDAY:
823N/A return DAY_MONDAY;
823N/A
823N/A case Calendar.TUESDAY:
823N/A return DAY_TUESDAY;
823N/A
823N/A case Calendar.WEDNESDAY:
823N/A return DAY_WEDNESDAY;
823N/A
823N/A case Calendar.THURSDAY:
823N/A return DAY_THURSDAY;
823N/A
823N/A case Calendar.FRIDAY:
823N/A return DAY_FRIDAY;
823N/A
823N/A case Calendar.SATURDAY:
823N/A return DAY_SATURDAY;
823N/A }
823N/A return null;
823N/A }
823N/A}