jicarilla-sandbox/platform/components/http/api/src/java/org/jicarilla/http/util RFC2119.java,NONE,1.1 NioUtil.java,1.4,1.5
Leo Simons <[email protected]>
| Newsgroups | gmane.comp.java.jicarilla.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/api/src/java/org/jicarilla/http/util
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22610/platform/components/http/api/src/java/org/jicarilla/http/util
Modified Files:
NioUtil.java
Added Files:
RFC2119.java
Log Message:
start some early code to tackle the higher-level protocol issues
Index: NioUtil.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/api/src/java/org/jicarilla/http/util/NioUtil.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- NioUtil.java 26 Feb 2004 16:51:54 -0000 1.4
+++ NioUtil.java 9 Apr 2004 18:55:59 -0000 1.5
@@ -71,10 +71,10 @@
final byte[] bytes = new byte[byteBuffer.remaining()];
byteBuffer.get( bytes );
final char[] chars = new char[bytes.length];
+
for( int i = 0; i < bytes.length; i++ )
- {
chars[i] = (char)bytes[i];
- }
+
byteBuffer.rewind();
return chars;
}
@@ -109,10 +109,8 @@
final StringBuffer buffer = new StringBuffer();
for( int i = 0; i < byteBuffers.length; i++ )
- {
- final ByteBuffer byteBuffer = byteBuffers[i];
- buffer.append( toCharArray( byteBuffer ) );
- }
+ buffer.append( toCharArray( byteBuffers[i] ) );
+
return buffer.toString();
}
@@ -120,15 +118,17 @@
{
if( string == null )
return null;
+
+ return ByteBuffer.wrap( string.getBytes() );
- final ByteBuffer bbuf = ByteBuffer.allocate( string.length() );
+ /*final ByteBuffer bbuf = ByteBuffer.allocate( string.length() );
final StringBuffer sbuf = new StringBuffer( string );
for( int i = 0; i < string.length(); i++ )
{
bbuf.put( (byte)sbuf.charAt(i) );
}
bbuf.rewind();
- return bbuf;
+ return bbuf;*/
}
public static ByteBuffer toByteBuffer( final int num )
--- NEW FILE: RFC2119.java ---
/* ====================================================================
The Jicarilla Software License
Copyright (c) 2003 Leo Simons.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.http.util;
import org.jicarilla.lang.Assert;
/**
* Provides programmatic encoding of
* <a href="http://www.ietf.org/rfc/rfc2119.txt">RFC 2119</a>,
* specifying best current practices for naming different
* levels of requirement.
*
* RFC 2119 was written by S. Bradner. The definitions of these
* terms are an amalgam of definitions taken
* from a number of RFCs. In addition, suggestions have been
* incorporated from a number of people including Robert Ullmann, Thomas
* Narten, Neal McBurnett, and Robert Elz.
*
* @author S. Bradner
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: RFC2119.java,v 1.1 2004/04/09 18:55:59 lsimons Exp $
*/
public class RFC2119
{
/**
* This word, or the terms "REQUIRED" or "SHALL", mean that the
* definition is an absolute requirement of the specification.
*/
public final static Level MUST = new Level( 2, "MUST" );
/**
* This phrase, or the phrase "SHALL NOT", mean that the
* definition is an absolute prohibition of the specification.
*/
public final static Level SHOULD = new Level( 1, "SHOULD" );
/**
* This word, or the adjective "RECOMMENDED", mean that there
* may exist valid reasons in particular circumstances to ignore a
* particular item, but the full implications must be understood and
* carefully weighed before choosing a different course.
*/
public final static Level MAY = new Level( 0, "MAY" );
/**
* This phrase, or the phrase "NOT RECOMMENDED" mean that
* there may exist valid reasons in particular circumstances when the
* particular behavior is acceptable or even useful, but the full
* implications should be understood and the case carefully weighed
* before implementing any behavior described with this label.
*/
public final static Level SHOULD_NOT = new Level( -1, "SHOULD NOT" );
/**
* This word, or the adjective "OPTIONAL", mean that an item is
* truly optional. One vendor may choose to include the item because a
* particular marketplace requires it or because the vendor feels that
* it enhances the product while another vendor may omit the same item.
* An implementation which does not include a particular option MUST be
* prepared to interoperate with another implementation which does
* include the option, though perhaps with reduced functionality. In the
* same vein an implementation which does include a particular option
* MUST be prepared to interoperate with another implementation which
* does not include the option (except, of course, for the feature the
* option provides.)
*/
public final static Level MUST_NOT = new Level( -2, "MUST_NOT" );
public static class Level implements Comparable
{
protected Integer m_level;
protected String m_name;
public int compareTo( Object o )
{
if( !(o instanceof Level) )
throw new ClassCastException(
"O must be an instance of level!" );
return m_level.compareTo( ((Level)o).m_level );
}
protected Level( int level, String name )
{
Assert.assertNotNull( name );
m_level = new Integer( level );
m_name = name;
}
public String toString()
{
return m_name;
}
}
}
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click