Название категории

Collection vs collections

Collection vs Collections in Java

Collections, with an “s”, in Java is a utility class. The Collections class provides generic algorithms that are used for sorting, shuffling, searching, copying, filling, and reversing. Collection, without an “s”, is an interface which is also the root interface in the hierarchy from which most of the interfaces in the Java Collection Framework derive. For example, the List, Queue, and Set interfaces all derive from the Collection interface. But, note that the Map interface does NOT derive from the Collection interface.

Aside from being the name for a root interface, the term collection is used to refer to an object that stores data. You can also think of a collection as a container. Most collections support the fundamental operations of insert, retrieve, and iterate.

How to get a concrete Collection class?

You might be wondering what’s the point of just having an interface hierarchy – what about the actual concrete classes which implement the interface(s)? Of course, there are concrete classes provided by Java that implement those interfaces. They are in the java.util package. One example would be the popular ArrayList class, which implements the List interface. Another popular class is HashMap, which implements the Map interface – HashMap is commonly used as a hashtable implementation in Java.

What does the Collections class do?

Earlier we mentioned that the Collections class is a utility class. Note that the meaning of a utility class is a class that defines a set of methods that perform common, often re-used functions. The Collections class contains a lot of static methods which are used to implement the algorithms mentioned earlier – like sort(), shuffle(), etc.

Because the methods are static you will see a lot of calls that use the Collections class directly, which will look like something that starts with “Collections.”, for example – Collections.sort(someArgument).

Those methods are used to perform operations on collections – so actual Collection types (which are of type Collection, where Collection is the interface). An example of when we would want to use a Collections method is if we have an ArrayList, and we want to sort all the elements in that ArrayList. We could simply make a call like this: Collections.sort(someArrayList).

So, we could summarize the difference between the Collections class and Collection interface by saying that Collections and Collection, although different things, are very much related. This is because Collections is a utility class with methods that are meant to operate on concrete classes that are of the Collection type.

Note that some of the Collections class methods can also be used on classes that implement the Map interface – which do not derive from the Collection interface and for that reason are not of the Collection type.

This is a common interview question that you should definitely know when preparing for a Java interview.

Follow Varoon Sahgal, author, on Google Plus

When To Use A New SharePoint Site Collection VS. A New Sub Site

Categories: Configurations, Design, Document Management, Features, Infrastructure, MOSS 2007, Permission Management, SharePoint 2010, System Administration, WSS2, WSS3

Collection vs collections

I have been asked all too often by clients, "When should we use a Site Collection and when should we use a Sub Site?". What's the best option and how do I choose?

The good thing to remember is that there is no definitive answer to this question, however, there are more technical factors that can help you decide on whether you should chose a site collection over a sub site or vice versa.

Some of the reasons that I might pick a Site Collection

  1. I have a branded new site and I want it created with no relation to any other site. If you are creating a new site and it's not related to any other sites that you have in your existing site hierarchy or SharePoint farm then you chose a site collection.
  2. If you require a dedicated URL to your site. You want your client to access and upload documents so you want to create a URL for your partner at http://partner.mycompany.com . You can bind this URL to a site collection. This URL cannot be bound to a sub site of an existing site collection.
  3. You want to create a managed path called divisions and you want to create a site for each division you your organization. Each division wants complete control over their site and sub sites and want to be found at URL divisions/divisionName.
  4. Where you require to have a quota set on a site created you will need to use a site collection as only site collections can have quotas assigned to them.
  5. If you need a dedicated Content Database for your site as you expect to have vast amounts of data and documents and you require it to be more secure that normal, you can can configure a dedicated site collection with a dedicated content database attached to it.
  6. If you were purchasing hosted environments from a hosting provider then you would also see the difference in a site collection and a sub site in the cost model offered by the hosting company. You will notice that getting a site collection provisioned with have a higher admin cost than just creating a sub site. Sub site creation can be carried out by a member of the owners group of any site or site collection. Whereas site collection creation has to be completed by Farm Administrators unless there is a mechanism provided though web wizards.
  7. As part of a backup and recovery policy you want your data to be very quickly restored if there are any problems or if there has been content that has gotten deleted that you need to retrieve. A site collection is better in this case because you can restore the site collection more easily than you can restore a site or a sub site of a site.

Some of the reasons why you should select a sub site:

  1. You want to inherit the same security for the new sub site as its parent site & the security model for your organization already exists. You want to create a new site but you don't want to change or move away from the existing security model implemented already.
  2. There has been a team in your organization unit that created many new site columns and site content types that you would like to use throughout your site and its sub sites -- as parent sites can contain site content types, these can be used in all subs sites of the site hierarchy -- Site Collections break this functionality.
  3. You want to allow the Site Owners and Designers to manage all sites that get created without any overhead of having to log a support call for a new site collection.
  4. You want to aggregate data throughout your site hierarchy using Web Parts like the Content Query Web Part, Data View Web Part and other data aggregation Web Parts.
  5. You have a site template that you want to apply to the new site that creates a couple of lists and libraries as part of the template -- an example may be you want a Tasks Manager Site Template where a site can maintain and manage all your tasks using tasks lists and to have them integrate with Outlook.
  6. If your site is going to be a short lived site and it's only going to be used in the process of creating some other content. An example might be a meeting site where you create a site that is created from a Meetings Templates. You can record and schedule meetings regarding the production of a catalog of products for your organization. This site is short lived and won't be in existence after the production of the catalog is completed.

