if ((request != null) && request.getAttributes().containsKey(variableName)) { result = request.getAttributes().get(variableName).toString();
Object variable = request.getAttributes().get(variableName); if ((request != null) && (variable != null)) { result = variable.toString();
    private String getVariableContent(String variableName, Request request,            Response response) {        String result = null;        Variable var = getVariables().get(variableName);        if (var == null)            var = getDefaultVariable();        // Check for a matching request attribute        if ((request != null)                && request.getAttributes().containsKey(variableName)) {            result = request.getAttributes().get(variableName).toString();        }        // Check for a matching response attribute        if ((result == null) && (response != null)                && response.getAttributes().containsKey(variableName)) {            result = response.getAttributes().get(variableName).toString();        }        // Check for a matching request or response property        if (result == null) {            if (request != null) {                if (variableName.equals("c")) {                    result = Boolean.toString(request.isConfidential());                } else if (variableName.equals("cia")) {                    result = request.getClientInfo().getAddress();                } else if (variableName.equals("cig")) {                    result = request.getClientInfo().getAgent();                } else if (variableName.equals("cri")) {                    result = request.getChallengeResponse().getIdentifier();                } else if (variableName.equals("crs")) {                    if (request.getChallengeResponse().getScheme() != null) {                        result = request.getChallengeResponse().getScheme()                                .getTechnicalName();                    }                } else if (variableName.equals("ecs")) {                    if ((request.getEntity() != null)                            && (request.getEntity().getCharacterSet() != null)) {                        result = request.getEntity().getCharacterSet()                                .getName();                    }                } else if (variableName.equals("ee")) {                    if ((request.getEntity() != null)                            && (request.getEntity().getEncoding() != null)) {                        result = request.getEntity().getEncoding().getName();                    }                } else if (variableName.equals("eed")) {                    if ((request.getEntity() != null)                            && (request.getEntity().getExpirationDate() != null)) {                        result = DateUtils.format(request.getEntity()                                .getExpirationDate(), DateUtils.FORMAT_RFC_1123                                .get(0));                    }                } else if (variableName.equals("el")) {                    if ((request.getEntity() != null)                            && (request.getEntity().getLanguage() != null)) {                        result = request.getEntity().getLanguage().getName();                    }                } else if (variableName.equals("emd")) {                    if ((request.getEntity() != null)                            && (request.getEntity().getModificationDate() != null)) {                        result = DateUtils.format(request.getEntity()                                .getModificationDate(),                                DateUtils.FORMAT_RFC_1123.get(0));                    }                } else if (variableName.equals("emt")) {                    if ((request.getEntity() != null)                            && (request.getEntity().getMediaType() != null)) {                        result = request.getEntity().getMediaType().getName();                    }                } else if (variableName.equals("es")) {                    if ((request.getEntity() != null)                            && (request.getEntity().getSize() != -1)) {                        result = Long.toString(request.getEntity().getSize());                    }                } else if (variableName.equals("et")) {                    if ((request.getEntity() != null)                            && (request.getEntity().getTag() != null)) {                        result = request.getEntity().getTag().getName();                    }                } else if (variableName.startsWith("f")) {                    result = getReferenceContent(variableName.substring(1),                            request.getReferrerRef());                } else if (variableName.startsWith("h")) {                    result = getReferenceContent(variableName.substring(1),                            request.getHostRef());                } else if (variableName.equals("m")) {                    if (request.getMethod() != null) {                        result = request.getMethod().getName();                    }                } else if (variableName.equals("p")) {                    if (request.getProtocol() != null) {                        result = request.getProtocol().getName();                    }                } else if (variableName.startsWith("r")) {                    result = getReferenceContent(variableName.substring(1),                            request.getResourceRef());                }            }            if ((result == null) && (response != null)) {                if (variableName.equals("ECS")) {                    if ((response.getEntity() != null)                            && (response.getEntity().getCharacterSet() != null)) {                        result = response.getEntity().getCharacterSet()                                .getName();                    }                } else if (variableName.equals("EE")) {                    if ((response.getEntity() != null)                            && (response.getEntity().getEncoding() != null)) {                        result = response.getEntity().getEncoding().getName();                    }                } else if (variableName.equals("EED")) {                    if ((response.getEntity() != null)                            && (response.getEntity().getExpirationDate() != null)) {                        result = DateUtils.format(response.getEntity()                                .getExpirationDate(), DateUtils.FORMAT_RFC_1123                                .get(0));                    }                } else if (variableName.equals("EL")) {                    if ((response.getEntity() != null)                            && (response.getEntity().getLanguage() != null)) {                        result = response.getEntity().getLanguage().getName();                    }                } else if (variableName.equals("EMD")) {                    if ((response.getEntity() != null)                            && (response.getEntity().getModificationDate() != null)) {                        result = DateUtils.format(response.getEntity()                                .getModificationDate(),                                DateUtils.FORMAT_RFC_1123.get(0));                    }                } else if (variableName.equals("EMT")) {                    if ((response.getEntity() != null)                            && (response.getEntity().getMediaType() != null)) {                        result = response.getEntity().getMediaType().getName();                    }                } else if (variableName.equals("ES")) {                    if ((response.getEntity() != null)                            && (response.getEntity().getSize() != -1)) {                        result = Long.toString(response.getEntity().getSize());                    }                } else if (variableName.equals("ET")) {                    if ((response.getEntity() != null)                            && (response.getEntity().getTag() != null)) {                        result = response.getEntity().getTag().getName();                    }                } else if (variableName.startsWith("R")) {                    result = getReferenceContent(variableName.substring(1),                            response.getRedirectRef());                } else if (variableName.equals("S")) {                    if (response.getStatus() != null) {                        result = Integer.toString(response.getStatus()                                .getCode());                    }                } else if (variableName.equals("SIA")) {                    result = response.getServerInfo().getAddress();                } else if (variableName.equals("SIG")) {                    result = response.getServerInfo().getAgent();                } else if (variableName.equals("SIP")) {                    if (response.getServerInfo().getPort() != null) {                        result = response.getServerInfo().getPort().toString();                    }                }            }        }        if (result == null) {            // Use the default value instead            result = var.getDefaultValue();        }        return result;    }