public static Entity fromString(String entityText) throws IllegalArgumentException {
        Entity retEnt = null;

        entityText = entityText.replace("$$", "$ $").replaceFirst("\\$$", "\\$ ");
        String[] pieces = entityText.split("\\$");

        retEnt = new Entity(pieces[0]);

        if (pieces.length != 3) {
            throw new IllegalArgumentException("Entity malformed");
        }

        String[] attributes = pieces[1].split("#");
        String[] relationships = pieces[2].split("#");

        for (String attribute : attributes) {
            // Remove leading and trailing spaces
            attribute = attribute.trim();

            // Skip empty attributes
            if (attribute.isEmpty()) {
                continue;
            }

            String[] attrPieces = attribute.split(":");

            if (attrPieces.length != 2) {
                throw new IllegalArgumentException("Attribute malformed");
            }

            boolean isPrimaryKey = attrPieces[1].contains("_PRIMARY_KEY");
            if (isPrimaryKey) {
                attrPieces[1] = attrPieces[1].replace("_PRIMARY_KEY", "");
            }

            retEnt.addAttribute(attrPieces[0], AttributeType.valueOf(attrPieces[1]));
            retEnt.setPrimaryKey(attrPieces[0], isPrimaryKey);
        }

        for (String relationship : relationships) {
            // Remove leading and trailing spaces
            relationship = relationship.trim();

            // Skip empty relationships
            if (relationship.isEmpty()) {
                continue;
            }

            String[] relPieces = relationship.split(":");

            // Report malformed attributes
            if (relPieces.length != 2) {
                throw new IllegalArgumentException("Relationship malformed");
            }

            String otherEntityName = relPieces[1];
            Entity otherEntity = EntityManager.getEntityByName(otherEntityName);

            if (otherEntity == null) {
                throw new IllegalArgumentException("Other Entity, \"" + otherEntityName + ",\" doesn't exist");
            }

            retEnt.addRelationship(relPieces[0], otherEntity);
        }

        return retEnt;
    }