text:
sap.ui.define([
	"jquery.sap.global",
	"./_MetadataConverter"
], function (jQuery, _MetadataConverter) {
	"use strict";

	var V2MetadataConverter,
		sModuleName = "sap.ui.model.odata.v4.lib._V2MetadataConverter",

		// namespaces
		sEdmxNamespace = "http://schemas.microsoft.com/ado/2007/06/edmx",
		sMicrosoftNamespace = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata",
		mV2toV4 = {
			"creatable" : {
				"property" : "Insertable",
				"term" : "@Org.OData.Capabilities.V1.InsertRestrictions"
			},
			"deletable" : {
				"property" : "Deletable",
				"term" : "@Org.OData.Capabilities.V1.DeleteRestrictions"
			},
			"deletable-path" : {
				"property" : "Deletable",
				"term" : "@Org.OData.Capabilities.V1.DeleteRestrictions"
			},
			"field-control" : {
				"term" : "@com.sap.vocabularies.Common.v1.FieldControl"
			},
			"heading" : {
				"term" : "@com.sap.vocabularies.Common.v1.Heading"
			},
			"label" : {
				"term" : "@com.sap.vocabularies.Common.v1.Label"
			},
			"precision" : {
				"term" : "@Org.OData.Measures.V1.Scale"
			},
			"quickinfo" : {
				"term" : "@com.sap.vocabularies.Common.v1.QuickInfo"
			},
			"requires-filter" : {
				"property" : "RequiresFilter",
				"term" : "@Org.OData.Capabilities.V1.FilterRestrictions"
			},
			"searchable" : {
				"property" : "Searchable",
				"term" : "@Org.OData.Capabilities.V1.SearchRestrictions"
			},
			"text" : {
				"term" : "@com.sap.vocabularies.Common.v1.Text"
			},
			"updatable" : {
				"property" : "Updatable",
				"term" : "@Org.OData.Capabilities.V1.UpdateRestrictions"
			},
			"updatable-path" : {
				"property" : "Updatable",
				"term" : "@Org.OData.Capabilities.V1.UpdateRestrictions"
			}
		},
		mV2toV4Semantics = {
			"bday" : {
				TermName : "Contact"
			},
			"city" : {
				Path : "adr",
				TermName : "Contact",
				V4Attribute: "locality"
			},
			"country" : {
				Path : "adr",
				TermName : "Contact"
			},
			"familyname" : {
				Path : "n",
				TermName : "Contact",
				V4Attribute: "surname"
			},
			"givenname" : {
				Path : "n",
				TermName : "Contact",
				V4Attribute: "given"
			},
			"honorific" : {
				Path : "n",
				TermName : "Contact",
				V4Attribute: "prefix"
			},
			"middlename" : {
				Path : "n",
				TermName : "Contact",
				V4Attribute: "additional"
			},
			"name" : {
				TermName : "Contact",
				V4Attribute: "fn"
			},
			"nickname" : {
				TermName : "Contact"
			},
			"note" : {
				TermName : "Contact"
			},
			"org" : {
				TermName : "Contact"
			},
			"org-role" : {
				TermName : "Contact",
				V4Attribute : "role"
			},
			"org-unit" : {
				TermName : "Contact",
				V4Attribute : "orgunit"
			},
			"photo" : {
				TermName : "Contact"
			},
			"pobox" : {
				Path : "adr",
				TermName : "Contact"
			},
			"region" : {
				Path : "adr",
				TermName : "Contact"
			},
			"street" : {
				Path : "adr",
				TermName : "Contact"
			},
			"suffix" : {
				Path : "n",
				TermName : "Contact"
			},
			"title" : {
				TermName : "Contact"
			},
			"zip" : {
				Path : "adr",
				TermName : "Contact",
				V4Attribute: "code"
			},
			// event annotations
			"class" : {
				TermName : "Event"
			},
			"dtend" : {
				TermName : "Event"
			},
			"dtstart" : {
				TermName : "Event"
			},
			"duration" : {
				TermName : "Event"
			},
			"fbtype" : {
				TermName : "Event"
			},
			"location" : {
				TermName : "Event"
			},
			"status" : {
				TermName : "Event"
			},
			"transp" : {
				TermName : "Event"
			},
			"wholeday" : {
				TermName : "Event"
			},
			// message annotations
			"body" : {
				TermName : "Message"
			},
			"from" : {
				TermName : "Message"
			},
			"received" : {
				TermName : "Message"
			},
			"sender" : {
				TermName : "Message"
			},
			"subject" : {
				TermName : "Message"
			},
			// task annotations
			"completed" : {
				TermName : "Task"
			},
			"due" : {
				TermName : "Task"
			},
			"percent-complete" : {
				TermName : "Task",
				V4Attribute: "percentcomplete"
			},
			"priority" : {
				TermName : "Task"
			}
		},
		sSapNamespace = "http://www.sap.com/Protocols/SAPData",

		// the configurations for traverse
		oAliasConfig = {
			"DataServices" : {
				"Schema" : {
					__processor : _MetadataConverter.processAlias
				}
			}
		},
		oStructuredTypeConfig = {
			"NavigationProperty" : {
				__processor : processTypeNavigationProperty
			},
			"Property" : {
				__processor : processTypeProperty
			}
		},
		oFullConfig = {
			"DataServices" : {
				__processor : processDataServices,
				"Schema" : {
					__postProcessor : postProcessSchema,
					__processor : _MetadataConverter.processSchema,
					__include : [_MetadataConverter.oAnnotationsConfig],
					"Association" : {
						__processor : processAssociation,
						"End" : {
							__processor : processAssociationEnd
						},
						"ReferentialConstraint" : {
							__processor : processReferentialConstraint,
							"Dependent" : {
								__processor : processDependent,
								"PropertyRef" : {
									__processor : processReferentialConstraintPropertyRef
								}
							},
							"Principal" : {
								__processor : processPrincipal,
								"PropertyRef" : {
									__processor : processReferentialConstraintPropertyRef
								}
							}
						}
					},
					"ComplexType" : {
						__processor : processComplexType,
						__include : [oStructuredTypeConfig]
					},
					"EntityContainer" : {
						__processor : processEntityContainer,
						"AssociationSet" : {
							__processor : processAssociationSet,
							"End" : {
								__processor : processAssociationSetEnd
							}
						},
						"EntitySet" : {
							__processor : processEntitySet
						},
						"FunctionImport" : {
							__processor : processFunctionImport,
							"Parameter" : {
								__processor : processParameter
							}
						}
					},
					"EntityType" : {
						__processor : processEntityType,
						__include : [oStructuredTypeConfig],
						"Key" : {
							"PropertyRef" : {
								__processor : processEntityTypeKeyPropertyRef
							}
						}
					}
				}
			}
		};

	/**
	 * Iterates over all attributes and converts V2 annotations to corresponding V4 annotations
	 * based on the given kind.
	 *
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 * @param {string} sKind The kind of the element, e.g. "EntitySet" or "Property"
	 */
	function convertAnnotations(oElement, oAggregate, sKind) {
		var sElementPath = oAggregate.annotatable.path,
			mAnnotations = oAggregate.convertedV2Annotations[sElementPath] || {},
			oAttribute,
			aAttributes = oElement.attributes,
			sParentPath = oAggregate.annotatable.parent.path,
			mSemanticAnnotations = oAggregate.convertedV2Annotations[sParentPath] || {},
			i,
			n = aAttributes.length;

		if (sKind === "EntityType") {
			setAnnotation(mAnnotations, "label", oElement.getAttributeNS(sSapNamespace, "label"));
		} else {
			for (i = 0; i < n; i++) {
				oAttribute = aAttributes[i];
				if (oAttribute.namespaceURI !== sSapNamespace) {
					continue;
				}
				if (sKind === "EntitySet") {
					convertEntitySetAnnotation(oElement, oAttribute, mAnnotations, oAggregate);
				} else if (sKind === "Property" && oAttribute.localName === "semantics") {
					convertPropertySemanticAnnotations(oAttribute, mSemanticAnnotations);
				} else if (sKind === "Property") {
					convertPropertyAnnotations(oAttribute, mAnnotations);
				}
			}
			if (sKind === "EntitySet"
					&& oElement.getAttributeNS(sSapNamespace, "searchable") !== "true") {
				// default for sap:searchable is false --> add v4 annotation, if value of
				// v2 annotation is not true
				setAnnotation(mAnnotations, "searchable", false);
			}
		}

		if (Object.keys(mAnnotations).length > 0) {
			oAggregate.convertedV2Annotations[sElementPath] = mAnnotations;
		}
		if (Object.keys(mSemanticAnnotations).length > 0) {
			oAggregate.convertedV2Annotations[sParentPath] = mSemanticAnnotations;
		}
	}

	/**
	 * Converts a V2 annotation of an EntitySet to the corresponding V4 annotation and puts
	 * the annotation into the given map of V4 annotations.
	 *
	 * @param {Element} oElement The element
	 * @param {Attr} oAttribute The attribute
	 * @param {object} mAnnotations Map of V4 annotations
	 * @param {object} oAggregate The aggregate (for error handling)
	 */
	function convertEntitySetAnnotation(oElement, oAttribute, mAnnotations, oAggregate) {
		var sConflictingV2Annotation;

		switch (oAttribute.localName){
			case "creatable":
			case "deletable":
			case "updatable":
				if (oAttribute.value === "false") {
					setAnnotation(mAnnotations, oAttribute.localName, false);
				}
				break;
			case "deletable-path":
			case "updatable-path":
				sConflictingV2Annotation = oAttribute.localName.slice(0, 9);
				if (oElement.getAttributeNS(sSapNamespace, sConflictingV2Annotation)) {
					setAnnotation(mAnnotations, oAttribute.localName, false);
					jQuery.sap.log.warning("Inconsistent metadata in '" + oAggregate.url + "'",
						"Use either 'sap:" + sConflictingV2Annotation + "' or 'sap:"
							+ sConflictingV2Annotation + "-path'"
							+ " at entity set '" + oAggregate.annotatable.path + "'", sModuleName);
				} else {
					setAnnotation(mAnnotations, oAttribute.localName, {
						$Path : oAttribute.value
					});
				}
				break;
			case "label":
				mAnnotations["@com.sap.vocabularies.Common.v1.Label"] = oAttribute.value;
				break;
			case "pageable":
				if (oAttribute.value === "false") {
					mAnnotations["@Org.OData.Capabilities.V1.SkipSupported"] = false;
					mAnnotations["@Org.OData.Capabilities.V1.TopSupported"] = false;
				}
				break;
			case "requires-filter":
				if (oAttribute.value === "true") {
					setAnnotation(mAnnotations, oAttribute.localName, true);
				}
				break;
			case "topable":
				if (oAttribute.value === "false") {
					mAnnotations["@Org.OData.Capabilities.V1.TopSupported"] = false;
				}
				break;
			default: //no conversion yet
		}
	}

	/**
	 * Converts a V2 annotation of an EntitySet to the corresponding V4 annotation and puts
	 * the annotation into the given map of V4 annotations.
	 *
	 * @param {Attr} oAttribute The attribute
	 * @param {object} mAnnotations Map of V4 annotations
	 */
	function convertPropertyAnnotations(oAttribute, mAnnotations) {
		switch (oAttribute.localName) {
			// simple cases
			case "heading":
			case "label":
			case "quickinfo":
				setAnnotation(mAnnotations, oAttribute.localName, oAttribute.value);
				break;
			case "field-control":
			case "precision":
			case "text":
				setAnnotation(mAnnotations, oAttribute.localName, {
					$Path : oAttribute.value
				});
				break;
			// more complex cases
			case "aggregation-role":
				if (oAttribute.value === "dimension") {
					mAnnotations["@com.sap.vocabularies.Analytics.v1.Dimension"] = true;
				} else if (oAttribute.value === "measure") {
					mAnnotations["@com.sap.vocabularies.Analytics.v1.Measure"] = true;
				}
				break;
			case "display-format":
				if (oAttribute.value === "NonNegative") {
					mAnnotations["@com.sap.vocabularies.Common.v1.IsDigitSequence"] = true;
				} else if (oAttribute.value === "UpperCase") {
					mAnnotations["@com.sap.vocabularies.Common.v1.IsUpperCase"] = true;
				}
				break;
			case "visible":
				if (oAttribute.value === "false") {
					mAnnotations["@com.sap.vocabularies.UI.v1.Hidden"] = true;
					mAnnotations["@com.sap.vocabularies.Common.v1.FieldControl"] = {
						$EnumMember :
							"com.sap.vocabularies.Common.v1.FieldControlType/Hidden"
					};
				}
				break;
			default:
				//no conversion supported
		}
	}

	/**
	 * Converts a sap:semantics V2 annotation of a property to the corresponding V4 annotation at
	 * an EntityType and puts the annotation into the given map of V4 annotations.
	 *
	 * @param {Attr} oAttribute The attribute
	 * @param {object} mSemanticAnnotations Map of V4 annotations
	 */
	function convertPropertySemanticAnnotations(oAttribute, mSemanticAnnotations) {
		var oAnnotations,
			oPath,
			oSemantics,
			sValue = oAttribute.value;

		if (mV2toV4Semantics[sValue]) {
			oPath = {
				"$Path" : oAttribute.ownerElement.getAttribute("Name")
			};
			oAnnotations = V2MetadataConverter.getOrCreateObject(mSemanticAnnotations,
				"@com.sap.vocabularies.Communication.v1." + mV2toV4Semantics[sValue].TermName);
			if (mV2toV4Semantics[sValue].Path) {
				oSemantics = V2MetadataConverter.getOrCreateObject(oAnnotations,
					mV2toV4Semantics[sValue].Path);
				oSemantics[mV2toV4Semantics[sValue].V4Attribute || sValue] = oPath;
				oAnnotations[mV2toV4Semantics[sValue].Path] = oSemantics;
			} else {
				oAnnotations[mV2toV4Semantics[sValue].V4Attribute || sValue] = oPath;
			}
		}
	}

	/**
	 * Post-processing of an Schema element.
	 *
	 * @param {Element} oElement The element
	 * @param {any[]} aResult The results from child elements
	 * @param {object} oAggregate The aggregate
	 */
	function postProcessSchema(oElement, aResult, oAggregate) {
		if (oAggregate.schema.$Annotations) {
			V2MetadataConverter.mergeAnnotations(oAggregate.convertedV2Annotations,
				oAggregate.schema.$Annotations);
		} else if (Object.keys(oAggregate.convertedV2Annotations).length > 0) {
			oAggregate.schema.$Annotations = oAggregate.convertedV2Annotations;
		}

		oAggregate.convertedV2Annotations = {}; // reset schema annotations for next schema
	}

	/**
	 * Processes an Association element.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processAssociation(oElement, oAggregate) {
		var sName = oAggregate.namespace + oElement.getAttribute("Name");

		oAggregate.associations[sName] = oAggregate.association = {
			referentialConstraint : null,
			roles : {} // maps role name -> AssocationEnd
		};
	}

	/**
	 * Processes an End element below an Association element.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processAssociationEnd(oElement, oAggregate) {
		var sName = oElement.getAttribute("Role");

		oAggregate.association.roles[sName] = {
			multiplicity : oElement.getAttribute("Multiplicity"),
			propertyName : undefined, // will poss. be set in updateNavigationProperties...
			typeName : V2MetadataConverter.resolveAlias(oElement.getAttribute("Type"), oAggregate)
		};
	}

	/**
	 * Processes an AssociationSet element.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processAssociationSet(oElement, oAggregate) {
		var oAssociationSet = {
				associationName : V2MetadataConverter.resolveAlias(
					oElement.getAttribute("Association"), oAggregate),
				ends : []
			};

		oAggregate.associationSet = oAssociationSet;
		oAggregate.associationSets.push(oAssociationSet);
	}

	/**
	 * Processes an End element below an Association or AssociationSet element.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processAssociationSetEnd(oElement, oAggregate) {
		oAggregate.associationSet.ends.push({
			entitySetName : oElement.getAttribute("EntitySet"),
			roleName : oElement.getAttribute("Role")
		});
	}

	/**
	 * Processes a ComplexType element.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processComplexType(oElement, oAggregate) {
		processType(oElement, oAggregate, {"$kind" : "ComplexType"});
	}

	/**
	 * Processes a DataServices element.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processDataServices(oElement, oAggregate) {
		if (oElement.getAttributeNS(sMicrosoftNamespace, "DataServiceVersion") !== "2.0") {
			throw new Error(oAggregate.url + " is not a valid OData V2 metadata document");
		}
	}

	/**
	 * Processes a Dependent element below a ReferentialConstraint element.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processDependent(oElement, oAggregate) {
		var oConstraint = oAggregate.association.referentialConstraint;

		oAggregate.constraintRole = oConstraint.dependent = {
			roleName : oElement.getAttribute("Role")
		};
	}

	/**
	 * Processes an EntityContainer.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processEntityContainer(oElement, oAggregate) {
		var sQualifiedName = oAggregate.namespace + oElement.getAttribute("Name");

		oAggregate.result[sQualifiedName] = oAggregate.entityContainer = {
			"$kind" : "EntityContainer"
		};
		if (oElement.getAttributeNS(sMicrosoftNamespace, "IsDefaultEntityContainer") === "true") {
			oAggregate.defaultEntityContainer = sQualifiedName;
		}
		V2MetadataConverter.annotatable(oAggregate, sQualifiedName);
	}

	/**
	 * Processes an EntitySet element at the EntityContainer.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processEntitySet(oElement, oAggregate) {
		var sName = oElement.getAttribute("Name");

		oAggregate.entityContainer[sName] = oAggregate.entitySet = {
			$kind : "EntitySet",
			$Type :
				V2MetadataConverter.resolveAlias(oElement.getAttribute("EntityType"), oAggregate)
		};
		V2MetadataConverter.annotatable(oAggregate, sName);

		convertAnnotations(oElement, oAggregate, "EntitySet");
	}

	/**
	 * Processes an EntityType element.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processEntityType(oElement, oAggregate) {
		var oType = {
			$kind : "EntityType"
		};

		processType(oElement, oAggregate, oType);
		V2MetadataConverter.processAttributes(oElement, oType, {
			"Abstract" : V2MetadataConverter.setIfTrue,
			"BaseType" : function (sType) {
				return sType ? V2MetadataConverter.resolveAlias(sType, oAggregate) : undefined;
			}
		});

		convertAnnotations(oElement, oAggregate, "EntityType");
	}

	/**
	 * Processes a PropertyRef element of the EntityType's Key.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processEntityTypeKeyPropertyRef(oElement, oAggregate) {
		var sName = oElement.getAttribute("Name");

		V2MetadataConverter.getOrCreateArray(oAggregate.type, "$Key").push(sName);
	}

	/**
	 * Processes a FunctionImport element.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processFunctionImport(oElement, oAggregate) {
		var sHttpMethod = oElement.getAttributeNS(sMicrosoftNamespace, "HttpMethod"),
			sKind = sHttpMethod === "POST" ? "Action" : "Function",
			oFunction = {
				$kind : sKind
			},
			sName = oElement.getAttribute("Name"),
			sQualifiedName = oAggregate.namespace + sName,
			oFunctionImport = {
				$kind : sKind + "Import"
			},
			sReturnType = oElement.getAttribute("ReturnType"),
			oReturnType;

		oFunctionImport["$" + sKind] = sQualifiedName;
		V2MetadataConverter.processAttributes(oElement, oFunctionImport, {
			"EntitySet" : V2MetadataConverter.setValue
		});
		if (sReturnType) {
			oFunction.$ReturnType = oReturnType = {};
			processTypedCollection(sReturnType, oReturnType, oAggregate, oElement);
		}
		if (oElement.getAttributeNS(sSapNamespace, "action-for")) {
			jQuery.sap.log.warning("Unsupported 'sap:action-for' at FunctionImport '" + sName
				+ "', removing this FunctionImport", undefined, sModuleName);
		} else {
			// add Function and FunctionImport to the result
			oAggregate.entityContainer[sName] = oFunctionImport;
			oAggregate.result[sQualifiedName] = [oFunction];
		}
		// Remember the current function (even if it has not been added to the result), so that
		// processParameter adds to this. This avoids that parameters belonging to a removed
		// FunctionImport are added to the predecessor.
		oAggregate.function = oFunction;
		V2MetadataConverter.annotatable(oAggregate, oFunctionImport);
	}

	/**
	 * Processes a Parameter element within an Action or Function.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processParameter(oElement, oAggregate) {
		var oFunction = oAggregate.function,
			oParameter = {
				$Name : oElement.getAttribute("Name")
			};

		V2MetadataConverter.processFacetAttributes(oElement, oParameter);
		processTypedCollection(oElement.getAttribute("Type"), oParameter, oAggregate, oElement);

		V2MetadataConverter.getOrCreateArray(oFunction, "$Parameter").push(oParameter);
		V2MetadataConverter.annotatable(oAggregate, oParameter);
	}

	/**
	 * Processes a Principal element below a ReferentialConstraint element.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processPrincipal(oElement, oAggregate) {
		var oConstraint = oAggregate.association.referentialConstraint;

		oAggregate.constraintRole = oConstraint.principal = {
			roleName : oElement.getAttribute("Role")
		};
	}

	/**
	 * Processes an End element below an Association element.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processReferentialConstraint(oElement, oAggregate) {
		oAggregate.association.referentialConstraint = {};
	}

	/**
	 * Processes an End element below an Association element.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processReferentialConstraintPropertyRef(oElement, oAggregate) {
		oAggregate.constraintRole.propertyRef = oElement.getAttribute("Name");
	}

	/**
	 * Processes a ComplexType or EntityType element.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 * @param {object} oType The initial typed result object
	 */
	function processType(oElement, oAggregate, oType) {
		var sQualifiedName = oAggregate.namespace + oElement.getAttribute("Name");

		oAggregate.result[sQualifiedName] = oAggregate.type = oType;
		V2MetadataConverter.annotatable(oAggregate, sQualifiedName);
	}

	/**
	 * Processes the type in the form "Type" or "Collection(Type)" and sets the appropriate
	 * properties.
	 * @param {string} sType The type attribute from the Element
	 * @param {object} oProperty The property attribute in the JSON
	 * @param {object} oAggregate The aggregate
	 * @param {Element} oElement The element using the type
	 */
	function processTypedCollection(sType, oProperty, oAggregate, oElement) {
		var aMatches = V2MetadataConverter.rCollection.exec(sType);

		if (aMatches) {
			oProperty.$isCollection = true;
			sType = aMatches[1];
		}
		// according to the XSD simple types do not (necessarily) have the namespace "Edm."
		if (sType.indexOf(".") < 0) {
			sType = "Edm." + sType;
		}
		switch (sType) {
			case "Edm.DateTime":
				oProperty.$v2Type = sType;
				if (oElement.getAttributeNS(sSapNamespace, "display-format") === "Date") {
					sType = "Edm.Date";
					delete oProperty.$Precision;
				} else {
					sType = "Edm.DateTimeOffset";
				}
				break;
			case "Edm.Float":
				oProperty.$v2Type = sType;
				sType = "Edm.Single";
				break;
			case "Edm.Time":
				oProperty.$v2Type = sType;
				sType = "Edm.TimeOfDay";
				break;
			default:
				sType = V2MetadataConverter.resolveAlias(sType, oAggregate);
		}
		oProperty.$Type = sType;
	}

	/**
	 * Processes a NavigationProperty element of a structured type.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processTypeNavigationProperty(oElement, oAggregate) {
		var sName = oElement.getAttribute("Name"),
			oProperty = {
				$kind : "NavigationProperty"
			};

		oAggregate.type[sName] = oProperty;
		oAggregate.navigationProperties.push({
			associationName :
				V2MetadataConverter.resolveAlias(oElement.getAttribute("Relationship"), oAggregate),
			fromRoleName : oElement.getAttribute("FromRole"),
			property : oProperty,
			propertyName : sName,
			toRoleName : oElement.getAttribute("ToRole")
		});
	}

	/**
	 * Processes a Property element of a structured type.
	 * @param {Element} oElement The element
	 * @param {object} oAggregate The aggregate
	 */
	function processTypeProperty(oElement, oAggregate) {
		var sName = oElement.getAttribute("Name"),
			oProperty = {
				"$kind" : "Property"
			};

		V2MetadataConverter.processFacetAttributes(oElement, oProperty);
		processTypedCollection(oElement.getAttribute("Type"), oProperty, oAggregate, oElement);

		oAggregate.type[sName] = oProperty;
		V2MetadataConverter.annotatable(oAggregate, sName);

		convertAnnotations(oElement, oAggregate, "Property");
	}

	/**
	 * Sets an annotation for the given V2 name in the given annotations map.
	 * Does nothing if vValue is <code>null</code> or <code>""</code>
	 *
	 * @param {object} mAnnotations Map of annotations to be updated
	 * @param {string} sV2Name The name of the V2 annotation
	 * @param {object|boolean} vValue The new value
	 */
	function setAnnotation(mAnnotations, sV2Name, vValue) {
		var mAnnotationInfo = mV2toV4[sV2Name],
			oAnnotation;
		if (vValue === null || vValue === "") {
			return;
		}
		if (mAnnotationInfo.property) {
			oAnnotation = mAnnotations[mAnnotationInfo.term] || {};
			oAnnotation[mAnnotationInfo.property] = vValue;
		} else {
			oAnnotation = vValue;
		}
		mAnnotations[mAnnotationInfo.term] = oAnnotation;
	}

	/**
	 * Sets $EntityContainer to the default entity container (or the only one).
	 * @param {object} oAggregate The aggregate
	 */
	function setDefaultEntityContainer(oAggregate) {
		var sDefaultEntityContainer = oAggregate.defaultEntityContainer,
			aEntityContainers;

		if (sDefaultEntityContainer) {
			oAggregate.result.$EntityContainer = sDefaultEntityContainer;
		} else {
			aEntityContainers = Object.keys(oAggregate.result).filter(function (sQualifiedName) {
				return oAggregate.result[sQualifiedName].$kind === "EntityContainer";
			});
			if (aEntityContainers.length === 1) {
				oAggregate.result.$EntityContainer = aEntityContainers[0];
			}
		}
	}

	/**
	 * Updates navigation properties and creates navigation property bindings. Iterates over the
	 * aggregated navigation properties list and updates the corresponding navigation properties
	 * from the associations. Iterates over the aggregated association set and tries to create
	 * navigation property bindings for both directions.
	 *
	 * @param {object} oAggregate The aggregate
	 */
	function updateNavigationPropertiesAndCreateBindings(oAggregate) {

		oAggregate.navigationProperties.forEach(function (oNavigationPropertyData) {
			var oAssociation = oAggregate.associations[oNavigationPropertyData.associationName],
				oConstraint = oAssociation.referentialConstraint,
				oNavigationProperty = oNavigationPropertyData.property,
				oToRole = oAssociation.roles[oNavigationPropertyData.toRoleName];

			oNavigationProperty.$Type = oToRole.typeName;
			oToRole.propertyName = oNavigationPropertyData.propertyName;
			if (oToRole.multiplicity === "1") {
				oNavigationProperty.$Nullable = false;
			}
			if (oToRole.multiplicity === "*") {
				oNavigationProperty.$isCollection = true;
			}
			if (oConstraint
					&& oConstraint.principal.roleName === oNavigationPropertyData.toRoleName) {
				oNavigationProperty.$ReferentialConstraint = {};
				oNavigationProperty.$ReferentialConstraint[oConstraint.dependent.propertyRef]
					= oConstraint.principal.propertyRef;
			}
		});

		oAggregate.associationSets.forEach(function (oAssociationSet) {
			var oAssociation = oAggregate.associations[oAssociationSet.associationName],
				oEntityContainer = oAggregate.entityContainer;

			/*
			 * Creates a navigation property binding for the navigation property of the "from" set's
			 * type that has the "to" type as target, using the sets pointing to these types.
			 */
			function createNavigationPropertyBinding(oAssociationSetFrom, oAssociationSetTo) {
				var oEntitySet = oEntityContainer[oAssociationSetFrom.entitySetName],
					oToRole = oAssociation.roles[oAssociationSetTo.roleName];

				if (oToRole.propertyName) {
					oEntitySet.$NavigationPropertyBinding
						= oEntitySet.$NavigationPropertyBinding || {};
					oEntitySet.$NavigationPropertyBinding[oToRole.propertyName]
						= oAssociationSetTo.entitySetName;
				}
			}

			// Try to create navigation property bindings for the two directions
			createNavigationPropertyBinding(oAssociationSet.ends[0], oAssociationSet.ends[1]);
			createNavigationPropertyBinding(oAssociationSet.ends[1], oAssociationSet.ends[0]);
		});
	}

	V2MetadataConverter = jQuery.extend({}, _MetadataConverter, {
		/**
		 * Converts the metadata from XML format to a JSON object.
		 *
		 * @param {Document} oDocument
		 *   The XML DOM document
		 * @param {string} sUrl
		 *   The URL by which this document has been loaded (for error messages)
		 * @returns {object}
		 *   The metadata JSON
		 */
		convertXMLMetadata : function (oDocument, sUrl) {
			var oAggregate, oElement;

			jQuery.sap.measure.average("convertXMLMetadata", "", sModuleName);

			oElement = oDocument.documentElement;
			if (oElement.localName !== "Edmx" || oElement.namespaceURI !== sEdmxNamespace) {
				throw new Error(sUrl + " is not a valid OData V2 metadata document");
			}
			oAggregate = {
				"aliases" : {}, // maps alias -> namespace
				"annotatable" : null, // the current annotatable, see function annotatable
				"association" : null, // the current association
				"associations" : {}, // maps qualified name -> association
				"associationSet" : null, // the current associationSet
				"associationSets" : [], // list of associationSets
				"constraintRole" : null, // the current Principal/Dependent
				// maps annotatable path to a map of converted V2 annotations for current Schema
				"convertedV2Annotations" : {},
				"defaultEntityContainer" : null, // the name of the default EntityContainer
				"entityContainer" : null, // the current EntityContainer
				"entitySet" : null, // the current EntitySet
				"function" : null, // the current function
				"namespace" : null, // the namespace of the current Schema
				"navigationProperties" : [], // a list of navigation property data
				"processFacetAttributes" : V2MetadataConverter.processFacetAttributes,
				"processTypedCollection" : processTypedCollection,
				"schema" : null, // the current Schema
				"type" : null, // the current EntityType/ComplexType
				"result" : {
					"$Version" : "4.0" // The result of the conversion is a V4 streamlined JSON
				},
				"url" : sUrl // the document URL (for error messages)
			};

			// pass 1: find aliases
			V2MetadataConverter.traverse(oElement, oAggregate, oAliasConfig);
			// pass 2: full conversion
			V2MetadataConverter.traverse(oElement, oAggregate, oFullConfig);
			// pass 3
			setDefaultEntityContainer(oAggregate);
			updateNavigationPropertiesAndCreateBindings(oAggregate);

			jQuery.sap.measure.end("convertXMLMetadata");
			return oAggregate.result;
		},

		/**
		 * Merges the given V2 annotations into the given V4 annotations map. If the annotation
		 * is contained in both maps the V4 one wins.
		 * @param {object} mConvertedV2Annotations
		 *   Maps annotatable path to a map of converted V2 annotations; this object is modified
		 *   during the merge
		 * @param {object} [mV4Annotations]
		 *   Maps annotatable path to a map of V4 annotations; V2 annotations are merged into this
		 *   object
		 */
		mergeAnnotations : function (mConvertedV2Annotations, mV4Annotations) {
			var sAnnotatablePath;

			for (sAnnotatablePath in mConvertedV2Annotations) {
				if (sAnnotatablePath in mV4Annotations) {
					mV4Annotations[sAnnotatablePath] = jQuery.extend(
						mConvertedV2Annotations[sAnnotatablePath],
						mV4Annotations[sAnnotatablePath]);
				} else {
					mV4Annotations[sAnnotatablePath] = mConvertedV2Annotations[sAnnotatablePath];
				}
			}
		},

		/**
		 * Processes the TFacetAttributes and TPropertyFacetAttributes of the elements Property,
		 * TypeDefinition etc.
		 * @param {Element} oElement The element
		 * @param {object} oResult The result object to fill
		 */
		processFacetAttributes : function (oElement, oResult) {
			V2MetadataConverter.processAttributes(oElement, oResult, {
				"DefaultValue" : V2MetadataConverter.setValue,
				"MaxLength" : function (sValue) {
					return sValue === "Max" ? undefined : V2MetadataConverter.setNumber(sValue);
				},
				"Nullable" : V2MetadataConverter.setIfFalse,
				"Precision" : V2MetadataConverter.setNumber,
				"Scale" :  V2MetadataConverter.setNumber,
				"Unicode" : V2MetadataConverter.setIfFalse
			});
			if (oElement.getAttribute("FixedLength") === "false") {
				oResult.$Scale = "variable";
			}
		}
	});

	return V2MetadataConverter;
}, /* bExport= */false);


