repo_id
stringclasses
1 value
file_path
stringlengths
117
174
content
stringlengths
8
42.4k
__index_level_0__
int64
0
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/EventHistoryResultHandler.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; /** Interface defining a callback which contains the result of event history database operations. */ public interface EventHistoryResultHandler<T> { void call(final T value); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/Extension.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.adobe.marketing.mobile.internal.CoreConstants; import com.adobe.marketing.mobile.services.Log; import java.util.Map; /** Abstract class that defines an {@code Extension} */ public abstract class Extension { @NonNull private final ExtensionApi extensionApi; /** * Construct the extension and initialize with the {@code ExtensionApi}. * * @param extensionApi the {@link ExtensionApi} this extension will use */ protected Extension(@NonNull final ExtensionApi extensionApi) { this.extensionApi = extensionApi; } /** * Get extension name for use by the event hub to managing shared state and for logging. This * MUST be overridden by the extension. If null or empty string is returned, the extension will * not be registered. * * @return the extension name as a {@link String} */ protected abstract @NonNull String getName(); /** * Get friendly, human-readable name of the extension. * * @return the friendly extension name as a {@link String} */ protected @Nullable String getFriendlyName() { return null; } /** * Get extension version as a string for use by the event hub for logging. * * @return the extension version as a {@link String} */ protected @Nullable String getVersion() { return null; } /** * Optional metadata provided for use by the event hub for logging. * * @return the extension metadata as a {@code Map<String, String>} */ protected @Nullable Map<String, String> getMetadata() { return null; } /** * Called when the extension is registered by the core. Implementers can implement this method * to setup event listeners and shared states. */ protected void onRegistered() { Log.trace(CoreConstants.LOG_TAG, getLogTag(), "Extension registered successfully."); } /** * Called when the extension is unregistered by the core. Implementers can implement this method * to clean up resources when the extension is released. */ protected void onUnregistered() { Log.trace(CoreConstants.LOG_TAG, getLogTag(), "Extension unregistered successfully."); } /** * Called before each Event is processed by any ExtensionListener owned by this Extension Should * be overridden by any extension that wants to control its own Event flow on a per Event basis. * * @param event {@link Event} that will be processed next * @return {@code boolean} to denote if event processing should continue for this `Extension` */ public boolean readyForEvent(@NonNull final Event event) { return true; } /** * This provides the services the extension will need. * * @return the {@link ExtensionApi} used to handle this extension */ public final @NonNull ExtensionApi getApi() { return extensionApi; } /** * Get the log tag for this extension. * * @return a log tag for this extension */ private String getLogTag() { return "Extension[" + getName() + "(" + getVersion() + ")]"; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/SharedStateResolution.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; /** Type representing the resolution of an extension's `SharedState` */ public enum SharedStateResolution { /** LAST_SET will resolve for the last set shared state */ LAST_SET, /** ANY will resolve for the last shared state indiscriminately */ ANY, }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/ExtensionApi.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.util.Map; /** * Class that defines all the public methods an {@code Extension} may call to interface with the AEP * SDK. */ public abstract class ExtensionApi { /** * Registers a new event listener for current extension for the provided event type and source. * * @param eventType required parameter, the event type as a valid string (not null or empty) * @param eventSource required parameter, the event source as a valid string (not null or empty) * @param eventListener required parameter, the listener which extends the {@link * ExtensionEventListener} interface */ public abstract void registerEventListener( @NonNull final String eventType, @NonNull final String eventSource, @NonNull final ExtensionEventListener eventListener); /** * Dispatches an `Event` to the `EventHub` * * @param event An Event to be dispatched to the {@code EventHub} */ public abstract void dispatch(@NonNull final Event event); /** Starts the `Event` queue for this extension */ public abstract void startEvents(); /** Stops the `Event` queue for this extension */ public abstract void stopEvents(); // Shared state /** * Creates a new shared state for this extension. If event is null, one of two behaviors will be * observed: * * <ul> * <li>If this extension has not previously published a shared state, shared state will be * versioned at 0 * <li>If this extension has previously published a shared state, shared state will be * versioned at the latest * </ul> * * @param state {@code Map<String, Object>} representing current state of this extension * @param event The {@link Event} for which the state is being set. Passing null will set the * state for the next shared state version */ public abstract void createSharedState( @NonNull final Map<String, Object> state, @Nullable final Event event); /** * Creates a pending shared state for this extension. * * <ul> * <li>If this extension has not previously published a shared state, shared state will be * versioned at 0 * <li>If this extension has previously published a shared state, shared state will be * versioned at the latest * </ul> * * @param event The {@link Event} for which pending shared state is being set. Passing null will * set the state for the next shared state version. * @return {@link SharedStateResolver} that should be called with the shared state data when it * is ready */ public abstract @Nullable SharedStateResolver createPendingSharedState( @Nullable final Event event); /** * Gets the shared state data for a specified extension. * * @param extensionName extension name for which to retrieve data. See documentation for the * list of available states. * @param event the {@link Event} for which the state is being requested. Passing null will * retrieve latest state available. * @param barrier If true, the {@code EventHub} will only return {@code set} if extensionName * has moved past event. * @param resolution the {@link SharedStateResolution} to resolve for return {@code * SharedStateResult} for the requested extensionName and event */ public abstract @Nullable SharedStateResult getSharedState( @NonNull final String extensionName, @Nullable final Event event, final boolean barrier, @NonNull final SharedStateResolution resolution); // XDM Shared state /** * Creates a new XDM shared state for this extension. The state passed to this API needs to be * mapped to known XDM mixins. If an extension uses multiple mixins, the current data for all of * them should be provided when the XDM shared state is set. If event is null, one of two * behaviors will be observed: * * <ul> * <li>If this extension has not previously published a shared state, shared state will be * versioned at 0 * <li>If this extension has previously published a shared state, shared state will be * versioned at the latest * </ul> * * @param state {@code Map<String, Object>} representing current state of this extension * @param event The {@link Event} for which the state is being set. Passing null will set the * state for the next shared state version */ public abstract void createXDMSharedState( @NonNull final Map<String, Object> state, @Nullable final Event event); /** * Creates a pending XDM shared state for this extension. * * <ul> * <li>If this extension has not previously published a shared state, shared state will be * versioned at 0 * <li>If this extension has previously published a shared state, shared state will be * versioned at the latest * </ul> * * @param event The {@link Event} for which pending shared state is being set. Passing null will * set the state for the next shared state version. * @return {@link SharedStateResolver} that should be called with the shared state data when it * is ready */ public abstract @Nullable SharedStateResolver createPendingXDMSharedState( @Nullable final Event event); /** * Gets the XDM shared state data for a specified extension. If the stateName extension * populates multiple mixins in their shared state, all the data will be returned at once and it * can be accessed using path discovery. * * @param extensionName extension name for which to retrieve data. See documentation for the * list of available states. * @param event the {@link Event} for which the state is being requested. Passing null will * retrieve latest state available. * @param barrier If true, the {@code EventHub} will only return {@code set} if extensionName * has moved past event. * @param resolution the {@link SharedStateResolution} to resolve for return {@code * SharedStateResult} for the requested extensionName and event */ public abstract @Nullable SharedStateResult getXDMSharedState( @NonNull final String extensionName, @Nullable final Event event, final boolean barrier, @NonNull final SharedStateResolution resolution); /** * Unregisters current extension. <br> * This method executes asynchronously, unregistering the extension on the event hub thread. * {@link Extension#onUnregistered} method will be called at the end of this operation. * * @see Extension#onUnregistered() */ public abstract void unregisterExtension(); /** * Retrieves a count of historical events matching the provided requests. * * @param eventHistoryRequests an array of {@link EventHistoryRequest}s used to generate the * hash and timeframe for the event lookup * @param enforceOrder if `true`, consecutive lookups will use the oldest timestamp from the * previous event as their from date * @param handler the {@link EventHistoryResultHandler} for each provided request */ public abstract void getHistoricalEvents( @NonNull EventHistoryRequest[] eventHistoryRequests, boolean enforceOrder, @NonNull EventHistoryResultHandler<Integer> handler); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/MobileCore.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; import android.app.Activity; import android.app.Application; import android.app.Application.ActivityLifecycleCallbacks; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.core.os.UserManagerCompat; import com.adobe.marketing.mobile.internal.AppResourceStore; import com.adobe.marketing.mobile.internal.CoreConstants; import com.adobe.marketing.mobile.internal.DataMarshaller; import com.adobe.marketing.mobile.internal.configuration.ConfigurationExtension; import com.adobe.marketing.mobile.internal.eventhub.EventHub; import com.adobe.marketing.mobile.internal.eventhub.EventHubConstants; import com.adobe.marketing.mobile.internal.migration.V4Migrator; import com.adobe.marketing.mobile.services.Log; import com.adobe.marketing.mobile.services.ServiceProvider; import com.adobe.marketing.mobile.services.internal.context.App; import com.adobe.marketing.mobile.util.DataReader; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; public final class MobileCore { private static final String LOG_TAG = "MobileCore"; private static final long API_TIMEOUT_MS = 5000; static AtomicBoolean sdkInitializedWithContext = new AtomicBoolean(false); private MobileCore() {} // ======================================================== // MobileCore methods // ======================================================== /** * Returns the version for the {@code MobileCore} extension * * @return The version string */ @NonNull public static String extensionVersion() { WrapperType wrapperType = EventHub.Companion.getShared().getWrapperType(); if (wrapperType == WrapperType.NONE) { return EventHubConstants.VERSION_NUMBER; } else { return EventHubConstants.VERSION_NUMBER + "-" + wrapperType.getWrapperTag(); } } /** * Sets the SDK's current wrapper type. This API should only be used if being developed on * platforms such as React Native or Flutter * * <p> * * @param wrapperType the type of wrapper being used. It should not be null. */ public static void setWrapperType(@NonNull final WrapperType wrapperType) { if (wrapperType == null) { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "setWrapperType failed - wrapperType is null."); return; } EventHub.Companion.getShared().setWrapperType(wrapperType); } /** * Set the Android {@link Application}, which enables the SDK get the app {@code Context}, * register a {@link ActivityLifecycleCallbacks} to monitor the lifecycle of the app and get the * {@link Activity} on top of the screen. * * <p>NOTE: This method should be called right after the app starts, so it gives the SDK all the * contexts it needed. * * @param application the Android {@link Application} instance. It should not be null. */ public static void setApplication(@NonNull final Application application) { if (application == null) { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "setApplication failed - application is null"); return; } // Direct boot mode is supported on Android N and above if (VERSION.SDK_INT >= VERSION_CODES.N) { if (UserManagerCompat.isUserUnlocked(application)) { Log.debug( CoreConstants.LOG_TAG, LOG_TAG, "setApplication - device is unlocked and not in direct boot mode," + " initializing the SDK."); } else { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "setApplication failed - device is in direct boot mode, SDK will not be" + " initialized."); return; } } if (sdkInitializedWithContext.getAndSet(true)) { Log.debug( CoreConstants.LOG_TAG, LOG_TAG, "setApplication failed - ignoring as setApplication was already called."); return; } if (VERSION.SDK_INT == VERSION_CODES.O || VERSION.SDK_INT == VERSION_CODES.O_MR1) { // AMSDK-8502 // Workaround to prevent a crash happening on Android 8.0/8.1 related to // TimeZoneNamesImpl // https://issuetracker.google.com/issues/110848122 try { new Date().toString(); } catch (AssertionError e) { // Workaround for a bug in Android that can cause crashes on Android 8.0 and 8.1 } catch (Exception e) { // Workaround for a bug in Android that can cause crashes on Android 8.0 and 8.1 } } ServiceProvider.getInstance().getAppContextService().setApplication(application); App.INSTANCE.registerActivityResumedListener(MobileCore::collectLaunchInfo); // Migration and EventHistory operations must complete in a background thread before any // extensions are registered. // To ensure these tasks are completed before any registerExtension calls are made, // reuse the eventHubExecutor instead of using a separate executor instance. EventHub.Companion.getShared() .executeInEventHubExecutor( () -> { try { V4Migrator migrator = new V4Migrator(); migrator.migrate(); } catch (Exception e) { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "Migration from V4 SDK failed with error - " + e.getLocalizedMessage()); } // Initialize event history EventHub.Companion.getShared().initializeEventHistory(); return null; }); } /** * Get the global {@link Application} object of the current process. * * <p>NOTE: {@link #setApplication(Application)} must be called before calling this method. * * @return the current {@code Application}, or null if no {@code Application} was set or the * {@code Application} process was destroyed. */ @Nullable public static Application getApplication() { return ServiceProvider.getInstance().getAppContextService().getApplication(); } /** * Set the {@link LoggingMode} level for the Mobile SDK. * * @param mode the logging mode. It should not be null. */ public static void setLogLevel(@NonNull final LoggingMode mode) { if (mode == null) { Log.error(CoreConstants.LOG_TAG, LOG_TAG, "setLogLevel failed - mode is null"); return; } com.adobe.marketing.mobile.services.Log.setLogLevel(mode); } /** * Get the {@link LoggingMode} level for the Mobile SDK * * @return the set {@code LoggingMode} */ @NonNull public static LoggingMode getLogLevel() { return com.adobe.marketing.mobile.services.Log.getLogLevel(); } /** * Registers all extensions with Core and starts event processing. * * <p>This method needs to be called after {@link MobileCore#setApplication(Application)} is * called. * * @param extensions List of extension classes whose parent is {@link Extension}. It should not * be null. * @param completionCallback an optional {@link AdobeCallback} invoked after registrations are * completed */ public static void registerExtensions( @NonNull final List<Class<? extends Extension>> extensions, @Nullable final AdobeCallback<?> completionCallback) { if (!sdkInitializedWithContext.get()) { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "Failed to registerExtensions - setApplication not called"); return; } final List<Class<? extends Extension>> extensionsToRegister = new ArrayList<>(); extensionsToRegister.add(ConfigurationExtension.class); if (extensions != null) { for (final Class<? extends Extension> extension : extensions) { if (extension != null) { extensionsToRegister.add(extension); } } } final AtomicInteger registeredExtensions = new AtomicInteger(0); for (final Class<? extends Extension> extension : extensionsToRegister) { EventHub.Companion.getShared() .registerExtension( extension, eventHubError -> { if (registeredExtensions.incrementAndGet() == extensionsToRegister.size()) { EventHub.Companion.getShared().start(); try { if (completionCallback != null) { completionCallback.call(null); } } catch (Exception ex) { } } return null; }); } } /** * Registers an event listener for the provided event type and source. * * @param eventType the event type as a valid string. It should not be null or empty. * @param eventSource the event source as a valid string. It should not be null or empty. * @param callback the callback whose {@link AdobeCallback#call(Object)} will be called when the * event is heard. It should not be null. */ public static void registerEventListener( @NonNull final String eventType, @NonNull final String eventSource, @NonNull final AdobeCallback<Event> callback) { if (callback == null) { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "Failed to registerEventListener - callback is null", Log.UNEXPECTED_NULL_VALUE); return; } if (eventType == null || eventSource == null) { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "Failed to registerEventListener - event type/source is null"); return; } EventHub.Companion.getShared().registerListener(eventType, eventSource, callback); } /** * This method will dispatch the provided {@code Event} to dispatch an event for other * extensions or the internal SDK to consume. * * @param event the {@link Event} to be dispatched. It should not be null */ public static void dispatchEvent(@NonNull final Event event) { if (event == null) { Log.error(CoreConstants.LOG_TAG, LOG_TAG, "Failed to dispatchEvent - event is null"); return; } EventHub.Companion.getShared().dispatch(event); } /** * This method will be used when the provided {@code Event} is used as a trigger and a response * event is expected in return. * * <p>Passes an {@link AdobeError#UNEXPECTED_ERROR} to {@link * AdobeCallbackWithError#fail(AdobeError)} if {@code event} is null. Passes an {@link * AdobeError#CALLBACK_TIMEOUT} to {@link AdobeCallbackWithError#fail(AdobeError)} if {@code * event} processing timeout occurs. * * @param event the {@link Event} to be dispatched, used as a trigger. It should not be null. * @param timeoutMS the timeout specified in milliseconds. * @param responseCallback the callback whose {@link AdobeCallbackWithError#call(Object)} will * be called when the response event is heard. It should not be null. */ public static void dispatchEventWithResponseCallback( @NonNull final Event event, final long timeoutMS, @NonNull final AdobeCallbackWithError<Event> responseCallback) { if (responseCallback == null) { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "Failed to dispatchEventWithResponseCallback - callback is null"); return; } if (event == null) { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "Failed to dispatchEventWithResponseCallback - event is null"); responseCallback.fail(AdobeError.UNEXPECTED_ERROR); return; } EventHub.Companion.getShared().registerResponseListener(event, timeoutMS, responseCallback); EventHub.Companion.getShared().dispatch(event); } /** * Sets the resource Id for small icon. * * @param resourceID the resource Id of the icon */ public static void setSmallIconResourceID(final int resourceID) { AppResourceStore.INSTANCE.setSmallIconResourceID(resourceID); } /** * Returns the resource Id for small icon if it was set by `setSmallIconResourceID`. * * @return a `int` value if it has been set, otherwise -1 */ public static int getSmallIconResourceID() { return AppResourceStore.INSTANCE.getSmallIconResourceID(); } /** * Sets the resource Id for large icon. * * @param resourceID the resource Id of the icon */ public static void setLargeIconResourceID(final int resourceID) { AppResourceStore.INSTANCE.setLargeIconResourceID(resourceID); } /** * Returns the resource Id for large icon if it was set by `setLargeIconResourceID`. * * @return a `int` value if it has been set, otherwise -1 */ public static int getLargeIconResourceID() { return AppResourceStore.INSTANCE.getLargeIconResourceID(); } // ======================================================== // Identifiers // ======================================================== /** * This method dispatches an event to notify the SDK of a new {@code advertisingIdentifier} * * @param advertisingIdentifier {@code String} representing Android advertising identifier */ public static void setAdvertisingIdentifier(@Nullable final String advertisingIdentifier) { Map<String, Object> eventData = new HashMap<>(); eventData.put( CoreConstants.EventDataKeys.Identity.ADVERTISING_IDENTIFIER, advertisingIdentifier); Event event = new Event.Builder( CoreConstants.EventNames.SET_ADVERTISING_IDENTIFIER, EventType.GENERIC_IDENTITY, EventSource.REQUEST_CONTENT) .setEventData(eventData) .build(); dispatchEvent(event); } /** * This method dispatches an event to notify the SDK of a new {@code pushIdentifier} * * @param pushIdentifier {@code String} representing the new push identifier */ public static void setPushIdentifier(@Nullable final String pushIdentifier) { Map<String, Object> eventData = new HashMap<>(); eventData.put(CoreConstants.EventDataKeys.Identity.PUSH_IDENTIFIER, pushIdentifier); Event event = new Event.Builder( CoreConstants.EventNames.SET_PUSH_IDENTIFIER, EventType.GENERIC_IDENTITY, EventSource.REQUEST_CONTENT) .setEventData(eventData) .build(); dispatchEvent(event); } /** * Collect PII data. Although using this call enables collection of PII data, the SDK does not * automatically send the data to any Adobe endpoint. * * @param data the map containing the PII data to be collected. It should not be null or empty. */ public static void collectPii(@NonNull final Map<String, String> data) { if (data == null || data.isEmpty()) { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "Could not trigger PII, the data is null or empty."); return; } final Map<String, Object> eventData = new HashMap<>(); eventData.put(CoreConstants.EventDataKeys.Signal.SIGNAL_CONTEXT_DATA, data); Event event = new Event.Builder( CoreConstants.EventNames.COLLECT_PII, EventType.GENERIC_PII, EventSource.REQUEST_CONTENT) .setEventData(eventData) .build(); dispatchEvent(event); } /** * Collects message data from various points in the application. * * <p>This method can be invoked to support the following use cases: * * <ol> * <li>Tracking Push Message receive and click. * <li>Tracking Local Notification receive and click. * </ol> * * <p>The message tracking information can be supplied in the {@code messageInfo} Map. For * scenarios where the application is launched as a result of notification click, {@link * #collectLaunchInfo(Activity)} will be invoked with the target Activity and message data will * be extracted from the Intent extras. * * @param messageInfo {@code Map<String, Object>} containing message tracking information. It * should not be null or empty. */ public static void collectMessageInfo(@NonNull final Map<String, Object> messageInfo) { if (messageInfo == null || messageInfo.isEmpty()) { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "collectData: Could not dispatch generic data event, data is null or empty."); return; } Event event = new Event.Builder( CoreConstants.EventNames.COLLECT_DATA, EventType.GENERIC_DATA, EventSource.OS) .setEventData(messageInfo) .build(); dispatchEvent(event); } /** * Collects data from the Activity / context to be used later by the SDK. * * <p>This method marshals the {@code activity} instance and extracts the intent data / extras. * * <ol> * <li>Tracking Deep Link click-through * <ul> * <li>Update AndroidManifest.xml to support intent-filter in the activity with the * intended action and type of data. * <li>Handle the intent in the activity. * </ul> * <li>Tracking Push Message click-through * <li>Tracking Local Notification click-through * </ol> * * <p>Invoke this method from Activity.onResume() callback in your activity. * * @param activity current {@link Activity} reference. */ @VisibleForTesting static void collectLaunchInfo(final Activity activity) { final Map<String, Object> marshalledData = DataMarshaller.marshal(activity); if (marshalledData == null || marshalledData.isEmpty()) { Log.debug( CoreConstants.LOG_TAG, LOG_TAG, "collectData: Could not dispatch generic data event, data is null or empty."); return; } Event event = new Event.Builder( CoreConstants.EventNames.COLLECT_DATA, EventType.GENERIC_DATA, EventSource.OS) .setEventData(marshalledData) .build(); dispatchEvent(event); } // ======================================================== // Configuration methods // ======================================================== /** * Configure the SDK by downloading the remote configuration file hosted on Adobe servers * specified by the given application ID. * * <p>The configuration file is cached once downloaded and used in subsequent calls to this API. * If the remote file is updated after the first download, the updated file is downloaded and * replaces the cached file. * * @param appId A unique identifier assigned to the app instance by Adobe Launch. It should not * be null. */ public static void configureWithAppID(@NonNull final String appId) { if (appId == null) { Log.error(CoreConstants.LOG_TAG, LOG_TAG, "configureWithAppID failed - appId is null."); return; } Map<String, Object> eventData = new HashMap<>(); eventData.put( CoreConstants.EventDataKeys.Configuration.CONFIGURATION_REQUEST_CONTENT_JSON_APP_ID, appId); Event event = new Event.Builder( CoreConstants.EventNames.CONFIGURE_WITH_APP_ID, EventType.CONFIGURATION, EventSource.REQUEST_CONTENT) .setEventData(eventData) .build(); dispatchEvent(event); } /** * Load configuration from the file in the assets folder. SDK automatically reads config from * `ADBMobileConfig.json` file if it exists in the assets folder. Use this API only if the * config needs to be read from a different file. * * <p>On application relaunch, the configuration from the file at {@code filepath} is not * preserved and this method must be called again if desired. * * <p>On failure to read the file or parse the JSON contents, the existing configuration remains * unchanged. * * <p>Calls to this API will replace any existing SDK configuration except those set using * {@link #updateConfiguration(Map)} or {@link #setPrivacyStatus(MobilePrivacyStatus)}. * Configuration updates made using {@link #updateConfiguration(Map)} and {@link * #setPrivacyStatus(MobilePrivacyStatus)} are always applied on top of configuration changes * made using this API. * * @param fileName the name of the configure file in the assets folder. It should not be null. */ public static void configureWithFileInAssets(@NonNull final String fileName) { if (fileName == null) { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "configureWithFileInAssets failed - fileName is null."); return; } Map<String, Object> eventData = new HashMap<>(); eventData.put( CoreConstants.EventDataKeys.Configuration .CONFIGURATION_REQUEST_CONTENT_JSON_ASSET_FILE, fileName); Event event = new Event.Builder( CoreConstants.EventNames.CONFIGURE_WITH_FILE_PATH, EventType.CONFIGURATION, EventSource.REQUEST_CONTENT) .setEventData(eventData) .build(); dispatchEvent(event); } /** * Load configuration from local file. * * <p>Configure the SDK by reading a local file containing the JSON configuration. On * application relaunch, the configuration from the file at {@code filepath} is not preserved * and this method must be called again if desired. * * <p>On failure to read the file or parse the JSON contents, the existing configuration remains * unchanged. * * <p>Calls to this API will replace any existing SDK configuration except those set using * {@link #updateConfiguration(Map)} or {@link #setPrivacyStatus(MobilePrivacyStatus)}. * Configuration updates made using {@link #updateConfiguration(Map)} and {@link * #setPrivacyStatus(MobilePrivacyStatus)} are always applied on top of configuration changes * made using this API. * * @param filePath absolute path to a local configuration file. It should not be null. */ public static void configureWithFileInPath(@NonNull final String filePath) { if (filePath == null) { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "configureWithFileInPath failed - filePath is null."); return; } Map<String, Object> eventData = new HashMap<>(); eventData.put( CoreConstants.EventDataKeys.Configuration .CONFIGURATION_REQUEST_CONTENT_JSON_FILE_PATH, filePath); Event event = new Event.Builder( CoreConstants.EventNames.CONFIGURE_WITH_FILE_PATH, EventType.CONFIGURATION, EventSource.REQUEST_CONTENT) .setEventData(eventData) .build(); dispatchEvent(event); } /** * Update specific configuration parameters. * * <p>Update the current SDK configuration with specific key/value pairs. Keys not found in the * current configuration are added. Configuration updates are preserved and applied over * existing or new configurations set by calling {@link #configureWithAppID(String)} or {@link * #configureWithFileInPath(String)}, even across application restarts. * * <p>Using {@code null} values is allowed and effectively removes the configuration parameter * from the current configuration. * * @param configMap configuration key/value pairs to be updated or added. It should not be null. */ public static void updateConfiguration(@NonNull final Map<String, Object> configMap) { if (configMap == null) { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "updateConfiguration failed - configMap is null."); return; } Map<String, Object> eventData = new HashMap<>(); eventData.put( CoreConstants.EventDataKeys.Configuration .CONFIGURATION_REQUEST_CONTENT_UPDATE_CONFIG, configMap); Event event = new Event.Builder( CoreConstants.EventNames.CONFIGURATION_UPDATE, EventType.CONFIGURATION, EventSource.REQUEST_CONTENT) .setEventData(eventData) .build(); dispatchEvent(event); } /** * Clear the changes made by {@link #updateConfiguration(Map)} and {@link * #setPrivacyStatus(MobilePrivacyStatus)} to the initial configuration provided either by * {@link #configureWithAppID(String)} or {@link #configureWithFileInPath(String)} or {@link * #configureWithFileInAssets(String)} */ public static void clearUpdatedConfiguration() { Map<String, Object> eventData = new HashMap<>(); eventData.put( CoreConstants.EventDataKeys.Configuration .CONFIGURATION_REQUEST_CONTENT_CLEAR_UPDATED_CONFIG, true); Event event = new Event.Builder( CoreConstants.EventNames.CLEAR_UPDATED_CONFIGURATION, EventType.CONFIGURATION, EventSource.REQUEST_CONTENT) .setEventData(eventData) .build(); dispatchEvent(event); } /** * Set the Adobe Mobile Privacy status. * * <p>Sets the {@link MobilePrivacyStatus} for this SDK. The set privacy status is preserved and * applied over any new configuration changes from calls to {@link #configureWithAppID(String)} * or {@link #configureWithFileInPath(String)}, even across application restarts. * * @param privacyStatus {@link MobilePrivacyStatus} to be set to the SDK * @see MobilePrivacyStatus */ public static void setPrivacyStatus(@NonNull final MobilePrivacyStatus privacyStatus) { if (privacyStatus == null) { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "setPrivacyStatus failed - privacyStatus is null."); return; } Map<String, Object> privacyStatusUpdateConfig = new HashMap<>(); privacyStatusUpdateConfig.put( CoreConstants.EventDataKeys.Configuration.GLOBAL_CONFIG_PRIVACY, privacyStatus.getValue()); updateConfiguration(privacyStatusUpdateConfig); } /** * Get the current Adobe Mobile Privacy Status. * * <p>Gets the currently configured {@link MobilePrivacyStatus} and passes it as a parameter to * the given {@link AdobeCallback#call(Object)} function. * * @param callback {@link AdobeCallback} instance which is invoked with the configured privacy * status as a parameter. It should not be null. * @see AdobeCallback * @see MobilePrivacyStatus */ public static void getPrivacyStatus(final AdobeCallback<MobilePrivacyStatus> callback) { if (callback == null) { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "Failed to retrieve the privacy status - callback is null"); return; } Map<String, Object> eventData = new HashMap<>(); eventData.put( CoreConstants.EventDataKeys.Configuration .CONFIGURATION_REQUEST_CONTENT_RETRIEVE_CONFIG, true); Event event = new Event.Builder( CoreConstants.EventNames.PRIVACY_STATUS_REQUEST, EventType.CONFIGURATION, EventSource.REQUEST_CONTENT) .setEventData(eventData) .build(); AdobeCallbackWithError<Event> callbackWithError = new AdobeCallbackWithError<Event>() { @Override public void fail(final AdobeError error) { if (callback instanceof AdobeCallbackWithError) { ((AdobeCallbackWithError<?>) callback) .fail(AdobeError.CALLBACK_TIMEOUT); } else { // Todo - Check if this is a valid return value. callback.call(null); } } @Override public void call(final Event event) { String status = DataReader.optString( event.getEventData(), CoreConstants.EventDataKeys.Configuration .GLOBAL_CONFIG_PRIVACY, null); callback.call(MobilePrivacyStatus.fromString(status)); } }; dispatchEventWithResponseCallback(event, API_TIMEOUT_MS, callbackWithError); } /** * Retrieve all identities stored by/known to the SDK in a JSON {@code String} format. * * @param callback {@link AdobeCallback} instance which is invoked with all the known identifier * in JSON {@link String} format. It should not be null. * @see AdobeCallback */ public static void getSdkIdentities(@NonNull final AdobeCallback<String> callback) { if (callback == null) { Log.error( CoreConstants.LOG_TAG, LOG_TAG, "Failed to get SDK identities - callback is null"); return; } AdobeCallbackWithError<Event> callbackWithError = new AdobeCallbackWithError<Event>() { @Override public void fail(final AdobeError error) { if (callback instanceof AdobeCallbackWithError) { ((AdobeCallbackWithError<?>) callback) .fail(AdobeError.CALLBACK_TIMEOUT); } else { callback.call("{}"); } } @Override public void call(final Event event) { String value = DataReader.optString( event.getEventData(), CoreConstants.EventDataKeys.Configuration .CONFIGURATION_RESPONSE_IDENTITY_ALL_IDENTIFIERS, "{}"); callback.call(value); } }; Event event = new Event.Builder( CoreConstants.EventNames.GET_SDK_IDENTITIES, EventType.CONFIGURATION, EventSource.REQUEST_IDENTITY) .build(); dispatchEventWithResponseCallback(event, API_TIMEOUT_MS, callbackWithError); } /** * Clears all identifiers from Edge extensions and generates a new Experience Cloud ID (ECID). */ public static void resetIdentities() { Event event = new Event.Builder( CoreConstants.EventNames.RESET_IDENTITIES_REQUEST, EventType.GENERIC_IDENTITY, EventSource.REQUEST_RESET) .build(); dispatchEvent(event); } // ======================================================== // Lifecycle methods // ======================================================== /** * Start/resume lifecycle session. * * <p>Start a new lifecycle session or resume a previously paused lifecycle session. If a * previously paused session timed out, then a new session is created. If a current session is * running, then calling this method does nothing. * * <p>Additional context data may be passed when calling this method. Lifecycle data and any * additional data are sent as context data parameters to Analytics, to Target as mbox * parameters, and for Audience Manager they are sent as customer variables. Any additional data * is also used by the Rules Engine when processing rules. * * <p>This method should be called from the Activity onResume method. * * @param additionalContextData optional additional context for this session. */ public static void lifecycleStart(@Nullable final Map<String, String> additionalContextData) { Map<String, Object> eventData = new HashMap<>(); eventData.put( CoreConstants.EventDataKeys.Lifecycle.LIFECYCLE_ACTION_KEY, CoreConstants.EventDataKeys.Lifecycle.LIFECYCLE_START); eventData.put( CoreConstants.EventDataKeys.Lifecycle.ADDITIONAL_CONTEXT_DATA, additionalContextData); Event event = new Event.Builder( CoreConstants.EventNames.LIFECYCLE_RESUME, EventType.GENERIC_LIFECYCLE, EventSource.REQUEST_CONTENT) .setEventData(eventData) .build(); dispatchEvent(event); } /** * Pause/stop lifecycle session. * * <p>Pauses the current lifecycle session. Calling pause on an already paused session updates * the paused timestamp, having the effect of resetting the session timeout timer. If no * lifecycle session is running, then calling this method does nothing. * * <p>A paused session is resumed if {@link #lifecycleStart(Map)} is called before the session * timeout. After the session timeout, a paused session is closed and calling {@link * #lifecycleStart(Map)} will create a new session. The session timeout is defined by the {@code * lifecycle.sessionTimeout} configuration parameter. If not defined, the default session * timeout is five minutes. * * <p>This method should be called from the Activity onPause method. */ public static void lifecyclePause() { Map<String, Object> eventData = new HashMap<>(); eventData.put( CoreConstants.EventDataKeys.Lifecycle.LIFECYCLE_ACTION_KEY, CoreConstants.EventDataKeys.Lifecycle.LIFECYCLE_PAUSE); Event event = new Event.Builder( CoreConstants.EventNames.LIFECYCLE_PAUSE, EventType.GENERIC_LIFECYCLE, EventSource.REQUEST_CONTENT) .setEventData(eventData) .build(); dispatchEvent(event); } // ======================================================== // Track methods // ======================================================== /** * This method dispatches an Analytics track {@code action} event * * <p>Actions represent events that occur in your application that you want to measure; the * corresponding metrics will be incremented each time the event occurs. For example, you may * want to track when an user click on the login button or a certain article was viewed. * * <p> * * @param action {@code String} containing the name of the action to track * @param contextData {@code Map<String, String>} containing context data to attach on this hit */ public static void trackAction( @NonNull final String action, @Nullable final Map<String, String> contextData) { Map<String, Object> eventData = new HashMap<>(); eventData.put( CoreConstants.EventDataKeys.Analytics.TRACK_ACTION, action == null ? "" : action); eventData.put( CoreConstants.EventDataKeys.Analytics.CONTEXT_DATA, contextData == null ? new HashMap<String, String>() : contextData); Event event = new Event.Builder( CoreConstants.EventNames.ANALYTICS_TRACK, EventType.GENERIC_TRACK, EventSource.REQUEST_CONTENT) .setEventData(eventData) .build(); dispatchEvent(event); } /** * This method dispatches an Analytics track {@code state} event * * <p>States represent different screens or views of your application. When the user navigates * between application pages, a new track call should be sent with current state name. Tracking * state name is typically called from an Activity in the onResume method. * * <p> * * @param state {@code String} containing the name of the state to track. It should not be null. * @param contextData optional contextData {@code Map<String, String>} containing context data * to attach on this hit */ public static void trackState( @NonNull final String state, @Nullable final Map<String, String> contextData) { Map<String, Object> eventData = new HashMap<>(); eventData.put( CoreConstants.EventDataKeys.Analytics.TRACK_STATE, state == null ? "" : state); eventData.put( CoreConstants.EventDataKeys.Analytics.CONTEXT_DATA, contextData == null ? new HashMap<String, String>() : contextData); Event event = new Event.Builder( CoreConstants.EventNames.ANALYTICS_TRACK, EventType.GENERIC_TRACK, EventSource.REQUEST_CONTENT) .setEventData(eventData) .build(); dispatchEvent(event); } @VisibleForTesting static void resetSDK() { EventHub.Companion.getShared().shutdown(); EventHub.Companion.setShared(new EventHub()); sdkInitializedWithContext.set(false); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/EventHistoryRequest.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; import com.adobe.marketing.mobile.internal.util.MapUtilsKt; import java.util.Map; public class EventHistoryRequest { private final Map<String, Object> map; private final long fromDate; private final long toDate; /** * Used for selecting or deleting Events from Event History. * * @param map Key-value pairs that will be used to generate the hash when looking up an Event. * @param fromDate Date that represents the lower bounds of the date range used when looking up * an Event. If not provided, the lookup will use the beginning of Event History as the * lower bounds. * @param toDate Date that represents the upper bounds of the date range used when looking up an * Event. If not provided, there will be no upper bound on the date range. */ public EventHistoryRequest( final Map<String, Object> map, final long fromDate, final long toDate) { this.map = map; this.fromDate = fromDate; this.toDate = toDate; } public long getMaskAsDecimalHash() { return MapUtilsKt.convertMapToFnv1aHash(map, null); } public long getFromDate() { return fromDate; } public long getToDate() { return toDate; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/LoggingMode.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; public enum LoggingMode { ERROR(0), WARNING(1), DEBUG(2), VERBOSE(3); public final int id; LoggingMode(final int identifier) { id = identifier; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/EventCoder.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; import androidx.annotation.Nullable; import com.adobe.marketing.mobile.util.JSONUtils; import java.util.Map; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /** The helper methods used to encode/decode an Event to/from json String */ public class EventCoder { private static final String NAME = "name"; private static final String UUID = "uuid"; private static final String SOURCE = "source"; private static final String TYPE = "type"; private static final String DATA = "data"; private static final String TIMESTAMP = "timestamp"; private static final String RESPONSE_ID = "responseId"; private static final String PARENT_ID = "parentId"; private static final String MASK = "mask"; private EventCoder() {} /** * Decode an event from json string * * @param eventString the json string * @return the decoded event if the json is valid, otherwise null */ public static Event decode(final String eventString) { if (eventString == null) { return null; } try { final JSONObject json = new JSONObject(eventString); final String name = optString(json, NAME, null); final String uniqueIdentifier = optString(json, UUID, null); final String source = optString(json, SOURCE, null); final String type = optString(json, TYPE, null); final Map<String, Object> data = JSONUtils.toMap(json.optJSONObject(DATA)); final long timestamp = json.optLong(TIMESTAMP, 0); final String responseId = optString(json, RESPONSE_ID, null); final String parentId = optString(json, PARENT_ID, null); final JSONArray maskJsonArray = json.optJSONArray(MASK); String[] mask = null; if (maskJsonArray != null) { mask = JSONUtils.toList(maskJsonArray).toArray(new String[0]); } final Event ret = new Event.Builder(name, type, source, mask) .setUniqueIdentifier(uniqueIdentifier) .setTimestamp(timestamp) .setEventData(data) .setResponseId(responseId) .setParentId(parentId) .build(); return ret; } catch (JSONException e) { return null; } } /** * Encode an event to a json string * * @param event the event to encode * @return json string represents all the fields of the event, otherwise returns null if the * event is null or there is json error */ public static String encode(final Event event) { if (event == null) { return null; } JSONObject json = new JSONObject(); try { json.put(NAME, event.getName()); json.put(TYPE, event.getType()); json.put(SOURCE, event.getSource()); json.put(UUID, event.getUniqueIdentifier()); json.put(TIMESTAMP, event.getTimestamp()); json.put(DATA, JSONObject.wrap(event.getEventData())); json.put(RESPONSE_ID, event.getResponseID()); json.put(PARENT_ID, event.getParentID()); json.put(MASK, JSONObject.wrap(event.getMask())); } catch (JSONException e) { return null; } return json.toString(); } /** * Returns the value mapped by {@code key} if it exists, or the {@code fallback} if no such * mapping exists. Exists because {@code JSONObject#optString} does not allow a null fallback. * * @param jsonObject the json from which the key is to be fetched * @param key the key that is to be fetched * @param fallback the fallback value if the key does not exist in {@code jsonObject} * @return value mapped by {@code key} if it exists in {@code jsonObject}, or {@code fallback} * if no such mapping exists. */ private static String optString( final JSONObject jsonObject, final String key, @Nullable final String fallback) { try { return jsonObject.getString(key); } catch (final JSONException e) { return fallback; } } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/SharedStateResult.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.util.Map; /** Contains the status and value for a given shared state */ public class SharedStateResult { private final SharedStateStatus status; private final Map<String, Object> value; /** * Creates a new shared state result with given status and value * * @param status status of the shared state * @param value value of the shared state */ public SharedStateResult( @NonNull final SharedStateStatus status, @Nullable final Map<String, Object> value) { this.status = status; this.value = value; } /** Returns the {@link SharedStateStatus}. */ public @NonNull SharedStateStatus getStatus() { return status; } /** Returns the shared state. */ public @Nullable Map<String, Object> getValue() { return value; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/ExtensionEventListener.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; import androidx.annotation.NonNull; /** * Defines a generic listener that can hear a specific kind of {@code Event} on an {@code EventHub} */ @FunctionalInterface public interface ExtensionEventListener { void hear(@NonNull final Event event); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/MobilePrivacyStatus.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; /** * Represents the possible privacy settings for the Adobe SDK. * * <p>The possible values for the Adobe Mobile Privacy Status. The privacy status controls whether * specific activity is allowed on the device. The default privacy status is set in any ADBMobile * JSON configuration file using the parameter {@code global.privacy}. Use {@code * AdobeMobileMarketing.setPrivacyStatus()} API to override the default privacy status. * * <p>(TODO - verify the documentation link is accurate for AMSDK V5) To learn more about the Adobe * Mobile Privacy Status, view the online documentation at <a * href="https://marketing.adobe.com/resources/help/en_US/mobile/ios/privacy.html">https://marketing.adobe.com/resources/help/en_US/mobile/ios/privacy.html</a> */ public enum MobilePrivacyStatus { /** Adobe Mobile Privacy Status opted-in. */ OPT_IN("optedin"), /** Adobe Mobile Privacy Status opted-out. */ OPT_OUT("optedout"), /** Adobe Mobile Privacy Status is unknown. */ UNKNOWN("optunknown"); private final String value; MobilePrivacyStatus(final String value) { this.value = value; } /** * Returns the string value for this enum type. * * @return the string name for this enum type. */ public String getValue() { return value; } /** * Returns a {@link MobilePrivacyStatus} object based on the provided {@code text}. * * <p>If the text provided is not valid, {@link #UNKNOWN} will be returned. * * @param text {@link String} to be converted to a {@code MobilePrivacyStatus} object * @return {@code MobilePrivacyStatus} object equivalent to the provided text */ public static MobilePrivacyStatus fromString(final String text) { for (MobilePrivacyStatus b : MobilePrivacyStatus.values()) { if (b.value.equalsIgnoreCase(text)) { return b; } } return UNKNOWN; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/SharedStateResolver.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; import androidx.annotation.Nullable; import java.util.Map; /** * A `SharedStateResolver` which is invoked to set pending the `SharedState` versioned at `Event` */ @FunctionalInterface public interface SharedStateResolver { /** * @param state A {@code Map<String, Object>} containing data to resolve pending shared state. */ void resolve(@Nullable final Map<String, Object> state); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/Event.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; import androidx.annotation.NonNull; import com.adobe.marketing.mobile.internal.CoreConstants; import com.adobe.marketing.mobile.internal.util.MapExtensionsKt; import com.adobe.marketing.mobile.services.Log; import com.adobe.marketing.mobile.util.EventDataUtils; import java.util.*; import java.util.concurrent.TimeUnit; /** * Represents a single event * * @author Adobe Systems Incorporated * @version 5.0 */ public final class Event { // Name of the event private String name; // Unique identifier for the event private String uniqueIdentifier; // The `EventSource` for the event private String source; // The `EventType` for the event private String type; // Optional data associated with this event private Map<String, Object> data; // Time this event was created private long timestamp; // If `responseID` is not nil, then this event is a response event and `responseID` is the // `event.id` of the `triggerEvent` private String responseID; // Represents the unique identifier for the parent of this event. The parent event is a // trigger for creating the current event private String parentID; // Specifies the properties in the Event and its data that should be used in the hash for // EventHistory storage. private String[] mask; /** Event Builder */ public static class Builder { private final Event event; private boolean didBuild; /** * Builder constructor with required {@code Event} attributes as parameters * * @param name required {@code String} to be set as event name; should not be null or empty * string * @param type required {@code String} to be set as event type; should not be null or empty * string * @param source required {@code String} to be set as event source; should not be null or * empty string */ public Builder(final String name, final String type, final String source) { this(name, type, source, null); } /** * Builder constructor with required {@code Event} attributes as parameters * * @param name required {@code String} to be set as event name; should not be null or empty * string * @param type required {@code String} to be set as event type; should not be null or empty * string * @param source required {@code String} to be set as event source; should not be null or * empty string * @param mask {@code String[]} event mask */ public Builder( final String name, final String type, final String source, final String[] mask) { event = new Event(); event.name = name; event.uniqueIdentifier = UUID.randomUUID().toString(); event.type = type; event.source = source; event.responseID = null; event.parentID = null; event.mask = mask; didBuild = false; } /** * Sets the data for this {@code Event}. The keys should be of type {@code String}. * * <p>Note: Custom classes are not supported as value types. These values will be skipped * from the {@code Event} data. * * <p>The accepted value types are: * * <ul> * <li>{@code Boolean} * <li>{@code Byte} * <li>{@code Collection<Object>} * <li>{@code Double} * <li>{@code Float} * <li>{@code Integer} * <li>{@code String} * <li>{@code List<Object>} * <li>{@code Long} * <li>{@code Map<String, Object>} * <li>{@code Short} * <li>null * </ul> * * @param data Data associated with this {@link Event} * @return this Event {@link Builder} * @throws UnsupportedOperationException if this method is called after {@link * Builder#build()} was called */ public Builder setEventData(final Map<String, Object> data) { throwIfAlreadyBuilt(); try { event.data = EventDataUtils.immutableClone(data); } catch (final Exception e) { Log.warning( CoreConstants.LOG_TAG, "EventBuilder", "Event data couldn't be serialized, empty data was set instead %s", e); } return this; } /** * Builds and returns the {@code Event} object. It returns null if the event's type or * source are null * * @return the constructed {@link Event} or null if the type or source are null * @throws UnsupportedOperationException if this method is called again */ public Event build() { throwIfAlreadyBuilt(); didBuild = true; if (event.type == null || event.source == null) { return null; } if (event.timestamp == 0) { event.timestamp = System.currentTimeMillis(); } return event; } /** * Sets the uniqueIdentifier for this {@code Event}. If no unique identifier is set, one is * generated when the {@code Event} is created. * * @param uniqueIdentifier {@code String} event uniqueIdentifier * @return this Event {@link Builder} * @throws UnsupportedOperationException if this method is called after {@link * Builder#build()} was called */ Builder setUniqueIdentifier(final String uniqueIdentifier) { if (uniqueIdentifier == null) { return this; } throwIfAlreadyBuilt(); event.uniqueIdentifier = uniqueIdentifier; return this; } /** * Sets this as response for {@code requestEvent}. Additionally, marks {@code requestEvent} * as the parent event to this event. * * @param requestEvent {@code Event} event * @return this Event {@link Builder} * @throws UnsupportedOperationException if this method is called after {@link * Builder#build()} was called */ public Builder inResponseToEvent(final Event requestEvent) { throwIfAlreadyBuilt(); if (requestEvent == null) { throw new NullPointerException("requestEvent is null"); } setResponseId(requestEvent.uniqueIdentifier); chainToParentEvent(requestEvent); return this; } /** * Sets parent event for this event. * * @param parentEvent the {@code Event} to be set as the parent event. The parent event is * considered as the trigger for creating the current event * @return this {@link Event.Builder} * @throws UnsupportedOperationException if this method is called after {@link * Builder#build()} was called */ public Builder chainToParentEvent(@NonNull final Event parentEvent) { throwIfAlreadyBuilt(); if (parentEvent == null) { throw new NullPointerException("parentEvent cannot be null"); } event.parentID = parentEvent.getUniqueIdentifier(); return this; } /** * Sets responseId for this {@code Event} * * * @param responseId {@code String} event uniqueIdentifier * @return this Event {@link Builder} * @throws UnsupportedOperationException if this method is called after {@link * Builder#build()} was called */ Builder setResponseId(final String responseId) { throwIfAlreadyBuilt(); event.responseID = responseId; return this; } /** * Sets parentId for this event * * @param parentId the uniqueIdentifier of the parent event * @return this {@link Event.Builder} * @throws UnsupportedOperationException if this method is called after {@link * Builder#build()} was called */ Builder setParentId(final String parentId) { throwIfAlreadyBuilt(); event.parentID = parentId; return this; } /** * Set the timestamp for this event * * @param timestamp long event timestamp * @return this Event {@link Builder} * @throws UnsupportedOperationException if this method is called after {@link * Builder#build()} was called */ Builder setTimestamp(final long timestamp) { throwIfAlreadyBuilt(); event.timestamp = timestamp; return this; } private void throwIfAlreadyBuilt() { if (didBuild) { throw new UnsupportedOperationException( "Event - attempted to call methods on Event.Builder after build() was" + " called"); } } } /** Private constructor. Use builder to create an event */ @SuppressWarnings("unused") private Event() {} /** * Clones the current {@link Event} with updated data * * @param newData data associated with the new {@code Event} * @return new cloned {@code Event} with provided data */ public Event cloneWithEventData(final Map<String, Object> newData) { Event newEvent = new Event.Builder(this.name, this.type, this.source, this.mask) .setEventData(newData) .build(); newEvent.uniqueIdentifier = this.uniqueIdentifier; newEvent.timestamp = this.timestamp; newEvent.responseID = this.responseID; return newEvent; } /** * Returns the {@code Event} name * * @return {@code String} representing the {@link Event} name */ public String getName() { return name; } /** * Returns the {@code Event} uniqueIdentifier * * @return {@code String} representing the {@link Event} uniqueIdentifier */ public String getUniqueIdentifier() { return uniqueIdentifier; } /** * Returns the {@code Event} source value * * @return {@code String} representing the {@link Event} source */ public String getSource() { return source; } /** * Returns the {@code Event} type value * * @return {@code String} representing the {@link Event} type */ public String getType() { return type; } /** * Retrieves the event data for current {@code Event} * * @return {@code Map<String, Object>} with the {@link Event} data key-value pairs. Returns null * if the data is null or if an error occurred while processing */ public Map<String, Object> getEventData() { return data; } /** * @return {@link Event} timestamp in milliseconds */ public long getTimestamp() { return timestamp; } /** * Pair ID for events dispatched by the receiver(s) in response to this event * * @return String response pair ID */ public String getResponseID() { return responseID; } /** * Returns the unique identifier of the parent of this event. * * @return the unique identifier of the parent of this event */ public String getParentID() { return parentID; } /** * @return event timestamp in seconds */ public long getTimestampInSeconds() { return TimeUnit.MILLISECONDS.toSeconds(timestamp); } /** * @return {@code String[]} containing properties in the Event and its data that should be used * in the hash for EventHistory storage. */ public String[] getMask() { return mask; } @NonNull @Override public String toString() { final String NEWLINE = "\n"; final String COMMA = ","; final StringBuilder sb = new StringBuilder(); sb.append("{").append(NEWLINE); sb.append(" class: Event").append(COMMA).append(NEWLINE); sb.append(" name: ").append(name).append(COMMA).append(NEWLINE); sb.append(" uniqueIdentifier: ").append(uniqueIdentifier).append(COMMA).append(NEWLINE); sb.append(" source: ").append(source).append(COMMA).append(NEWLINE); sb.append(" type: ").append(type).append(COMMA).append(NEWLINE); sb.append(" responseId: ").append(responseID).append(COMMA).append(NEWLINE); sb.append(" parentId: ").append(parentID).append(COMMA).append(NEWLINE); sb.append(" timestamp: ").append(timestamp).append(COMMA).append(NEWLINE); String dataAsStr = data == null ? "{}" : MapExtensionsKt.prettify(data); sb.append(" data: ").append(dataAsStr).append(COMMA).append(NEWLINE); sb.append(" mask: ").append(Arrays.toString(mask)).append(COMMA).append(NEWLINE); sb.append("}"); return sb.toString(); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/WrapperType.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; import com.adobe.marketing.mobile.internal.CoreConstants; public enum WrapperType { NONE(CoreConstants.Wrapper.Type.NONE), REACT_NATIVE(CoreConstants.Wrapper.Type.REACT_NATIVE), FLUTTER(CoreConstants.Wrapper.Type.FLUTTER), CORDOVA(CoreConstants.Wrapper.Type.CORDOVA), UNITY(CoreConstants.Wrapper.Type.UNITY), XAMARIN(CoreConstants.Wrapper.Type.XAMARIN); private final String wrapperTag; WrapperType(final String wrapperTag) { this.wrapperTag = wrapperTag; } public String getWrapperTag() { return this.wrapperTag; } public static WrapperType fromString(final String wrapperTag) { if (CoreConstants.Wrapper.Type.REACT_NATIVE.equals(wrapperTag)) { return REACT_NATIVE; } else if (CoreConstants.Wrapper.Type.FLUTTER.equals(wrapperTag)) { return FLUTTER; } else if (CoreConstants.Wrapper.Type.CORDOVA.equals(wrapperTag)) { return CORDOVA; } else if (CoreConstants.Wrapper.Type.UNITY.equals(wrapperTag)) { return UNITY; } else if (CoreConstants.Wrapper.Type.XAMARIN.equals(wrapperTag)) { return XAMARIN; } return NONE; } public String getFriendlyName() { switch (this) { case REACT_NATIVE: return CoreConstants.Wrapper.Name.REACT_NATIVE; case FLUTTER: return CoreConstants.Wrapper.Name.FLUTTER; case CORDOVA: return CoreConstants.Wrapper.Name.CORDOVA; case UNITY: return CoreConstants.Wrapper.Name.UNITY; case XAMARIN: return CoreConstants.Wrapper.Name.XAMARIN; case NONE: default: return CoreConstants.Wrapper.Name.NONE; } } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/SharedStateStatus.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; /** Type representing the state of an extension's `SharedState` */ public enum SharedStateStatus { SET, PENDING, NONE, }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/VisitorID.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; import com.adobe.marketing.mobile.internal.CoreConstants; import com.adobe.marketing.mobile.services.Log; import com.adobe.marketing.mobile.util.StringUtils; /** An identifier to be used with the Adobe Experience Cloud Visitor ID Service */ public class VisitorID { private static final int RANDOM_HASH_BASE = 17; private static final int RANDOM_HASH_PADDING = 31; private final AuthenticationState authenticationState; private final String id; private final String idOrigin; private final String idType; /** * {@link AuthenticationState} for this {@link VisitorID} * * @return The {@link AuthenticationState} */ public AuthenticationState getAuthenticationState() { return authenticationState; } /** * ID for this {@link VisitorID} * * @return The {@link VisitorID} ID */ public final String getId() { return id; } /** * ID Origin for this {@link VisitorID} * * @return {@link VisitorID} Origin string */ public final String getIdOrigin() { return idOrigin; } /** * ID Type for this {@link VisitorID} * * @return {@link VisitorID} type */ public final String getIdType() { return idType; } /** Used to indicate the authentication state for the current {@link VisitorID} */ public enum AuthenticationState { UNKNOWN(0), AUTHENTICATED(1), LOGGED_OUT(2); private final int value; AuthenticationState(final int value) { this.value = value; } public int getValue() { return value; } public static AuthenticationState fromInteger(final int authStateInteger) { for (AuthenticationState b : AuthenticationState.values()) { if (b.getValue() == authStateInteger) { return b; } } return AuthenticationState.UNKNOWN; } } /** * Constructor initializes {@link #id}, {@link #idOrigin}, {@link #idType} and {@link * #authenticationState}. * * @param idOrigin {@link String} containing the ID Origin for the {@link VisitorID} * @param idType {@code String} containing the ID Type for the {@code VisitorID}; it should not * be null/empty * @param id {@code String} containing the ID for the {@code VisitorID}; it should not be * null/empty * @param authenticationState {@link AuthenticationState} containing the authentication state * for the {@code VisitorID} * @throws IllegalStateException if the provided {@code idType} is null or empty */ public VisitorID( final String idOrigin, final String idType, final String id, final AuthenticationState authenticationState) { // TODO: cleanContextDataKey logic will be moved to Analytics extension // https://github.com/adobe/aepsdk-core-android/issues/217 // final String cleanIdType = ContextDataUtil.cleanContextDataKey(idType); // idType cannot be null/empty if (StringUtils.isNullOrEmpty(idType)) { throw new IllegalStateException("idType parameter cannot be null or empty"); } // id cannot be null/empty // Do not throw IllegalStateException to maintain backwards compatibility if (StringUtils.isNullOrEmpty(id)) { Log.debug( CoreConstants.LOG_TAG, "VisitorID", "The custom VisitorID should not have null/empty id, this VisitorID will be" + " ignored"); } this.idOrigin = idOrigin; this.idType = idType; this.id = id; this.authenticationState = authenticationState; } /** * Compares the provided {@link VisitorID} object with this and determines if they are equal. * * <p>The comparison checks that the provided {@link Object} parameter is a {@code VisitorID} * instance. If it is, then checks the equality of the {@link #idType} and {@link #id} fields * between the two objects. * * @param o {@code VisitorID} object to compare against * @return {@code boolean} indicating whether the provided {@code VisitorID} object is equal to * this */ @Override public boolean equals(final Object o) { if (o == this) { return true; } if (!(o instanceof VisitorID)) { return false; } VisitorID idToCompare = (VisitorID) o; if (!this.idType.equals(idToCompare.idType)) { return false; } // if id is null, the passed in ID must be null to match if (this.id == null) { return idToCompare.id == null; } if (idToCompare.id == null) { return false; } return this.id.compareTo(idToCompare.id) == 0; } @Override public int hashCode() { int result = RANDOM_HASH_BASE; result = RANDOM_HASH_PADDING * result + id.hashCode(); result = RANDOM_HASH_PADDING * result + idType.hashCode(); return result; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/AdobeCallbackWithError.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; @SuppressWarnings("unused") public interface AdobeCallbackWithError<T> extends AdobeCallback<T> { void fail(final AdobeError error); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/BroadcastHandler.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; import android.content.Context; import android.content.Intent; interface BroadcastHandler { /** * Handle the Android system broadcast. This may marshall the data from the Intent, and convert * it into an event data {@code Map<String, Object>} and call the corresponding API to dispatch * the data in an {@link Event}. * * @param context Context as received from the Android Broadcast receiver. * @param intent Intent as received from the Android Broadcast receiver. */ void handleBroadcast(Context context, Intent intent); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/EventType.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; /** * Class to define the type of an {@code Event} * * @author Adobe Systems Incorporated * @version 5.0 * @see Event * @see EventSource */ public final class EventType { private EventType() {} public static final String ACQUISITION = "com.adobe.eventType.acquisition"; public static final String ANALYTICS = "com.adobe.eventType.analytics"; public static final String ASSURANCE = "com.adobe.eventType.assurance"; public static final String AUDIENCEMANAGER = "com.adobe.eventType.audienceManager"; public static final String CAMPAIGN = "com.adobe.eventType.campaign"; public static final String CONFIGURATION = "com.adobe.eventType.configuration"; public static final String CONSENT = "com.adobe.eventType.edgeConsent"; public static final String CUSTOM = "com.adobe.eventType.custom"; public static final String EDGE = "com.adobe.eventType.edge"; public static final String EDGE_IDENTITY = "com.adobe.eventType.edgeIdentity"; public static final String EDGE_MEDIA = "com.adobe.eventType.edgeMedia"; public static final String GENERIC_DATA = "com.adobe.eventType.generic.data"; public static final String GENERIC_IDENTITY = "com.adobe.eventType.generic.identity"; public static final String GENERIC_LIFECYCLE = "com.adobe.eventType.generic.lifecycle"; public static final String GENERIC_PII = "com.adobe.eventType.generic.pii"; public static final String GENERIC_TRACK = "com.adobe.eventType.generic.track"; public static final String HUB = "com.adobe.eventType.hub"; public static final String IDENTITY = "com.adobe.eventType.identity"; public static final String LIFECYCLE = "com.adobe.eventType.lifecycle"; public static final String LOCATION = "com.adobe.eventType.location"; public static final String MEDIA = "com.adobe.eventType.media"; public static final String MESSAGING = "com.adobe.eventType.messaging"; public static final String PII = "com.adobe.eventType.pii"; public static final String PLACES = "com.adobe.eventType.places"; public static final String RULES_ENGINE = "com.adobe.eventType.rulesEngine"; public static final String SIGNAL = "com.adobe.eventType.signal"; public static final String SYSTEM = "com.adobe.eventType.system"; public static final String TARGET = "com.adobe.eventType.target"; public static final String USERPROFILE = "com.adobe.eventType.userProfile"; public static final String WILDCARD = "com.adobe.eventType._wildcard_"; }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/EventSource.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; /** * Class to define the source of an {@code Event} * * @author Adobe Systems Incorporated * @version 5.0 * @see Event * @see EventType */ public final class EventSource { private EventSource() {} public static final String NONE = "com.adobe.eventSource.none"; public static final String OS = "com.adobe.eventSource.os"; public static final String REQUEST_CONTENT = "com.adobe.eventSource.requestContent"; public static final String REQUEST_IDENTITY = "com.adobe.eventSource.requestIdentity"; public static final String REQUEST_PROFILE = "com.adobe.eventSource.requestProfile"; public static final String REQUEST_RESET = "com.adobe.eventSource.requestReset"; public static final String RESPONSE_CONTENT = "com.adobe.eventSource.responseContent"; public static final String RESPONSE_IDENTITY = "com.adobe.eventSource.responseIdentity"; public static final String RESPONSE_PROFILE = "com.adobe.eventSource.responseProfile"; public static final String SHARED_STATE = "com.adobe.eventSource.sharedState"; public static final String WILDCARD = "com.adobe.eventSource._wildcard_"; public static final String APPLICATION_LAUNCH = "com.adobe.eventSource.applicationLaunch"; public static final String APPLICATION_CLOSE = "com.adobe.eventSource.applicationClose"; public static final String CONSENT_PREFERENCE = "consent:preferences"; public static final String UPDATE_CONSENT = "com.adobe.eventSource.updateConsent"; public static final String RESET_COMPLETE = "com.adobe.eventSource.resetComplete"; public static final String UPDATE_IDENTITY = "com.adobe.eventSource.updateIdentity"; public static final String REMOVE_IDENTITY = "com.adobe.eventSource.removeIdentity"; public static final String ERROR_RESPONSE_CONTENT = "com.adobe.eventSource.errorResponseContent"; public static final String CREATE_TRACKER = "com.adobe.eventSource.createTracker"; public static final String TRACK_MEDIA = "com.adobe.eventSource.trackMedia"; public static final String CONTENT_COMPLETE = "com.adobe.eventSource.contentComplete"; public static final String DEBUG = "com.adobe.eventSource.debug"; }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/AdobeCallback.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; @SuppressWarnings("unused") public interface AdobeCallback<T> { void call(final T value); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/AdobeError.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; import java.io.Serializable; /** */ public class AdobeError implements Serializable { private static final long serialVersionUID = 1L; /** when something unexpected happens internally. */ public static final AdobeError UNEXPECTED_ERROR = new AdobeError("general.unexpected", 0); /** when a timeout happens. */ public static final AdobeError CALLBACK_TIMEOUT = new AdobeError("general.callback.timeout", 1); /** when a callback is null. */ public static final AdobeError CALLBACK_NULL = new AdobeError("general.callback.null", 2); /** when a server error happens. */ public static final AdobeError SERVER_ERROR = new AdobeError("general.server.error", 4); /** when a network error happens. */ public static final AdobeError NETWORK_ERROR = new AdobeError("general.network.error", 5); /** when an invalid request is made. */ public static final AdobeError INVALID_REQUEST = new AdobeError("general.request.invalid", 6); /** when an invalid response is received. */ public static final AdobeError INVALID_RESPONSE = new AdobeError("general.response.invalid", 7); /** when a extension is not initialized. */ public static final AdobeError EXTENSION_NOT_INITIALIZED = new AdobeError("general.extension.not.initialized", 11); private final String errorName; private final int errorCode; protected AdobeError(final String errorName, final int errorCode) { this.errorName = errorName; this.errorCode = errorCode; } /** * Retrieves current error's name as a {@code String}. * * @return the error name {@link String} */ public String getErrorName() { return errorName; } /** * Retrieves current error's code as a {@code int}. * * @return the error code {@code int} */ public int getErrorCode() { return errorCode; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/ExtensionHelper.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.util.Map; /** Helper methods to access protected Extension methods from different packages */ public class ExtensionHelper { private ExtensionHelper() {} public static @Nullable String getName(@NonNull final Extension extension) { try { return extension.getName(); } catch (Exception e) { return null; } } public static @Nullable String getFriendlyName(@NonNull final Extension extension) { try { return extension.getFriendlyName(); } catch (Exception e) { return null; } } public static @Nullable String getVersion(@NonNull final Extension extension) { try { return extension.getVersion(); } catch (Exception e) { return null; } } public static @Nullable Map<String, String> getMetadata(@NonNull final Extension extension) { try { return extension.getMetadata(); } catch (Exception e) { return null; } } public static void notifyUnregistered(@NonNull final Extension extension) { try { extension.onUnregistered(); } catch (Exception ignored) { } } public static void notifyRegistered(@NonNull final Extension extension) { try { extension.onRegistered(); } catch (Exception ignored) { } } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/Evaluable.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; /** * Evaluable Interface. * * <p>The classes that implements {@link Evaluable} are {@link ComparisonExpression} {@link * LogicalExpression} {@link UnaryExpression} */ public interface Evaluable { RulesResult evaluate(final Context context); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/RulesEngine.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; import java.util.ArrayList; import java.util.List; /** RulesEngine to evaluate matching rules for given input data */ public class RulesEngine<T extends Rule> { private final Object rulesEngineMutex = new Object(); private final Evaluating evaluator; private final Transforming transformer; private List<T> rules; public RulesEngine(final Evaluating evaluator, final Transforming transformer) { this.evaluator = evaluator; this.transformer = transformer; this.rules = new ArrayList<>(); } public List<T> evaluate(final TokenFinder tokenFinder) { synchronized (rulesEngineMutex) { final Context context = new Context(tokenFinder, evaluator, transformer); List<T> triggerRules = new ArrayList<>(); for (final T rule : rules) { RulesResult result = rule.getEvaluable().evaluate(context); if (result.isSuccess()) { triggerRules.add(rule); } } return triggerRules; } } public void replaceRules(final List<T> newRules) { if (newRules == null) { return; } synchronized (rulesEngineMutex) { rules = new ArrayList<>(newRules); } } public void addRules(final List<T> newRules) { synchronized (rulesEngineMutex) { rules.addAll(newRules); } } public List<T> getRules() { return new ArrayList<>(rules); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/TokenFinder.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; public interface TokenFinder { Object get(final String key); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/TransformerBlock.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; @FunctionalInterface public interface TransformerBlock<T> { T transform(final Object e); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/Segment.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; /** * A segment represents a part of text that can be evaluated to a value. There are two types of * Segment - {@link SegmentToken} - {@link SegmentText} * * <p>The following string is parsed by {@link TemplateParser} to have 3 segments. "Hi {{username}}, * Welcome to New York" 1. Hi --> (SegmentText) 2. {{username}} --> (SegmentToken) 3. , Welcome to * New York --> (Segment Text) */ interface Segment { String getContent(final TokenFinder tokenFinder, final Transforming transformers); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/SegmentText.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; /** SegmentText represents plain text. */ public class SegmentText implements Segment { private final String content; public SegmentText(final String content) { this.content = content; } @Override public String getContent(final TokenFinder tokenFinder, final Transforming transformer) { return content; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/Transformer.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; import java.util.HashMap; import java.util.Map; public class Transformer implements Transforming { Map<String, TransformerBlock<?>> transformations = new HashMap<>(); public void register(final String name, final TransformerBlock<?> transformerBlock) { transformations.put(name, transformerBlock); } @Override public Object transform(final String name, final Object parameter) { TransformerBlock<?> block = transformations.get(name); if (block == null) { return parameter; } return block.transform(parameter); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/Operand.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; /** * Interface for Operands. * * <p>The classes that implements {@link Operand} are {@link OperandLiteral} {@link * OperandMustacheToken} {@link OperandFunction} */ public interface Operand<T> { /** * All operand's must implement this to retrieve its resolved value. * * @param context The context contains details for token swapping and transforming the operand * if required. * @return the resolved operand value */ T resolve(final Context context); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/Context.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; public class Context { public final TokenFinder tokenFinder; public final Evaluating evaluator; public final Transforming transformer; public Context( final TokenFinder tokenFinder, final Evaluating evaluator, final Transforming transformer) { this.tokenFinder = tokenFinder; this.evaluator = evaluator; this.transformer = transformer; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/RulesResult.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; public class RulesResult { public enum FailureType { UNKNOWN, CONDITION_FAILED, TYPE_MISMATCHED, MISSING_OPERATOR, INVALID_OPERAND, } private final boolean isSuccess; private final String failureMessage; private final FailureType failureType; public static final RulesResult SUCCESS = new RulesResult(true); public RulesResult(final FailureType failureType, final String failureMessage) { this.isSuccess = false; this.failureMessage = failureMessage; this.failureType = failureType; } public boolean isSuccess() { return isSuccess; } public String getFailureMessage() { return failureMessage; } public FailureType getFailureType() { return failureType; } private RulesResult(final boolean isSuccess) { this.isSuccess = isSuccess; this.failureMessage = null; this.failureType = null; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/OperandLiteral.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; public class OperandLiteral<T> implements Operand<T> { private final T value; public OperandLiteral(final T value) { this.value = value; } @Override public T resolve(final Context context) { return this.value; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/UnaryExpression.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; public class UnaryExpression<A> implements Evaluable { private final Operand<A> lhs; private final String operationName; public UnaryExpression(final Operand<A> lhs, final String operationName) { this.lhs = lhs; this.operationName = operationName; } @Override public RulesResult evaluate(final Context context) { A resolvedLhs = null; if (lhs != null) { resolvedLhs = lhs.resolve(context); } if (operationName == null || operationName.isEmpty()) { return new RulesResult( RulesResult.FailureType.INVALID_OPERAND, String.format("Evaluating %s %s returned false", resolvedLhs, operationName)); } return context.evaluator.evaluate(operationName, resolvedLhs); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/LogicalExpression.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; import java.util.List; public class LogicalExpression implements Evaluable { public final List<Evaluable> operands; public final String operationName; public LogicalExpression(final List<Evaluable> operands, final String operationName) { this.operands = operands; this.operationName = operationName; } @Override public RulesResult evaluate(final Context context) { if (operationName == null || operationName.isEmpty()) { return new RulesResult( RulesResult.FailureType.MISSING_OPERATOR, "Null or empty operator for logical expression"); } switch (operationName) { case "and": return performAndOperation(context, operands); case "or": return performOrOperation(context, operands); default: return new RulesResult( RulesResult.FailureType.MISSING_OPERATOR, String.format("Unknown conjunction operator - %s.", operationName)); } } private RulesResult performAndOperation( final Context context, final List<Evaluable> resolvedOperands) { for (Evaluable evaluable : resolvedOperands) { if (evaluable != null) { RulesResult rulesResult = evaluable.evaluate(context); if (!rulesResult.isSuccess()) { return new RulesResult( RulesResult.FailureType.CONDITION_FAILED, "AND operation returned false."); } } } return RulesResult.SUCCESS; } private RulesResult performOrOperation( final Context context, final List<Evaluable> resolvedOperands) { for (Evaluable evaluable : resolvedOperands) { if (evaluable != null) { RulesResult rulesResult = evaluable.evaluate(context); if (rulesResult.isSuccess()) { return RulesResult.SUCCESS; } } } return new RulesResult( RulesResult.FailureType.CONDITION_FAILED, "OR operation returned false."); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/FunctionBlock.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; @FunctionalInterface public interface FunctionBlock<T> { T execute(final Object... e); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/ComparisonExpression.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; /** * {@link ComparisonExpression} allows for comparison of two operands and evaluates to a True or * False. Comparison operators include LessThan, LessThanOrEqual to, Equal, NotEqual, GreaterThan, * GreaterThanOrEqual to, Contains and notContains. */ public class ComparisonExpression<A, B> implements Evaluable { private final Operand<A> lhs; private final Operand<B> rhs; private final String operationName; /** * Initializer. Constructs the {@link ComparisonExpression} object with operands and operation * name. * * @param lhs an {@link Operand} * @param operationName A {@code String} value defining the operation. * @param rhs an {@link Operand} */ public ComparisonExpression( final Operand<A> lhs, final String operationName, final Operand<B> rhs) { this.lhs = lhs; this.operationName = operationName; this.rhs = rhs; } /** * Call this method to evaluate this {@link ComparisonExpression}. * * <p>This method always returns a valid non null {@link RulesResult} object. Returns * RulesResult failure if the operation name or either of the operands are null. * * @param context The context containing details for token swapping and transforming the operand * if required. A non null value of {@link Context} is expected to be passed to this method. * @return A {@link RulesResult} object representing a evaluated rule */ public RulesResult evaluate(final Context context) { if (operationName == null) { return new RulesResult( RulesResult.FailureType.MISSING_OPERATOR, "Operator is null, Comparison returned false"); } if (lhs == null || rhs == null) { return new RulesResult( RulesResult.FailureType.INVALID_OPERAND, "Operand is null, Comparison returned false."); } A resolvedLhs = lhs.resolve(context); B resolvedRhs = rhs.resolve(context); if (resolvedLhs == null || resolvedRhs == null) { return new RulesResult( RulesResult.FailureType.INVALID_OPERAND, String.format( "Comparison %s %s %s returned false", resolvedLhs, operationName, resolvedRhs)); } return context.evaluator.evaluate(resolvedLhs, operationName, resolvedRhs); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/OperandFunction.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; public class OperandFunction<T> implements Operand<T> { private final FunctionBlock<T> block; private final Object[] functionParameters; public OperandFunction(final FunctionBlock<T> block, final Object... functionParameters) { this.block = block; this.functionParameters = functionParameters; } @Override public T resolve(final Context context) { return block.execute(functionParameters); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/Transforming.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; public interface Transforming { Object transform(final String name, final Object parameter); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/TemplateParser.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; import java.util.ArrayList; import java.util.List; public class TemplateParser { private static final DelimiterPair defaultDelimiter = new DelimiterPair("{{", "}}"); static List<Segment> parse(final String templateString) { return TemplateParser.parse(templateString, defaultDelimiter); } static List<Segment> parse(final String templateString, final DelimiterPair delimiter) { List<Segment> tokens = new ArrayList<>(); if (templateString == null || templateString.isEmpty()) { return tokens; } DelimiterPair currentDelimiter = delimiter == null ? defaultDelimiter : delimiter; int i = 0; int end = templateString.length(); Parser parser = new Parser(i, State.START); while (i < end) { switch (parser.state) { case START: if (templateString.substring(i).startsWith(currentDelimiter.getStartTag())) { parser.setState(i, State.TAG); i = templateString.indexOf(currentDelimiter.getStartTag(), i) + 1; } else { parser.setState(i, State.TEXT); } break; case TEXT: if (templateString.substring(i).startsWith(currentDelimiter.getStartTag())) { if (parser.index != i) { tokens.add(new SegmentText(templateString.substring(parser.index, i))); } parser.setState(i, State.TAG); i = templateString.indexOf(currentDelimiter.getStartTag(), i) + 1; } break; case TAG: if (templateString.substring(i).startsWith(currentDelimiter.getEndTag())) { int tokenContentStartIndex = parser.index + currentDelimiter.getStartLength(); tokens.add( new SegmentToken( templateString.substring(tokenContentStartIndex, i))); parser.state = State.START; i = templateString.indexOf(currentDelimiter.getEndTag(), i) + 1; } break; } i++; } switch (parser.state) { case START: break; case TEXT: tokens.add(new SegmentText(templateString.substring(parser.index, i))); break; case TAG: return new ArrayList<>(); } return tokens; } } class Parser { int index; State state; Parser(final int index, final State state) { this.index = index; this.state = state; } public void setState(final int index, final State state) { this.state = state; this.index = index; } } enum State { START, TEXT, TAG, }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/OperandMustacheToken.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; import java.util.List; /** Class to handle the mustache token Operand. */ public class OperandMustacheToken<T> implements Operand<T> { private static final String LOG_TAG = "OperandMustacheToken"; private final MustacheToken mustacheToken; private final Class<T> tClass; /** * Constructor. Initialize this operand using a tokenString. A valid tokenString has only one * token. For example : {{region.city}} * {%~state.com.adobe.marketing,mobile.lifecycle.contextdata.deviceName%} * * <p>Following are considered are invalid token strings 1. region.city - (this string does not * contain token delimiters) 2. {{region.city - (this string is not enclosed between delimiters) * 3. some{{region.city}} - (this string does not start with a valid token) * * @param tokenString string representing a mustache token operand * @param tClass string representing a mustache token operand */ public OperandMustacheToken(final String tokenString, final Class<T> tClass) { MustacheToken mustacheToken = null; // Mustache token operands must have only one token, ignore others. final List<Segment> segmentList = TemplateParser.parse(tokenString); if (segmentList.size() > 0 && segmentList.get(0) instanceof SegmentToken) { SegmentToken segmentToken = (SegmentToken) segmentList.get(0); mustacheToken = segmentToken.getMustacheToken(); } this.mustacheToken = mustacheToken; this.tClass = tClass; } /** * Returns the resolved value of the MustacheToken operand. An invalid mustacheToken operand * returns null. * * @param context The context contains details for token swapping and transforming the operand * if required * @return the resolved operand value */ @Override public T resolve(final Context context) { if (mustacheToken == null) { return null; } Object resolvedValue = mustacheToken.resolve(context.tokenFinder, context.transformer); try { return tClass.cast(resolvedValue); } catch (ClassCastException ex) { return null; } } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/Template.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; import java.util.List; public class Template { private final List<Segment> segments; public Template(final String templateString) { this.segments = TemplateParser.parse(templateString); } public Template(final String templateString, final DelimiterPair delimiterPair) { this.segments = TemplateParser.parse(templateString, delimiterPair); } public String render(final TokenFinder tokenFinder, final Transforming transformer) { StringBuilder stringBuilder = new StringBuilder(); for (Segment eachSegment : segments) { stringBuilder.append(eachSegment.getContent(tokenFinder, transformer)); } return stringBuilder.toString(); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/DelimiterPair.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; /** * Class representing delimiter pair for tokens. * * <p>The default delimiter pair from launch rules are "{%" "%}" eg token: {%region.cityName%} */ public class DelimiterPair { private final String startTag; private final String endTag; /** * Constructor. * * @param startString the startTag for this {@link DelimiterPair} * @param endString the endTag for this {@link DelimiterPair} */ public DelimiterPair(final String startString, final String endString) { this.startTag = startString; this.endTag = endString; } /** * @return the startTag for this {@link DelimiterPair} */ String getStartTag() { return startTag; } /** * @return the endTag for this {@link DelimiterPair} */ String getEndTag() { return endTag; } /** * @return the character length of startTag of this delimiter */ int getStartLength() { return startTag.length(); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/SegmentToken.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; /** * SegmentToken represents token, whose value is substituted by the {@link TokenFinder} or {@link * Transforming}. */ public class SegmentToken implements Segment { private final MustacheToken mustacheToken; public SegmentToken(final String mustacheString) { this.mustacheToken = new MustacheToken(mustacheString); } public MustacheToken getMustacheToken() { return mustacheToken; } /** Retrieves the evaluated value of this {@link SegmentToken} */ @Override public String getContent(final TokenFinder tokenFinder, final Transforming transformer) { Object resolvedToken = mustacheToken.resolve(tokenFinder, transformer); if (resolvedToken != null) { return resolvedToken.toString(); } return ""; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/ConditionEvaluator.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; import java.util.regex.Pattern; public class ConditionEvaluator implements Evaluating { private final Option option; private static final String OPERATOR_EQUALS = "equals"; private static final String OPERATOR_NOT_EQUALS = "notEquals"; private static final String OPERATOR_GREATER_THAN = "greaterThan"; private static final String OPERATOR_GREATER_THAN_OR_EQUALS = "greaterEqual"; private static final String OPERATOR_LESS_THAN = "lessThan"; private static final String OPERATOR_LESS_THAN_OR_EQUALS = "lessEqual"; private static final String OPERATOR_CONTAINS = "contains"; private static final String OPERATOR_NOT_CONTAINS = "notContains"; private static final String OPERATOR_STARTS_WITH = "startsWith"; private static final String OPERATOR_ENDS_WITH = "endsWith"; private static final String OPERATOR_EXISTS = "exists"; private static final String OPERATOR_NOT_EXISTS = "notExist"; public enum Option { DEFAULT, // For case sensitive string operations CASE_INSENSITIVE, // For case insensitive string operations } public ConditionEvaluator(final Option option) { this.option = option; } public ConditionEvaluator() { this.option = Option.DEFAULT; } /** * Runs operation on the operands. * * <p>This method always returns a valid non null {@link RulesResult} object. {@link * RulesResult#SUCCESS} is returned if the operation on the operands evaluates to true. * * @param lhs A resolved {@link Operand} * @param operation A {@link String} representing the operation to be performed on the operands * @param rhs A resolved {@code Operand} */ @Override public <A, B> RulesResult evaluate(final A lhs, final String operation, final B rhs) { boolean evaluationResult; switch (operation) { case OPERATOR_EQUALS: evaluationResult = this.checkEqual(lhs, rhs); break; case OPERATOR_NOT_EQUALS: evaluationResult = this.notEqual(lhs, rhs); break; case OPERATOR_STARTS_WITH: evaluationResult = this.startsWith(lhs, rhs); break; case OPERATOR_ENDS_WITH: evaluationResult = this.endsWith(lhs, rhs); break; case OPERATOR_GREATER_THAN: evaluationResult = this.greaterThan(lhs, rhs); break; case OPERATOR_GREATER_THAN_OR_EQUALS: evaluationResult = this.greaterThanEquals(lhs, rhs); break; case OPERATOR_LESS_THAN: evaluationResult = this.lesserThan(lhs, rhs); break; case OPERATOR_LESS_THAN_OR_EQUALS: evaluationResult = this.lesserThanOrEqual(lhs, rhs); break; case OPERATOR_CONTAINS: evaluationResult = this.contains(lhs, rhs); break; case OPERATOR_NOT_CONTAINS: evaluationResult = this.notContains(lhs, rhs); break; default: return new RulesResult( RulesResult.FailureType.MISSING_OPERATOR, String.format("Operator is invalid \"%s\"", operation)); } return evaluationResult ? RulesResult.SUCCESS : new RulesResult( RulesResult.FailureType.CONDITION_FAILED, String.format("Condition not matched for operation \"%s\"", operation)); } @Override public <A> RulesResult evaluate(final String operation, final A lhs) { boolean evaluationResult; switch (operation) { case OPERATOR_EXISTS: evaluationResult = this.exists(lhs); break; case OPERATOR_NOT_EXISTS: evaluationResult = this.notExists(lhs); break; default: return new RulesResult( RulesResult.FailureType.MISSING_OPERATOR, String.format("Operator is invalid \"%s\"", operation)); } return evaluationResult ? RulesResult.SUCCESS : new RulesResult( RulesResult.FailureType.CONDITION_FAILED, String.format("Condition not matched for operation \"%s\"", operation)); } // -------------------------------------------------------------------------- // Private - Operator definitions // -------------------------------------------------------------------------- private boolean checkEqual(final Object lhs, final Object rhs) { if (lhs instanceof String && rhs instanceof String && option == Option.CASE_INSENSITIVE) { String lhsValue = lhs.toString(); String rhsValue = rhs.toString(); return lhsValue.equalsIgnoreCase(rhsValue); } return lhs.equals(rhs); } private boolean notEqual(final Object lhs, final Object rhs) { return !checkEqual(lhs, rhs); } private boolean startsWith(final Object lhs, final Object rhs) { if (lhs instanceof String && rhs instanceof String) { String lhsValue = lhs.toString(); String rhsValue = rhs.toString(); String matcherMode = option == ConditionEvaluator.Option.CASE_INSENSITIVE ? "(?i)" : ""; return lhsValue.matches(matcherMode + Pattern.quote(rhsValue) + ".*"); } return false; } private boolean endsWith(final Object lhs, final Object rhs) { if (lhs instanceof String && rhs instanceof String) { String lhsValue = lhs.toString(); String rhsValue = rhs.toString(); String matcherMode = option == ConditionEvaluator.Option.CASE_INSENSITIVE ? "(?i)" : ""; return lhsValue.matches(matcherMode + ".*" + Pattern.quote(rhsValue)); } return false; } private boolean exists(final Object lhs) { return lhs != null; } private boolean notExists(final Object lhs) { return lhs == null; } // -------------------------------------------------------------------------- // Private - Operator definitions coming soon // -------------------------------------------------------------------------- private boolean greaterThan(final Object lhs, final Object rhs) { Double resolvedLhs = tryParseDouble(lhs); Double resolvedRhs = tryParseDouble(rhs); if (resolvedLhs == null || resolvedRhs == null) { return false; } return resolvedLhs > resolvedRhs; } private boolean greaterThanEquals(final Object lhs, final Object rhs) { Double resolvedLhs = tryParseDouble(lhs); Double resolvedRhs = tryParseDouble(rhs); if (resolvedLhs == null || resolvedRhs == null) { return false; } return resolvedLhs >= resolvedRhs; } private boolean lesserThan(final Object lhs, final Object rhs) { Double resolvedLhs = tryParseDouble(lhs); Double resolvedRhs = tryParseDouble(rhs); if (resolvedLhs == null || resolvedRhs == null) { return false; } return resolvedLhs < resolvedRhs; } private boolean lesserThanOrEqual(final Object lhs, final Object rhs) { Double resolvedLhs = tryParseDouble(lhs); Double resolvedRhs = tryParseDouble(rhs); if (resolvedLhs == null || resolvedRhs == null) { return false; } return resolvedLhs <= resolvedRhs; } private boolean contains(final Object lhs, final Object rhs) { if (lhs instanceof String && rhs instanceof String) { String lhsValue = lhs.toString(); String rhsValue = rhs.toString(); if (option == ConditionEvaluator.Option.CASE_INSENSITIVE) { lhsValue = lhsValue.toLowerCase(); rhsValue = rhsValue.toLowerCase(); } return lhsValue.contains(rhsValue); } return false; } private boolean notContains(final Object lhs, final Object rhs) { return !contains(lhs, rhs); } private Double tryParseDouble(final Object value) { try { return Double.valueOf(value.toString()); } catch (Exception ex) { return null; } } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/MustacheToken.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Class representing mustache token. * * <p>Once a token is identified in any part of the rule, use this class to obtain the resolved * value of the token. A token can be of two types 1. Variable Following example demonstrates * variable token to retrieve the "city" details from the SDK context. {{region.city}} 2. Function * Following example demonstrates function token to urlEncode the provided webURL. * {{urlenc(http://adobe.com)}} */ class MustacheToken { private final Type tokenType; private final String tokenString; private String functionName; private MustacheToken innerVariable; /** * Constructor to initialize the mustache token. * * <p>This constructor automatically recognizes the token type from the provided token string * * @param tokenString the token string without the delimiters representing the token */ MustacheToken(final String tokenString) { Matcher functionMatcher = Pattern.compile("\\(([^)]+)\\)").matcher(tokenString); this.tokenString = tokenString; // check if the token is a function if (functionMatcher.find()) { innerVariable = new MustacheToken(functionMatcher.group(1)); functionName = tokenString.substring(0, functionMatcher.start()); tokenType = Type.FUNCTION; return; } tokenType = Type.VARIABLE; } /** * Resolves the token into its corresponding value. * * @param tokenFinder A {@link TokenFinder} instance that contains SDK context to replace tokens * @param transformers A set of transformers to evaluate the function tokens. * @return value of resolved token. */ protected Object resolve(final TokenFinder tokenFinder, final Transforming transformers) { if (tokenType == Type.FUNCTION) { return transformers.transform( this.functionName, innerVariable.resolve(tokenFinder, transformers)); } else { return tokenFinder.get(tokenString); } } private enum Type { FUNCTION, VARIABLE, } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/Rule.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; /** Interface to be implemented by defining rule element. */ public interface Rule { Evaluable getEvaluable(); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/rulesengine/Evaluating.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.rulesengine; public interface Evaluating { <A, B> RulesResult evaluate(final A lhs, final String operation, final B rhs); <A> RulesResult evaluate(final String operation, final A lhs); }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/util/StringUtils.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.util; public final class StringUtils { private StringUtils() {} /** * Checks if a {@code String} is null, empty or it only contains whitespaces. * * @param str the {@link String} that we want to check * @return {@code boolean} with the evaluation result */ public static boolean isNullOrEmpty(final String str) { return str == null || str.trim().isEmpty(); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/util/StreamUtils.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.util; import com.adobe.marketing.mobile.internal.CoreConstants; import com.adobe.marketing.mobile.services.Log; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; public final class StreamUtils { private static final int STREAM_READ_BUFFER_SIZE = 1024; private static final String TAG = "StreamUtils"; private StreamUtils() {} /** * Reads the contents of the {@code InputStream} as a String. The input stream provided will be * closed after contents are read. * * @param inputStream {@link InputStream} to read * @return {@link String} representation of the input stream */ public static String readAsString(final InputStream inputStream) { if (inputStream == null) { return null; } try (final ByteArrayOutputStream buffer = new ByteArrayOutputStream()) { final byte[] data = new byte[STREAM_READ_BUFFER_SIZE]; int bytesRead; while ((bytesRead = inputStream.read(data, 0, data.length)) != -1) { buffer.write(data, 0, bytesRead); } final byte[] byteArray = buffer.toByteArray(); return new String(byteArray, StandardCharsets.UTF_8); } catch (final IOException ex) { Log.trace( CoreConstants.LOG_TAG, TAG, "Unable to convert InputStream to String," + ex.getLocalizedMessage()); return null; } finally { try { inputStream.close(); } catch (final IOException ex) { Log.trace( CoreConstants.LOG_TAG, TAG, "Unable to close InputStream," + ex.getLocalizedMessage()); } } } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/util/CloneFailedException.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.util; import androidx.annotation.NonNull; /** * Exception thrown by {@link EventDataUtils} to indicate that an exception occurred during deep * clone. */ public class CloneFailedException extends Exception { private final Reason reason; /** Enum to indicate the reason for the exception. */ enum Reason { MAX_DEPTH_REACHED, UNSUPPORTED_TYPE, UNKNOWN } /** * Constructor. * * @param message {@code String} message for the exception */ public CloneFailedException(final String message) { this(message, Reason.UNKNOWN); } /** * Constructor. * * @param reason the {@link Reason} for the exception */ CloneFailedException(@NonNull final Reason reason) { this(reason.toString(), reason); } /** * Private constructor to unify public constructors and allow cascading. * * @param message {@code String} message for the exception * @param reason the {@link Reason} for the exception */ private CloneFailedException(@NonNull final String message, @NonNull final Reason reason) { super(message); this.reason = reason; } /** * Returns the {@link Reason} for the exception. * * @return returns the {@link Reason} for the exception */ @NonNull Reason getReason() { return reason; } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/util/DataReaderException.java
/* Copyright 2022 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.util; /** Exception thrown by {@link DataReader} to indicate an error occurred reading object. */ public class DataReaderException extends Exception { /** * Constructor. * * @param message {@code String} message for the exception */ public DataReaderException(final String message) { super(message); } /** * Constructor. * * @param inner {@code Exception} that caused this exception */ public DataReaderException(final Exception inner) { super(inner); } }
0
AEP Core
/Users/yy/GIT/Github/llm-fine-tune/data_prep/repos/core_3_2_0/core/src/main/java/com/adobe/marketing/mobile/util/MapUtils.java
/* Copyright 2023 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adobe.marketing.mobile.util; import androidx.annotation.Nullable; import java.util.Collection; import java.util.Map; /** Utility class for Maps */ public final class MapUtils { private MapUtils() {} /** * Checks if the provided {@code map} is null or it has no element * * @param map the {@code map} to be verified * @return true if null or empty, false otherwise */ public static boolean isNullOrEmpty(@Nullable final Map<?, ?> map) { return map == null || map.isEmpty(); } /** * Adds {@code key}/{@code value} to {@code map} if {@code value} is not null or an empty * string, map or collection. * * @param map collection to put {@code values} mapped to {@code key} if {@code values} is * non-null and contains at least one entry * @param key key used to map {@code value} in {@code map} * @param value an object to add to {@code map} if not null or empty */ public static void putIfNotEmpty( @Nullable final Map<String, Object> map, @Nullable final String key, @Nullable final Object value) { if (map == null || key == null || value == null) { return; } boolean isValueEmpty = false; if (value instanceof String) { isValueEmpty = ((String) value).isEmpty(); } else if (value instanceof Map<?, ?>) { isValueEmpty = ((Map<?, ?>) value).isEmpty(); } else if (value instanceof Collection<?>) { isValueEmpty = ((Collection<?>) value).isEmpty(); } if (!isValueEmpty) { map.put(key, value); } } }
0
README.md exists but content is empty.
Downloads last month
34