Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Keys.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package org.apache.archiva.model;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import org.apache.commons.lang.StringUtils;
  21. /**
  22. * Keys - utility methods for converting common objects into string keys.
  23. *
  24. *
  25. */
  26. public class Keys
  27. {
  28. public static String toKey( String groupId, String artifactId, String version, String classifier, String type )
  29. {
  30. StringBuffer key = new StringBuffer();
  31. key.append( groupId ).append( ":" );
  32. key.append( artifactId ).append( ":" );
  33. key.append( version ).append( ":" );
  34. key.append( StringUtils.defaultString( classifier ) ).append( ":" );
  35. key.append( type );
  36. return key.toString();
  37. }
  38. public static String toKey( ArtifactReference ref )
  39. {
  40. return toKey( ref.getGroupId(), ref.getArtifactId(), ref.getVersion(), ref.getClassifier(), ref.getType() );
  41. }
  42. public static String toKey( ProjectReference ref )
  43. {
  44. StringBuffer key = new StringBuffer();
  45. key.append( ref.getGroupId() ).append( ":" );
  46. key.append( ref.getArtifactId() );
  47. return key.toString();
  48. }
  49. public static String toKey( String groupId, String artifactId, String version )
  50. {
  51. StringBuffer key = new StringBuffer();
  52. key.append( groupId ).append( ":" );
  53. key.append( artifactId ).append( ":" );
  54. key.append( version );
  55. return key.toString();
  56. }
  57. public static String toKey( VersionedReference ref )
  58. {
  59. return toKey( ref.getGroupId(), ref.getArtifactId(), ref.getVersion() );
  60. }
  61. }