text:
#ifndef HTMLFrameElement_h
#define HTMLFrameElement_h

#include "core/html/HTMLFrameElementBase.h"

namespace blink {

class HTMLFrameElement FINAL : public HTMLFrameElementBase {
    DEFINE_WRAPPERTYPEINFO();
public:
    DECLARE_NODE_FACTORY(HTMLFrameElement);

    bool hasFrameBorder() const { return m_frameBorder; }

    bool noResize() const;

private:
    explicit HTMLFrameElement(Document&);

    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;

    virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE;
    virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE;

    virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;

    bool m_frameBorder;
    bool m_frameBorderSet;
};

} // namespace blink

#endif // HTMLFrameElement_h

redpajama_set_name: RedPajamaGithub


text:
import fs from 'fs-extra';
import request from 'request';
import FileManager from './FileManager.js';

const defaultConfiguration = {
    serviceURL: 'http://helmetrex.com/rbs'
    //serviceURL: 'http://localhost/rbs'
};

class Client {

    constructor (configuration = defaultConfiguration) {
        this.configModel = configuration;
        this.fileManager = new FileManager();
    }

    setupUserCredentials(options){
        return new Promise( (resolve, reject) => {
            this.configModel.user = options.user;
            this.configModel.pass = options.pass;
            resolve();
        });
    }

