Class LoadImagesCommand

java.lang.Object
com.oorian.messaging.commands.Command
com.oorian.messaging.commands.LoadImagesCommand

public class LoadImagesCommand extends Command
Command to preload multiple images on the client side.

This command instructs the client to load multiple images into the browser cache before they're needed for display. This is useful for optimizing page performance by preloading image galleries, slideshows, or other image-heavy content.

Features:

  • Preloads multiple images in a single command
  • URL encoding for safe transmission
  • Batch image loading optimization
  • Supports single or multiple image URLs

Usage:


 // Preload multiple images
 List<String> urls = Arrays.asList("img1.jpg", "img2.jpg", "img3.jpg");
 LoadImagesCommand loadImgs = new LoadImagesCommand(urls);

 // Or preload a single image
 LoadImagesCommand loadImg = new LoadImagesCommand("single.jpg");
 JsonObject json = loadImg.toJson();
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • LoadImagesCommand

      public LoadImagesCommand(List<String> imageUrls)
      Constructs a new LoadImagesCommand to preload multiple images.
      Parameters:
      imageUrls - the list of image URLs to preload
    • LoadImagesCommand

      public LoadImagesCommand(String imageUrl)
      Constructs a new LoadImagesCommand to preload a single image.
      Parameters:
      imageUrl - the URL of the image to preload
  • Method Details

    • toJson

      public JsonObject toJson()
      Generates the JSON representation of this load images command.

      The JSON includes the command ID and an array of URL-encoded image sources.

      Specified by:
      toJson in class Command
      Returns:
      a JsonObject containing the load images command data