/** * {@inheritDoc} */ @Override public CodecControl<SortResponse> newCodecControl() { return new SortResponseDecorator( codec ); }
/** * {@inheritDoc} */ @Override public byte[] getValue() { if ( value == null ) { try { computeLength(); ByteBuffer buffer = ByteBuffer.allocate( valueLength ); value = encode( buffer ).array(); } catch ( Exception e ) { return null; } } return value; }
/** * {@inheritDoc} */ @Override public SortResultCode getSortResult() { return getDecorated().getSortResult(); }
/** * {@inheritDoc} */ @Override public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException { if ( buffer == null ) { throw new EncoderException( I18n.err( I18n.ERR_08000_CANNOT_PUT_A_PDU_IN_NULL_BUFFER ) ); } buffer.put( UniversalTag.SEQUENCE.getValue() ); buffer.put( TLV.getBytes( sortRespLen ) ); BerValue.encodeEnumerated( buffer, getSortResult().getVal() ); if ( getAttributeName() != null ) { BerValue.encode( buffer, getAttributeName() ); } return buffer; }
/** * {@inheritDoc} */ @Override protected void setIntegerValue( int value, Asn1Container container ) { SortResponseContainer sortRespContainer = ( SortResponseContainer ) container; SortResultCode code = SortResultCode.get( value ); sortRespContainer.getControl().setSortResult( code ); sortRespContainer.setGrammarEndAllowed( true ); } }
/** * {@inheritDoc} */ @Override public Asn1Object decode( byte[] controlBytes ) throws DecoderException { ByteBuffer buffer = ByteBuffer.wrap( controlBytes ); SortResponseContainer container = new SortResponseContainer( getCodecService(), this ); DECODER.decode( buffer, container ); return this; }
@Override public void action( SortResponseContainer container ) throws DecoderException { BerValue value = container.getCurrentTLV().getValue(); String atType = Strings.utf8ToString( value.getData() ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_05310_ATTRIBUTE_TYPE, atType ) ); } container.getControl().setAttributeName( atType ); container.setGrammarEndAllowed( true ); } } );
/** * @return the control length. */ @Override public int computeLength() { sortRespLen = 0; valueLength = 0; // result code value sortRespLen += 1 + 1 + 1; if ( getAttributeName() != null ) { byte[] data = Strings.getBytesUtf8( getAttributeName() ); sortRespLen += 1 + TLV.getNbBytes( data.length ) + data.length; } valueLength = 1 + TLV.getNbBytes( sortRespLen ) + sortRespLen; return valueLength; }
/** * {@inheritDoc} */ @Override public void setSortResult( SortResultCode result ) { getDecorated().setSortResult( result ); }
/** * {@inheritDoc} */ @Override public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException { if ( buffer == null ) { throw new EncoderException( I18n.err( I18n.ERR_08000_CANNOT_PUT_A_PDU_IN_NULL_BUFFER ) ); } buffer.put( UniversalTag.SEQUENCE.getValue() ); buffer.put( TLV.getBytes( sortRespLen ) ); BerValue.encodeEnumerated( buffer, getSortResult().getVal() ); if ( getAttributeName() != null ) { BerValue.encode( buffer, getAttributeName() ); } return buffer; }
/** * {@inheritDoc} */ @Override protected void setIntegerValue( int value, Asn1Container container ) { SortResponseContainer sortRespContainer = ( SortResponseContainer ) container; SortResultCode code = SortResultCode.get( value ); sortRespContainer.getControl().setSortResult( code ); sortRespContainer.setGrammarEndAllowed( true ); } }
/** * {@inheritDoc} */ @Override public Asn1Object decode( byte[] controlBytes ) throws DecoderException { ByteBuffer buffer = ByteBuffer.wrap( controlBytes ); SortResponseContainer container = new SortResponseContainer( getCodecService(), this ); DECODER.decode( buffer, container ); return this; }
@Override public void action( SortResponseContainer container ) throws DecoderException { BerValue value = container.getCurrentTLV().getValue(); String atType = Strings.utf8ToString( value.getData() ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_05310_ATTRIBUTE_TYPE, atType ) ); } container.getControl().setAttributeName( atType ); container.setGrammarEndAllowed( true ); } } );
/** * @return the control length. */ @Override public int computeLength() { sortRespLen = 0; valueLength = 0; // result code value sortRespLen += 1 + 1 + 1; if ( getAttributeName() != null ) { byte[] data = Strings.getBytesUtf8( getAttributeName() ); sortRespLen += 1 + TLV.getNbBytes( data.length ) + data.length; } valueLength = 1 + TLV.getNbBytes( sortRespLen ) + sortRespLen; return valueLength; }
/** * {@inheritDoc} */ @Override public void setAttributeName( String attributeName ) { getDecorated().setAttributeName( attributeName ); }
/** * {@inheritDoc} */ @Override public byte[] getValue() { if ( value == null ) { try { computeLength(); ByteBuffer buffer = ByteBuffer.allocate( valueLength ); value = encode( buffer ).array(); } catch ( Exception e ) { return null; } } return value; }
/** * {@inheritDoc} */ @Override public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException { if ( buffer == null ) { throw new EncoderException( I18n.err( I18n.ERR_08000_CANNOT_PUT_A_PDU_IN_NULL_BUFFER ) ); } buffer.put( UniversalTag.SEQUENCE.getValue() ); buffer.put( TLV.getBytes( sortRespLen ) ); BerValue.encodeEnumerated( buffer, getSortResult().getVal() ); if ( getAttributeName() != null ) { BerValue.encode( buffer, getAttributeName() ); } return buffer; }
/** * {@inheritDoc} */ @Override public CodecControl<SortResponse> newCodecControl( SortResponse control ) { return new SortResponseDecorator( codec, control ); } }
/** * {@inheritDoc} */ @Override protected void setIntegerValue( int value, Asn1Container container ) { SortResponseContainer sortRespContainer = ( SortResponseContainer ) container; SortResultCode code = SortResultCode.get( value ); sortRespContainer.getControl().setSortResult( code ); sortRespContainer.setGrammarEndAllowed( true ); } }
/** * {@inheritDoc} */ @Override public Asn1Object decode( byte[] controlBytes ) throws DecoderException { ByteBuffer buffer = ByteBuffer.wrap( controlBytes ); SortResponseContainer container = new SortResponseContainer( getCodecService(), this ); DECODER.decode( buffer, container ); return this; }