    removeUserCredentials(){
        return new Promise( (resolve, reject) => {
            this.configModel.user = null;
            this.configModel.pass = null;
            resolve();
        });
    }

    getUser(){
        return this.configModel.user;
    }

    post (methodName, body, isAuth = false) {
        return new Promise( (resolve, reject) => {
            const url = this.configModel.serviceURL + '/' + methodName;
            var requestOptions = {
                uri: url,
                method: 'POST',
                json: true,
                body: body
            };
            if (isAuth) {
                if (this.configModel.user && this.configModel.pass) {
                    requestOptions.auth = {
                        'user': this.configModel.user,
                        'pass': this.configModel.pass,
                        'sendImmediately': true
                    }
                } else {
                    reject('Specify user name and password or create new account.');
                }
            }
            try {
                request(
                    requestOptions,
                    (error, response, body) => {
                        if (response) {
                            if (response.statusCode !== 200) {
                                if (response.statusCode === 401) {
                                    reject('User is not authenticated');
                                } else {
                                    reject('Got error code ' + response.statusCode + ' processing request to ' + url);
                                }
                            } else if (error) {
                                reject('Error connection to ' + this.configModel.serviceURL);
                            } else {
                                if (body.error === true) {
                                    let errorMessage = "Error: ";
                                    if(body.errors && body.errors.length > 0){
                                        body.errors.map( errorStr => {
                                            errorMessage += errorStr + ', ';
                                        });
                                    }
                                    reject(errorMessage.substr(0, errorMessage.length - 2));
                                } else {
                                    resolve(body.data);
                                }
                            }
                        } else {
                            reject('Error connection to ' + this.configModel.serviceURL);
                        }
                    }
                )
            } catch (e) {
                reject('Error: ' + e.message);
            }
        });
    }

