// Path: src/main/java/org/struckture/base/exceptions/FieldConfigurationException.java
// public class FieldConfigurationException extends StruckException {
//     /**
//      * Constructor.
//      * @param message message
//      */
//     public FieldConfigurationException(String message) {
//         super(message);
//     }
// 
//     /**
//      * Constructor.
//      * @param message message
//      * @param cause cause
//      */
//     public FieldConfigurationException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/org/struckture/base/exceptions/StrucktureReadException.java
// public class StrucktureReadException extends StruckException {
// 
//     /**
//      * Constructor.
//      * @param message message
//      */
//     public StrucktureReadException(String message) {
//         super(message);
//     }
// 
//     /**
//      * Constructor.
//      * @param message message
//      * @param cause cause
//      */
//     public StrucktureReadException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }


import org.struckture.base.annotations.StringEncoding;
import org.struckture.base.annotations.StruckField;
import org.struckture.base.exceptions.FieldConfigurationException;
import org.struckture.base.exceptions.StrucktureReadException;
import java.io.UnsupportedEncodingException;
import java.lang.annotation.Annotation;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.Set;
package org.struckture.handlers;



/**
 * String Handler.
 */
public class StringHandler extends AbstractHandler<String> {

    private int size = 0;
    private String encoding = "ASCII";

    @Override
    public void init(Set<Annotation> annotations) {
        super.init(annotations);
        StruckField struckField = getAnnotation(StruckField.class);
        size = struckField.size();

        StringEncoding stringEncoding = getAnnotation(StringEncoding.class);
        if (stringEncoding != null) {
            if (Charset.isSupported(stringEncoding.value())) {
                encoding = stringEncoding.value();
            } else {
// Path: src/main/java/org/struckture/base/exceptions/FieldConfigurationException.java
// public class FieldConfigurationException extends StruckException {
//     /**
//      * Constructor.
//      * @param message message
//      */
//     public FieldConfigurationException(String message) {
//         super(message);
//     }
// 
//     /**
//      * Constructor.
//      * @param message message
//      * @param cause cause
//      */
//     public FieldConfigurationException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/org/struckture/base/exceptions/StrucktureReadException.java
// public class StrucktureReadException extends StruckException {
// 
//     /**
//      * Constructor.
//      * @param message message
//      */
//     public StrucktureReadException(String message) {
//         super(message);
//     }
// 
//     /**
//      * Constructor.
//      * @param message message
//      * @param cause cause
//      */
//     public StrucktureReadException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }


// Path: src/main/java/org/struckture/handlers/StringHandler.java
import org.struckture.base.annotations.StringEncoding;
import org.struckture.base.annotations.StruckField;
import org.struckture.base.exceptions.FieldConfigurationException;
import org.struckture.base.exceptions.StrucktureReadException;
import java.io.UnsupportedEncodingException;
import java.lang.annotation.Annotation;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.Set;

package org.struckture.handlers;



/**
 * String Handler.
 */
public class StringHandler extends AbstractHandler<String> {

    private int size = 0;
    private String encoding = "ASCII";

    @Override
    public void init(Set<Annotation> annotations) {
        super.init(annotations);
        StruckField struckField = getAnnotation(StruckField.class);
        size = struckField.size();

        StringEncoding stringEncoding = getAnnotation(StringEncoding.class);
        if (stringEncoding != null) {
            if (Charset.isSupported(stringEncoding.value())) {
                encoding = stringEncoding.value();
            } else {
                throw new FieldConfigurationException("Encoding '" + encoding + "' is not supported.");