Converts the http entity to string. If entity is null, returns empty string.
@param entity
@return
@throws IOException
165909
public static String entityToString(HttpEntity entity) throws IOException {
        if (entity != null) {
            InputStream is = entity.getContent();
            return IOUtils.toString(is, "UTF-8");
        }
        return "";
    }
4874
public static String generateEntityName(SQLiteDaoDefinition dao, SQLiteEntity entity) {
		String entityName;
		if (entity == null) {
			M2MEntity m2mEntity = M2MEntity.extractEntityManagedByDAO(dao.getElement());
			entityName = m2mEntity.getSimpleName();
		} else {
			entityName = entity.getSimpleName();
		}
		return entityName;
	}
310482
private static <T extends RepresentationModel<?>> HttpHeaders getHeadersWithLinks(ResponseEntity<T> entity) {

		T body = entity.getBody();

		Links links = body != null ? body.getLinks() : Links.NONE;

		HttpHeaders httpHeaders = new HttpHeaders();
		httpHeaders.putAll(entity.getHeaders());
		httpHeaders.add("Link", links.toString());

		return httpHeaders;
	}
1153313
public static String postResponseAsString(String uri, Header header,
            HttpEntity httpEntity) {
        HttpPost httpPost = new HttpPost(uri);
        httpPost.setHeader(header);
        httpPost.setEntity(httpEntity);
        return request(httpPost);
    }
992997
function convertEntity(entity) {
    switch (entity[0]) {
        case '"': {
            if(entity.indexOf("^^") > 0) {
                var parts = entity.split("^^");
                return {literal: parts[0] + "^^<" + parts[1] + ">" };
            } else {
                return { literal: entity };
            }
        }
        case '_': return { blank: entity.replace('b', '') };
        default:  return { token: 'uri', value: entity, prefix: null, suffix: null };
    }
}
50289
@SuppressWarnings("unchecked")
    public static <T> T unwrap(final T entity) {
        if (isProxy(entity)) {
            return (T) asProxy(entity).__unwrap();
        }
        return entity;
    }
899204
public void delete(Object entity) {
    try {
      entityManager.executeEntityListeners(CallbackType.PRE_DELETE, entity);
      Key nativeKey = Marshaller.marshalKey(entityManager, entity);
      nativeWriter.delete(nativeKey);
      entityManager.executeEntityListeners(CallbackType.POST_DELETE, entity);
    } catch (DatastoreException exp) {
      throw DatastoreUtils.wrap(exp);
    }
  }
224140
public static Class getReferentClass(final Object entity) {
        if (isProxy(entity)) {
            return asProxy(entity).__getReferenceObjClass();
        } else {
            return entity != null ? entity.getClass() : null;
        }
    }
528329
private String asJSON(Object entity) {

        String entityJson = null;

        try {
            entityJson = this.mapper.writeValueAsString(entity);
        } catch (Exception e) {
            LOG.error("Could not parse as JSON: " + e.getMessage());
        }

        return entityJson;
    }
243038
public static String generateEntityQualifiedName(SQLiteDaoDefinition dao, SQLiteEntity entity) {
		String entityName;
		if (entity == null) {
			M2MEntity m2mEntity = M2MEntity.extractEntityManagedByDAO(dao.getElement());
			entityName = m2mEntity.getQualifiedName();
		} else {
			entityName = entity.getName().toString();
		}
		return entityName;
	}
943354
public static String getCharset(HttpEntity entity) {
		final String guess = EntityUtils.getContentCharSet(entity);
		return guess == null ? HTTP.DEFAULT_CONTENT_CHARSET : guess;
	}
1180006
public static void makeStringResponse(HttpResponse response, String s) {
        StringEntity entity = new StringEntity(s, ContentType.TEXT_PLAIN);
        entity.setContentEncoding("utf-8");
        response.setEntity(entity);
    }
559263
@SuppressWarnings("unchecked")
	@Override
	public int delete(final Object entity) {
		@SuppressWarnings("rawtypes")
		EntityHandler handler = this.getEntityHandler();
		if (!handler.getEntityType().isInstance(entity)) {
			throw new IllegalArgumentException("Entity type not supported");
		}

		try {
			Class<?> type = entity.getClass();
			TableMetadata metadata = handler.getMetadata(this.transactionManager, type);
			SqlContext context = handler.createDeleteContext(this, metadata, type, true);
			context.setSqlKind(SqlKind.DELETE);
			handler.setDeleteParams(context, entity);
			return handler.doDelete(this, context, entity);
		} catch (SQLException e) {
			throw new EntitySqlRuntimeException(SqlKind.DELETE, e);
		}
	}
1158566
public static boolean isEncoded (final HttpEntity entity) {
        Header h = entity.getContentType();
        if (h != null) {
            HeaderElement[] elems = h.getElements();
            if (elems.length > 0) {
                String contentType = elems[0].getName();
                return contentType.equalsIgnoreCase(CONTENT_TYPE);
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
1158074
public static String getName(ObjectMeta entity) {
    if (entity != null) {
      return Utils.coalesce(entity.getName(),
        getAdditionalPropertyText(entity.getAdditionalProperties(), "id"),
        entity.getUid());
    } else {
      return null;
    }
  }
1239494
public String getCollectionName(Object entity) {
        if (entity == null) {
            return null;
        }

        return getCollectionName(entity.getClass());
    }
1211399
private void serializeEntityDocument(EntityDocument entityDocument) {
		try {
			if (this.entityDocumentCount > 0) {
				this.outputStream.write(JSON_SEP);
			}
			mapper.writeValue(this.outputStream, entityDocument);
		} catch (IOException e) {
			reportException(e);
		}
		this.entityDocumentCount++;
	}