    download(methodName, body, isAuth = false) {
        return new Promise( (resolve, reject) => {
            const requestBody = body;
            const url = this.configModel.serviceURL + methodName;
            let requestOptions = {
                uri: url,
                headers: {'Content-type': 'application/json'},
                method: 'POST',
                body: JSON.stringify(requestBody),
                encoding: null
            };
            if (isAuth) {
                if (this.configModel.user && this.configModel.pass) {
                    requestOptions.auth = {
                        'user': this.configModel.user,
                        'pass': this.configModel.pass,
                        'sendImmediately': true
                    }
                } else {
                    reject('Specify user name and password or create new account.');
                }
            }
            try {
                request(
                    requestOptions,
                    (error, response, body) => {
                        if (response) {
                            if (response.statusCode !== 200) {
                                if (response.statusCode === 401) {
                                    reject('User is not authenticated');
                                } else {
                                    reject('Got error code ' + response.statusCode + ' processing request to ' + url);
                                }
                            } else if (error) {
                                reject('Error connection to ' + this.configModel.serviceURL);
                            } else {
                                resolve(body);
                            }
                        } else {
                            reject('Error connection to ' + this.configModel.serviceURL);
                        }
                    }
                )
            } catch (e) {
                reject('Error: ' + e.message);
            }
        });

    }

    downloadGet(methodName, isAuth = false) {
        return new Promise( (resolve, reject) => {
            const url = this.configModel.serviceURL + methodName;
            let requestOptions = {
                uri: url,
                method: 'GET',
                encoding: null
            };
            if (isAuth) {
                if (this.configModel.user && this.configModel.pass) {
                    requestOptions.auth = {
                        'user': this.configModel.user,
                        'pass': this.configModel.pass,
                        'sendImmediately': true
                    }
                } else {
                    reject('Specify user name and password or create new account.');
                }
            }
            try {
                request(
                    requestOptions,
                    (error, response, body) => {
                        if (response) {
                            if (response.statusCode !== 200) {
                                if (response.statusCode === 401) {
                                    reject('User is not authenticated');
                                } else {
                                    reject('Got error code ' + response.statusCode + ' processing request to ' + url);
                                }
                            } else if (error) {
                                reject('Error connection to ' + this.configModel.serviceURL);
                            } else {
                                resolve(body);
                            }
                        } else {
                            reject('Error connection to ' + this.configModel.serviceURL);
                        }
                    }
                )
            } catch (e) {
                reject('Error: ' + e.message);
            }
        });

    }

    upload(option, isAuth = false) {
        return new Promise( (resolve, reject) => {
            const url = this.configModel.serviceURL + option.url;
            let requestOptions = {
                uri: url,
                method: 'POST'
            };
            if (isAuth) {
                if (this.configModel.user && this.configModel.pass) {
                    requestOptions.auth = {
                        'user': this.configModel.user,
                        'pass': this.configModel.pass,
                        'sendImmediately': true
                    }
                } else {
                    reject('Specify user name and password or create new account.');
                }
            }
            requestOptions.formData = {};
            if (option.filePaths && option.filePaths.length > 0) {
                option.filePaths.map( (filePath, index) => {
                    requestOptions.formData['file_' + index] = fs.createReadStream(filePath);
                });
            } else {
                reject('Files for uploading were not specified.');
            }
            try {
                request(
                    requestOptions,
                    (error, response, body) => {
                        if (response) {
                            if (response.statusCode !== 200) {
                                if (response.statusCode === 401) {
                                    reject('User is not authenticated');
                                } else {
                                    reject('Got error code ' + response.statusCode + ' processing request to ' + url);
                                }
                            } else if (error) {
                                reject('Error connection to ' + this.configModel.serviceURL);
                            } else if (body) {
                                if (body.error === true) {
                                    let errorMessage = "Error: ";
                                    if(body.errors && body.errors.length > 0){
                                        body.errors.map( errorStr => {
                                            errorMessage += errorStr + ', ';
                                        });
                                    }
                                    reject(errorMessage.substr(0, errorMessage.length - 2));
                                } else {
                                    resolve(body.data);
                                }
                            }
                        } else {
                            reject('Error connection to ' + this.configModel.serviceURL);
                        }
                    }
                )
            } catch (e) {
                reject('Error: ' + e.message);
            }
        });
    }

}

export default Client;


text:
$:.unshift(File.expand_path('../../lib', __FILE__))

require 'mongo-i18n'
require 'rspec'

connection = Mongo::Connection.new
DB = connection.db('mongo-i18n-store-test')


text: export const DynamicTemplateManager = {};


text:
class CreateWishlistItems < ActiveRecord::Migration
  def change
    create_table :wishlist_items do |t|
      t.integer :group_person_id
      t.text :name_or_url
      t.text :comments
      t.string :image
      t.string :link_title
      t.text :link_description
    end
  end
end


text:
var db    = require('./config/db');
var Event = require('./models/event');

console.log('removing events...');
Event.remove({}, function(){
  console.log("Creating events...");
  Event.create({title: "My Bday Party!", start: "2016-05-11"}).then(process.exit);
});


text:
package logger

// InfoErrorLogger is the interface for logger.
type InfoErrorLogger interface {
	Info(interface{})
	Error(err error)
}


text:
require 'facebooker/model'
module Facebooker

  ##
  # A simple representation of a cookie.
  class Cookie
    include Model
    attr_accessor :uid, :name, :value, :expires, :path
  end
end


text: mvn clean -Dtest=$1 -Dmaven.surefire.debug -Dswarm.debug.port=5005 test


text:
import { Injectable } from '@angular/core';
import { HttpClient} from '@angular/common/http';
import { Observable } from 'rxjs/Observable';

import { CachedHttpService } from '../http/cached-http.service';
import { Data } from '../model/data.model';

@Injectable()
export class RaceEventsHttpService extends CachedHttpService {

  protected endPoint: string = '/rest/events/assigned';

  constructor(protected http: HttpClient) {
    super(http);
  }

  public getRaceEvents(): Observable<Data> {
    return this.getData(this.endPoint);
  }
}


