idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
38,800 | private void pushInput ( byte [ ] inputBytes ) throws Exception { buf . write ( inputBytes ) ; while ( buf . size ( ) >= 4 ) { byte [ ] bytes = buf . toByteArray ( ) ; int size = 0 ; size = ( size << 8 ) + byteToInt ( bytes [ 0 ] ) ; size = ( size << 8 ) + byteToInt ( bytes [ 1 ] ) ; size = ( size << 8 ) + byteToInt ( ... | reads the messages from the AUT . |
38,801 | protected void read ( ) throws Exception { InputStream is = socket . getInputStream ( ) ; while ( is . available ( ) > 0 ) { byte [ ] bytes = new byte [ 1024 * 1024 ] ; int read = is . read ( bytes ) ; byte [ ] actuallyRead = new byte [ read ] ; System . arraycopy ( bytes , 0 , actuallyRead , 0 , read ) ; pushInput ( a... | listen for a complete message . |
38,802 | public static String extractMessage ( Throwable e ) { String msg = e . getMessage ( ) ; return msg == null ? "" : ( e instanceof WebDriverException ) ? msg . split ( "\n" ) [ 0 ] : msg ; } | Webdriver exception have debug info for the client . polluting server side . |
38,803 | public void setKeyboardOptions ( ) { File folder = new File ( contentAndSettingsFolder + "/Library/Preferences/" ) ; File preferenceFile = new File ( folder , "com.apple.Preferences.plist" ) ; try { JSONObject preferences = new JSONObject ( ) ; preferences . put ( "KeyboardAutocapitalization" , false ) ; preferences . ... | the default keyboard options aren t good for automation . For instance it automatically capitalize the first letter of sentences etc . Getting rid of all that to have the keyboard execute requests without changing them . |
38,804 | public void setAccessibilityOptions ( ) { File folder = new File ( contentAndSettingsFolder + "/Library/Preferences/" ) ; File preferenceFile = new File ( folder , "com.apple.Accessibility.plist" ) ; try { JSONObject preferences = new JSONObject ( ) ; if ( instrumentsVersion . getMajor ( ) < 6 ) { preferences . put ( "... | Set the Accessibility preferences . Overrides the values in com . apple . Accessibility . plist file . |
38,805 | public void resetContentAndSettings ( ) { if ( instrumentsVersion . getMajor ( ) < 6 ) { if ( hasContentAndSettingsFolder ( ) ) { boolean ok = deleteRecursive ( getContentAndSettingsFolder ( ) ) ; if ( ! ok ) { System . err . println ( "cannot delete content and settings folder " + contentAndSettingsFolder ) ; } } Stri... | Does what IOS Simulator - Reset content and settings menu does by deleting the files on disk . The simulator shouldn t be running when that is done . |
38,806 | private File extract ( InstrumentsVersion version ) { if ( version . getBuild ( ) == null ) { throw new WebDriverException ( "you are running a version of XCode that is too old " + version ) ; } extractFromJar ( "instruments" ) ; extractFromJar ( "InstrumentsShim.dylib" ) ; extractFromJar ( "ScriptAgentShim.dylib" ) ; ... | extract the binaries for the specified version of instruments . |
38,807 | private void processVersionLine ( String log ) { log = log . replace ( start , "" ) ; String [ ] pieces = log . split ( " \\(" ) ; if ( pieces . length == 2 ) { version = pieces [ 0 ] ; build = pieces [ 1 ] . replace ( ")" , "" ) ; } else { version = pieces [ 0 ] ; build = null ; } } | string parsing to get the version out . |
38,808 | public static < T > T augment ( WebDriver driver ) { Augmenter augmenter = new Augmenter ( ) ; augmenter . addDriverAugmentation ( IOSCapabilities . CONFIGURABLE , new AddConfigurable ( ) ) ; augmenter . addDriverAugmentation ( IOSCapabilities . ELEMENT_TREE , new AddLogElementTree ( ) ) ; augmenter . addDriverAugmenta... | Add all the IOS specific interfaces ios - driver supports . |
38,809 | public static File extractAppFromURL ( URL url ) throws IOException { String fileName = url . toExternalForm ( ) . substring ( url . toExternalForm ( ) . lastIndexOf ( '/' ) + 1 ) ; File tmpDir = createTmpDir ( "iosd" ) ; log . fine ( "tmpDir: " + tmpDir . getAbsolutePath ( ) ) ; File downloadedFile = new File ( tmpDir... | Downloads zip from from url extracts it into tmp dir and returns path to extracted directory |
38,810 | private void forceWebViewToReloadManually ( int retry ) { boolean ok = false ; setMode ( WorkingMode . Native ) ; for ( int i = 0 ; i < retry ; i ++ ) { try { WebElement b = getNativeDriver ( ) . findElement ( By . xpath ( "//UIAWindow/UIAScrollView/UIAButton" ) ) ; b . click ( ) ; ok = true ; } catch ( WebDriverExcept... | the webview doesn t refresh correctly if it hasn t been loaded at lease once . |
38,811 | public static WebElement createObject ( RemoteWebDriver driver , Map < String , Object > ro ) { String ref = ro . get ( "ELEMENT" ) . toString ( ) ; String type = ( String ) ro . get ( "type" ) ; if ( type != null ) { String remoteObjectName = "org.uiautomation.ios.client.uiamodels.impl.Remote" + type ; if ( "UIAElemen... | Uses reflection to instanciate a remote object implementing the correct interface . |
38,812 | public Response handle ( ) throws Exception { Object p = getRequest ( ) . getPayload ( ) . get ( "id" ) ; if ( JSONObject . NULL . equals ( p ) ) { getWebDriver ( ) . getContext ( ) . setCurrentFrame ( null , null , null ) ; } else { RemoteWebElement iframe ; if ( p instanceof String ) { iframe = getIframe ( ( String )... | NoSuchFrame - If the frame specified by id cannot be found . |
38,813 | private ImmutableList < LanguageDictionary > loadDictionaries ( ) { Map < String , LanguageDictionary > languageNameMap = new HashMap < > ( ) ; for ( File f : LanguageDictionary . getL10NFiles ( app ) ) { String name = LanguageDictionary . extractLanguageName ( f ) ; LanguageDictionary res = languageNameMap . get ( nam... | Load all the dictionaries for the application . |
38,814 | public Map < String , String > getResources ( ) { Map < String , String > resourceByResourceName = new HashMap < > ( ) ; String metadata = getMetadata ( ICON ) ; if ( metadata . equals ( "" ) ) { metadata = getFirstIconFile ( BUNDLE_ICONS ) ; } resourceByResourceName . put ( ICON , metadata ) ; return resourceByResourc... | the list of resources to publish via http . |
38,815 | public JSONObject readContentFromBinaryFile ( File binaryFile ) throws Exception { PlistFileUtils util = new PlistFileUtils ( binaryFile ) ; return util . toJSON ( ) ; } | load the content of the binary file and returns it as a json object . |
38,816 | private JSONObject getCriteria ( JSONObject payload ) throws JSONException { if ( payload . has ( "criteria" ) ) { JSONObject json = payload . getJSONObject ( "criteria" ) ; return json ; } else if ( payload . has ( "using" ) ) { return getCriteriaFromWebDriverSelector ( payload ) ; } else { throw new InvalidSelectorEx... | create the criteria for the request . If the request follows the webdriver protocol maps it to a criteria ios - driver understands . |
38,817 | private JSONObject getCriteriaFromWebDriverSelector ( JSONObject payload ) throws JSONException { String using = payload . getString ( "using" ) ; String value = payload . getString ( "value" ) ; if ( "tag name" . equals ( using ) || "class name" . equals ( using ) ) { try { Package p = UIAElement . class . getPackage ... | handles the mapping from the webdriver using to a criteria . |
38,818 | public void setCurrentFrame ( RemoteWebElement iframe , RemoteWebElement document , RemoteWebElement window ) { this . iframe = iframe ; this . document = document ; this . window = window ; if ( iframe != null ) { isOnMainFrame = false ; } else { isOnMainFrame = true ; } if ( iframe == null && document == null ) { thi... | breaks the nodeId reference . |
38,819 | public void start ( ) { if ( log . isLoggable ( Level . FINE ) ) { log . fine ( String . format ( "Starting command: %s" , commandString ( ) ) ) ; } ProcessBuilder builder = new ProcessBuilder ( args ) ; if ( workingDir != null ) { builder . directory ( workingDir ) ; } if ( ! environment . isEmpty ( ) ) { Map < String... | Starts the command . Doesn t wait for it to finish . Doesn t wait for stdout and stderr either . |
38,820 | public < T > T execute ( WebDriverLikeRequest request ) { Response response = null ; long total = 0 ; try { HttpClient client = newHttpClientWithTimeout ( ) ; String url = remoteURL + request . getPath ( ) ; BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest ( request . getMethod ( ) , url ) ; if (... | send the request to the remote server for execution . |
38,821 | public Subscription subscribe ( String applicationName , String eventName , String consumerGroup ) throws IOException { return subscription ( applicationName , eventName ) . withConsumerGroup ( consumerGroup ) . subscribe ( ) ; } | Create a subscription for a single event type . |
38,822 | public SubscriptionBuilder subscription ( String applicationName , String eventName ) throws IOException { return new SubscriptionBuilder ( this , applicationName , Collections . singleton ( eventName ) ) ; } | Build a subscription for a single event type . |
38,823 | public SubscriptionBuilder subscription ( String applicationName , Set < String > eventNames ) throws IOException { return new SubscriptionBuilder ( this , applicationName , eventNames ) ; } | Build a subscription for multiple event types . |
38,824 | public void deleteSubscription ( String subscriptionId ) throws IOException { checkArgument ( ! subscriptionId . isEmpty ( ) , "Subscription ID cannot be empty." ) ; final URI uri = baseUri . resolve ( String . format ( "/subscriptions/%s" , subscriptionId ) ) ; final Request request = clientHttpRequestFactory . create... | Delete subscription based on subscription ID . |
38,825 | private HttpURLConnection openConnection ( URL url ) throws IOException { URLConnection urlConnection = url . openConnection ( ) ; if ( ! ( urlConnection instanceof HttpURLConnection ) ) { throw new IllegalStateException ( "Connection should be an HttpURLConnection" ) ; } return ( HttpURLConnection ) urlConnection ; } | Opens and returns a connection to the given URL . |
38,826 | public StreamParameters withCommitTimeout ( int commitTimeout ) { return new StreamParameters ( batchLimit , streamLimit , batchFlushTimeout , streamTimeout , streamKeepAliveLimit , maxUncommittedEvents , commitTimeout ) ; } | Maximum amount of seconds that nakadi will be waiting for commit after sending a batch to a client . If the commit does not come within this timeout nakadi will initialize stream termination no new data will be sent . Partitions from this stream will be assigned to other streams . |
38,827 | private void initializeProcessor ( JsonProcessor processor ) throws ODataUnmarshallingException { LOG . info ( "Trying to initialize processor: {}" , processor . getClass ( ) . getSimpleName ( ) ) ; processor . initialize ( ) ; fields = processor . getValues ( ) ; odataValues = processor . getODataValues ( ) ; links = ... | Initialize processor ready for for unmarshalling entity . |
38,828 | private String getEntityName ( ) throws ODataUnmarshallingException { String odataType = odataValues . get ( JsonConstants . TYPE ) ; if ( isNullOrEmpty ( odataType ) ) { TargetType targetType = getTargetType ( ) ; if ( targetType == null ) { throw new ODataUnmarshallingException ( "Could not find entity name" ) ; } re... | Gets the entity type name . |
38,829 | protected void setEntityNavigationProperties ( Object entity , StructuredType entityType ) throws ODataException { for ( Map . Entry < String , Object > entry : links . entrySet ( ) ) { String propertyName = entry . getKey ( ) ; Object entryLinks = entry . getValue ( ) ; LOG . debug ( "Found link for navigation propert... | Sets the given entity with navigation links . |
38,830 | public void writeStartFeed ( String requestContextURL , Map < String , Object > meta ) throws ODataRenderException { this . contextURL = checkNotNull ( requestContextURL ) ; try { startFeed ( false ) ; if ( ODataUriUtil . hasCountOption ( oDataUri ) && meta != null && meta . containsKey ( "count" ) ) { metadataWriter .... | Write start feed to the XML stream . |
38,831 | public void writeBodyFeed ( List < ? > entities ) throws ODataRenderException { checkNotNull ( entities ) ; try { for ( Object entity : entities ) { writeEntry ( entity , true ) ; } } catch ( XMLStreamException | IllegalAccessException | NoSuchFieldException | ODataEdmException e ) { LOG . error ( "Not possible to mars... | Write feed body . |
38,832 | public String getXml ( ) { try { return ( ( ByteArrayOutputStream ) outputStream ) . toString ( StandardCharsets . UTF_8 . name ( ) ) ; } catch ( UnsupportedEncodingException e ) { return outputStream . toString ( ) ; } } | Get the generated XML . |
38,833 | public static void closeIfNecessary ( Closeable closeable ) throws ODataClientException { if ( closeable != null ) { try { closeable . close ( ) ; } catch ( IOException e ) { throw new ODataClientException ( "Could not close '" + closeable . getClass ( ) . getSimpleName ( ) + "'" , e ) ; } } } | Close closable objects if it is necessary . Mostly used to close connections . |
38,834 | public static Map < String , String > populateRequestProperties ( Map < String , String > requestProperties , int bodyLength , MediaType contentType , MediaType acceptType ) { Map < String , String > properties ; if ( requestProperties == null || requestProperties . isEmpty ( ) ) { properties = new HashMap < > ( ) ; } ... | Util method for first populating request properties before execution . |
38,835 | public Object getAction ( ) throws ODataException { Option < String > actionNameOption = ODataUriUtil . getActionCallName ( odataUri ) ; if ( actionNameOption . isDefined ( ) ) { LOG . debug ( "The operation is supposed to be an action" ) ; String actionName = actionNameOption . get ( ) ; return parseAction ( actionNam... | Returns the instance of Action with all parameters provided by request . |
38,836 | public void addActionImport ( Class < ? > cls ) { EdmActionImport actionImportAnnotation = cls . getAnnotation ( EdmActionImport . class ) ; ActionImportImpl . Builder actionImportBuilder = new ActionImportImpl . Builder ( ) . setEntitySetName ( actionImportAnnotation . entitySet ( ) ) . setActionName ( actionImportAnn... | Adds an action import to factory . |
38,837 | public Iterable < ActionImport > build ( FactoryLookup lookup ) { List < ActionImport > actionImports = new ArrayList < > ( ) ; for ( ActionImportImpl . Builder actionImportBuilder : actionImportBuilders ) { actionImportBuilder . setEntitySet ( lookup . getEntitySet ( actionImportBuilder . getEntitySetName ( ) ) ) ; ac... | Builds action import objects based on registered classes . |
38,838 | public String getJsonError ( ODataException exception ) throws ODataRenderException { checkNotNull ( exception ) ; LOG . debug ( "Start building Json error document" ) ; ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( ) ; try { JsonGenerator jsonGenerator = JSON_FACTORY . createGenerator ( outputStream... | Gets the json error output according to ODataException . |
38,839 | public void writeData ( Object entity , EntityType entityType ) throws XMLStreamException , ODataRenderException { xmlWriter . writeStartElement ( ODATA_CONTENT ) ; xmlWriter . writeAttribute ( TYPE , XML . toString ( ) ) ; xmlWriter . writeStartElement ( METADATA , ODATA_PROPERTIES , "" ) ; marshall ( entity , entityT... | Write the data for a given entity . |
38,840 | private void marshallPrimitive ( Object value , PrimitiveType primitiveType ) throws XMLStreamException { LOG . trace ( "Primitive value: {} of type: {}" , value , primitiveType ) ; if ( value != null ) { xmlWriter . writeCharacters ( value . toString ( ) ) ; } } | Marshall a primitive value . |
38,841 | public void endDocument ( ) throws ODataRenderException { try { xmlWriter . writeEndDocument ( ) ; xmlWriter . flush ( ) ; } catch ( XMLStreamException e ) { LOG . error ( "Not possible to end stream XML" ) ; throw new ODataRenderException ( "Not possible to end stream XML: " , e ) ; } } | End the XML stream document . |
38,842 | public void writeMetadataDocument ( ) throws ODataRenderException { try { xmlWriter . writeStartElement ( EDMX_NS , EDMX ) ; xmlWriter . writeNamespace ( EDMX_PREFIX , EDMX_NS ) ; xmlWriter . writeAttribute ( VERSION , ODATA_VERSION ) ; xmlWriter . writeStartElement ( EDMX_NS , EDMX_DATA_SERVICES ) ; boolean entityCont... | Write the Metadata Document . |
38,843 | public static Type getAndCheckType ( EntityDataModel entityDataModel , Class < ? > javaType ) { Type type = entityDataModel . getType ( javaType ) ; if ( type == null ) { throw new ODataSystemException ( "No type found in the entity data model for Java type: " + javaType . getName ( ) ) ; } return type ; } | Gets the OData type for a Java type and throws an exception if there is no OData type for the Java type . |
38,844 | public static PrimitiveType checkIsPrimitiveType ( Type type ) { if ( ! isPrimitiveType ( type ) ) { throw new ODataSystemException ( "A primitive type is required, but '" + type . getFullyQualifiedName ( ) + "' is not a primitive type: " + type . getMetaType ( ) ) ; } return ( PrimitiveType ) type ; } | Checks if the specified OData type is a primitive type and throws an exception if it is not . |
38,845 | public static PrimitiveType getAndCheckPrimitiveType ( EntityDataModel entityDataModel , String typeName ) { return checkIsPrimitiveType ( getAndCheckType ( entityDataModel , typeName ) ) ; } | Gets the OData type with a specified name and checks if the OData type is a primitive type ; throws an exception if the OData type is not a primitive type . |
38,846 | public static StructuredType checkIsStructuredType ( Type type ) { if ( ! isStructuredType ( type ) ) { throw new ODataSystemException ( "A structured type is required, but '" + type . getFullyQualifiedName ( ) + "' is not a structured type: " + type . getMetaType ( ) ) ; } return ( StructuredType ) type ; } | Checks if the specified OData type is a structured type and throws an exception if it is not . |
38,847 | public static StructuredType getAndCheckStructuredType ( EntityDataModel entityDataModel , String typeName ) { return checkIsStructuredType ( getAndCheckType ( entityDataModel , typeName ) ) ; } | Gets the OData type with a specified name and checks if the OData type is a structured type ; throws an exception if the OData type is not a structured type . |
38,848 | public static StructuredType getAndCheckStructuredType ( EntityDataModel entityDataModel , Class < ? > javaType ) { return checkIsStructuredType ( getAndCheckType ( entityDataModel , javaType ) ) ; } | Gets the OData type for a Java type and checks if the OData type is a structured type ; throws an exception if the OData type is not a structured type . |
38,849 | public static EntityType checkIsEntityType ( Type type ) { if ( ! isEntityType ( type ) ) { throw new ODataSystemException ( "An entity type is required, but '" + type . getFullyQualifiedName ( ) + "' is not an entity type: " + type . getMetaType ( ) ) ; } return ( EntityType ) type ; } | Checks if the specified OData type is an entity type and throws an exception if it is not . |
38,850 | public static EntityType getAndCheckEntityType ( EntityDataModel entityDataModel , String typeName ) { return checkIsEntityType ( getAndCheckType ( entityDataModel , typeName ) ) ; } | Gets the OData type with a specified name and checks if the OData type is an entity type ; throws an exception if the OData type is not an entity type . |
38,851 | public static EntityType getAndCheckEntityType ( EntityDataModel entityDataModel , Class < ? > javaType ) { return checkIsEntityType ( getAndCheckType ( entityDataModel , javaType ) ) ; } | Gets the OData type for a Java type and checks if the OData type is an entity type ; throws an exception if the OData type is not an entity type . |
38,852 | public static ComplexType checkIsComplexType ( Type type ) { if ( ! isComplexType ( type ) ) { throw new ODataSystemException ( "A complex type is required, but '" + type . getFullyQualifiedName ( ) + "' is not a complex type: " + type . getMetaType ( ) ) ; } return ( ComplexType ) type ; } | Checks if the specified OData type is a complex type and throws an exception if it is not . |
38,853 | public static ComplexType getAndCheckComplexType ( EntityDataModel entityDataModel , Class < ? > javaType ) { return checkIsComplexType ( getAndCheckType ( entityDataModel , javaType ) ) ; } | Gets the OData type for a Java type and checks if the OData type is a complex type ; throws an exception if the OData type is not a complex type . |
38,854 | public static String getPropertyTypeName ( StructuralProperty property ) { return property . isCollection ( ) ? property . getElementTypeName ( ) : property . getTypeName ( ) ; } | Gets the OData type name of the property ; if the property is a collection gets the OData type name of the elements of the collection . |
38,855 | public static Type getPropertyType ( EntityDataModel entityDataModel , StructuralProperty property ) { return getAndCheckType ( entityDataModel , getPropertyTypeName ( property ) ) ; } | Gets the OData type of the property ; if the property is a collection gets the OData type of the elements of the collection . |
38,856 | public static StructuralProperty getStructuralProperty ( EntityDataModel entityDataModel , StructuredType structuredType , String propertyName ) { StructuralProperty structuralProperty = structuredType . getStructuralProperty ( propertyName ) ; if ( structuralProperty != null ) { return structuralProperty ; } else { St... | Get the Structural Property from the given Entity Data Model and Structured Type looking up all the base types recursively . |
38,857 | public static Set < String > getKeyPropertyNames ( EntityType entityType ) { Set < String > keyPropertyNames = entityType . getKey ( ) . getPropertyRefs ( ) . stream ( ) . map ( PropertyRef :: getPath ) . collect ( Collectors . toSet ( ) ) ; return keyPropertyNames ; } | Gets the names of the properties that are part of the key of an entity type . |
38,858 | public static Map < String , Object > getKeyPropertyValues ( EntityType entityType , Object entity ) { Map < String , Object > keyPropertyValues = new HashMap < > ( ) ; for ( PropertyRef propertyRef : entityType . getKey ( ) . getPropertyRefs ( ) ) { String propertyName = propertyRef . getPath ( ) ; Object propertyValu... | Gets the values of the properties that part of the key of an entity type . |
38,859 | public static EntitySet getAndCheckEntitySet ( EntityDataModel entityDataModel , String entitySetName ) { EntitySet entitySet = entityDataModel . getEntityContainer ( ) . getEntitySet ( entitySetName ) ; if ( entitySet == null ) { throw new ODataSystemException ( "Entity set not found in the entity data model: " + enti... | Gets the entity set with the specified name throws an exception if no entity set with the specified name exists . |
38,860 | public static EntitySet getEntitySetByEntityTypeName ( EntityDataModel entityDataModel , String entityTypeName ) throws ODataEdmException { for ( EntitySet entitySet : entityDataModel . getEntityContainer ( ) . getEntitySets ( ) ) { if ( entitySet . getTypeName ( ) . equals ( entityTypeName ) ) { return entitySet ; } }... | Get the Entity Set for a given Entity Type name through the Entity Data Model . |
38,861 | public static String getEntityNameByEntityTypeName ( EntityDataModel entityDataModel , String entityTypeName ) throws ODataEdmException { for ( EntitySet entitySet : entityDataModel . getEntityContainer ( ) . getEntitySets ( ) ) { if ( entitySet . getTypeName ( ) . equals ( entityTypeName ) ) { return entitySet . getNa... | Get the Entity Name for a given Entity Type name through the Entity Data Model . This looks for entity in both EntitySets and Singletons in the container |
38,862 | public static EntitySet getEntitySetByEntity ( EntityDataModel entityDataModel , Object entity ) throws ODataEdmException { return getEntitySetByEntityTypeName ( entityDataModel , getAndCheckEntityType ( entityDataModel , entity . getClass ( ) ) . getFullyQualifiedName ( ) ) ; } | Get the Entity Set of a given entity through the Entity Data Model . |
38,863 | public static boolean isSingletonEntity ( EntityDataModel entityDataModel , Object entity ) throws ODataEdmException { EntityType entityType = getAndCheckEntityType ( entityDataModel , entity . getClass ( ) ) ; boolean isSingletonEntity = false ; for ( Singleton singleton : entityDataModel . getEntityContainer ( ) . ge... | Check if the given entity is a Singleton entity . |
38,864 | public static String getEntityName ( EntityDataModel entityDataModel , Object entity ) throws ODataEdmException { EntityType entityType = getAndCheckEntityType ( entityDataModel , entity . getClass ( ) ) ; String entityName = null ; for ( EntitySet entitySet : entityDataModel . getEntityContainer ( ) . getEntitySets ( ... | Get the entity name in the entity data model for the given entity . |
38,865 | public static Singleton getAndCheckSingleton ( EntityDataModel entityDataModel , String singletonName ) { Singleton singleton = entityDataModel . getEntityContainer ( ) . getSingleton ( singletonName ) ; if ( singleton == null ) { throw new ODataSystemException ( "Singleton not found in the entity data model: " + singl... | Gets the singleton with the specified name throws an exception if no singleton with the specified name exists . |
38,866 | public static FunctionImport getAndCheckFunctionImport ( EntityDataModel entityDataModel , String functionImportName ) { FunctionImport functionImport = entityDataModel . getEntityContainer ( ) . getFunctionImport ( functionImportName ) ; if ( functionImport == null ) { throw new ODataSystemException ( "Function import... | Gets the function import by the specified name throw an exception if no function import with the specified name exists . |
38,867 | public static ActionImport getAndCheckActionImport ( EntityDataModel entityDataModel , String actionImportName ) { ActionImport actionImport = entityDataModel . getEntityContainer ( ) . getActionImport ( actionImportName ) ; if ( actionImport == null ) { throw new ODataSystemException ( "Action import not found in the ... | Gets the action import by the specified name throw an exception if no action import with the specified name exists . |
38,868 | public static Action getAndCheckAction ( EntityDataModel entityDataModel , String actionName ) { int namespaceLastIndex = actionName . lastIndexOf ( '.' ) ; String namespace = actionName . substring ( 0 , namespaceLastIndex ) ; String simpleActionName = actionName . substring ( namespaceLastIndex + 1 ) ; Schema schema ... | Gets the action by the specified name throw an exception if no action with the specified name exists . |
38,869 | public static boolean isCollection ( EntityDataModel entityDataModel , String typeName ) { EntitySet entitySet = entityDataModel . getEntityContainer ( ) . getEntitySet ( typeName ) ; if ( entitySet != null ) { return true ; } try { if ( Collection . class . isAssignableFrom ( Class . forName ( typeName ) ) || COLLECTI... | Checks if the specified typeName is a collection . |
38,870 | public static String formatEntityKey ( EntityDataModel entityDataModel , Object entity ) throws ODataEdmException { Key entityKey = getAndCheckEntityType ( entityDataModel , entity . getClass ( ) ) . getKey ( ) ; List < PropertyRef > keyPropertyRefs = entityKey . getPropertyRefs ( ) ; try { if ( keyPropertyRefs . size ... | Get the entity key for a given entity by inspecting the Entity Data Model . |
38,871 | public static String pluralize ( String word ) { if ( word == null ) { throw new IllegalArgumentException ( ) ; } final String lowerCaseWord = word . toLowerCase ( ) ; if ( endsWithAny ( lowerCaseWord , "s" , "sh" , "o" ) ) { return word + "es" ; } if ( lowerCaseWord . endsWith ( "y" ) && ! lowerCaseWord . endsWith ( "... | Get the plural for the given English word . |
38,872 | protected int scoreServiceDocument ( ODataRequestContext requestContext , MediaType requiredMediaType ) { if ( isServiceDocument ( requestContext . getUri ( ) ) ) { int scoreByFormat = scoreByFormat ( getFormatOption ( requestContext . getUri ( ) ) , requiredMediaType ) ; int scoreByMediaType = scoreByMediaType ( reque... | Calculate a score for a Service Document Renderer based on a given OData request context and required media type . |
38,873 | public void initialize ( ) throws ODataUnmarshallingException { LOG . info ( "Parser is initializing" ) ; try { JsonParser jsonParser = JSON_FACTORY . createParser ( inputJson ) ; while ( jsonParser . nextToken ( ) != JsonToken . END_OBJECT ) { String token = jsonParser . getCurrentName ( ) ; if ( token != null ) { if ... | Initialize processor automatically scanning the input JSON . |
38,874 | private void process ( JsonParser jsonParser ) throws IOException , ODataUnmarshallingException { if ( jsonParser . getCurrentToken ( ) == JsonToken . FIELD_NAME ) { LOG . info ( "Starting to parse {} token" , jsonParser . getCurrentName ( ) ) ; String key = jsonParser . getCurrentName ( ) ; jsonParser . nextToken ( ) ... | Process all things that do not contain special ODataTags . |
38,875 | private List < Object > getCollectionValue ( JsonParser jsonParser ) throws IOException { LOG . info ( "Start parsing {} array" , jsonParser . getCurrentName ( ) ) ; List < Object > list = new ArrayList < > ( ) ; while ( jsonParser . nextToken ( ) != JsonToken . END_ARRAY ) { if ( jsonParser . getCurrentToken ( ) == Js... | Parse the complex values . |
38,876 | private Object getEmbeddedObject ( JsonParser jsonParser ) throws IOException { LOG . info ( "Start parsing an embedded object." ) ; Map < String , Object > embeddedMap = new HashMap < > ( ) ; while ( jsonParser . nextToken ( ) != JsonToken . END_OBJECT ) { String key = jsonParser . getText ( ) ; jsonParser . nextToken... | Process an embedded object . |
38,877 | private void processLinks ( JsonParser jsonParser ) throws IOException { LOG . info ( "@odata.bind tag found - start parsing" ) ; final String fullLinkFieldName = jsonParser . getText ( ) ; final String key = fullLinkFieldName . substring ( 0 , fullLinkFieldName . indexOf ( ODATA_BIND ) ) ; JsonToken token = jsonParser... | Process OData links . |
38,878 | private String processLink ( JsonParser jsonParser ) throws IOException { final String link = jsonParser . getText ( ) ; if ( link . contains ( SVC_EXTENSION ) ) { return link . substring ( link . indexOf ( SVC_EXTENSION ) + SVC_EXTENSION . length ( ) ) ; } return link ; } | Process OData link . |
38,879 | public void fillUpdatedObjectProperty ( Object entity , Object currentNode , StructuralProperty property , Field field , String node , Map < String , Object > map ) throws ODataException { for ( Map . Entry < String , Object > entry : ( ( Map < String , Object > ) currentNode ) . entrySet ( ) ) { if ( findAppropriateEl... | Populates the embedded object property with the relevant field values . |
38,880 | public void fillUpdatedCollectionProperty ( Object entity , Object currentNode , StructuralProperty property , Field field , String node , Map < String , Object > map ) throws ODataException { Collection < Object > valueSet ; if ( field . getType ( ) . isAssignableFrom ( Set . class ) ) { valueSet = new HashSet < > ( )... | Populates the collection property with the relevant field values . |
38,881 | public void fillPrimitiveProperty ( Object entity , Set < String > keySet , StructuralProperty property , Field field , String node , Map < String , Object > map ) throws ODataException { for ( String target : keySet ) { if ( node . equalsIgnoreCase ( target ) ) { Object value = getFieldValueByType ( property . getType... | Populates the primitive property of the entity with the relevant field value . |
38,882 | public void fillCollectionProperty ( Object entity , Set < String > keySet , StructuralProperty property , Field field , String node , Map < String , Object > map ) throws ODataException { for ( String target : keySet ) { if ( node . equalsIgnoreCase ( target ) ) { Iterable subValues = ( Iterable ) map . get ( target )... | Populates the collection property of the entity with field values . |
38,883 | protected Object getFieldValueByType ( String typeName , Object targetNode , Map < String , Object > map , boolean isExtracted ) throws ODataException { Object fieldValue = null ; LOG . debug ( "Type is {}" , typeName ) ; Type type = entityDataModel . getType ( typeName ) ; if ( type == null ) { throw new ODataUnmarsha... | Gets the field value for the property type . |
38,884 | private Object unmarshallEntityByName ( String entityName , Map < String , Object > map , Object currentNode ) throws ODataException { LOG . debug ( "Entity '{}' created." , entityName ) ; if ( ! isNullOrEmpty ( entityName ) ) { Object entity = loadEntity ( entityName ) ; setEntityProperties ( entity , JsonParserUtils ... | Unmarsall a named entity . |
38,885 | public Object loadEntity ( String entityName ) throws ODataUnmarshallingException { Object entity = null ; if ( entityName != null ) { try { StructuredType entityType = JsonParserUtils . getStructuredType ( entityName , entityDataModel ) ; if ( entityType != null ) { entity = entityType . getJavaType ( ) . newInstance ... | Creates the an entity based on its name . |
38,886 | public void setEntityProperties ( Object entity , StructuredType entityType , Map < String , Object > map , Object currentNode ) throws ODataException { Set < String > keySet = map . keySet ( ) ; for ( StructuralProperty property : getAllProperties ( entityType , entityDataModel ) ) { Field field = property . getJavaFi... | Sets the given entity with structural properties from the fields . |
38,887 | public ProcessorResult handleWrite ( Object entity ) throws ODataException { if ( ODataUriUtil . isRefPathUri ( getoDataUri ( ) ) ) { return processLink ( ( ODataLink ) entity ) ; } else { if ( entity != null ) { throw new ODataBadRequestException ( "The body of a DELETE request must be empty." ) ; } return processEnti... | This method delete entity . |
38,888 | private ProcessorResult processEntity ( ) throws ODataException { TargetType targetType = getTargetType ( ) ; if ( ! targetType . isCollection ( ) ) { Option < String > singletonName = ODataUriUtil . getSingletonName ( getoDataUri ( ) ) ; if ( singletonName . isDefined ( ) ) { throw new ODataBadRequestException ( "The ... | This method finds correct data source based on target type and executes delete operation on data source . |
38,889 | public String writeRawJson ( final String json , final String contextUrl ) throws ODataRenderException { this . contextURL = checkNotNull ( contextUrl ) ; try { final ByteArrayOutputStream stream = new ByteArrayOutputStream ( ) ; jsonGenerator = JSON_FACTORY . createGenerator ( stream , JsonEncoding . UTF8 ) ; jsonGene... | Writes raw json to the JSON stream . |
38,890 | private String writeJson ( Object data , Map < String , Object > meta ) throws IOException , NoSuchFieldException , IllegalAccessException , ODataEdmException , ODataRenderException { ByteArrayOutputStream stream = new ByteArrayOutputStream ( ) ; jsonGenerator = JSON_FACTORY . createGenerator ( stream , JsonEncoding . ... | Write the given data to the JSON stream . The data to write will be either a single entity or a feed depending on whether it is a single object or list . |
38,891 | public Action build ( Class < ? > cls ) { EdmAction edmAction = cls . getAnnotation ( EdmAction . class ) ; EdmReturnType edmReturnType = cls . getAnnotation ( EdmReturnType . class ) ; Set < Parameter > parameters = new HashSet < > ( ) ; for ( Field field : cls . getDeclaredFields ( ) ) { EdmParameter parameterAnnotat... | Builds an action instance from given class . |
38,892 | protected boolean isEntityQuery ( ODataUri uri , EntityDataModel entityDataModel ) { return getTargetType ( uri , entityDataModel ) . map ( t -> t . getMetaType ( ) == MetaType . ENTITY ) . orElse ( false ) ; } | Check if the parsed OData URI is a query and it results in an entity or a collection of entities . |
38,893 | protected String buildContextURL ( ODataRequestContext requestContext , Object data ) throws ODataRenderException { ODataUri oDataUri = requestContext . getUri ( ) ; if ( ODataUriUtil . isActionCallUri ( oDataUri ) || ODataUriUtil . isFunctionCallUri ( oDataUri ) ) { return buildContextUrlFromOperationCall ( oDataUri ,... | Build the Context URL from a given OData request context . |
38,894 | protected void checkContextURL ( ODataRequestContext requestContext , Option < String > contextURL ) throws ODataRenderException { if ( ! contextURL . isDefined ( ) ) { throw new ODataRenderException ( String . format ( "Not possible to create context URL for request %s" , requestContext ) ) ; } } | Check whether the given Context URL is defined . |
38,895 | public ProcessorResult handleWrite ( Object action ) throws ODataException { Operation operation ; if ( action instanceof Operation ) { operation = ( Operation ) action ; Object data = operation . doOperation ( getODataRequestContext ( ) , getDataSourceFactory ( ) ) ; if ( data == null ) { return new ProcessorResult ( ... | Handles action call and returns result in case when action returns it . |
38,896 | public String getPropertyAsString ( Object data ) throws ODataException { LOG . trace ( "GetPropertyAsString invoked with {}" , data ) ; if ( data != null ) { return makePropertyString ( data ) ; } else { return generateNullPropertyString ( ) ; } } | This is main method to get property as string . |
38,897 | public String buildServiceDocument ( ) throws ODataRenderException { LOG . info ( "Building service(root) document" ) ; try ( ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( BUFFER_SIZE ) ) { XMLStreamWriter writer = startServiceDocument ( outputStream ) ; writeEntitySets ( writer ) ; writeSingleton ( ... | This is main method which generates service document . |
38,898 | private void writeEntitySets ( XMLStreamWriter writer ) throws XMLStreamException , ODataRenderException { List < EntitySet > entitySets = getEntityContainer ( ) . getEntitySets ( ) ; LOG . debug ( "Number of entity sets to be written in service document are {}" , entitySets . size ( ) ) ; for ( EntitySet entitySet : e... | This writes all entity sets in entity data model as collection of elements . |
38,899 | private XMLStreamWriter startServiceDocument ( ByteArrayOutputStream outputStream ) throws XMLStreamException , ODataRenderException { XMLStreamWriter writer = XMLWriterUtil . startDocument ( outputStream , null , SERVICE , ODATA_SERVICE_NS ) ; writer . writeNamespace ( ATOM , ATOM_NS ) ; writer . writeNamespace ( META... | Starts service document with correct attributes and also writes workspace title elements . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.