src/share/classes/java/nio/Direct-X-Buffer.java

Print this page




 395             db.limit(end);
 396             cb.put(db);
 397             return new String(ca);
 398         } catch (StringIndexOutOfBoundsException x) {
 399             throw new IndexOutOfBoundsException();
 400         }
 401     }
 402 
 403 
 404     // --- Methods to support CharSequence ---
 405 
 406     public CharBuffer subSequence(int start, int end) {
 407         int pos = position();
 408         int lim = limit();
 409         assert (pos <= lim);
 410         pos = (pos <= lim ? pos : lim);
 411         int len = lim - pos;
 412 
 413         if ((start < 0) || (end > len) || (start > end))
 414             throw new IndexOutOfBoundsException();
 415         int sublen = end - start;
 416         int off = (pos + start) << $LG_BYTES_PER_VALUE$;
 417         assert (off >= 0);
 418         return new DirectCharBuffer$RW$$BO$(this, -1, 0, sublen, sublen, off);


 419     }
 420 
 421 #end[char]
 422 
 423 
 424 
 425 #if[!byte]
 426 
 427     public ByteOrder order() {
 428 #if[boS]
 429         return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
 430                 ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
 431 #end[boS]
 432 #if[boU]
 433         return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN)
 434                 ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
 435 #end[boU]
 436     }
 437 
 438 #end[!byte]




 395             db.limit(end);
 396             cb.put(db);
 397             return new String(ca);
 398         } catch (StringIndexOutOfBoundsException x) {
 399             throw new IndexOutOfBoundsException();
 400         }
 401     }
 402 
 403 
 404     // --- Methods to support CharSequence ---
 405 
 406     public CharBuffer subSequence(int start, int end) {
 407         int pos = position();
 408         int lim = limit();
 409         assert (pos <= lim);
 410         pos = (pos <= lim ? pos : lim);
 411         int len = lim - pos;
 412 
 413         if ((start < 0) || (end > len) || (start > end))
 414             throw new IndexOutOfBoundsException();
 415         return new DirectCharBuffer$RW$$BO$(this, 
 416                                             -1, 
 417                                             pos + start,
 418                                             pos + end,
 419                                             capacity(),
 420                                             offset);
 421     }
 422 
 423 #end[char]
 424 
 425 
 426 
 427 #if[!byte]
 428 
 429     public ByteOrder order() {
 430 #if[boS]
 431         return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
 432                 ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
 433 #end[boS]
 434 #if[boU]
 435         return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN)
 436                 ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
 437 #end[boU]
 438     }
 439 
 440 #end[!byte]