text:
{% comment %}
===============================================================================
Author: (C) 2011 Oliver Gutierrez <ogutsua@evosistemas.com>
Module: templates/evodjango/form.html
Description: Form field include template
===============================================================================
{% endcomment %}

{% load i18n %}

<form id="{% firstof form_name form.form_name %}" method="{% firstof form_method form.form_method 'post' %}" action="{% firstof form_action form.form_action %}"{% if form.is_multipart %} enctype="multipart/form-data"{% endif %}>
	{% csrf_token %}
	{{ form.non_field_errors }}
	{% for fieldset in form.get_fieldsets %}
		<fieldset id="{% firstof form_name form.form_name %}_{{ fieldset.id }}" {% if fieldset.classes %}class="{{ fieldset.classes|join:" " }}"{% endif %}>
			{% if fieldset.name %}
{{ fieldset.name }}
{% endif %}
			{% if fieldset.desc %}
{{ fieldset.desc|safe }}
{% endif %}
			{% for field in fieldset.fields %}
				{% include "evodjango/includes/form_field.html" with field=field %}
			{% endfor %}
		</fieldset>
	{% empty %}
		{% for field in form %}
			{% include "evodjango/includes/form_field.html" with field=field %}
		{% endfor %}
	{% endfor %}

	{% for formset in fieldset.formsets %}
		{% include "evodjango/includes/formset.html" with formset=formset %}
	{% endfor %}

	{# Extra HTML in the form #}
	{{ extra_html }}

	{# Next field commonly used in auth forms #}
	{% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}

		<input id="submit_{% firstof form_name form.form_name %}" type="submit" name="submit_button"{% if submit_label or form.submit_label %} value="{% firstof submit_label form.submit_label %}"{% endif%}{% if form.ajax %} onclick="{{ form.get_ajax_call }}"{% endif %} />
		{% if form.show_reset %}<input id="reset_{% firstof form_name form.form_name %}" type="reset" name="reset_button" value="{{ form.reset_label }}" />{% endif %}

</form>


text:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.preference.PreferenceScreen
  xmlns:android="http://schemas.android.com/apk/res/android">

  <Preference
    android:key="@string/pref_osm_profile"
    android:title="@string/profile"
    android:order="1"/>

  <android.support.v7.preference.PreferenceCategory
    android:key="@string/pref_settings_general"
    android:title="@string/prefs_group_general"
    android:order="2">
    <ListPreference
      android:key="@string/pref_munits"
      android:title="@string/measurement_units"
      android:summary="@string/measurement_units_summary"
      android:entries="@array/measument_units"
      android:entryValues="@array/measument_units_values"
      android:order="1"/>
    <SwitchPreferenceCompat
      android:key="@string/pref_show_zoom_buttons"
      android:title="@string/pref_zoom_title"
      android:summary="@string/pref_zoom_summary"
      android:order="2"/>
    <SwitchPreferenceCompat
      android:key="@string/pref_3d_buildings"
      android:title="@string/pref_map_3d_buildings_title"
      android:order="3"/>
    <SwitchPreferenceCompat
      android:key="@string/pref_autodownload"
      android:title="@string/autodownload"
      android:order="4"/>
    <SwitchPreferenceCompat
      android:key="@string/pref_large_fonts_size"
      android:title="@string/big_font"
      android:defaultValue="false"
      android:order="5"/>
    <!--<SwitchPreferenceCompat-->
      <!--android:key="@string/pref_transliteration"-->
      <!--android:title="@string/whatsnew_transliteration_title"-->
      <!--android:defaultValue="false"-->
      <!--android:order="6"/>-->
    <android.support.v7.preference.PreferenceScreen
      android:key="@string/pref_track_screen"
      android:title="@string/pref_track_record_title"
      android:persistent="false"
      android:order="7">
      <SwitchPreferenceCompat
        android:key="@string/pref_track_record_time"
        android:title="@string/pref_track_record_title"
        android:order="1"/>
      <ListPreference
        android:key="@string/pref_track_record"
        android:title="@string/pref_track_record_title"
        android:entries="@array/track_length"
        android:entryValues="@array/track_length_values"
        android:order="2"/>
      <Preference
        android:selectable="false"
        android:persistent="false"
        android:enabled="false"
        android:summary="@string/recent_track_help_text"
        android:order="3"/>
    </android.support.v7.preference.PreferenceScreen>
    <Preference
      android:key="@string/pref_storage"
      android:title="@string/maps_storage"
      android:summary="@string/maps_storage_summary"
      android:order="8"/>
    <SwitchPreferenceCompat
      android:key="@string/pref_send_statistics"
      android:title="@string/allow_statistics"
      android:summary="@string/allow_statistics_hint"
      android:order="9"/>
    <!--<SwitchPreferenceCompat-->
      <!--android:key="@string/pref_play_services"-->
      <!--android:title="Google Play Services"-->
      <!--android:summary="@string/pref_use_google_play"-->
      <!--android:defaultValue="true"-->
      <!--android:order="10"/>-->
    <SwitchPreferenceCompat
      android:key="@string/pref_showcase_switched_on"
      android:title="@string/showcase_settings_title"
      android:defaultValue="true"
      android:switchTextOff=""
      android:switchTextOn=""
      android:order="11"/>
    <SwitchPreferenceCompat
      android:key="@string/pref_enable_logging"
      android:title="Enable logging"
      android:defaultValue="false"
      android:order="12"/>
    <ListPreference
      android:key="@string/pref_use_mobile_data"
      android:title="@string/mobile_data"
      android:summary="@string/mobile_data_option_ask"
      android:entries="@array/mobile_data_options"
      android:entryValues="@array/mobile_data_options_values"
      android:order="13"/>
  </android.support.v7.preference.PreferenceCategory>

  <android.support.v7.preference.PreferenceCategory
    android:key="@string/pref_navigation"
    android:title="@string/prefs_group_route"
    android:order="3">
    <!--<ListPreference-->
      <!--android:key="@string/pref_map_style"-->
      <!--android:title="@string/pref_map_style_title"-->
      <!--android:entries="@array/map_style"-->
      <!--android:entryValues="@array/map_style_values"-->
      <!--android:order="1"/>-->
    <SwitchPreferenceCompat
      android:key="@string/pref_3d"
      android:title="@string/pref_map_3d_title"
      android:order="2"/>
    <SwitchPreferenceCompat
      android:key="@string/pref_auto_zoom"
      android:title="@string/pref_map_auto_zoom"
      android:order="3"/>
    <!--<SwitchPreferenceCompat-->
      <!--android:key="@string/pref_traffic_simplified_colors"-->
      <!--android:title="@string/pref_traffic_simplified_colors_title"-->
      <!--android:order="4"/>-->
    <android.support.v7.preference.PreferenceScreen
      android:key="@string/pref_tts_screen"
      android:title="@string/pref_tts_enable_title"
      android:persistent="false"
      android:order="5">
      <SwitchPreferenceCompat
        android:key="@string/pref_tts_enabled"
        android:title="@string/pref_tts_enable_title"
        android:order="1"/>
      <ListPreference
        android:key="@string/pref_tts_language"
        android:title="@string/pref_tts_language_title"
        android:order="2"/>
      <Preference
        android:key="@string/pref_tts_info"
        android:selectable="false"
        android:persistent="false"
        android:enabled="false"
        android:summary="@string/prefs_languages_information"
        android:order="3"/>
      <Preference
        android:key="@string/pref_tts_info_link"
        android:selectable="true"
        android:persistent="false"
        android:enabled="true"
        android:summary="@string/prefs_languages_information_off_link"
        android:order="4"/>
    </android.support.v7.preference.PreferenceScreen>
  </android.support.v7.preference.PreferenceCategory>

  <android.support.v7.preference.PreferenceCategory
    android:key="@string/pref_information"
    android:title="@string/prefs_group_information"
    android:order="6">
    <!--<Preference-->
      <!--android:key="@string/pref_help"-->
      <!--android:title="@string/help"-->
      <!--android:fragment="com.mapswithme.maps.settings.HelpFragment"-->
      <!--android:order="1"/>-->
    <Preference
      android:key="@string/pref_about"
      android:title="@string/about"
      android:fragment="com.mapswithme.maps.settings.AboutFragment"
      android:order="2"/>
  </android.support.v7.preference.PreferenceCategory>
</android.support.v7.preference.PreferenceScreen>


text:
Alloy.Globals.extendsBaseViewController($, arguments[0]);

var selectedProject = $.$attrs.selectedProject;

$.titleBar.UIInit($, $.getCurrentWindow());
$.moneyIncomeCategoriesRecentTable.UIInit($, $.getCurrentWindow());

var incomes = Alloy.createCollection("MoneyIncome").xSearchInDb({
	projectId : selectedProject.xGet("id"),
	ownerUserId : Alloy.Models.User.xGet("id")
}, {
	orderBy : "lastClientUpdateTime" + " DESC"
});

var recentIncomeCategories = Alloy.createCollection("MoneyIncomeCategory");
var recentIncomesLength = 5;
if (incomes.length < 5) {
	recentIncomesLength = incomes.length;
}

for (var i = 0; i < recentIncomesLength; i++) {
		recentIncomeCategories.add(incomes.at(i).xGet("moneyIncomeCategory"));
}

$.moneyIncomeCategoriesRecentTable.addCollection(recentIncomeCategories);

$.titleBar.bindXTable($.moneyIncomeCategoriesRecentTable);


text:
<?php

// autoload_namespaces.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'libphonenumber' => array($vendorDir . '/giggsey/libphonenumber-for-php/src'),
    'Twig_Extensions_' => array($vendorDir . '/twig/extensions/lib'),
    'Twig_' => array($vendorDir . '/twig/twig/lib'),
    'Symfony\\' => array($vendorDir . '/symfony/symfony/src'),
    'SymfonyStandard' => array($baseDir . '/app'),
    'Sensio\\Bundle\\GeneratorBundle' => array($vendorDir . '/sensio/generator-bundle'),
    'Sensio\\Bundle\\FrameworkExtraBundle' => array($vendorDir . '/sensio/framework-extra-bundle'),
    'Sensio\\Bundle\\DistributionBundle' => array($vendorDir . '/sensio/distribution-bundle'),
    'Psr\\Log\\' => array($vendorDir . '/psr/log'),
    'Knp\\Menu\\' => array($vendorDir . '/knplabs/knp-menu/src'),
    'Knp\\Bundle\\MenuBundle' => array($vendorDir . '/knplabs/knp-menu-bundle'),
    'Incenteev\\ParameterHandler' => array($vendorDir . '/incenteev/composer-parameter-handler'),
    'FOS\\OAuthServerBundle' => array($vendorDir . '/friendsofsymfony/oauth-server-bundle'),
    'Exporter' => array($vendorDir . '/sonata-project/exporter/lib'),
    'Doctrine\\ORM\\' => array($vendorDir . '/doctrine/orm/lib'),
    'Doctrine\\DBAL\\' => array($vendorDir . '/doctrine/dbal/lib'),
    'Doctrine\\Common\\Lexer\\' => array($vendorDir . '/doctrine/lexer/lib'),
    'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'),
    'Doctrine\\Common\\Collections\\' => array($vendorDir . '/doctrine/collections/lib'),
    'Doctrine\\Common\\Cache\\' => array($vendorDir . '/doctrine/cache/lib'),
    'Doctrine\\Common\\Annotations\\' => array($vendorDir . '/doctrine/annotations/lib'),
    'Doctrine\\Common\\' => array($vendorDir . '/doctrine/common/lib'),
    'Doctrine\\Bundle\\DoctrineCacheBundle' => array($vendorDir . '/doctrine/doctrine-cache-bundle'),
    'Assetic' => array($vendorDir . '/kriswallsmith/assetic/src'),
    '' => array($baseDir . '/src'),
);


