You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/02/20 04:58:21 UTC
svn commit: r379013 [39/45] - in /directory/trunks/apacheds: ./ core-plugin/
core-plugin/src/main/java/org/apache/directory/server/core/tools/schema/
core-plugin/src/test/java/org/apache/directory/server/core/tools/schema/
core-shared/ core-shared/src/...
Modified: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/io/NtpMessageEncoder.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/io/NtpMessageEncoder.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/io/NtpMessageEncoder.java (original)
+++ directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/io/NtpMessageEncoder.java Sun Feb 19 19:57:02 2006
@@ -17,6 +17,7 @@
package org.apache.directory.server.ntp.io;
+
import java.nio.ByteBuffer;
import org.apache.directory.server.ntp.messages.LeapIndicatorType;
@@ -24,6 +25,7 @@
import org.apache.directory.server.ntp.messages.NtpMessage;
import org.apache.directory.server.ntp.messages.ReferenceIdentifier;
+
public class NtpMessageEncoder
{
public void encode( ByteBuffer byteBuffer, NtpMessage message )
@@ -34,9 +36,9 @@
header = encodeMode( message.getMode(), header );
byteBuffer.put( header );
- byteBuffer.put( (byte) ( message.getStratum().getOrdinal() & 0xFF ) );
- byteBuffer.put( (byte) ( message.getPollInterval() & 0xFF ) );
- byteBuffer.put( (byte) ( message.getPrecision() & 0xFF ) );
+ byteBuffer.put( ( byte ) ( message.getStratum().getOrdinal() & 0xFF ) );
+ byteBuffer.put( ( byte ) ( message.getPollInterval() & 0xFF ) );
+ byteBuffer.put( ( byte ) ( message.getPrecision() & 0xFF ) );
byteBuffer.putInt( message.getRootDelay() );
byteBuffer.putInt( message.getRootDispersion() );
@@ -49,31 +51,35 @@
message.getTransmitTimestamp().writeTo( byteBuffer );
}
+
private byte encodeLeapIndicator( LeapIndicatorType leapIndicator, byte header )
{
- byte twoBits = (byte) ( leapIndicator.getOrdinal() & 0x03 );
- return (byte) ( ( twoBits << 6 ) | header );
+ byte twoBits = ( byte ) ( leapIndicator.getOrdinal() & 0x03 );
+ return ( byte ) ( ( twoBits << 6 ) | header );
}
+
private byte encodeVersionNumber( int versionNumber, byte header )
{
- byte threeBits = (byte) ( versionNumber & 0x07 );
- return (byte) ( ( threeBits << 3 ) | header );
+ byte threeBits = ( byte ) ( versionNumber & 0x07 );
+ return ( byte ) ( ( threeBits << 3 ) | header );
}
+
private byte encodeMode( ModeType mode, byte header )
{
- byte threeBits = (byte) ( mode.getOrdinal() & 0x07 );
- return (byte) ( threeBits | header );
+ byte threeBits = ( byte ) ( mode.getOrdinal() & 0x07 );
+ return ( byte ) ( threeBits | header );
}
+
private void encodeReferenceIdentifier( ReferenceIdentifier identifier, ByteBuffer byteBuffer )
{
char[] characters = identifier.getCode().toCharArray();
for ( int ii = 0; ii < characters.length; ii++ )
{
- byteBuffer.put( (byte) characters[ ii ] );
+ byteBuffer.put( ( byte ) characters[ii] );
}
}
}
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/io/NtpMessageEncoder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/io/NtpMessageEncoder.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/LeapIndicatorType.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/LeapIndicatorType.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/LeapIndicatorType.java (original)
+++ directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/LeapIndicatorType.java Sun Feb 19 19:57:02 2006
@@ -17,10 +17,12 @@
package org.apache.directory.server.ntp.messages;
+
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+
/**
* Leap Indicator (LI): This is a two-bit code warning of an impending
* leap second to be inserted/deleted in the last minute of the current
@@ -35,57 +37,65 @@
*/
public final class LeapIndicatorType implements Comparable
{
- /**
- * Enumeration elements are constructed once upon class loading.
- * Order of appearance here determines the order of compareTo.
- */
- public static final LeapIndicatorType NO_WARNING = new LeapIndicatorType(0, "No leap second warning.");
- public static final LeapIndicatorType POSITIVE_LEAP_SECOND = new LeapIndicatorType(1, "Last minute has 61 seconds.");
- public static final LeapIndicatorType NEGATIVE_LEAP_SECOND = new LeapIndicatorType(2, "Last minute has 59 seconds.");
- public static final LeapIndicatorType ALARM_CONDITION = new LeapIndicatorType(3, "Alarm condition (clock not synchronized).");
+ /**
+ * Enumeration elements are constructed once upon class loading.
+ * Order of appearance here determines the order of compareTo.
+ */
+ public static final LeapIndicatorType NO_WARNING = new LeapIndicatorType( 0, "No leap second warning." );
+ public static final LeapIndicatorType POSITIVE_LEAP_SECOND = new LeapIndicatorType( 1,
+ "Last minute has 61 seconds." );
+ public static final LeapIndicatorType NEGATIVE_LEAP_SECOND = new LeapIndicatorType( 2,
+ "Last minute has 59 seconds." );
+ public static final LeapIndicatorType ALARM_CONDITION = new LeapIndicatorType( 3,
+ "Alarm condition (clock not synchronized)." );
/**
* These two lines are all that's necessary to export a List of VALUES.
*/
- private static final LeapIndicatorType[] values = { NO_WARNING, POSITIVE_LEAP_SECOND, NEGATIVE_LEAP_SECOND,
- ALARM_CONDITION };
+ private static final LeapIndicatorType[] values =
+ { NO_WARNING, POSITIVE_LEAP_SECOND, NEGATIVE_LEAP_SECOND, ALARM_CONDITION };
// VALUES needs to be located here, otherwise illegal forward reference
public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
private final String name;
private final int ordinal;
+
/**
* Private constructor prevents construction outside of this class.
*/
- private LeapIndicatorType( int ordinal, String name )
+ private LeapIndicatorType(int ordinal, String name)
{
this.ordinal = ordinal;
this.name = name;
}
+
public static LeapIndicatorType getTypeByOrdinal( int type )
{
for ( int ii = 0; ii < values.length; ii++ )
{
- if ( values[ ii ].ordinal == type )
+ if ( values[ii].ordinal == type )
{
- return values[ ii ];
+ return values[ii];
}
}
return NO_WARNING;
}
+
public int getOrdinal()
{
return ordinal;
}
+
public int compareTo( Object that )
{
- return ordinal - ( (LeapIndicatorType) that ).ordinal;
+ return ordinal - ( ( LeapIndicatorType ) that ).ordinal;
}
+
public String toString()
{
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/LeapIndicatorType.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/LeapIndicatorType.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/ModeType.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/ModeType.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/ModeType.java (original)
+++ directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/ModeType.java Sun Feb 19 19:57:02 2006
@@ -17,10 +17,12 @@
package org.apache.directory.server.ntp.messages;
+
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+
/**
* Mode: This is a three-bit integer indicating the mode, with values
* defined as follows:
@@ -38,60 +40,66 @@
*/
public final class ModeType implements Comparable
{
- /**
- * Enumeration elements are constructed once upon class loading.
- * Order of appearance here determines the order of compareTo.
- */
- public static final ModeType RESERVED = new ModeType(0, "Reserved mode.");
- public static final ModeType SYMMETRIC_ACTIVE = new ModeType(1, "Symmetric active mode.");
- public static final ModeType RESERVED_PASSIVE = new ModeType(2, "Symmetric passive mode.");
- public static final ModeType CLIENT = new ModeType(3, "Client mode.");
- public static final ModeType SERVER = new ModeType(4, "Server mode.");
- public static final ModeType BROADCAST = new ModeType(5, "Broadcast mode.");
- public static final ModeType RESERVED_FOR_NTP_CONTROL = new ModeType(6, "Reserved for NTP control message.");
- public static final ModeType RESERVED_FOR_PRIVATE_USE = new ModeType(7, "Reserved for private use.");
+ /**
+ * Enumeration elements are constructed once upon class loading.
+ * Order of appearance here determines the order of compareTo.
+ */
+ public static final ModeType RESERVED = new ModeType( 0, "Reserved mode." );
+ public static final ModeType SYMMETRIC_ACTIVE = new ModeType( 1, "Symmetric active mode." );
+ public static final ModeType RESERVED_PASSIVE = new ModeType( 2, "Symmetric passive mode." );
+ public static final ModeType CLIENT = new ModeType( 3, "Client mode." );
+ public static final ModeType SERVER = new ModeType( 4, "Server mode." );
+ public static final ModeType BROADCAST = new ModeType( 5, "Broadcast mode." );
+ public static final ModeType RESERVED_FOR_NTP_CONTROL = new ModeType( 6, "Reserved for NTP control message." );
+ public static final ModeType RESERVED_FOR_PRIVATE_USE = new ModeType( 7, "Reserved for private use." );
/**
* These two lines are all that's necessary to export a List of VALUES.
*/
- private static final ModeType[] values = { RESERVED, SYMMETRIC_ACTIVE, RESERVED_PASSIVE, CLIENT, SERVER, BROADCAST,
- RESERVED_FOR_NTP_CONTROL, RESERVED_FOR_PRIVATE_USE };
+ private static final ModeType[] values =
+ { RESERVED, SYMMETRIC_ACTIVE, RESERVED_PASSIVE, CLIENT, SERVER, BROADCAST, RESERVED_FOR_NTP_CONTROL,
+ RESERVED_FOR_PRIVATE_USE };
// VALUES needs to be located here, otherwise illegal forward reference
public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
private final String name;
private final int ordinal;
+
/**
* Private constructor prevents construction outside of this class.
*/
- private ModeType( int ordinal, String name )
+ private ModeType(int ordinal, String name)
{
this.ordinal = ordinal;
this.name = name;
}
+
public static ModeType getTypeByOrdinal( int type )
{
for ( int ii = 0; ii < values.length; ii++ )
{
- if ( values[ ii ].ordinal == type )
+ if ( values[ii].ordinal == type )
{
- return values[ ii ];
+ return values[ii];
}
}
return SERVER;
}
+
public int getOrdinal()
{
return ordinal;
}
+
public int compareTo( Object that )
{
- return ordinal - ( (ModeType) that ).ordinal;
+ return ordinal - ( ( ModeType ) that ).ordinal;
}
+
public String toString()
{
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/ModeType.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/ModeType.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpMessage.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpMessage.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpMessage.java (original)
+++ directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpMessage.java Sun Feb 19 19:57:02 2006
@@ -1,161 +1,176 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.directory.server.ntp.messages;
-
-public class NtpMessage
-{
- private LeapIndicatorType leapIndicator;
- private int versionNumber;
- private ModeType mode;
- private StratumType stratumType;
- private byte pollInterval;
- private byte precision;
- private int rootDelay;
- private int rootDispersion;
-
- private ReferenceIdentifier referenceIdentifier;
-
- private NtpTimeStamp referenceTimestamp;
- private NtpTimeStamp originateTimestamp;
- private NtpTimeStamp receiveTimestamp;
- private NtpTimeStamp transmitTimestamp;
-
- public NtpMessage( LeapIndicatorType leapIndicator, int versionNumber, ModeType mode, StratumType stratumType,
- byte pollInterval, byte precision, int rootDelay, int rootDispersion,
- ReferenceIdentifier referenceIdentifier, NtpTimeStamp referenceTimestamp, NtpTimeStamp originateTimestamp,
- NtpTimeStamp receiveTimestamp, NtpTimeStamp transmitTimestamp )
- {
- this.leapIndicator = leapIndicator;
- this.versionNumber = versionNumber;
- this.mode = mode;
- this.stratumType = stratumType;
- this.pollInterval = pollInterval;
- this.precision = precision;
- this.rootDelay = rootDelay;
- this.rootDispersion = rootDispersion;
- this.referenceIdentifier = referenceIdentifier;
- this.referenceTimestamp = referenceTimestamp;
- this.originateTimestamp = originateTimestamp;
- this.receiveTimestamp = receiveTimestamp;
- this.transmitTimestamp = transmitTimestamp;
- }
-
- /**
- * @return Returns the Leap Indicator.
- */
- public LeapIndicatorType getLeapIndicator()
- {
- return leapIndicator;
- }
-
- /**
- * @return Returns the Mode.
- */
- public ModeType getMode()
- {
- return mode;
- }
-
- /**
- * @return Returns the Originate Timestamp.
- */
- public NtpTimeStamp getOriginateTimestamp()
- {
- return originateTimestamp;
- }
-
- /**
- * @return Returns the Poll Interval.
- */
- public byte getPollInterval()
- {
- return pollInterval;
- }
-
- /**
- * @return Returns the Precision.
- */
- public byte getPrecision()
- {
- return precision;
- }
-
- /**
- * @return Returns the Receive Timestamp.
- */
- public NtpTimeStamp getReceiveTimestamp()
- {
- return receiveTimestamp;
- }
-
- /**
- * @return Returns the Reference Identifier.
- */
- public ReferenceIdentifier getReferenceIdentifier()
- {
- return referenceIdentifier;
- }
-
- /**
- * @return Returns the Reference Timestamp.
- */
- public NtpTimeStamp getReferenceTimestamp()
- {
- return referenceTimestamp;
- }
-
- /**
- * @return Returns the Root Delay.
- */
- public int getRootDelay()
- {
- return rootDelay;
- }
-
- /**
- * @return Returns the Root Dispersion.
- */
- public int getRootDispersion()
- {
- return rootDispersion;
- }
-
- /**
- * @return Returns the Stratum.
- */
- public StratumType getStratum()
- {
- return stratumType;
- }
-
- /**
- * @return Returns the Transmit Timestamp.
- */
- public NtpTimeStamp getTransmitTimestamp()
- {
- return transmitTimestamp;
- }
-
- /**
- * @return Returns the Version Number.
- */
- public int getVersionNumber()
- {
- return versionNumber;
- }
-}
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.directory.server.ntp.messages;
+
+
+public class NtpMessage
+{
+ private LeapIndicatorType leapIndicator;
+ private int versionNumber;
+ private ModeType mode;
+ private StratumType stratumType;
+ private byte pollInterval;
+ private byte precision;
+ private int rootDelay;
+ private int rootDispersion;
+
+ private ReferenceIdentifier referenceIdentifier;
+
+ private NtpTimeStamp referenceTimestamp;
+ private NtpTimeStamp originateTimestamp;
+ private NtpTimeStamp receiveTimestamp;
+ private NtpTimeStamp transmitTimestamp;
+
+
+ public NtpMessage(LeapIndicatorType leapIndicator, int versionNumber, ModeType mode, StratumType stratumType,
+ byte pollInterval, byte precision, int rootDelay, int rootDispersion, ReferenceIdentifier referenceIdentifier,
+ NtpTimeStamp referenceTimestamp, NtpTimeStamp originateTimestamp, NtpTimeStamp receiveTimestamp,
+ NtpTimeStamp transmitTimestamp)
+ {
+ this.leapIndicator = leapIndicator;
+ this.versionNumber = versionNumber;
+ this.mode = mode;
+ this.stratumType = stratumType;
+ this.pollInterval = pollInterval;
+ this.precision = precision;
+ this.rootDelay = rootDelay;
+ this.rootDispersion = rootDispersion;
+ this.referenceIdentifier = referenceIdentifier;
+ this.referenceTimestamp = referenceTimestamp;
+ this.originateTimestamp = originateTimestamp;
+ this.receiveTimestamp = receiveTimestamp;
+ this.transmitTimestamp = transmitTimestamp;
+ }
+
+
+ /**
+ * @return Returns the Leap Indicator.
+ */
+ public LeapIndicatorType getLeapIndicator()
+ {
+ return leapIndicator;
+ }
+
+
+ /**
+ * @return Returns the Mode.
+ */
+ public ModeType getMode()
+ {
+ return mode;
+ }
+
+
+ /**
+ * @return Returns the Originate Timestamp.
+ */
+ public NtpTimeStamp getOriginateTimestamp()
+ {
+ return originateTimestamp;
+ }
+
+
+ /**
+ * @return Returns the Poll Interval.
+ */
+ public byte getPollInterval()
+ {
+ return pollInterval;
+ }
+
+
+ /**
+ * @return Returns the Precision.
+ */
+ public byte getPrecision()
+ {
+ return precision;
+ }
+
+
+ /**
+ * @return Returns the Receive Timestamp.
+ */
+ public NtpTimeStamp getReceiveTimestamp()
+ {
+ return receiveTimestamp;
+ }
+
+
+ /**
+ * @return Returns the Reference Identifier.
+ */
+ public ReferenceIdentifier getReferenceIdentifier()
+ {
+ return referenceIdentifier;
+ }
+
+
+ /**
+ * @return Returns the Reference Timestamp.
+ */
+ public NtpTimeStamp getReferenceTimestamp()
+ {
+ return referenceTimestamp;
+ }
+
+
+ /**
+ * @return Returns the Root Delay.
+ */
+ public int getRootDelay()
+ {
+ return rootDelay;
+ }
+
+
+ /**
+ * @return Returns the Root Dispersion.
+ */
+ public int getRootDispersion()
+ {
+ return rootDispersion;
+ }
+
+
+ /**
+ * @return Returns the Stratum.
+ */
+ public StratumType getStratum()
+ {
+ return stratumType;
+ }
+
+
+ /**
+ * @return Returns the Transmit Timestamp.
+ */
+ public NtpTimeStamp getTransmitTimestamp()
+ {
+ return transmitTimestamp;
+ }
+
+
+ /**
+ * @return Returns the Version Number.
+ */
+ public int getVersionNumber()
+ {
+ return versionNumber;
+ }
+}
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpMessage.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpMessageModifier.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpMessageModifier.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpMessageModifier.java (original)
+++ directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpMessageModifier.java Sun Feb 19 19:57:02 2006
@@ -17,6 +17,7 @@
package org.apache.directory.server.ntp.messages;
+
public class NtpMessageModifier
{
private LeapIndicatorType leapIndicator;
@@ -35,13 +36,15 @@
private NtpTimeStamp receiveTimestamp;
private NtpTimeStamp transmitTimestamp;
+
public NtpMessage getNtpMessage()
{
return new NtpMessage( leapIndicator, versionNumber, mode, stratumType, pollInterval, precision, rootDelay,
- rootDispersion, referenceIdentifier, referenceTimestamp, originateTimestamp, receiveTimestamp,
- transmitTimestamp );
+ rootDispersion, referenceIdentifier, referenceTimestamp, originateTimestamp, receiveTimestamp,
+ transmitTimestamp );
}
+
/**
* @param leapIndicator The Leap Indicator to set.
*/
@@ -50,6 +53,7 @@
this.leapIndicator = leapIndicator;
}
+
/**
* @param mode The Mode to set.
*/
@@ -58,6 +62,7 @@
this.mode = mode;
}
+
/**
* @param originateTimestamp The Originate Timestamp to set.
*/
@@ -66,6 +71,7 @@
this.originateTimestamp = originateTimestamp;
}
+
/**
* @param pollInterval The Poll Interval to set.
*/
@@ -74,6 +80,7 @@
this.pollInterval = pollInterval;
}
+
/**
* @param precision The Precision to set.
*/
@@ -82,6 +89,7 @@
this.precision = precision;
}
+
/**
* @param receiveTimestamp The Receive Timestamp to set.
*/
@@ -90,6 +98,7 @@
this.receiveTimestamp = receiveTimestamp;
}
+
/**
* @param referenceIdentifier The Reference Identifier to set.
*/
@@ -98,6 +107,7 @@
this.referenceIdentifier = referenceIdentifier;
}
+
/**
* @param referenceTimestamp The Reference Timestamp to set.
*/
@@ -106,6 +116,7 @@
this.referenceTimestamp = referenceTimestamp;
}
+
/**
* @param rootDelay The Root Delay to set.
*/
@@ -114,6 +125,7 @@
this.rootDelay = rootDelay;
}
+
/**
* @param rootDispersion The Root Dispersion to set.
*/
@@ -122,6 +134,7 @@
this.rootDispersion = rootDispersion;
}
+
/**
* @param stratumType The Stratum to set.
*/
@@ -130,6 +143,7 @@
this.stratumType = stratumType;
}
+
/**
* @param transmitTimestamp The Transmit Timestamp to set.
*/
@@ -137,6 +151,7 @@
{
this.transmitTimestamp = transmitTimestamp;
}
+
/**
* @param versionNumber The Version Number to set.
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpMessageModifier.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpMessageModifier.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpTimeStamp.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpTimeStamp.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpTimeStamp.java (original)
+++ directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpTimeStamp.java Sun Feb 19 19:57:02 2006
@@ -1,129 +1,138 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.directory.server.ntp.messages;
-
-import java.nio.ByteBuffer;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-/**
- * NTP timestamps are represented as a 64-bit unsigned fixed-point number,
- * in seconds relative to 0h on 1 January 1900. The integer part is in the
- * first 32 bits and the fraction part in the last 32 bits. In the fraction
- * part, the non-significant low order can be set to 0.
- */
-public class NtpTimeStamp
-{
- /**
- * The number of milliseconds difference between the Java epoch and
- * the NTP epoch ( January 1, 1900, 00:00:00 GMT ).
- */
- private static final long NTP_EPOCH_DIFFERENCE = -2208988800000L;
-
- private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
- private static final SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss.SSS z" );
-
- static
- {
- dateFormat.setTimeZone( UTC_TIME_ZONE );
- }
-
- private long seconds = 0;
- private long fraction = 0;
-
- public NtpTimeStamp()
- {
- this( new Date() );
- }
-
- public NtpTimeStamp( Date date )
- {
- long msSinceStartOfNtpEpoch = date.getTime() - NTP_EPOCH_DIFFERENCE;
-
- seconds = msSinceStartOfNtpEpoch / 1000;
- fraction = ( ( msSinceStartOfNtpEpoch % 1000 ) * 0x100000000L ) / 1000;
- }
-
- public NtpTimeStamp( ByteBuffer data )
- {
- for ( int ii = 0; ii < 4; ii++ )
- {
- seconds = 256 * seconds + makePositive( data.get() );
- }
-
- for ( int ii = 4; ii < 8; ii++ )
- {
- fraction = 256 * fraction + makePositive( data.get() );
- }
- }
-
- public void writeTo( ByteBuffer buffer )
- {
- byte[] bytes = new byte[ 8 ];
-
- long temp = seconds;
- for ( int ii = 3; ii >= 0; ii-- )
- {
- bytes[ ii ] = (byte) ( temp % 256 );
- temp = temp / 256;
- }
-
- temp = fraction;
- for ( int ii = 7; ii >= 4; ii-- )
- {
- bytes[ ii ] = (byte) ( temp % 256 );
- temp = temp / 256;
- }
-
- buffer.put( bytes );
- }
-
- public String toString()
- {
- long msSinceStartOfNtpEpoch = seconds * 1000 + ( fraction * 1000 ) / 0x100000000L;
- Date date = new Date( msSinceStartOfNtpEpoch + NTP_EPOCH_DIFFERENCE );
-
- synchronized ( dateFormat )
- {
- return "org.apache.ntp.message.NtpTimeStamp[ date = " + dateFormat.format( date ) + " ]";
- }
- }
-
- public boolean equals( Object o )
- {
- if ( this == o )
- {
- return true;
- }
-
- if ( !( o instanceof NtpTimeStamp ) )
- {
- return false;
- }
-
- NtpTimeStamp that = (NtpTimeStamp) o;
- return ( this.seconds == that.seconds ) && ( this.fraction == that.fraction );
- }
-
- private int makePositive( byte b )
- {
- int byteAsInt = b;
- return ( byteAsInt < 0 ) ? 256 + byteAsInt : byteAsInt;
- }
-}
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.directory.server.ntp.messages;
+
+
+import java.nio.ByteBuffer;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+
+/**
+ * NTP timestamps are represented as a 64-bit unsigned fixed-point number,
+ * in seconds relative to 0h on 1 January 1900. The integer part is in the
+ * first 32 bits and the fraction part in the last 32 bits. In the fraction
+ * part, the non-significant low order can be set to 0.
+ */
+public class NtpTimeStamp
+{
+ /**
+ * The number of milliseconds difference between the Java epoch and
+ * the NTP epoch ( January 1, 1900, 00:00:00 GMT ).
+ */
+ private static final long NTP_EPOCH_DIFFERENCE = -2208988800000L;
+
+ private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
+ private static final SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss.SSS z" );
+
+ static
+ {
+ dateFormat.setTimeZone( UTC_TIME_ZONE );
+ }
+
+ private long seconds = 0;
+ private long fraction = 0;
+
+
+ public NtpTimeStamp()
+ {
+ this( new Date() );
+ }
+
+
+ public NtpTimeStamp(Date date)
+ {
+ long msSinceStartOfNtpEpoch = date.getTime() - NTP_EPOCH_DIFFERENCE;
+
+ seconds = msSinceStartOfNtpEpoch / 1000;
+ fraction = ( ( msSinceStartOfNtpEpoch % 1000 ) * 0x100000000L ) / 1000;
+ }
+
+
+ public NtpTimeStamp(ByteBuffer data)
+ {
+ for ( int ii = 0; ii < 4; ii++ )
+ {
+ seconds = 256 * seconds + makePositive( data.get() );
+ }
+
+ for ( int ii = 4; ii < 8; ii++ )
+ {
+ fraction = 256 * fraction + makePositive( data.get() );
+ }
+ }
+
+
+ public void writeTo( ByteBuffer buffer )
+ {
+ byte[] bytes = new byte[8];
+
+ long temp = seconds;
+ for ( int ii = 3; ii >= 0; ii-- )
+ {
+ bytes[ii] = ( byte ) ( temp % 256 );
+ temp = temp / 256;
+ }
+
+ temp = fraction;
+ for ( int ii = 7; ii >= 4; ii-- )
+ {
+ bytes[ii] = ( byte ) ( temp % 256 );
+ temp = temp / 256;
+ }
+
+ buffer.put( bytes );
+ }
+
+
+ public String toString()
+ {
+ long msSinceStartOfNtpEpoch = seconds * 1000 + ( fraction * 1000 ) / 0x100000000L;
+ Date date = new Date( msSinceStartOfNtpEpoch + NTP_EPOCH_DIFFERENCE );
+
+ synchronized ( dateFormat )
+ {
+ return "org.apache.ntp.message.NtpTimeStamp[ date = " + dateFormat.format( date ) + " ]";
+ }
+ }
+
+
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+
+ if ( !( o instanceof NtpTimeStamp ) )
+ {
+ return false;
+ }
+
+ NtpTimeStamp that = ( NtpTimeStamp ) o;
+ return ( this.seconds == that.seconds ) && ( this.fraction == that.fraction );
+ }
+
+
+ private int makePositive( byte b )
+ {
+ int byteAsInt = b;
+ return ( byteAsInt < 0 ) ? 256 + byteAsInt : byteAsInt;
+ }
+}
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpTimeStamp.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/NtpTimeStamp.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/ReferenceIdentifier.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/ReferenceIdentifier.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/ReferenceIdentifier.java (original)
+++ directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/ReferenceIdentifier.java Sun Feb 19 19:57:02 2006
@@ -17,10 +17,12 @@
package org.apache.directory.server.ntp.messages;
+
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+
/**
* Reference Identifier: This is a 32-bit bitstring identifying the
* particular reference source. In the case of NTP Version 3 or Version
@@ -37,34 +39,41 @@
*/
public class ReferenceIdentifier implements Comparable
{
- /**
- * Enumeration elements are constructed once upon class loading.
- * Order of appearance here determines the order of compareTo.
- */
- public static final ReferenceIdentifier INIT = new ReferenceIdentifier(0, "INIT", "initializing");
- public static final ReferenceIdentifier LOCL = new ReferenceIdentifier(1, "LOCL", "uncalibrated local clock");
- public static final ReferenceIdentifier PPS = new ReferenceIdentifier(2, "PPL", "pulse-per-second source");
- public static final ReferenceIdentifier ACTS = new ReferenceIdentifier(3, "ACTS", "NIST dialup modem service");
- public static final ReferenceIdentifier USNO = new ReferenceIdentifier(4, "USNO", "USNO modem service");
- public static final ReferenceIdentifier PTB = new ReferenceIdentifier(5, "PTB", "PTB (Germany) modem service");
- public static final ReferenceIdentifier TDF = new ReferenceIdentifier(6, "TDF", "Allouis (France) Radio 164 kHz");
- public static final ReferenceIdentifier DCF = new ReferenceIdentifier(7, "DCF", "Mainflingen (Germany) Radio 77.5 kHz");
- public static final ReferenceIdentifier MSF = new ReferenceIdentifier(8, "MSF", "Rugby (UK) Radio 60 kHz");
- public static final ReferenceIdentifier WWV = new ReferenceIdentifier(9, "WWV", "Ft. Collins (US) Radio 2.5, 5, 10, 15, 20 MHz");
- public static final ReferenceIdentifier WWVB = new ReferenceIdentifier(10, "WWVB", "Boulder (US) Radio 60 kHz");
- public static final ReferenceIdentifier WWVH = new ReferenceIdentifier(11, "WWVH", "Kaui Hawaii (US) Radio 2.5, 5, 10, 15 MHz");
- public static final ReferenceIdentifier CHU = new ReferenceIdentifier(12, "CHU", "Ottawa (Canada) Radio 3330, 7335, 14670 kHz");
- public static final ReferenceIdentifier LORC = new ReferenceIdentifier(13, "LORC", "LORAN-C radionavigation system");
- public static final ReferenceIdentifier OMEG = new ReferenceIdentifier(14, "OMEG", "OMEGA radionavigation system");
- public static final ReferenceIdentifier GPS = new ReferenceIdentifier(15, "GPS", "Global Positioning Service");
- public static final ReferenceIdentifier GOES = new ReferenceIdentifier(16, "GOES", "Geostationary Orbit Environment Satellite");
- public static final ReferenceIdentifier CDMA = new ReferenceIdentifier(17, "CDMA", "CDMA mobile cellular/PCS telephone system");
+ /**
+ * Enumeration elements are constructed once upon class loading.
+ * Order of appearance here determines the order of compareTo.
+ */
+ public static final ReferenceIdentifier INIT = new ReferenceIdentifier( 0, "INIT", "initializing" );
+ public static final ReferenceIdentifier LOCL = new ReferenceIdentifier( 1, "LOCL", "uncalibrated local clock" );
+ public static final ReferenceIdentifier PPS = new ReferenceIdentifier( 2, "PPL", "pulse-per-second source" );
+ public static final ReferenceIdentifier ACTS = new ReferenceIdentifier( 3, "ACTS", "NIST dialup modem service" );
+ public static final ReferenceIdentifier USNO = new ReferenceIdentifier( 4, "USNO", "USNO modem service" );
+ public static final ReferenceIdentifier PTB = new ReferenceIdentifier( 5, "PTB", "PTB (Germany) modem service" );
+ public static final ReferenceIdentifier TDF = new ReferenceIdentifier( 6, "TDF", "Allouis (France) Radio 164 kHz" );
+ public static final ReferenceIdentifier DCF = new ReferenceIdentifier( 7, "DCF",
+ "Mainflingen (Germany) Radio 77.5 kHz" );
+ public static final ReferenceIdentifier MSF = new ReferenceIdentifier( 8, "MSF", "Rugby (UK) Radio 60 kHz" );
+ public static final ReferenceIdentifier WWV = new ReferenceIdentifier( 9, "WWV",
+ "Ft. Collins (US) Radio 2.5, 5, 10, 15, 20 MHz" );
+ public static final ReferenceIdentifier WWVB = new ReferenceIdentifier( 10, "WWVB", "Boulder (US) Radio 60 kHz" );
+ public static final ReferenceIdentifier WWVH = new ReferenceIdentifier( 11, "WWVH",
+ "Kaui Hawaii (US) Radio 2.5, 5, 10, 15 MHz" );
+ public static final ReferenceIdentifier CHU = new ReferenceIdentifier( 12, "CHU",
+ "Ottawa (Canada) Radio 3330, 7335, 14670 kHz" );
+ public static final ReferenceIdentifier LORC = new ReferenceIdentifier( 13, "LORC",
+ "LORAN-C radionavigation system" );
+ public static final ReferenceIdentifier OMEG = new ReferenceIdentifier( 14, "OMEG", "OMEGA radionavigation system" );
+ public static final ReferenceIdentifier GPS = new ReferenceIdentifier( 15, "GPS", "Global Positioning Service" );
+ public static final ReferenceIdentifier GOES = new ReferenceIdentifier( 16, "GOES",
+ "Geostationary Orbit Environment Satellite" );
+ public static final ReferenceIdentifier CDMA = new ReferenceIdentifier( 17, "CDMA",
+ "CDMA mobile cellular/PCS telephone system" );
/**
* These two lines are all that's necessary to export a List of VALUES.
*/
- private static final ReferenceIdentifier[] values = { INIT, LOCL, PPS, ACTS, USNO, PTB, TDF, DCF, MSF, WWV, WWVB,
- WWVH, CHU, LORC, OMEG, GPS, GOES, CDMA };
+ private static final ReferenceIdentifier[] values =
+ { INIT, LOCL, PPS, ACTS, USNO, PTB, TDF, DCF, MSF, WWV, WWVB, WWVH, CHU, LORC, OMEG, GPS, GOES, CDMA };
// VALUES needs to be located here, otherwise illegal forward reference
public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
@@ -72,56 +81,63 @@
private final String name;
private final String code;
+
/**
* Private constructor prevents construction outside of this class.
*/
- private ReferenceIdentifier( int ordinal, String code, String name )
+ private ReferenceIdentifier(int ordinal, String code, String name)
{
this.ordinal = ordinal;
this.code = code;
this.name = name;
}
+
public static ReferenceIdentifier getTypeByOrdinal( int type )
{
for ( int ii = 0; ii < values.length; ii++ )
{
- if ( values[ ii ].ordinal == type )
+ if ( values[ii].ordinal == type )
{
- return values[ ii ];
+ return values[ii];
}
}
return LOCL;
}
+
public static ReferenceIdentifier getTypeByName( String type )
{
for ( int ii = 0; ii < values.length; ii++ )
{
- if ( values[ ii ].code.equalsIgnoreCase( type ) )
+ if ( values[ii].code.equalsIgnoreCase( type ) )
{
- return values[ ii ];
+ return values[ii];
}
}
return LOCL;
}
+
public int getOrdinal()
{
return ordinal;
}
+
public String getCode()
{
return code;
}
+
public int compareTo( Object that )
{
- return ordinal - ( (ReferenceIdentifier) that ).ordinal;
+ return ordinal - ( ( ReferenceIdentifier ) that ).ordinal;
}
+
public String toString()
{
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/ReferenceIdentifier.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/ReferenceIdentifier.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/StratumType.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/StratumType.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/StratumType.java (original)
+++ directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/StratumType.java Sun Feb 19 19:57:02 2006
@@ -17,10 +17,12 @@
package org.apache.directory.server.ntp.messages;
+
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+
/**
* Stratum: This is a eight-bit unsigned integer indicating the stratum
* level of the local clock, with values defined as follows:
@@ -34,55 +36,61 @@
*/
public final class StratumType implements Comparable
{
- /**
- * Enumeration elements are constructed once upon class loading.
- * Order of appearance here determines the order of compareTo.
- */
- public static final StratumType UNSPECIFIED = new StratumType(0, "Unspecified or unavailable.");
- public static final StratumType PRIMARY_REFERENCE = new StratumType(1, "Primary reference.");
- public static final StratumType SECONDARY_REFERENCE = new StratumType(2, "Secondary reference.");
+ /**
+ * Enumeration elements are constructed once upon class loading.
+ * Order of appearance here determines the order of compareTo.
+ */
+ public static final StratumType UNSPECIFIED = new StratumType( 0, "Unspecified or unavailable." );
+ public static final StratumType PRIMARY_REFERENCE = new StratumType( 1, "Primary reference." );
+ public static final StratumType SECONDARY_REFERENCE = new StratumType( 2, "Secondary reference." );
/**
* These two lines are all that's necessary to export a List of VALUES.
*/
- private static final StratumType[] values = { UNSPECIFIED, PRIMARY_REFERENCE, SECONDARY_REFERENCE };
+ private static final StratumType[] values =
+ { UNSPECIFIED, PRIMARY_REFERENCE, SECONDARY_REFERENCE };
// VALUES needs to be located here, otherwise illegal forward reference
public static final List VALUES = Collections.unmodifiableList( Arrays.asList( values ) );
private final int ordinal;
private final String name;
+
/**
* Private constructor prevents construction outside of this class.
*/
- private StratumType( int ordinal, String name )
+ private StratumType(int ordinal, String name)
{
this.ordinal = ordinal;
this.name = name;
}
+
public static StratumType getTypeByOrdinal( int type )
{
for ( int ii = 0; ii < values.length; ii++ )
{
- if ( values[ ii ].ordinal == type )
+ if ( values[ii].ordinal == type )
{
- return values[ ii ];
+ return values[ii];
}
}
return UNSPECIFIED;
}
+
public int getOrdinal()
{
return ordinal;
}
+
public int compareTo( Object that )
{
- return ordinal - ( (StratumType) that ).ordinal;
+ return ordinal - ( ( StratumType ) that ).ordinal;
}
+
public String toString()
{
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/StratumType.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/messages/StratumType.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpDecoder.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpDecoder.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpDecoder.java (original)
+++ directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpDecoder.java Sun Feb 19 19:57:02 2006
@@ -1,37 +1,40 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.directory.server.ntp.protocol;
-
-import org.apache.directory.server.ntp.io.NtpMessageDecoder;
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.codec.ProtocolDecoder;
-import org.apache.mina.filter.codec.ProtocolDecoderOutput;
-
-public class NtpDecoder implements ProtocolDecoder
-{
- public void decode( IoSession session, ByteBuffer in, ProtocolDecoderOutput out )
- {
- NtpMessageDecoder decoder = new NtpMessageDecoder();
- out.write( decoder.decode( in.buf() ) );
- }
-
- public void dispose( IoSession arg0 ) throws Exception
- {
- }
-}
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.directory.server.ntp.protocol;
+
+
+import org.apache.directory.server.ntp.io.NtpMessageDecoder;
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+
+
+public class NtpDecoder implements ProtocolDecoder
+{
+ public void decode( IoSession session, ByteBuffer in, ProtocolDecoderOutput out )
+ {
+ NtpMessageDecoder decoder = new NtpMessageDecoder();
+ out.write( decoder.decode( in.buf() ) );
+ }
+
+
+ public void dispose( IoSession arg0 ) throws Exception
+ {
+ }
+}
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpDecoder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpDecoder.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpEncoder.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpEncoder.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpEncoder.java (original)
+++ directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpEncoder.java Sun Feb 19 19:57:02 2006
@@ -1,44 +1,47 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.directory.server.ntp.protocol;
-
-import org.apache.directory.server.ntp.io.NtpMessageEncoder;
-import org.apache.directory.server.ntp.messages.NtpMessage;
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.codec.ProtocolEncoder;
-import org.apache.mina.filter.codec.ProtocolEncoderOutput;
-
-public class NtpEncoder implements ProtocolEncoder
-{
- public void encode( IoSession session, Object message, ProtocolEncoderOutput out )
- {
- NtpMessageEncoder encoder = new NtpMessageEncoder();
-
- ByteBuffer buf = ByteBuffer.allocate( 1024 );
- encoder.encode( buf.buf(), (NtpMessage) message );
-
- buf.flip();
-
- out.write( buf );
- }
-
- public void dispose( IoSession arg0 ) throws Exception
- {
- }
-}
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.directory.server.ntp.protocol;
+
+
+import org.apache.directory.server.ntp.io.NtpMessageEncoder;
+import org.apache.directory.server.ntp.messages.NtpMessage;
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+import org.apache.mina.filter.codec.ProtocolEncoderOutput;
+
+
+public class NtpEncoder implements ProtocolEncoder
+{
+ public void encode( IoSession session, Object message, ProtocolEncoderOutput out )
+ {
+ NtpMessageEncoder encoder = new NtpMessageEncoder();
+
+ ByteBuffer buf = ByteBuffer.allocate( 1024 );
+ encoder.encode( buf.buf(), ( NtpMessage ) message );
+
+ buf.flip();
+
+ out.write( buf );
+ }
+
+
+ public void dispose( IoSession arg0 ) throws Exception
+ {
+ }
+}
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpEncoder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpEncoder.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpProtocolCodecFactory.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpProtocolCodecFactory.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpProtocolCodecFactory.java (original)
+++ directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpProtocolCodecFactory.java Sun Feb 19 19:57:02 2006
@@ -1,48 +1,54 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.directory.server.ntp.protocol;
-
-import org.apache.mina.filter.codec.ProtocolCodecFactory;
-import org.apache.mina.filter.codec.ProtocolDecoder;
-import org.apache.mina.filter.codec.ProtocolEncoder;
-
-public class NtpProtocolCodecFactory implements ProtocolCodecFactory
-{
- private static final NtpProtocolCodecFactory INSTANCE = new NtpProtocolCodecFactory();
-
- public static NtpProtocolCodecFactory getInstance()
- {
- return INSTANCE;
- }
-
- private NtpProtocolCodecFactory()
- {
- }
-
- public ProtocolEncoder getEncoder()
- {
- // Create a new encoder.
- return new NtpEncoder();
- }
-
- public ProtocolDecoder getDecoder()
- {
- // Create a new decoder.
- return new NtpDecoder();
- }
-}
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.directory.server.ntp.protocol;
+
+
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+
+
+public class NtpProtocolCodecFactory implements ProtocolCodecFactory
+{
+ private static final NtpProtocolCodecFactory INSTANCE = new NtpProtocolCodecFactory();
+
+
+ public static NtpProtocolCodecFactory getInstance()
+ {
+ return INSTANCE;
+ }
+
+
+ private NtpProtocolCodecFactory()
+ {
+ }
+
+
+ public ProtocolEncoder getEncoder()
+ {
+ // Create a new encoder.
+ return new NtpEncoder();
+ }
+
+
+ public ProtocolDecoder getDecoder()
+ {
+ // Create a new decoder.
+ return new NtpDecoder();
+ }
+}
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpProtocolCodecFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpProtocolCodecFactory.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpProtocolHandler.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpProtocolHandler.java (original)
+++ directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpProtocolHandler.java Sun Feb 19 19:57:02 2006
@@ -1,96 +1,105 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.directory.server.ntp.protocol;
-
-import org.apache.directory.server.ntp.NtpService;
-import org.apache.directory.server.ntp.messages.NtpMessage;
-import org.apache.directory.server.ntp.service.NtpServiceImpl;
-import org.apache.mina.common.IdleStatus;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.codec.ProtocolCodecFilter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NtpProtocolHandler implements IoHandler
-{
- /** the log for this class */
- private static final Logger log = LoggerFactory.getLogger( NtpProtocolHandler.class );
-
- private NtpService ntpService = new NtpServiceImpl();
-
- public void sessionCreated( IoSession session ) throws Exception
- {
- if ( log.isDebugEnabled() )
- {
- log.debug( session.getRemoteAddress() + " CREATED" );
- }
-
- session.getFilterChain().addFirst( "codec", new ProtocolCodecFilter( NtpProtocolCodecFactory.getInstance() ) );
- }
-
- public void sessionOpened( IoSession session )
- {
- if ( log.isDebugEnabled() )
- {
- log.debug( session.getRemoteAddress() + " OPENED" );
- }
- }
-
- public void sessionClosed( IoSession session )
- {
- if ( log.isDebugEnabled() )
- {
- log.debug( session.getRemoteAddress() + " CLOSED" );
- }
- }
-
- public void sessionIdle( IoSession session, IdleStatus status )
- {
- if ( log.isDebugEnabled() )
- {
- log.debug( session.getRemoteAddress() + " IDLE(" + status + ")" );
- }
- }
-
- public void exceptionCaught( IoSession session, Throwable cause )
- {
- log.error( session.getRemoteAddress() + " EXCEPTION", cause );
- session.close();
- }
-
- public void messageReceived( IoSession session, Object message )
- {
- if ( log.isDebugEnabled() )
- {
- log.debug( session.getRemoteAddress() + " RCVD: " + message );
- }
-
- NtpMessage reply = ntpService.getReplyFor( (NtpMessage) message );
-
- session.write( reply );
- }
-
- public void messageSent( IoSession session, Object message )
- {
- if ( log.isDebugEnabled() )
- {
- log.debug( session.getRemoteAddress() + " SENT: " + message );
- }
- }
-}
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.directory.server.ntp.protocol;
+
+
+import org.apache.directory.server.ntp.NtpService;
+import org.apache.directory.server.ntp.messages.NtpMessage;
+import org.apache.directory.server.ntp.service.NtpServiceImpl;
+import org.apache.mina.common.IdleStatus;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class NtpProtocolHandler implements IoHandler
+{
+ /** the log for this class */
+ private static final Logger log = LoggerFactory.getLogger( NtpProtocolHandler.class );
+
+ private NtpService ntpService = new NtpServiceImpl();
+
+
+ public void sessionCreated( IoSession session ) throws Exception
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( session.getRemoteAddress() + " CREATED" );
+ }
+
+ session.getFilterChain().addFirst( "codec", new ProtocolCodecFilter( NtpProtocolCodecFactory.getInstance() ) );
+ }
+
+
+ public void sessionOpened( IoSession session )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( session.getRemoteAddress() + " OPENED" );
+ }
+ }
+
+
+ public void sessionClosed( IoSession session )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( session.getRemoteAddress() + " CLOSED" );
+ }
+ }
+
+
+ public void sessionIdle( IoSession session, IdleStatus status )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( session.getRemoteAddress() + " IDLE(" + status + ")" );
+ }
+ }
+
+
+ public void exceptionCaught( IoSession session, Throwable cause )
+ {
+ log.error( session.getRemoteAddress() + " EXCEPTION", cause );
+ session.close();
+ }
+
+
+ public void messageReceived( IoSession session, Object message )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( session.getRemoteAddress() + " RCVD: " + message );
+ }
+
+ NtpMessage reply = ntpService.getReplyFor( ( NtpMessage ) message );
+
+ session.write( reply );
+ }
+
+
+ public void messageSent( IoSession session, Object message )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( session.getRemoteAddress() + " SENT: " + message );
+ }
+ }
+}
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpProtocolHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/protocol/NtpProtocolHandler.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/service/NtpServiceImpl.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/service/NtpServiceImpl.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/service/NtpServiceImpl.java (original)
+++ directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/service/NtpServiceImpl.java Sun Feb 19 19:57:02 2006
@@ -17,6 +17,7 @@
package org.apache.directory.server.ntp.service;
+
import org.apache.directory.server.ntp.NtpService;
import org.apache.directory.server.ntp.messages.LeapIndicatorType;
import org.apache.directory.server.ntp.messages.ModeType;
@@ -26,6 +27,7 @@
import org.apache.directory.server.ntp.messages.ReferenceIdentifier;
import org.apache.directory.server.ntp.messages.StratumType;
+
public class NtpServiceImpl implements NtpService
{
public NtpMessage getReplyFor( NtpMessage request )
@@ -36,8 +38,8 @@
modifier.setVersionNumber( 4 );
modifier.setMode( ModeType.SERVER );
modifier.setStratum( StratumType.PRIMARY_REFERENCE );
- modifier.setPollInterval( (byte) 0x04 );
- modifier.setPrecision( (byte) 0xFA );
+ modifier.setPollInterval( ( byte ) 0x04 );
+ modifier.setPrecision( ( byte ) 0xFA );
modifier.setRootDelay( 0 );
modifier.setRootDispersion( 0 );
modifier.setReferenceIdentifier( ReferenceIdentifier.LOCL );
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/service/NtpServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-ntp/src/main/java/org/apache/directory/server/ntp/service/NtpServiceImpl.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/AbstractNtpTestCase.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/AbstractNtpTestCase.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/AbstractNtpTestCase.java (original)
+++ directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/AbstractNtpTestCase.java Sun Feb 19 19:57:02 2006
@@ -14,9 +14,9 @@
* limitations under the License.
*
*/
-
package org.apache.directory.server.ntp;
+
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
@@ -24,45 +24,61 @@
import junit.framework.TestCase;
import org.apache.directory.server.ntp.messages.NtpMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class AbstractNtpTestCase extends TestCase
{
- protected static final int MINIMUM_NTP_DATAGRAM_SIZE = 576;
-
- protected void print( NtpMessage request )
- {
- System.out.println( request.getLeapIndicator() );
- System.out.println( request.getVersionNumber() );
- System.out.println( request.getMode() );
- System.out.println( request.getStratum() );
- System.out.println( request.getPollInterval() );
- System.out.println( request.getPrecision() );
- System.out.println( request.getRootDelay() );
- System.out.println( request.getRootDispersion() );
- System.out.println( request.getReferenceIdentifier() );
- System.out.println( request.getReferenceTimestamp() );
- System.out.println( request.getOriginateTimestamp() );
- System.out.println( request.getReceiveTimestamp() );
- System.out.println( request.getTransmitTimestamp() );
- }
-
- protected ByteBuffer getByteBufferFromFile(String file) throws IOException
- {
- InputStream is = getClass().getResourceAsStream(file);
-
- byte[] bytes = new byte[ MINIMUM_NTP_DATAGRAM_SIZE ];
-
- int offset = 0;
- int numRead = 0;
- while (offset < bytes.length && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0)
- {
- offset += numRead;
- }
-
- is.close();
-
- return ByteBuffer.wrap(bytes);
- }
-}
+ protected static final int MINIMUM_NTP_DATAGRAM_SIZE = 576;
+ protected final Logger log;
+
+ public AbstractNtpTestCase()
+ {
+ log = LoggerFactory.getLogger( getClass() );
+ }
+
+
+ public AbstractNtpTestCase(Class subclass)
+ {
+ log = LoggerFactory.getLogger( subclass );
+ }
+
+
+ protected void print( NtpMessage request )
+ {
+ log.debug( String.valueOf( request.getLeapIndicator() ) );
+ log.debug( String.valueOf( request.getVersionNumber() ) );
+ log.debug( String.valueOf( request.getMode() ) );
+ log.debug( String.valueOf( request.getStratum() ) );
+ log.debug( String.valueOf( request.getPollInterval() ) );
+ log.debug( String.valueOf( request.getPrecision() ) );
+ log.debug( String.valueOf( request.getRootDelay() ) );
+ log.debug( String.valueOf( request.getRootDispersion() ) );
+ log.debug( String.valueOf( request.getReferenceIdentifier() ) );
+ log.debug( String.valueOf( request.getReferenceTimestamp() ) );
+ log.debug( String.valueOf( request.getOriginateTimestamp() ) );
+ log.debug( String.valueOf( request.getReceiveTimestamp() ) );
+ log.debug( String.valueOf( request.getTransmitTimestamp() ) );
+ }
+
+
+ protected ByteBuffer getByteBufferFromFile( String file ) throws IOException
+ {
+ InputStream is = getClass().getResourceAsStream( file );
+
+ byte[] bytes = new byte[MINIMUM_NTP_DATAGRAM_SIZE];
+
+ int offset = 0;
+ int numRead = 0;
+ while ( offset < bytes.length && ( numRead = is.read( bytes, offset, bytes.length - offset ) ) >= 0 )
+ {
+ offset += numRead;
+ }
+
+ is.close();
+
+ return ByteBuffer.wrap( bytes );
+ }
+}
Propchange: directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/AbstractNtpTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/AbstractNtpTestCase.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageDecoderTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageDecoderTest.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageDecoderTest.java (original)
+++ directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageDecoderTest.java Sun Feb 19 19:57:02 2006
@@ -14,37 +14,39 @@
* limitations under the License.
*
*/
-
package org.apache.directory.server.ntp;
-import java.nio.ByteBuffer;
+import java.nio.ByteBuffer;
import org.apache.directory.server.ntp.io.NtpMessageDecoder;
import org.apache.directory.server.ntp.messages.NtpMessage;
public class NtpMessageDecoderTest extends AbstractNtpTestCase
{
- private ByteBuffer requestByteBuffer;
-
- public void testParseClient() throws Exception
- {
- requestByteBuffer = getByteBufferFromFile( "NTP-CLIENT-UDP.pdu" );
-
- NtpMessageDecoder decoder = new NtpMessageDecoder();
- NtpMessage request = decoder.decode( requestByteBuffer );
-
- print( request );
- }
-
- public void testParseServer() throws Exception
- {
- requestByteBuffer = getByteBufferFromFile( "NTP-SERVER-UDP.pdu" );
-
- NtpMessageDecoder decoder = new NtpMessageDecoder();
- NtpMessage request = decoder.decode( requestByteBuffer );
-
- print( request );
- }
-}
+ private ByteBuffer requestByteBuffer;
+
+ public NtpMessageDecoderTest()
+ {
+ super( NtpMessageDecoderTest.class );
+ }
+
+
+ public void testParseClient() throws Exception
+ {
+ requestByteBuffer = getByteBufferFromFile( "NTP-CLIENT-UDP.pdu" );
+ NtpMessageDecoder decoder = new NtpMessageDecoder();
+ NtpMessage request = decoder.decode( requestByteBuffer );
+ print( request );
+ }
+
+
+ public void testParseServer() throws Exception
+ {
+ requestByteBuffer = getByteBufferFromFile( "NTP-SERVER-UDP.pdu" );
+ NtpMessageDecoder decoder = new NtpMessageDecoder();
+ NtpMessage request = decoder.decode( requestByteBuffer );
+ print( request );
+ }
+}
Propchange: directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageDecoderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageDecoderTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageEncoderTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageEncoderTest.java?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageEncoderTest.java (original)
+++ directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageEncoderTest.java Sun Feb 19 19:57:02 2006
@@ -14,9 +14,9 @@
* limitations under the License.
*
*/
-
package org.apache.directory.server.ntp;
+
import java.nio.ByteBuffer;
import org.apache.directory.server.ntp.io.NtpMessageDecoder;
@@ -32,39 +32,44 @@
public class NtpMessageEncoderTest extends AbstractNtpTestCase
{
- public void testEncodeMessage() throws Exception
- {
- NtpMessageModifier modifier = new NtpMessageModifier();
- modifier.setLeapIndicator( LeapIndicatorType.NO_WARNING );
- modifier.setVersionNumber( 4 );
- modifier.setMode( ModeType.SERVER );
- modifier.setStratum( StratumType.PRIMARY_REFERENCE );
- modifier.setPollInterval( (byte)0x06 ); // 6
- modifier.setPrecision( (byte)0xFA ); // -6
- modifier.setRootDelay( 0 );
- modifier.setRootDispersion( 0 );
- modifier.setReferenceIdentifier( ReferenceIdentifier.LOCL );
-
- NtpTimeStamp now = new NtpTimeStamp();
-
- modifier.setReferenceTimestamp( now );
- modifier.setOriginateTimestamp( now );
- modifier.setReceiveTimestamp( now );
- modifier.setTransmitTimestamp( now );
-
- NtpMessage message = modifier.getNtpMessage();
-
- ByteBuffer replyByteBuffer = ByteBuffer.allocate( 1024 );
-
- NtpMessageEncoder encoder = new NtpMessageEncoder();
- encoder.encode( replyByteBuffer, message );
-
- print( message );
-
- NtpMessageDecoder decoder = new NtpMessageDecoder();
- NtpMessage reply = decoder.decode( replyByteBuffer );
-
- print( reply );
- }
-}
+ public NtpMessageEncoderTest()
+ {
+ super( NtpMessageEncoderTest.class );
+ }
+
+
+ public void testEncodeMessage() throws Exception
+ {
+ NtpMessageModifier modifier = new NtpMessageModifier();
+ modifier.setLeapIndicator( LeapIndicatorType.NO_WARNING );
+ modifier.setVersionNumber( 4 );
+ modifier.setMode( ModeType.SERVER );
+ modifier.setStratum( StratumType.PRIMARY_REFERENCE );
+ modifier.setPollInterval( ( byte ) 0x06 ); // 6
+ modifier.setPrecision( ( byte ) 0xFA ); // -6
+ modifier.setRootDelay( 0 );
+ modifier.setRootDispersion( 0 );
+ modifier.setReferenceIdentifier( ReferenceIdentifier.LOCL );
+
+ NtpTimeStamp now = new NtpTimeStamp();
+
+ modifier.setReferenceTimestamp( now );
+ modifier.setOriginateTimestamp( now );
+ modifier.setReceiveTimestamp( now );
+ modifier.setTransmitTimestamp( now );
+
+ NtpMessage message = modifier.getNtpMessage();
+
+ ByteBuffer replyByteBuffer = ByteBuffer.allocate( 1024 );
+
+ NtpMessageEncoder encoder = new NtpMessageEncoder();
+ encoder.encode( replyByteBuffer, message );
+ print( message );
+
+ NtpMessageDecoder decoder = new NtpMessageDecoder();
+ NtpMessage reply = decoder.decode( replyByteBuffer );
+
+ print( reply );
+ }
+}
Propchange: directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageEncoderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/trunks/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageEncoderTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Feb 19 19:57:02 2006
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id
Modified: directory/trunks/apacheds/protocol-shared/pom.xml
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-shared/pom.xml?rev=379013&r1=379012&r2=379013&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-shared/pom.xml (original)
+++ directory/trunks/apacheds/protocol-shared/pom.xml Sun Feb 19 19:57:02 2006
@@ -4,11 +4,13 @@
<parent>
<groupId>org.apache.directory.server</groupId>
<artifactId>build</artifactId>
- <version>1.0-RC1-SNAPSHOT</version>
+ <version>1.0-RC1</version>
</parent>
<groupId>org.apache.directory.server</groupId>
- <version>0.7.1-SNAPSHOT</version>
<artifactId>apacheds-protocol-shared</artifactId>
+ <description>
+ Shared library that is used by all protocol providers in ApacheDS
+ </description>
<name>ApacheDS Protocol Shared</name>
<packaging>jar</packaging>
<dependencies>
@@ -34,7 +36,7 @@
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-core</artifactId>
- <version>1.0-RC1-SNAPSHOT</version>
+ <version>${pom.version}</version>
</dependency>
</dependencies>
<build>