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.

ZXBookmarkDoCoMoResultParser.m 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright 2012 ZXing authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "ZXBookmarkDoCoMoResultParser.h"
  17. #import "ZXResult.h"
  18. #import "ZXURIParsedResult.h"
  19. #import "ZXURIResultParser.h"
  20. @implementation ZXBookmarkDoCoMoResultParser
  21. - (ZXParsedResult *)parse:(ZXResult *)result {
  22. NSString *rawText = [result text];
  23. if (![rawText hasPrefix:@"MEBKM:"]) {
  24. return nil;
  25. }
  26. NSString *title = [[self class] matchSingleDoCoMoPrefixedField:@"TITLE:" rawText:rawText trim:YES];
  27. NSArray *rawUri = [[self class] matchDoCoMoPrefixedField:@"URL:" rawText:rawText trim:YES];
  28. if (rawUri == nil) {
  29. return nil;
  30. }
  31. NSString *uri = rawUri[0];
  32. if (![ZXURIResultParser isBasicallyValidURI:uri]) {
  33. return nil;
  34. }
  35. return [ZXURIParsedResult uriParsedResultWithUri:uri title:title];
  36. }
  37. @end