text:
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>common</artifactId>
    <groupId>org.sakaiproject.common</groupId>
    <version>10.4</version><!-- ProjectVersion -->
    <relativePath>../pom.xml</relativePath>
  </parent>
  <name>Sakai Privacy Pack</name>
  <groupId>org.sakaiproject.common</groupId>
  <artifactId>sakai-privacy-pack</artifactId>
  <organization>
    <name>Sakai Project</name>
    <url>http://sakaiproject.org/</url>
  </organization>
  <inceptionYear>2004</inceptionYear>
  <packaging>sakai-component</packaging>
  <properties>
    <deploy.target>components</deploy.target>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.sakaiproject.common</groupId>
      <artifactId>sakai-privacy-impl</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.sakaiproject.common</groupId>
          <artifactId>sakai-privacy-hbm</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>
  <build>
    <resources />
  </build>
</project>


text:
package com.mrbysco.miab.entity.memes;

import com.mrbysco.miab.init.MemeLoot;
import com.mrbysco.miab.init.MemeSounds;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWanderAvoidWater;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.EntityMoveHelper;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;

import javax.annotation.Nullable;

public class EntityClippy extends EntityMob {

	public float jumpAmount;
	public float jumpFactor;
	public float prevJumpFactor;
	private boolean wasOnGround;
	public EntityClippy(World worldIn) {
		super(worldIn);
		this.setSize(0.7F, 1.95F);
		this.moveHelper = new EntityClippy.ClippyMoverHelper(this);
	}

	protected void initEntityAI()
	{
		super.initEntityAI();
		this.tasks.addTask(1, new EntityAISwimming(this));
		this.tasks.addTask(1, new EntityClippy.AIHop(this));
		this.tasks.addTask(2, new EntityClippy.AIClippyAttack(this));
		this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
		this.tasks.addTask(4, new EntityAIWander(this, 1.0D));
		this.tasks.addTask(6, new EntityAILookIdle(this));
		this.tasks.addTask(5, new EntityAIWanderAvoidWater(this, 1.0D));

		this.applyEntityAI();
	}

	private void applyEntityAI() {
		this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, new Class[0]));
	}

	@Override
	protected void applyEntityAttributes()
	{
		super.applyEntityAttributes();

		this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(16.0D);
		this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(30.0D);
		this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D);
	}

	@Override
	protected SoundEvent getAmbientSound() {
		Biome biome = this.world.getBiome(this.getPosition());
		SoundEvent sound = SoundEvents.ENTITY_SLIME_HURT;
		if(!this.isDead)
		{
			if(this.world.isDaytime() == false)
			{
				sound = MemeSounds.clippy_night;
			}
			if(BiomeDictionary.hasType(biome, Type.FOREST))
			{
				if(playerNearby() && getPlayerHealth() < 6)
				{
					sound = MemeSounds.clippy_health;
				}
				if(this.posY < 60)
				{
					sound = MemeSounds.clippy_cave;
				}
				sound = MemeSounds.clippy_forest;
			}
			else if(playerNearby() && getPlayerHealth() < 6)
			{
				sound = MemeSounds.clippy_health;
			}
			else if(this.posY < 60)
			{
				sound = MemeSounds.clippy_cave;
			}
			else if(this.world.findNearestStructure("Mineshaft", this.getPosition(), true) == this.getPosition())
			{
				sound = MemeSounds.clippy_mineshaft;
			}
			else
			{
				sound = MemeSounds.clippy_passive;
			}
		}
		return sound;
	}

	private boolean playerNearby()
	{
		EntityPlayer player = this.world.getClosestPlayerToEntity(this, 20);

		return player != null;
	}

	private float getPlayerHealth()
	{
		float health = this.world.getClosestPlayerToEntity(this, 20).getHealth();

		return health;
	}

	@Override
    protected SoundEvent getHurtSound(DamageSource source)
    {
        return MemeSounds.clippy_hurt;
    }

	@Override
    protected SoundEvent getDeathSound()
    {
        return MemeSounds.clippy_death;
    }

	@Nullable
	protected ResourceLocation getLootTable()
	{
		return MemeLoot.CLIPPY_LOOT;
	}

	@Override
	public void onCollideWithPlayer(EntityPlayer entityIn) {
		if (this.canDamagePlayer() && !this.isDead)
		{
			this.dealDamage(entityIn);
		}
	}

	protected boolean canDamagePlayer()
	{
		return this.getAttackTarget() instanceof EntityPlayer;
	}

	protected void dealDamage(EntityLivingBase entityIn)
	{
		int i = 2;

		if (this.canEntityBeSeen(entityIn) && this.getDistanceSq(entityIn) < 0.6D * (double)i * 0.6D * (double)i && entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float)2))
		{
			this.playSound(SoundEvents.ENTITY_SLIME_ATTACK, 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
			this.applyEnchantments(this, entityIn);
		}
	}

	public void writeEntityToNBT(NBTTagCompound compound) {
		super.writeEntityToNBT(compound);
		compound.setBoolean("wasOnGround", this.wasOnGround);
	}

	public void readFromNBT(NBTTagCompound compound) {
		super.readFromNBT(compound);
		this.wasOnGround = compound.getBoolean("wasOnGround");
	}

	public void onUpdate()
	{
		this.jumpFactor += (this.jumpAmount - this.jumpFactor) * 0.5F;
		this.prevJumpFactor = this.jumpFactor;
		super.onUpdate();

		if (this.onGround && !this.wasOnGround)
		{
			int i = 2;
			for (int j = 0; j < i * 8; ++j)
			{
				float f = this.rand.nextFloat() * ((float)Math.PI * 2F);
				float f1 = this.rand.nextFloat() * 0.5F + 0.5F;
				float f2 = MathHelper.sin(f) * (float)i * 0.5F * f1;
				float f3 = MathHelper.cos(f) * (float)i * 0.5F * f1;
				World world = this.world;
				EnumParticleTypes enumparticletypes = EnumParticleTypes.FIREWORKS_SPARK;
				double d0 = this.posX + (double)f2;
				double d1 = this.posZ + (double)f3;
				world.spawnParticle(enumparticletypes, d0, this.getEntityBoundingBox().minY, d1, 0.0D, 0.0D, 0.0D);
			}

			//this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) / 0.8F);
			this.jumpAmount = -0.5F;
		}
		else if (!this.onGround && this.wasOnGround)
		{
			this.jumpAmount = 1.0F;
		}

		this.wasOnGround = this.onGround;
		this.alterJumpAmount();
	}

	protected void alterJumpAmount()
	{
		this.jumpAmount *= 0.6F;
	}

	protected void jump()
	{
		this.motionY = 0.41999998688697815D;
		this.isAirBorne = true;
	}

	/**
	 * Gets the amount of time the clippy needs to wait between jumps.
	 */
	protected int getJumpDelay()
	{
		return this.rand.nextInt(20) + 10;
	}

	protected SoundEvent getJumpSound()
	{
		return MemeSounds.boing;
	}

	static class AIHop extends EntityAIBase
	{
		private final EntityClippy clippy;

		public AIHop(EntityClippy clippyIn)
		{
			this.clippy = clippyIn;
			this.setMutexBits(5);
		}

		/**
		 * Returns whether the EntityAIBase should begin execution.
		 */
		public boolean shouldExecute()
		{
			return true;
		}

		/**
		 * Keep ticking a continuous task that has already been started
		 */
		public void updateTask()
		{
			((EntityClippy.ClippyMoverHelper)this.clippy.getMoveHelper()).setSpeed(1.0D);
		}
	}

	static class ClippyMoverHelper extends EntityMoveHelper
	{
		private float yRot;
		private int jumpDelay;
		private final EntityClippy clippy;
		private boolean isAggressive;

		public ClippyMoverHelper(EntityClippy clippyIn)
		{
			super(clippyIn);
			this.clippy = clippyIn;
			this.yRot = 180.0F * clippyIn.rotationYaw / (float)Math.PI;
		}

		public void setDirection(float p_179920_1_, boolean p_179920_2_)
		{
			this.yRot = p_179920_1_;
			this.isAggressive = p_179920_2_;
		}

		public void setSpeed(double speedIn)
		{
			this.speed = speedIn;
			this.action = EntityMoveHelper.Action.MOVE_TO;
		}

		public void onUpdateMoveHelper()
		{
			this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw, this.yRot, 90.0F);
			this.entity.rotationYawHead = this.entity.rotationYaw;
			this.entity.renderYawOffset = this.entity.rotationYaw;

			if (this.action != EntityMoveHelper.Action.MOVE_TO)
			{
				this.entity.setMoveForward(0.0F);
			}
			else
			{
				this.action = EntityMoveHelper.Action.WAIT;

				if (this.entity.onGround)
				{
					this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue()));

					if (this.jumpDelay-- <= 0)
					{
						this.jumpDelay = this.clippy.getJumpDelay();

						if (this.isAggressive)
						{
							this.jumpDelay /= 3;
						}

						this.clippy.getJumpHelper().setJumping();

						this.clippy.playSound(this.clippy.getJumpSound(), this.clippy.getSoundVolume(), ((this.clippy.getRNG().nextFloat() - this.clippy.getRNG().nextFloat()) * 0.2F + 1.0F) * 0.8F);
					}
					else
					{
						this.clippy.moveStrafing = 0.0F;
						this.clippy.moveForward = 0.0F;
						this.entity.setAIMoveSpeed(0.0F);
					}
				}
				else
				{
					this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue()));
				}
			}
		}
	}

	static class AIClippyAttack extends EntityAIBase
	{
		private final EntityClippy clippy;
		private int growTieredTimer;

		public AIClippyAttack(EntityClippy clippyIn)
		{
			this.clippy = clippyIn;
			this.setMutexBits(2);
		}

		/**
		 * Returns whether the EntityAIBase should begin execution.
		 */
		public boolean shouldExecute()
		{
			EntityLivingBase entitylivingbase = this.clippy.getAttackTarget();

			if (entitylivingbase == null)
			{
				return false;
			}
			else if (!entitylivingbase.isEntityAlive())
			{
				return false;
			}
			else
			{
				return !(entitylivingbase instanceof EntityPlayer) || !((EntityPlayer)entitylivingbase).capabilities.disableDamage;
			}
		}

		/**
		 * Execute a one shot task or start executing a continuous task
		 */
		public void startExecuting()
		{
			this.growTieredTimer = 300;
			super.startExecuting();
		}

		/**
		 * Returns whether an in-progress EntityAIBase should continue executing
		 */
		public boolean shouldContinueExecuting()
		{
			EntityLivingBase entitylivingbase = this.clippy.getAttackTarget();

			if (entitylivingbase == null)
			{
				return false;
			}
			else if (!entitylivingbase.isEntityAlive())
			{
				return false;
			}
			else if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer)entitylivingbase).capabilities.disableDamage)
			{
				return false;
			}
			else
			{
				return --this.growTieredTimer > 0;
			}
		}

		/**
		 * Keep ticking a continuous task that has already been started
		 */
		public void updateTask()
		{
			this.clippy.faceEntity(this.clippy.getAttackTarget(), 10.0F, 10.0F);
			((EntityClippy.ClippyMoverHelper)this.clippy.getMoveHelper()).setDirection(this.clippy.rotationYaw, true);
		}
	}
}