What about the times where I don't technically have any requirements like a dedicated URL and Content Database, tight security with very limited access, custom coded solutions deployed to a site collection, etc?

If you do not have any of the requirements listed above or indeed any technical requirement that might need a site collection then you should always be thinking of the Sub Site as the way forward. You can get most, if not all, of what you want by using sub sites and there are no extra overheads in using sub sites. Site Collections and all of the content created within its site hierarchy is accessible and can be aggregated using some of the Out-Of-The-Box web parts. This works well for intranet type sites and sub sites. News from the IT/Operations site can be easily aggregated to the root site without the need for extra authentication or custom code.

Organizing Your Images: Galleries & Collections

Images are kept in galleries, and galleries can be organized into collections that all live within your Image Browser. You can sort images, galleries, and collections by their name, date uploaded, date created, a custom sort, and more. It's important to create an organization system that works best for you. To access your images, click the Images link from the Navigation Bar.

Collection vs collections

Collection A group of galleries and/or other collections. May not contain loose images - those must go in a gallery. A collection is visually represented by a folder icon.

Collection vs collections

Nested gallery/collection A gallery or collection that is stored within a collection. Through the ability to infinitely nest collections within one another, you can keep both your website and Image Browser organized and running at optimal speed.

Collection vs collections

Top level (also called "root level") This term describes a gallery or collection that exists on its own that is not nested in other collections

Collection vs collectionsNote: It's possible for galleries or collections to exist as both top level and nested in other collections. Learn more in the Adding a Gallery to a Collection section at the bottom of this page

Collection vs collections

Sorting Your Galleries, Collections, and Images

Sorting your galleries, collections, and images is particularly important for your Listed on Website section, because their order within the Image Browser is reflected on your live website's Gallery List page.

1. From the Left Pane, select the gallery or collection that you'd like to sort.

Collection vs collectionsNote: To organize the top-level galleries/collections that display on your public Gallery List page, click the Listed on Website tab.

Collection vs collections

2. At the top of the Center Pane, click on the Sort by drop-down menu. A selection of sorting options are there for your choosing. These will vary based on the type of content you're sorting (i.e. images vs. galleries/collections). When sorting a collection, you'll see two different sort options: the primary sort (i.e. name vs. date created), as well as a secondary sort (whether you'd like galleries first, collections first, or the two intermingled and dictated only by the primary sort).

Collection vs collections

3. If you prefer to custom sort your collections, galleries, or images, choose the Custom option. In this window, you will be able to drag and drop your content into the desired order. Once set, be sure to click the Save button in the top right-hand corner of the Center Pane. (Tip: Collapse the Left and Right Panes using the dividers on either side of the Center Pane to be able to see more content in your Image Browser -- this makes custom sorting much more efficient!)

Collection vs collections

When custom sorting the images in a gallery, you will be given the option to define the starting sequence of the sort, either by filename, date uploaded, or date taken. Clicking any of the sort selections a second time from this window will swap the direction.

Collection vs collections

Moving a gallery or a collection removes it from its current location and puts it into another. (This is different from adding a gallery to a collection, which keeps the gallery in its current location, too. Please read the Adding a Galley to a Collection section, below.) There are three ways to move content: dragging and dropping within the Left Pane, using the Actions drop-down menu in the Center Pane, or clicking the +/- menu from the Right Pane.

1. From the Left or Center Pane of your Image Browser, select the gallery or collection you want to move.

Collection vs collections

2. Click and hold your mouse to drag and drop your selection to its new location in the Left Pane. Be sure your mouse highlights the new desired location before releasing.

Collection vs collectionsNote: It is not possible to drag from the Left Pane to the Right (only Left to Left or Right to Left).

Collection vs collections

Using Menu Actions to a Move Gallery/Collection

There are options to use menu action buttons rather then dragging and dropping to move content.

1. Select the collection or gallery from the Left Pane.

Collection vs collections

2. Click the Add or move menu located in the Right Pane. Select Move to collection. (Or, to move multiple galleries/collections in batch, select Move to another collection from the Center Pane's Actions menu.)

Collection vs collections

3. In the pop-up box that appears, enter the collection into which you would like to move your selection. Click on the text field and begin typing the collection’s name. You may also create a new collection on the fly by clicking the Create a collection link, naming your new collection, and clicking Add. When you submit the action, your selection will be moved to this newly created collection.

Collection vs collections

Adding a Gallery to a Collection

For more flexible organization, galleries may be located in as many collections as you'd like. Adding a gallery to multiple collections merely creates virtual copies of it and doesn't take up additional storage space in your account. (It should be noted that collections, however, may only exist in one location and cannot be cross-listed in other collections.)

1. From the Left or Center Pane of your Image Browser, select the gallery you want to add.

Collection vs collections

2. Click the Add or move menu located in the Right Pane. Select Add to collection . (Or, to add multiple galleries/collections in batch, select Add gallery to another collection from the Center Pane's Actions menu.)

Collection vs collections

3. In the pop-up box that appears, click on the text field and begin typing the collection’s name. You may also create a new collection on the fly by clicking the Create a collection link, naming your new collection, and clicking Add. When you submit the action, your selection will be added to this newly created collection.