text:
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Reflection;

public class GConfSchemaExtractorProgram
{
    private static Dictionary<string, StringBuilder> entries;
    private static int schema_count;

    public static void Main(string [] args)
    {
        if (args.Length != 2) {
            Console.Error.WriteLine ("Usage: gconf-schema-extractor.exe Foo.dll bar.schema");
            Environment.Exit (1);
        }

        Extract (args [0], args [1]);
    }

    private static void Extract (string assemblyName, string outputFile)
    {
        Assembly asm = Assembly.LoadFrom (assemblyName);
        StringBuilder sbuilder = Extract (asm.GetTypes ());
        if (sbuilder != null) {
            using (StreamWriter writer = new StreamWriter (outputFile)) {
                writer.Write (sbuilder.ToString ());
            }
        }
    }

    internal static StringBuilder Extract (IEnumerable<Type> types)
    {
        schema_count = 0;
        entries = new Dictionary<string, StringBuilder> ();

        foreach (Type type in types) {
            foreach(FieldInfo field in type.GetFields()) {
                if(field.FieldType.IsGenericType &&
                    field.FieldType.GetGenericTypeDefinition().Name.StartsWith("SchemaEntry")) {

                    if(field.Name == "Zero") {
                        continue;
                    }

                    object schema = field.GetValue(null);

                    AddSchemaEntry(schema.GetType().GetField("DefaultValue").GetValue(schema),
                        GetString(schema, "Namespace"),
                        GetString(schema, "Key"),
                        GetString(schema, "ShortDescription"),
                        GetString(schema, "LongDescription")
                    );
                }
            }
        }

        if(schema_count > 0) {
            StringBuilder final = new StringBuilder();
            final.Append("<?xml version=\"1.0\"?>\n");
            final.Append("<gconfschemafile>\n");
            final.Append("  <schemalist>\n");

			List<string> keys = new List<string>(entries.Keys);
			keys.Sort();

			foreach(string key in keys) {
				final.Append(entries[key]);
			}

            final.Append("  </schemalist>\n");
            final.Append("</gconfschemafile>\n");

            return final;
        }
        return null;
    }

    private static string GetString(object o, string name)
    {
        FieldInfo field = o.GetType().GetField(name);
        return (string)field.GetValue(o);
    }

    private static string GetValueString(Type type, object o, out string gctype)
    {
        if(type == typeof(bool)) {
            gctype = "bool";
            return o == null ? null : o.ToString().ToLower();
        } else if(type == typeof(int)) {
            gctype = "int";
        } else if(type == typeof(float) || type == typeof(double)) {
            gctype = "float";
        } else if(type == typeof(string)) {
            gctype = "string";
        } else {
            throw new Exception("Unsupported type '" + type + "'");
        }

        return o == null ? null : o.ToString();
    }

    private static void AddSchemaEntry(object value, string namespce, string key,
        string short_desc, string long_desc)
    {
        schema_count++;

        string full_key = CreateKey(namespce, key);

        bool list = value.GetType().IsArray;
        Type type = list ? Type.GetTypeArray((object [])value)[0] : value.GetType();
        string str_val = null;
        string str_type = null;

        if(list) {
            if(value == null || ((object [])value).Length == 0) {
                GetValueString(type, null, out str_type);
                str_val = "[]";
            } else {
                str_val = "[";
                object [] arr = (object [])value;
                for(int i = 0; i < arr.Length; i++) {
                    str_val += GetValueString(type, arr[i], out str_type).Replace(",", "\\,");
                    if(i < arr.Length - 1) {
                        str_val += ",";
                    }
                }
                str_val += "]";
            }
        } else {
            str_val = GetValueString(type, value, out str_type);
        }

 		StringBuilder builder = new StringBuilder();
        builder.AppendFormat("    <schema>\n");
        builder.AppendFormat("      <key>/schemas{0}</key>\n", full_key);
        builder.AppendFormat("      <applyto>{0}</applyto>\n", full_key);
        builder.AppendFormat("      <owner>banshee</owner>\n");
        if(!list) {
            builder.AppendFormat("      <type>{0}</type>\n", str_type);
        } else {
            builder.AppendFormat("      <type>list</type>\n");
            builder.AppendFormat("      <list_type>{0}</list_type>\n", str_type);
        }
        builder.AppendFormat("      <default>{0}</default>\n", str_val);
        builder.AppendFormat("      <locale name=\"C\">\n");
        builder.AppendFormat("        <short>{0}</short>\n", short_desc);
        builder.AppendFormat("        <long>{0}</long>\n", long_desc);
        builder.AppendFormat("      </locale>\n");
        builder.AppendFormat("    </schema>\n");
		entries.Add(full_key, builder);
    }

    private static string CamelCaseToUnderCase(string s)
    {
        string undercase = String.Empty;
        string [] tokens = Regex.Split(s, "([A-Z]{1}[a-z]+)");

        for(int i = 0; i < tokens.Length; i++) {
            if(tokens[i] == String.Empty) {
                continue;
            }

            undercase += tokens[i].ToLower();
            if(i < tokens.Length - 2) {
                undercase += "_";
            }
        }

        return undercase;
    }

    private static string CreateKey(string namespce, string key)
    {
        return namespce == null
            ? "/apps/banshee/" + CamelCaseToUnderCase(key)
            : "/apps/banshee/" + CamelCaseToUnderCase(namespce.Replace(".", "/"))
                + "/" + CamelCaseToUnderCase(key);
    }
}


text:
class AliReducedBaseTrack : public TObject {

  friend class AliAnalysisTaskReducedTreeMaker;  // friend analysis task which fills the object

  public:
    AliReducedBaseTrack();
    AliReducedBaseTrack(const AliReducedBaseTrack &c);
    virtual ~AliReducedBaseTrack();

    // getters
    UShort_t TrackId()                     const {return fTrackId;}
    Float_t Px()  const {return (fIsCartesian ? fP[0] : TMath::Abs(fP[0])*TMath::Cos(fP[1]));}
    Float_t Py()  const {return (fIsCartesian ? fP[1] : TMath::Abs(fP[0])*TMath::Sin(fP[1]));}
    Float_t Pz()  const {return (fIsCartesian ? fP[2] : TMath::Abs(fP[0])*TMath::SinH(fP[2]));}
    Float_t P()   const {return (fIsCartesian ? TMath::Sqrt(fP[0]*fP[0]+fP[1]*fP[1]+fP[2]*fP[2]) : TMath::Abs(fP[0])*TMath::CosH(fP[2]));}
    Float_t Phi() const;
    Float_t Pt()  const {return (fIsCartesian ? TMath::Sqrt(fP[0]*fP[0]+fP[1]*fP[1]) : fP[0]);}
    Float_t Eta() const;
    Float_t Rapidity(Float_t massAssumption) const;
    Float_t Theta() const;
    Float_t Energy(Float_t massAssumption) const {return TMath::Sqrt(massAssumption*massAssumption+P()*P());}
    Bool_t  TestFlag(UShort_t iflag)       const {return ((iflag<(8*sizeof(ULong_t))) ? fFlags&(ULong_t(1)<<iflag) : kFALSE);}
    ULong_t GetFlags()                     const {return fFlags;}
    Int_t  Charge()                        const {return fCharge;}
    Bool_t IsCartesian() const {return fIsCartesian;}

    ULong_t GetQualityFlags()             const {return fQualityFlags;}
    Bool_t UsedForQvector()               const {return fQualityFlags&(UShort_t(1)<<0);}
    Bool_t TestQualityFlag(UShort_t iflag)  const {return ((iflag<(8*sizeof(ULong_t))) ? fQualityFlags&(ULong_t(1)<<iflag) : kFALSE);}
    Bool_t IsMCTruth()                        const {return (fIsMCTruth ? kTRUE : kFALSE);}
    //Bool_t HasMCTruthInfo()               const {return (fMCFlags ? kTRUE : kFALSE);}
    Bool_t IsTRDmatch()                     const {return fQualityFlags&(ULong_t(1)<<26);}
    Bool_t IsGammaLeg()                   const {return fQualityFlags&(ULong_t(1)<<1);}
    Bool_t IsPureGammaLeg()            const {return fQualityFlags&(ULong_t(1)<<8);}
    Bool_t IsK0sLeg()                           const {return fQualityFlags&(ULong_t(1)<<2);}
    Bool_t IsPureK0sLeg()                   const {return fQualityFlags&(ULong_t(1)<<9);}
    Bool_t IsLambdaLeg()                   const {return fQualityFlags&(ULong_t(1)<<3);}
    Bool_t IsPureLambdaLeg()            const {return fQualityFlags&(ULong_t(1)<<10);}
    Bool_t IsALambdaLeg()                 const {return fQualityFlags&(ULong_t(1)<<4);}
    Bool_t IsPureALambdaLeg()          const {return fQualityFlags&(ULong_t(1)<<11);}
    Bool_t IsKink(Int_t i=0)               const {return (i>=0 && i<3 ? (fQualityFlags&(ULong_t(1)<<(5+i))) : kFALSE);}
    Bool_t IsKinkNegativeLabel(Int_t i=0)     const {return (i>=0 && i<3 ? (fQualityFlags&(ULong_t(1)<<(12+i))) : kFALSE);}
    Float_t GetBayesProb(Int_t specie)  const { return (fQualityFlags&(ULong_t(1)<<(15+specie)) ? (fQualityFlags&(ULong_t(1)<<21) ? 0.9 : (fQualityFlags&(ULong_t(1)<<20) ? 0.8 : (fQualityFlags&(ULong_t(1)<<19)           ? 0.7 : 0.5)))   : 0.0);}

    UInt_t GetMCFlags()                      const {return fMCFlags;}
    Bool_t TestMCFlag(UShort_t iflag) const {return ((iflag<(8*sizeof(UInt_t))) ? fMCFlags & (UInt_t(1)<<iflag) : kFALSE);}
    Bool_t IsMCKineParticle()              const {return (fIsMCTruth ? kTRUE : kFALSE);}

    // setters
    void   Px(Float_t px) {fP[0] = px; fIsCartesian=kTRUE;}
    void   Py(Float_t py) {fP[1] = py; fIsCartesian=kTRUE;}
    void   Pz(Float_t pz) {fP[2] = pz; fIsCartesian=kTRUE;}
    void   PxPyPz(Float_t px, Float_t py, Float_t pz) {fP[0]=px;fP[1]=py;fP[2]=pz;fIsCartesian=kTRUE;}
    void   Pt(Float_t pt) {fP[0] = pt; fIsCartesian=kFALSE;}
    void   Phi(Float_t phi) {fP[1] = phi; fIsCartesian=kFALSE;}
    void   Eta(Float_t eta) {fP[2] = eta; fIsCartesian=kFALSE;}
    void   PtPhiEta(Float_t pt, Float_t phi, Float_t eta) {fP[0]=pt;fP[1]=phi;fP[2]=eta;fIsCartesian=kFALSE;}
    void   Charge(Int_t ch) {fCharge=ch;}
    void   ResetFlags() {fFlags=0;}
    void   SetFlags(ULong_t flags) {fFlags=flags;}
    Bool_t SetFlag(UShort_t iflag)  {if(iflag>=8*sizeof(ULong_t)) return kFALSE; fFlags|=(ULong_t(1)<<iflag); return kTRUE;}
    Bool_t UnsetFlag(UShort_t iflag) {if(iflag>=8*sizeof(ULong_t)) return kFALSE; if(TestFlag(iflag)) fFlags^=(ULong_t(1)<<iflag); return kTRUE;}
    Bool_t SetQualityFlag(UShort_t iflag)      {if (iflag>=8*sizeof(ULong_t)) return kFALSE; fQualityFlags|=(ULong_t(1)<<iflag); return kTRUE;}
    Bool_t UnsetQualityFlag(UShort_t iflag)  {if (iflag>=8*sizeof(ULong_t)) return kFALSE; if(TestQualityFlag(iflag)) fQualityFlags^=(ULong_t(1)<<iflag); return kTRUE;}
    void    SetMCFlags(UInt_t flags) {fMCFlags = flags;}
    Bool_t SetMCFlag(UShort_t iflag) {if(iflag>=8*sizeof(UInt_t)) return kFALSE; fMCFlags |= (UInt_t(1)<<iflag); return kTRUE;}
    Bool_t UnsetMCFlag(UShort_t iflag) {if(iflag>=8*sizeof(UInt_t)) return kFALSE; if(TestMCFlag(iflag)) fMCFlags ^= (UInt_t(1)<<iflag); return kTRUE;}
    void SetIsMCTruth(Bool_t flag=kTRUE) {fIsMCTruth = flag;}

  protected:
    UShort_t fTrackId;            // track id
    Float_t fP[3];         // 3-momentum vector
    Bool_t  fIsCartesian;  // if false then the 3-momentum vector is in spherical coordinates (pt,phi,eta)
    Char_t  fCharge;       // electrical charge
    ULong_t fFlags;        // flags reserved for various operations
    ULong_t fQualityFlags;          // BIT0 toggled if track used for TPC event plane
                                                   // BIT1 toggled if track belongs to a gamma conversion
                                                   // BIT2 toggled if track belongs to a K0s
                                                   // BIT3 toggled if track belongs to a Lambda
                                                   // BIT4 toggled if track belongs to an Anti-Lambda
                                                   // BIT5 toggled if the track has kink0 index > 0
                                                   // BIT6 toggled if the track has kink1 index > 0
                                                   // BIT7 toggled if the track has kink2 index > 0
                                                   // BIT8 toggled if track belongs to a pure gamma conversion
                                                   // BIT9 toggled if track belongs to a pure K0s
                                                   // BIT10 toggled if track belongs to a pure Lambda
                                                   // BIT11 toggled if track belongs to a pure ALambda
                                                   // BIT12 toggled if the track has kink0 index < 0
                                                   // BIT13 toggled if the track has kink1 index < 0
                                                   // BIT14 toggled if the track has kink2 index < 0
                                                   // AOD
                                                   // BIT(15+i) toggled if track has filter bit 0+i , 0 <= i <= 10
                                                   // BIT26 toggled if this is a track matched in TRD

                                                   // For AliReducedPairInfo objects
                                                   // BIT1 toggled for pure V0 K0s candidates
                                                   // BIT2 toggled for pure V0 Lambda candidates
                                                   // BIT3 toggled for pure V0 anti-Lambda candidates
                                                   // BIT4 toggled for pure V0 photon candidates
    UInt_t fMCFlags;                     // flags used to encode Monte-Carlo information
    Bool_t fIsMCTruth;                  // TRUE: if the particle is pure MC track; FALSE: if the particle is a reconstructed track

    AliReducedBaseTrack& operator= (const AliReducedBaseTrack &c);

    ClassDef(AliReducedBaseTrack, 5)
};

//_______________________________________________________________________________
inline Float_t AliReducedBaseTrack::Phi() const {
  //
  // Return the azimuthal angle of this particle
  //
  if(!fIsCartesian) return fP[1];
  Float_t phi=TMath::ATan2(fP[1],fP[0]);
  if(phi>=0.0)
    return phi;
  else
    return (TMath::TwoPi()+phi);
}

//_______________________________________________________________________________
inline Float_t AliReducedBaseTrack::Theta() const {
  //
  // Return the polar angle for this particle
  //
  Float_t p=P();
  if(p>=1.0e-6)
    return TMath::ACos(Pz()/p);
  else
    return 0.0;
}

//_______________________________________________________________________________
inline Float_t AliReducedBaseTrack::Eta() const {
  //
  // Return the pseudorapidity of this particle
  //
  if(!fIsCartesian) return fP[2];
  Float_t eta = TMath::Tan(0.5*Theta());
  if(eta>1.0e-6)
    return -1.0*TMath::Log(eta);
  else
    return 0.0;
}

//_______________________________________________________________________________
inline Float_t AliReducedBaseTrack::Rapidity(Float_t massAssumption) const {
  //
  // Return the rapidity of this particle using a massAssumption
  //
  Float_t e = Energy(massAssumption);
  Float_t factor = e-Pz();
  if(TMath::Abs(factor)<1.0e-6) return 0.0;
  factor = (e+Pz())/factor;
  if(factor<1.0e-6) return 0.0;
  return 0.5*TMath::Log(factor);
}

#endif


text:
package com.hubspot.jackson.jaxrs;

import java.io.IOException;
import java.util.List;

import static com.hubspot.jackson.jaxrs.util.TestResource.TestObject;

public class AlwaysPropertiesTest extends AbstractIntegrationTest {

  @Override
  protected String path() {
    return "/always";
  }

  @Override
  protected String queryParamName() {
    return "property";
  }

  @Override
  public void testNoFiltering() throws IOException {
    List<TestObject> objects = getObjects();

    assertIdPresent(objects);
    assertNameNotPresent(objects);
  }

  @Override
  public void testIncludeName() throws IOException {
    List<TestObject> objects = getObjects("name");

    assertIdPresent(objects);
    assertNamePresent(objects);
  }

  @Override
  public void testExcludeId() throws IOException {
    List<TestObject> objects = getObjects("!id");

    assertIdNotPresent(objects);
    assertNameNotPresent(objects);
  }

  @Override
  public void testExcludeName() throws IOException {
    List<TestObject> objects = getObjects("!name");

    assertIdPresent(objects);
    assertNameNotPresent(objects);
  }

  @Override
  public void testCommaSeparated() throws IOException {
    List<TestObject> objects = getObjects("id,name");

    assertIdPresent(objects);
    assertNamePresent(objects);
  }

}


text:
"""Tests for polyphony_rnn_create_dataset."""

import magenta
from magenta.models.polyphony_rnn import polyphony_encoder_decoder
from magenta.models.polyphony_rnn import polyphony_rnn_pipeline
from magenta.models.shared import events_rnn_model
from magenta.protobuf import music_pb2
import tensorflow as tf

FLAGS = tf.app.flags.FLAGS

class PolySeqPipelineTest(tf.test.TestCase):

  def setUp(self):
    self.config = events_rnn_model.EventSequenceRnnConfig(
        None,
        magenta.music.OneHotEventSequenceEncoderDecoder(
            polyphony_encoder_decoder.PolyphonyOneHotEncoding()),
        tf.contrib.training.HParams())

  def testPolyRNNPipeline(self):
    note_sequence = magenta.common.testing_lib.parse_test_proto(
        music_pb2.NoteSequence,
        """
        time_signatures: {
          numerator: 4
          denominator: 4}
        tempos: {
          qpm: 120}""")
    magenta.music.testing_lib.add_track_to_sequence(
        note_sequence, 0,
        [(36, 100, 0.00, 2.0), (40, 55, 2.1, 5.0), (44, 80, 3.6, 5.0),
         (41, 45, 5.1, 8.0), (64, 100, 6.6, 10.0), (55, 120, 8.1, 11.0),
         (39, 110, 9.6, 9.7), (53, 99, 11.1, 14.1), (51, 40, 12.6, 13.0),
         (55, 100, 14.1, 15.0), (54, 90, 15.6, 17.0), (60, 100, 17.1, 18.0)])

    pipeline_inst = polyphony_rnn_pipeline.get_pipeline(
        min_steps=80,  # 5 measures
        max_steps=512,
        eval_ratio=0,
        config=self.config)
    result = pipeline_inst.transform(note_sequence)
    self.assertTrue(len(result['training_poly_tracks']))

if __name__ == '__main__':
  tf.test.main()